/* Bridge V2 UI core — SIGNAL-BLUE (locked design, Figma sCyiHpR53jhJdUn0ZUYaIJ).
   Two themes, user-switchable: dark (black·blue) and light (white·blue).
   Tokens below are exact values lifted from the winner frames (1:90 dark, 6:2 light).
   --danger is a build extension (the designed sick-face states need an alarm tone
   the mock never used) — flagged for sir's grading pass. */

@font-face {
  font-family: 'Space Grotesk';
  font-style: normal; font-weight: 500; font-display: swap;
  src: url('assets/fonts/space-grotesk-500-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('assets/fonts/inter-latin.woff2') format('woff2');
}

:root, :root[data-theme="dark"] {
  --bg: #121316;
  --surface: #1d1f23;
  --border: #33363b;
  --blue: #5c9cf0;
  --tint: #1f3052;
  --text: #ededeb;
  --muted: #8f9199;
  --danger: #e0655c;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #fcfcff;
  --surface: #f1f4f9;
  --border: #d9dee5;
  --blue: #5c9cf0;
  --tint: #deebfc;
  --text: #1c1f24;
  --muted: #707580;
  --danger: #c7473d;
  color-scheme: light;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', 'Malgun Gothic', system-ui, sans-serif;
  font-size: 15px;
  overscroll-behavior: none;
}
button { background: none; border: none; color: inherit; font: inherit; cursor: pointer; }

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

/* ---- header ---- */
header {
  display: flex; align-items: center; gap: 10px;
  padding:
    calc(18px + var(--safe-top))
    calc(18px + var(--safe-right))
    14px
    calc(18px + var(--safe-left));
  width: 100%; max-width: 756px; margin: 0 auto;
}
.wordmark {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-weight: 500; font-size: 18px; color: var(--blue);
  letter-spacing: 0.2px;
}
.spacer { flex: 1; }
.chip {
  background: var(--tint); border-radius: 8px; padding: 6px 10px;
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-weight: 500; font-size: 11px; color: var(--blue);
  white-space: nowrap; display: flex; align-items: center; gap: 6px;
}
.iconbtn {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px; color: var(--muted);
}
.iconbtn:hover { color: var(--text); background: var(--surface); }
.iconbtn svg { width: 17px; height: 17px; }

/* ---- connection banner (Law 2 sick face: never dead air, never silent) ---- */
.banner {
  max-width: 756px; margin: 0 auto;
  width: calc(100% - 36px - var(--safe-left) - var(--safe-right));
  border-radius: 10px; padding: 8px 12px;
  font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 500; font-size: 11px;
  background: var(--tint); color: var(--danger);
  display: flex; align-items: center; gap: 8px;
}
.banner.hidden { display: none; }

/* ---- thread ---- */
main {
  flex: 1; overflow-y: auto; width: 100%;
}
.thread-inner {
  display: flex; flex-direction: column; gap: 16px; align-items: flex-start;
  padding:
    10px
    calc(18px + var(--safe-right))
    10px
    calc(18px + var(--safe-left));
  max-width: 756px; margin: 0 auto;
}
.user-row { display: flex; justify-content: flex-end; width: 100%; }
.user-bubble {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 11px 16px; font-size: 15px; max-width: 85%;
  white-space: pre-wrap; overflow-wrap: break-word; font-variant-ligatures: no-contextual;
}
.mercer-col { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.meta {
  display: flex; align-items: center; gap: 6px;
  font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 500; font-size: 11px;
  color: var(--muted);
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--blue); flex: none; }
.danger-dot { background: var(--danger); }
.mercer-text { font-size: 15px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: break-word; width: 100%; font-variant-ligatures: no-contextual; }
.system-line {
  width: 100%; text-align: center; font-size: 12px; color: var(--muted);
  overflow-wrap: break-word;
}
.system-line.failed { color: var(--danger); }

/* ---- working pill: the pulse is a binding motion spec (sir, 2026-07-28) ---- */
.working {
  display: flex; align-items: center; gap: 8px;
  background: var(--tint); border-radius: 10px; padding: 8px 12px;
  font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 500; font-size: 11px;
  color: var(--blue); max-width: 100%;
}
.working.hidden { display: none; }
.working .dot { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.72); }
}
@media (prefers-reduced-motion: reduce) { .working .dot { animation: none; } }
.working .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- composer ---- */
footer {
  width: 100%; max-width: 756px; margin: 0 auto;
  padding:
    12px
    calc(18px + var(--safe-right))
    calc(16px + env(safe-area-inset-bottom, 12px))
    calc(18px + var(--safe-left));
}
.input {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 9px 10px 9px 18px;
}
.input:focus-within { border-color: var(--blue); }
textarea {
  flex: 1; background: none; border: none; outline: none; resize: none;
  color: var(--text); font: inherit; font-size: 15px; line-height: 1.4;
  max-height: 132px; padding: 4px 0;
}
textarea::placeholder { color: var(--muted); }
.sendbtn {
  display: flex; align-items: center; justify-content: center; flex: none;
  width: 30px; height: 30px; border-radius: 50%; background: var(--blue); color: #fff;
}
.sendbtn svg { width: 15px; height: 15px; }
.sendbtn:disabled { opacity: 0.4; cursor: default; }
.hidden { display: none !important; }

/* ---- sheets (threads / settings) ---- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 10;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 18px 18px 0 0; width: 100%; max-width: 560px;
  max-height: 75dvh; overflow-y: auto;
  padding:
    18px
    calc(18px + var(--safe-right))
    calc(18px + env(safe-area-inset-bottom, 8px))
    calc(18px + var(--safe-left));
  display: flex; flex-direction: column; gap: 14px;
}
@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 18px; }
}
.sheet h2 {
  font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 500;
  font-size: 13px; color: var(--blue); letter-spacing: 0.66px; text-transform: uppercase;
}
.sheet label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 6px; }
.sheet input {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; color: var(--text); font: inherit; font-size: 14px;
  outline: none;
}
.sheet input:focus { border-color: var(--blue); }
.btn-primary {
  background: var(--blue); color: #fff; border-radius: 10px; padding: 8px 18px;
  font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 500; font-size: 13px;
  align-self: flex-start;
}
.btn-quiet {
  border: 1px solid var(--border); color: var(--muted); border-radius: 10px; padding: 8px 18px;
  font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 500; font-size: 13px;
}
.thread-item {
  display: flex; flex-direction: column; gap: 4px; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 16px; width: 100%;
}
.thread-item .t-title { font-size: 14px; color: var(--text); }
.thread-item .t-sub {
  font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.thread-item.active { border-color: var(--blue); }
.note { font-size: 12px; color: var(--muted); line-height: 1.5; }
