/* MDCAT Ace — global styles */
:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #142033;
  --muted: #5b6b80;
  --border: #dbe3ec;
  --brand: #0f766e;
  --brand-2: #14b8a6;
  --brand-soft: #e6f6f4;
  --accent: #f59e0b;
  --ok: #16a34a;
  --ok-soft: #e8f7ee;
  --bad: #dc2626;
  --bad-soft: #fdecec;
  --warn-soft: #fff6e0;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 14px;
  --bio: #16a34a;
  --chem: #7c3aed;
  --phy: #2563eb;
  --eng: #db2777;
  --lr: #ea580c;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220; --surface: #121b2d; --surface-2: #1a2540; --text: #e6edf6; --muted: #9aa9bd;
    --border: #26324a; --brand: #2dd4bf; --brand-2: #5eead4; --brand-soft: #0f2e2c;
    --ok-soft: #0f2a1b; --bad-soft: #341414; --warn-soft: #33270b;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1220; --surface: #121b2d; --surface-2: #1a2540; --text: #e6edf6; --muted: #9aa9bd;
  --border: #26324a; --brand: #2dd4bf; --brand-2: #5eead4; --brand-soft: #0f2e2c;
  --ok-soft: #0f2a1b; --bad-soft: #341414; --warn-soft: #33270b;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25); color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); letter-spacing: -.02em; }
h2 { font-size: clamp(1.35rem, 2.6vw, 1.8rem); letter-spacing: -.01em; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border);
}
.nav { display: flex; align-items: center; gap: 16px; height: 64px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.2rem; color: var(--text); }
.logo:hover { text-decoration: none; }
.logo-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #0f766e, #14b8a6); font-size: 1rem;
}
.logo span b { color: var(--brand); }
.nav-links { display: flex; gap: 4px; margin-left: auto; list-style: none; padding: 0; margin-top: 0; margin-bottom: 0; }
.nav-links a {
  display: block; padding: 8px 12px; border-radius: 10px; color: var(--muted); font-weight: 600; font-size: .95rem;
}
.nav-links a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-links a.active { color: var(--brand); background: var(--brand-soft); }
.icon-btn {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text); width: 40px; height: 40px;
  border-radius: 10px; cursor: pointer; display: grid; place-items: center; font-size: 1.05rem;
}
.menu-btn { display: none; }
@media (max-width: 860px) {
  .menu-btn { display: grid; margin-left: auto; }
  .nav-links {
    position: absolute; top: 64px; left: 0; right: 0; flex-direction: column; background: var(--surface);
    border-bottom: 1px solid var(--border); padding: 8px 16px 16px; display: none; margin: 0;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 12px; }
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 20px; border-radius: 12px;
  font-weight: 700; font-size: .95rem; border: 1px solid transparent; cursor: pointer; transition: transform .08s, background .15s;
  font-family: inherit; line-height: 1.2;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
:root[data-theme="dark"] .btn-primary { color: #04201d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { color: #04201d; } }
.btn-primary:hover { filter: brightness(1.08); }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 7px 12px; font-size: .85rem; border-radius: 10px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* Hero */
.hero { padding: 64px 0 40px; position: relative; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: -40% -10% auto auto; width: 620px; height: 620px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--brand-2) 22%, transparent), transparent 65%); z-index: -1;
}
.hero-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 40px; align-items: center; }
@media (max-width: 860px) { .hero-grid { grid-template-columns: 1fr; } .hero { padding-top: 36px; } }
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; font-size: .8rem; font-weight: 700;
  background: var(--brand-soft); color: var(--brand); margin-bottom: 16px;
}
.hero p.lead { font-size: 1.15rem; color: var(--muted); max-width: 560px; }
.hero h1 .hl { color: var(--brand); }

/* Cards & grids */
.section { padding: 40px 0; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.section-head p { margin: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1000px) { .grid-5 { grid-template-columns: repeat(3, 1fr); } .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px) { .grid-2, .grid-3, .grid-5 { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .grid-4 { grid-template-columns: 1fr; } }

.stat-card { text-align: center; padding: 18px 12px; }
.stat-card .num { font-size: 1.9rem; font-weight: 800; color: var(--brand); line-height: 1.1; }
.stat-card .lbl { font-size: .85rem; color: var(--muted); }

.subject-card { position: relative; display: flex; flex-direction: column; gap: 6px; color: var(--text); transition: transform .12s, border-color .15s; }
.subject-card:hover { transform: translateY(-2px); border-color: var(--sc, var(--brand)); text-decoration: none; }
.subject-card .ic {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 1.4rem;
  background: color-mix(in srgb, var(--sc) 14%, transparent); color: var(--sc); margin-bottom: 6px;
}
.subject-card h3 { margin: 0; }
.subject-card .meta { font-size: .85rem; color: var(--muted); }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--sc, var(--brand)); border-radius: 99px; }

.feature .ic { font-size: 1.5rem; margin-bottom: 8px; }
.feature h3 { margin-bottom: 4px; }
.feature p { margin: 0; color: var(--muted); font-size: .95rem; }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }

/* Page header */
.page-head { padding: 36px 0 12px; }
.page-head p { color: var(--muted); max-width: 720px; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
.crumbs a { color: var(--muted); }

/* Tabs / chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: .88rem; cursor: pointer; font-family: inherit;
}
.chip:hover { background: var(--surface-2); text-decoration: none; }
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }
:root[data-theme="dark"] .chip.active { color: #04201d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip.active { color: #04201d; } }

/* Layout with sidebar */
.layout { display: grid; grid-template-columns: 290px 1fr; gap: 24px; align-items: start; padding-bottom: 48px; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }
.sidebar { position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow: auto; padding: 12px; }
.layout > *, .test-shell > *, .grid > *, .hero-grid > * { min-width: 0; }
@media (max-width: 900px) { .sidebar { position: static; max-height: none; order: 2; } }
.sidebar h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 8px 8px 8px; }
.unit-list { list-style: none; margin: 0; padding: 0; }
.unit-list a {
  display: flex; gap: 10px; align-items: baseline; padding: 8px 10px; border-radius: 10px; color: var(--text); font-size: .93rem;
}
.unit-list a:hover { background: var(--surface-2); text-decoration: none; }
.unit-list a.active { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.unit-list .n { font-size: .78rem; color: var(--muted); min-width: 22px; font-variant-numeric: tabular-nums; }
.unit-list .cnt { margin-left: auto; font-size: .75rem; color: var(--muted); }

/* Notes */
.notes { font-size: 1.02rem; }
.notes h2 { margin-top: 0; }
.notes h3 { margin-top: 1.4em; color: var(--brand); }
.notes ul, .notes ol { padding-left: 1.3em; margin: 0 0 1em; }
.notes li { margin-bottom: .35em; }
.notes table { margin: 0 0 1em; border: 1px solid var(--border); border-radius: 10px; display: block; overflow-x: auto; width: fit-content; max-width: 100%; }
@media (max-width: 600px) { article.notes { padding: 18px !important; } .notes th, .notes td { padding: 8px 10px; } }
.notes .tip, .tip {
  background: var(--warn-soft); border-left: 4px solid var(--accent); padding: 12px 14px; border-radius: 8px; margin: 1em 0; font-size: .95rem;
}
.notes .key, .key {
  background: var(--brand-soft); border-left: 4px solid var(--brand); padding: 12px 14px; border-radius: 8px; margin: 1em 0;
}
.notes code, code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .92em; }
.outcomes { margin-top: 24px; }
.outcomes details { border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; background: var(--surface); }
.outcomes summary { cursor: pointer; font-weight: 700; }
.outcomes ul { margin: 10px 0 0; padding-left: 1.2em; font-size: .93rem; color: var(--muted); }

/* MCQ */
.q-card { margin-bottom: 16px; }
.q-head { display: flex; justify-content: space-between; gap: 10px; font-size: .8rem; color: var(--muted); margin-bottom: 6px; }
.q-text { font-weight: 600; font-size: 1.05rem; margin-bottom: 12px; white-space: pre-line; }
.span-2 { grid-column: span 2; }
@media (max-width: 760px) { .span-2 { grid-column: auto; } }
@media (max-width: 900px) { .test-shell aside { position: static !important; } }
.opts { display: grid; gap: 8px; }
.opt {
  display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%; padding: 11px 14px; border-radius: 12px;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font: inherit; font-size: .98rem;
  transition: border-color .12s, background .12s;
}
.opt:hover:not([disabled]) { border-color: var(--brand); background: var(--brand-soft); }
.opt .l {
  flex: none; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: .8rem;
  background: var(--surface-2); color: var(--muted);
}
.opt.selected { border-color: var(--brand); background: var(--brand-soft); }
.opt.selected .l { background: var(--brand); color: #fff; }
.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.correct .l { background: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .l { background: var(--bad); color: #fff; }
.opt[disabled] { cursor: default; }
.explain {
  margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); font-size: .95rem;
}
.explain b.ok { color: var(--ok); }
.explain b.bad { color: var(--bad); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.score-pill { font-weight: 700; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); font-size: .9rem; }

/* Test runner */
.test-shell { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; padding-bottom: 48px; }
@media (max-width: 900px) { .test-shell { grid-template-columns: 1fr; } }
.test-top {
  position: sticky; top: 64px; z-index: 20; background: var(--bg); padding: 12px 0; display: flex; align-items: center; gap: 12px;
  justify-content: space-between; flex-wrap: wrap;
}
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.2rem; padding: 6px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.timer.low { color: var(--bad); border-color: var(--bad); }
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 6px; }
.palette button {
  height: 36px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: .8rem; font-weight: 700; cursor: pointer;
}
.palette button.ans { background: var(--brand); color: #fff; border-color: var(--brand); }
.palette button.flag { box-shadow: inset 0 -3px 0 var(--accent); }
.palette button.cur { outline: 2px solid var(--text); outline-offset: 1px; }
.palette button.r-ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.palette button.r-bad { background: var(--bad); color: #fff; border-color: var(--bad); }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: .78rem; color: var(--muted); margin-top: 12px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; border: 1px solid var(--border); }
.subject-tag { display: inline-block; font-size: .72rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; padding: 2px 8px; border-radius: 6px; color: #fff; }

.result-hero { text-align: center; padding: 28px; }
.ring { --p: 0; width: 160px; height: 160px; border-radius: 50%; margin: 0 auto 14px; display: grid; place-items: center;
  background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--surface-2) 0); }
.ring > div { width: 128px; height: 128px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 1.8rem; font-weight: 800; }
.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }

.form-row { display: grid; gap: 6px; margin-bottom: 14px; }
.form-row label { font-weight: 700; font-size: .9rem; }
select, input[type="number"], input[type="text"] {
  font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); width: 100%;
}
.check-list { display: grid; gap: 6px; max-height: 260px; overflow: auto; padding: 8px; border: 1px solid var(--border); border-radius: 10px; }
.check-list label { font-weight: 500; display: flex; gap: 8px; align-items: center; font-size: .92rem; cursor: pointer; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding: 32px 0; margin-top: 40px; background: var(--surface); }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 24px; }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr; } }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: 6px; }
.site-footer a { color: var(--muted); }
.site-footer h4 { font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.history-item { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: .93rem; }
.history-item:last-child { border-bottom: 0; }
