/* ============================================================
   Шкіпер — курс на патент стерника моторноводного (Польща)
   Дизайн-система v3: Unbounded + Golos Text, морська палітра,
   світла/темна тема, всі компоненти курсу
   ============================================================ */

:root {
  /* Палітра — світла тема */
  --paper: #eef3f9;
  --paper-grad: linear-gradient(180deg, #e8eff8 0%, #eef3f9 240px);
  --surface: #ffffff;
  --surface-2: #f3f7fc;
  --ink: #122a43;
  --ink-strong: #0a1e33;
  --muted: #5b7089;
  --brand: #0d5aa7;
  --brand-2: #1b83d6;
  --brand-strong: #0a4585;
  --brand-soft: #e3eff9;
  --brand-grad: linear-gradient(135deg, #0a3d74 0%, #0d5aa7 55%, #1173c4 100%);
  --accent: #c07a10;
  --accent-soft: #fcf2e0;
  --ok: #148a4e;
  --ok-soft: #e2f5ea;
  --bad: #c53a3a;
  --bad-soft: #fbe9e9;
  --line: #d8e2ee;
  --line-strong: #c3d2e2;
  --shadow-s: 0 1px 2px rgba(13, 42, 74, .06), 0 2px 8px rgba(13, 42, 74, .05);
  --shadow-m: 0 2px 4px rgba(13, 42, 74, .05), 0 12px 32px rgba(13, 42, 74, .09);
  --shadow-l: 0 4px 8px rgba(13, 42, 74, .06), 0 24px 56px rgba(13, 42, 74, .13);
  --radius: 18px;
  --radius-s: 12px;
  --radius-xs: 8px;
  --font-display: "Unbounded", "Golos Text", "Segoe UI", system-ui, sans-serif;
  --font-body: "Golos Text", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --topbar-bg: rgba(255, 255, 255, .82);
  --hero-ink: #f2f8ff;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0b141f;
    --paper-grad: linear-gradient(180deg, #0d1828 0%, #0b141f 240px);
    --surface: #131f2e;
    --surface-2: #182839;
    --ink: #dfe9f4;
    --ink-strong: #f3f8fd;
    --muted: #8aa0b8;
    --brand: #4fa3e8;
    --brand-2: #6cb6f1;
    --brand-strong: #8ec8f5;
    --brand-soft: #16304a;
    --brand-grad: linear-gradient(135deg, #0d2f52 0%, #12466e 55%, #16558a 100%);
    --accent: #e2a94f;
    --accent-soft: #2d2413;
    --ok: #3fbc7d;
    --ok-soft: #123324;
    --bad: #e06e6e;
    --bad-soft: #371a1d;
    --line: #22344a;
    --line-strong: #2e4560;
    --shadow-s: 0 1px 2px rgba(0, 0, 0, .35), 0 2px 8px rgba(0, 0, 0, .28);
    --shadow-m: 0 2px 4px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .38);
    --shadow-l: 0 4px 8px rgba(0, 0, 0, .32), 0 24px 56px rgba(0, 0, 0, .5);
    --topbar-bg: rgba(15, 24, 37, .84);
    --hero-ink: #eaf3fc;
  }
}

:root[data-theme="dark"] {
  --paper: #0b141f;
  --paper-grad: linear-gradient(180deg, #0d1828 0%, #0b141f 240px);
  --surface: #131f2e;
  --surface-2: #182839;
  --ink: #dfe9f4;
  --ink-strong: #f3f8fd;
  --muted: #8aa0b8;
  --brand: #4fa3e8;
  --brand-2: #6cb6f1;
  --brand-strong: #8ec8f5;
  --brand-soft: #16304a;
  --brand-grad: linear-gradient(135deg, #0d2f52 0%, #12466e 55%, #16558a 100%);
  --accent: #e2a94f;
  --accent-soft: #2d2413;
  --ok: #3fbc7d;
  --ok-soft: #123324;
  --bad: #e06e6e;
  --bad-soft: #371a1d;
  --line: #22344a;
  --line-strong: #2e4560;
  --shadow-s: 0 1px 2px rgba(0, 0, 0, .35), 0 2px 8px rgba(0, 0, 0, .28);
  --shadow-m: 0 2px 4px rgba(0, 0, 0, .3), 0 12px 32px rgba(0, 0, 0, .38);
  --shadow-l: 0 4px 8px rgba(0, 0, 0, .32), 0 24px 56px rgba(0, 0, 0, .5);
  --topbar-bg: rgba(15, 24, 37, .84);
  --hero-ink: #eaf3fc;
}

/* ---------- База ---------- */

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

html { overflow-x: clip; }

body {
  margin: 0;
  overflow-x: clip;
  background: var(--paper);
  background-image: var(--paper-grad);
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--brand); color: #fff; }

img, svg { max-width: 100%; height: auto; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

:focus-visible {
  outline: 2px solid var(--brand-2);
  outline-offset: 2px;
  border-radius: 4px;
}

h1, h2, h3, h4 { line-height: 1.28; color: var(--ink-strong); }
h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.85rem;
  letter-spacing: -.01em;
  margin: .5em 0 .5em;
}
h2 { font-size: 1.42rem; font-weight: 700; margin: 1.9em 0 .6em; letter-spacing: -.01em; }
h3 { font-size: 1.12rem; font-weight: 700; margin: 1.5em 0 .5em; }

p { margin: .85em 0; }
ul, ol { padding-left: 1.45em; }
li { margin: .4em 0; }
li::marker { color: var(--brand); font-weight: 700; }

strong { color: var(--ink-strong); }

hr { border: none; border-top: 1px solid var(--line); margin: 2.2em 0; }

code, kbd {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: .86em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .12em .45em;
}

/* Скролбар */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 8px;
  border: 3px solid var(--paper);
}
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ---------- Таблиці ---------- */

table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  margin: 1.3em 0;
  font-size: .93em;
  line-height: 1.55;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  overflow: hidden;
  box-shadow: var(--shadow-s);
}
th, td { padding: .62em .9em; text-align: left; vertical-align: top; }
th {
  background: var(--brand-soft);
  color: var(--ink-strong);
  font-weight: 700;
  font-size: .82em;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--line);
}
td { border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 55%, var(--surface)); }
tbody tr:hover td { background: var(--brand-soft); }

.table-scroll { overflow-x: auto; margin: 1.3em 0; border-radius: var(--radius-s); }
.table-scroll table { margin: 0; min-width: 560px; }

/* ---------- Верхня панель ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--topbar-bg);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: .55rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  flex-wrap: wrap;
}

.logo {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: var(--ink-strong);
  white-space: nowrap;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: .01em;
}
.logo:hover { text-decoration: none; }
.logo .logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--brand-grad);
  color: #fff;
  font-size: 1.25rem;
  box-shadow: var(--shadow-s);
}
.logo small {
  display: block;
  font-family: var(--font-body);
  font-weight: 500;
  color: var(--muted);
  font-size: .68rem;
  letter-spacing: .02em;
  line-height: 1.2;
  margin-top: .15em;
}

.topnav {
  display: flex;
  gap: .1rem;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.topnav::-webkit-scrollbar { display: none; }
.topnav a {
  padding: .45rem .85rem;
  border-radius: 999px;
  color: var(--ink);
  font-weight: 600;
  font-size: .92rem;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.topnav a:hover { background: var(--surface-2); text-decoration: none; }
.topnav a.active {
  background: var(--brand);
  color: #fff;
}
:root[data-theme="dark"] .topnav a.active { color: #0b141f; }

.topbar-tools { display: flex; gap: .4rem; align-items: center; }

.tool-btn {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: .4rem .75rem;
  font: inherit;
  font-size: .84rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1.2;
  transition: border-color .15s ease, background .15s ease, transform .1s ease;
}
.tool-btn:hover { border-color: var(--brand); transform: translateY(-1px); }
.tool-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }
:root[data-theme="dark"] .tool-btn.active { color: #0b141f; }

/* ---------- Контейнери ---------- */

.wrap { max-width: 1140px; margin: 0 auto; padding: 1.6rem 1.2rem 4.5rem; }
.wrap-narrow { max-width: 880px; }

.breadcrumbs { font-size: .85rem; color: var(--muted); margin: .6rem 0 0; font-weight: 500; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--brand); }

/* ---------- Кнопки ---------- */

.btn {
  display: inline-block;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-strong);
  border-radius: 12px;
  padding: .65rem 1.3rem;
  font: inherit;
  font-weight: 700;
  font-size: .95rem;
  cursor: pointer;
  text-align: center;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease, background .12s ease;
}
.btn:hover {
  background: var(--surface-2);
  border-color: var(--brand);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-s);
}
.btn:active { transform: translateY(0); }
.btn-primary {
  background: var(--brand-grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 35%, transparent);
}
.btn-primary:hover { background: var(--brand-grad); filter: brightness(1.08); color: #fff; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { background: var(--ok); filter: brightness(1.08); color: #fff; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---------- Головна: hero ---------- */

.hero {
  position: relative;
  overflow: hidden;
  background: var(--brand-grad);
  color: var(--hero-ink);
  border-radius: calc(var(--radius) + 6px);
  padding: 2.8rem 2.4rem 3.2rem;
  margin: 1.3rem 0 2rem;
  box-shadow: var(--shadow-l);
}
.hero::before {
  content: "";
  position: absolute;
  right: -60px;
  top: -70px;
  width: 340px;
  height: 340px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cg fill='none' stroke='%23ffffff' stroke-width='1.6'%3E%3Ccircle cx='50' cy='50' r='46'/%3E%3Ccircle cx='50' cy='50' r='34'/%3E%3Cpath d='M50 8v12M50 80v12M8 50h12M80 50h12'/%3E%3Cpath d='M50 22 58 50 50 78 42 50z' fill='%23ffffff'/%3E%3C/g%3E%3C/svg%3E");
  background-size: contain;
  opacity: .1;
  pointer-events: none;
}
.hero::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 28' preserveAspectRatio='none'%3E%3Cpath d='M0 18 Q15 6 30 18 T60 18 T90 18 T120 18 V28 H0 Z' fill='%23ffffff' opacity='.10'/%3E%3Cpath d='M0 22 Q15 12 30 22 T60 22 T90 22 T120 22 V28 H0 Z' fill='%23ffffff' opacity='.14'/%3E%3C/svg%3E");
  background-size: 480px 34px;
  background-repeat: repeat-x;
  pointer-events: none;
}
.hero h1 {
  margin: 0 0 .55em;
  font-size: 2.05rem;
  color: inherit;
  max-width: 21em;
}
.hero p {
  margin: .3em 0;
  font-size: 1.06rem;
  opacity: .94;
  max-width: 44em;
  line-height: 1.65;
}

.chips { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: 1.4rem; position: relative; }
.chip {
  background: rgba(255, 255, 255, .13);
  border: 1px solid rgba(255, 255, 255, .3);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  border-radius: 999px;
  padding: .32rem .95rem;
  font-size: .87rem;
  font-weight: 700;
  letter-spacing: .01em;
}

/* ---------- Секції ---------- */

.section-title {
  display: flex;
  align-items: baseline;
  gap: .8rem;
  margin-top: 2.6em;
  flex-wrap: wrap;
}
.section-title h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3rem;
  position: relative;
  padding-left: .85rem;
}
.section-title h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: .18em;
  bottom: .18em;
  width: 4px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--brand-2), var(--brand));
}
.section-title .sub { color: var(--muted); font-size: .88rem; font-weight: 500; }

/* ---------- Картки ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.1rem;
  margin: 1.3rem 0;
}

.card {
  position: relative;
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem 1.3rem;
  color: var(--ink);
  box-shadow: var(--shadow-s);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: var(--brand-grad);
  opacity: 0;
  transition: opacity .16s ease;
}
.card:hover {
  text-decoration: none;
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
  box-shadow: var(--shadow-m);
}
.card:hover::before { opacity: 1; }

.card .card-num {
  display: inline-block;
  font-size: .74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 999px;
  padding: .18rem .7rem;
  margin-bottom: .65rem;
}
.card h3 { margin: .1em 0 .3em; font-size: 1.07rem; letter-spacing: -.01em; }
.card .card-pl { color: var(--muted); font-size: .83rem; font-style: italic; }
.card .card-desc { color: var(--muted); font-size: .89rem; margin-top: .5rem; line-height: 1.6; }
.card .card-state {
  position: absolute;
  top: 1.05rem;
  right: 1.15rem;
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
}
.card.done { border-color: color-mix(in srgb, var(--ok) 55%, var(--line)); }
.card.done::before { background: var(--ok); opacity: 1; }
.card.done .card-state { color: var(--ok); }

.card-wide { grid-column: 1 / -1; }

/* ---------- Прогрес ---------- */

.progress-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.35rem;
  margin: 1.3rem 0;
  box-shadow: var(--shadow-s);
}
.progress-panel > strong {
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}
.progress-track {
  height: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-top: .6rem;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--brand-2), var(--ok));
  border-radius: 999px;
  transition: width .6s cubic-bezier(.3, .8, .3, 1);
}
.progress-label { font-size: .9rem; color: var(--muted); font-weight: 500; margin: .55em 0 0; }

/* ---------- Урок ---------- */

.lesson-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1rem;
  color: var(--muted);
  font-size: .87rem;
  font-weight: 600;
  margin: -0.1rem 0 1.6rem;
}
.lesson-meta span {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .22rem .8rem;
  box-shadow: var(--shadow-s);
}

.lesson h2 {
  position: relative;
  padding-left: .9rem;
  margin-top: 2.1em;
}
.lesson h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: .2em;
  bottom: .2em;
  width: 4px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--brand-2), var(--brand));
}
.lesson h1 { font-size: 1.7rem; }

/* Польські підзаголовки при режимі PL */
body.pl-inline h2[data-pl]::after,
body.pl-inline h3[data-pl]::after {
  content: " · " attr(data-pl);
  font-family: var(--font-body);
  font-size: .68em;
  font-weight: 500;
  font-style: italic;
  color: var(--muted);
  letter-spacing: 0;
}

/* ---------- Терміни з польським перекладом ---------- */

.term {
  border-bottom: 2px dotted color-mix(in srgb, var(--brand) 55%, transparent);
  cursor: help;
  position: relative;
}
.term:hover { border-bottom-color: var(--brand); }
.term::after {
  content: "🇵🇱 " attr(data-pl);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  background: var(--ink-strong);
  color: var(--paper);
  font-size: .8rem;
  font-weight: 600;
  font-style: normal;
  padding: .35em .8em;
  border-radius: 8px;
  white-space: normal;
  width: max-content;
  max-width: min(80vw, 320px);
  text-align: center;
  box-shadow: var(--shadow-m);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
  z-index: 60; /* вище за липку шапку (z-index 50), щоб підказка не ховалась під нею */
}
.term:hover::after { opacity: 1; transform: translateX(-50%) translateY(-2px); }

body.pl-inline .term::after {
  content: " (" attr(data-pl) ")";
  position: static;
  transform: none;
  background: none;
  color: var(--brand);
  font-style: italic;
  font-weight: 600;
  padding: 0;
  white-space: normal;
  box-shadow: none;
  opacity: 1;
  pointer-events: auto;
}

/* ---------- Ілюстрації ---------- */

figure.illustration {
  margin: 1.8em 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem 1.4rem 1rem;
  text-align: center;
  box-shadow: var(--shadow-s);
}
figure.illustration svg { display: block; margin: 0 auto; max-width: 100%; height: auto; }
figure.illustration figcaption {
  margin-top: .9rem;
  padding-top: .8rem;
  border-top: 1px dashed var(--line);
  font-size: .86rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.55;
}

/* ---------- Виноски (callouts) ---------- */

.callout {
  border-radius: var(--radius-s);
  padding: .95rem 1.2rem;
  margin: 1.4em 0;
  font-size: .94rem;
  line-height: 1.65;
  border: 1px solid color-mix(in srgb, var(--brand) 22%, var(--line));
  border-left: 4px solid var(--brand);
  background: var(--brand-soft);
  box-shadow: var(--shadow-s);
}
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }
.callout-exam {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
  border-left-color: var(--accent);
  background: var(--accent-soft);
}
.callout-warn {
  border-color: color-mix(in srgb, var(--bad) 28%, var(--line));
  border-left-color: var(--bad);
  background: var(--bad-soft);
}
.callout-tip {
  border-color: color-mix(in srgb, var(--ok) 28%, var(--line));
  border-left-color: var(--ok);
  background: var(--ok-soft);
}
.callout .callout-title {
  font-weight: 800;
  display: block;
  margin-bottom: .3em;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.callout .callout-title { color: var(--brand); }
.callout-exam .callout-title { color: var(--accent); }
.callout-warn .callout-title { color: var(--bad); }
.callout-tip .callout-title { color: var(--ok); }

/* ---------- Тест у кінці уроку ---------- */

.quiz {
  margin-top: 3rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem 1.7rem;
  box-shadow: var(--shadow-m);
}
.quiz-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .7rem; }
.quiz-header h2 {
  margin: 0;
  border: none;
  padding: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
}
.quiz-header h2::before { display: none; }
.quiz-langs { display: flex; gap: .35rem; }

.quiz-q { margin: 1.6rem 0; padding-top: 1.4rem; border-top: 1px solid var(--line); }
.quiz-q .q-text { font-weight: 700; margin: 0 0 .8em; color: var(--ink-strong); line-height: 1.55; }
.quiz-q .q-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.9em;
  height: 1.9em;
  margin-right: .5em;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: .82em;
}

.q-options { display: grid; gap: .55rem; counter-reset: opt; }
.q-option {
  position: relative;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  border-radius: var(--radius-s);
  padding: .68rem 1rem .68rem 3rem;
  font: inherit;
  font-size: .94rem;
  line-height: 1.5;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease, transform .12s ease;
  counter-increment: opt;
}
.q-option::before {
  content: counter(opt, upper-alpha);
  position: absolute;
  left: .8rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.65em;
  height: 1.65em;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: .8em;
  font-weight: 800;
}
.q-option:hover:not([disabled]) { border-color: var(--brand); transform: translateX(2px); }
.q-option:hover:not([disabled])::before { border-color: var(--brand); color: var(--brand); }
.q-option[disabled] { cursor: default; }
.q-option.selected { border-color: var(--brand); background: var(--brand-soft); }
.q-option.selected::before { background: var(--brand); border-color: var(--brand); color: #fff; }
.q-option.correct { border-color: var(--ok); background: var(--ok-soft); font-weight: 700; }
.q-option.correct::before { content: "✓"; background: var(--ok); border-color: var(--ok); color: #fff; }
.q-option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.q-option.wrong::before { content: "✕"; background: var(--bad); border-color: var(--bad); color: #fff; }

.q-explain {
  margin-top: .8rem;
  font-size: .89rem;
  color: var(--ink);
  background: var(--ok-soft);
  border: 1px solid color-mix(in srgb, var(--ok) 25%, var(--line));
  border-left: 3px solid var(--ok);
  border-radius: var(--radius-xs);
  padding: .65rem 1rem;
  line-height: 1.6;
}

.quiz-summary {
  margin-top: 1.6rem;
  padding: 1.05rem 1.3rem;
  border-radius: var(--radius-s);
  font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .9rem;
}
.quiz-summary.pass { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); background: var(--ok-soft); }
.quiz-summary.fail { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); background: var(--bad-soft); }

/* ---------- Навігація між уроками ---------- */

.lesson-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.8rem;
  flex-wrap: wrap;
}
.lesson-nav a {
  flex: 1 1 220px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: .9rem 1.1rem;
  color: var(--ink-strong);
  font-weight: 700;
  font-size: .93rem;
  box-shadow: var(--shadow-s);
  transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease;
}
.lesson-nav a:hover {
  text-decoration: none;
  border-color: var(--brand);
  transform: translateY(-2px);
  box-shadow: var(--shadow-m);
}
.lesson-nav a small {
  display: block;
  color: var(--muted);
  font-weight: 600;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .2em;
}
.lesson-nav .nav-next { text-align: right; }

.mark-done-row { margin: 2.2rem 0 0; text-align: center; }

/* ---------- Пробний іспит ---------- */

.exam-status {
  position: sticky;
  top: 62px;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--topbar-bg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: .65rem 1.2rem;
  box-shadow: var(--shadow-m);
  margin: 1rem 0 1.6rem;
  flex-wrap: wrap;
}
.exam-timer {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink-strong);
}
.exam-timer.low { color: var(--bad); animation: timer-pulse 1s ease infinite alternate; }
@keyframes timer-pulse { from { opacity: 1; } to { opacity: .55; } }
.exam-answered { color: var(--muted); font-weight: 700; font-size: .9rem; }

.exam-q {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.4rem;
  margin: 1rem 0;
  box-shadow: var(--shadow-s);
}
.exam-q .q-topic,
.q-topic {
  font-size: .72rem;
  font-weight: 800;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: .3rem;
}
.exam-q.unanswered-flag { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }

.exam-result {
  border-radius: var(--radius);
  padding: 2rem 2rem;
  margin: 1.5rem 0;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-m);
  text-align: center;
}
.exam-result.pass { border-color: color-mix(in srgb, var(--ok) 55%, var(--line)); }
.exam-result.fail { border-color: color-mix(in srgb, var(--bad) 50%, var(--line)); }
.exam-result .big {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  margin: .25em 0;
  letter-spacing: .01em;
}
.exam-result.pass .big { color: var(--ok); }
.exam-result.fail .big { color: var(--bad); }
.exam-result h2 { font-family: var(--font-display); font-weight: 600; }

.attempts { font-size: .9rem; }
.attempts li { color: var(--muted); }

/* ---------- Словник ---------- */

.glossary-search {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: .85rem 1.15rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--ink);
  margin: 1rem 0 .4rem;
  box-shadow: var(--shadow-s);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.glossary-search::placeholder { color: var(--muted); }
.glossary-search:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}

/* ---------- Озвучка польської ---------- */

.speak-btn {
  border: none;
  background: none;
  cursor: pointer;
  font-size: .92em;
  padding: 0 .28em;
  vertical-align: baseline;
  opacity: .55;
  transition: opacity .12s ease, transform .12s ease;
}
.speak-btn:hover { opacity: 1; transform: scale(1.2); }

/* ---------- Тренажер ---------- */

.topic-chips { display: flex; flex-wrap: wrap; gap: .45rem; margin: .8rem 0 1.2rem; }
.chip-toggle {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: .38rem .95rem;
  font: inherit;
  font-size: .87rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease, transform .1s ease;
}
.chip-toggle:hover { border-color: var(--brand); transform: translateY(-1px); }
.chip-toggle.on {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
:root[data-theme="dark"] .chip-toggle.on { color: #0b141f; }
.chip-toggle .chip-n { opacity: .65; font-weight: 600; font-size: .8em; }

.trainer-controls {
  display: flex;
  align-items: center;
  gap: .8rem;
  flex-wrap: wrap;
  margin: 1rem 0 .4rem;
}
.trainer-controls select {
  font: inherit;
  font-weight: 600;
  padding: .55rem .8rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

/* ---------- Флеш-картки ---------- */

.fcard-wrap { max-width: 580px; margin: 1.6rem auto; }
.fcard {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow-m);
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .7rem;
  padding: 2.2rem 1.6rem;
  cursor: pointer;
  text-align: center;
  user-select: none;
  overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.fcard::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: var(--brand-grad);
}
.fcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-l); }
.fcard .fcard-lang {
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.fcard .fcard-term {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink-strong);
}
.fcard .fcard-hint { color: var(--muted); font-size: .9rem; max-width: 34em; }
.fcard.flipped { border-color: var(--brand); }
.fcard.flipped::before { background: linear-gradient(90deg, var(--ok), var(--brand-2)); }
.fcard .fcard-cat {
  font-size: .76rem;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 999px;
  padding: .14rem .7rem;
  font-weight: 700;
}

.fcard-actions {
  display: flex;
  gap: .7rem;
  justify-content: center;
  margin-top: 1.2rem;
  flex-wrap: wrap;
}
.fcard-progress {
  text-align: center;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 600;
  margin-top: .9rem;
}

/* ---------- Шпаргалка ---------- */

.cheat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 1.1rem;
  margin: 1.3rem 0;
  align-items: start;
}
.cheat-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-s);
  padding: 1.15rem 1.3rem;
}
.cheat-block h2, .cheat-block h3 {
  margin-top: .1em;
  border: none;
  padding: 0;
  font-size: 1.05rem;
  font-family: var(--font-display);
  font-weight: 600;
}
.cheat-block h2::before { display: none; }
.cheat-block table { font-size: .86em; box-shadow: none; }

/* ---------- Підвал ---------- */

.footer {
  background: var(--surface);
  border-top: 1px solid var(--line);
  margin-top: 3.5rem;
  padding: 1.8rem 1.2rem 2.6rem;
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.7;
}
.footer-inner { max-width: 1140px; margin: 0 auto; }

/* ---------- Адаптивність ---------- */

@media (max-width: 760px) {
  body { font-size: 16px; }
  h1 { font-size: 1.45rem; }
  .lesson h1 { font-size: 1.35rem; }
  .hero { padding: 1.8rem 1.4rem 2.4rem; }
  .hero h1 { font-size: 1.4rem; }
  .hero p { font-size: .97rem; }
  .topbar-inner { gap: .6rem; }
  .topnav { margin-left: 0; width: 100%; order: 3; }
  .logo small { display: none; }
  .exam-status { top: 0; }
  .wrap { padding: 1rem .95rem 3rem; }
  .quiz { padding: 1.2rem 1rem; }
  .exam-result { padding: 1.4rem 1.1rem; }
  .fcard .fcard-term { font-size: 1.25rem; }
}

/* ---------- Друк ---------- */

@media print {
  .topbar, .quiz, .lesson-nav, .mark-done-row, .footer,
  .fcard-actions, .trainer-controls, .topic-chips { display: none; }
  body { background: #fff; color: #000; font-size: 12px; }
  .hero { box-shadow: none; }
  .cheat-grid { display: block; }
  .cheat-block {
    break-inside: avoid;
    border: 1px solid #bbb;
    box-shadow: none;
    margin-bottom: .8em;
  }
}
