/* Karty 5.–9. ročník (PLAN-01 §2.4): a Czech school notebook. The year map is squared paper, everything
 * clickable is fountain-pen blue, each card sheet has a red margin rule, matches get a highlighter.
 * The one bold moment is the map lighting up the cards that share the code under the pointer.
 * Offline only: every url() stays below this folder (D9). */

/* Fonts: @fontsource-variable 5.3.0, OFL-1.1 (css/fonts/OFL-*.txt); latin + latin-ext cover Czech. */
@font-face {
  font-family: 'Literata';
  font-style: normal;
  font-display: swap;
  font-weight: 200 900;
  src: url(fonts/literata-latin-ext-wght-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Literata';
  font-style: normal;
  font-display: swap;
  font-weight: 200 900;
  src: url(fonts/literata-latin-wght-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(fonts/atkinson-hyperlegible-next-latin-ext-wght-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url(fonts/atkinson-hyperlegible-next-latin-wght-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---- Tokens (§2.4) ---- */
:root {
  color-scheme: light dark;
  --paper: #FFFFFF;
  --desk: #F2F4F8;
  --grid: #D9E2EF;
  --graphite: #262A31;
  --graphite-2: #5D6572;
  --ink: #2342B8;
  --ink-wash: #E8EDFB;
  --margin: #D8484D;
  --marker: #FFE95A;
  --on-marker: #262A31;
  --on-ink: #FFFFFF;
  --backdrop: rgba(18, 22, 30, 0.45);
  --serif: 'Literata', Georgia, 'Times New Roman', serif;
  --sans: 'Atkinson Hyperlegible Next', 'Segoe UI', system-ui, sans-serif;
  --top-h: 64px;
  --strip-h: 72px;
  --rail-w: 300px;
  --sq: 20px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1A1F29;
    --desk: #12161E;
    --grid: #263043;
    --graphite: #E4E7ED;
    --graphite-2: #A3ABB9;
    --ink: #9DB1FF;
    --ink-wash: #26305A;
    --margin: #E8777B;
    --marker: #F2D64B;
    --on-ink: #12161E;
    --backdrop: rgba(0, 0, 0, 0.6);
  }
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--desk); }
body {
  margin: 0;
  background: var(--desk);
  color: var(--graphite);
  font: 15px/1.5 var(--sans);
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
mark { background: var(--marker); color: var(--on-marker); border-radius: 2px; padding: 0 1px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
[hidden] { display: none !important; }

.boot, .fatal { max-width: 60ch; margin: 15vh auto; padding: 0 16px; font: 17px/1.55 var(--serif); }
.fatal code { font-family: var(--sans); font-weight: 700; }

.skip {
  position: absolute; left: 16px; top: -48px; z-index: 60;
  padding: 8px 12px; border: 0; border-radius: 3px; background: var(--ink); color: var(--on-ink); font-weight: 700;
}
.skip:focus { top: 12px; }

/* ---- Header ---- */
.top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 24px;
  height: var(--top-h); padding: 0 24px 0 28px;
  background: var(--desk);
  border-bottom: 1px solid var(--grid);
}
.brand { margin: 0; font: 700 21px/1 var(--serif); white-space: nowrap; }
.search { position: relative; flex: 1 1 auto; max-width: 460px; }
.search input {
  width: 100%; height: 40px; padding: 0 36px 0 12px;
  border: 1px solid var(--graphite-2); border-radius: 3px;
  background: var(--paper); color: var(--graphite);
  font: 15px/1 var(--sans);
}
.search input::placeholder { color: var(--graphite-2); opacity: 1; }
.search input:focus-visible { outline-offset: 0; border-color: var(--ink); }
.search kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  min-width: 22px; padding: 1px 6px; border: 1px solid var(--grid); border-radius: 3px;
  color: var(--graphite-2); font: 13px/18px var(--sans); text-align: center; pointer-events: none;
}
.search input:focus + kbd, .search input:not(:placeholder-shown) + kbd { display: none; }
.years { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.years-label { color: var(--graphite-2); font-size: 13px; }
.year-buttons { display: flex; gap: 6px; }
.year {
  min-width: 40px; height: 34px; padding: 0 8px;
  border: 1px solid var(--ink); border-radius: 3px;
  background: transparent; color: var(--ink);
  font: 700 15px/1 var(--sans); cursor: pointer;
}
.year:hover { background: var(--ink-wash); }
.year[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.year.is-zero:not([aria-pressed="true"]) { border-color: var(--grid); color: var(--graphite-2); }
.filters-toggle { display: none; }

/* ---- Layout ---- */
.layout { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); align-items: start; }
.main { min-width: 0; padding: 24px 32px 48px; }

/* ---- Rail (D6) ---- */
.rail {
  position: sticky; top: var(--top-h);
  height: calc(100vh - var(--top-h)); overflow-y: auto; overscroll-behavior: contain;
  padding: 8px 16px 48px 28px;
  border-right: 1px solid var(--grid);
  background: var(--desk);
}
.rail-head { display: none; }
.facet + .facet { margin-top: 28px; }
.facet-title { margin: 16px 0 4px; font: 700 17px/1.3 var(--serif); }
.domain { margin: 14px 0 4px; font: 700 13px/1.3 var(--sans); color: var(--graphite-2); }
.rows, .leaves ul { list-style: none; margin: 0; padding: 0; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; align-items: start; }
.komp-row { grid-template-columns: minmax(0, 1fr) auto auto; }
.check {
  display: flex; gap: 10px; align-items: flex-start; min-width: 0;
  padding: 5px 0; border: 0; background: none;
  font: 15px/1.35 var(--sans); color: var(--graphite); text-align: left; cursor: pointer;
}
.check:hover .label, .check:hover .leaf-code { color: var(--ink); }
.box {
  position: relative; flex: none; width: 16px; height: 16px; margin-top: 2px;
  border: 1.5px solid var(--ink); border-radius: 2px; background: var(--paper);
}
.check[aria-checked="true"] .box, .check[aria-checked="mixed"] .box { background: var(--ink); }
.check[aria-checked="true"] .box::after {
  content: ''; position: absolute; left: 4px; top: 0; width: 5px; height: 9px;
  border: solid var(--on-ink); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.check[aria-checked="mixed"] .box::after {
  content: ''; position: absolute; left: 2px; right: 2px; top: 5.5px; height: 2px; background: var(--on-ink);
}
.count { padding-top: 6px; font: 13px/1.3 var(--sans); color: var(--graphite-2); text-align: right; white-space: nowrap; }
.all-mark { margin-right: 6px; color: var(--graphite-2); }
.is-zero > .check { color: var(--graphite-2); }
.is-zero > .check .box { border-color: var(--graphite-2); }
.levels { display: flex; gap: 4px; padding-top: 3px; }
.level {
  width: 26px; height: 24px; padding: 0;
  border: 1px solid var(--ink); border-radius: 2px;
  background: transparent; color: var(--ink); font: 700 13px/1 var(--sans); cursor: pointer;
}
.level:hover { background: var(--ink-wash); }
.level[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.is-zero .level:not([aria-pressed="true"]) { border-color: var(--graphite-2); color: var(--graphite-2); }
.leaves { grid-column: 1 / -1; margin: 0 0 6px 26px; }
.leaves > summary {
  width: fit-content; padding: 1px 0; cursor: pointer;
  font: 13px/1.4 var(--sans); color: var(--ink);
}
.leaves > summary:hover { text-decoration: underline; text-underline-offset: 2px; }
.leaf { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; }
.leaf .check { font-size: 13px; }
.leaf .box { width: 14px; height: 14px; }
.leaf .check[aria-checked="true"] .box::after { left: 3.5px; width: 4.5px; height: 8px; }
.leaf-label { display: flex; flex-direction: column; min-width: 0; }
.leaf-code { font-weight: 700; }
.leaf-text {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  color: var(--graphite-2); font-size: 13px; line-height: 1.35;
}
.leaf .count { padding-top: 5px; }

/* ---- Year map: squared paper (§2.4, D8) ---- */
.map {
  padding: var(--sq) var(--sq) 0 0;
  border: 1px solid var(--grid);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: var(--sq) var(--sq);
  background-position: -1px -1px;
  background-attachment: local;
}
.lane { display: flex; height: calc(var(--sq) * 2); margin-bottom: var(--sq); }
.lane-label {
  flex: none; width: calc(var(--sq) * 2); padding-top: 10px;
  font: 700 15px/1 var(--sans); color: var(--graphite-2); text-align: center;
}
.tiles {
  flex: 1 1 auto; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 4px;
  min-width: 0; margin: 0; padding: 0; list-style: none;
}
.tiles > li { min-width: 0; }
.tile, .mini {
  background-color: color-mix(in srgb, var(--paper) 88%, transparent);
  background-image: linear-gradient(var(--marker), var(--marker));
  background-repeat: no-repeat;
  background-size: 0% 100%;
  transition: background-size 150ms ease-out;
  cursor: pointer;
}
.tile {
  display: flex; align-items: flex-start;
  width: 100%; height: 100%; padding: 3px 8px;
  border: 1px solid var(--graphite-2); border-radius: 2px;
  color: var(--graphite); font: 13px/16px var(--sans); text-align: left; overflow: hidden;
}
.tile-n { margin-right: 2px; font-weight: 700; color: var(--ink); }
.tile-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile:hover { border-color: var(--ink); }
.tile.is-faded { background-color: color-mix(in srgb, var(--paper) 55%, transparent); border-color: var(--grid); color: var(--graphite-2); }
.tile.is-faded .tile-n { color: var(--graphite-2); }
.tile.is-open { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.tile.is-thread, .mini.is-thread { background-size: 100% 100%; color: var(--on-marker); }
/* Lessons on the map (S3): one dot per tagged lesson (hollow when planned), a dog-ear on the latest lesson's cards. */
.tile, .mini { position: relative; }
.dots { position: absolute; right: 5px; bottom: 3px; display: flex; gap: 3px; }
.dots i { display: block; width: 5px; height: 5px; border-radius: 50%; background: var(--ink); }
.dots i.is-planned { background: transparent; box-shadow: inset 0 0 0 1px var(--ink); }
.notch {
  position: absolute; top: 0; right: 0; width: 0; height: 0;
  border-style: solid; border-width: 0 12px 12px 0; border-color: transparent var(--ink) transparent transparent;
}
.mini .notch { border-width: 0 6px 6px 0; }
.is-faded .dots i:not(.is-planned) { background: var(--graphite-2); }
.is-faded .notch { border-right-color: var(--graphite-2); }
.is-thread .dots i:not(.is-planned) { background: var(--on-marker); }
.is-thread .notch { border-right-color: var(--on-marker); }
.tile.is-thread { border-color: var(--on-marker); }
.tile.is-thread .tile-n { color: var(--on-marker); }

/* The condensed strip: sticky under the header once the map has scrolled away (D25). Zero-height anchor: no layout shift. */
.strip-anchor { position: sticky; top: var(--top-h); z-index: 20; height: 0; }
.strip {
  position: absolute; left: -32px; right: -32px; top: 0;
  height: var(--strip-h); padding: 6px 32px 4px 32px;
  border-bottom: 1px solid var(--grid);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 10px 10px;
}
.strip-lane { display: flex; gap: 2px; height: 10px; margin-bottom: 2px; }
.strip-label { flex: none; width: 24px; font: 700 9px/10px var(--sans); color: var(--graphite-2); }
.mini {
  flex: 1 1 0; min-width: 0; height: 10px; padding: 0 3px;
  border: 0; border-radius: 1px; box-shadow: inset 0 0 0 1px var(--graphite-2);
  color: var(--graphite); font: 700 9px/10px var(--sans); text-align: left; overflow: hidden;
}
.mini.is-faded { background-color: transparent; box-shadow: inset 0 0 0 1px var(--grid); color: var(--graphite-2); }
.mini.is-open { box-shadow: inset 0 0 0 2px var(--ink); }

/* ---- View bar ---- */
.viewbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; max-width: 760px; margin: 24px 0 8px; }
.tabs { display: flex; gap: 4px; }
.tab {
  height: 34px; padding: 0 12px; border: 1px solid var(--ink); border-radius: 3px;
  background: transparent; color: var(--ink); font: 700 15px/1 var(--sans); cursor: pointer;
}
.tab span { margin-left: 2px; font-weight: 400; }
.tab:hover { background: var(--ink-wash); }
.tab[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.result { margin: 0 8px 0 0; font: 700 15px/1.4 var(--sans); }
.active { display: flex; flex-wrap: wrap; gap: 6px; }
.filter {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px; border: 1px solid var(--ink); border-radius: 3px;
  background: var(--ink-wash); color: var(--ink); font: 700 13px/1.2 var(--sans); cursor: pointer;
}
.filter:hover { background: var(--paper); }
.filter span { font-weight: 400; }
.clear {
  padding: 4px 2px; border: 0; background: none; color: var(--ink); cursor: pointer;
  font: 13px/1.2 var(--sans); text-decoration: underline; text-underline-offset: 2px;
}

/* ---- Sheets ---- */
.results { max-width: 760px; outline: none; }
.grade-head { margin: 28px 0 10px; font: 700 15px/1.3 var(--sans); }
.grade-head span { margin-left: 6px; font-weight: 400; color: var(--graphite-2); }
.sheet {
  display: grid; grid-template-columns: 56px minmax(0, 1fr);
  margin: 0 0 20px;
  border: 1px solid var(--grid);
  background: var(--paper);
  scroll-margin-top: calc(var(--top-h) + 84px);
}
.margin { padding-top: 22px; border-right: 2px solid var(--margin); text-align: center; }
.num { font: 400 36px/1 var(--serif); color: var(--graphite-2); }
.body { min-width: 0; padding: 20px 28px 24px 24px; }
.meta { margin: 0 0 2px; font: 13px/1.4 var(--sans); color: var(--graphite-2); }
.title { margin: 0 0 8px; font: 700 28px/1.2 var(--serif); text-wrap: balance; }
.part h4 { margin: 20px 0 6px; font: 700 13px/1.3 var(--sans); color: var(--graphite-2); }
.items { margin: 0; padding-left: 1.1em; font: 17px/1.55 var(--serif); max-width: 70ch; }
.items li { padding-left: 0.2em; }
.items li::marker { content: '– '; color: var(--graphite-2); }
.group { margin: 12px 0 2px; font: 700 15px/1.4 var(--serif); }
.codes { margin: 0; padding: 0; list-style: none; }
.code-row { display: grid; grid-template-columns: 208px minmax(0, 1fr); column-gap: 16px; padding: 7px 0; }
.code-row + .code-row { border-top: 1px dashed var(--grid); }
.code-head { display: flex; gap: 8px; align-items: baseline; }
.chip {
  padding: 4px 7px; border: 1px solid transparent; border-radius: 3px;
  background: var(--ink-wash); color: var(--ink);
  font: 700 13px/1.2 var(--sans); white-space: nowrap; cursor: pointer;
}
.chip:hover { border-color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.chip mark { padding: 0; }
.rvp { font: 13px/1 var(--sans); color: var(--ink); text-underline-offset: 2px; }
.code-text { margin: 0; font: 15px/1.5 var(--serif); }
.also { grid-column: 2; margin: 3px 0 0; font: 13px/1.5 var(--sans); color: var(--graphite-2); }
.ref {
  padding: 0 1px; border: 0; background: none; cursor: pointer;
  color: var(--ink); font: 700 13px/1.5 var(--sans);
  text-decoration: underline; text-underline-offset: 2px;
}
.back {
  padding: 4px 2px; border: 0; background: none; cursor: pointer;
  color: var(--ink); font: 700 15px/1.3 var(--sans); text-decoration: underline; text-underline-offset: 3px;
}
.empty { max-width: 60ch; padding: 20px 24px; border: 1px dashed var(--graphite-2); background: var(--paper); }
.empty p { margin: 0 0 12px; font: 17px/1.55 var(--serif); }
.empty ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.empty li span { color: var(--graphite-2); font-size: 13px; }

/* ---- Lessons (S3): the register is a třídní kniha, the date sits in the red-ruled margin ---- */
.note {
  max-width: 760px; margin: 12px 0; padding: 8px 12px;
  border-left: 3px solid var(--ink); background: var(--paper); font: 13px/1.5 var(--sans);
}
.register-empty { margin: 0 0 8px; font: 17px/1.55 var(--serif); color: var(--graphite-2); }
.book { width: 100%; border-collapse: collapse; border: 1px solid var(--grid); background: var(--paper); font: 15px/1.5 var(--serif); }
.book thead th {
  padding: 8px 12px; border-bottom: 1px solid var(--graphite-2);
  font: 700 13px/1.3 var(--sans); color: var(--graphite-2); text-align: left;
}
.book thead th:first-child, .book .l-date { width: 150px; border-right: 2px solid var(--margin); }
.book tbody th, .book td { padding: 10px 12px; border-top: 1px solid var(--grid); text-align: left; vertical-align: top; }
.book tbody tr:first-child > * { border-top: 0; }
.l-date { font: 700 15px/1.4 var(--sans); white-space: nowrap; }
.l-cards { width: 200px; }
.card-ref {
  display: block; padding: 1px 0 3px; border: 0; background: none; cursor: pointer; text-align: left;
  color: var(--ink); font: 13px/1.35 var(--sans); text-decoration: underline; text-underline-offset: 2px;
}
.card-ref .tile-n { text-decoration: none; }
.no-card { color: var(--graphite-2); font: 13px/1.35 var(--sans); }
.l-text p, .taught-text p { margin: 0 0 4px; }
.l-text strong, .taught-text strong { font-weight: 600; }
.planned {
  display: inline-block; margin-left: 6px; padding: 0 5px; border: 1px solid var(--graphite-2); border-radius: 3px;
  color: var(--graphite-2); font: 400 12px/1.5 var(--sans); white-space: nowrap;
}
.lesson.is-target > th { box-shadow: inset 4px 0 0 var(--ink); }
.taught { margin: 0; padding: 0; list-style: none; }
.taught > li { padding: 6px 0; }
.taught > li + li { border-top: 1px dashed var(--grid); }
.lesson-date {
  padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--ink); font: 700 13px/1.4 var(--sans); text-decoration: underline; text-underline-offset: 2px;
}
.taught-text { margin-top: 2px; font: 15px/1.5 var(--serif); }
/* A lesson's own outcomes: below a dashed rule under its text, the sheet's labels, compact chips that fit the line. */
.outcomes { margin: 8px 0 0; padding: 0; border-top: 1px dashed var(--grid); }
.outcomes dt { margin: 8px 0 3px; font: 700 13px/1.3 var(--sans); color: var(--graphite-2); }
.outcomes dd { margin: 0; }
.o-codes { margin: 0; padding: 0; list-style: none; }
.o-codes li { margin: 0 0 3px; }
.o-codes .chip { margin-right: 4px; padding: 1px 5px; }
.outcomes .items { font: 15px/1.5 var(--serif); max-width: none; }

/* ---- Coverage matrix (S4): codes × cards on squared paper; a filled square = the card uses the code ---- */
.matrix-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 760px; margin: 4px 0 10px; }
.matrix-caption { margin: 0; font: 13px/1.4 var(--sans); color: var(--graphite-2); }
.matrix-caption i {
  display: inline-block; width: 12px; height: 12px; margin-right: 6px; vertical-align: -1px;
  border-radius: 2px; background: var(--ink);
}
.matrix {
  border-collapse: separate; border-spacing: 0;
  border: 1px solid var(--grid); background: var(--paper);
  font: 13px/1.2 var(--sans);
}
.matrix col.is-hover { background: var(--ink-wash); }
.matrix thead th { position: sticky; top: calc(var(--top-h) + var(--strip-h)); z-index: 3; background: var(--paper); }
.matrix .m-cards th { top: calc(var(--top-h) + var(--strip-h) + 23px); }
.m-corner { padding: 0 8px 4px; vertical-align: bottom; text-align: left; font: 700 13px/1.2 var(--sans); color: var(--graphite-2); border-bottom: 1px solid var(--graphite-2); }
.m-grades th:not(.m-corner) { height: 23px; padding: 0 4px; text-align: left; font: 700 13px/23px var(--sans); color: var(--graphite-2); }
.m-cards th { padding: 0; border-bottom: 1px solid var(--graphite-2); }
.m-card {
  display: block; width: 22px; height: 24px; padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--ink); font: 700 13px/24px var(--sans); text-align: center;
}
.m-card:hover { text-decoration: underline; text-underline-offset: 2px; }
.m-cards th.is-faded .m-card { color: var(--graphite-2); font-weight: 400; }
.m-section th { padding: 14px 8px 2px; text-align: left; font: 700 15px/1.3 var(--serif); }
.m-domain th { padding: 8px 8px 2px; text-align: left; font: 700 13px/1.3 var(--sans); color: var(--graphite-2); }
.m-row > th { position: sticky; left: 0; z-index: 1; padding: 0; background: var(--paper); text-align: left; }
.m-code {
  display: flex; gap: 8px; align-items: baseline;
  width: 270px; height: 22px; padding: 0 8px; border: 0; background: none; cursor: pointer;
  text-align: left; white-space: nowrap; overflow: hidden;
}
.m-code-id { flex: none; font: 700 12px/22px var(--sans); color: var(--ink); }
.m-code-note { min-width: 0; overflow: hidden; text-overflow: ellipsis; font: 12px/22px var(--sans); color: var(--graphite-2); }
.m-code:hover .m-code-note { color: var(--graphite); }
.m-row.is-empty .m-code-id { color: var(--graphite-2); font-weight: 400; }
.m-row.is-selected > th, .m-row.is-selected .m-code { background: var(--ink-wash); }
.matrix td { position: relative; width: 22px; min-width: 22px; height: 22px; padding: 0; border-left: 1px solid var(--grid); border-top: 1px solid var(--grid); }
.matrix td.is-on::before { content: ''; position: absolute; inset: 2px; border-radius: 2px; background: var(--ink); }
.matrix td.is-on.is-faded::before { background: color-mix(in srgb, var(--ink) 35%, var(--paper)); }
.matrix .m-start { border-left: 1px solid var(--graphite-2); }
.m-row:hover > th, .m-row:hover .m-code, .m-row:hover > td { background-color: var(--ink-wash); }

.footer { max-width: 760px; margin-top: 40px; padding-top: 14px; border-top: 1px solid var(--grid); font: 13px/1.5 var(--sans); color: var(--graphite-2); }

.backdrop { position: fixed; inset: 0; z-index: 40; background: var(--backdrop); }

/* ---- Below 960 px: the rail becomes a drawer, lanes scroll sideways ---- */
@media (max-width: 959px) {
  .top { position: static; flex-wrap: wrap; height: auto; gap: 10px 12px; padding: 12px 16px; }
  .brand { flex: 1 1 auto; font-size: 19px; }
  .filters-toggle {
    display: inline-flex; order: 1; align-items: center; height: 34px; padding: 0 12px;
    border: 1px solid var(--ink); border-radius: 3px; background: var(--ink-wash); color: var(--ink);
    font: 700 15px/1 var(--sans); cursor: pointer;
  }
  .search { order: 2; flex-basis: 100%; max-width: none; }
  .search kbd { display: none; }
  .years { order: 3; margin-left: 0; }
  .layout { display: block; }
  .rail {
    position: fixed; inset: 0 auto 0 0; z-index: 50;
    width: min(88vw, 360px); height: 100%;
    padding: 12px 16px 48px 20px;
    border-right: 1px solid var(--grid);
    transform: translateX(-102%); visibility: hidden;
    transition: transform 200ms ease-out, visibility 0s linear 200ms;
  }
  .rail.is-open { transform: none; visibility: visible; transition: transform 200ms ease-out; }
  .rail-head { display: flex; justify-content: flex-end; }
  .rail-close {
    padding: 6px 10px; border: 1px solid var(--ink); border-radius: 3px;
    background: var(--ink-wash); color: var(--ink); font: 700 15px/1 var(--sans); cursor: pointer;
  }
  .main { padding: 16px 16px 40px; }
  .map { overflow-x: auto; }
  .lane { min-width: calc(var(--sq) * 2 + var(--n) * 136px); }
  .strip-anchor { top: 0; }
  .strip { left: -16px; right: -16px; padding: 6px 16px 4px; }
  .sheet { grid-template-columns: 40px minmax(0, 1fr); scroll-margin-top: 84px; }
  .margin { padding-top: 18px; }
  .num { font-size: 28px; }
  .body { padding: 16px 16px 20px; }
  .title { font-size: 24px; }
  .code-row { grid-template-columns: minmax(0, 1fr); row-gap: 4px; }
  .also { grid-column: 1; }
  .book thead { display: none; }
  .book, .book tbody, .book tr, .book tbody th, .book td { display: block; width: auto; }
  .book tbody tr { border-top: 1px solid var(--grid); }
  .book tbody tr:first-child { border-top: 0; }
  .book tbody th, .book td { border-top: 0; padding: 4px 12px; }
  .book .l-date { width: auto; padding-top: 10px; border-right: 0; border-bottom: 2px solid var(--margin); }
  .book td.l-text { padding-bottom: 12px; }
  .matrix-bar { flex-wrap: wrap; }
  .matrix-wrap { overflow-x: auto; margin-right: -16px; }
  .matrix thead th, .matrix .m-cards th { position: static; }
  .m-code { width: 190px; }
}

@media (prefers-reduced-motion: reduce) {
  .tile, .mini, .rail, .rail.is-open { transition: none; }
}

/* ---- Print: only the sheets, one card per page ---- */
@page { size: A4; margin: 14mm 14mm 16mm; }
@media print {
  :root {
    --paper: #FFFFFF; --desk: #FFFFFF; --grid: #C9D2E0; --graphite: #000000; --graphite-2: #4A515C;
    --ink: #1F3AA0; --ink-wash: #FFFFFF; --margin: #D8484D; --marker: #FFE95A;
  }
  .skip, .top, .rail, .map, .strip-anchor, .viewbar, .footer, .back, .grade-head, .rvp, .backdrop, .empty { display: none !important; }
  html, body { background: #FFFFFF; }
  .layout { display: block; }
  .main { padding: 0; }
  .results { max-width: none; }
  .sheet { break-after: page; border: 0; grid-template-columns: 12mm minmax(0, 1fr); }
  .sheet:last-child { break-after: auto; }
  .margin { padding-top: 2mm; }
  .num { font-size: 22pt; }
  .body { padding: 0 0 0 5mm; }
  .meta { font-size: 8.5pt; }
  .title { font-size: 17pt; margin-bottom: 2mm; }
  .part h4 { margin: 4mm 0 1.5mm; font-size: 8.5pt; }
  .items { font-size: 10.5pt; line-height: 1.4; max-width: none; }
  .group { font-size: 10pt; margin-top: 2mm; }
  .code-row { grid-template-columns: 44mm minmax(0, 1fr); padding: 1.2mm 0; break-inside: avoid; }
  .items li { break-inside: avoid; }
  .chip { font-size: 8.5pt; padding: 0.6mm 1.2mm; }
  .code-text { font-size: 10pt; line-height: 1.35; }
  .also { font-size: 8pt; }
  .ref { font-size: 8pt; }
  .chip { border-color: var(--graphite); background: none; color: var(--graphite); }
  .ref, .lesson-date { color: var(--graphite); text-decoration: none; }
  .taught-text { font-size: 10pt; }
  .outcomes dt { margin: 1.5mm 0 0.5mm; font-size: 8.5pt; }
  .outcomes .items, .o-text { font-size: 10pt; line-height: 1.35; }
  .o-codes li, .outcomes .items li { break-inside: avoid; }
  mark { background: none; color: inherit; }
}
