/* Final Chapter — subjects: list, subject page, Онол / Тест / Статистик panels. */

/* ---------- collage strips (phone list) ---------- */
.subject-strips { display: grid; gap: 12px; }
@media (min-width: 640px) { .subject-strips { grid-template-columns: 1fr 1fr; } }
.subject-strip, .subject-banner {
  position: relative; display: block; overflow: hidden; border-radius: 18px;
  aspect-ratio: 5 / 2; color: #fff; text-decoration: none; box-shadow: var(--shadow);
  background: var(--subj);
}
.subject-strip img, .subject-banner img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* faint theme-colour wash over the collage + a dark fade for the label */
.strip-shade {
  position: absolute; inset: 0;
  background:
    linear-gradient(0deg, rgba(0, 0, 0, .62), rgba(0, 0, 0, 0) 62%),
    color-mix(in srgb, var(--c1) 22%, transparent);
}
.subject-strip-name, .banner-name {
  position: absolute; left: 16px; bottom: 34px;
  font-family: var(--font-head); font-weight: var(--head-weight); font-size: 1.45rem; line-height: 1.1;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .45);
}
.strip-sub { position: absolute; left: 16px; top: 12px; font-family: var(--font-hand); font-size: 1.15rem; text-shadow: 0 1px 6px rgba(0, 0, 0, .5); }
.strip-progress { position: absolute; left: 16px; right: 16px; bottom: 13px; display: flex; align-items: center; gap: 10px; font-size: .78rem; font-weight: 600; }
.strip-progress .bar { flex: 1; background: rgba(255, 255, 255, .3); height: 6px; }

/* ---------- subject page ---------- */
.subject-page { display: grid; gap: 14px; }
.back-link { font-weight: 600; text-decoration: none; color: var(--muted); }
.subject-banner { aspect-ratio: 5 / 1.4; }
.banner-name { bottom: 14px; font-size: 1.7rem; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 14px; background: var(--line); position: sticky; top: 64px; z-index: 5; }
.tab { padding: 9px 4px; border-radius: 11px; text-align: center; font-weight: 600; text-decoration: none; color: var(--muted); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.panel { display: grid; gap: 12px; align-content: start; min-width: 0; }
.panel-head { display: flex; align-items: center; gap: 8px; }
.panel-head .h { font-size: 1.2rem; }
.panel-meta { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.sub-h { font-size: 1rem; margin: 6px 0 0; font-family: var(--font-head); }
.panel-actions { margin-top: 4px; }

/* desktop: collage tiles share the full width (4 subjects → 4 equal tiles), panels in 3 columns below */
.subj-nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.subj-tile {
  position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 16px;
  color: #fff; text-decoration: none; background: var(--subj); box-shadow: var(--shadow);
  outline: 3px solid transparent; outline-offset: 2px; transition: transform .15s ease, outline-color .15s ease, filter .15s ease;
}
.subj-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.subj-tile:not([aria-current]) { filter: saturate(.75) brightness(.92); }
.subj-tile:hover { transform: translateY(-2px); filter: none; }
.subj-tile[aria-current="page"] { outline-color: var(--subj); }
.subj-tile-name {
  position: absolute; left: 12px; right: 12px; bottom: 16px;
  font-family: var(--font-head); font-weight: var(--head-weight); font-size: clamp(1rem, 1.5vw, 1.35rem); line-height: 1.1;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .5);
}
.subj-tile-bar { position: absolute; left: 12px; right: 12px; bottom: 8px; height: 4px; border-radius: 9px; background: rgba(255, 255, 255, .3); overflow: hidden; }
.subj-tile-bar i { display: block; height: 100%; background: #fff; border-radius: inherit; }
.subj-cols { container-type: inline-size; display: grid; gap: 14px; align-items: start; }
.subj-cols > .panel { padding: 16px; }
/* 3 columns need ≈ 960px of content; narrower screens get 2 with Статистик full width below */
@media (min-width: 900px) {
  .subj-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .subj-cols [data-panel="stats"] { grid-column: 1 / -1; }
}
@media (min-width: 1240px) {
  .subj-cols { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .subj-cols [data-panel="stats"] { grid-column: auto; }
}
.subj-cols > .panel { min-width: 0; }
.subj-cols .panel-head { flex-wrap: wrap; }
/* narrow columns: tighter test grid and tiles */
.subj-cols .tgrid { border-spacing: 3px; }
.subj-cols .tgrid tbody th { width: 44px; font-size: .78rem; }
.subj-cols .tcell { height: 40px; font-size: .8rem; border-radius: 9px; }
.subj-cols .tiles { grid-template-columns: repeat(2, 1fr); }
.subj-cols .missed-top li { grid-template-columns: 1fr 56px auto; }

/* ---------- theory ---------- */
.status-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: .78rem; color: var(--muted); }
.st { display: inline-flex; align-items: center; gap: 5px; }
.st i, .topic-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--st); border: 1.5px solid var(--st-b, var(--st)); }
.s0 { --st: transparent; --st-b: var(--line-strong); --st-bg: transparent; }
.s1 { --st: #7FA7D9; --st-bg: color-mix(in srgb, #7FA7D9 14%, transparent); }
.s2 { --st: #E2A33B; --st-bg: color-mix(in srgb, #E2A33B 16%, transparent); }
.s3 { --st: #3F9B62; --st-bg: color-mix(in srgb, #3F9B62 15%, transparent); }

.chapters { display: grid; gap: 8px; }
.chapter { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; }
.chapter > summary { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; list-style: none; font-weight: 600; }
.chapter > summary::-webkit-details-marker { display: none; }
.chapter > summary::after { content: '›'; font-size: 1.2rem; color: var(--muted); transition: transform .2s; }
.chapter[open] > summary::after { transform: rotate(90deg); }
.chapter-name { flex: 1; min-width: 0; }
.chapter-count { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .85rem; }
.chapter-bar { width: 44px; height: 5px; }
.topics { list-style: none; margin: 0; padding: 0 8px 8px; display: grid; gap: 4px; }
.topic { display: flex; align-items: center; gap: 4px; border-radius: 10px; background: var(--st-bg); transition: background .2s; }
.topic-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 10px 8px; border: 0; background: none; text-align: left; cursor: pointer; }
.topic-name { flex: 1; min-width: 0; }
.topic.s3 .topic-name { font-weight: 600; }
.topic-status { font-size: .72rem; color: var(--muted); white-space: nowrap; }
.topic-note { width: 36px; height: 36px; border: 0; border-radius: 9px; background: none; cursor: pointer; color: var(--muted); }
.topic-note.has { color: var(--text); }
.inline-input { flex: 1; min-width: 0; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--bg); }
.row-tools { display: flex; gap: 2px; }
.tool { min-width: 30px; height: 30px; padding: 0 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; font-weight: 600; }
.tool[disabled] { opacity: .3; cursor: default; }
.add-row { margin: 0 8px 10px; }
.chapter .topic:has(.inline-input) { padding: 4px; background: none; }

.seg--3 { grid-template-columns: repeat(3, 1fr); }
.seg--4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 480px) { .seg--4 { grid-template-columns: repeat(4, 1fr); } }
.seg--4 button { font-size: .82rem; }
.seg--4 button[aria-checked="true"] { background: var(--st-bg); box-shadow: inset 0 0 0 2px var(--st, var(--c1)); }
.seg--4 button.s0[aria-checked="true"] { box-shadow: inset 0 0 0 2px var(--line-strong); background: var(--surface); }
.seg--mini { grid-template-columns: auto auto; padding: 3px; gap: 2px; border-radius: 11px; }
.seg--mini button { min-height: 30px; padding: 0 12px; border-radius: 8px; font-size: .85rem; }

/* ---------- tests grid ---------- */
.tgrid-wrap { overflow-x: auto; }
.tgrid { width: 100%; border-collapse: separate; border-spacing: 5px; table-layout: fixed; }
.tgrid th { font-size: .82rem; font-weight: 700; color: var(--muted); }
.tgrid thead th { padding-bottom: 2px; }
.tgrid tbody th { width: 64px; text-align: left; font-variant-numeric: tabular-nums; }
.tcell {
  position: relative; width: 100%; height: 46px; border-radius: 11px; cursor: pointer;
  border: 1.5px dashed var(--line-strong); background: transparent;
  font-weight: 700; font-variant-numeric: tabular-nums; font-size: .9rem;
}
.tcell:hover { border-color: var(--c1); }
.tcell[class*="band-"]:not(.band-0) { border-style: solid; border-color: transparent; }
.band-0 { }
.band-1 { background: #F4C7C3; color: #6E1F1A; }
.band-2 { background: #F8D9B0; color: #6B3D0A; }
.band-3 { background: #F3E7A6; color: #5B4A06; }
.band-4 { background: #CFE6BE; color: #24502A; }
.band-5 { background: #8FCB9B; color: #12381C; }
.tcell .redo { position: absolute; top: 2px; right: 5px; font-style: normal; font-size: .8rem; color: #B5651D; }
.tcell .pass { position: absolute; bottom: 1px; left: 0; right: 0; font-style: normal; font-size: .58rem; font-weight: 800; }
.tlegend { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.tlegend span { display: inline-flex; align-items: center; gap: 5px; }
.sw { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.custom-tests { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.custom-tests li { display: grid; grid-template-columns: 1fr auto 92px; gap: 8px; align-items: center; }
.custom-tests li:not(:has(.tool)) { grid-template-columns: 1fr 92px; }
.custom-name { font-weight: 600; font-size: .9rem; }

/* cell sheet */
.score-row { display: grid; grid-template-columns: 1fr auto 1fr 1fr; gap: 8px; align-items: end; }
.score-row:not(:has(.slash)) { grid-template-columns: 1fr 1fr; }
.slash { padding-bottom: 12px; font-size: 1.3rem; color: var(--muted); }
.score-preview { min-height: 1.4em; margin: 0; }
.score-preview .warn { color: #9A2A25; }
.missed { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; background: var(--surface); }
.missed > summary { cursor: pointer; }
.missed[open] > summary { margin-bottom: 8px; }
.input--sm { min-height: 38px; padding: 6px 12px; }
.missed-list { display: grid; gap: 10px; max-height: 40vh; overflow: auto; margin-top: 8px; }
.missed-list .row { gap: 6px; }
.missed-list .chip { font-size: .8rem; }
.missed-list .chip[aria-pressed="true"] { background: #E2A33B; border-color: #E2A33B; color: #2B1B02; }
.missed-ch-name { margin-bottom: 4px; }

/* ---------- stats ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 480px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { display: grid; gap: 2px; padding: 10px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.tile-label { font-size: .75rem; color: var(--muted); font-weight: 600; }
.tile-num { font-family: var(--font-head); font-weight: var(--head-weight); font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.chart { position: relative; margin: 0; padding: 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.chart figcaption { margin-bottom: 6px; }
.chart-box { width: 100%; }
.chart svg { display: block; touch-action: pan-y; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font-body); }
.chart .target { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .target-label { font-weight: 600; }
.chart .line { fill: none; stroke: var(--subj); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt { fill: var(--subj); stroke: var(--surface); stroke-width: 2; }
.chart .pt.on { r: 6.5; }
.chart .cross { stroke: var(--line-strong); stroke-width: 1; }
.chart-tip {
  position: absolute; z-index: 3; pointer-events: none; display: grid; gap: 1px;
  padding: 7px 10px; border-radius: 10px; background: var(--primary); color: var(--on-primary);
  font-size: .78rem; white-space: nowrap; box-shadow: var(--shadow);
}
.chart-tip .muted { color: color-mix(in srgb, var(--on-primary) 70%, transparent); }
.missed-top { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; counter-reset: m; }
.missed-top li { display: grid; grid-template-columns: 1fr 80px auto; gap: 10px; align-items: center; font-size: .88rem; }
.mt-n { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.subj-edit { display: flex; justify-content: flex-end; margin: -8px 0 14px; }
.subject-strips + .subj-edit { margin: 12px 0 0; justify-content: flex-start; }
