/* CFP Study — app shell styles. Tokens are shared with module CSS (hp12c.css). */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #14181f;
  --muted: #5d6675;
  --border: #dde2ea;
  --accent: #0f6b62;
  --accent-2: #e7f3f1;
  --accent-ink: #ffffff;
  --good: #1a7f4b;
  --good-bg: #e6f4ec;
  --bad: #c0392b;
  --bad-bg: #fbeceb;
  --warn: #9a6700;
  --warn-bg: #fff4d6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 2px 8px rgba(16, 24, 40, .05);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  /* domain colors */
  --d-conduct: #7c3aed;
  --d-general: #2563eb;
  --d-risk: #db2777;
  --d-investment: #059669;
  --d-tax: #d97706;
  --d-retirement: #0891b2;
  --d-estate: #9333ea;
  --d-psychology: #e11d48;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116; --surface: #161a21; --surface-2: #1d232c; --text: #e8ecf2; --muted: #9aa4b2;
    --border: #2a313c; --accent: #3cc7b4; --accent-2: #13302c; --accent-ink: #062520;
    --good: #4ade80; --good-bg: #10281a; --bad: #f87171; --bad-bg: #2d1414; --warn: #fbbf24; --warn-bg: #2a2110;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    --d-conduct: #a78bfa; --d-general: #60a5fa; --d-risk: #f472b6; --d-investment: #34d399;
    --d-tax: #fbbf24; --d-retirement: #22d3ee; --d-estate: #c084fc; --d-psychology: #fb7185;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1116; --surface: #161a21; --surface-2: #1d232c; --text: #e8ecf2; --muted: #9aa4b2;
  --border: #2a313c; --accent: #3cc7b4; --accent-2: #13302c; --accent-ink: #062520;
  --good: #4ade80; --good-bg: #10281a; --bad: #f87171; --bad-bg: #2d1414; --warn: #fbbf24; --warn-bg: #2a2110;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
  --d-conduct: #a78bfa; --d-general: #60a5fa; --d-risk: #f472b6; --d-investment: #34d399;
  --d-tax: #fbbf24; --d-retirement: #22d3ee; --d-estate: #c084fc; --d-psychology: #fb7185;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 15.5px; line-height: 1.55; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0 0 .8em; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: .05em .35em; border-radius: 5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
.sidebar { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 12px; font-weight: 800; letter-spacing: .02em;
}
.topbar .spacer { flex: 1; }
.sync-pill { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.sync-dot.ok { background: var(--good); } .sync-dot.err { background: var(--bad); } .sync-dot.busy { background: var(--warn); }
.countdown-chip { font-size: 12px; font-weight: 600; background: var(--accent-2); color: var(--accent); padding: 4px 10px; border-radius: 99px; white-space: nowrap; }

main#view { padding: 20px 16px 110px; max-width: 1100px; width: 100%; margin: 0 auto; min-width: 0; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; font-size: 11px;
  color: var(--muted); font-weight: 500;
}
.bottomnav a:hover { text-decoration: none; }
.bottomnav a.active { color: var(--accent); }
.bottomnav svg, .sidebar svg { width: 22px; height: 22px; }

@media (min-width: 900px) {
  .shell { grid-template-columns: 240px 1fr; }
  .sidebar {
    display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
    padding: 18px 12px; border-right: 1px solid var(--border); background: var(--surface);
  }
  .sidebar .brand { padding: 4px 10px 18px; }
  .sidebar a.nav {
    display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 9px; color: var(--muted); font-weight: 500;
  }
  .sidebar a.nav:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
  .sidebar a.nav.active { background: var(--accent-2); color: var(--accent); }
  .sidebar .nav-sep { margin: 12px 12px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
  .sidebar .side-foot { margin-top: auto; padding: 12px; font-size: 12px; color: var(--muted); }
  .topbar .brand { display: none; }
  .bottomnav { display: none; }
  main#view { padding: 28px 32px 60px; }
}

/* ---------- common components ---------- */
.page-head { margin-bottom: 20px; }
.page-head p { color: var(--muted); margin: 0; }
.eyebrow { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 6px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs a { color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 14px; }
.card h2, .card h3 { margin-bottom: 8px; }
.card.flat { box-shadow: none; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: 1fr; }
.grid.three, .grid.four { grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid.two, .grid.four { grid-template-columns: 1fr 1fr; } .grid.three { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1000px) { .grid.three { grid-template-columns: repeat(3, 1fr); } .grid.four { grid-template-columns: repeat(4, 1fr); } }
.stack > * + * { margin-top: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer;
  min-height: 40px; text-decoration: none; transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { padding: 5px 11px; min-height: 32px; font-size: 13px; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.accent { background: var(--accent-2); color: var(--accent); }

.dom-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label, .field .lbl { font-size: 13px; font-weight: 600; color: var(--muted); }
input[type=text], input[type=number], input[type=date], input[type=password], input[type=search], select, textarea {
  width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  min-height: 40px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); border-radius: 99px; padding: 6px 12px;
  background: var(--surface); cursor: pointer; font-size: 13.5px; user-select: none;
}
.chip input { display: none; }
.chip.on, .chip:has(input:checked) { border-color: var(--accent); background: var(--accent-2); color: var(--accent); font-weight: 600; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); font-weight: 600; }
tr:last-child td { border-bottom: 0; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); opacity: 0; z-index: 100;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 500;
  transition: .2s; pointer-events: none; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.loading { padding: 40px 0; text-align: center; color: var(--muted); }

/* ---------- dashboard ---------- */
.hero { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .hero { grid-template-columns: 1.3fr 1fr; } }
.ring-wrap { display: flex; align-items: center; gap: 18px; }
.ring { width: 112px; height: 112px; flex: none; }
.ring text { font-family: var(--font); }
.big-num { font-size: 2rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.kpi .v { font-size: 1.25rem; font-weight: 700; }
.kpi .l { font-size: 12px; color: var(--muted); }
.dom-card { display: flex; flex-direction: column; gap: 8px; color: var(--text); }
.dom-card:hover { text-decoration: none; border-color: var(--accent); }
.dom-card .top { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.dom-card .name { font-weight: 650; display: flex; align-items: center; gap: 8px; }
.dom-card .stats { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.next-list { list-style: none; margin: 0; padding: 0; }
.next-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.next-list li:last-child { border-bottom: 0; }
.next-list .ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-2); color: var(--accent); flex: none; font-weight: 700; }
.next-list .txt { flex: 1; min-width: 0; }
.heat { display: grid; grid-template-columns: repeat(auto-fill, minmax(26px, 1fr)); gap: 4px; }
.heat a { aspect-ratio: 1; border-radius: 5px; display: block; background: var(--surface-2); }

/* ---------- notes ---------- */
.topic-list { list-style: none; margin: 0; padding: 0; }
.topic-list li a { display: flex; gap: 12px; align-items: flex-start; padding: 12px 4px; border-bottom: 1px solid var(--border); color: var(--text); }
.topic-list li:last-child a { border-bottom: 0; }
.topic-list li a:hover { text-decoration: none; background: var(--surface-2); }
.topic-list .n { font-family: var(--mono); font-size: 12px; color: var(--muted); width: 26px; flex: none; padding-top: 2px; }
.topic-list .t { flex: 1; min-width: 0; }
.topic-list .t strong { display: block; font-weight: 600; }
.topic-list .t span { font-size: 13px; color: var(--muted); }
.check { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border); flex: none; margin-top: 2px; display: grid; place-items: center; }
.check.on { background: var(--good); border-color: var(--good); color: #fff; }
.check.on::after { content: ""; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }

.notes-layout { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 1100px) { .notes-layout { grid-template-columns: minmax(0, 1fr) 280px; } .notes-aside { position: sticky; top: 80px; align-self: start; } }
.prose { font-size: 16px; line-height: 1.7; max-width: 72ch; }
.prose h4 { font-size: 1.05rem; margin: 1.6em 0 .5em; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1em; }
.prose li { margin-bottom: .35em; }
.prose table { margin: 1em 0; font-size: 14px; }
.prose .table-wrap { margin: 1em 0; }
.prose .table-wrap table { margin: 0; }
.callout { border-radius: 10px; padding: 14px 16px; border: 1px solid var(--border); background: var(--surface); }
.callout h3 { font-size: .95rem; display: flex; align-items: center; gap: 8px; }
.callout ul { margin: 0; padding-left: 1.2em; }
.callout li { margin-bottom: .4em; }
.callout.key { border-left: 4px solid var(--accent); }
.callout.trap { border-left: 4px solid var(--bad); }
.callout.formula { border-left: 4px solid var(--warn); }
.pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 24px; flex-wrap: wrap; }

/* ---------- questions ---------- */
.q-wrap { max-width: 780px; }
.q-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.q-stem { font-size: 16.5px; line-height: 1.6; white-space: pre-line; margin-bottom: 16px; }
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice {
  display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 12px 14px; border-radius: 10px;
  border: 1.5px solid var(--border); background: var(--surface); cursor: pointer; width: 100%; line-height: 1.5;
}
.choice:hover:not(:disabled) { border-color: var(--accent); }
.choice .letter {
  flex: none; width: 26px; height: 26px; border-radius: 7px; background: var(--surface-2); display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
}
.choice.selected { border-color: var(--accent); background: var(--accent-2); }
.choice.selected .letter { background: var(--accent); color: var(--accent-ink); }
.choice.correct { border-color: var(--good); background: var(--good-bg); }
.choice.correct .letter { background: var(--good); color: #fff; }
.choice.wrong { border-color: var(--bad); background: var(--bad-bg); }
.choice.wrong .letter { background: var(--bad); color: #fff; }
.choice:disabled { cursor: default; }
.explain { margin-top: 16px; border-radius: 10px; padding: 14px 16px; background: var(--surface-2); white-space: pre-line; line-height: 1.6; }
.explain h3 { margin-bottom: 6px; }
.q-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; align-items: center; }
.q-progress { height: 4px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-bottom: 16px; }
.q-progress span { display: block; height: 100%; background: var(--accent); }
.case-box { margin-bottom: 16px; }
.case-box details > summary { cursor: pointer; font-weight: 600; }
.case-box .prose { font-size: 15px; }

/* mock exam */
.exam-bar {
  position: sticky; top: 57px; z-index: 20; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; margin-bottom: 16px;
}
@media (min-width: 900px) { .exam-bar { top: 64px; } }
.timer { font-family: var(--mono); font-weight: 700; font-size: 15px; }
.timer.low { color: var(--bad); }
.nav-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; }
.nav-grid button {
  height: 36px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 12.5px;
  font-variant-numeric: tabular-nums; position: relative;
}
.nav-grid button.answered { background: var(--accent-2); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.nav-grid button.current { outline: 2px solid var(--text); }
.nav-grid button.flagged::after { content: ""; position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }
.nav-grid button.correct { background: var(--good-bg); border-color: var(--good); color: var(--good); }
.nav-grid button.wrong { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }

/* flashcards */
.flash { perspective: 1400px; max-width: 640px; margin: 0 auto; }
.flash-inner {
  position: relative; min-height: 260px; transition: transform .45s; transform-style: preserve-3d; cursor: pointer;
}
.flash.flipped .flash-inner { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; flex-direction: column;
  justify-content: center; align-items: center; text-align: center; padding: 28px; border-radius: 16px; background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow); font-size: 18px; line-height: 1.5; overflow-y: auto;
}
.flash-face .tag { position: absolute; top: 12px; left: 14px; font-size: 12px; color: var(--muted); }
.flash-back { transform: rotateY(180deg); }
.rate-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 640px; margin: 16px auto 0; }
.rate-row .btn { flex-direction: column; gap: 0; font-size: 14px; padding: 8px 4px; }
.rate-row .btn small { font-weight: 500; color: var(--muted); font-size: 11px; }

/* figures */
.fig-status { white-space: nowrap; }
.fig-table td:nth-child(2) { font-weight: 650; white-space: nowrap; }
.fig-table td:nth-child(3) { color: var(--muted); white-space: nowrap; }
@media (max-width: 640px) {
  .fig-table thead { display: none; }
  .fig-table tr { display: block; padding: 10px 12px; border-bottom: 1px solid var(--border); }
  .fig-table td { display: block; padding: 2px 0; border: 0; white-space: normal !important; }
  .fig-table td:nth-child(3)::before { content: "2025: "; }
}
.sec-nav { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 14px; scrollbar-width: thin; }
.sec-nav a { white-space: nowrap; font-size: 13px; padding: 5px 11px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); color: var(--text); }

/* tools */
.tool-out { background: var(--surface-2); border-radius: 10px; padding: 14px; }
.tool-out .line { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px dashed var(--border); font-variant-numeric: tabular-nums; }
.tool-out .line:last-child { border-bottom: 0; }
.tool-out .line.total { font-weight: 700; font-size: 1.05em; }
.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tabs a { padding: 9px 12px; white-space: nowrap; color: var(--muted); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--accent); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* planner */
.week { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--surface); }
.week.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.week .wk-head { display: flex; justify-content: space-between; gap: 10px; font-weight: 650; margin-bottom: 6px; flex-wrap: wrap; }
.week ul { list-style: none; padding: 0; margin: 0; }
.week li { display: flex; gap: 10px; align-items: flex-start; padding: 4px 0; font-size: 14px; }
.week li input { margin-top: 4px; accent-color: var(--accent); }
.grid > .card + .card, .hero > .card + .card { margin-top: 0; }
.next-list .ico { font-size: 12px; }
