/* Digital Advisors — mobile-first, feels like an app (SPEC-mobile-app §7). */

:root {
  --bg: #ffffff;
  --bg-soft: #f4f5f7;
  --text: #16181d;
  --text-soft: #5c6270;
  --line: #e3e5ea;
  --accent: #2f6fed;
  --accent-text: #ffffff;
  --graph-bubble: #eef2fb;
  --general-bubble: #f4f5f7;
  --boundary-bg: #fdf6e9;
  --boundary-line: #e8d5a8;
  --danger: #c0392b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10131a;
    --bg-soft: #1a1e28;
    --text: #e8eaf0;
    --text-soft: #9aa1b0;
    --line: #2a2f3c;
    --accent: #5b8def;
    --accent-text: #0d1017;
    --graph-bubble: #1c2434;
    --general-bubble: #1a1e28;
    --boundary-bg: #2a2416;
    --boundary-line: #55482a;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg-soft);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
}
@media (min-width: 560px) {
  #app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

.screen { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.screen[hidden] { display: none; }
.scroll { flex: 1; overflow-y: auto; padding: 0 16px 16px; }

/* ── bars ─────────────────────────────────────────────────────────── */
.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.bar-title { font-weight: 650; font-size: 17px; }
.icon-btn {
  background: none; border: none; color: var(--text);
  font-size: 20px; width: 40px; height: 36px; cursor: pointer; border-radius: 8px;
}
.icon-btn:active { background: var(--bg-soft); }

/* ── auth ─────────────────────────────────────────────────────────── */
#screen-auth { justify-content: center; padding: 24px; }
.auth-box { text-align: center; }
.auth-box .logo { width: 64px; height: 64px; }
.auth-box h1 { margin: 12px 0 4px; font-size: 24px; }
.tagline { color: var(--text-soft); margin: 0 0 24px; }
.auth-box form { display: flex; flex-direction: column; gap: 10px; }
.auth-box input {
  font-size: 17px; padding: 13px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--text);
  text-align: center;
}
.auth-box button {
  font-size: 16px; font-weight: 600; padding: 13px; border-radius: 12px;
  border: none; background: var(--accent); color: var(--accent-text); cursor: pointer;
}
.auth-box button.ghost { background: none; color: var(--accent); }
.hint { color: var(--text-soft); font-size: 14px; margin: 0 0 4px; }
.error { color: var(--danger); font-size: 14px; }

/* ── picker ───────────────────────────────────────────────────────── */
.chip {
  margin: 12px 16px 0; padding: 10px 14px; border-radius: 12px;
  background: var(--graph-bubble); font-size: 14px;
}
.group-label {
  font-size: 12px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-soft); margin: 22px 2px 10px; font-weight: 650;
}
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 14px; border: 1px solid var(--line); border-radius: 16px;
  background: var(--bg); cursor: pointer; text-align: left; color: var(--text);
  transition: transform .06s;
}
.card:active { transform: scale(.97); background: var(--bg-soft); }
.card .adv-icon svg { width: 30px; height: 30px; color: var(--accent); }
.card .adv-name { font-weight: 650; font-size: 14.5px; line-height: 1.25; }
.card .adv-sub { font-size: 12.5px; color: var(--text-soft); line-height: 1.35; }

/* ── questions ───────────────────────────────────────────────────── */
.advisor-hero { text-align: center; padding: 26px 8px 4px; }
.hero-icon svg { width: 46px; height: 46px; color: var(--accent); }
.framing { color: var(--text-soft); font-size: 14.5px; margin: 10px 0 0; }
.starters { display: flex; flex-direction: column; gap: 10px; }
.starter {
  text-align: left; font-size: 14.5px; line-height: 1.4; color: var(--text);
  padding: 13px 14px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--bg-soft); cursor: pointer;
}
.starter:active { background: var(--graph-bubble); }

/* ── chat ─────────────────────────────────────────────────────────── */
.messages { display: flex; flex-direction: column; gap: 12px; padding-top: 14px; }
.msg { max-width: 88%; padding: 11px 14px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 6px; }
.msg.graph { align-self: flex-start; background: var(--graph-bubble); border-bottom-left-radius: 6px; }
.msg.general { align-self: flex-start; background: var(--general-bubble); border-bottom-left-radius: 6px; font-size: 15px; }
.msg.thinking { align-self: flex-start; color: var(--text-soft); background: none; padding: 2px 4px; font-size: 14px; }
.msg.thinking::after { content: '…'; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.provenance {
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-soft); margin: 0 0 4px;
}
.secondary {
  align-self: flex-start; max-width: 88%; margin-top: -4px;
  border-left: 3px solid var(--accent); border-radius: 0 12px 12px 0;
  background: var(--bg-soft); padding: 10px 14px; font-size: 14.5px;
}
.secondary summary { cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--accent); }
.secondary p { white-space: pre-wrap; margin: 8px 0 0; }

.boundary-card {
  align-self: stretch; background: var(--boundary-bg);
  border: 1px solid var(--boundary-line); border-radius: 14px; padding: 12px 14px;
  font-size: 14px;
}
.boundary-card a {
  display: inline-block; margin-top: 8px; font-weight: 650; color: var(--accent);
  text-decoration: none;
}
.atoms-list { align-self: stretch; display: flex; flex-direction: column; gap: 8px; }
.atom { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.atom b { display: block; font-size: 14px; }
.atom span { color: var(--text-soft); font-size: 13px; }

/* ── input bar ────────────────────────────────────────────────────── */
.input-bar {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
  border-top: 1px solid var(--line); background: var(--bg);
}
.input-bar textarea {
  flex: 1; resize: none; font: inherit; color: var(--text);
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 18px; padding: 10px 14px; max-height: 120px;
}
.input-bar .send {
  width: 40px; height: 40px; border-radius: 50%; border: none;
  background: var(--accent); color: var(--accent-text);
  font-size: 19px; cursor: pointer; flex-shrink: 0;
}
.input-bar .send:disabled { opacity: .45; }

/* ── history ─────────────────────────────────────────────────────── */
.conv-list { padding-top: 10px; }
.conv-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 13px 6px; border: none; border-bottom: 1px solid var(--line);
  background: none; color: var(--text); text-align: left; cursor: pointer;
}
.conv-row .conv-main { flex: 1; min-width: 0; }
.conv-row .conv-agent { font-size: 12px; color: var(--text-soft); }
.conv-row .conv-title { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-row .conv-del { background: none; border: none; font-size: 17px; cursor: pointer; color: var(--text-soft); }
.empty { color: var(--text-soft); text-align: center; margin-top: 40px; }
