:root {
  /* ---- Light sky-blue palette ---- */
  --app-bg: #e8f2fd;        /* page backdrop behind the chat */
  --panel: #ffffff;         /* sidebar + card surfaces */
  --panel2: #f2f8ff;        /* insets, code, blockquotes */
  --field: #f4f9ff;         /* input backgrounds */
  --ink: #123049;           /* primary text — deep slate blue */
  --muted: #5c789a;         /* secondary text */
  --faint: #8ba4c0;         /* tertiary text / hints */
  --sky: #0284C7;           /* primary accent — 4.10:1 w/ white (AA UI/large) */
  --sky-deep: #0369A1;      /* darker accent — gradients, headings, links (5.93:1) */
  --sky-soft: #e4f1fd;      /* soft accent fill */
  --accent: #5a8def;        /* secondary accent (periwinkle) */
  --amber: #8a5a00;         /* text-safe gold for markers/verdict (5.93:1); fill-safe too */
  --good: #12a678;          /* excellent band / full cancellation */
  --line: #d8e6f4;          /* borders */
  --line-soft: #eaf2fa;     /* faint dividers */
  --user: #e4eefb;          /* user avatar */
  --err: #e5484d;
  --on-accent: #ffffff;     /* text on coloured buttons */
  --radius: 10px;
  --radius-sm: 6px;
  --radius-xs: 4px;
  --font: "Raleway", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --font-head: "Lora", Georgia, "Times New Roman", serif;   /* serif for display/headings */
  --shadow-sm: 0 1px 2px rgba(20, 50, 80, 0.05);   /* whisper lift, cards only */
}

* { box-sizing: border-box; }

/* The hidden attribute must win over class-level `display` (e.g. .auth-overlay
   uses display:grid, which would otherwise keep it on screen after login). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background:
    linear-gradient(rgba(244, 250, 255, 0.5), rgba(232, 242, 253, 0.62)),
    url("cosmos-bg.webp") center center / cover no-repeat fixed,
    var(--app-bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app {
  display: grid;
  grid-template-columns: 336px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Left panel ---------- */
.panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 16px 20px;
}

/* Fixed header (logo + title) — stays pinned while the rest of the sidebar scrolls. */
.brand {
  display: flex; align-items: center; gap: 10px;
  flex: 0 0 auto; margin: 0;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand-mark {
  width: 36px; height: 36px; flex: 0 0 auto;
  display: block; object-fit: contain;
}
.brand h1 { margin: 0; font-family: var(--font-head); font-size: 19px; font-weight: 600; letter-spacing: 0.2px; color: var(--ink); }
.tag { margin: 1px 0 0; color: var(--muted); font-size: 11px; }

.birth-form h2, .chart-card h3, .match-card h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--sky-deep); margin: 4px 0 10px; font-weight: 700;
}

label { display: block; margin-bottom: 9px; font-size: 12px; color: var(--muted); font-weight: 500; }
label small { display: block; margin-top: 3px; font-size: 10.5px; color: var(--faint); font-weight: 400; }

input {
  width: 100%; margin-top: 4px; padding: 7px 10px;
  background: var(--field); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--ink); font-size: 13px; font-family: var(--font);
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--faint); }
input:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.14); }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

button {
  cursor: pointer; border: none; border-radius: var(--radius-sm);
  font-family: var(--font); font-weight: 600;
}

#computeBtn, #matchBtn {
  width: 100%; padding: 9px; margin-top: 2px; font-size: 13px;
  color: var(--on-accent); background: var(--sky);
  transition: background .15s;
}
#computeBtn:hover, #matchBtn:hover { background: var(--sky-deep); }
#computeBtn:disabled, #matchBtn:disabled { opacity: 0.6; cursor: wait; }

.err { color: var(--err); font-size: 11.5px; margin: 7px 0 0; }

/* ---------- Chart card ---------- */
.chart-card {
  margin-top: 16px; padding: 12px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.chart-card .asc { font-size: 13px; margin-bottom: 9px; color: var(--ink); }
.chart-card .asc b { color: var(--sky-deep); }
.chart-card table { width: 100%; border-collapse: collapse; font-size: 12px; }
.chart-card th, .chart-card td {
  text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line-soft);
}
.chart-card th { color: var(--muted); font-weight: 600; }
.chart-card td .retro { color: var(--sky); font-size: 10.5px; }
.chart-card .dasha {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted); line-height: 1.6;
}
.chart-card .dasha b { color: var(--ink); }

.chart-card .aspects {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
}
.aspects-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--sky-deep); font-weight: 700; margin-bottom: 6px;
}
.node-toggle {
  float: right; display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; text-transform: none; letter-spacing: 0; font-weight: 500;
  color: var(--muted); cursor: pointer;
}
.node-toggle input { width: auto; margin: 0; accent-color: var(--sky); cursor: pointer; }
.chart-card .aspects ul { list-style: none; margin: 0; padding: 0; }
.chart-card .aspects li { padding: 2px 0; }
.chart-card .aspects li b { color: var(--ink); }
.chart-card .aspects .by { color: var(--accent); }
.chart-card .aspects .conj { margin-top: 6px; color: var(--faint); }
.chart-card .aspects .none { color: var(--faint); }

.chart-card .navamsa {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line);
}
.chart-card .nav-lagna { font-size: 12px; color: var(--muted); margin-bottom: 7px; }
.chart-card .nav-lagna b { color: var(--sky-deep); }
.chart-card .varg { color: var(--amber); }
.chart-card .varg-note { margin-top: 6px; font-size: 10.5px; color: var(--faint); }

.chart-card .divisionals {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line);
}
#vargaSelect, #bavSelect {
  float: right; padding: 3px 6px; font-size: 11px;
  background: var(--field); color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px; font-family: var(--font);
  text-transform: none; letter-spacing: 0; cursor: pointer;
}
#vargaSelect:focus, #bavSelect:focus { outline: none; border-color: var(--sky); }
.chart-card .varga-governs { font-size: 11.5px; color: var(--sky-deep); margin-bottom: 7px; }
.chart-card .same { color: var(--amber); }

.chart-card .ashtaka {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line);
}
.chart-card .sav-note { font-size: 11.5px; color: var(--sky-deep); margin-bottom: 7px; }
.chart-card .ashtaka tr.strong td:nth-child(3) { color: var(--sky-deep); font-weight: 700; }
.chart-card .ashtaka tr.weak td:nth-child(3) { color: var(--faint); }

.chart-card .transits {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line);
}
.ss-badge {
  display: inline-block; padding: 4px 10px; border-radius: var(--radius-xs);
  font-size: 11.5px; font-weight: 600; margin-bottom: 6px;
}
.ss-badge.on { color: var(--on-accent); background: var(--sky); }
.ss-badge.off { color: var(--muted); background: var(--panel2); border: 1px solid var(--line); }
.chart-card .ss-detail { font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.chart-card .ss-detail b { color: var(--ink); }
.chart-card .ss-detail.small { color: var(--faint); font-size: 10.5px; }

/* ---------- Yogas ---------- */
.chart-card .yogas { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.y-count {
  float: right; font-size: 10px; font-weight: 700; color: var(--sky-deep);
  background: var(--sky-soft); border-radius: var(--radius-xs); padding: 1px 8px;
}
.yoga-list { list-style: none; margin: 4px 0 0; padding: 0; }
.yoga {
  padding: 6px 9px; margin-bottom: 5px; border-radius: var(--radius-sm);
  background: var(--panel2); border-left: 3px solid var(--sky);
}
.yoga.bad { border-left-color: var(--amber); background: var(--field); }
.y-name { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.yoga.bad .y-name { color: var(--amber); }
.y-detail { font-size: 11px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.chart-card .yogas .none { font-size: 11.5px; color: var(--faint); }

/* ---------- Guna Milan (compatibility) ---------- */
.match-card {
  margin-top: 16px; padding: 12px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.role-toggle {
  display: flex; flex-wrap: wrap; align-items: center; gap: 9px;
  font-size: 12px; color: var(--muted); margin-bottom: 12px;
}
.role-toggle label {
  display: inline-flex; align-items: center; gap: 5px; margin: 0; cursor: pointer;
}
.role-toggle input { width: auto; margin: 0; accent-color: var(--sky); cursor: pointer; }

/* verdict band colours drive the ring, number and label via --band */
.band-poor { --band: var(--err); }
.band-average { --band: var(--amber); }
.band-good { --band: var(--sky); }
.band-excellent { --band: var(--good); }

.match-result { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.score-head { display: flex; align-items: center; gap: 14px; }
.score-ring {
  flex: 0 0 78px; width: 78px; height: 78px; border-radius: 50%;
  background: conic-gradient(var(--band) var(--deg), var(--line) 0);
  display: grid; place-items: center;
}
.score-inner {
  width: 60px; height: 60px; border-radius: 50%; background: var(--panel);
  display: grid; place-items: center; line-height: 1;
}
.score-inner b { font-family: var(--font-head); font-size: 23px; color: var(--ink); }
.score-inner span { font-size: 11px; color: var(--muted); margin-top: 2px; }

.score-meta { flex: 1; min-width: 0; }
.verdict { font-family: var(--font-head); font-size: 16px; font-weight: 700; color: var(--band); margin-bottom: 6px; }
.pair { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); }
.pair b { color: var(--ink); }
.pair small { color: var(--sky-deep); }

.dosha-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.dosha-badge {
  font-size: 10.5px; font-weight: 600; padding: 3px 9px; border-radius: var(--radius-xs);
  color: var(--err); background: rgba(229, 72, 77, 0.1); border: 1px solid rgba(229, 72, 77, 0.35);
}
.dosha-badge.ok {
  color: var(--muted); background: var(--field); border-color: var(--line);
}

.kuta-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.kuta-table td { padding: 0; vertical-align: middle; }
.kuta .kt-name {
  padding: 6px 8px 2px 0; font-size: 12.5px; color: var(--ink); width: 42%;
}
.kuta .kt-name small { display: block; font-size: 10px; color: var(--faint); margin-top: 1px; }
.kuta .kt-bar { padding: 6px 8px 2px; }
.kuta .kt-bar span {
  display: block; height: 6px; border-radius: 3px; min-width: 2px;
  background: var(--sky);
}
.kuta .kt-score { padding: 6px 0 2px; text-align: right; font-size: 12.5px; color: var(--ink); white-space: nowrap; }
.kuta .kt-score small { color: var(--muted); font-size: 11px; }
.kuta-detail td { padding: 0 0 6px; font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--line-soft); }
.kuta.dosha .kt-name, .kuta.dosha .kt-score { color: var(--err); }
.kuta.dosha .kt-bar span { background: var(--err); }
.kuta-detail.dosha td { color: var(--err); }

/* Manglik / Mangal dosha panel */
.manglik { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.mk-verdict {
  font-size: 12px; line-height: 1.45; margin: 4px 0 10px; padding: 8px 11px;
  border-radius: var(--radius-sm); background: var(--panel2); color: var(--ink);
  border-left: 3px solid var(--line);
}
.manglik.mk-clear .mk-verdict { border-left-color: var(--sky); }
.manglik.mk-cancelled .mk-verdict { border-left-color: var(--good); }
.manglik.mk-mitigated .mk-verdict { border-left-color: var(--amber); }
.manglik.mk-present .mk-verdict { border-left-color: var(--err); color: var(--err); }
.mk-person { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 12px; color: var(--muted); }
.mk-who { min-width: 76px; color: var(--ink); }
.mk-flag { font-size: 10.5px; font-weight: 600; padding: 2px 9px; border-radius: var(--radius-xs); white-space: nowrap; }
.mk-flag.on { color: var(--err); background: rgba(229, 72, 77, 0.1); border: 1px solid rgba(229, 72, 77, 0.35); }
.mk-flag.off { color: var(--muted); background: var(--field); border: 1px solid var(--line); }
.mk-person small { color: var(--faint); }

.caveats { margin: 12px 0 0; padding-left: 18px; font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.caveats li { margin: 3px 0; }
.match-note { margin-top: 10px; font-size: 11px; color: var(--faint); }
.ask-match {
  margin-top: 12px; width: 100%; padding: 8px 11px; font-size: 12px;
  color: var(--sky-deep); background: var(--sky-soft);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  transition: background .15s, color .15s, border-color .15s;
}
.ask-match:hover {
  color: var(--on-accent); border-color: transparent; background: var(--sky);
}

.disclaimer { margin-top: 20px; font-size: 11px; color: var(--faint); line-height: 1.5; }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; height: 100vh; }

.chat-scroll { flex: 1; overflow-y: auto; padding: 24px 0; }

.welcome {
  max-width: 540px; margin: 7vh auto 0; text-align: center; color: var(--muted);
}
.welcome-glyph { font-size: 40px; color: var(--sky); }
.welcome h2 { font-family: var(--font-head); font-weight: 600; color: var(--ink); margin: 8px 0 6px; font-size: 22px; }
.welcome p { line-height: 1.6; }

.msg { max-width: 720px; margin: 0 auto 18px; padding: 0 24px; display: flex; gap: 12px; }
.msg .avatar {
  flex: 0 0 28px; height: 28px; border-radius: var(--radius-sm); display: grid; place-items: center;
  font-size: 14px; font-weight: 700; margin-top: 2px;
}
.msg.user .avatar { background: var(--user); color: var(--sky-deep); font-size: 10px; }
.msg.assistant .avatar { background: var(--sky); color: var(--on-accent); }
.msg .body { flex: 1; line-height: 1.7; color: var(--ink); }

/* Markdown styling inside assistant messages */
.body h1, .body h2, .body h3 { font-family: var(--font-head); font-weight: 600; color: var(--sky-deep); margin: 14px 0 7px; line-height: 1.3; }
.body h1 { font-size: 18px; } .body h2 { font-size: 16px; } .body h3 { font-size: 14.5px; }
.body p { margin: 7px 0; }
.body ul, .body ol { margin: 7px 0; padding-left: 20px; }
.body li { margin: 3px 0; }
.body strong { color: var(--ink); font-weight: 700; }
.body a { color: var(--sky-deep); }
.body code {
  background: var(--sky-soft); color: var(--sky-deep);
  padding: 1px 6px; border-radius: var(--radius-xs); font-size: 12.5px;
}
.body pre {
  background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; overflow-x: auto;
}
.body pre code { background: none; color: var(--ink); padding: 0; }
.body table { border-collapse: collapse; margin: 10px 0; width: 100%; font-size: 13px; }
.body th, .body td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.body th { background: var(--sky-soft); color: var(--sky-deep); }
.body blockquote {
  border-left: 3px solid var(--sky); margin: 10px 0; padding: 2px 14px;
  color: var(--muted); background: var(--panel2); border-radius: 0 6px 6px 0;
}
.cursor::after { content: "▍"; color: var(--sky); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Suggestions ---------- */
.suggestions {
  max-width: 720px; margin: 0 auto; padding: 4px 24px 8px;
  display: flex; flex-wrap: wrap; gap: 7px;
}
.suggestions button {
  background: var(--panel); color: var(--muted); border: 1px solid var(--line);
  padding: 6px 12px; font-size: 12px; font-weight: 500; border-radius: var(--radius-sm);
  transition: color .15s, border-color .15s, background .15s;
}
.suggestions button:hover { color: var(--sky-deep); border-color: var(--sky); background: var(--sky-soft); }

/* ---------- Composer ---------- */
.composer {
  max-width: 720px; width: 100%; margin: 0 auto; padding: 10px 24px 18px;
  display: flex; gap: 8px; align-items: flex-end;
}
#input {
  flex: 1; resize: none; max-height: 180px; padding: 10px 13px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--ink); font-size: 14px; font-family: var(--font); line-height: 1.5;
  transition: border-color .15s, box-shadow .15s;
}
#input:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.14); }
#input:disabled { opacity: 0.6; background: var(--panel2); }
#sendBtn {
  padding: 10px 18px; font-size: 13px; color: var(--on-accent);
  background: var(--sky); transition: background .15s;
}
#sendBtn:hover:not(:disabled) { background: var(--sky-deep); }
#sendBtn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: #c3d6e8 transparent; }
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: #c3d6e8; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #a9c3dc; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Account bar ---------- */
.account {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: -4px 0 14px; padding: 7px 10px;
  background: var(--sky-soft); border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 11.5px; color: var(--muted);
}
.account-user b { color: var(--sky-deep); }
.logout {
  padding: 4px 10px; font-size: 11px; color: var(--sky-deep);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.logout:hover { color: var(--err); border-color: var(--err); }

/* ---------- Saved people ---------- */
.people-card {
  margin-top: 16px; padding: 12px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.save-person {
  float: right; padding: 3px 9px; font-size: 10.5px; font-weight: 600;
  color: var(--sky-deep); background: var(--sky-soft);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  text-transform: none; letter-spacing: 0;
}
.save-person:hover:not(:disabled) {
  color: var(--on-accent); border-color: transparent; background: var(--sky);
}
.save-person:disabled { opacity: 0.5; cursor: not-allowed; }
.people-list { list-style: none; margin: 4px 0 0; padding: 0; }
.people-list li { display: flex; align-items: stretch; gap: 6px; margin-bottom: 5px; }
.p-load {
  flex: 1; text-align: left; padding: 7px 10px; font-size: 12.5px; font-weight: 500;
  color: var(--ink); background: var(--field); border: 1px solid var(--line);
  border-radius: var(--radius-sm); transition: border-color .15s, background .15s;
}
.p-load small { color: var(--faint); font-weight: 400; margin-left: 4px; }
.p-load:hover { border-color: var(--sky); background: var(--sky-soft); }
/* The saved chat the composer is currently writing to. */
.conv-list li.active .p-load {
  border-color: var(--sky); background: var(--sky-soft); font-weight: 600;
}
.p-del {
  flex: 0 0 auto; width: 30px; font-size: 12px; color: var(--faint);
  background: var(--field); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.p-del:hover { color: var(--err); border-color: var(--err); background: rgba(229, 72, 77, 0.06); }
.people-empty { font-size: 11.5px; color: var(--faint); padding: 4px 0; }

/* ---------- Auth overlay ---------- */
.auth-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 20px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.32), rgba(232, 242, 253, 0.5)),
    url("cosmos-bg.webp") center center / cover no-repeat fixed;
}
.auth-box {
  width: 100%; max-width: 340px; text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px 26px; box-shadow: var(--shadow-sm);
}
.auth-mark { width: 56px; height: 56px; margin: 0 auto 12px; }
.auth-box h2 { font-family: var(--font-head); font-weight: 600; color: var(--ink); margin: 0 0 4px; font-size: 21px; }
.auth-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 18px; }
/* Continue with Google */
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 10px 12px; margin-bottom: 4px;
  font-size: 13.5px; font-weight: 600; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  cursor: pointer; transition: background .15s, border-color .15s, box-shadow .15s;
}
.google-btn:hover { background: #f7f9fc; border-color: var(--sky); box-shadow: var(--shadow-sm); }
.google-btn svg { flex: 0 0 auto; }
/* "or" divider between Google and the email form */
.auth-or {
  display: flex; align-items: center; gap: 10px;
  margin: 14px 2px 12px; color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
}
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-form { display: flex; flex-direction: column; gap: 9px; }
.auth-form input {
  margin-top: 0; padding: 10px 12px; font-size: 13.5px;
  background: var(--field); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--ink);
}
.auth-form input:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.14); }
#authSubmit {
  margin-top: 4px; padding: 10px; font-size: 13.5px; color: var(--on-accent);
  background: var(--sky);
}
#authSubmit:hover:not(:disabled) { background: var(--sky-deep); }
#authSubmit:disabled { opacity: 0.6; cursor: wait; }
.auth-form .err { text-align: left; }
.auth-switch { margin: 16px 0 0; font-size: 12px; color: var(--muted); }
#authSwitch {
  background: none; color: var(--sky-deep); font-size: 12px; font-weight: 600;
  padding: 0 0 0 4px; text-decoration: underline;
}

/* ---------- Responsive: stack + compact on small screens ---------- */
/* Mobile drawer controls + branding bar — hidden on desktop */
.panel-toggle, .panel-scrim, .mobile-bar { display: none; }

@media (max-width: 820px) {
  /* fixed backgrounds jank on mobile Safari — let it scroll with content;
     overflow-x is a defensive guard against sub-pixel horizontal scroll. */
  html, body { background-attachment: scroll; overflow-x: hidden; }

  /* Chat takes the full width; the sidebar becomes a slide-in drawer. */
  .app { grid-template-columns: 1fr; }
  .chat { height: 100vh; height: 100dvh; }

  .panel {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: min(86vw, 340px); z-index: 200;
    border-right: 1px solid var(--line); border-bottom: none;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 4px 0 28px rgba(20, 50, 80, 0.22);
  }
  .app.panel-open .panel { transform: translateX(0); }
  .brand { display: none; }              /* the sidebar's own logo lives on desktop only */
  .panel-scroll { padding: 54px 14px 18px; }   /* top clears the floating hamburger */

  /* Fixed branding bar across the top — always visible once signed in, so
     closing the drawer reveals the chat under a pinned Pythia header. It sits
     below the scrim (z 190) so a tap anywhere on it also closes an open drawer. */
  .mobile-bar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 180;
    display: flex; align-items: center; gap: 9px;
    height: 52px; padding: 0 14px 0 62px;  /* left padding clears the floating hamburger */
    background: var(--panel); border-bottom: 1px solid var(--line);
    box-shadow: 0 1px 10px rgba(20, 50, 80, 0.06);
  }
  .mobile-bar .brand-mark { width: 30px; height: 30px; }
  .mobile-bar h1 {
    margin: 0; font-family: var(--font-head); font-size: 17px;
    font-weight: 600; letter-spacing: 0.2px; color: var(--ink);
  }

  /* Hamburger toggle + backdrop */
  .panel-toggle {
    position: fixed; top: 5px; left: 10px; z-index: 210;
    width: 42px; height: 42px; display: grid; place-items: center;
    font-size: 18px; color: var(--on-accent); background: var(--sky);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
  }
  /* Once the drawer is open it stays out of the way — close it by tapping the
     chat or the branding bar. This also keeps it off the scrolling sidebar. */
  .app.panel-open .panel-toggle { display: none; }
  /* Transparent tap-catcher over the chat: no dimming, but tapping the chat
     while the drawer is open closes the drawer. */
  .panel-scrim {
    position: fixed; inset: 0; z-index: 190; display: block;
    background: transparent;
    pointer-events: none;
  }
  .app.panel-open .panel-scrim { pointer-events: auto; }

  /* Chat gutters; keep content clear of the fixed top bar */
  .chat-scroll { padding: 64px 0 18px; }
  .msg { padding: 0 14px; gap: 10px; }
  .suggestions, .composer { padding-left: 14px; padding-right: 14px; }
  .welcome { margin-top: 6vh; }

  /* Touch targets ≥44px */
  #computeBtn, #matchBtn, #authSubmit, #sendBtn { padding-top: 12px; padding-bottom: 12px; }
  .suggestions button { padding: 8px 13px; }
  .p-del { width: 40px; }
}

@media (max-width: 480px) {
  /* Compact type + spacing for phones */
  .brand { margin-bottom: 12px; }
  .chart-card, .match-card, .people-card { padding: 11px; margin-top: 12px; }
  .msg { margin-bottom: 14px; }
  .composer { padding-top: 8px; padding-bottom: 14px; }
  .welcome h2 { font-size: 20px; }
  .welcome-glyph { font-size: 34px; }
  .auth-box { padding: 22px 18px; }
}

/* ================= Public site: landing + legal pages ================= */
.site { display: flex; flex-direction: column; min-height: 100vh; }

.site-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; gap: 12px;
}
.site-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 700; }
.site-brand span { font-family: var(--font-head); font-size: 20px; }
.site-brand .brand-mark { width: 32px; height: 32px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 16px; border-radius: var(--radius-sm); font-weight: 600; font-size: 13.5px;
  text-decoration: none; cursor: pointer; border: 1px solid transparent;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn-primary { background: var(--sky); color: var(--on-accent); }
.btn-primary:hover { background: var(--sky-deep); }
.btn-ghost { background: var(--panel); color: var(--sky-deep); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--sky); box-shadow: var(--shadow-sm); }
.btn-lg { padding: 12px 22px; font-size: 15px; }

.landing { flex: 1 1 auto; }
.section { padding: 8px 0 8px; }
.section-title { text-align: center; font-family: var(--font-head); font-weight: 600; font-size: clamp(20px, 3vw, 28px); color: var(--ink); margin: 24px 0 4px; }
.section-lead { text-align: center; color: var(--muted); font-size: 14px; margin: 0 auto 18px; max-width: 560px; padding: 0 20px; }
.hero { max-width: 760px; margin: 0 auto; padding: 48px 24px 40px; text-align: center; }
.hero-glyph { font-size: 44px; color: var(--sky); margin-bottom: 10px; }
.hero h1 {
  font-family: var(--font-head); font-weight: 700; font-size: clamp(28px, 5vw, 46px);
  color: var(--ink); margin: 0 0 14px; line-height: 1.12;
}
.hero-sub { font-size: clamp(15px, 2.2vw, 18px); color: var(--muted); line-height: 1.6; margin: 0 auto 24px; max-width: 620px; }
.hero-sub b { color: var(--ink); }
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero-note { margin-top: 16px; font-size: 12px; color: var(--faint); }

.features {
  max-width: 1000px; margin: 24px auto 8px; padding: 0 24px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
}
.feature {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 18px; box-shadow: var(--shadow-sm);
}
.feature-ic {
  width: 40px; height: 40px; border-radius: var(--radius-sm); display: grid; place-items: center;
  font-size: 20px; color: var(--sky); background: var(--sky-soft); margin-bottom: 12px;
}
.feature h3 { font-family: var(--font-head); font-size: 17px; color: var(--ink); margin: 0 0 6px; }
.feature p { font-size: 13px; color: var(--muted); line-height: 1.55; margin: 0; }

.accounts { display: flex; justify-content: center; padding: 28px 24px 8px; }
.accounts-card {
  width: 100%; max-width: 760px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 28px 32px;
}
.accounts-card h2 { font-family: var(--font-head); font-size: 20px; color: var(--sky-deep); margin: 0 0 10px; }
.accounts-card p { color: var(--muted); font-size: 14px; line-height: 1.65; margin: 0 0 10px; }
.accounts-card p:last-child { margin-bottom: 0; }
.accounts-card b { color: var(--ink); }
.accounts-card a { color: var(--sky-deep); }

.cta-band { text-align: center; padding: 48px 24px 8px; }
.cta-band h2 {
  font-family: var(--font-head); font-weight: 600; font-size: clamp(22px, 3.5vw, 30px);
  color: var(--ink); margin: 0 0 18px;
}

.site-footer {
  margin-top: 40px; padding: 28px 24px; border-top: 1px solid var(--line);
  text-align: center; color: var(--muted); background: var(--panel);
}
.foot-brand { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-head); font-weight: 700; color: var(--ink); margin-bottom: 10px; }
.foot-brand .brand-mark { width: 24px; height: 24px; }
.foot-links { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin-bottom: 12px; }
.foot-links a { color: var(--sky-deep); text-decoration: none; font-size: 13px; font-weight: 500; }
.foot-links a:hover { text-decoration: underline; }
.foot-fine { max-width: 560px; margin: 0 auto 8px; font-size: 11.5px; color: var(--faint); line-height: 1.5; }
.foot-copy { font-size: 12px; color: var(--faint); margin: 0; }

/* Legal pages */
.legal { flex: 1 1 auto; padding: 24px; display: flex; justify-content: center; }
.legal-card {
  width: 100%; max-width: 760px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 36px 40px;
}
.legal-card h1 { font-family: var(--font-head); font-size: 30px; color: var(--ink); margin: 0 0 4px; }
.legal-date { color: var(--faint); font-size: 12.5px; margin: 0 0 22px; }
.legal-card h2 { font-family: var(--font-head); font-size: 18px; color: var(--sky-deep); margin: 24px 0 8px; }
.legal-card p, .legal-card li { color: var(--muted); font-size: 14px; line-height: 1.65; }
.legal-card ul { padding-left: 20px; margin: 8px 0; }
.legal-card li { margin-bottom: 6px; }
.legal-card b { color: var(--ink); }
.legal-card code { background: var(--panel2); padding: 1px 5px; border-radius: var(--radius-xs); font-size: 12.5px; }
.legal-card a { color: var(--sky-deep); }
.legal-back { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); }

/* Legal links under the app's login box */
.auth-legal { margin: 14px 0 0; font-size: 11px; color: var(--faint); line-height: 1.5; }
.auth-legal a { color: var(--muted); text-decoration: underline; }

@media (max-width: 720px) {
  .features { grid-template-columns: 1fr 1fr; }
  .site-nav { padding: 14px 18px; }
  .legal-card { padding: 26px 22px; }
}
@media (max-width: 480px) {
  .features { grid-template-columns: 1fr; }
  .hero { padding: 32px 20px; }
}
