/* IBBlueprint — styling. Restrained, "serious finance" palette: deep navy,
   warm off-white paper, a single brass/gold accent. Built mobile-first. */
:root {
  --navy: #0f1b2d;
  --navy-2: #16263d;
  --paper: #f7f5f0;
  --card: #ffffff;
  --ink: #16202e;
  --muted-ink: #6b7686;
  --line: #e4e0d7;
  --accent: #b8893b;     /* brass */
  --accent-deep: #9a6f28;
  --good: #2e8b57;
  --mid: #c79a2e;
  --warn: #c0532f;
  --ring-bg: #ece8df;
  --cell-empty: #efece4;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16,27,45,.06), 0 8px 24px rgba(16,27,45,.06);
  --font: "Iowan Old Style", "Palatino Linotype", "Georgia", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
button { font-family: inherit; cursor: pointer; }

/* ---------------- Top bar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: var(--navy);
  color: #fff;
  border-bottom: 2px solid var(--accent);
}
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.brand-mark {
  font-family: var(--font); font-weight: 700; font-size: 16px;
  background: var(--accent); color: var(--navy);
  width: 36px; height: 36px; border-radius: 8px;
  display: grid; place-items: center; letter-spacing: -.5px;
}
.brand-titles { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-family: var(--font); font-size: 19px; letter-spacing: .3px; }
.brand-by { font-size: 11px; color: var(--accent); letter-spacing: .4px; text-transform: none; opacity: .9; }
.nav { display: flex; gap: 4px; }
.nav-link {
  background: transparent; border: none; color: #c9d2de;
  padding: 8px 14px; border-radius: 8px; font-size: 14px; font-weight: 500;
}
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.active { background: var(--accent); color: var(--navy); font-weight: 600; }

/* ---------------- Layout ---------------- */
.container { max-width: 920px; margin: 0 auto; padding: 28px 20px 80px; }
.container.narrow { max-width: 680px; }
.page-title { font-family: var(--font); font-size: 30px; margin: 6px 0 22px; }
.section-h { font-family: var(--font); font-size: 21px; margin: 34px 0 14px; }
.muted { color: var(--muted-ink); font-size: 14px; margin-top: -6px; }
.empty { color: var(--muted-ink); text-align: center; padding: 40px 0; }

/* ---------------- Hero ---------------- */
.hero { text-align: center; padding: 26px 0 10px; }
.hero h1 { font-family: var(--font); font-size: 40px; line-height: 1.1; margin: 0 0 14px; letter-spacing: -.5px; }
.hero .sub { color: var(--muted-ink); max-width: 560px; margin: 0 auto 24px; font-size: 16px; }
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------------- Buttons ---------------- */
.btn {
  border: 1px solid transparent; border-radius: 10px;
  padding: 10px 18px; font-size: 15px; font-weight: 600;
  transition: transform .04s ease, box-shadow .2s ease, background .2s ease;
}
.btn:active { transform: translateY(1px); }
.btn.big { padding: 14px 26px; font-size: 16px; }
.btn.small { padding: 7px 13px; font-size: 13px; }
.btn-primary { background: var(--navy); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--navy-2); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-deep); }

/* ---------------- Stat cards ---------------- */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 28px 0 8px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-align: center; box-shadow: var(--shadow); }
.stat-value { font-family: var(--font); font-size: 28px; font-weight: 700; }
.stat-label { color: var(--muted-ink); font-size: 12px; margin-top: 2px; text-transform: uppercase; letter-spacing: .5px; }

/* ---------------- Category grid ---------------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.cat-card { text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.cat-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.cat-name { font-family: var(--font); font-size: 18px; margin-bottom: 10px; }
.cat-bar { height: 7px; background: var(--ring-bg); border-radius: 4px; overflow: hidden; }
.cat-bar-fill { height: 100%; border-radius: 4px; }
.cat-score { color: var(--muted-ink); font-size: 12px; margin-top: 8px; }

/* ---------------- Setup ---------------- */
.field-label { font-size: 14px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted-ink); margin: 26px 0 10px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; font-size: 14px; color: var(--ink); }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip:hover:not(.on) { border-color: var(--accent); }
.mode-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mode-card { text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.mode-card.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.mode-name { font-weight: 700; margin-bottom: 4px; }
.mode-desc { font-size: 12.5px; color: var(--muted-ink); }
.setup-actions { margin-top: 32px; }

/* ---------------- Session ---------------- */
.progress-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.progress-track { flex: 1; height: 8px; background: var(--ring-bg); border-radius: 5px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 5px; transition: width .3s ease; }
.progress-text { font-size: 13px; color: var(--muted-ink); font-variant-numeric: tabular-nums; }

.q-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tag { font-size: 11.5px; padding: 3px 9px; border-radius: 6px; background: #eef0f3; color: #4a5568; font-weight: 600; letter-spacing: .2px; }
.tag-cat { background: var(--navy); color: #fff; }
.tag-variant { background: #efe6d4; color: var(--accent-deep); text-transform: capitalize; }
.tag-diff.diff-foundational { background: #e3f0e8; color: #2e8b57; }
.tag-diff.diff-intermediate { background: #fbf0d8; color: #a87c1e; }
.tag-diff.diff-advanced { background: #f6e0d6; color: #b04a26; }

.q-card { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 18px; }
.q-prompt { font-family: var(--font); font-size: 22px; line-height: 1.35; margin: 0; }

.answer-panel { }
.answer-input { width: 100%; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; font-size: 16px; font-family: var(--sans); resize: vertical; background: var(--card); color: var(--ink); }
.answer-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(184,137,59,.15); }
.answer-tools { display: flex; align-items: center; gap: 12px; margin: 12px 0; flex-wrap: wrap; }
.btn-mic { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 9px 16px; font-size: 14px; font-weight: 600; color: var(--ink); }
.btn-mic.live { background: var(--warn); color: #fff; border-color: var(--warn); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(192,83,47,.4); } 50% { box-shadow: 0 0 0 8px rgba(192,83,47,0); } }
.voice-hint { font-size: 12px; color: var(--muted-ink); }
.answer-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------------- Feedback ---------------- */
.feedback { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.score-block { display: flex; align-items: center; gap: 20px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; box-shadow: var(--shadow); margin-bottom: 18px; }
.ring { width: 96px; height: 96px; flex-shrink: 0; }
.ring-text { font-family: var(--font); font-size: 30px; font-weight: 700; }
.score-headline { font-family: var(--font); font-size: 22px; }
.score-sub { color: var(--muted-ink); font-size: 14px; margin-top: 4px; }

.your-answer, .why { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 4px 14px; margin-bottom: 14px; }
.your-answer summary, .why summary { cursor: pointer; font-weight: 600; padding: 10px 0; font-size: 14px; }
.your-answer p, .why p { color: var(--muted-ink); margin: 0 0 12px; }

.fb-h { font-family: var(--font); font-size: 17px; margin: 22px 0 10px; }
.concepts { display: flex; flex-direction: column; gap: 7px; }
.concept-row { display: flex; gap: 10px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 9px; padding: 10px 13px; font-size: 14.5px; }
.concept-row.hit { border-left: 3px solid var(--good); }
.concept-row.miss { border-left: 3px solid var(--warn); }
.concept-mark { font-weight: 800; }
.concept-row.hit .concept-mark { color: var(--good); }
.concept-row.miss .concept-mark { color: var(--warn); }

.model-answer { background: #fffdf8; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 16px 20px; }
.model-answer p { margin: 0; font-size: 15.5px; line-height: 1.6; }
.refs { margin-top: 14px; font-size: 13px; }
.refs-label { color: var(--muted-ink); }
.ref-pill { display: inline-block; background: #eef0f3; color: #4a5568; border-radius: 6px; padding: 3px 9px; margin: 0 4px 4px 0; font-size: 12px; }

.siblings-note { margin: -4px 0 10px; }
.siblings { display: flex; flex-direction: column; gap: 7px; }
.sibling-row { display: flex; gap: 10px; align-items: flex-start; background: #fbfaf6; border: 1px dashed var(--line); border-left: 3px solid var(--accent); border-radius: 9px; padding: 10px 13px; }
.sibling-text { font-size: 14.5px; font-style: italic; color: #2a3340; }

.selfgrade { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sg { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; font-size: 15px; font-weight: 600; background: var(--card); }
.sg-bad:hover { background: #f6e0d6; border-color: var(--warn); }
.sg-mid:hover { background: #fbf0d8; border-color: var(--mid); }
.sg-good:hover { background: #e3f0e8; border-color: var(--good); }
.fb-foot { margin-top: 16px; }

/* ---------------- Session complete ---------------- */
.complete-card { text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 40px 24px; box-shadow: var(--shadow); }
.complete-emoji { font-size: 40px; }
.complete-card h1 { font-family: var(--font); margin: 8px 0; }
.complete-card .ring { margin: 16px auto; }
.complete-note { color: var(--muted-ink); }
.complete-actions { display: flex; gap: 10px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }

/* ---------------- Dashboard ---------------- */
.dash-top { display: grid; grid-template-columns: 180px 1fr; gap: 20px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.dash-ring { text-align: center; }
.dash-ring .ring { width: 130px; height: 130px; }
.dash-ring-label { font-size: 13px; color: var(--muted-ink); margin-top: 4px; }
.dash-kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.kpi { }
.kpi-value { font-family: var(--font); font-size: 26px; font-weight: 700; }
.kpi-label { color: var(--muted-ink); font-size: 13px; }

.heat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.heat-col { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.heat-cat { font-family: var(--font); font-size: 15px; margin-bottom: 8px; font-weight: 600; }
.heat-cell { display: flex; justify-content: space-between; align-items: center; border-radius: 7px; padding: 8px 10px; margin-bottom: 6px; font-size: 12.5px; }
.heat-sub { color: #2a3340; }
.heat-val { font-weight: 700; font-variant-numeric: tabular-nums; }

.reco { display: flex; align-items: center; justify-content: space-between; gap: 16px; background: var(--navy); color: #fff; border-radius: var(--radius); padding: 18px 22px; margin-top: 24px; flex-wrap: wrap; }
.reco-label { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: #aebacb; }
.reco-cat { font-family: var(--font); font-size: 20px; }
.reco .btn-primary { background: var(--accent); color: var(--navy); }
.reco .btn-primary:hover { background: #c89846; }

.fav-list { display: flex; flex-direction: column; gap: 8px; }
.fav-row { display: flex; gap: 10px; align-items: center; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; font-size: 14px; }
.fav-row:hover { border-color: var(--accent); }

/* ---------------- Browse ---------------- */
.browse-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; box-shadow: var(--shadow); }
.browse-card summary { display: flex; gap: 10px; align-items: center; padding: 14px 16px; cursor: pointer; list-style: none; }
.browse-card summary::-webkit-details-marker { display: none; }
.browse-q { flex: 1; font-size: 15px; }
.browse-score { color: var(--muted-ink); font-size: 13px; font-variant-numeric: tabular-nums; }
.browse-body { padding: 0 16px 16px; border-top: 1px solid var(--line); }
.browse-sec-h { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted-ink); margin: 14px 0 6px; }
.browse-body ul { margin: 0; padding-left: 18px; font-size: 14px; }
.browse-body li { margin-bottom: 4px; }
.variant-row { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; padding: 6px 0; }

/* ---------------- Responsive ---------------- */
@media (max-width: 680px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .mode-row { grid-template-columns: 1fr; }
  .dash-top { grid-template-columns: 1fr; }
  .dash-kpis { grid-template-columns: repeat(2, 1fr); }
  .hero h1 { font-size: 30px; }
  .q-prompt { font-size: 19px; }
  .nav-link { padding: 8px 10px; font-size: 13px; }
  .selfgrade { grid-template-columns: 1fr; }
}

/* ---------------- Auth (login modal + account) ---------------- */
.nav-link.login-link { background: var(--accent); color: var(--navy); font-weight: 600; }
.nav-link.login-link:hover { background: #c89846; color: var(--navy); }
.nav-link.acct-link { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.acct-link:hover { background: rgba(255,255,255,.16); }

.sd-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15,27,45,.55); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px;
  animation: sdfade .18s ease;
}
@keyframes sdfade { from { opacity: 0; } to { opacity: 1; } }
.sd-card {
  position: relative; width: 100%; max-width: 380px;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 28px 26px; box-shadow: 0 20px 60px rgba(16,27,45,.3);
  animation: sdpop .2s ease;
}
@keyframes sdpop { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.sd-x { position: absolute; top: 12px; right: 14px; border: none; background: transparent; font-size: 22px; line-height: 1; color: var(--muted-ink); cursor: pointer; }
.sd-x:hover { color: var(--ink); }
.sd-brand { font-family: var(--font); font-size: 15px; color: var(--accent-deep); letter-spacing: .3px; }
.sd-title { font-family: var(--font); font-size: 23px; margin: 4px 0 4px; }
.sd-sub { color: var(--muted-ink); font-size: 13.5px; margin: 0 0 18px; }
.sd-google {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  border: 1px solid var(--line); background: #fff; color: #1f2733;
  border-radius: 10px; padding: 11px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.sd-google:hover { background: #f6f5f1; border-color: #cfcabf; }
.sd-gicon { display: inline-flex; }
.sd-divider { display: flex; align-items: center; text-align: center; color: var(--muted-ink); font-size: 12px; margin: 16px 0; }
.sd-divider::before, .sd-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.sd-divider span { padding: 0 10px; }
.sd-input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px;
  font-size: 15px; margin-bottom: 10px; background: var(--card); color: var(--ink); font-family: var(--sans);
}
.sd-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(184,137,59,.15); }
.sd-msg { font-size: 13px; color: var(--warn); min-height: 16px; margin: 2px 0 8px; }
.sd-msg.ok { color: var(--good); }
.sd-primary {
  width: 100%; border: none; background: var(--navy); color: #fff;
  border-radius: 10px; padding: 12px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.sd-primary:hover { background: var(--navy-2); }
.sd-primary.ghost { background: transparent; color: var(--warn); border: 1px solid var(--line); }
.sd-primary.ghost:hover { border-color: var(--warn); background: #f6e0d6; }
.sd-switch { text-align: center; font-size: 13.5px; color: var(--muted-ink); margin-top: 14px; }
.sd-switch a { color: var(--accent-deep); font-weight: 600; text-decoration: none; }
.sd-switch a:hover { text-decoration: underline; }
.sd-acct-head { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted-ink); }
.sd-acct-email { font-family: var(--font); font-size: 18px; margin: 2px 0 6px; word-break: break-all; }
