/* Chat Desk — an interpreter's desk: English carries the line, the original sits beneath it as a gloss. */
:root {
  --bg: #e9edf1;
  --surface: #ffffff;
  --ink: #16202b;
  --muted: #677382;
  --gloss: #7d6a52;          /* the original-language line: warm, like pencil annotation */
  --line: #d6dce3;
  --accent: #2b59c3;         /* cobalt: actions and your own words */
  --accent-ink: #ffffff;
  --out: #dfe8fb;
  --in: #ffffff;
  --warn: #b5432c;
  --warn-bg: #fbe9e4;
  --ok: #2c7a4b;
  --hold-bg: #fff4d6;
  --shadow: 0 1px 2px rgba(22, 32, 43, .08);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --gloss-font: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --r: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f151c; --surface: #17202a; --ink: #e7ecf2; --muted: #93a0ae; --gloss: #c9b291;
    --line: #26323f; --accent: #6f95f2; --accent-ink: #0b1220; --out: #1f3156; --in: #1b2531;
    --warn: #f08a72; --warn-bg: #3a2019; --ok: #6fcf97; --hold-bg: #3a3116; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.4 var(--sans); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

#app { height: 100dvh; display: flex; flex-direction: column; }

/* ---- top bar: one tab per number */
.top { display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: var(--ink); color: #fff; }
@media (prefers-color-scheme: dark) { .top { background: #0a0f14; } }
.phones { display: flex; gap: 6px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.phone-tab { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px; border: 0;
  background: rgba(255,255,255,.08); color: #cfd8e3; white-space: nowrap; font-size: 15px; }
.phone-tab.on { background: #fff; color: #16202b; font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #4cc38a; flex: none; }
.dot.off { background: #f06b52; }
.dot.warn { background: #f2b33d; }
.badge { min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--accent); color: #fff;
  font-size: 12px; font-weight: 700; text-align: center; }
.icon-btn { border: 0; background: transparent; font-size: 20px; width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center; flex: none; }
.top .icon-btn { color: #fff; }
.icon-btn:hover { background: rgba(127,127,127,.12); }

/* ---- banners */
.banner { padding: 10px 14px; font-size: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  border-bottom: 1px solid var(--line); }
.banner.off { background: var(--warn-bg); color: var(--warn); }
.banner.hold { background: var(--hold-bg); }
.banner .spacer { flex: 1; }
.banner button { border: 1px solid currentColor; background: transparent; border-radius: 8px; padding: 4px 10px; font-size: 13px; }

/* ---- panes */
.panes { flex: 1; display: flex; min-height: 0; }
.list-pane { width: 100%; display: flex; flex-direction: column; background: var(--surface); position: relative; min-height: 0; }
.chat-pane { display: none; flex: 1; min-width: 0; flex-direction: column; min-height: 0; }
body.in-chat .list-pane { display: none; }
body.in-chat .chat-pane { display: flex; }
@media (min-width: 900px) {
  .list-pane { width: 360px; flex: none; border-right: 1px solid var(--line); }
  .chat-pane, body.in-chat .chat-pane { display: flex; }
  body.in-chat .list-pane { display: flex; }
  .back { display: none !important; }
}

.seg { display: flex; margin: 10px 12px 0; background: var(--bg); border-radius: 10px; padding: 3px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 7px; border-radius: 8px; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.search { padding: 10px 12px; }
.search input { width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
  color: var(--ink); font-size: 15px; }
.list { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.filters { display: flex; gap: 6px; padding: 0 12px 8px; overflow-x: auto; scrollbar-width: none; }
.filters:empty { display: none; }
.fchip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 11px; font-size: 13px;
  white-space: nowrap; color: var(--muted); }
.fchip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.lab { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; margin-right: 4px;
  --lab: var(--accent); background: color-mix(in srgb, var(--lab) 16%, transparent); color: var(--lab); }
.row-labels { margin-top: 3px; }
.section-head { padding: 10px 14px 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.hit mark { background: color-mix(in srgb, #f2b33d 45%, transparent); color: inherit; border-radius: 3px; }
.note-bar { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line);
  background: var(--hold-bg); padding: 7px 14px; font-size: 14px; }
.reply-bar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--surface); border-top: 1px solid var(--line); }
.reply-quote { flex: 1; min-width: 0; border-left: 3px solid var(--accent); padding: 2px 8px; font-size: 13px; }
.reply-quote div:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.reply-who { font-weight: 600; color: var(--accent); font-size: 12px; }
.proof-warn { background: var(--hold-bg); padding: 8px 14px; font-size: 14px; border-top: 1px solid var(--line); }
.msg .quote { border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--ink) 5%, transparent);
  border-radius: 6px; padding: 4px 8px; margin-bottom: 5px; font-size: 13px; color: var(--muted); }
.msg .quote b { display: block; color: var(--accent); font-size: 12px; }
.msg .reply-btn { border: 0; background: none; color: var(--muted); font-size: 13px; padding: 0 2px; cursor: pointer; }
.msg.flash { outline: 3px solid #f2b33d; outline-offset: 2px; }
.row { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 11px 14px; border-bottom: 1px solid var(--line); }
.row:hover, .row.on { background: var(--bg); }
.avatar { width: 50px; height: 50px; flex: none; border-radius: 50%; background: var(--bg); color: var(--muted); display: grid;
  place-items: center; font-weight: 600; flex: none; font-size: 15px; }
.row-main { flex: 1; min-width: 0; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.avatar { overflow: hidden; }
.head-avatar { width: 44px; height: 44px; font-size: 14px; cursor: zoom-in; }
.row-top { display: flex; gap: 8px; align-items: baseline; }
.row-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-name .tilde { color: var(--muted); font-weight: 400; }
.row-time { color: var(--muted); font-size: 12px; flex: none; }
.row.unread .row-time { color: var(--accent); font-weight: 600; }
.row-bottom { display: flex; gap: 8px; align-items: center; margin-top: 2px; }
.row-preview { flex: 1; min-width: 0; color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.unread .row-preview { color: var(--ink); }
.wa { color: var(--ok); font-size: 12px; flex: none; }
.list-note { padding: 18px 16px; color: var(--muted); font-size: 14px; }
.row.archived-entry .avatar { background: transparent; font-size: 20px; }
.row.archived-entry .row-name { font-weight: 600; }
.list-head { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--line);
  font-weight: 650; }
.fab { position: absolute; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); width: 52px; height: 52px;
  border-radius: 16px; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 24px;
  box-shadow: 0 4px 14px rgba(43, 89, 195, .35); }

/* ---- conversation */
.empty-chat { flex: 1; display: grid; place-items: center; padding: 24px; color: var(--muted); text-align: center; }
.empty-chat p { max-width: 300px; }
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--surface);
  border-bottom: 1px solid var(--line); }
.who { flex: 1; min-width: 0; }
.who-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 440px) { #lang-chip { display: none; } }  /* language stays in the chat ⋯ menu */
.chip { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 4px 10px; font-size: 13px;
  font-weight: 600; letter-spacing: .04em; flex: none; }

.msgs { flex: 1; overflow-y: auto; padding: 12px 12px 16px; display: flex; flex-direction: column; gap: 6px;
  overscroll-behavior: contain; }
.day { align-self: center; color: var(--muted); font-size: 12px; padding: 8px 0 2px; }
.msg { max-width: min(78%, 560px); padding: 8px 11px 6px; border-radius: var(--r); box-shadow: var(--shadow);
  position: relative; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.in { align-self: flex-start; background: var(--in); border-top-left-radius: 4px; }
.msg.out { align-self: flex-end; background: var(--out); border-top-right-radius: 4px; }
.msg .primary-line { white-space: pre-wrap; }
/* the signature: the original language as an interlinear gloss */
.msg .gloss { white-space: pre-wrap; font-family: var(--gloss-font); font-style: italic; color: var(--gloss);
  font-size: 14px; margin-top: 3px; padding-top: 3px; border-top: 1px dashed color-mix(in srgb, var(--gloss) 35%, transparent); }
.msg.swapped .primary-line { font-family: var(--gloss-font); font-style: italic; }
.msg.swapped .gloss { font-family: var(--sans); font-style: normal; color: var(--muted); }
.msg .meta { display: flex; gap: 6px; justify-content: flex-end; align-items: center; color: var(--muted); font-size: 11px; margin-top: 3px; }
.msg .lang { text-transform: uppercase; letter-spacing: .06em; }
.msg .pending { color: var(--muted); font-size: 13px; }
.msg .pending::after { content: "…"; animation: blink 1.2s steps(3) infinite; }
@keyframes blink { 50% { opacity: .3; } }
.msg img.photo, .msg video.video { display: block; width: min(340px, 68vw); max-width: 100%; height: auto; max-height: 460px;
  object-fit: cover; border-radius: 10px; margin: 2px 0 4px; cursor: zoom-in; background: var(--bg); }
.msg video.video { cursor: default; object-fit: contain; background: #000; }
.lightbox img { width: auto; height: auto; min-width: min(92vw, 520px); object-fit: contain; }
.msg audio { width: 240px; max-width: 100%; height: 36px; display: block; margin: 2px 0 4px; }
.msg .kind { color: var(--muted); font-size: 14px; }
.msg .err { color: var(--warn); font-size: 13px; }
.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; font-size: inherit; }
.msg.out.failed { background: var(--warn-bg); }
.status { font-size: 11px; }
.status.sent { color: var(--ok); }
.status.failed { color: var(--warn); font-weight: 600; }
.fail-box { margin-top: 4px; font-size: 13px; color: var(--warn); }
.fail-box .acts { display: flex; gap: 12px; margin-top: 4px; }

/* ---- proof panel: what will actually go out */
.proof { background: var(--surface); border-top: 1px solid var(--line); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.proof-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.proof textarea { width: 100%; resize: none; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
  font: 16px/1.4 var(--gloss-font); font-style: italic; color: var(--ink); background: var(--bg); max-height: 30vh; }
.means { font-size: 14px; color: var(--ink); }
.means-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-right: 4px; }
.proof.stale .means #proof-back { color: var(--muted); text-decoration: line-through; }
.proof-actions { display: flex; justify-content: flex-end; gap: 8px; }

.composer { display: flex; align-items: flex-end; gap: 6px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line); }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 20px; padding: 9px 14px;
  font: 16px/1.4 var(--sans); background: var(--bg); color: var(--ink); max-height: 30vh; min-height: 40px; }
.primary { border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 600; border-radius: 20px;
  padding: 0 16px; height: 40px; flex: none; }
.primary:disabled { opacity: .5; cursor: default; }
.ghost { border: 1px solid var(--line); background: transparent; border-radius: 20px; padding: 0 14px; height: 38px; }
.danger { color: var(--warn); }

/* ---- sheets, lightbox, toast */
.sheet-wrap { position: fixed; inset: 0; background: rgba(10, 15, 20, .45); display: flex; align-items: flex-end;
  justify-content: center; z-index: 20; }
.sheet { background: var(--surface); width: 100%; max-width: 520px; max-height: 85dvh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
@media (min-width: 600px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 18px; } }
.sheet h2 { font-size: 18px; margin: 0 0 12px; }
.sheet label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.sheet input, .sheet textarea { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font: 16px var(--sans); }
.sheet .acts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.sheet .note { color: var(--muted); font-size: 14px; }
.menu-item { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 13px 4px;
  border-bottom: 1px solid var(--line); font-size: 16px; }
.qr { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.qr button.use { flex: 1; text-align: left; border: 0; background: transparent; padding: 12px 4px; }
.photo-preview { width: 100%; max-height: 40dvh; object-fit: contain; border-radius: 10px; background: var(--bg); }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 30; display: grid; place-items: center; }
.lightbox img { max-width: 100vw; max-height: 100dvh; }
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 40; font-size: 14px;
  max-width: calc(100vw - 32px); }

/* ---- login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login form { background: var(--surface); padding: 28px 22px; border-radius: 18px; width: 100%; max-width: 360px; box-shadow: var(--shadow); }
.login h1 { margin: 0 0 4px; font-size: 22px; }
.login p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.login .gloss-demo { font-family: var(--gloss-font); font-style: italic; color: var(--gloss); }
.login label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.login input { width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 16px; }
.login .primary { width: 100%; margin-top: 20px; }
.login .error { color: var(--warn); font-size: 14px; margin-top: 12px; min-height: 1.2em; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.note-line { margin-top: 4px; font-size: 12px; color: var(--muted, #888); }
.row.failed-row { background: var(--warn-bg); }
.failed-why { font-size: 12px; color: var(--warn); margin-top: 2px; }
.row.failed-row { cursor: pointer; align-items: flex-start; }
.row-preview.wrap { white-space: normal; overflow: visible; display: block; margin-top: 2px; color: var(--ink); }
.failed-acts { display: flex; gap: 8px; margin-top: 8px; }
.fchip.fail { color: var(--warn); border-color: var(--warn); font-weight: 600; }
.fchip.fail.on { background: var(--warn); border-color: var(--warn); color: #fff; }
.fchip .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.fchip.ghost-chip { border-style: dashed; }
.fchip.primary-chip { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; padding: 6px 14px; }
.fchip.danger-chip { color: var(--warn); border-color: var(--warn); padding: 6px 14px; }
.label-pick { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.label-pick .fchip.on { background: color-mix(in srgb, var(--lab) 18%, var(--surface)); border-color: var(--lab); color: var(--ink); }
.row-input { display: flex; gap: 8px; align-items: center; }
.row-input input { flex: 1; min-width: 0; }
.label-manage { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.label-line { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.label-line input[type=color] { width: 28px; height: 28px; padding: 0; border: 0; background: none; flex: none; }
.label-name { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.label-count { color: var(--muted); font-size: 13px; }
.once-row { display: flex; align-items: center; gap: 10px; margin: 10px 0 2px; cursor: pointer; }
.once-row input { width: 20px; height: 20px; flex: none; }
.once-badge { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px dashed var(--accent); color: var(--accent);
  display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.once-row .note { display: inline; }
.msg .kind.once { font-weight: 600; }
.row.new-chat .row-name { font-weight: 600; }
.row.new-chat .avatar { font-size: 20px; }
.new-sugg { display: flex; flex-direction: column; margin: 4px -4px 0; max-height: 40dvh; overflow: auto; }
.qr-headline { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.qr-body { max-height: 52dvh; overflow: auto; margin: 4px 0 8px; }
.qr-sec { display: flex; align-items: center; gap: 4px; margin: 12px 0 4px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.qr-sec-name { flex: 1; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.qr.editing { display: flex; flex-direction: column; gap: 4px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.qr-text { font-size: 14px; }
.qr-tools { display: flex; align-items: center; gap: 4px; }
.qr-tools .icon-btn:disabled, .qr-sec .icon-btn:disabled { opacity: .3; }
.qr-move { max-width: 140px; font-size: 13px; padding: 4px 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.qr.used .use { color: var(--ok, #1f9d6b); font-weight: 600; background: color-mix(in srgb, var(--ok, #1f9d6b) 9%, transparent); border-radius: 8px; }
.qr-tick { font-weight: 700; }
.gal-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; max-height: 55dvh; overflow: auto; margin: 6px 0; }
.gal-item { position: relative; aspect-ratio: 1; border: 0; padding: 0; border-radius: 8px; overflow: hidden; background: var(--bg); cursor: pointer; }
.gal-item img, .gal-item video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.gal-tag { position: absolute; left: 4px; bottom: 4px; font-size: 11px; font-weight: 700; color: #fff; background: rgba(0,0,0,.6); border-radius: 6px; padding: 1px 6px; }
.gal-add { display: inline-grid; place-items: center; min-height: 36px; padding: 0 12px; border-radius: 10px; cursor: pointer; font-size: 14px; width: auto; }

/* quick replies keep their line breaks */
.qr button.use, .qr-text { white-space: pre-wrap; }
textarea.qr-new { width: 100%; resize: vertical; min-height: 64px; font: inherit; }
.qr-add-row { justify-content: flex-end; margin-top: 6px; }

textarea.qr-new { min-height: 110px; max-height: 60vh; line-height: 1.4; }
.qr-preview { margin: 8px 0 4px; padding: 10px; border-radius: 12px; background: var(--bg); display: flex; flex-direction: column; }
.qr-preview-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.qr-preview .msg.out { white-space: pre-wrap; max-width: 85%; align-self: flex-end; }
button.qr-text { text-align: left; border: 0; background: transparent; padding: 4px 0; white-space: pre-wrap; color: inherit; font: inherit; cursor: pointer; }
.qr-edit-hint { color: var(--muted); }

/* gallery collections */
.gal-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.gal-tabs .fchip { white-space: nowrap; }
.gal-count { opacity: .6; font-weight: 500; }
.gal-coltools { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.gal-item { position: relative; }
.gal-col { position: absolute; left: 4px; bottom: 4px; max-width: calc(100% - 8px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: rgba(0,0,0,.6); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 6px; }
.gal-move { margin-top: 8px; }
.gal-add { white-space: nowrap; display: inline-flex; align-items: center; height: auto; padding: 8px 14px; }

/* locations */
.loc-card { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); text-decoration: none; min-width: 220px; }
.loc-pin { font-size: 26px; line-height: 1; }
.loc-body { display: flex; flex-direction: column; gap: 2px; }
.loc-status { font-size: 13px; }
.loc-open { font-size: 13px; color: var(--accent); font-weight: 600; margin-top: 2px; }

#archive-btn.on, #block-btn.on { background: color-mix(in srgb, var(--warn) 18%, transparent); border-radius: 50%; }
/* phone-width chat header: the name keeps its room; Save to phone stays in the chat's ⋯ menu */
@media (max-width: 560px) {
  .chat-head { gap: 2px; padding: 6px 4px; }
  .chat-head .icon-btn { width: 34px; height: 36px; font-size: 18px; flex: none; }
  .chat-head .head-avatar { width: 34px; height: 34px; flex: none; }
  .chat-head #save-contact { padding: 4px 7px; flex: none; }
  .chat-head #save-contact .chip-word { display: none; }
  .chat-head .who { min-width: 80px; }
  .chat-head #lang-chip { padding: 4px 8px; font-size: 12px; flex: none; }
}
.menu-info { padding: 10px 12px; font-size: 13px; color: var(--muted); }

/* ticks */
.status.tick { font-weight: 700; letter-spacing: -2px; margin-left: 4px; }
.status.tick.sent, .status.tick.delivered { color: var(--muted); }
.status.tick.read { color: #34b7f1; }
.status.tick.waiting { letter-spacing: 0; }
.row-preview .status.tick { margin: 0 2px 0 0; }

/* select several chats */
.selbar { position: sticky; top: 0; z-index: 3; background: var(--surface); border-bottom: 1px solid var(--line); padding: 6px 10px; display: flex; flex-direction: column; gap: 6px; }
.selhead { display: flex; align-items: center; gap: 8px; }
.selacts { display: flex; flex-wrap: wrap; gap: 6px; }
.selbtn { border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 14px; cursor: pointer; }
.selbtn:disabled { opacity: .45; cursor: default; }
.selbtn.danger { color: #c2412d; border-color: color-mix(in srgb, #c2412d 40%, var(--line)); }
.row.selecting { position: relative; padding-left: 44px; }
.row .pick { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--muted); display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff; }
.row.picked .pick { background: var(--accent); border-color: var(--accent); }
.row.picked { background: color-mix(in srgb, var(--accent) 10%, transparent); }

/* holding a chat selects it: keep the phone's own text-selection / callout out of the way */
.row { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* pull to refresh */
.ptr { height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted);
  font-size: 13px; transition: height .15s ease; flex: none; }
.ptr .ptr-ico { font-size: 16px; display: inline-block; }
.ptr.spin .ptr-ico { animation: ptrspin 0.8s linear infinite; }
@keyframes ptrspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ptr { transition: none; } .ptr.spin .ptr-ico { animation: none; } }

/* ---- Links tab: ToKnowMe sign-up links */
.links { padding: 4px 12px calc(24px + env(safe-area-inset-bottom)); }
.link-new { display: flex; flex-direction: column; gap: 8px; padding: 12px 0 14px; }
.link-q { font-weight: 600; font-size: 17px; }
.link-new input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg);
  color: var(--ink); font-size: 17px; }
.primary.big, .ghost.big { height: 52px; font-size: 17px; border-radius: 14px; width: 100%; }
.link-made { border: 2px solid var(--accent); border-radius: var(--r); padding: 14px; margin-bottom: 16px; background: var(--out); }
.link-made-for { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.link-made-url { font-size: 19px; font-weight: 600; word-break: break-all; margin-bottom: 12px; user-select: all; -webkit-user-select: all; }
.link-made-acts { display: flex; gap: 10px; }
.link-made-acts > button { flex: 1; width: auto; min-width: 0; }
.links-head { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 0; }
.link-row { display: flex; gap: 10px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.link-row.off .link-main { opacity: .55; }
.link-main { flex: 1; min-width: 0; }
.link-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-url { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-counts { font-size: 13px; margin-top: 2px; }
.link-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex: none; }
.links-off { padding: 28px 16px; text-align: center; color: var(--muted); }
.links-off h3 { color: var(--ink); margin: 0 0 6px; }
.switch { position: relative; display: inline-block; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch .slider { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .15s; }
.switch .slider::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow); transition: transform .15s; }
.switch input:checked + .slider { background: var(--ok); }
.switch input:checked + .slider::after { transform: translateX(20px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .slider { opacity: .6; }
@media (max-width: 420px) {
  .composer { gap: 4px; }
  .composer .icon-btn { width: 32px; }
  .composer .primary { padding: 0 12px; }
}

/* ✏️ next to the contact's name: save or edit it in one tap */
.who-name .name-edit { border: 0; background: transparent; padding: 2px 4px; margin-left: 4px; font-size: 14px; line-height: 1; cursor: pointer; opacity: .8; vertical-align: middle; }
.who-name .name-edit:hover { opacity: 1; }

/* ⚡ auto-send toggle in the composer: lit when on */
.auto-btn { opacity: .55; }
.auto-btn.on { opacity: 1; background: #f2b33d; border-radius: 50%; }

/* composer: side buttons in a group; on phone screens they fold behind ＋ so the message box gets the width */
.composer { position: relative; }
.tools { display: flex; gap: 6px; align-items: flex-end; }
.tools .tl { display: none; }
.tools-btn { display: none; font-size: 24px; font-weight: 300; }
@media (max-width: 700px) {
  .tools-btn { display: inline-flex; align-items: center; justify-content: center; flex: none; }
  .composer.tray-open .tools-btn { transform: rotate(45deg); }
  .tools { display: none; position: absolute; left: 8px; bottom: calc(100% + 6px); z-index: 20; flex-direction: column; align-items: stretch; gap: 2px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.18); min-width: 200px; }
  .composer.tray-open .tools { display: flex; }
  .tools .icon-btn { width: auto; height: 44px; justify-content: flex-start; gap: 12px; padding: 0 12px; display: flex; align-items: center; font-size: 20px; }
  .tools .tl { display: inline; font-size: 15px; color: var(--ink); }
  .tools .auto-btn.on { border-radius: 10px; }
  /* typing: a roomier box */
  .composer.typing textarea { min-height: 64px; }
}
.composer.typing textarea { max-height: 40vh; }
@media (max-width: 700px) { .tools .auto-btn { opacity: 1; } .tools .auto-btn.on .tl { font-weight: 650; } }

/* contact note (follows the number): strip under the header, folds to a slim line */
.note-bar { display: flex !important; gap: 8px; align-items: baseline; background: #fff4c7; color: #6b4d00; border-bottom: 1px solid #e8cf73; padding: 8px 12px; font-size: 14px; line-height: 1.4; cursor: pointer; }
.note-bar[hidden] { display: none !important; }
.note-bar .nb-text { flex: 1; min-width: 0; white-space: pre-wrap; }
.note-bar .nb-meta { font-size: 11.5px; opacity: .8; white-space: nowrap; flex: none; }
.note-bar.folded { padding: 4px 12px; font-size: 12.5px; }
.note-bar.folded .nb-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip.has-note { background: #fff4c7; color: #6b4d00; border-color: #e8cf73; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .note-bar, :root:not([data-theme="light"]) .chip.has-note { background: #3a3115; color: #f3d77a; border-color: #5c4d1d; } }
:root[data-theme="dark"] .note-bar, :root[data-theme="dark"] .chip.has-note { background: #3a3115; color: #f3d77a; border-color: #5c4d1d; }

/* 📋 To contact: the sheet's list (in the ✏️ sheet) and the opener strip above the composer */
.sheet-open { margin-bottom: 10px; }
.tc-row { display: flex; align-items: center; border-top: 1px solid var(--line); }
.tc-row .row { flex: 1; min-width: 0; min-height: 64px; }
.tc-link { flex: none; width: 48px; height: 48px; display: grid; place-items: center; text-decoration: none; font-size: 20px; }
.tc-list .ghost.big { margin-top: 10px; }
.tc-row { flex-wrap: wrap; }
.tc-done { flex: 1 1 100%; display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 0 4px 10px 48px; font-size: 14px; flex-wrap: wrap; }
.tc-done span { margin-right: auto; color: var(--muted); }
.ghost.small, .primary.small { height: 36px; padding: 0 14px; font-size: 14px; border-radius: 18px; }
.tc-undo { padding: 14px 4px; }
/* one tab per phone's list when there's more than one */
.tc-lists { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.tc-lists .chip { min-height: 36px; padding: 6px 14px; cursor: pointer; color: var(--ink); }
.tc-lists .chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tc-tools { display: flex; gap: 8px; margin-bottom: 8px; }
.tc-tools input { flex: 1; min-width: 0; height: 44px; }
.tc-country { flex: none; max-width: 45%; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 0 8px; font-size: 15px; }
.opener-bar { display: flex; align-items: center; gap: 4px; padding: 4px 6px 4px 14px; font-size: 13px; color: var(--muted);
  background: var(--out); border-top: 1px solid var(--line); }
.opener-bar { flex-wrap: wrap; }
.opener-bar .ob-text { flex: 1 1 100%; min-width: 0; padding-top: 4px; }
.opener-bar .ob-means { color: var(--ink); font-style: italic; }
.opener-bar .ob-langs { display: flex; gap: 4px; margin-right: auto; }
.ob-lang { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; min-width: 44px; height: 36px; font-weight: 600; }
.ob-lang.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.opener-bar .icon-btn { width: 40px; height: 40px; font-size: 20px; }

/* 📤 send queue: ticks on the To-contact rows, the bar for the ticked ones, the queue panel, the ✏️ badge */
.tc-check { flex: none; width: 48px; min-height: 64px; display: grid; place-items: center; margin: 0 !important; cursor: pointer; }
.sheet input.tc-tick { width: 24px; height: 24px; padding: 0; margin: 0; accent-color: var(--accent); cursor: pointer; }
.tc-row .row.new-chat { padding-left: 2px; }
.tc-row .row.new-chat .avatar { width: 40px; height: 40px; }
.tc-pick { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.tc-qline { display: block; width: 100%; text-align: left; min-height: 44px; margin: 0 0 10px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 14px; }
.tc-qline.paused { background: var(--hold-bg); }
.tc-selbar { position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom)); z-index: 2; display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; margin: 8px -16px 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--surface);
  border-top: 1px solid var(--line); box-shadow: 0 -4px 12px rgba(0, 0, 0, .08); }
.tc-selbar span { margin-right: auto; font-weight: 600; }
.tc-selbar .primary { height: 44px; }
.q-status { padding: 10px 12px; border-radius: 10px; background: var(--bg); font-size: 15px; margin-bottom: 10px; overflow-wrap: anywhere; }
.q-status.paused { background: var(--hold-bg); }
.q-toggle { width: 100%; height: 48px; font-size: 16px; margin-bottom: 8px; }
.q-item { display: flex; align-items: center; gap: 8px; min-height: 60px; padding: 6px 0; border-top: 1px solid var(--line); }
.q-main { flex: 1; min-width: 0; }
.q-note { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.q-state { flex: none; font-size: 13px; color: var(--muted); text-align: right; max-width: 40%; }
.q-item.sending .q-state { color: var(--accent); font-weight: 600; }
.q-item.sent .q-state { color: var(--ok); }
.q-item.failed .q-state { color: var(--warn); font-weight: 600; }
.q-remove { flex: none; width: 44px; height: 44px; }
.fab-badge { position: absolute; top: -6px; right: -8px; min-width: 22px; padding: 2px 6px; border-radius: 999px; font-size: 12px;
  line-height: 16px; font-weight: 700; background: var(--surface); color: var(--accent); border: 1px solid var(--accent); white-space: nowrap; }
.fab-badge.paused { color: var(--warn); border-color: var(--warn); background: var(--warn-bg); }
