:root {
  --ink: #17332f;
  --ink-soft: #536863;
  --paper: #ffffff;
  --surface: #fffdf8;
  --line: #dcd7cb;
  --green: #176b57;
  --green-dark: #0e4d3f;
  --green-soft: #dcece5;
  --gold: #c69239;
  --red: #a3413d;
  --red-soft: #f5dfdc;
  --blue-soft: #e3edf3;
  --shadow: 0 18px 50px rgba(28, 48, 43, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font: 16px/1.5 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input { font: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

.site-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; min-height: 72px; padding: 10px max(24px, calc((100vw - 1420px) / 2)); background: rgba(255, 255, 255, .94); border-bottom: 1px solid rgba(23, 51, 47, .1); backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; color: white; background: var(--green); border-radius: 12px; font: 700 20px/1 Georgia, serif; }
.brand-mark.large { width: 50px; height: 50px; border-radius: 15px; font-size: 27px; }
.brand strong, .brand small { display: block; line-height: 1.05; }
.brand small { margin-top: 4px; color: var(--ink-soft); font-size: 10px; letter-spacing: .18em; }
.main-nav { display: flex; align-items: center; gap: 5px; }
.main-nav a, .nav-button { padding: 9px 12px; color: var(--ink-soft); background: none; border: 0; border-radius: 9px; text-decoration: none; cursor: pointer; }
.main-nav a:hover, .main-nav a.active, .nav-button:hover { color: var(--ink); background: rgba(23, 107, 87, .08); }
.main-nav form { margin: 0; }
.page-shell { width: min(1420px, calc(100% - 48px)); min-height: calc(100vh - 132px); margin: 0 auto; padding: 42px 0 72px; }
.site-footer { display: flex; justify-content: center; padding: 22px; color: var(--ink-soft); border-top: 1px solid var(--line); font-size: 13px; }

.eyebrow { display: block; margin-bottom: 9px; color: var(--green); font-size: 12px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3, h4, p { margin-top: 0; }
h1 { max-width: 840px; margin-bottom: 16px; font: 600 clamp(34px, 5vw, 64px)/1.03 Georgia, "Times New Roman", serif; letter-spacing: -.035em; }
h2, h3 { letter-spacing: -.02em; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 60px; align-items: end; margin-bottom: 42px; }
.hero > div > p, .page-heading > p { max-width: 750px; color: var(--ink-soft); font-size: 17px; }
.hero-summary { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); min-width: 620px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.hero-summary div { padding: 21px; border-right: 1px solid var(--line); }
.hero-summary div:last-child { border: 0; }
.hero-summary strong, .hero-summary span { display: block; }
.hero-summary strong { font: 600 28px/1 Georgia, serif; }
.hero-summary span { margin-top: 7px; color: var(--ink-soft); font-size: 12px; }

.discipline-list { display: grid; gap: 14px; }
.discipline-card { overflow: clip; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 5px 24px rgba(28, 48, 43, .04); }
.discipline-card > summary { display: flex; justify-content: space-between; align-items: center; min-height: 94px; padding: 20px 24px; cursor: pointer; list-style: none; }
.discipline-card > summary::-webkit-details-marker { display: none; }
.discipline-card > summary > div:first-child { display: flex; align-items: center; gap: 19px; }
.discipline-card h2 { margin: 0; font-size: 22px; }
.discipline-card summary p { margin: 3px 0 0; color: var(--ink-soft); font-size: 13px; }
.discipline-index { color: var(--gold); font: 500 18px/1 Georgia, serif; }
.summary-progress { display: flex; align-items: center; gap: 18px; color: var(--ink-soft); font-size: 13px; }
.chevron { width: 10px; height: 10px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform .2s; }
details[open] .chevron { transform: rotate(225deg); }
.discipline-content { padding: 0 24px 26px; border-top: 1px solid var(--line); }
.topic-block { padding-top: 27px; }
.topic-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 20px; margin-bottom: 10px; }
.topic-heading h3 { margin: 0; font-size: 17px; }
.topic-heading span { color: var(--ink-soft); font-size: 12px; }
.subtopic-table { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; }
.subtopic-row { display: grid; grid-template-columns: minmax(260px, 1.6fr) 120px minmax(200px, .8fr) 100px; gap: 16px; align-items: center; min-height: 67px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.subtopic-row:last-child { border: 0; }
.subtopic-row.table-head { min-height: 38px; color: var(--ink-soft); background: #f1eee6; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.subtopic-name strong, .subtopic-name small { display: block; }
.subtopic-name strong { font-size: 14px; }
.subtopic-name small, .progress-cell small { margin-top: 3px; color: var(--ink-soft); font-size: 11px; }
.frequency { font: 600 16px/1 Georgia, serif; }
.progress-cell > span { display: block; font-size: 12px; }
.progress-track { height: 5px; margin: 7px 0 4px; overflow: hidden; background: #e7e3da; border-radius: 9px; }
.progress-track i { display: block; height: 100%; background: var(--green); border-radius: inherit; }
.study-link { display: inline-flex; justify-content: space-between; align-items: center; gap: 9px; padding: 8px 11px; color: var(--green-dark); background: var(--green-soft); border-radius: 9px; font-size: 12px; font-weight: 700; text-decoration: none; }

.breadcrumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 25px; color: var(--ink-soft); font-size: 12px; }
.breadcrumbs a { color: var(--green); }
.study-header { display: flex; justify-content: space-between; align-items: end; gap: 30px; margin-bottom: 24px; }
.study-header h1 { margin: 0; font-size: clamp(30px, 4vw, 48px); }
.question-meta { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.question-meta span { padding: 6px 9px; color: var(--ink-soft); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; font-size: 11px; }
.study-layout { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 24px; align-items: start; }
.question-panel, .answer-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pdf-toolbar { display: flex; justify-content: space-between; align-items: center; min-height: 52px; padding: 8px 15px; border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 700; }
.pdf-toolbar > div { display: flex; gap: 7px; align-items: center; }
.icon-button { width: 34px; height: 34px; color: var(--ink); background: #f1eee6; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.text-link { padding: 7px; color: var(--green); font-size: 12px; }
.pdf-stage { min-height: 520px; padding: 14px; overflow: auto; text-align: center; background: #fff; border-radius: 0 0 var(--radius) var(--radius); }
.pdf-stage canvas { display: block; max-width: none; margin: 0 auto; background: white; box-shadow: 0 4px 18px rgba(0,0,0,.09); }
.pdf-loading { display: grid; min-height: 470px; place-items: center; color: var(--ink-soft); }
.answer-panel { position: sticky; top: 94px; padding: 25px; }
.answer-panel h2 { margin-bottom: 9px; font: 600 27px/1.08 Georgia, serif; }
.answer-panel p { color: var(--ink-soft); font-size: 14px; }
.option-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 24px 0 13px; }
.option-button { aspect-ratio: 1; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; font-size: 18px; font-weight: 800; cursor: pointer; }
.option-button:hover, .option-button:focus-visible, .option-button.selected { color: white; background: var(--green); border-color: var(--green); outline: none; }
.button { display: inline-flex; justify-content: center; align-items: center; min-height: 44px; padding: 10px 17px; border: 1px solid transparent; border-radius: 10px; font-weight: 750; text-decoration: none; cursor: pointer; }
.button.primary { color: white; background: var(--green); }
.button.primary:hover { background: var(--green-dark); }
.button.secondary { color: var(--ink); background: #eee9df; border-color: var(--line); }
.button.quiet { color: var(--green); background: transparent; }
.button.full { width: 100%; margin-top: 9px; }
.result-banner { margin: -4px -4px 18px; padding: 16px; border-radius: 12px; font: 600 24px/1.1 Georgia, serif; }
.result-banner.correct { color: var(--green-dark); background: var(--green-soft); }
.result-banner.incorrect { color: #7d2c29; background: var(--red-soft); }
.result-banner.unknown { color: #35586d; background: var(--blue-soft); }
.solution-summary, .alternative-explanations { margin: 24px 0; }
.solution-summary h3, .alternative-explanations h3 { font-size: 16px; }
.solution-summary { padding: 16px; background: #f4f1e8; border-radius: 12px; }
.explanation { padding: 14px 0; border-top: 1px solid var(--line); }
.explanation h4 { display: flex; align-items: center; gap: 9px; margin-bottom: 7px; font-size: 13px; }
.explanation h4 span { display: grid; width: 27px; height: 27px; place-items: center; border: 1px solid var(--line); border-radius: 8px; }
.explanation.correct h4 span { color: white; background: var(--green); border-color: var(--green); }
.explanation p { margin-bottom: 7px; color: var(--ink); font-size: 13px; }
.solution-pending { padding: 16px; background: #f4f1e8; border-radius: 12px; }
.molecule-diagram { margin: 16px 0; padding: 12px; overflow: hidden; text-align: center; background: white; border: 1px solid var(--line); border-radius: 12px; }
.molecule-canvas { min-height: 160px; display: grid; place-items: center; }
.molecule-canvas svg { display: block; width: 100%; height: auto; max-height: 260px; }
.molecule-diagram figcaption { margin-top: 7px; color: var(--ink-soft); font-size: 11px; }
.molecule-error { min-height: 0; padding: 15px; color: var(--red); font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }

.page-heading { margin-bottom: 30px; }
.page-heading h1 { margin-bottom: 11px; font-size: clamp(38px, 5vw, 57px); }
.history-list { display: grid; gap: 10px; }
.history-item { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 17px; align-items: center; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; }
.status-dot { width: 9px; height: 9px; background: var(--ink-soft); border-radius: 50%; }
.status-dot.correct { background: var(--green); }.status-dot.incorrect { background: var(--red); }.status-dot.unknown { background: #557b91; }
.history-main strong, .history-main span, .history-main small, .history-answer span, .history-answer small { display: block; }
.history-main span, .history-main small, .history-answer span, .history-answer small { color: var(--ink-soft); font-size: 12px; }
.history-answer { min-width: 100px; text-align: right; }
.success-text { color: var(--green); }.error-text { color: var(--red); }.unknown-text { color: #426a80; }
.settings-card { max-width: 620px; padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
label { display: grid; gap: 7px; margin-bottom: 16px; font-size: 13px; font-weight: 700; }
input { width: 100%; padding: 12px 13px; color: var(--ink); background: white; border: 1px solid #bbb7ad; border-radius: 9px; outline: none; }
input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 107, 87, .12); }
.alert { padding: 11px 13px; border-radius: 9px; font-size: 13px; }
.alert.error { color: #7d2c29; background: var(--red-soft); }.alert.success { color: var(--green-dark); background: var(--green-soft); }
.empty-state { padding: 45px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.empty-state.standalone { max-width: 720px; margin: 70px auto; }

.login-page { background: #fff; }
.login-page .page-shell { width: min(1180px, calc(100% - 40px)); display: grid; align-items: center; padding: 60px 0; }
.login-page .site-footer { display: none; }
.login-shell { display: grid; grid-template-columns: 1.25fr minmax(340px, .75fr); gap: 80px; align-items: center; }
.login-intro h1 { font-size: clamp(46px, 6vw, 76px); }
.login-intro p { max-width: 650px; color: var(--ink-soft); font-size: 19px; }
.login-card { padding: 34px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 36px; font-size: 20px; }
.login-card h2 { font: 600 32px/1 Georgia, serif; }
.form-note { margin: 17px 0 0; color: var(--ink-soft); text-align: center; font-size: 11px; }

@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; gap: 25px; }
  .hero-summary { min-width: 0; }
  .study-layout { grid-template-columns: 1fr; }
  .answer-panel { position: static; }
  .subtopic-row { grid-template-columns: minmax(220px, 1fr) 90px minmax(170px, .7fr) 90px; gap: 10px; }
  .login-shell { grid-template-columns: 1fr; gap: 35px; }
}

@media (max-width: 680px) {
  .site-header { min-height: 62px; padding: 8px 14px; }
  .brand small { display: none; }
  .main-nav { gap: 0; }
  .main-nav a, .nav-button { padding: 8px; font-size: 12px; }
  .page-shell { width: min(100% - 24px, 1420px); padding: 28px 0 50px; }
  .hero-summary { grid-template-columns: 1fr; }
  .hero-summary div { border-right: 0; border-bottom: 1px solid var(--line); }
  .discipline-card > summary { padding: 16px; }
  .discipline-content { padding: 0 12px 15px; }
  .summary-progress > span:first-child { display: none; }
  .subtopic-table { border: 0; overflow: visible; }
  .subtopic-row.table-head { display: none; }
  .subtopic-row { grid-template-columns: 1fr auto; gap: 9px; margin-bottom: 9px; padding: 13px; background: #f7f4ed; border: 1px solid var(--line); border-radius: 11px; }
  .frequency { grid-column: 2; grid-row: 1; }
  .progress-cell { grid-column: 1 / -1; }
  .study-link { grid-column: 1 / -1; justify-content: center; }
  .study-header { display: block; }
  .question-meta { justify-content: flex-start; margin-top: 16px; }
  .pdf-stage { height: auto; min-height: 420px; padding: 8px; }
  .answer-panel { padding: 20px; }
  .history-item { grid-template-columns: 10px 1fr; }
  .history-answer { grid-column: 2; text-align: left; }
  .login-page .page-shell { width: min(100% - 24px, 1180px); padding: 30px 0; }
  .login-intro h1 { font-size: 40px; }
  .login-card { padding: 24px; }
}
