:root {
  --ink: #202326;
  --muted: #697075;
  --paper: #f5f4f1;
  --card: #ffffff;
  --line: #d9d9d5;
  --navy: #17191b;
  --navy-soft: #24282c;
  --red: #c83d35;
  --red-dark: #9d2925;
  --yellow: #d9a825;
  --green: #277251;
  --amber: #906313;
  --shadow: 0 12px 30px rgba(32,35,38,.08);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); line-height: 1.5; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button { cursor: pointer; }
.skip-link { position: fixed; z-index: 20; left: 1rem; top: -5rem; padding: .65rem .9rem; background: #fff; color: var(--ink); border-radius: 8px; box-shadow: var(--shadow); }
.skip-link:focus { top: 1rem; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar { position: sticky; top: 0; display: flex; flex: 0 0 272px; flex-direction: column; min-height: 100vh; padding: 1.7rem 1.15rem 1.2rem; color: #f4f4f1; background: var(--navy); }
.brand-lockup { display: flex; align-items: flex-start; justify-content: space-between; gap: .6rem; margin: 0 .35rem 2.8rem; }
.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; }
.brand-mark { width: 2.55rem; height: 2.55rem; color: #ec5147; flex: 0 0 auto; }
.brand strong { display: block; letter-spacing: .03em; font-size: 1.08rem; }
.brand small { display: block; margin-top: .12rem; color: #aeb4b7; font-size: .67rem; letter-spacing: .04em; }
.region-chip { margin-top: .25rem; padding: .26rem .44rem; border: 1px solid #4d5255; border-radius: 5px; color: #dce0dd; font-size: .65rem; letter-spacing: .08em; white-space: nowrap; }
.nav-list { display: grid; gap: .42rem; }
.nav-link { display: flex; align-items: center; gap: .75rem; min-height: 48px; padding: .65rem .72rem; color: #adb3b5; border-radius: 8px; font-size: .9rem; text-decoration: none; transition: color .15s ease, background .15s ease; }
.nav-link:hover, .nav-link:focus-visible { color: #fff; background: var(--navy-soft); }
.nav-link.active { color: #fff; background: var(--red); box-shadow: inset 3px 0 0 #f3d56a; }
.nav-icon { display: inline-grid; width: 1.45rem; place-items: center; color: currentColor; font-size: 1.25rem; line-height: 1; }
.nav-count { min-width: 1.35rem; margin-left: auto; padding: .12rem .3rem; color: #fff; background: #5e6468; border-radius: 10px; font-size: .68rem; text-align: center; }
.nav-link.active .nav-count { background: rgba(0,0,0,.25); }
.sidebar-footer { margin-top: auto; padding: 1rem .7rem .2rem; border-top: 1px solid #363b3f; color: #aeb4b7; font-size: .72rem; }
.progress-mini { display: flex; justify-content: space-between; margin-bottom: .45rem; color: #d9ddda; }
.progress-mini strong { color: #f3d56a; font-weight: 700; }
.progress-track { height: 5px; overflow: hidden; background: #3e4448; border-radius: 5px; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--yellow); border-radius: inherit; transition: width .3s ease; }
.sidebar-footer p { margin: .8rem 0 0; line-height: 1.45; }
.main-content { min-width: 0; flex: 1; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 70px; padding: 1rem clamp(1rem, 4vw, 3.4rem); border-bottom: 1px solid var(--line); background: rgba(245,244,241,.92); }
.breadcrumbs { display: flex; align-items: center; gap: .65rem; color: var(--muted); font-size: .79rem; }
.breadcrumbs strong { color: var(--ink); font-size: .85rem; }
.top-actions { display: flex; align-items: center; gap: .65rem; }
.account-state { color: var(--muted); font-size: .77rem; }
.avatar { display: inline-grid; width: 38px; height: 38px; place-items: center; padding: 0; color: #fff; background: var(--navy); border: 0; border-radius: 50%; font-size: .85rem; font-weight: 700; }
.mobile-menu { display: none; width: 42px; height: 42px; padding: .55rem; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.mobile-menu span { display: block; height: 2px; margin: 4px 0; background: var(--ink); }
.page-content { width: min(1120px, 100%); margin: 0 auto; padding: clamp(1.3rem, 3.5vw, 3.3rem) clamp(1rem, 4vw, 3.4rem) 5rem; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; margin-bottom: 1.9rem; }
.eyebrow { margin: 0 0 .45rem; color: var(--red-dark); font-size: .68rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .45rem; font-size: clamp(1.8rem, 4vw, 2.65rem); letter-spacing: -.035em; line-height: 1.1; }
h2 { margin-bottom: .55rem; font-size: clamp(1.25rem, 2.6vw, 1.7rem); letter-spacing: -.02em; line-height: 1.2; }
h3 { margin-bottom: .4rem; font-size: 1.04rem; line-height: 1.25; }
.lead { max-width: 650px; margin-bottom: 0; color: var(--muted); font-size: 1rem; }
.muted { color: var(--muted); }
.tiny { font-size: .75rem; }
.yellow-rule { width: 52px; height: 4px; margin: 1rem 0 0; background: var(--yellow); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(270px, .6fr); gap: 1rem; margin-bottom: 2rem; }
.hero-card { position: relative; overflow: hidden; padding: clamp(1.35rem, 4vw, 2.4rem); color: #fff; background: var(--navy); border-radius: 12px; box-shadow: var(--shadow); }
.hero-card:after { position: absolute; right: -65px; bottom: -85px; width: 220px; height: 220px; border: 24px solid rgba(200,61,53,.52); border-radius: 50%; content: ""; }
.hero-card h1 { max-width: 600px; color: #fff; }
.hero-card .lead { position: relative; z-index: 1; color: #d3d6d4; }
.hero-card .eyebrow { color: #f3d56a; }
.hero-card .yellow-rule { position: relative; z-index: 1; }
.stats-card { display: flex; flex-direction: column; justify-content: space-between; padding: 1.35rem; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.stats-card .number { display: block; margin: .3rem 0 .2rem; color: var(--red-dark); font-size: 2.7rem; font-weight: 800; letter-spacing: -.06em; line-height: 1; }
.stats-card p { margin-bottom: 0; color: var(--muted); font-size: .8rem; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 1.8rem 0 .8rem; }
.section-heading h2 { margin-bottom: 0; }
.section-heading a { color: var(--red-dark); font-size: .78rem; font-weight: 700; text-decoration: none; }
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; }
.topic-card, .lesson-card, .panel, .question-card, .exam-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 4px 16px rgba(32,35,38,.04); }
.topic-card { display: flex; min-height: 156px; flex-direction: column; padding: 1rem; }
.topic-card .topic-meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: .8rem; color: var(--muted); font-size: .71rem; }
.topic-card .topic-number { display: inline-grid; width: 30px; height: 30px; place-items: center; color: var(--red-dark); background: #f9e5df; border-radius: 50%; font-size: .73rem; font-weight: 800; }
.topic-card h3 { flex: 1; }
.topic-card p { margin-bottom: .8rem; color: var(--muted); font-size: .78rem; }
.topic-actions { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: auto; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; gap: .4rem; padding: .62rem 1rem; color: #fff; background: var(--red); border: 1px solid var(--red); border-radius: 7px; font-size: .82rem; font-weight: 700; text-decoration: none; transition: background .15s ease, transform .15s ease; }
.button:hover, .button:focus-visible { background: var(--red-dark); }
.button:active { transform: translateY(1px); }
.button.secondary { color: var(--ink); background: #fff; border-color: var(--line); }
.button.secondary:hover, .button.secondary:focus-visible { background: #f2f1ee; }
.button.ghost { color: var(--red-dark); background: transparent; border-color: transparent; }
.button[disabled] { cursor: not-allowed; opacity: .5; }
.inline-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.1rem; }
.notice { display: flex; gap: .7rem; margin: 1rem 0; padding: .85rem 1rem; color: #594617; background: #fff8df; border-left: 4px solid var(--yellow); border-radius: 7px; font-size: .8rem; }
.notice.info { color: #34454b; background: #eaf0f1; border-left-color: #5d7d87; }
.notice.error { color: #7d2f2a; background: #fceae7; border-left-color: var(--red); }
.notice strong { display: block; margin-bottom: .12rem; }
.empty-state { padding: 2rem 1.3rem; text-align: center; border: 1px dashed #bbbdb9; border-radius: 10px; }
.empty-state p { max-width: 460px; margin: 0 auto .9rem; color: var(--muted); font-size: .85rem; }
.lesson-list { display: grid; gap: .8rem; }
.lesson-card { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.15rem; }
.lesson-card h3 { margin-bottom: .22rem; }
.lesson-card p { margin: 0; color: var(--muted); font-size: .8rem; }
.status-badge { display: inline-flex; align-items: center; min-height: 25px; padding: .23rem .5rem; color: #435051; background: #edf0ed; border-radius: 4px; font-size: .66rem; font-weight: 700; white-space: nowrap; }
.focus-badge { margin-bottom: .65rem; }
.exam-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .35rem; }
.status-badge.red { color: #8c2c27; background: #f8e3df; }
.status-badge.amber { color: #70500e; background: #fff2c9; }
.status-badge.gray { color: #5f6466; background: #eeeeeb; }
.meter { overflow: hidden; height: 8px; background: #e5e4df; border-radius: 8px; }
.meter span { display: block; height: 100%; background: var(--red); border-radius: inherit; }
.panel { padding: 1.2rem; }
.panel + .panel { margin-top: .8rem; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem; margin-bottom: 1rem; }
.panel-head h2, .panel-head h3 { margin-bottom: 0; }
.question-card { max-width: 780px; padding: clamp(1rem, 3vw, 1.6rem); }
.question-card.full { max-width: none; }
.question-label { margin-bottom: .8rem; color: var(--muted); font-size: .75rem; font-weight: 700; }
.question-label strong { color: var(--red-dark); }
.question-prompt { margin-bottom: 1.25rem; font-size: clamp(1.15rem, 2.5vw, 1.45rem); font-weight: 700; line-height: 1.35; }
.options { display: grid; gap: .6rem; }
.option { position: relative; display: flex; align-items: flex-start; gap: .65rem; min-height: 52px; padding: .8rem .85rem; border: 1px solid var(--line); border-radius: 7px; cursor: pointer; transition: border-color .15s, background .15s; }
.option:hover, .option:focus-within { border-color: #b9a08b; background: #fffaf1; }
.option.selected { border-color: var(--red); background: #fff2ee; box-shadow: 0 0 0 1px var(--red); }
.option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.option-key { display: inline-grid; width: 25px; height: 25px; flex: 0 0 auto; place-items: center; color: var(--red-dark); background: #f7ddd6; border-radius: 4px; font-size: .73rem; font-weight: 800; }
.option-copy { font-size: .86rem; }
.text-answer { display: block; width: 100%; min-height: 80px; padding: .75rem; resize: vertical; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.text-answer:focus, .option input:focus-visible + .option-key { outline: 3px solid rgba(200,61,53,.28); outline-offset: 2px; }
.question-footer { display: flex; align-items: center; justify-content: space-between; gap: .7rem; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.feedback { margin-top: 1rem; padding: 1rem; border-radius: 8px; font-size: .83rem; }
.feedback.correct { color: #174e38; background: #e6f3eb; border-left: 4px solid var(--green); }
.feedback.incorrect { color: #742c29; background: #fbe8e5; border-left: 4px solid var(--red); }
.feedback.manual, .feedback.unscored { color: #5e4d1b; background: #fff6d7; border-left: 4px solid var(--yellow); }
.feedback h3 { margin-bottom: .25rem; }
.feedback p { margin: .35rem 0 0; }
.feedback .proposed { margin-top: .7rem; padding-top: .7rem; border-top: 1px solid rgba(100,80,30,.2); font-weight: 700; }
.image-question { margin: 0 0 1.1rem; }
.image-frame { position: relative; display: block; width: 100%; max-width: 780px; overflow: hidden; margin-bottom: .45rem; background: #ecebe7; border: 1px solid var(--line); border-radius: 7px; }
.image-frame.photo { aspect-ratio: 4 / 3; }
.image-frame.diagram { aspect-ratio: 900 / 230; }
.image-frame img { display: block; width: 100%; height: 100%; object-fit: contain; }
.image-frame.diagram img { position: absolute; top: -63.0435%; left: -4.4444%; width: 108.6667%; max-width: none; height: auto; }
.image-button { display: block; width: 100%; padding: 0; overflow: hidden; border: 0; background: transparent; cursor: zoom-in; }
.image-button:focus-visible { outline: 3px solid rgba(200,61,53,.35); outline-offset: 3px; }
.image-caption { display: flex; align-items: center; justify-content: space-between; gap: .7rem; color: var(--muted); font-size: .71rem; }
.image-caption .button { min-height: 34px; padding: .35rem .6rem; font-size: .7rem; }
.missing-image { display: grid; min-height: 140px; place-items: center; padding: 1rem; color: var(--muted); text-align: center; font-size: .8rem; }
.exam-grid { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 1rem; align-items: start; }
.exam-index { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; padding: .85rem; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.exam-index h3 { font-size: .85rem; }
.exam-buttons { display: grid; grid-template-columns: repeat(5, 1fr); gap: .35rem; }
.exam-number { min-height: 36px; padding: .2rem; color: var(--muted); background: #f5f4f1; border: 1px solid var(--line); border-radius: 4px; font-size: .72rem; }
.exam-number.active { color: #fff; background: var(--red); border-color: var(--red); }
.exam-number.answered { color: var(--ink); border-color: #b5cbbb; background: #eef6ee; }
.exam-number.unreviewed:after { display: block; width: 4px; height: 4px; margin: 0 auto; background: var(--yellow); border-radius: 50%; content: ""; }
.exam-card { padding: 1.2rem; }
.exam-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.exam-header p { margin-bottom: 0; color: var(--muted); font-size: .78rem; }
.exam-submit { margin-top: 1rem; padding: 1rem; border: 1px solid #dfd7bf; border-radius: 8px; background: #fff9e8; }
.exam-result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.result-stat { padding: .9rem; background: #f8f7f4; border-radius: 7px; }
.result-stat strong { display: block; font-size: 1.45rem; }
.result-stat span { color: var(--muted); font-size: .72rem; }
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.account-split { margin-top: 1rem; }
.auth-card { max-width: 520px; margin: 1rem auto; }
.form-grid { display: grid; gap: .8rem; }
.field { display: grid; gap: .3rem; }
.field label { color: var(--muted); font-size: .76rem; font-weight: 700; }
.field input, .field select { min-height: 46px; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.field input:focus, .field select:focus { outline: 3px solid rgba(200,61,53,.2); border-color: var(--red); }
.account-actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.source-details { margin-top: 1rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.source-details summary { color: var(--muted); cursor: pointer; font-size: .78rem; font-weight: 700; }
.source-details p { margin: .55rem 0 0; }
.import-label { display: inline-flex; align-items: center; min-height: 44px; padding: .62rem 1rem; color: var(--ink); border: 1px solid var(--line); border-radius: 7px; background: #fff; font-size: .82rem; font-weight: 700; cursor: pointer; }
.import-label input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: .7rem; }
.stat-box { padding: 1rem; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.stat-box strong { display: block; margin-bottom: .2rem; font-size: 1.45rem; }
.stat-box span { color: var(--muted); font-size: .72rem; }
.image-dialog { width: min(960px, calc(100% - 1.5rem)); max-width: 960px; padding: 0; border: 0; border-radius: 10px; box-shadow: 0 24px 80px rgba(0,0,0,.3); }
.image-dialog::backdrop { background: rgba(16,18,20,.72); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: .85rem 1rem; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 1rem; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: #fff; font-size: 1.4rem; line-height: 1; }
.dialog-image { padding: 1rem; background: #f2f1ed; }
.dialog-image .image-frame { max-width: none; margin: 0; }
.error-copy { margin: 0; padding: .8rem 1rem; color: #7d2f2a; font-size: .8rem; }
.global-alert { margin: 1rem clamp(1rem, 4vw, 3.4rem) 0; padding: .7rem .9rem; color: #7d2f2a; background: #fceae7; border-left: 4px solid var(--red); border-radius: 5px; font-size: .8rem; }
.bottom-nav { display: none; }
@media (max-width: 900px) {
  .sidebar { flex-basis: 230px; }
  .card-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .hero-grid { grid-template-columns: 1fr; }
  .exam-grid { grid-template-columns: 170px minmax(0,1fr); }
}
@media (max-width: 680px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 10; inset: 0 auto 0 0; width: min(290px, 88vw); min-height: 100vh; transform: translateX(-105%); transition: transform .2s ease; box-shadow: 12px 0 35px rgba(0,0,0,.2); }
  body.menu-open .sidebar { transform: translateX(0); }
  body.menu-open:after { position: fixed; z-index: 9; inset: 0; background: rgba(20,21,22,.56); content: ""; }
  .mobile-menu { display: block; }
  .topbar { min-height: 62px; padding: .65rem 1rem; }
  .breadcrumbs { gap: .4rem; font-size: .7rem; }
  .account-state { display: none; }
  .page-content { padding: 1.2rem 1rem 5.6rem; }
  .page-header { display: block; margin-bottom: 1.35rem; }
  .page-header .button { margin-top: 1rem; }
  .card-grid, .split, .stat-grid { grid-template-columns: 1fr; }
  .topic-card { min-height: 140px; }
  .lesson-card { align-items: flex-start; flex-direction: column; }
  .hero-card { padding: 1.4rem; }
  .hero-card:after { right: -100px; bottom: -100px; }
  .section-heading { margin-top: 1.4rem; }
  .exam-grid { grid-template-columns: 1fr; }
  .exam-index { position: static; max-height: none; }
  .exam-buttons { grid-template-columns: repeat(8, 1fr); }
  .exam-card { padding: .95rem; }
  .exam-header { display: block; }
  .exam-header .status-badge { margin-top: .5rem; }
  .question-footer { align-items: stretch; flex-direction: column; }
  .question-footer .button { width: 100%; }
  .bottom-nav { position: fixed; z-index: 8; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(5, 1fr); padding: .35rem .35rem max(.35rem, env(safe-area-inset-bottom)); background: rgba(255,255,255,.97); border-top: 1px solid var(--line); box-shadow: 0 -4px 15px rgba(32,35,38,.08); }
  .bottom-nav a { display: grid; min-height: 48px; place-items: center; color: var(--muted); font-size: 1.1rem; text-decoration: none; }
  .bottom-nav small { font-size: .61rem; line-height: 1; }
  .bottom-nav a.active { color: var(--red-dark); font-weight: 700; }
}
@media (prefers-reduced-motion: reduce) { *, *:before, *:after { scroll-behavior: auto !important; transition: none !important; } }
