/* Samar's chats: one calm stylesheet. Phone first; two columns from 900 px. Light and dark. */
:root {
  color-scheme: light dark;
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #eceeea;
  --chat-bg: #efeee8;
  --text: #1b2320;
  --muted: #5c6a65;
  --faint: #8a9692;
  --line: #dfe3de;
  --accent: #1d6b5a;
  --accent-strong: #145244;
  --accent-ink: #ffffff;
  --accent-soft: #d9ede6;
  --mine: #dcefe6;
  --theirs: #ffffff;
  --danger: #b0302a;
  --danger-soft: #f8e1df;
  --warn: #7a5a00;
  --warn-soft: #fbf0cf;
  --focus: #2266cc;
  --shadow: 0 1px 1px rgba(20, 30, 25, 0.06), 0 1px 3px rgba(20, 30, 25, 0.06);
  --radius: 12px;
  --tap: 40px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412;
    --surface: #171e1b;
    --surface-2: #212a26;
    --chat-bg: #121815;
    --text: #e4ebe8;
    --muted: #9aa8a3;
    --faint: #73817c;
    --line: #2a3530;
    --accent: #5bbf9f;
    --accent-strong: #8fd8bf;
    --accent-ink: #0b1310;
    --accent-soft: #1d3a31;
    --mine: #1c3a30;
    --theirs: #1d2522;
    --danger: #f08a80;
    --danger-soft: #3a1f1d;
    --warn: #f2cf6b;
    --warn-soft: #3a3118;
    --focus: #7fb0ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
#app { height: 100%; }
a { color: var(--accent-strong); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.icon { flex: none; display: block; }

/* ---------- buttons and fields ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none; white-space: nowrap; font-weight: 500;
}
.button:hover { background: var(--surface-2); }
.button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.button.primary:hover { background: var(--accent-strong); }
.button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.button.danger:hover { background: var(--danger-soft); }
.button.quiet { border-color: transparent; background: transparent; color: var(--accent-strong); }
.button.quiet:hover { background: var(--accent-soft); }
.button[disabled] { opacity: 0.55; cursor: default; }
.button.compact { min-height: 34px; padding: 0 10px; font-size: 0.9rem; }
.narrow .button.compact, .login .button.compact { min-height: var(--tap); }
.icon-button {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap); flex: none; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted); cursor: pointer; padding: 0;
}
.icon-button:hover { background: var(--surface-2); color: var(--text); }
.field { display: grid; gap: 4px; }
.field label, .label { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: var(--tap); padding: 8px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface); color: var(--text);
}
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 88px; }
.error { color: var(--danger); font-size: 0.9rem; }
.notice { background: var(--warn-soft); color: var(--warn); padding: 10px 12px; border-radius: 10px; font-size: 0.92rem; }
.notice.calm { background: var(--accent-soft); color: var(--accent-strong); }
.tag {
  display: inline-block; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.01em;
  padding: 1px 6px; border-radius: 6px; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.tag.business { background: #e3ecf8; color: #2b4f7e; }
.tag.personal { background: #f3e6ef; color: #7a3b66; }
@media (prefers-color-scheme: dark) {
  .tag.business { background: #1f2c3d; color: #a9c4ea; }
  .tag.personal { background: #35222f; color: #e2b2d3; }
}
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.badge.ok { background: var(--accent-soft); color: var(--accent-strong); }

/* ---------- avatars and faces ---------- */
.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 0.95rem; color: #fff; user-select: none;
}
.avatar.big { width: 40px; height: 40px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.c0 { background: #3f7f73; } .c1 { background: #7a6a3a; } .c2 { background: #4c6a9a; } .c3 { background: #9a4c5e; }
.c4 { background: #5d7d3b; } .c5 { background: #7b5296; } .c6 { background: #a0623a; } .c7 { background: #3d6f8f; }
.faces { display: inline-flex; flex: none; }
.face {
  width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.62rem; font-weight: 700; color: #fff; border: 2px solid var(--surface); margin-left: -6px;
}
.face:first-child { margin-left: 0; }
.face.more { background: var(--surface-2); color: var(--muted); }

/* ---------- the frame ---------- */
.app { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; height: 100dvh; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 0 12px 0 16px; min-height: 52px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.05rem; }
.brand .icon { color: var(--accent); }
.topnav { display: flex; gap: 2px; margin-left: 12px; }
.topnav a {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-weight: 500;
}
.topnav a:hover { background: var(--surface-2); color: var(--text); }
.topnav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); }
.whoami { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.9rem; }
.main { min-height: 0; overflow: hidden; }
.tabbar {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 56px; color: var(--muted); text-decoration: none; font-size: 0.72rem; font-weight: 600;
}
.tabbar a[aria-current="page"] { color: var(--accent-strong); }
.topbar { grid-row: 1; }
.link-banner { grid-row: 2; }
.main { grid-row: 3; }
.tabbar { grid-row: 4; }
/* the owner's banner when a number's link is down (on every page, the chat on a phone too) */
.link-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 6px 12px 6px 16px;
  background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--line); font-size: 0.92rem;
}
.link-banner p { margin: 0; flex: 1 1 220px; }
.link-banner .button { color: var(--warn); border-color: currentColor; background: transparent; }
.narrow.route-chat .topbar, .narrow.route-chat .tabbar { display: none; }

.split { display: grid; height: 100%; min-height: 0; }
.wide .split { grid-template-columns: minmax(320px, 380px) minmax(0, 1fr); }
.narrow .split { grid-template-columns: minmax(0, 1fr); }
.narrow.route-chat .inbox { display: none; }
.narrow.route-inbox .chat-pane { display: none; }
.page { height: 100%; overflow-y: auto; }
.page-inner { max-width: 760px; margin: 0 auto; padding: 16px 16px 40px; display: grid; gap: 16px; align-content: start; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; }
.card h2 { display: flex; align-items: center; gap: 8px; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); display: grid; gap: 10px; justify-items: center; align-content: center; height: 100%; }
.empty h2 { color: var(--text); font-size: 1.2rem; }

/* ---------- inbox ---------- */
.inbox { display: flex; flex-direction: column; min-height: 0; height: 100%; background: var(--surface); }
.wide .inbox { border-right: 1px solid var(--line); }
.inbox-tools { display: grid; gap: 8px; padding: 10px 12px 8px; border-bottom: 1px solid var(--line); }
.search-line { display: flex; gap: 8px; align-items: center; }
.search-box { position: relative; flex: 1; }
.search-box .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search-box input { padding-left: 36px; border-radius: 20px; background: var(--surface-2); border-color: transparent; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface-2); border-radius: 10px; padding: 2px; }
.seg button {
  min-height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font-weight: 500; cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.narrow .seg button, .narrow .chip { min-height: var(--tap); }
.narrow .chip { border-radius: 20px; }
.inbox-scroll { flex: 1; overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.list { list-style: none; margin: 0; padding: 0; }
mark { background: var(--warn-soft); color: inherit; border-radius: 3px; padding: 0 1px; }
.list-title { padding: 12px 16px 4px; font-size: 0.78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 68px; padding: 8px 14px;
  color: inherit; text-decoration: none; background: transparent; border: 0; text-align: left; cursor: pointer;
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
.row:hover { background: var(--surface-2); }
.row.is-active { background: var(--accent-soft); }
.row.is-cursor { box-shadow: inset 3px 0 0 var(--accent); }
.row-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.row-top, .row-bottom { display: flex; align-items: center; gap: 6px; min-width: 0; }
.row-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-time { margin-left: auto; font-size: 0.78rem; color: var(--faint); flex: none; }
.row.has-unread .row-time { color: var(--accent-strong); font-weight: 600; }
.row-preview { flex: 1; min-width: 0; color: var(--muted); font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unread {
  flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent);
  color: var(--accent-ink); font-size: 0.75rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.tick {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--faint); flex: none;
  display: inline-flex; align-items: center; justify-content: center; color: var(--accent-ink);
}
.row[aria-checked="true"] .tick { background: var(--accent); border-color: var(--accent); }
.row[aria-checked="true"] { background: var(--accent-soft); }
.select-bar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line);
  background: var(--surface); padding-bottom: calc(8px + env(safe-area-inset-bottom));
}
.select-bar .count { font-weight: 600; margin-right: auto; }
.more-line { display: flex; justify-content: center; padding: 12px; }
.search-hit { display: grid; gap: 2px; padding: 10px 16px; color: inherit; text-decoration: none; border-bottom: 1px solid var(--line); }
.search-hit:hover { background: var(--surface-2); }
.search-hit .hit-top { display: flex; gap: 8px; font-size: 0.85rem; }
.search-hit .hit-chat { font-weight: 600; }
.search-hit .hit-time { margin-left: auto; color: var(--faint); }
.search-hit .hit-text { color: var(--muted); font-size: 0.9rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.status-line { padding: 20px 16px; color: var(--muted); text-align: center; }

/* ---------- chat ---------- */
.chat-pane { min-height: 0; height: 100%; display: flex; flex-direction: column; background: var(--chat-bg); }
.chat-head {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px; min-height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.chat-title { flex: 1; min-width: 0; display: grid; gap: 1px; }
.chat-title h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.02rem; }
.chat-sub { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--muted); min-width: 0; flex-wrap: wrap; }
.chat-actions { display: flex; gap: 6px; flex: none; }
.narrow .chat-actions .label-text { display: none; }
.views-line { font-size: 0.78rem; color: var(--muted); }
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 10px 14px; overscroll-behavior: contain; }
.wide .messages { padding: 14px 24px 18px; }
.older-line { display: flex; justify-content: center; padding: 6px 0 12px; }
.day { display: flex; justify-content: center; margin: 12px 0 8px; }
.day span { background: var(--surface); color: var(--muted); font-size: 0.75rem; font-weight: 600; padding: 3px 10px; border-radius: 8px; box-shadow: var(--shadow); }
.line { display: flex; justify-content: center; margin: 6px 0; }
.line > span {
  display: inline-flex; align-items: center; gap: 6px; max-width: 90%; text-align: center;
  background: var(--surface-2); color: var(--muted); font-size: 0.8rem; padding: 4px 10px; border-radius: 8px;
}
.line time { color: var(--faint); font-size: 0.72rem; }
.line.call > span { color: var(--text); }
.line.call.missed > span { color: var(--danger); }
.line.system > span { border: 1px dashed var(--line); background: transparent; }
.msg { display: flex; align-items: flex-end; gap: 2px; margin: 3px 0; }
.msg.mine { flex-direction: row-reverse; }
.msg-col { display: grid; gap: 2px; max-width: min(560px, 84%); min-width: 0; justify-items: start; }
.msg.mine .msg-col { justify-items: end; }
.bubble {
  position: relative; background: var(--theirs); border-radius: 12px; padding: 6px 10px 5px; box-shadow: var(--shadow);
  min-width: 72px; max-width: 100%; overflow-wrap: anywhere;
}
.msg.mine .bubble { background: var(--mine); }
.bubble.bare { background: transparent; box-shadow: none; padding: 0; }
.msg.is-target .bubble { outline: 2px solid var(--accent); outline-offset: 2px; }
.msg.is-deleted .bubble { opacity: 0.85; }
.sender { font-size: 0.8rem; font-weight: 700; color: var(--accent-strong); margin-bottom: 2px; }
.flag { font-size: 0.75rem; font-style: italic; color: var(--muted); margin-bottom: 2px; display: flex; align-items: center; gap: 4px; }
.flag.deleted { font-style: normal; font-weight: 600; color: var(--danger); }
.text { white-space: pre-wrap; }
.msg.is-deleted .text { color: var(--muted); }
.bubble-meta { display: flex; justify-content: flex-end; align-items: center; gap: 6px; font-size: 0.7rem; color: var(--faint); margin-top: 2px; }
.bubble-meta .edited { font-style: italic; }
.msg-actions { width: var(--tap); height: var(--tap); color: var(--faint); align-self: center; }
.wide .msg-actions { opacity: 0; }
.wide .msg:hover .msg-actions, .wide .msg:focus-within .msg-actions { opacity: 1; }
.quote {
  display: block; width: 100%; text-align: left; border: 0; border-left: 3px solid var(--accent); background: rgba(0, 0, 0, 0.04);
  border-radius: 6px; padding: 4px 8px; margin-bottom: 4px; font-size: 0.85rem; color: var(--muted); cursor: pointer;
}
@media (prefers-color-scheme: dark) { .quote { background: rgba(255, 255, 255, 0.05); } }
.narrow .quote { min-height: var(--tap); }
.quote span { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.reactions { display: flex; gap: 4px; flex-wrap: wrap; padding: 0 4px; }
.reaction { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; font-size: 0.8rem; padding: 0 6px; line-height: 20px; }
.photo-button { display: block; border: 0; padding: 0; background: transparent; cursor: zoom-in; border-radius: 8px; overflow: hidden; }
.photo, .video, .gif { display: block; max-width: 100%; height: auto; border-radius: 8px; background: var(--surface-2); }
.photo { max-height: 340px; width: auto; }
.video, .gif { max-height: 320px; width: 100%; }
.sticker { display: block; width: 128px; height: 128px; object-fit: contain; }
.media-caption { margin-top: 4px; }
.media-wait {
  display: grid; gap: 6px; justify-items: start; padding: 10px 12px; border-radius: 8px; background: var(--surface-2);
  color: var(--muted); font-size: 0.88rem; min-width: 200px;
}
.voice { display: flex; align-items: center; gap: 8px; }
.voice audio, .audio audio { height: 40px; max-width: 260px; }
.dur { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.transcript { margin-top: 6px; padding: 6px 8px; border-radius: 8px; background: rgba(0, 0, 0, 0.04); font-size: 0.9rem; white-space: pre-wrap; }
@media (prefers-color-scheme: dark) { .transcript { background: rgba(255, 255, 255, 0.05); } }
.transcript-label { display: block; font-size: 0.72rem; font-weight: 700; color: var(--muted); margin-bottom: 2px; }
.doc, .place, .card-msg {
  display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; background: rgba(0, 0, 0, 0.04); min-width: 220px;
}
@media (prefers-color-scheme: dark) { .doc, .place, .card-msg { background: rgba(255, 255, 255, 0.05); } }
.doc .icon, .place .icon, .card-msg .icon { color: var(--accent); }
.doc-main, .place-main, .card-main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.doc-name, .place-name, .card-name { font-weight: 600; overflow-wrap: anywhere; }
.poll { display: grid; gap: 8px; min-width: 240px; }
.poll-q { font-weight: 600; }
.opt { display: grid; gap: 3px; }
.opt-top { display: flex; justify-content: space-between; gap: 8px; font-size: 0.92rem; }
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.voters { font-size: 0.75rem; color: var(--muted); }
.placeholder { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.9rem; padding: 8px; border-radius: 8px; background: var(--surface-2); min-width: 220px; }
.ph-main { display: grid; gap: 1px; }
.event-card { display: grid; gap: 2px; padding: 8px 10px; border-left: 3px solid var(--accent); border-radius: 6px; background: rgba(0, 0, 0, 0.03); }
.composer { background: var(--surface); border-top: 1px solid var(--line); padding: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); display: grid; gap: 6px; }
.composer-row { display: flex; align-items: flex-end; gap: 4px; }
.composer textarea {
  flex: 1; min-height: var(--tap); max-height: 160px; resize: none; border: 1px solid var(--line); border-radius: 20px;
  padding: 9px 14px; background: var(--surface-2); line-height: 1.35;
}
.composer textarea:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.send-button { background: var(--accent); color: var(--accent-ink); }
.send-button:hover { background: var(--accent-strong); color: var(--accent-ink); }
.composer-bar { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; background: var(--surface-2); border-radius: 8px; padding: 4px 4px 4px 10px; }
.composer-bar .what { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recording { color: var(--danger); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.recording::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.read-only { padding: 10px 14px; font-size: 0.85rem; color: var(--muted); text-align: center; background: var(--surface); border-top: 1px solid var(--line); }

/* ---------- sheets, viewer, toasts ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(10, 15, 13, 0.4);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-height: 88dvh; overflow-y: auto; background: var(--surface); color: var(--text);
  border-radius: 16px 16px 0 0; padding: 6px 16px calc(16px + env(safe-area-inset-bottom)); display: grid; gap: 12px;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
}
.wide .sheet-backdrop { align-items: center; }
.wide .sheet { width: min(460px, 92vw); border-radius: 14px; padding: 6px 18px 18px; }
.wide .sheet.sheet-wide { width: min(620px, 92vw); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; position: sticky; top: 0; background: var(--surface); }
.sheet-text { color: var(--muted); }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.sheet-list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.sheet-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 6px 8px; border: 0;
  border-radius: 10px; background: transparent; text-align: left; cursor: pointer; color: var(--text);
}
.sheet-item:hover { background: var(--surface-2); }
.sheet-item.danger { color: var(--danger); }
.sheet-item .icon { color: var(--muted); }
.emoji-row { display: flex; gap: 4px; flex-wrap: wrap; }
.emoji-row button { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-size: 1.3rem; cursor: pointer; }
.emoji-row button:hover { background: var(--surface-2); }
.preview-text { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; font-size: 0.9rem; color: var(--muted); white-space: pre-wrap; max-height: 120px; overflow: hidden; }
.person-pick { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 4px 6px; border-radius: 10px; cursor: pointer; }
.person-pick:hover { background: var(--surface-2); }
.person-pick input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.person-pick .who { flex: 1; display: grid; }
.viewer {
  position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, 0.92); display: grid; grid-template-rows: auto 1fr; color: #fff;
}
.viewer-bar { display: flex; justify-content: flex-end; gap: 8px; padding: 8px; }
.viewer-bar .button { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.4); }
.viewer-bar .icon-button { color: #fff; }
.viewer img { max-width: 100%; max-height: 100%; margin: auto; object-fit: contain; display: block; min-height: 0; }
.viewer-body { min-height: 0; display: flex; padding: 0 8px 16px; }
/* one toast, above everything (sheets too): above the tab bar on a phone (above the reply box in a chat, where the
   tab bar is hidden), at the bottom of the screen on a computer. A tap closes it. */
.toasts {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 80; display: grid; justify-items: center;
  pointer-events: none; width: max-content; max-width: calc(100vw - 32px);
  bottom: calc(57px + 12px + env(safe-area-inset-bottom));
}
.narrow.route-chat .toasts { bottom: calc(66px + env(safe-area-inset-bottom)); }
.wide .toasts { bottom: 24px; }
.toast {
  pointer-events: auto; min-height: var(--tap); padding: 9px 16px; border: 0; border-radius: 10px; font: inherit; font-size: 0.9rem;
  text-align: center; background: #1d2522; color: #f1f5f3; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2); cursor: pointer;
}
.toast.bad { background: #6d1f1a; }

/* ---------- tasks ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs [role="tab"] {
  min-height: var(--tap); padding: 0 14px; border: 0; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs [role="tab"][aria-selected="true"] { color: var(--accent-strong); border-bottom-color: var(--accent); }
.bulk-bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; border-radius: 10px; background: var(--accent-soft); }
.bulk-bar .count { font-weight: 600; margin-right: auto; color: var(--accent-strong); }
.tasks { display: grid; gap: 10px; list-style: none; margin: 0; padding: 0; }
.task { display: flex; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.task-tick { display: flex; align-items: flex-start; justify-content: center; width: var(--tap); min-height: var(--tap); flex: none; padding-top: 8px; cursor: pointer; }
.task-tick input { width: 20px; height: 20px; accent-color: var(--accent); }
.task-main { flex: 1; min-width: 0; display: grid; gap: 6px; }
.task-title { font-weight: 600; }
.task-quote { margin: 0; padding: 4px 10px; border-left: 3px solid var(--line); color: var(--muted); font-size: 0.92rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.task-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; font-size: 0.82rem; color: var(--muted); }
.task-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ---------- people, setup, settings ---------- */
.people { list-style: none; margin: 0; padding: 0; display: grid; }
.person { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.person:last-child { border-bottom: 0; }
.person-main { flex: 1; min-width: 0; display: grid; }
.person-name { font-weight: 600; }
.form-grid { display: grid; gap: 12px; }
.wide .form-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.wide .form-grid.three > :nth-child(n+4) { grid-column: 1 / -1; }
.state { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.state::before { flex: none; }
.state::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--faint); }
.state-open::before { background: #2e9d6d; }
.state-qr::before, .state-connecting::before { background: #d39b19; }
.state-closed::before, .state-logged_out::before { background: var(--danger); }
.qr { display: grid; gap: 8px; justify-items: center; padding: 12px; background: #fff; border-radius: 12px; color: #1b2320; }
.qr img { width: 240px; height: 240px; image-rendering: pixelated; }
.secret-state { font-weight: 600; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { flex: 1; min-width: 200px; }
.facts { display: grid; gap: 4px; font-size: 0.92rem; }
.left-out { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.left-out li { display: flex; align-items: center; gap: 8px; justify-content: space-between; min-height: var(--tap); }

/* ---------- sign in ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); display: grid; gap: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px 20px; }
.login-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.login form { display: grid; gap: 12px; }
.login .code-input { font-size: 1.4rem; letter-spacing: 0.3em; text-align: center; font-variant-numeric: tabular-nums; }
