/* CARE Exam. The main site's light-blue palette (the owner's own look), with
   text size and high-contrast options. Sizes are in rem so the text size
   setting scales everything. */

:root {
  --accent: #5BB4E5;
  --accent-deep: #2F7FAF;
  --accent-soft: #E8F4FB;
  --ink: #1F3A5F;
  --text: #2B2F36;
  --muted: #5F6672;
  --line: #D5DAE1;
  --btn: #EEF1F4;
  --btn-hover: #E1E6EB;
  --page: #FFFFFF;
  --panel: #F7F9FB;
  --ok: #1E7A45;
  --ok-soft: #E6F4EC;
  --bad: #B3261E;
  --bad-soft: #FBEAE9;
  --flag: #A15C00;
  --flag-soft: #FFF3DF;
  --focus: #1F6FD1;
  --sans: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --wrap: 1080px;
  font-size: 100%;
  color-scheme: light;
}
:root[data-size="l"] { font-size: 112.5%; }
:root[data-size="xl"] { font-size: 125%; }
:root[data-size="xxl"] { font-size: 150%; }

/* High contrast: black on white, solid borders, no tints that carry meaning. */
:root[data-contrast="high"] {
  --accent: #000000;
  --accent-deep: #000000;
  --accent-soft: #FFFFFF;
  --ink: #000000;
  --text: #000000;
  --muted: #000000;
  --line: #000000;
  --btn: #FFFFFF;
  --btn-hover: #FFFF00;
  --panel: #FFFFFF;
  --ok: #00561F;
  --ok-soft: #FFFFFF;
  --bad: #8A0000;
  --bad-soft: #FFFFFF;
  --flag: #000000;
  --flag-soft: #FFFF00;
  --focus: #000000;
}
:root[data-contrast="high"] .btn, :root[data-contrast="high"] .opt, :root[data-contrast="high"] .cell { border-width: 2px; border-color: #000; }
:root[data-contrast="high"] a { text-decoration-thickness: 2px; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--text); font: 1rem/1.55 var(--sans); }
h1, h2, h3 { color: var(--ink); line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.3rem; margin-top: 1.6em; }
h3 { font-size: 1.05rem; }
h1:focus, h2:focus { outline: none; }
p { margin: 0 0 .8em; }
a { color: var(--accent-deep); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -9999px; top: 0; background: var(--ink); color: #fff; padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 1rem; top: 1rem; }

.wrap { width: 100%; max-width: calc(var(--wrap) + 2rem); margin: 0 auto; padding: 0 1rem; }
.narrow { max-width: 46rem; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 .25rem; color: var(--accent-deep); font-weight: 700; font-size: .85rem; letter-spacing: .04em; text-transform: uppercase; }
.lead { font-size: 1.12rem; }
.hint { color: var(--muted); font-size: .88rem; margin: .35rem 0 0; }
.loading { padding: 3rem 0; color: var(--muted); }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
  min-height: 2.75rem; padding: .5rem 1rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--btn); color: var(--ink); font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--btn-hover); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #16304f; }
:root[data-contrast="high"] .btn-primary { background: #000; color: #fff; }
:root[data-contrast="high"] .btn-primary:hover:not(:disabled) { background: #000; outline: 3px solid #FFFF00; }
.link-btn { background: none; border: 0; padding: .25rem; color: var(--accent-deep); text-decoration: underline; cursor: pointer; font-size: .9rem; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1.5rem 0; }

/* ---------- site header and footer ---------- */

.site-head { border-top: 4px solid var(--accent); border-bottom: 1px solid var(--line); }
.site-head .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem; min-height: 4.5rem; }
.brand img { display: block; width: 220px; height: auto; }
.site-nav { display: flex; flex-wrap: wrap; gap: .25rem 1.1rem; margin-left: auto; }
.site-nav a { color: var(--ink); font-weight: 600; text-decoration: none; padding: .4rem 0; }
.site-nav a:hover, .site-nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 4px; }
.site-foot { margin-top: 3rem; padding: 1.5rem 0 2rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .88rem; }
.site-foot .display-controls { margin-top: .75rem; }

.display-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; }
.display-controls select { min-height: 2.5rem; padding: .25rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--page); }
.pref-check { display: inline-flex; align-items: center; gap: .4rem; min-height: 2.5rem; }
.pref-check input { width: 1.2rem; height: 1.2rem; }

/* ---------- landing page ---------- */

.hero { padding: 2.5rem 0 1rem; }
.hero h1 { font-size: 2.3rem; max-width: 22ch; }
.notice { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: .9rem 1rem; border-radius: 0 8px 8px 0; margin: 1.25rem 0; }
:root[data-contrast="high"] .notice { border: 2px solid #000; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; margin: 1rem 0; }
.card { border: 1px solid var(--line); border-radius: 10px; padding: 1.1rem 1.2rem; background: var(--page); }
.card h3 { margin-top: 0; }
.card .btn { margin-top: .5rem; }
.faq details { border-bottom: 1px solid var(--line); padding: .75rem 0; }
.faq summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.faq details p { margin: .6rem 0 0; }
.features { padding-left: 1.2rem; }
.features li { margin-bottom: .4rem; }

table { border-collapse: collapse; }
.format, .simple, .scores { width: 100%; margin: 1rem 0; }
.format th, .format td, .simple th, .simple td, .scores th, .scores td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.format thead th, .simple thead th, .scores thead th { background: var(--panel); color: var(--ink); font-size: .9rem; }
.format tfoot th, .format tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
.break-row th, .break-row td { color: var(--muted); font-style: italic; }
.table-scroll { overflow-x: auto; }

/* ---------- start and between screens ---------- */

.start, .between { padding: 2rem 1rem 3rem; }
.rules { padding-left: 1.2rem; }
.rules li { margin-bottom: .35rem; }
.settings { display: grid; gap: 1rem; }
.setting label { font-weight: 600; margin-right: .5rem; }
.setting select { min-height: 2.5rem; padding: .25rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--page); max-width: 100%; }
.break-clock { font-size: 3rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; margin: 1rem 0; }

/* ---------- the test screen ---------- */

.test-shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.tbar {
  position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem 1.25rem;
  padding: .55rem 1rem; background: var(--ink); color: #fff; font-size: .95rem;
}
:root[data-contrast="high"] .tbar { background: #000; }
.tbar-name { display: flex; align-items: center; gap: .45rem; font-weight: 700; }
.tbar-name img { display: block; }
.tbar-section { font-weight: 600; }
.tbar-count { margin-left: auto; font-variant-numeric: tabular-nums; }
.timer { display: flex; align-items: center; gap: .4rem; padding: .2rem .6rem; border-radius: 6px; background: rgba(255,255,255,.12); font-variant-numeric: tabular-nums; }
.timer-value { font-weight: 700; min-width: 3.6em; }
.timer.low { background: #FCE3B0; color: #5A3600; }
.timer .link-btn { color: inherit; }
.timer-hidden { font-style: italic; opacity: .8; }

.qarea { flex: 1 0 auto; width: 100%; max-width: 72rem; margin: 0 auto; padding: 1.25rem 1rem 6.5rem; }
.qarea.with-passage { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.passage {
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 1rem 1.2rem;
  position: sticky; top: 4rem; max-height: calc(100dvh - 11rem); overflow: auto;
}
.passage-title { margin-top: 0; font-size: 1.1rem; }
.passage-text { font-size: 1.05rem; line-height: 1.65; }
.passage-text table, .stem table { border-collapse: collapse; margin: .5rem 0 1rem; font-size: .95rem; }
.passage-text th, .passage-text td, .stem th, .stem td { border: 1px solid var(--line); padding: .35rem .6rem; text-align: left; }
.passage-text th, .stem th { background: var(--accent-soft); }
.qpanel { min-width: 0; }
.qpanel.wide { max-width: 60rem; }
.qnum { font-size: 1rem; color: var(--muted); margin: 0 0 .5rem; }
.stem { font-size: 1.12rem; line-height: 1.6; margin-bottom: .75rem; color: var(--text); }
.stem img, .stem svg { max-width: 100%; height: auto; }
.instruction { color: var(--muted); font-size: .92rem; font-style: italic; }
.sample-note { background: var(--flag-soft); border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; }

.bbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem;
  padding: .65rem 1rem; background: var(--page); border-top: 1px solid var(--line); box-shadow: 0 -2px 8px rgba(0,0,0,.05);
}
.bbar .btn-primary { margin-left: auto; }
.flag-btn[aria-pressed="true"], .calc-btn[aria-pressed="true"] { background: var(--flag-soft); border-color: var(--flag); color: var(--flag); }
:root[data-contrast="high"] .flag-btn[aria-pressed="true"] { color: #000; }

/* choices */
.choices { display: grid; gap: .55rem; }
.opt {
  display: grid; grid-template-columns: auto auto 1fr auto; align-items: start; gap: .65rem;
  padding: .75rem .9rem; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: var(--page);
}
.opt:hover { border-color: var(--accent); }
.opt:has(input:checked) { border-color: var(--ink); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--ink); }
.opt:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.opt input { width: 1.2rem; height: 1.2rem; margin: .2rem 0 0; accent-color: var(--ink); }
.opt-letter { font-weight: 700; color: var(--muted); }
.opt-text { font-size: 1.05rem; }
.opt.is-key { border-color: var(--ok); background: var(--ok-soft); }
.opt.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt:has(input:disabled) { cursor: default; }
.mark { font-weight: 700; font-size: .88rem; white-space: nowrap; }
.mark.ok { color: var(--ok); }
.mark.bad { color: var(--bad); }

/* fill in */
.fill { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.fill-input { width: 10rem; min-height: 2.75rem; padding: .4rem .7rem; border: 2px solid var(--line); border-radius: 8px; font-size: 1.15rem; }
.fill-input:focus { border-color: var(--ink); }
.fill-unit { font-weight: 600; }
.key-note { margin-top: .5rem; }

/* hot spot */
.hs-box { position: relative; display: inline-block; max-width: 100%; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; touch-action: manipulation; cursor: crosshair; background: #fff; }
.hs-box[role="img"] { cursor: default; }
.hs-img { display: block; max-width: 100%; width: 34rem; height: auto; user-select: none; -webkit-user-select: none; }
.hs-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.hs-ring { fill: rgba(31, 58, 95, .15); stroke: #1F3A5F; stroke-width: 2.5; }
.hs-dot { fill: #1F3A5F; }
.hs-target { fill: rgba(30, 122, 69, .18); stroke: #1E7A45; stroke-width: 3; stroke-dasharray: 8 4; }
.hs-legend { margin-top: .5rem; }

/* ordered response */
.order { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.order-box { border: 1px solid var(--line); border-radius: 10px; padding: .75rem; background: var(--panel); }
.order-title { font-size: .95rem; margin: 0 0 .5rem; }
.order-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.order-item { display: flex; align-items: center; gap: .5rem; min-height: 2.75rem; padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 8px; background: var(--page); }
.order-item.is-key { border-color: var(--ok); }
.order-item.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.order-add { flex: 1; min-height: 2.5rem; text-align: left; background: none; border: 0; padding: .25rem; cursor: pointer; color: var(--text); }
.order-add:hover { text-decoration: underline; }
.order-num { font-weight: 700; color: var(--muted); }
.order-text { flex: 1; }
.order-ctls { display: flex; gap: .25rem; }
.order-ctl { width: 2.4rem; height: 2.4rem; border: 1px solid var(--line); border-radius: 6px; background: var(--btn); cursor: pointer; }
.order-ctl:disabled { opacity: .35; cursor: default; }
.order-empty { color: var(--muted); font-style: italic; padding: .5rem; }

/* section review grid */
.review-grid { list-style: none; margin: 1rem 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr)); gap: .5rem; }
.cell { position: relative; width: 100%; min-height: 3.6rem; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 8px; background: var(--page); cursor: pointer; }
.cell-num { font-weight: 700; font-size: 1.05rem; }
.cell-state { font-size: .7rem; color: var(--bad); }
.cell.is-done { background: var(--accent-soft); border-color: var(--accent-deep); }
.cell.is-empty { border-style: dashed; border-color: var(--bad); }
.cell.is-flag { box-shadow: inset 0 0 0 2px var(--flag); }
.cell-flag { position: absolute; top: .15rem; right: .35rem; color: var(--flag); }
.legend { display: flex; flex-wrap: wrap; gap: .6rem; }
.key { display: inline-block; padding: .15rem .6rem; border: 1px solid var(--line); border-radius: 6px; font-size: .85rem; }
.key.is-done { background: var(--accent-soft); border-color: var(--accent-deep); }
.key.is-empty { border-style: dashed; border-color: var(--bad); }
.key.is-flag { box-shadow: inset 0 0 0 2px var(--flag); }

/* dialogs and toasts */
.dialog-back { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 1rem; background: rgba(15, 23, 42, .45); }
.dialog { width: 100%; max-width: 30rem; padding: 1.4rem 1.5rem; border-radius: 12px; background: var(--page); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
:root[data-contrast="high"] .dialog { border: 3px solid #000; }
.dialog h2 { margin-top: 0; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.toast { position: fixed; bottom: 5.5rem; left: 50%; transform: translateX(-50%); z-index: 40; max-width: calc(100% - 2rem); padding: .7rem 1rem; border-radius: 8px; background: var(--ink); color: #fff; font-weight: 600; box-shadow: 0 4px 16px rgba(0,0,0,.2); }

/* calculator (from the main site) */
.calc { position: fixed; z-index: 30; width: 15.5rem; padding: .6rem; border: 1px solid var(--line); border-radius: 12px; background: var(--page); box-shadow: 0 8px 30px rgba(0,0,0,.2); }
.calc-head { display: flex; align-items: center; justify-content: space-between; cursor: move; touch-action: none; padding-bottom: .4rem; }
.calc-head h2 { font-size: .95rem; margin: 0; }
.calc-x { width: 2.2rem; height: 2.2rem; border: 0; background: none; cursor: pointer; font-size: 1rem; }
.calc-screen { padding: .4rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); text-align: right; margin-bottom: .5rem; }
.calc-expr { min-height: 1.1em; font-size: .8rem; color: var(--muted); }
.calc-out { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.calc-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: .35rem; }
.calc-keys button { min-height: 2.6rem; border: 1px solid var(--line); border-radius: 8px; background: var(--btn); font-weight: 600; cursor: pointer; }
.calc-keys button.op { background: var(--accent-soft); }
.calc-keys button.eq { background: var(--ink); color: #fff; }
.calc-keys button.pressed { filter: brightness(.9); }

/* ---------- results and review ---------- */

.results, .review { padding: 2rem 1rem 3rem; }
.score-hero { display: grid; grid-template-columns: auto 1fr; gap: .5rem 2rem; align-items: center; padding: 1.25rem 1.5rem; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); margin: 1rem 0; }
.total { display: flex; flex-direction: column; }
.total-num { font-size: 3rem; font-weight: 800; color: var(--ink); line-height: 1; }
.total-label, .level-label { font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.level { display: flex; flex-direction: column; }
.level-name { font-size: 1.6rem; font-weight: 700; color: var(--ink); }
.counts { grid-column: 1 / -1; color: var(--muted); }
.levels { margin: .5rem 0 1rem; }
.levels summary { cursor: pointer; color: var(--accent-deep); font-weight: 600; }
.scores .sec-row th, .scores .sec-row td { font-weight: 700; background: var(--panel); }
.scores .sub-row th { font-weight: 400; padding-left: 1.6rem; }
.bar-col { width: 30%; }
.bar { display: block; height: .7rem; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent-deep); }
:root[data-contrast="high"] .bar { border: 1px solid #000; background: #fff; }
:root[data-contrast="high"] .bar-fill { background: #000; }
.review-topics li { margin-bottom: .35rem; }
.review-sec { border-bottom: 2px solid var(--accent); padding-bottom: .3rem; }
.review-item { border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.2rem; margin: 1rem 0; }
.review-head { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; margin-bottom: .5rem; }
.review-head h3 { margin: 0; }
.tag { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; border: 1px solid var(--line); }
.tag-ok { color: var(--ok); border-color: var(--ok); background: var(--ok-soft); }
.tag-bad { color: var(--bad); border-color: var(--bad); background: var(--bad-soft); }
.tag-trial { color: var(--muted); border-style: dashed; }
.tag-plain { color: var(--muted); font-weight: 400; }
.review-passage { margin-bottom: .75rem; padding: .5rem .8rem; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.review-passage summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.explanation { margin-top: 1rem; padding: .8rem 1rem; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); }
.explanation h3 { margin: 0 0 .4rem; font-size: .95rem; }
.why { margin: 0; padding-left: 1.1rem; }
.why li { margin-bottom: .45rem; }
.why-right b { color: var(--ok); }
.why-wrong b { color: var(--text); }
.explain { margin-top: .4rem; }
.study-link { margin: .75rem 0 0; font-size: .9rem; }

/* ---------- study pages ---------- */

.study { padding: 2rem 1rem 3rem; }
.study-toc { columns: 2 18rem; padding-left: 1.2rem; }
.study-toc li { margin-bottom: .3rem; break-inside: avoid; }
.study-area { border-top: 1px solid var(--line); padding-top: 1rem; margin-top: 2rem; scroll-margin-top: 1rem; }
.study-area h2 { margin-top: .5rem; }
.study-area .section-tag { color: var(--accent-deep); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.example { border-left: 4px solid var(--accent); background: var(--panel); padding: .7rem 1rem; margin: .8rem 0; border-radius: 0 8px 8px 0; }
.study-area table { margin: .6rem 0 1rem; }
.study-area th, .study-area td { border: 1px solid var(--line); padding: .35rem .6rem; text-align: left; }
.study-area th { background: var(--accent-soft); }
.back-top { font-size: .9rem; }

/* ---------- narrow screens (practice works on phones) ---------- */

@media (max-width: 760px) {
  h1 { font-size: 1.55rem; }
  .hero h1 { font-size: 1.8rem; }
  .qarea.with-passage { display: block; }
  .passage { position: static; max-height: none; margin-bottom: 1.25rem; }
  .order { grid-template-columns: 1fr; }
  .tbar { font-size: .85rem; gap: .25rem .75rem; }
  .tbar-name span { display: none; }
  .bbar { gap: .35rem; padding: .5rem; }
  .bbar .btn { flex: 1 1 auto; padding: .45rem .6rem; font-size: .9rem; }
  .bbar .btn-primary { margin-left: 0; }
  .qarea { padding-bottom: 9rem; }
  .score-hero { grid-template-columns: 1fr; }
  .bar-col { display: none; }
  .brand img { width: 180px; }
  .site-nav { margin-left: 0; }
}
