:root {
  --bg: #f6f1ea;
  --card: #fffdf9;
  --ink: #2a241f;
  --muted: #756a5f;
  --line: #e4dacd;
  --accent: #b5532f;
  --accent-ink: #fffaf4;
  --soft: #f0e3d6;
  --danger: #b3261e;
  --ok: #3f7d4e;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 6px 20px rgba(60, 40, 20, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1a17;
    --card: #282420;
    --ink: #f3ece3;
    --muted: #a99c8e;
    --line: #3a342e;
    --accent: #e0835c;
    --accent-ink: #1d1410;
    --soft: #352c25;
    --danger: #f2877f;
    --ok: #86c296;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
#app {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 110px);
  min-height: 100dvh;
}
h1 { font-size: 26px; line-height: 1.2; margin: 0; letter-spacing: -.01em; text-wrap: balance; }
h2 { font-size: 19px; margin: 0 0 10px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
[hidden] { display: none !important; }

/* Top bar */
.bar { display: flex; align-items: center; gap: 10px; min-height: 52px; margin-bottom: 14px; }
.bar h1 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.bar .who { color: var(--muted); font-size: 14px; }

/* Buttons */
button, .btn {
  font: inherit; color: inherit; cursor: pointer;
  border: 1px solid var(--line); background: var(--card);
  border-radius: 14px; padding: 12px 16px; min-height: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  touch-action: manipulation;
}
button:active { transform: scale(.98); }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px;
}
.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.ghost { border-color: transparent; background: transparent; padding: 10px 12px; }
.danger { color: var(--danger); }
.wide { width: 100%; }
.big { min-height: 60px; font-size: 19px; border-radius: 18px; }
.icon { width: 22px; height: 22px; flex: none; }

.fab {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  width: min(688px, calc(100vw - 32px));
  box-shadow: 0 8px 24px rgba(120, 50, 20, .28);
}
.fab:active { transform: translateX(-50%) scale(.98); }

/* Cards & list */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.row { display: flex; gap: 14px; align-items: center; width: 100%; text-align: left;
  padding: 12px; border-radius: var(--radius); margin-bottom: 10px; box-shadow: var(--shadow); }
.row .thumb { width: 68px; height: 68px; border-radius: 12px; object-fit: cover; flex: none; background: var(--soft); }
.row .thumb.none { display: grid; place-items: center; color: var(--muted); }
.row .body { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow-wrap: anywhere; }
.row .meta { color: var(--muted); font-size: 14px; }
.badge { background: var(--accent); color: var(--accent-ink); border-radius: 999px;
  min-width: 26px; height: 26px; padding: 0 8px; display: grid; place-items: center;
  font-size: 14px; font-weight: 700; flex: none; }
.empty { text-align: center; color: var(--muted); padding: 56px 16px; }

/* Forms */
label { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 6px; }
input[type=text], input[type=tel], input[type=password], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; min-height: 48px;
}
textarea { min-height: 96px; resize: vertical; }
.check { display: flex; align-items: center; gap: 10px; margin: 14px 0 0; font-size: 16px; color: var(--ink); }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.err { color: var(--danger); margin: 10px 0 0; min-height: 1.4em; }

/* PIN pad */
.pin-wrap { max-width: 340px; margin: 8vh auto 0; text-align: center; }
.pin-wrap h1 { margin-bottom: 6px; }
.dots { display: flex; justify-content: center; gap: 14px; margin: 26px 0 8px; min-height: 18px; }
.dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--muted); }
.dots i.on { background: var(--accent); border-color: var(--accent); }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.pad button { min-height: 68px; font-size: 26px; border-radius: 20px; font-variant-numeric: tabular-nums; }
.pad .go { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-size: 18px; font-weight: 600; }

/* Compose */
.pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pick button { flex-direction: column; min-height: 84px; font-size: 15px; padding: 10px 6px; }
.strip { display: flex; gap: 10px; overflow-x: auto; padding: 12px 0 2px; }
.strip .item { position: relative; flex: none; }
.strip img, .strip video { width: 104px; height: 104px; object-fit: cover; border-radius: 14px; background: var(--soft); display: block; }
.strip .x { position: absolute; top: -8px; right: -8px; width: 32px; height: 32px; min-height: 0; padding: 0;
  border-radius: 50%; background: var(--ink); color: var(--bg); border: 0; font-size: 18px; line-height: 1; }
.strip .tag { position: absolute; left: 6px; bottom: 6px; background: rgba(0,0,0,.6); color: #fff;
  font-size: 12px; padding: 2px 7px; border-radius: 8px; }
.mic { width: 100%; min-height: 76px; font-size: 19px; font-weight: 600; border-radius: 20px;
  background: var(--soft); border-color: transparent; }
.mic.rec { background: var(--danger); color: #fff; }
.mic .dot { width: 14px; height: 14px; border-radius: 50%; background: #fff; }
@media (prefers-reduced-motion: no-preference) {
  .mic.rec .dot { animation: pulse 1s ease-in-out infinite; }
  .spin { animation: spin 1s linear infinite; }
}
@keyframes pulse { 50% { opacity: .25; } }
@keyframes spin { to { transform: rotate(360deg); } }
.recorded { display: flex; gap: 10px; align-items: center; }
.recorded audio { flex: 1; min-width: 0; }
audio { width: 100%; height: 48px; }
.progress { height: 8px; border-radius: 99px; background: var(--soft); overflow: hidden; margin-top: 12px; }
.progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* Thread */
.msg .head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; margin-bottom: 8px; }
.msg .name { font-weight: 600; }
.msg.mine { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.msg .text { font-size: 20px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; margin: 4px 0 12px; }
.media { display: grid; gap: 10px; margin-bottom: 12px; }
.media img, .media video { width: 100%; max-height: 70vh; object-fit: contain; border-radius: 14px; background: #000; display: block; }
details { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
summary { color: var(--muted); font-size: 15px; cursor: pointer; min-height: 32px; }
details .text { font-size: 16px; color: var(--muted); margin-bottom: 8px; }
.working { display: flex; gap: 10px; align-items: center; color: var(--muted); }
.spin { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); flex: none; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* People */
.person { display: flex; align-items: center; gap: 12px; }
.person .body { flex: 1; min-width: 0; }
.pill { font-size: 12px; background: var(--soft); border-radius: 99px; padding: 2px 9px; margin-left: 6px; color: var(--muted); }
