:root {
  --ink: #172a3a;
  --ink-soft: #526574;
  --paper: #f7f4ed;
  --surface: #fffdf8;
  --line: #dedbd1;
  --teal: #087e75;
  --teal-dark: #08675f;
  --orange: #e87530;
  --orange-soft: #fff0e5;
  --green: #1d7b50;
  --red: #b7463d;
  --blue-soft: #e9f3f4;
  --shadow: 0 18px 50px rgba(23, 42, 58, .10);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 5%, rgba(8, 126, 117, .09), transparent 30rem),
    radial-gradient(circle at 95% 12%, rgba(232, 117, 48, .08), transparent 26rem),
    var(--paper);
  font-family: "DM Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { color: inherit; }
a { color: var(--teal); }
.hidden { display: none !important; }

.boot { min-height: 100vh; display: grid; place-content: center; text-align: center; color: var(--ink-soft); }
.boot-mark { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; margin: auto; background: var(--ink); color: white; font: 700 32px Literata, serif; box-shadow: var(--shadow); }

.shell { width: min(1240px, calc(100% - 40px)); margin: 0 auto; padding: 26px 0 54px; }
.masthead { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark { width: 46px; height: 46px; border-radius: 14px; background: var(--ink); color: #fff; display: grid; place-items: center; font: 700 23px Literata, serif; }
.brand-name { font: 700 20px Literata, serif; }
.brand-sub { color: var(--ink-soft); font-size: 12px; letter-spacing: .07em; text-transform: uppercase; }
.exam-switch { display: flex; background: rgba(255,255,255,.68); border: 1px solid var(--line); border-radius: 13px; padding: 4px; }
.exam-switch button { border: 0; padding: 10px 15px; border-radius: 9px; background: transparent; cursor: pointer; font-weight: 700; color: var(--ink-soft); }
.exam-switch button.active { background: var(--ink); color: #fff; box-shadow: 0 4px 15px rgba(23,42,58,.2); }

.hero { display: grid; grid-template-columns: 1.35fr .65fr; gap: 22px; margin-bottom: 22px; }
.hero-main { min-height: 315px; position: relative; overflow: hidden; color: #fff; background: var(--ink); border-radius: 28px; padding: 42px; box-shadow: var(--shadow); }
.hero-main::after { content: ""; position: absolute; width: 310px; height: 310px; border: 70px solid rgba(255,255,255,.045); border-radius: 50%; right: -95px; bottom: -140px; }
.eyebrow { margin: 0 0 12px; color: #80d7cf; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .13em; }
h1, h2, h3 { font-family: Literata, Georgia, serif; }
.hero h1 { margin: 0; max-width: 700px; font-size: clamp(30px, 4vw, 50px); line-height: 1.08; letter-spacing: -.035em; }
.hero-copy { max-width: 660px; color: #c3ced4; line-height: 1.65; margin: 18px 0 26px; }
.button-row { display: flex; flex-wrap: wrap; gap: 11px; position: relative; z-index: 1; }
.btn { border: 1px solid transparent; border-radius: 12px; padding: 12px 17px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; font-weight: 700; transition: .18s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--orange); color: #fff; box-shadow: 0 8px 22px rgba(232,117,48,.28); }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost-light { background: rgba(255,255,255,.08); color: #fff; border-color: rgba(255,255,255,.18); }
.btn-danger { color: var(--red); border-color: #ebc9c5; background: #fff8f7; }
.btn-sm { padding: 8px 11px; font-size: 13px; border-radius: 9px; }

.hero-side { border: 1px solid var(--line); background: rgba(255,253,248,.88); border-radius: 28px; padding: 28px; display: flex; flex-direction: column; }
.hero-side h3 { margin: 0 0 7px; }
.metric-ring { width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center; margin: 18px auto; background: conic-gradient(var(--teal) var(--progress), #e3e3dc 0); position: relative; }
.metric-ring::before { content: ""; width: 116px; height: 116px; border-radius: 50%; background: var(--surface); position: absolute; }
.metric-ring strong { position: relative; font-size: 28px; }
.metric-ring small { position: absolute; margin-top: 42px; color: var(--ink-soft); }
.side-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: auto; }
.side-stat { border-top: 1px solid var(--line); padding-top: 12px; }
.side-stat strong { display: block; font-size: 20px; }
.side-stat span { color: var(--ink-soft); font-size: 12px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.quick-panel { display: flex; align-items: center; justify-content: space-between; gap: 28px; margin-bottom: 22px; padding: 22px 26px; border: 1px solid #cfe2df; border-radius: var(--radius); background: linear-gradient(115deg, #eef8f6, #fffdf8); }
.quick-panel h2 { margin: 0; font-size: 22px; }
.quick-panel p:not(.eyebrow) { margin: 6px 0 0; color: var(--ink-soft); line-height: 1.5; max-width: 690px; }
.panel { background: rgba(255,253,248,.9); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: 0 8px 30px rgba(23,42,58,.04); }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 19px; }
.panel h2 { margin: 0; font-size: 21px; }
.panel-note { margin: 4px 0 0; color: var(--ink-soft); font-size: 13px; }
.mock-list { display: grid; gap: 10px; }
.mock-card { border: 1px solid var(--line); border-radius: 14px; padding: 15px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fff; }
.mock-card strong { display: block; }
.mock-card span { color: var(--ink-soft); font-size: 12px; }

.chapter-tools { display: flex; gap: 8px; margin-bottom: 12px; }
.link-btn { border: 0; background: transparent; color: var(--teal); padding: 0; cursor: pointer; font-weight: 700; font-size: 12px; }
.chapters { max-height: 405px; overflow: auto; padding-right: 5px; }
.chapter-row { display: grid; grid-template-columns: auto 34px 1fr auto; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid #ebe8df; cursor: pointer; }
.chapter-row:last-child { border-bottom: 0; }
.chapter-row input { width: 17px; height: 17px; accent-color: var(--teal); }
.chapter-number { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: var(--blue-soft); color: var(--teal-dark); font-size: 12px; font-weight: 700; }
.chapter-title { font-size: 13px; line-height: 1.3; }
.chapter-progress { color: var(--ink-soft); font-size: 11px; white-space: nowrap; }
.practice-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--line); margin-top: 14px; padding-top: 16px; }
.practice-controls select { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px; }
.check-inline { display: flex; align-items: center; gap: 6px; color: var(--ink-soft); font-size: 12px; }

.history-panel { margin-top: 22px; }
.history-list { display: grid; gap: 8px; }
.history-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 15px; border: 1px solid var(--line); background: #fff; padding: 14px 15px; border-radius: 13px; }
.history-row strong { display: block; font-size: 14px; }
.history-meta { color: var(--ink-soft); font-size: 12px; margin-top: 3px; }
.score-pill { border-radius: 999px; padding: 6px 10px; font-weight: 700; font-size: 12px; background: var(--blue-soft); color: var(--teal-dark); }
.score-pill.pass { background: #e5f4eb; color: var(--green); }
.score-pill.fail { background: #fae9e7; color: var(--red); }
.empty { color: var(--ink-soft); text-align: center; padding: 30px 10px; }

/* Examination workspace */
.exam-shell { min-height: 100vh; background: #f5f6f3; }
.exam-top { position: sticky; top: 0; z-index: 20; height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 max(22px, calc((100vw - 1320px)/2)); background: var(--ink); color: #fff; box-shadow: 0 5px 20px rgba(23,42,58,.2); }
.exam-title strong { display: block; }
.exam-title span { font-size: 12px; color: #b6c5cc; }
.timer { font-variant-numeric: tabular-nums; border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.07); border-radius: 11px; padding: 9px 13px; min-width: 104px; text-align: center; font-weight: 700; }
.timer.warning { color: #ffd19f; border-color: rgba(232,117,48,.6); }
.exam-layout { width: min(1320px, 100%); margin: auto; display: grid; grid-template-columns: minmax(0, 1fr) 310px; min-height: calc(100vh - 72px); }
.exam-layout.quick-layout { display: block; }
.question-area { padding: 28px 38px 40px; min-width: 0; }
.question-card { max-width: 850px; margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 20px; overflow: hidden; box-shadow: 0 10px 35px rgba(23,42,58,.06); }
.question-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 17px 22px; border-bottom: 1px solid var(--line); color: var(--ink-soft); font-size: 12px; }
.marks { border-radius: 999px; background: var(--orange-soft); color: #a84d18; font-weight: 700; padding: 5px 9px; }
.case-box { padding: 20px 22px; background: #edf5f4; border-bottom: 1px solid #cfe2df; color: #294d50; line-height: 1.62; white-space: pre-line; font-size: 14px; }
.case-box strong { display: block; color: var(--teal-dark); margin-bottom: 7px; }
.question-body { padding: 26px 28px 30px; }
.question-body h2 { margin: 0 0 23px; font: 600 clamp(18px, 2.4vw, 23px)/1.45 "DM Sans", sans-serif; }
.options { display: grid; gap: 11px; }
.option { border: 1px solid var(--line); border-radius: 13px; background: #fff; padding: 14px 15px; display: grid; grid-template-columns: 32px 1fr; gap: 11px; text-align: left; cursor: pointer; line-height: 1.45; transition: .14s; }
.option:hover { border-color: #9bbcb9; background: #fbfdfc; }
.option.selected { border-color: var(--teal); background: #edf8f6; box-shadow: 0 0 0 1px var(--teal); }
.option-key { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; border: 1px solid #cfd7d6; font-weight: 700; font-size: 12px; }
.option.selected .option-key { color: #fff; background: var(--teal); border-color: var(--teal); }
.question-actions { max-width: 850px; margin: 15px auto 0; display: flex; justify-content: space-between; gap: 10px; }
.question-actions > div { display: flex; gap: 9px; }

.palette { border-left: 1px solid var(--line); background: var(--surface); padding: 24px 20px; position: sticky; top: 72px; height: calc(100vh - 72px); overflow: auto; }
.palette h3 { margin: 0; font-size: 17px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 12px; margin: 14px 0 18px; color: var(--ink-soft); font-size: 10px; }
.legend span::before { content: ""; width: 8px; height: 8px; display: inline-block; border-radius: 3px; background: #e7e6e1; margin-right: 5px; }
.legend .l-answered::before { background: var(--teal); }
.legend .l-flagged::before { background: var(--orange); }
.palette-group { margin-bottom: 18px; }
.palette-group-title { font-size: 11px; color: var(--ink-soft); margin-bottom: 7px; font-weight: 700; }
.palette-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.palette-btn { aspect-ratio: 1; border: 1px solid var(--line); border-radius: 8px; background: #eeede8; cursor: pointer; font-size: 11px; position: relative; }
.palette-btn.visited { background: #fff; }
.palette-btn.answered { background: var(--teal); color: #fff; border-color: var(--teal); }
.palette-btn.flagged::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--orange); position: absolute; top: -3px; right: -3px; border: 2px solid #fff; }
.palette-btn.current { outline: 2px solid var(--ink); outline-offset: 2px; }
.mobile-palette-btn { display: none; }

/* Results */
.results-hero { background: var(--ink); color: #fff; border-radius: 26px; padding: 34px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 20px; }
.results-hero h1 { margin: 5px 0 9px; font-size: 34px; }
.result-score { text-align: right; }
.result-score strong { display: block; font-size: 44px; }
.result-score span { color: #c3ced4; }
.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 18px 0 25px; }
.result-stat { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.result-stat strong { display: block; font-size: 22px; }
.result-stat span { color: var(--ink-soft); font-size: 12px; }
.review-list { display: grid; gap: 12px; }
.review-item { background: #fff; border: 1px solid var(--line); border-left: 5px solid #bbb; border-radius: 14px; padding: 18px 20px; }
.review-item.correct { border-left-color: var(--green); }
.review-item.wrong { border-left-color: var(--red); }
.review-item.unanswered { border-left-color: #9aa4aa; }
.review-item h3 { font: 600 16px/1.45 "DM Sans", sans-serif; margin: 5px 0 12px; }
.answer-line { font-size: 13px; margin: 5px 0; }
.answer-line strong { color: var(--ink-soft); }
.explanation { margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: 13px; line-height: 1.55; }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(10,24,35,.64); backdrop-filter: blur(5px); display: grid; place-items: center; padding: 18px; }
.modal { width: min(520px, 100%); max-height: 90vh; overflow: auto; background: var(--surface); border-radius: 20px; box-shadow: 0 24px 80px rgba(0,0,0,.25); padding: 27px; }
.quick-backdrop { background: rgba(23, 42, 58, .42); }
.quick-modal { width: min(720px, 100%); padding: 0; border: 1px solid rgba(255,255,255,.7); box-shadow: 0 24px 80px rgba(23,42,58,.22); }
.quick-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 24px 26px 13px; }
.quick-modal-head h2 { margin: 0; font-size: 23px; }
.quick-close { width: 36px; height: 36px; border: 0; border-radius: 50%; background: #eeece5; color: var(--ink-soft); cursor: pointer; font-size: 25px; line-height: 1; }
.quick-progress { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding: 0 26px 17px; }
.quick-progress span { height: 4px; border-radius: 99px; background: #dfded8; }
.quick-progress span.done { background: #84c9c1; }
.quick-progress span.current { background: var(--teal); }
.quick-case { max-height: 180px; overflow: auto; margin: 0 26px 18px; padding: 14px 16px; border-radius: 12px; background: #edf7f5; color: #315558; font-size: 13px; line-height: 1.5; }
.quick-case strong { color: var(--teal-dark); }
.quick-case p { margin: 5px 0 0; }
.quick-question-meta { padding: 0 26px; color: var(--ink-soft); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.quick-stem { margin: 9px 26px 18px; font: 600 19px/1.45 "DM Sans", sans-serif; }
.quick-options { padding: 0 26px; }
.quick-options .option.correct { border-color: var(--green); background: #e8f5ed; box-shadow: 0 0 0 1px var(--green); }
.quick-options .option.correct .option-key { background: var(--green); border-color: var(--green); color: #fff; }
.quick-options .option.wrong { border-color: var(--red); background: #fbeceb; }
.quick-options .option.wrong .option-key { background: var(--red); border-color: var(--red); color: #fff; }
.quick-options .option.muted { opacity: .58; }
.quick-feedback { margin: 18px 26px 0; padding: 14px 16px; border-radius: 12px; font-size: 13px; line-height: 1.5; }
.quick-feedback.correct { background: #e8f5ed; color: #195f40; }
.quick-feedback.wrong { background: #fbeceb; color: #86362f; }
.quick-feedback p { margin: 5px 0 0; }
.quick-hint { margin: 16px 26px 0; color: var(--ink-soft); font-size: 12px; }
.quick-modal-actions { display: flex; justify-content: flex-end; align-items: center; gap: 9px; padding: 18px 26px 24px; }
.modal h2 { margin: 0 0 7px; }
.modal p { color: var(--ink-soft); line-height: 1.55; }
.rule-list { display: grid; gap: 8px; margin: 18px 0; }
.rule { display: flex; justify-content: space-between; gap: 15px; border-bottom: 1px solid var(--line); padding: 9px 0; }
.rule span { color: var(--ink-soft); }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translate(-50%, 100px); opacity: 0; color: white; background: var(--ink); padding: 12px 17px; border-radius: 11px; box-shadow: var(--shadow); transition: .2s; pointer-events: none; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 900px) {
  .hero, .grid-2 { grid-template-columns: 1fr; }
  .quick-panel { align-items: flex-start; flex-direction: column; }
  .hero-side { min-height: 280px; }
  .exam-layout { grid-template-columns: 1fr; }
  .palette { display: none; position: fixed; z-index: 30; inset: 72px 0 0 20%; height: auto; box-shadow: -20px 0 50px rgba(23,42,58,.25); }
  .palette.open { display: block; }
  .mobile-palette-btn { display: inline-flex; }
  .question-area { padding: 20px; }
}

@media (max-width: 600px) {
  .shell { width: min(100% - 24px, 1240px); padding-top: 14px; }
  .masthead { align-items: flex-start; margin-bottom: 17px; }
  .brand-sub { display: none; }
  .exam-switch button { padding: 8px 10px; }
  .hero-main { padding: 28px 22px; min-height: 350px; }
  .hero-side { padding: 22px; }
  .panel { padding: 18px; }
  .history-row { grid-template-columns: 1fr auto; }
  .history-row .history-actions { grid-column: 1/-1; }
  .exam-top { height: auto; min-height: 68px; padding: 10px 13px; }
  .exam-title span { display: none; }
  .timer { min-width: 90px; padding: 8px; }
  .question-area { padding: 12px; }
  .question-meta, .case-box { padding: 15px; }
  .question-body { padding: 20px 16px 23px; }
  .option { padding: 12px; }
  .question-actions { position: sticky; bottom: 0; background: rgba(245,246,243,.94); padding: 10px 0; backdrop-filter: blur(8px); }
  .question-actions .btn { padding: 10px 11px; font-size: 12px; }
  .results-hero { grid-template-columns: 1fr; padding: 26px 22px; }
  .result-score { text-align: left; }
  .result-grid { grid-template-columns: 1fr 1fr; }
  .palette { left: 8%; }
  .quick-modal-head { padding: 20px 18px 12px; }
  .quick-progress { padding-left: 18px; padding-right: 18px; }
  .quick-case { margin-left: 18px; margin-right: 18px; max-height: 145px; }
  .quick-question-meta { padding: 0 18px; }
  .quick-stem { margin-left: 18px; margin-right: 18px; }
  .quick-options { padding: 0 18px; }
  .quick-feedback, .quick-hint { margin-left: 18px; margin-right: 18px; }
  .quick-modal-actions { padding: 16px 18px 20px; }
}
