:root {
  --ink: #16222c;
  --muted: #65717b;
  --paper: #f7f3ea;
  --surface: #fffdf8;
  --line: #d9d2c4;
  --accent: #e9532f;
  --accent-dark: #bd371b;
  --navy: #17324d;
  --success: #1d754d;
  --shadow: 0 18px 45px rgba(30, 39, 45, .09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.shell { width: min(1380px, calc(100% - 40px)); margin: 0 auto; }

.hero { display: flex; justify-content: space-between; align-items: center; gap: 40px; padding: 58px 0 38px; border-bottom: 1px solid var(--line); }
.hero-copy { max-width: 830px; }
.eyebrow { margin: 0 0 12px; color: var(--accent-dark); font: 800 12px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .15em; }
h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 760px; margin-bottom: 16px; font: 800 clamp(42px, 6vw, 76px)/.98 Georgia, "Times New Roman", serif; letter-spacing: -.045em; }
.lede { max-width: 720px; margin-bottom: 0; color: var(--muted); font-size: 19px; line-height: 1.55; }
.hero-mark { display: grid; grid-template-columns: auto auto auto; align-items: center; color: var(--accent); font: 700 48px/1 ui-monospace, monospace; transform: rotate(-2deg); }
.hero-mark strong { display: grid; place-items: center; width: 112px; height: 112px; margin: 0 8px; color: var(--surface); background: var(--navy); border-radius: 50%; font-size: 56px; box-shadow: var(--shadow); }

.toolbar { display: flex; align-items: end; gap: 12px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.toolbar label { display: grid; gap: 7px; min-width: 190px; color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.toolbar input, .toolbar select { width: 100%; height: 44px; padding: 0 12px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; outline: none; }
.toolbar input:focus, .toolbar select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(233, 83, 47, .12); }
.seed-field { max-width: 160px; }
.language-field { min-width: 130px !important; }
.topics-control { position: relative; display: grid; gap: 7px; }
.toolbar-caption { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.topics-panel { position: absolute; z-index: 20; top: calc(100% + 8px); left: 0; width: min(430px, calc(100vw - 40px)); padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.topics-panel h3 { margin-bottom: 6px; }
.topics-panel > p { margin-bottom: 14px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.topic-options { display: grid; gap: 8px; }
.topic-option { display: flex; align-items: flex-start; gap: 9px; padding: 9px 10px; background: #f5f3ed; border-radius: 5px; font-size: 14px; line-height: 1.4; }
.topic-option input { margin-top: 3px; accent-color: var(--navy); }
.topic-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 14px; }
.topic-actions .mini-button { flex: 1; }
.button { min-height: 44px; padding: 0 18px; border: 1px solid transparent; border-radius: 6px; font-weight: 800; transition: transform .15s ease, background .15s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: white; background: var(--accent); }
.button.primary:hover { background: var(--accent-dark); }
.button.ghost { color: var(--navy); background: transparent; border-color: var(--navy); }
.button.large { min-height: 54px; padding-inline: 26px; }

.workspace { display: grid; grid-template-columns: 268px minmax(0, 1fr); gap: 34px; padding: 34px 0 80px; }
.exam-panel { position: sticky; top: 20px; align-self: start; display: grid; gap: 14px; }
.clock-card, .progress-card, .variant-card { padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.label { margin-bottom: 8px; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; }
.clock { margin-bottom: 14px; color: var(--navy); font: 800 36px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.clock.warning { color: var(--accent-dark); }
.clock-actions { display: flex; gap: 8px; }
.mini-button { padding: 7px 11px; color: white; background: var(--navy); border: 0; border-radius: 5px; font-size: 12px; font-weight: 800; }
.mini-button.subtle { color: var(--navy); background: #e9edf0; }
.progress-line { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 13px; }
.progress-track { height: 7px; overflow: hidden; background: #e8e3da; border-radius: 10px; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .2s ease; }
.variant-card strong { display: block; margin-bottom: 8px; color: var(--navy); font: 800 20px/1.2 ui-monospace, monospace; }
.variant-card p:last-child, .variant-card p:nth-of-type(2) { color: var(--muted); font-size: 13px; line-height: 1.5; }
.question-nav { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.question-nav a { display: grid; place-items: center; min-height: 38px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 5px; font-size: 11px; font-weight: 800; text-decoration: none; }
.question-nav a.done { color: white; background: var(--navy); border-color: var(--navy); }

.exam-heading { display: flex; align-items: center; justify-content: space-between; gap: 30px; margin-bottom: 18px; }
.exam-heading h2 { margin: 0; font: 800 clamp(30px, 4vw, 46px)/1.05 Georgia, serif; letter-spacing: -.025em; }
.exam-total { display: flex; align-items: baseline; gap: 7px; color: var(--navy); }
.exam-total strong { font: 800 42px/1 ui-monospace, monospace; }
.exam-total span { color: var(--muted); font-size: 13px; }
.notice { margin-bottom: 20px; padding: 15px 17px; color: #604314; background: #f5e8c9; border-left: 4px solid #d79d32; border-radius: 4px; line-height: 1.5; }
.questions { display: grid; gap: 18px; }
.question { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 8px 22px rgba(30, 39, 45, .045); }
.question-head { display: flex; justify-content: space-between; gap: 18px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.question-index { color: var(--accent-dark); font: 800 12px/1.2 ui-monospace, monospace; letter-spacing: .08em; }
.question-type { color: var(--muted); font-size: 12px; font-weight: 700; }
.points { flex: 0 0 auto; color: var(--navy); font-weight: 900; }
.question-body { padding: 20px; }
.question-body h3 { margin-bottom: 12px; font-size: 21px; }
.prompt { color: #303b44; line-height: 1.65; }
pre { overflow-x: auto; margin: 14px 0; padding: 16px; color: #eaf1f4; background: #14222e; border-radius: 6px; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; tab-size: 4; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.answer-input, .code-input { width: 100%; color: var(--ink); background: #fbfaf6; border: 1px solid var(--line); border-radius: 6px; resize: vertical; outline: none; }
.answer-input { min-height: 48px; padding: 12px; }
.code-input { min-height: 230px; padding: 15px; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; tab-size: 4; }
.choices { display: grid; gap: 9px; margin-top: 14px; }
.choice { display: flex; align-items: flex-start; gap: 10px; padding: 11px 12px; background: #f5f3ed; border: 1px solid transparent; border-radius: 5px; line-height: 1.45; }
.choice:has(input:checked) { background: #edf1f3; border-color: var(--navy); }
.choice input { margin-top: 4px; accent-color: var(--navy); }
.solution { margin-top: 18px; padding: 17px; background: #edf5ef; border-left: 4px solid var(--success); border-radius: 4px; }
.solution h4 { margin: 0 0 10px; color: var(--success); }
.solution p, .solution li { line-height: 1.55; }
.solution pre { margin-bottom: 8px; }
.rubric { display: grid; gap: 8px; margin-top: 14px; }
.rubric label { display: flex; gap: 9px; align-items: flex-start; padding: 9px 10px; background: rgba(255,255,255,.62); border-radius: 4px; font-size: 14px; }
.rubric input { margin-top: 3px; accent-color: var(--success); }
.feedback-correct { color: var(--success); font-weight: 800; }
.feedback-wrong { color: var(--accent-dark); font-weight: 800; }
.submit-zone { display: flex; align-items: center; justify-content: space-between; gap: 30px; margin-top: 26px; padding: 26px; color: white; background: var(--navy); border-radius: 9px; }
.submit-zone h2 { margin-bottom: 7px; font-family: Georgia, serif; }
.submit-zone p { max-width: 690px; margin-bottom: 0; color: #cad6df; line-height: 1.5; }
.results { margin-top: 22px; padding: 26px; background: var(--surface); border: 2px solid var(--navy); border-radius: 9px; }
.results.hidden, .hidden { display: none; }
.score-row { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.score-big { color: var(--navy); font: 800 58px/1 ui-monospace, monospace; }
.score-caption { color: var(--muted); }
.score-breakdown { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 20px; }
.metric { padding: 14px; background: #f2efe8; border-radius: 6px; }
.metric strong { display: block; margin-bottom: 4px; font-size: 22px; }
.export-panel { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-top: 20px; padding: 18px; background: #eef2f4; border: 1px solid #d9e0e4; border-radius: 6px; }
.export-panel h3 { margin-bottom: 5px; }
.export-panel p { margin-bottom: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.export-actions { display: flex; flex: 0 0 auto; gap: 9px; }
.export-status { min-height: 21px; margin-top: 5px !important; color: var(--success) !important; font-weight: 700; }
.history { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.history ol { margin-bottom: 0; padding-left: 20px; color: var(--muted); line-height: 1.7; }
.materials { display: flex; align-items: flex-start; justify-content: space-between; gap: 36px; margin-top: 22px; padding: 26px; color: white; background: #213a4e; border-radius: 9px; }
.materials h2 { margin-bottom: 8px; font-family: Georgia, serif; }
.materials p:not(.eyebrow) { max-width: 620px; margin-bottom: 0; color: #ced9e0; line-height: 1.5; }
.materials-links { display: grid; min-width: 310px; gap: 9px; }
.materials-links a { padding: 12px 14px; color: white; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.24); border-radius: 6px; font-size: 14px; font-weight: 800; text-decoration: none; }
.materials-links a:hover { background: rgba(255,255,255,.14); }
footer { display: flex; justify-content: space-between; gap: 20px; padding: 24px max(20px, calc((100% - 1340px)/2)); color: #cbd4da; background: #14222e; font-size: 12px; }

@media (max-width: 900px) {
  .hero-mark { display: none; }
  .toolbar { flex-wrap: wrap; }
  .topics-control { flex: 1; min-width: 190px; }
  .workspace { grid-template-columns: 1fr; }
  .exam-panel { position: static; grid-template-columns: repeat(3, 1fr); }
  .question-nav { grid-column: 1 / -1; grid-template-columns: repeat(8, 1fr); }
}

@media (max-width: 620px) {
  .shell { width: min(100% - 24px, 1380px); }
  .hero { padding-top: 34px; }
  h1 { font-size: 42px; }
  .toolbar label, .seed-field { min-width: calc(50% - 6px); max-width: none; }
  .toolbar .button { flex: 1; }
  .exam-panel { grid-template-columns: 1fr; }
  .question-nav { grid-column: auto; grid-template-columns: repeat(5, 1fr); }
  .exam-total { display: none; }
  .question-head, .submit-zone, .score-row, .export-panel, .materials { align-items: flex-start; flex-direction: column; }
  .export-actions { width: 100%; flex-wrap: wrap; }
  .export-actions .button { flex: 1; }
  .score-breakdown { grid-template-columns: 1fr; }
  .materials-links { min-width: 0; width: 100%; }
  footer { flex-direction: column; }
}

@media print {
  :root, body { background: white; }
  .shell { width: 100%; }
  .hero { padding: 0 0 18px; }
  .hero h1 { font-size: 36px; }
  .hero-mark, .toolbar, .exam-panel, .notice, .submit-zone, .results, .materials, footer { display: none !important; }
  .workspace { display: block; padding: 18px 0; }
  .question { break-inside: avoid; box-shadow: none; margin-bottom: 16px; }
  .question-body { padding: 16px; }
  textarea { min-height: 140px !important; background: white !important; }
  .solution { display: none !important; }
}
