:root {
  color-scheme: light;
  --ink: #142f35;
  --muted: #4b6568;
  --brand: #175e55;
  --brand-strong: #104d45;
  --paper: #ffffff;
  --page: #f2f6f3;
  --line: #cfddd7;
  --diagram: #f1f7f5;
  --good: #165a45;
  --good-pale: #e8f5ec;
  --retry: #76451c;
  --retry-pale: #fff4e3;
  --body-font: "Avenir Next", Avenir, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font: 1rem/1.55 var(--body-font); }
a { color: var(--brand); }
button, input { font: inherit; }
button:not(:disabled) { cursor: pointer; }
:focus-visible { outline: 3px solid #2679aa; outline-offset: 4px; }
.skip-link { position: absolute; z-index: 2; inset: 0 auto auto 0; padding: .7rem 1rem; background: var(--paper); transform: translateY(-120%); }
.skip-link:focus { transform: none; }

.site-header { background: var(--paper); border-bottom: 1px solid var(--line); }
.header-inner, .main { width: min(100% - 3rem, 72rem); margin-inline: auto; }
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 4.5rem; gap: 1rem; }
.brand { display: inline-flex; gap: .65rem; align-items: center; text-decoration: none; font-weight: 800; font-size: .875rem; letter-spacing: .085em; color: var(--ink); }
.brand-mark { display: grid; place-items: center; width: 2.3rem; height: 2.3rem; background: var(--brand); color: white; border-radius: .55rem; font-size: 1.25rem; letter-spacing: normal; }
.brand-sub { color: var(--muted); font-weight: 600; }
.site-header nav { display: flex; gap: .3rem; align-items: center; }
.site-header nav a { font-size: .9rem; text-decoration: none; font-weight: 700; padding: .5rem .7rem; border-radius: .55rem; }
.site-header nav a[aria-current] { background: #e3efe8; color: var(--brand-strong); }

.main { padding-block: 2.6rem 4rem; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2rem, 4vw, 3.65rem); line-height: 1.09; letter-spacing: -.044em; }
h2 { line-height: 1.22; letter-spacing: -.018em; }
.kicker { color: var(--brand); font-weight: 750; letter-spacing: .05em; font-size: .875rem; }
.intro h1 { margin: .35rem 0 .7rem; }
.intro .description { color: var(--muted); max-width: 45ch; font-size: 1.1rem; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.25rem; }
.grade-picker { position: relative; display: grid; gap: .3rem; }
.grade-picker label { color: var(--muted); font-size: .875rem; font-weight: 750; }
.grade-picker select {
  appearance: none;
  min-height: 2.6rem;
  padding: .45rem 2rem .45rem .7rem;
  background: var(--paper);
  border: 1px solid #a6bdb5;
  border-radius: .55rem;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}
.grade-picker::after {
  content: '';
  position: absolute;
  right: .8rem;
  bottom: 1rem;
  width: .43rem;
  height: .43rem;
  border-right: 2px solid var(--brand);
  border-bottom: 2px solid var(--brand);
  transform: rotate(45deg);
  pointer-events: none;
}
.grade-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  border-radius: .45rem;
  padding: .2rem .55rem;
  background: #e4efe9;
  color: var(--brand-strong);
  font-size: .875rem;
  font-weight: 750;
  white-space: nowrap;
}
.topic-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.1rem; margin-top: 2.1rem; }
.topic-card { display: flex; flex-direction: column; min-width: 0; background: var(--paper); border: 1px solid var(--line); border-radius: 1rem; overflow: hidden; }
.topic-card figure { border-radius: 0; border: 0; border-bottom: 1px solid var(--line); margin: 0; }
.topic-card canvas { aspect-ratio: 2.6; }
.topic-body { display: flex; flex: 1; flex-direction: column; align-items: flex-start; padding: 1.25rem; gap: .7rem; }
.topic-body h2 { font-size: 1.35rem; }
.topic-body p { color: var(--muted); }
.topic-progress { margin-top: auto; font-size: .875rem; font-weight: 700; }
.topic-body .primary { margin-top: .1rem; }

.session-nav { margin-bottom: .65rem; font-size: .9rem; }
.session-head h1 { font-size: clamp(1.95rem, 4vw, 2.8rem); }
.session-head p { color: var(--muted); margin-top: .45rem; }
.session-grid { display: grid; grid-template-columns: minmax(0, 1fr) 17rem; gap: 1.3rem; align-items: start; margin-top: 1.45rem; }
.question-card, .path-card, .complete-card { min-width: 0; background: var(--paper); border: 1px solid var(--line); border-radius: 1rem; }
.question-card, .complete-card { padding: clamp(1rem, 3vw, 1.9rem); }
.question-meta { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem; color: var(--muted); margin-bottom: .7rem; font-size: .9rem; }
.level { display: inline-flex; align-items: center; gap: .28rem; border-radius: .45rem; padding: .2rem .55rem; border: 1px solid currentColor; font-weight: 750; white-space: nowrap; }
.level-1 { background: #f7f8f8; color: #42595c; }
.level-2 { background: #e7f4e7; color: #285e40; }
.level-3 { background: #e6f1f9; color: #205a87; }
.level-4 { background: #f0eafa; color: #5b3b89; }
.level-5 { background: #fcf0d6; color: #794a08; }
.question-card h2 { font-size: clamp(1.26rem, 2vw, 1.6rem); overflow-wrap: anywhere; }
.lookup-note { margin-top: .4rem; color: var(--muted); font-size: .84rem; }
.lookup-touch { display: none; }
.lookup-word[aria-describedby] {
  background: #e6f1eb;
  text-decoration: underline solid #286655;
  text-underline-offset: .15em;
}
#word-meaning {
  position: fixed; z-index: 30; max-width: min(20rem, calc(100vw - 16px));
  padding: .55rem .7rem; border-radius: .55rem; pointer-events: none;
  color: #fff; background: #203b34; box-shadow: 0 .3rem .95rem #102b332c;
  font-size: .95rem; line-height: 1.35; overflow-wrap: anywhere;
}
#word-meaning strong, #word-meaning span { display: block; }
#word-meaning strong { margin-bottom: .15rem; color: #cce7dc; font-size: .85rem; }
@media (hover: none) {
  .lookup-mouse { display: none; }
  .lookup-touch { display: inline; }
}
.question-card figure { margin: 1rem 0; }
.question-card .figure canvas { max-height: 13.75rem; }
.question-card .figure.two-cases canvas { max-height: 17.5rem; }
.figure { overflow: hidden; border: 1px solid #dbe8e1; border-radius: .75rem; background: var(--diagram); }
.figure canvas { display: block; width: 100%; aspect-ratio: 2.45; }
.figure.two-cases canvas { aspect-ratio: 1.9; }
.figure figcaption { padding: .55rem .8rem; border-top: 1px solid #dbe8e1; color: var(--muted); font-size: .9rem; line-height: 1.4; overflow-wrap: anywhere; }
.answer-group { border: 0; padding: 0; margin: 0; min-inline-size: 0; }
.answer-group legend { padding: 0; font-weight: 740; margin-bottom: .6rem; }
.options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.option { position: relative; display: flex; align-items: flex-start; gap: .6rem; cursor: pointer; min-height: 3.15rem; padding: .64rem .78rem; border-radius: .65rem; border: 1px solid var(--line); line-height: 1.4; overflow-wrap: anywhere; }
.option:hover { background: #f3f8f5; }
.option:has(input:checked) { border-color: #338076; background: #e9f4f0; }
.option:has(input:focus-visible) { outline: 3px solid #2679aa; outline-offset: 2px; }
.option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.option-letter { display: grid; place-items: center; flex: 0 0 1.55rem; height: 1.55rem; border: 1px solid #c8dad3; border-radius: .34rem; background: var(--paper); font-size: .875rem; font-weight: 750; }
.option.correct { border-color: #548875; background: var(--good-pale); }
.option.incorrect:has(input:checked) { border-color: #b37a41; background: var(--retry-pale); }
.option:has(input:disabled) { cursor: default; }
.choice-note { display: block; font-size: .875rem; font-weight: 750; color: var(--good); margin-top: .12rem; }
.incorrect .choice-note { color: var(--retry); }
.question-actions { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; margin-top: 1rem; }
.primary, .secondary { display: inline-flex; min-height: 2.75rem; align-items: center; justify-content: center; padding: .55rem .95rem; border-radius: .6rem; font-weight: 750; line-height: 1.25; text-align: center; text-decoration: none; }
.primary { background: var(--brand); color: white; border: 1px solid var(--brand); }
.primary:hover { background: var(--brand-strong); }
.primary:disabled { color: #4d6560; background: #e7eeea; border-color: #d3dfd9; }
.secondary { background: var(--paper); color: var(--brand-strong); border: 1px solid #9cb6ad; }
.secondary:hover { background: #ebf4ee; }
.feedback { margin-top: 1rem; padding: .85rem 1rem; border-radius: .65rem; background: var(--good-pale); }
.feedback.wrong { background: var(--retry-pale); }
.feedback h3 { font-size: 1.05rem; margin-bottom: .28rem; }
.feedback p + p { margin-top: .4rem; }
.feedback .explanation-visual { margin: .85rem 0 .65rem; }
.explanation-visual canvas { aspect-ratio: 2.75; }
.replay-button { font-size: .9rem; min-height: 2.35rem; }


.path-card { padding: 1.05rem; }
.path-card h2 { font-size: 1.1rem; }
.path-card progress { display: block; width: 100%; height: .65rem; accent-color: var(--brand); margin: .75rem 0 .45rem; }
.progress-label { color: var(--muted); font-size: .875rem; }
.path-list { list-style: none; margin: .8rem 0; padding: 0; }
.path-list li { display: flex; align-items: center; gap: .55rem; padding: .38rem 0; font-size: .9rem; line-height: 1.3; }
.path-list li[aria-current] { color: var(--brand-strong); font-weight: 800; }
.path-number { flex: 0 0 1.4rem; text-align: center; color: var(--muted); border-radius: .3rem; background: #eaf1ed; font-size: .8rem; font-weight: 750; padding: .18rem .18rem; }
.path-list li[aria-current] .path-number { background: var(--brand); color: white; }
.mode-note { padding-top: .85rem; border-top: 1px solid var(--line); }
.mode-note p { margin: .55rem 0 .7rem; color: var(--muted); font-size: .9rem; }
.complete-card h2 { font-size: 1.6rem; margin-bottom: .6rem; }
.complete-card p { color: var(--muted); }

@media (max-width: 860px) {
  .session-grid { grid-template-columns: minmax(0, 1fr); }
  .topic-grid { gap: .75rem; }
  .topic-body { padding: .9rem; }
}
@media (max-width: 620px) {
  .main, .header-inner { width: min(100% - 1.5rem, 72rem); }
  .header-inner { min-height: 3.65rem; }
  .brand-sub { display: none; }
  .site-header nav a { padding: .42rem .5rem; }
  .main { padding-block: 1.4rem 2.6rem; }
  .section-heading { flex-direction: column; gap: .8rem; }
  .topic-grid, .options { grid-template-columns: minmax(0, 1fr); }
  .topic-grid { margin-top: 1.25rem; }
  .topic-body { padding: 1rem; }
  .session-grid { margin-top: 1rem; }
  .figure.two-cases canvas { aspect-ratio: 1.55; }
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.end-session { color: var(--brand-strong); background: var(--paper); border: 1px solid var(--line); border-radius: .55rem; padding: .45rem .65rem; font-size: .875rem; font-weight: 750; }
.end-session:hover { background: #e3efe8; }
.tab-note { color: var(--muted); margin-top: .85rem; font-size: .875rem; }
.quick-check { background: #e4efe9; color: var(--brand-strong); border-radius: .4rem; padding: .15rem .5rem; font-weight: 750; }
.result-summary { margin: 1rem 0; padding: .7rem .85rem; background: #ecf4ef; border-radius: .55rem; }
.result-summary ul { margin: .4rem 0 .25rem; padding-inline-start: 1.25rem; }
.explorer { margin-top: 1.1rem; border-top: 1px solid var(--line); padding-top: .85rem; }
.explorer-controls { display: flex; flex-wrap: wrap; gap: .45rem; margin: .6rem 0; }
.explorer-controls button { min-width: 2.75rem; min-height: 2.5rem; border: 1px solid #9cb6ad; border-radius: .48rem; background: var(--paper); color: var(--brand-strong); font-weight: 750; }
.explorer-controls button[aria-pressed="true"] { background: var(--brand); color: white; border-color: var(--brand); }
.explorer-picker { display: grid; grid-template-columns: 1fr auto; gap: .35rem .65rem; margin-top: .65rem; font-weight: 700; }
.explorer-picker input[type="range"] { width: 100%; grid-column: 1 / -1; accent-color: var(--brand); }
.explorer-result { font-weight: 700; }
.explorer-note { color: var(--muted); font-size: .875rem; }
@media (max-width: 620px) {
  .header-inner { flex-wrap: wrap; align-content: center; padding-block: .5rem; gap: .4rem .65rem; }
  .site-header nav { flex-wrap: wrap; }
}
.explorer-picker output { grid-column: 2; grid-row: 1; }
.explorer h4 { margin: 0 0 .35rem; }
