/* Layout: one phone-first reading column like a study notebook; sticky chip nav; schemes in framed panels. */
:root {
  --bg: #f6f5f8;
  --surface: #ffffff;
  --soft: #efedf3;
  --line: #e2dfe8;
  --ink: #1c1a27;
  --muted: #5d596c;
  --art: #d93a50;
  --ven: #3563d4;
  --art-ink: #b4233a;
  --ven-ink: #2a50b0;
  --art-bg: #fbe5e8;
  --ven-bg: #e6edfc;
  --muscle: #f3d3d1;
  --muscle-line: #d9a5a6;
  --bone: #cdb184;
  --valve: #fffaf6;
  --flow: rgba(255, 255, 255, .92);
  --mark: #ffe46b;
  --badge-on: #ffe46b;
  --badge-on-ink: #1c1a27;
  --good: #187a4a;
  --good-bg: #e3f4ea;
  --bad: #b4321f;
  --bad-bg: #fbe7e2;
  --font-display: "Montserrat", "Segoe UI", system-ui, sans-serif;
  --font-body: "Montserrat", "Segoe UI", system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14131b; --surface: #1d1b26; --soft: #262433; --line: #322f40;
    --ink: #ecebf3; --muted: #a8a4b8;
    --art: #e2526a; --ven: #557ff0; --art-ink: #ff8d9d; --ven-ink: #94b0ff;
    --art-bg: #3b1d25; --ven-bg: #1d2848;
    --muscle: #4b2b34; --muscle-line: #7b4754; --bone: #a08a63; --valve: #fbeff0; --flow: rgba(255, 255, 255, .9);
    --mark: rgba(255, 214, 10, .34); --badge-on: #ffe46b; --badge-on-ink: #1c1a27;
    --good: #5fd39b; --good-bg: #173327; --bad: #ff8f77; --bad-bg: #3a201b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14131b; --surface: #1d1b26; --soft: #262433; --line: #322f40;
  --ink: #ecebf3; --muted: #a8a4b8;
  --art: #e2526a; --ven: #557ff0; --art-ink: #ff8d9d; --ven-ink: #94b0ff;
  --art-bg: #3b1d25; --ven-bg: #1d2848;
  --muscle: #4b2b34; --muscle-line: #7b4754; --bone: #a08a63; --valve: #fbeff0; --flow: rgba(255, 255, 255, .9);
  --mark: rgba(255, 214, 10, .34); --badge-on: #ffe46b; --badge-on-ink: #1c1a27;
  --good: #5fd39b; --good-bg: #173327; --bad: #ff8f77; --bad-bg: #3a201b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 1.02rem/1.6 var(--font-body);
  -webkit-text-size-adjust: 100%;
  margin: 0;
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px);
  z-index: 10; background: var(--bg);
}
:focus-visible { outline: 2px solid var(--ven-ink); outline-offset: 2px; }

/* top navigation */
.topnav {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.topnav-inner {
  max-width: 46rem; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.chips {
  position: relative; display: flex; gap: .375rem; overflow-x: auto;
  padding-block: .55rem; scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; font: 500 .85rem/1 var(--font-body); padding: .5rem .8rem;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); text-decoration: none; white-space: nowrap;
}
.chip.is-active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* page */
.page {
  max-width: 46rem; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 1.4rem 4rem;
  display: flex; flex-direction: column; gap: 2.9rem;
}
.crumbs { font-size: .8rem; color: var(--muted); letter-spacing: .02em; margin: 0; }
h1 {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(1.6rem, 6.4vw, 2.5rem); line-height: 1.12; letter-spacing: -.01em;
  text-wrap: balance; margin: .45rem 0 .9rem;
}
.meta { display: flex; flex-wrap: wrap; gap: .4rem; }
.meta span { font-size: .78rem; padding: .32rem .62rem; border-radius: 999px; background: var(--soft); color: var(--muted); }
.meta .sample { background: var(--badge-on); color: var(--badge-on-ink); font-weight: 600; }
.lead { margin-top: 1rem; color: var(--muted); }

section { scroll-margin-top: 4.6rem; display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.eyebrow { font: 600 .72rem/1 var(--font-body); text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin: 0; }
h2 { font-family: var(--font-display); font-weight: 700; font-size: 1.32rem; line-height: 1.2; margin: -.4rem 0 0; text-wrap: balance; }
h3 { font: 600 1.02rem/1.35 var(--font-body); margin: 0; text-wrap: balance; }
p { margin: 0; max-width: 65ch; }
ul { margin: 0; }
mark {
  color: inherit; padding: 0 .1em;
  background: linear-gradient(transparent 50%, var(--mark) 50%, var(--mark) 92%, transparent 92%);
}
.art-t { color: var(--art-ink); font-weight: 600; }
.ven-t { color: var(--ven-ink); font-weight: 600; }
.ref { font-size: .86rem; color: var(--muted); }

/* key facts */
.key { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 1.1rem 1.15rem; }
.key ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .7rem; }
.key li { position: relative; padding-left: 1.15rem; }
.key li::before { content: ""; position: absolute; left: 0; top: .62em; width: .42rem; height: .42rem; border-radius: 50%; background: var(--ink); }

.facts { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .55rem; }
.facts li { padding-left: 1.15rem; position: relative; }
.facts li::before { content: ""; position: absolute; left: .1rem; top: .7em; width: .5rem; height: 2px; background: var(--muted); }

/* figures */
.figure { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: .9rem; display: flex; flex-direction: column; gap: .8rem; min-width: 0; }
.figure svg { width: 100%; height: auto; max-width: 25rem; margin: 0 auto; display: block; }
.fig-top { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; }
.fig-title { font: 600 .9rem/1.3 var(--font-body); margin: 0; }
.figcap { font-size: .84rem; color: var(--muted); }
.seg { display: inline-flex; flex-wrap: wrap; background: var(--soft); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button {
  font: 500 .84rem/1 var(--font-body); border: 0; background: transparent; color: var(--muted);
  padding: .52rem .8rem; border-radius: 999px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

/* heart svg */
.muscle { fill: var(--muscle); stroke: var(--muscle-line); stroke-width: 2; }
.ven-f { fill: var(--ven); }
.art-f { fill: var(--art); }
.tube { fill: none; stroke-linejoin: round; }
.ven-s { stroke: var(--ven); }
.art-s { stroke: var(--art); }
.leaflet { fill: none; stroke: var(--valve); stroke-width: 4; stroke-linecap: round; }
.cusp { fill: none; stroke: var(--valve); stroke-width: 2.6; stroke-linecap: round; }
.chev { fill: none; stroke: var(--flow); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.badge { cursor: pointer; }
.badge circle { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; }
.badge text { font: 700 11.5px var(--font-body); fill: var(--ink); text-anchor: middle; pointer-events: none; }
.badge.is-on circle { fill: var(--badge-on); stroke: var(--badge-on-ink); stroke-width: 2.5; }
.badge.is-on text { fill: var(--badge-on-ink); }
.badge:focus-visible { outline: none; }
.badge:focus-visible circle { stroke: var(--ven-ink); stroke-width: 3; }
.pick { font-size: .92rem; min-height: 1.5em; font-weight: 600; }

.legend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .1rem .75rem; }
.lg-item button {
  width: 100%; display: grid; grid-template-columns: 1.7rem 1fr; gap: .6rem; align-items: start;
  text-align: left; background: transparent; border: 0; border-radius: 10px;
  padding: .45rem .4rem; color: inherit; font: inherit; cursor: pointer;
}
.lg-num {
  width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 1.5px solid var(--ink);
  display: grid; place-items: center; font: 700 .74rem/1 var(--font-body); font-variant-numeric: tabular-nums;
}
.lg-num.ven { border-color: var(--ven); color: var(--ven-ink); }
.lg-num.art { border-color: var(--art); color: var(--art-ink); }
.lg-name { display: block; font-weight: 600; font-size: .92rem; line-height: 1.3; }
.lg-desc { display: block; font-size: .8rem; line-height: 1.35; color: var(--muted); margin-top: .1rem; }
.lg-mask { display: none; font-size: .86rem; color: var(--muted); padding-top: .15rem; }
.lg-item.is-on button { background: var(--soft); }
.lg-item.is-on .lg-num { background: var(--badge-on); color: var(--badge-on-ink); border-color: var(--badge-on-ink); }
.legend.is-quiz .lg-item:not(.revealed) .lg-text { display: none; }
.legend.is-quiz .lg-item:not(.revealed) .lg-mask { display: block; }

/* photos: labels are drawn over the photo itself, so their colours stay fixed in both themes */
.photo { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.photo.narrow { max-width: 30rem; }
.ph-frame { position: relative; }
.ph-frame img { display: block; width: 100%; height: auto; }
.ph-frame svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.ph-lbl text { fill: #1c1a27; font-family: var(--font-body); font-weight: 700; paint-order: stroke; stroke: rgba(255, 255, 255, .95); stroke-linejoin: round; }
.ph-lbl .ph-line-halo { stroke: rgba(255, 255, 255, .9); stroke-width: 4.5px; vector-effect: non-scaling-stroke; }
.ph-lbl .ph-line { stroke: #1c1a27; stroke-width: 1.6px; vector-effect: non-scaling-stroke; }
.ph-lbl circle { fill: #ffe46b; stroke: #1c1a27; stroke-width: 1.6px; vector-effect: non-scaling-stroke; }
.photo figcaption { padding: .75rem .9rem .85rem; font-size: .88rem; line-height: 1.45; display: flex; flex-direction: column; gap: .35rem; }
.photo .credit { font-size: .74rem; color: var(--muted); line-height: 1.4; }

/* chambers */
.chambers { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.chamber { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .75rem; display: flex; flex-direction: column; gap: .35rem; min-width: 0; font-size: .88rem; line-height: 1.4; }
.chamber h3 { font-size: .93rem; }
.chamber .lbl { color: var(--muted); font-size: .76rem; display: block; }
.pill { align-self: flex-start; font: 600 .72rem/1 var(--font-body); padding: .3rem .5rem; border-radius: 999px; }
.pill.ven { background: var(--ven-bg); color: var(--ven-ink); }
.pill.art { background: var(--art-bg); color: var(--art-ink); }
@media (max-width: 22rem) { .chambers { grid-template-columns: 1fr; } }

/* circles svg */
.lane { fill: none; stroke-width: 7; stroke-linejoin: round; stroke-linecap: butt; }
.halo { stroke: var(--surface); stroke-width: 15; }
.lane-lbl { font: 600 11.5px var(--font-body); text-anchor: middle; }
text.art-t { fill: var(--art-ink); }
text.ven-t { fill: var(--ven-ink); }
.circ-name { font: 600 11px var(--font-display); text-anchor: middle; fill: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.box-t { font: 700 14px var(--font-body); fill: #fff; text-anchor: middle; }
.box-s { font: 500 10.5px var(--font-body); fill: #fff; text-anchor: middle; }
.ch-t { font: 700 13px var(--font-body); fill: #fff; text-anchor: middle; }
.g-big, .g-small { transition: opacity .25s ease; }
.circ[data-show="small"] .g-big { opacity: .14; }
.circ[data-show="big"] .g-small { opacity: .14; }
.circ[data-show="small"] .g-small .circ-name,
.circ[data-show="big"] .g-big .circ-name { fill: var(--ink); }
.routes { display: grid; gap: .6rem; }
.route { font-size: .9rem; line-height: 1.5; padding: .7rem .8rem; border-radius: 12px; background: var(--soft); transition: opacity .25s ease; }
.route b { font-family: var(--font-display); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; display: block; margin-bottom: .2rem; }
.circ[data-show="small"] .route.big, .circ[data-show="big"] .route.small { opacity: .45; }

/* cardiac cycle */
.cycle { display: flex; flex-direction: column; gap: .4rem; }
.cy-row { display: grid; grid-template-columns: 5.2rem 1fr; gap: .5rem; align-items: center; }
.cy-lbl { font-size: .8rem; font-weight: 600; }
.cy-track { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; min-width: 0; }
.cy-seg { height: 2.1rem; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: .74rem; font-weight: 600; white-space: nowrap; overflow: hidden; font-variant-numeric: tabular-nums; }
.work { background: var(--ink); color: var(--bg); }
.rest { background: repeating-linear-gradient(135deg, var(--soft) 0 6px, var(--line) 6px 8px); color: var(--muted); }
.cy-brace { grid-column: 5 / span 4; height: .55rem; border: 2px solid var(--muted); border-top: 0; border-radius: 0 0 6px 6px; }
.cy-pause { grid-column: 5 / span 4; text-align: center; font-size: .76rem; font-weight: 600; line-height: 1.2; }
.cy-scale { position: relative; height: 1.1rem; font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.cy-scale span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.cy-scale span:first-child { transform: none; }
.cy-scale span:last-child { transform: translateX(-100%); }
.cy-key { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .8rem; color: var(--muted); }
.cy-key span { display: inline-flex; align-items: center; gap: .4rem; }
.cy-key i { width: 1.1rem; height: .8rem; border-radius: 3px; display: inline-block; }

.numbers { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: .55rem; }
.num { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .8rem; min-width: 0; }
.num strong { display: block; font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.num span { font-size: .8rem; color: var(--muted); line-height: 1.35; display: block; margin-top: .15rem; }

.reg { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.reg > div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .75rem .8rem; min-width: 0; }
.reg h3 { font-size: .88rem; margin-bottom: .4rem; }
.reg ul { padding-left: 1.05rem; font-size: .88rem; line-height: 1.45; display: flex; flex-direction: column; gap: .25rem; }
@media (max-width: 22rem) { .reg { grid-template-columns: 1fr; } }

/* table */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .84rem; line-height: 1.4; }
th, td { padding: .6rem .6rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); hyphens: auto; overflow-wrap: break-word; }
tr:last-child th, tr:last-child td { border-bottom: 0; }
thead th { font-weight: 600; background: var(--soft); }
tbody th { font-weight: 600; color: var(--muted); width: 22%; }

/* traps */
.traps { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .7rem; }
.traps li { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: .85rem .9rem; display: flex; flex-direction: column; gap: .45rem; }
.tag { display: inline-block; font: 700 .68rem/1 var(--font-body); text-transform: uppercase; letter-spacing: .07em; padding: .28rem .45rem; border-radius: 6px; margin-right: .4rem; vertical-align: .12em; }
.tag.no { background: var(--bad-bg); color: var(--bad); }
.tag.yes { background: var(--good-bg); color: var(--good); }
.trap-false { color: var(--muted); }
.trap-true { font-size: .95rem; }

/* flashcards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .5rem; }
.card {
  min-height: 7rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
  color: var(--ink); padding: .8rem; text-align: left; cursor: pointer; font: inherit;
  display: flex; flex-direction: column; justify-content: space-between; gap: .5rem;
}
.card .front { font-family: var(--font-display); font-weight: 600; font-size: .92rem; line-height: 1.25; }
.card .hint { font-size: .74rem; color: var(--muted); }
.card .back { display: none; font-size: .84rem; line-height: 1.4; }
.card[aria-pressed="true"] { background: var(--soft); }
.card[aria-pressed="true"] .front { font-size: .76rem; color: var(--muted); }
.card[aria-pressed="true"] .back { display: block; }
.card[aria-pressed="true"] .hint { display: none; }

/* quiz */
.quiz { display: flex; flex-direction: column; gap: .8rem; }
.q { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 1rem; display: flex; flex-direction: column; gap: .75rem; min-width: 0; }
.q-head { font: 600 .72rem/1 var(--font-body); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0; }
.q-text { font-weight: 500; }
.q-list { margin: 0; padding-left: 1.4rem; font-size: .94rem; display: flex; flex-direction: column; gap: .15rem; }
.opts { display: flex; flex-direction: column; gap: .4rem; }
.opt { display: flex; gap: .6rem; align-items: flex-start; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: .94rem; line-height: 1.4; }
.opt input { margin-top: .22rem; accent-color: var(--ink); flex: none; }
.opt:has(input:checked) { border-color: var(--ink); background: var(--soft); }
.opt .n { font-weight: 700; font-variant-numeric: tabular-nums; }
.q input[type="text"] {
  font: 600 1.05rem var(--font-body); letter-spacing: .06em; padding: .6rem .75rem; width: 10rem; max-width: 100%;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink);
}
.q input[type="text"]:focus { border-color: var(--ink); outline: none; }
.match { display: flex; flex-direction: column; }
.match-key { font-size: .84rem; color: var(--muted); margin-bottom: .3rem; }
.match-row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .4rem 0; border-bottom: 1px dashed var(--line); font-size: .94rem; }
.match-row:last-child { border-bottom: 0; }
.mt { display: flex; gap: .3rem; flex: none; }
.mt label { position: relative; cursor: pointer; }
.mt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.mt span { display: grid; place-items: center; width: 2.4rem; height: 2.1rem; border-radius: 8px; border: 1.5px solid var(--line); font-weight: 700; font-variant-numeric: tabular-nums; }
.mt input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.mt input:focus-visible + span { outline: 2px solid var(--ven-ink); outline-offset: 2px; }
.q-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.btn { font: 600 .9rem/1 var(--font-body); padding: .72rem 1.15rem; border-radius: 999px; border: 0; background: var(--ink); color: var(--bg); cursor: pointer; }
.fb { border-radius: 10px; padding: .7rem .8rem; font-size: .92rem; line-height: 1.5; }
.fb:empty { display: none; }
.fb.ok { background: var(--good-bg); }
.fb.no { background: var(--bad-bg); }
.fb.wait { background: var(--soft); color: var(--muted); }
.fb strong.ok { color: var(--good); }
.fb strong.no { color: var(--bad); }
.fb a { color: inherit; font-weight: 600; }
.score { background: var(--soft); border-radius: 16px; padding: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.score h3 { font-family: var(--font-display); font-weight: 600; font-size: 1rem; }
.score ul { padding-left: 1.1rem; font-size: .9rem; }

.app-note { border-top: 1px solid var(--line); padding-top: 1.2rem; font-size: .86rem; color: var(--muted); display: flex; flex-direction: column; gap: .5rem; }
.app-note ul { padding-left: 1.1rem; display: flex; flex-direction: column; gap: .2rem; }

@media (prefers-reduced-motion: reduce) {
  .g-big, .g-small, .route { transition: none; }
}

/* ===================== приложение ===================== */
a { color: inherit; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; text-decoration: none; }
.btn.secondary { background: var(--soft); color: var(--ink); }
.btn.small { padding: .55rem .9rem; font-size: .84rem; }
.btn[disabled] { opacity: .5; cursor: default; }
.muted { color: var(--muted); }

/* шапка и меню */
.app-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.hdr-inner {
  max-width: 46rem; margin: 0 auto; display: flex; align-items: center; gap: 1rem; justify-content: space-between;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: .7rem;
}
.brand { font-weight: 800; font-size: 1rem; text-decoration: none; letter-spacing: -.01em; white-space: nowrap; }
.brand span { color: var(--art-ink); }
.who { display: flex; align-items: center; gap: .6rem; font-size: .84rem; min-width: 0; }
.who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 10rem; }
.linkbtn { background: none; border: 0; padding: .3rem 0; font: inherit; color: var(--muted); text-decoration: underline; cursor: pointer; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 8;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
}
.tab {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: .2rem;
  padding: .5rem .2rem .55rem; text-decoration: none; color: var(--muted); font-size: .7rem; font-weight: 600;
}
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--ink); }
.tab .dot {
  position: absolute; top: .3rem; left: calc(50% + 6px); min-width: 1.1rem; height: 1.1rem; padding: 0 .25rem;
  border-radius: 999px; background: var(--art); color: #fff; font-size: .66rem; line-height: 1.1rem; text-align: center;
}
body { padding-bottom: calc(4.2rem + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 60rem) {
  body { padding-bottom: 0; }
  .tabbar { position: static; display: flex; gap: .2rem; border: 0; padding: 0; background: none; }
  .tab { flex-direction: row; gap: .4rem; font-size: .85rem; padding: .45rem .7rem; border-radius: 999px; }
  .tab svg { width: 18px; height: 18px; }
  .tab[aria-current="page"] { background: var(--soft); }
  .tab .dot { position: static; }
}

/* заголовки страниц */
.page-head { display: flex; flex-direction: column; gap: .35rem; }
.page-head h1 { margin: 0; font-size: clamp(1.45rem, 5.5vw, 2rem); }
.loading { color: var(--muted); }
.error-box { background: var(--bad-bg); color: var(--ink); border-radius: 12px; padding: .8rem .9rem; font-size: .92rem; }

/* вход и регистрация */
.auth { max-width: 26rem; margin: 0 auto; width: 100%; display: flex; flex-direction: column; gap: 1.2rem; }
.auth .brand-big { font-weight: 800; font-size: 1.15rem; }
.auth .brand-big span { color: var(--art-ink); }
.form-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 1.1rem; display: flex; flex-direction: column; gap: .9rem; }
.field { display: flex; flex-direction: column; gap: .35rem; }
.field label { font-weight: 600; font-size: .88rem; }
.field input {
  font: 500 1rem var(--font-body); padding: .7rem .8rem; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink); width: 100%;
}
.field input:focus { border-color: var(--ink); outline: none; }
.field .hint { font-size: .78rem; color: var(--muted); }
.form-error { color: var(--bad); font-size: .88rem; font-weight: 600; min-height: 1.2em; }
.form-card .btn { width: 100%; padding-block: .85rem; }

/* кабинет */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
@media (min-width: 40rem) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: .8rem .85rem; display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.tile strong { font-size: 1.45rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile span { font-size: .78rem; color: var(--muted); line-height: 1.3; }
.callout { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; background: var(--ink); color: var(--bg); border-radius: 16px; padding: 1rem 1.1rem; }
.callout p { margin: 0; font-weight: 600; }
.callout .btn { background: var(--bg); color: var(--ink); }
.callout.calm { background: var(--soft); color: var(--ink); }
.callout.calm .btn { background: var(--ink); color: var(--bg); }

.topic-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 1rem; display: flex; flex-direction: column; gap: .7rem; min-width: 0; }
.topic-card h3 { font-size: 1.02rem; }
.topic-card .actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.bar { height: .5rem; border-radius: 999px; background: var(--soft); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--good); }
.bar.warn i { background: #d58b16; }
.bar.low i { background: var(--bad); }
.bar-meta { display: flex; justify-content: space-between; gap: .5rem; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.kinds { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .7rem; }
.kinds li { display: flex; flex-direction: column; gap: .3rem; }
.kinds .k-name { font-weight: 600; font-size: .9rem; }

/* карта тем */
.section-list { display: flex; flex-direction: column; gap: 1.6rem; }
.section-block { display: flex; flex-direction: column; gap: .6rem; }
.section-block h2 { font-size: 1.05rem; margin: 0; }
.topic-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .45rem; }
.topic-row { display: flex; align-items: center; justify-content: space-between; gap: .8rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .85rem; text-decoration: none; }
.topic-row .t-title { font-weight: 600; font-size: .94rem; }
.topic-row .t-meta { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.topic-row .t-num { display: block; font-size: .72rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .1rem; }
.topic-row.soon { background: transparent; border-style: dashed; color: var(--muted); }
.topic-row.soon .t-title { font-weight: 500; }

/* тренажёр */
.session-top { display: flex; flex-direction: column; gap: .4rem; }
.session-top .bar i { background: var(--ink); transition: width .3s ease; }
.session-actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.session-actions, .fb { scroll-margin-bottom: calc(5rem + env(safe-area-inset-bottom, 0px)); }
.q-img { display: block; width: 100%; max-width: 22rem; height: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.fb .note { display: block; margin-top: .35rem; font-size: .86rem; color: var(--muted); }
.q.locked .opt, .q.locked .mt label { cursor: default; }
.result-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 1.1rem; display: flex; flex-direction: column; gap: .7rem; }
.result-card .big { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.result-card ul { padding-left: 1.1rem; font-size: .9rem; display: flex; flex-direction: column; gap: .3rem; }

/* копилка */
.mistake-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.mistake { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .75rem .85rem; display: flex; flex-direction: column; gap: .35rem; }
.mistake .m-q { font-size: .9rem; line-height: 1.4; }
.mistake .m-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .8rem; font-size: .78rem; color: var(--muted); }
.steps { display: inline-flex; gap: 3px; vertical-align: middle; }
.steps i { width: .9rem; height: .32rem; border-radius: 2px; background: var(--line); }
.steps i.on { background: var(--good); }
.due-tag { font-weight: 700; color: var(--art-ink); }

/* родитель */
.code-box { font: 800 1.6rem/1 var(--font-body); letter-spacing: .12em; padding: .9rem 1rem; border-radius: 12px; background: var(--soft); text-align: center; user-select: all; }
.data-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.data-table th, .data-table td { padding: .55rem .6rem; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
.data-table thead th { background: var(--soft); font-weight: 600; }
.data-table tr:last-child td { border-bottom: 0; }

/* тема внутри приложения */
.topic-body { display: flex; flex-direction: column; gap: 2.9rem; }

/* лестница систематики */
.ladder { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .35rem; }
.ladder li { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .55rem .75rem; display: flex; flex-direction: column; gap: .1rem; font-size: .9rem; line-height: 1.4; }
.ladder li span { color: var(--muted); font-size: .82rem; }
.ladder li:nth-child(2) { margin-left: .5rem; } .ladder li:nth-child(3) { margin-left: 1rem; }
.ladder li:nth-child(4) { margin-left: 1.5rem; } .ladder li:nth-child(5) { margin-left: 2rem; }
.ladder li:nth-child(6) { margin-left: 2.5rem; } .ladder li:nth-child(7) { margin-left: 3rem; }
.ladder li:nth-child(8) { margin-left: 3.5rem; } .ladder li:nth-child(9) { margin-left: 4rem; }
.ladder li.is-species { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.ladder li.is-species span { color: var(--bg); opacity: .8; }

/* лента времени */
.timeline { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0; }
.timeline li { position: relative; padding: 0 0 1.1rem 1.4rem; border-left: 2px solid var(--line); margin-left: .45rem; display: flex; flex-direction: column; gap: .2rem; }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: -.5rem; top: .15rem; width: .85rem; height: .85rem; border-radius: 50%; background: var(--surface); border: 2px solid var(--ink); }
.timeline li:last-child::before { background: var(--ink); }
.timeline .tl-when { font-size: .76rem; color: var(--muted); font-weight: 600; }
.timeline p { font-size: .94rem; }

/* объём мозга */
.brain { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .45rem; }
.brain li { display: grid; grid-template-columns: 7.2rem 1fr 3.4rem; gap: .5rem; align-items: center; font-size: .82rem; }
.brain li i { display: block; height: .75rem; border-radius: 999px; background: var(--ink); }
.brain li b { font-variant-numeric: tabular-nums; text-align: right; }

/* сортировка: рудимент или атавизм */
.sort-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .45rem; }
.sort-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 10px; font-size: .92rem; }
.sort-list .sort-btns { display: flex; gap: .3rem; }
.sort-list button { font: 600 .8rem/1 var(--font-body); padding: .5rem .7rem; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.sort-list li.ok { background: var(--good-bg); border-color: transparent; }
.sort-list li.no { background: var(--bad-bg); border-color: transparent; }
.sort-list li.ok button, .sort-list li.no button { cursor: default; }
.sort-list .sort-why { flex-basis: 100%; font-size: .82rem; color: var(--muted); }

/* схема позвоночника */
.sp-bone { fill: none; stroke: var(--bone); stroke-width: 13; stroke-dasharray: 9 3; }
.sp-head { font: 700 17px var(--font-body); fill: var(--ink); text-anchor: middle; }
.sp-lbl text { font: 600 15px var(--font-body); fill: var(--ink); }
.sp-lbl .sp-sub { font: 500 13px var(--font-body); fill: var(--muted); }
.sp-lbl line { stroke: var(--muted); stroke-width: 1.2; }
.sp-front line { stroke: var(--ink); stroke-width: 1.6; }
.sp-front path { fill: var(--ink); }
.sp-front text { font: 600 13px var(--font-body); fill: var(--ink); }

/* фото: ленты, которые листаются вбок, и карточки учёных */
.photo > img { display: block; width: 100%; height: auto; background: var(--soft); }
.gallery { display: grid; grid-auto-flow: column; grid-auto-columns: min(80%, 17.5rem); gap: .7rem; align-items: start; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; padding-bottom: .5rem; }
.gallery.wide { grid-auto-columns: min(88%, 24rem); }
.gallery > .photo { scroll-snap-align: start; }
.gallery .photo figcaption { font-size: .84rem; }
.g-hint { font-size: .78rem; color: var(--muted); margin-top: -.55rem; }
.timeline .gallery { margin-top: .45rem; }
.who { margin: 0; display: grid; grid-template-columns: 5.8rem 1fr; gap: .85rem; align-items: start; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: .75rem; }
.who img { display: block; width: 100%; height: auto; border-radius: 10px; background: var(--soft); }
.who figcaption { font-size: .88rem; line-height: 1.45; display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.who .credit, .person .credit { font-size: .7rem; color: var(--muted); line-height: 1.35; }
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .6rem; }
.person { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.person img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover; background: var(--soft); }
.person figcaption { padding: .6rem .7rem .75rem; display: flex; flex-direction: column; gap: .2rem; font-size: .82rem; line-height: 1.4; }
.person figcaption b { font-size: .92rem; line-height: 1.25; }
.person .yrs { font-size: .74rem; color: var(--muted); font-weight: 600; }

/* схемы расовых признаков */
.rs-skin { stroke: var(--ink); stroke-width: 1.4; }
.rs-light { fill: #f3d9c4; } .rs-dark { fill: #8a5a3c; }
.rs-mel { fill: #3b2417; }
.rs-ray { stroke: #e0a100; stroke-width: 3; fill: none; stroke-linecap: round; }
.rs-ray-head { fill: #e0a100; }
.rs-eye { fill: var(--surface); stroke: var(--ink); stroke-width: 2.2; stroke-linejoin: round; }
.rs-iris { fill: var(--muted); } .rs-pupil { fill: var(--ink); }
.rs-fold { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; }
.rs-car { fill: #e79a9a; }
.rs-t { font: 700 16px var(--font-body); fill: var(--ink); }
.rs-s { font: 600 14px var(--font-body); fill: var(--muted); }
.rs-cover { fill: var(--surface); }
.rs-lead { stroke: var(--muted); stroke-width: 1.2; }

/* схема в ленте фото: слепая кишка и аппендикс */
.ph-scheme { padding: .7rem .6rem .2rem; }
.ph-scheme svg { display: block; width: 100%; height: auto; }
.ap-wall { fill: #f6cdb4; stroke: var(--ink); stroke-width: 2.4; }
.ap-fold { fill: none; stroke: #c98d6c; stroke-width: 2; }
.ap-tube-out, .ap-app-out { fill: none; stroke: var(--ink); }
.ap-tip-out { fill: var(--ink); } .ap-tip-in { fill: #f6cdb4; }
.ap-tube-in, .ap-app-in { fill: none; stroke: #f6cdb4; }
.ap-tube-out { stroke-width: 40; } .ap-tube-in { stroke-width: 35; }
.ap-app-out { stroke-width: 15; } .ap-app-in { stroke-width: 10; }
.ap-lead { stroke: var(--muted); stroke-width: 1.4; }
.ap-t { font: 600 17px var(--font-body); fill: var(--ink); }
.ap-key { font-weight: 800; fill: var(--bad, #c0392b); }

/* низшие и высшие растения */
.plant-groups { display: grid; grid-template-columns: 1fr 1.6fr; gap: .55rem; }
.pg { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .75rem; display: flex; flex-direction: column; gap: .4rem; min-width: 0; font-size: .88rem; line-height: 1.4; }
.pg h3 { font-size: .95rem; }
.pg p { margin: 0; }
.pg-list { color: var(--muted); font-size: .84rem; }
.pg-sub { border-top: 1px dashed var(--line); padding-top: .4rem; display: flex; flex-direction: column; gap: .15rem; }
@media (max-width: 26rem) { .plant-groups { grid-template-columns: 1fr; } }
.facts.small li { font-size: .88rem; }

/* схема хламидомонады: цвета клетки одинаковы в обеих темах, подписи — по теме */
.hl-wall { fill: #eef8e6; stroke: #5b8a3c; stroke-width: 3; }
.hl-cup { fill: #4fa83d; }
.hl-pyr { fill: #2f6e24; }
.hl-nuc { fill: #c9d7ef; stroke: #4d5f86; stroke-width: 2; }
.hl-nucleolus { fill: #4d5f86; }
.hl-eye { fill: #e0402f; }
.hl-vac { fill: #bfe8f5; stroke: #3d8eb0; stroke-width: 1.6; }
.hl-flag { fill: none; stroke: #5b8a3c; stroke-width: 2.4; stroke-linecap: round; }
.hl-lbl line { stroke: var(--muted); stroke-width: 1.2; }
.hl-n { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; }
.hl-num { font: 700 12px var(--font-body); fill: var(--ink); text-anchor: middle; }
.hl-t { font: 600 15px var(--font-body); fill: var(--ink); }
.hl-sub { font-weight: 500; font-size: 13px; fill: var(--muted); }
.is-quiz .hl-t { visibility: hidden; }

/* водоросли по глубине */
.dp-ray line { stroke-width: 4; stroke-linecap: round; }
.dp-green { fill: #5fbf4a; stroke: #2f6e24; stroke-width: 1.2; }
.dp-brown { fill: none; stroke: #8a5a2b; stroke-width: 5; stroke-linecap: round; }
.dp-red { fill: none; stroke: #c2334a; stroke-width: 3.4; stroke-linecap: round; }
.dp-axis text { font: 600 12px var(--font-body); fill: var(--muted); }
.dp-lbl text { font: 700 15px var(--font-body); fill: var(--ink); }
.dp-lbl .dp-sub { font-weight: 500; font-size: 13px; fill: var(--muted); }
