/* HaFa Web, decision 176. Decision 017's palette: navy is structure, saffron the one bright thing,
   dark mode is navy-black. System fonts, because the page loads nothing from anywhere else. */
:root {
  --navy: #12275F; --saffron: #F5B301; --ink: #0A1737;
  --bg: #EFF3FB; --panel: #ffffff; --wash: #F6F8FC; --text: #0B1223; --muted: #55607A; --faint: #7E889E;
  --hair: rgba(11, 18, 35, .09); --in: #ffffff; --out: #12275F; --onOut: #ffffff; --tintFill: rgba(18, 39, 95, .08);
  --danger: #C0392B; --read: #F5B301;
  --r: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #070D1C; --panel: #0D1731; --wash: #0A1329; --text: #EFF2FA; --muted: #9BA6BE; --faint: #6E7893;
    --hair: rgba(255, 255, 255, .1); --in: #16213F; --out: #22407F; --onOut: #EFF2FA; --tintFill: rgba(255, 255, 255, .06);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #070D1C; --panel: #0D1731; --wash: #0A1329; --text: #EFF2FA; --muted: #9BA6BE; --faint: #6E7893;
  --hair: rgba(255, 255, 255, .1); --in: #16213F; --out: #22407F; --onOut: #EFF2FA; --tintFill: rgba(255, 255, 255, .06);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
b { font-weight: 600; }
.fine { font-size: 13px; color: var(--faint); margin: 6px 0 0; }
.centre { text-align: center; padding: 8px 16px; }
.ghost { background: none; border: 0; padding: 6px 10px; border-radius: 999px; color: var(--muted); cursor: pointer; font-size: 13.5px; font-weight: 500; }
.ghost:hover { background: var(--tintFill); color: var(--text); }
.wordmark { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -.02em; font-size: 17px; min-width: 0; }
.wordmark > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mark { width: 26px; height: 26px; flex: none; }
:focus-visible { outline: 2px solid var(--saffron); outline-offset: 2px; }

/* ---- pairing ------------------------------------------------------------------------------ */
.pair { max-width: 980px; margin: 0 auto; padding: 20px 16px 40px; }
.pair-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.pair-card { background: var(--panel); border-radius: 22px; padding: 28px; display: grid; grid-template-columns: 1fr auto; gap: 32px; align-items: center; }
.pair-text h1 { margin: 0 0 14px; font-size: clamp(24px, 3.2vw, 32px); letter-spacing: -.03em; line-height: 1.12; }
.steps { margin: 0; padding-left: 22px; color: var(--muted); font-size: 16px; }
.steps li { margin: 8px 0; }
.steps b { color: var(--text); }
.keep { display: flex; gap: 9px; align-items: center; margin-top: 22px; font-weight: 500; cursor: pointer; }
.keep input { width: 18px; height: 18px; accent-color: var(--navy); }
.notice { margin: 16px 0 0; padding: 10px 14px; border-radius: 12px; background: rgba(245, 179, 1, .16); color: var(--text); font-size: 14px; }
.pair-qr { text-align: center; }
.qr { width: 280px; height: 280px; border-radius: 16px; background: #fff; display: grid; place-items: center; padding: 6px; box-shadow: 0 0 0 1px var(--hair); }
.qr svg { width: 100%; height: 100%; display: block; }
.qr-wait { color: #7E889E; font-size: 14px; }
.status { color: var(--muted); font-size: 14px; margin: 12px 0 0; }
.pair-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 18px; }
.pair-facts p { margin: 0; background: var(--panel); border-radius: var(--r); padding: 16px; color: var(--muted); font-size: 14px; }
.pair-facts b { color: var(--text); display: block; margin-bottom: 4px; }
@media (max-width: 760px) {
  .pair-card { grid-template-columns: 1fr; padding: 20px; }
  .pair-qr { order: -1; }
  .qr { width: min(280px, 100%); height: auto; aspect-ratio: 1; margin: 0 auto; }
  .pair-facts { grid-template-columns: 1fr; }
}

/* ---- two panes ------------------------------------------------------------------------------ */
.app { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; height: 100vh; height: 100dvh; }
.side { background: var(--panel); border-right: 1px solid var(--hair); display: flex; flex-direction: column; min-height: 0; }
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 14px 10px 16px; }
.side-actions { display: flex; gap: 2px; flex: none; }
.banner { margin: 0 12px 8px; padding: 10px 12px; border-radius: 12px; font-size: 13.5px; background: var(--tintFill); color: var(--text); }
.banner.warn { background: rgba(245, 179, 1, .18); }
.banner b { display: block; }
.search { padding: 0 12px 8px; }
.search input { width: 100%; border: 0; border-radius: 10px; padding: 9px 12px; background: var(--wash); outline-offset: 0; }
.chats { list-style: none; margin: 0; padding: 0 6px 12px; overflow-y: auto; flex: 1; }
.row { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 12px; cursor: pointer; }
.row:hover { background: var(--wash); }
.row.on { background: var(--tintFill); }
.avatar { width: 46px; height: 46px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 16px; background: var(--navy); }
.row-main { flex: 1; min-width: 0; }
.row-line { display: flex; align-items: baseline; gap: 8px; }
.row-title { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-time { font-size: 12px; color: var(--faint); flex: none; }
.row-time.new { color: var(--navy); font-weight: 600; }
:root[data-theme="dark"] .row-time.new { color: var(--saffron); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .row-time.new { color: var(--saffron); } }
.row-preview { flex: 1; color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { flex: none; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 6px; background: var(--saffron); color: var(--ink); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.muted-mark { color: var(--faint); font-size: 12px; }

.pane { min-width: 0; min-height: 0; background: var(--bg); display: flex; }
.empty { margin: auto; text-align: center; max-width: 420px; padding: 24px; color: var(--muted); }
.empty h2 { color: var(--text); margin: 12px 0 6px; letter-spacing: -.02em; }
.empty-mark { width: 64px; height: 64px; }
.chat { display: flex; flex-direction: column; width: 100%; min-height: 0; }
.chat-top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--hair); }
.chat-top .avatar { width: 38px; height: 38px; font-size: 14px; }
.chat-titles { display: flex; flex-direction: column; min-width: 0; }
.chat-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-sub { font-size: 12.5px; color: var(--faint); }
.back { display: none; font-size: 24px; line-height: 1; padding: 2px 10px; }
.messages { flex: 1; overflow-y: auto; padding: 16px clamp(12px, 4vw, 56px); display: flex; flex-direction: column; gap: 3px; }
.day { align-self: center; margin: 12px 0 6px; font-size: 12px; color: var(--muted); background: var(--panel); padding: 4px 10px; border-radius: 999px; }
.older { align-self: center; margin-bottom: 8px; }
.b { max-width: min(560px, 78%); padding: 7px 10px 5px 12px; border-radius: 16px; background: var(--in); align-self: flex-start; word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; box-shadow: 0 1px 0 var(--hair); }
.b.me { align-self: flex-end; background: var(--out); color: var(--onOut); }
.b.gap { margin-top: 8px; }
.b .who { display: block; font-size: 12.5px; font-weight: 600; color: var(--navy); margin-bottom: 1px; }
:root[data-theme="dark"] .b .who { color: var(--saffron); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .b .who { color: var(--saffron); } }
.b .meta { float: right; margin: 6px 0 0 10px; font-size: 11px; opacity: .7; white-space: nowrap; }
.b .tick.read { color: var(--read); opacity: 1; }
.b .tick.failed { color: #ff8a80; opacity: 1; }
.b.other .label { font-style: normal; }
.b.other .hint { display: block; font-size: 12.5px; opacity: .75; margin-top: 2px; }
.b.deleted { font-style: italic; opacity: .75; }
.b.pending { opacity: .75; }
.b.failed-send { box-shadow: 0 0 0 1.5px var(--danger); }
.sys { align-self: center; font-size: 12.5px; color: var(--muted); text-align: center; max-width: 80%; margin: 6px 0; }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px 16px 14px; background: var(--panel); border-top: 1px solid var(--hair); }
.composer textarea { flex: 1; resize: none; border: 0; border-radius: 20px; background: var(--wash); padding: 10px 14px; max-height: 160px; line-height: 1.4; }
.send { border: 0; border-radius: 999px; background: var(--saffron); color: var(--ink); font-weight: 700; padding: 10px 18px; cursor: pointer; }
.send:disabled { opacity: .5; cursor: default; }
.readonly { margin: 0; padding: 14px 16px; text-align: center; color: var(--muted); background: var(--panel); border-top: 1px solid var(--hair); }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .pane { display: none; }
  .app.show-chat .side { display: none; }
  .app.show-chat .pane { display: flex; }
  .back { display: inline-block; }
  .b { max-width: 86%; }
}
@media (prefers-reduced-motion: no-preference) { .row, .ghost { transition: background .15s; } }
