:root {
  --paper: #f4f7f5;
  --surface: #ffffff;
  --surface-2: #edf3f0;
  --ink: #17231e;
  --muted: #64746c;
  --line: #d7e1dc;
  --green: #176b4d;
  --green-dark: #0c4f37;
  --green-soft: #dcefe5;
  --coral: #d85a43;
  --coral-soft: #fae7e2;
  --gold: #d6a72e;
  --blue: #3978a8;
  --shadow: 0 14px 34px rgba(24, 55, 42, 0.09);
  font-family: "DM Sans", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

[hidden] {
  display: none !important;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--paper); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 20px 14px; background: #123f31; color: white; display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 7px 22px; border-bottom: 1px solid rgba(255,255,255,.14); }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; background: var(--gold); color: #18352a; font: 700 23px/1 "Source Serif 4", serif; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 14px; }
.brand span { font-size: 11px; color: #bbd3c8; margin-top: 2px; }
.main-nav { display: grid; gap: 4px; margin-top: 20px; }
.nav-item { border: 0; background: transparent; color: #d8e7e0; min-height: 42px; padding: 0 10px; display: flex; align-items: center; gap: 11px; text-align: left; border-left: 3px solid transparent; }
.nav-item svg { width: 18px; }
.nav-item b { margin-left: auto; border-radius: 999px; min-width: 22px; padding: 2px 6px; font-size: 11px; background: rgba(255,255,255,.14); text-align: center; }
.nav-item:hover, .nav-item.active { color: white; background: rgba(255,255,255,.09); border-left-color: var(--gold); }
.sidebar-bottom { margin-top: auto; display: grid; gap: 14px; }
.access-state { padding: 12px 10px; border-top: 1px solid rgba(255,255,255,.14); display: flex; gap: 9px; align-items: center; }
.access-state strong, .access-state small { display: block; }
.access-state strong { font-size: 12px; }
.access-state small { color: #bad0c6; font-size: 10px; margin-top: 2px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 4px rgba(214,167,46,.17); }
.status-dot.redeemed { background: #67d59f; box-shadow: 0 0 0 4px rgba(103,213,159,.17); }
main { min-width: 0; }
.topbar { height: 68px; padding: 0 28px; display: flex; align-items: center; gap: 14px; border-bottom: 1px solid var(--line); background: rgba(244,247,245,.95); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(12px); }
.search-box { flex: 1; max-width: 660px; display: flex; align-items: center; gap: 9px; height: 38px; padding: 0 10px; background: var(--surface); border: 1px solid var(--line); }
.search-box svg { width: 17px; color: var(--muted); }
.search-box input { border: 0; outline: 0; background: transparent; width: 100%; color: var(--ink); }
kbd { color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); padding: 2px 5px; font-size: 10px; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); display: grid; place-items: center; }
.icon-button:hover { border-color: var(--green); color: var(--green); }
.icon-button svg { width: 18px; }
.mobile-menu { display: none; }
.profile-badge { margin-left: auto; display: flex; align-items: center; gap: 9px; min-width: 150px; }
.profile-badge > span { width: 32px; height: 32px; display: grid; place-items: center; background: var(--coral-soft); color: var(--coral); font-weight: 700; font-size: 12px; }
.profile-badge strong, .profile-badge small { display: block; }
.profile-badge strong { font-size: 12px; }
.profile-badge small { color: var(--muted); font-size: 10px; margin-top: 2px; }
.view { display: none; padding: 28px; max-width: 1440px; margin: 0 auto; }
.view.active { display: block; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 22px; }
.eyebrow { color: var(--green); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.eyebrow.light { color: #a9d5c2; }
h1, h2, h3 { font-family: "Source Serif 4", serif; margin: 0; letter-spacing: 0; }
h1 { font-size: 34px; line-height: 1.1; }
h2 { font-size: 23px; }
h3 { font-size: 17px; }
p { line-height: 1.55; }
.muted { color: var(--muted); }
.button { min-height: 38px; padding: 0 14px; border: 1px solid var(--green); background: var(--green); color: white; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; font-weight: 600; }
.button:hover { background: var(--green-dark); }
.button:disabled { cursor: not-allowed; opacity: .45; }
.button.secondary { color: var(--green); background: white; }
.button.secondary:hover { background: var(--green-soft); }
.button.coral { background: var(--coral); border-color: var(--coral); }
.button.small { min-height: 32px; padding: 0 10px; font-size: 12px; }
.button svg { width: 16px; }
.action-cluster { display: flex; gap: 8px; flex-wrap: wrap; }
.dashboard-hero { min-height: 260px; display: grid; grid-template-columns: minmax(0, 1fr) 220px; background: var(--green-dark); color: white; overflow: hidden; }
.dashboard-hero-copy { padding: 34px; align-self: center; }
.dashboard-hero h1 { max-width: 620px; }
.dashboard-hero p { color: #cbe0d6; max-width: 620px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 21px; }
.dashboard-hero .button.secondary { border-color: rgba(255,255,255,.5); background: transparent; color: white; }
.book-cover { width: 100%; height: 100%; object-fit: cover; object-position: top center; border-left: 1px solid rgba(255,255,255,.2); }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 18px 0 26px; }
.metric-card { background: var(--surface); border: 1px solid var(--line); padding: 16px; min-height: 112px; }
.metric-card span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.metric-card strong { display: block; margin-top: 8px; font: 700 28px/1 "Source Serif 4", serif; }
.metric-card small { display: block; color: var(--muted); margin-top: 9px; font-size: 11px; }
.split-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(290px, .8fr); gap: 20px; }
.panel { background: var(--surface); border: 1px solid var(--line); }
.panel-header { min-height: 56px; padding: 0 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-body { padding: 18px; }
.topic-row { display: grid; grid-template-columns: 145px 1fr 42px; gap: 12px; align-items: center; margin: 14px 0; font-size: 12px; }
.progress-track { height: 7px; background: var(--surface-2); overflow: hidden; }
.progress-fill { height: 100%; background: var(--green); }
.activity-list, .test-list, .review-list { display: grid; }
.activity-row, .test-row, .review-row { padding: 13px 0; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.activity-row:last-child, .test-row:last-child, .review-row:last-child { border-bottom: 0; }
.activity-icon { width: 34px; height: 34px; display: grid; place-items: center; background: var(--surface-2); color: var(--green); flex: 0 0 auto; }
.activity-icon svg { width: 17px; }
.activity-row strong, .activity-row small { display: block; }
.activity-row strong { font-size: 12px; }
.activity-row small { color: var(--muted); font-size: 10px; margin-top: 3px; }
.book-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 18px; }
.toc-list { display: grid; }
.toc-item { border: 0; border-bottom: 1px solid var(--line); background: white; min-height: 47px; padding: 0 14px; text-align: left; display: flex; justify-content: space-between; align-items: center; color: var(--ink); }
.toc-item:hover { background: var(--surface-2); color: var(--green); }
.watermarked-document { position: relative; min-width: 0; overflow: hidden; }
.pdf-frame { width: 100%; height: calc(100vh - 160px); min-height: 620px; border: 1px solid var(--line); background: #dfe7e3; }
.document-watermark { position: absolute; inset: 0; pointer-events: none; display: grid; place-items: center; color: rgba(24, 54, 46, .14); font-size: 16px; font-weight: 700; overflow: hidden; transform: rotate(-28deg); text-align: center; }
.practice-toolbar { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin-bottom: 16px; }
.select, .text-input { min-height: 38px; border: 1px solid var(--line); background: white; color: var(--ink); padding: 0 10px; }
.practice-layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(280px, .7fr); gap: 18px; }
.question-panel { background: white; border: 1px solid var(--line); padding: 24px; min-height: 560px; }
.question-meta { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 19px; }
.tag { display: inline-flex; align-items: center; min-height: 24px; padding: 0 7px; font-size: 10px; font-weight: 700; color: var(--green); background: var(--green-soft); text-transform: uppercase; letter-spacing: .04em; }
.tag.coral { color: var(--coral); background: var(--coral-soft); }
.question-stem { font-family: "Source Serif 4", serif; font-size: 21px; line-height: 1.55; margin: 0 0 23px; }
.choice-list { display: grid; gap: 9px; }
.choice { width: 100%; min-height: 48px; border: 1px solid var(--line); background: white; color: var(--ink); text-align: left; padding: 10px 12px; display: grid; grid-template-columns: 28px 1fr; align-items: center; }
.choice:hover, .choice.selected { border-color: var(--green); background: var(--green-soft); }
.choice.correct { border-color: var(--green); background: var(--green-soft); }
.choice.incorrect { border-color: var(--coral); background: var(--coral-soft); }
.choice-label { font-weight: 700; color: var(--green); }
.question-actions { margin-top: 22px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.coach-panel { background: var(--surface); border: 1px solid var(--line); min-height: 560px; display: flex; flex-direction: column; }
.coach-messages { padding: 17px; display: grid; gap: 12px; flex: 1; align-content: start; }
.message { padding: 12px; background: var(--surface-2); font-size: 12px; line-height: 1.55; }
.message.user { background: var(--green-soft); margin-left: 28px; }
.coach-actions { padding: 12px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.test-row { display: grid; grid-template-columns: 46px 1fr auto; padding: 15px 18px; }
.test-letter { width: 42px; height: 42px; display: grid; place-items: center; background: var(--green); color: white; font: 700 20px/1 "Source Serif 4", serif; }
.test-row strong, .test-row small { display: block; }
.test-row small { color: var(--muted); margin-top: 3px; font-size: 11px; }
.test-actions { display: flex; gap: 7px; }
.exam-topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.exam-status { display: flex; align-items: center; gap: 14px; }
.exam-status > span { color: var(--muted); font-size: 12px; }
.exam-status > strong { min-width: 104px; padding: 9px 11px; background: var(--ink); color: white; text-align: center; font-variant-numeric: tabular-nums; }
.exam-status > strong.urgent { background: var(--coral); }
.exam-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 18px; align-items: start; }
.exam-navigator { position: sticky; top: 86px; }
.question-grid { padding: 12px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.question-number { aspect-ratio: 1; border: 1px solid var(--line); background: white; color: var(--ink); font-size: 11px; font-weight: 700; }
.question-number:hover, .question-number.active { border-color: var(--green); color: var(--green); }
.question-number.answered { background: var(--green-soft); border-color: #9bcab4; }
.question-number.flagged { box-shadow: inset 0 -3px var(--gold); }
.exam-question { min-height: 650px; }
.flag-tag { border: 0; cursor: pointer; margin-left: auto; }
.flag-tag svg { width: 12px; }
.flag-tag.on { background: #f7edc9; color: #775b0e; }
.bookmark-tag { border: 0; cursor: pointer; margin-left: auto; }
.bookmark-tag svg { width: 12px; }
.bookmark-tag.on { background: #f7edc9; color: #775b0e; }
.native-visual { margin: 0 0 22px; padding: 16px; border: 1px solid var(--line); background: white; display: grid; place-items: center; overflow: auto; }
.native-visual img { display: block; width: auto; max-width: 100%; max-height: 560px; min-height: 80px; object-fit: contain; }
.exam-review-list { display: grid; gap: 16px; }
.review-question { background: white; border: 1px solid var(--line); padding: 22px; }
.answer-comparison { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0; }
.answer-comparison span { padding: 11px; background: var(--surface-2); color: var(--muted); font-size: 11px; }
.answer-comparison strong { display: block; margin-top: 4px; color: var(--ink); font-size: 15px; }
.exam-metrics { grid-template-columns: repeat(4, minmax(0,1fr)); }
.empty-state { min-height: 250px; padding: 38px; display: grid; place-items: center; text-align: center; border: 1px dashed var(--line); background: var(--surface); }
.empty-state.compact { min-height: 170px; padding: 20px; }
.empty-state svg { width: 36px; color: var(--muted); margin-bottom: 12px; }
.access-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; }
.redeem-form { max-width: 520px; display: grid; gap: 12px; }
.retail-access-form { max-width: 520px; display: grid; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.retail-access-form h3, .retail-access-form p { margin: 0; }
.retail-access-form textarea { resize: vertical; min-height: 84px; }
.redeem-code { font-family: ui-monospace, monospace; letter-spacing: .08em; text-transform: uppercase; }
.qr-preview { min-height: 310px; background: white; border: 1px solid var(--line); padding: 22px; text-align: center; }
.qr-grid { margin: 17px auto; width: 180px; aspect-ratio: 1; display: grid; grid-template-columns: repeat(13, 1fr); gap: 2px; background: white; border: 10px solid white; box-shadow: 0 0 0 1px var(--line); }
.qr-grid i { background: var(--ink); }
.qr-grid i.off { background: white; }
.grid-answer { display: grid; gap: 8px; max-width: 340px; color: var(--muted); font-size: 12px; }
.link-tag { text-decoration: none; }
.review-copy { flex: 1; min-width: 0; }
.review-copy strong, .review-copy small { display: block; }
.review-copy small { color: var(--muted); margin-top: 3px; font-size: 11px; }
.review-copy p { margin: 8px 0 0; font-size: 12px; }
.note-block { margin-top: 22px; background: var(--surface-2); border-left: 3px solid var(--gold); }
.note-block p { margin-bottom: 0; }
.success-banner { display: flex; gap: 13px; padding: 16px; margin-bottom: 18px; background: var(--green-soft); color: var(--green-dark); }
.success-banner svg { width: 26px; flex: 0 0 auto; }
.success-banner p { margin: 4px 0 0; }
.auth-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-stack { display: grid; gap: 14px; }
.form-stack label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 600; }
.form-stack .text-input { width: 100%; }
.consent-check { grid-template-columns: auto 1fr; align-items: start; line-height: 1.45; }
.consent-check input { margin-top: 3px; }
.sign-out-button { margin-top: 18px; }
.setup-list { max-width: 760px; }
.setup-list code { background: var(--surface-2); padding: 2px 5px; }
.coach-compose { padding: 12px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.coach-compose textarea { width: 100%; min-height: 86px; padding: 10px; resize: vertical; }
.coach-access-note { padding: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.text-button { display: block; margin-top: 9px; padding: 0; border: 0; background: transparent; color: var(--green); font-size: 10px; text-decoration: underline; }
.code-output { display: grid; gap: 7px; max-height: 370px; overflow: auto; }
.code-output code { padding: 8px 10px; background: var(--surface-2); font-family: ui-monospace, monospace; font-size: 12px; }
.admin-editor { margin-top: 20px; }
.inline-form { display: flex; align-items: end; gap: 10px; }
.inline-form label { display: grid; flex: 1; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 600; }
.question-edit-form { margin-top: 20px; }
.question-edit-form textarea { min-height: 110px; padding: 10px; resize: vertical; }
.editor-placeholder { margin: 18px 0 4px; }
.choice:disabled { cursor: default; color: inherit; }
.toast { position: fixed; right: 22px; bottom: 22px; max-width: 340px; padding: 12px 14px; color: white; background: var(--ink); box-shadow: var(--shadow); transform: translateY(100px); opacity: 0; transition: .2s ease; z-index: 50; font-size: 12px; }
.toast.show { transform: translateY(0); opacity: 1; }
@media (max-width: 1040px) {
  .app-shell { grid-template-columns: 74px 1fr; }
  .brand div:last-child, .nav-item span, .access-state div, .sidebar-bottom .nav-item span { display: none; }
  .brand { justify-content: center; padding-inline: 0; }
  .nav-item { justify-content: center; padding: 0; }
  .nav-item b { position: absolute; margin: -25px -30px 0 0; }
  .access-state { justify-content: center; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .split-layout, .practice-layout { grid-template-columns: 1fr; }
  .exam-layout { grid-template-columns: 1fr; }
  .exam-navigator { position: static; }
  .question-grid { grid-template-columns: repeat(10, 1fr); }
  .coach-panel { min-height: 420px; }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; width: 244px; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .brand div:last-child, .nav-item span, .access-state div, .sidebar-bottom .nav-item span { display: block; }
  .nav-item { justify-content: flex-start; padding: 0 10px; }
  .access-state { justify-content: flex-start; }
  .mobile-menu { display: grid; }
  .topbar { padding: 0 12px; }
  .profile-badge, kbd { display: none; }
  .view { padding: 18px 12px; }
  .dashboard-hero { grid-template-columns: 1fr; }
  .dashboard-hero-copy { padding: 24px 18px; }
  .book-cover { display: none; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .book-layout, .access-layout, .auth-layout { grid-template-columns: 1fr; }
  .inline-form { align-items: stretch; flex-direction: column; }
  .pdf-frame { min-height: 520px; height: 70vh; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  h1 { font-size: 29px; }
  .question-panel { padding: 18px; }
  .question-stem { font-size: 18px; }
  .test-row { grid-template-columns: 42px 1fr; }
  .test-actions { grid-column: 1 / -1; }
  .exam-topbar, .exam-status { align-items: flex-start; flex-direction: column; }
  .exam-status { width: 100%; }
  .exam-status .button { width: 100%; }
  .question-grid { grid-template-columns: repeat(8, 1fr); }
  .exam-metrics { grid-template-columns: 1fr 1fr; }
  .answer-comparison { grid-template-columns: 1fr; }
}
