/* ==========================================================================
   Тренажер з історії України — історичний стиль
   Пергамент, коричневе чорнило, бордо й старе золото. Усе вирівняно по центру.
   ========================================================================== */

:root {
  --parchment:   #f3e9d2;
  --parchment-2: #e9dbbb;
  --paper:       #fbf6ea;
  --ink:         #2b1d12;
  --ink-soft:    #5b4631;
  --burgundy:    #7b1e22;
  --burgundy-2:  #5a1418;
  --gold:        #a8823a;
  --gold-soft:   #d9c38f;
  --right:       #3d6b3a;
  --right-bg:    #e3ecd6;
  --wrong:       #9e2a2b;
  --wrong-bg:    #f3dcd5;
  --radius:      6px;
  --serif-head:  "Cormorant Garamond", "Times New Roman", Georgia, serif;
  --serif-body:  "PT Serif", Georgia, "Times New Roman", serif;
  --shadow:      0 1px 2px rgba(43, 29, 18, .08), 0 8px 24px rgba(43, 29, 18, .10);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--serif-body);
  font-size: 18px;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--parchment);
  background-image:
    radial-gradient(ellipse at top, rgba(255, 250, 235, .7), transparent 60%),
    radial-gradient(ellipse at bottom, rgba(150, 110, 60, .12), transparent 70%);
  background-attachment: fixed;
}

a { color: var(--burgundy); }
a:hover { color: var(--burgundy-2); }

img { max-width: 100%; height: auto; }

/* ---- Орнамент (ромбовий мотив, як у вишивці) ------------------------------ */
.ornament {
  height: 14px;
  background:
    linear-gradient(45deg,  transparent 42%, var(--burgundy) 42% 58%, transparent 58%) 0 0 / 14px 14px,
    linear-gradient(-45deg, transparent 42%, var(--burgundy) 42% 58%, transparent 58%) 0 0 / 14px 14px,
    var(--gold-soft);
  border-top: 2px solid var(--gold);
  border-bottom: 2px solid var(--gold);
}
.ornament--thin { height: 8px; background-size: 8px 8px, 8px 8px, auto; border-width: 1px; }

/* ---- Шапка ---------------------------------------------------------------- */
.site-header__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 32px;
  padding: 14px 16px;
  background: var(--paper);
  border-bottom: 1px solid var(--gold-soft);
}

.site-logo img { display: block; height: 58px; width: auto; }

.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 6px;
}
.site-nav a {
  padding: 6px 10px;
  font-family: var(--serif-head);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.site-nav a:hover { color: var(--burgundy); border-bottom-color: var(--gold-soft); }
.site-nav a.is-active { color: var(--burgundy); border-bottom-color: var(--gold); }

.nav-toggle, .nav-toggle__btn { display: none; }

/* ---- Банер з панорамою Львова -------------------------------------------- */
.banner {
  position: relative;
  padding: 56px 16px 52px;
  text-align: center;
  color: #f6ead0;
  background:
    linear-gradient(rgba(43, 29, 18, .55), rgba(43, 29, 18, .78)),
    url("../img/page-background.jpg") center 40% / cover no-repeat;
  overflow: hidden;
}
.banner::after {               /* теплий сепієвий тон фотографії */
  content: "";
  position: absolute; inset: 0;
  background: rgba(168, 120, 50, .22);
  mix-blend-mode: multiply;
  pointer-events: none;
}
.banner__inner { position: relative; z-index: 1; max-width: 860px; margin: 0 auto; }
.banner__kicker {
  margin: 0 0 6px;
  font-size: 14px;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--gold-soft);
}
.banner__title {
  margin: 0;
  font-family: var(--serif-head);
  font-size: clamp(38px, 6vw, 60px);
  font-weight: 700;
  line-height: 1.1;
  text-shadow: 0 2px 12px rgba(0, 0, 0, .45);
}
.banner__subtitle {
  margin: 10px auto 0;
  max-width: 640px;
  font-style: italic;
  font-size: 19px;
  color: #efe2c4;
}

.banner--big { padding: 90px 16px 84px; background-position: center; background-size: cover; }
.banner--big .banner__subtitle { font-size: 21px; max-width: 700px; }

/* ---- Головна: картки тренажерів ------------------------------------------ */
.trainers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
  gap: 22px;
  text-align: left;
}
.trainer {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--gold-soft);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.trainer:hover, .trainer:focus-visible {
  transform: translateY(-4px);
  border-color: var(--burgundy);
  box-shadow: var(--shadow);
}
.trainer__img { display: block; aspect-ratio: 16 / 10; overflow: hidden; background: var(--parchment-2); border-bottom: 3px solid var(--gold); }
.trainer__img img {
  width: 100%; height: 100%;
  object-fit: cover;
  filter: sepia(.25) saturate(.9);
  transition: transform .4s, filter .4s;
}
.trainer:hover .trainer__img img { transform: scale(1.05); filter: none; }
.trainer__body { display: flex; flex: 1; flex-direction: column; gap: 6px; padding: 14px 18px 16px; }
.trainer__title { font-family: var(--serif-head); font-size: 24px; font-weight: 700; line-height: 1.15; color: var(--burgundy); }
.trainer__text { flex: 1; font-size: 15px; line-height: 1.5; color: var(--ink-soft); }
.trainer__go { margin-top: 6px; font-family: var(--serif-head); font-size: 18px; font-weight: 700; color: var(--gold); }
.trainer:hover .trainer__go { color: var(--burgundy); }

.card--cta { margin-top: 28px; }
.card--cta .lead { margin-bottom: 18px; }

/* ---- Основна частина ------------------------------------------------------ */
.page {
  flex: 1;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 40px 16px 56px;
}

.card {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--gold-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px clamp(18px, 5vw, 56px);
  text-align: center;
}
.card::before {                /* друга, внутрішня рамка — як на старовинних документах */
  content: "";
  position: absolute; inset: 7px;
  border: 1px solid rgba(168, 130, 58, .35);
  border-radius: 3px;
  pointer-events: none;
}

.card__title {
  margin: 0 0 8px;
  font-family: var(--serif-head);
  font-size: 34px;
  font-weight: 700;
  color: var(--burgundy);
}
.card__title::after {
  content: "";
  display: block;
  width: 90px; height: 2px;
  margin: 12px auto 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.lead { margin: 0 auto 28px; max-width: 620px; color: var(--ink-soft); font-style: italic; }

/* ---- Вступ до розділу ---------------------------------------------------- */
.intro {
  max-width: 720px;
  margin: 0 auto 34px;
  text-align: justify;
  hyphens: auto;
}
.intro p { margin: 0 0 12px; text-indent: 1.6em; }
.intro p:first-child { text-indent: 0; }
.intro p:first-child::first-letter {      /* буквиця, як у старовинних книгах */
  float: left;
  margin: 4px 8px 0 0;
  font-family: var(--serif-head);
  font-size: 3.4em;
  line-height: .8;
  font-weight: 700;
  color: var(--burgundy);
}
.intro a { font-style: italic; }

/* ---- Підказка «Як працювати з джерелом» (розгортається) ------------------ */
.howto {
  max-width: 720px;
  margin: 0 auto 24px;
  border: 1px solid var(--gold-soft);
  border-radius: var(--radius);
  background: rgba(217, 195, 143, .15);
  text-align: left;
}
.howto summary {
  padding: 10px 18px;
  font-family: var(--serif-head);
  font-size: 20px;
  font-weight: 700;
  color: var(--burgundy);
  text-align: center;
  cursor: pointer;
  list-style: none;
}
.howto summary::-webkit-details-marker { display: none; }
.howto summary::before { content: "✦ "; color: var(--gold); }
.howto[open] summary { border-bottom: 1px solid var(--gold-soft); }
.howto__body { padding: 14px 22px 16px; }

/* ---- Вибір розділу ------------------------------------------------------- */
.groups { display: grid; gap: 28px; }

.group__title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 0 0 14px;
  font-family: var(--serif-head);
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
}
.group__num {
  display: inline-grid;
  place-items: center;
  min-width: 40px; height: 40px;
  padding: 0 6px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: var(--burgundy);
  color: #f6ead0;
  font-size: 18px;
}

.group__items {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));   /* на вузькому екрані — в один стовпчик */
  gap: 14px;
  max-width: 720px;
  margin: 0 auto;
}

.section-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 20px;
  border: 1px solid var(--gold-soft);
  border-radius: var(--radius);
  background: linear-gradient(var(--paper), var(--parchment));
  color: var(--ink);
  text-decoration: none;
  transition: transform .15s, box-shadow .15s, border-color .15s, background .15s;
}
.section-link:hover, .section-link:focus-visible {
  border-color: var(--burgundy);
  background: var(--burgundy);
  color: #f6ead0;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.section-link__title { font-family: var(--serif-head); font-size: 21px; font-weight: 700; line-height: 1.25; }
.section-link__meta  { font-size: 14px; color: var(--ink-soft); }
.section-link:hover .section-link__meta, .section-link:focus-visible .section-link__meta { color: var(--gold-soft); }

/* ---- Завдання ------------------------------------------------------------ */
.task-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 22px;
  font-size: 15px;
}
.badge {
  padding: 3px 12px;
  border: 1px solid var(--gold);
  border-radius: 999px;
  color: var(--burgundy);
  background: rgba(217, 195, 143, .25);
}
.score { color: var(--ink-soft); }
.timer {
  min-width: 64px;
  padding: 3px 12px;
  border: 1px solid var(--gold);
  border-radius: 999px;
  font-family: var(--serif-head);
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
  background: var(--paper);
  font-variant-numeric: tabular-nums;
}
.timer--low { color: #fff; background: var(--wrong); border-color: var(--wrong); }
.score b { color: var(--right); }
.deck-progress { color: var(--ink-soft); }
.deck-progress b { color: var(--burgundy); }
.deck-round {                         /* перше завдання нового кола колоди */
  margin: -10px auto 20px;
  max-width: 760px;
  padding: 8px 14px;
  border: 1px solid var(--gold);
  border-radius: 8px;
  background: rgba(217, 195, 143, .2);
  color: var(--burgundy);
  text-align: center;
}

.question {
  margin: 0 auto 24px;
  max-width: 760px;
  font-family: var(--serif-head);
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
}
.question i, .question em { color: var(--ink-soft); }
.question img { display: block; margin: 16px auto; }

.source-image { margin: 0 auto 28px; }
.source-image img {
  display: block;
  margin: 0 auto;
  max-height: 520px;
  width: auto;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--gold-soft);
  box-shadow: var(--shadow);
  filter: sepia(.12);
}

.options {
  display: grid;
  gap: 12px;
  max-width: 720px;
  margin: 0 auto;
}
.option {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 12px 18px;
  border: 1px solid var(--gold-soft);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s, opacity .2s;
}
.option:hover:not(:disabled), .option:focus-visible {
  border-color: var(--burgundy);
  background: #fffaf0;
  transform: translateX(3px);
}
.option__letter {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  font-family: var(--serif-head);
  font-size: 21px;
  font-weight: 700;
  color: var(--burgundy);
  background: var(--paper);
}
.option__text { flex: 1; }
.option__text > :first-child { margin-top: 0; }
.option__text > :last-child  { margin-bottom: 0; }

.option__text:empty { display: none; }

/* Варіанти позначені лише на зображенні — рядок кнопок А Б В Г */
.options--letters {
  grid-template-columns: repeat(4, minmax(0, 96px));
  justify-content: center;
  gap: 16px;
}
.options--letters .option {
  justify-content: center;
  padding: 14px 0;
}
.options--letters .option:hover:not(:disabled),
.options--letters .option:focus-visible { transform: translateY(-2px); }
.options--letters .option__letter { width: 46px; height: 46px; font-size: 24px; }

.options.is-answered .option { cursor: default; }
.options.is-answered .option:not(.is-right):not(.is-wrong) { opacity: .5; }
.option.is-right { border-color: var(--right); background: var(--right-bg); opacity: 1; }
.option.is-right .option__letter { background: var(--right); border-color: var(--right); color: #fff; }
.option.is-wrong { border-color: var(--wrong); background: var(--wrong-bg); opacity: 1; }
.option.is-wrong .option__letter { background: var(--wrong); border-color: var(--wrong); color: #fff; }

.verdict {
  min-height: 1.6em;
  margin: 18px 0 0;
  font-family: var(--serif-head);
  font-size: 24px;
  font-weight: 700;
}
.verdict--right { color: var(--right); }
.verdict--wrong { color: var(--wrong); }

.comment {
  max-width: 720px;
  margin: 18px auto 0;
  padding: 18px 22px;
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
  background: rgba(217, 195, 143, .22);
  text-align: left;
}
.comment[hidden] { display: none; }
.comment__title {
  margin: 0 0 6px;
  font-family: var(--serif-head);
  font-size: 21px;
  color: var(--burgundy);
}

.task-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 26px;
}
.task-actions [hidden] { display: none; }

/* ---- Дати ---------------------------------------------------------------- */
.intro--steps ol {
  margin: 0 auto;
  padding-left: 1.4em;
  text-align: left;
  counter-reset: step;
  list-style: none;
}
.intro--steps li {
  position: relative;
  margin: 0 0 10px;
  padding-left: 14px;
}
.intro--steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: -1.4em; top: 1px;
  display: grid; place-items: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--burgundy);
  color: #f6ead0;
  font-family: var(--serif-head);
  font-weight: 700;
  font-size: 16px;
}

.group__items--wide { max-width: 760px; margin-bottom: 18px; }
.final-link { max-width: 420px; margin: 0 auto; }
.section-link--final {
  border: 2px solid var(--gold);
  background: linear-gradient(var(--paper), rgba(217, 195, 143, .45));
}

.date-item {
  position: relative;
  padding: 22px 0 24px;
  border-bottom: 1px dashed var(--gold-soft);
}
.date-item:last-of-type { border-bottom: 0; }
.date-item__num {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px;
  margin-bottom: 8px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  color: var(--burgundy);
  font-family: var(--serif-head);
  font-weight: 700;
  font-size: 19px;
}
.date-hint { margin: 0 0 10px; color: var(--ink-soft); font-style: italic; font-size: 16px; }

.date-fields {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 12px;
}
.field { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.field__label {
  font-size: 13px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.date-fields input,
.date-fields select {
  padding: 9px 12px;
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font-family: var(--serif-head);
  font-size: 22px;
  font-weight: 700;
  text-align: center;
}
.date-fields input { width: 7.5ch; }
.date-fields input.is-wide { width: 10ch; }
.date-fields input::placeholder { font-size: 16px; font-weight: 400; color: #a8957a; }
.date-fields input:focus,
.date-fields select:focus { outline: 2px solid var(--burgundy); outline-offset: 1px; }
.date-fields input:disabled,
.date-fields select:disabled { background: var(--parchment); color: var(--ink-soft); }

.date-item.is-right .date-fields input, .date-item.is-right .date-fields select { border-color: var(--right); background: var(--right-bg); }
.date-item.is-wrong .date-fields input, .date-item.is-wrong .date-fields select { border-color: var(--wrong); background: var(--wrong-bg); }

.date-answer {
  margin: 12px 0 0;
  font-family: var(--serif-head);
  font-size: 21px;
  font-weight: 700;
}
.date-answer[hidden] { display: none; }
.date-item.is-right .date-answer { color: var(--right); }
.date-item.is-wrong .date-answer { color: var(--wrong); }

.date-results { max-width: 560px; margin: 0 auto; text-align: left; }
.date-results li { margin: 6px 0; }
.date-results .is-right { color: var(--right); }
.date-results .is-wrong { color: var(--wrong); }

.timer--wide { min-width: 84px; }
.task-actions button[hidden] { display: none; }

/* ---- Кластери ------------------------------------------------------------ */
.document {                           /* умова — як архівний документ */
  position: relative;
  max-width: 760px;
  margin: 0 auto 26px;
  padding: 26px 30px 22px;
  background:
    linear-gradient(rgba(255, 255, 255, .55), rgba(255, 255, 255, .55)),
    var(--parchment);
  border: 1px solid var(--gold-soft);
  border-radius: 2px;
  box-shadow: 0 2px 10px rgba(43, 29, 18, .12), inset 0 0 40px rgba(150, 110, 60, .12);
  text-align: left;
}
.document::before {
  content: "Умова";
  position: absolute;
  top: -12px; left: 50%;
  transform: translateX(-50%);
  padding: 0 14px;
  background: var(--paper);
  font-family: var(--serif-head);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--gold);
}
.document p { margin: 0 0 10px; }
.document em, .document i { color: var(--ink-soft); }
.document img { display: block; margin: 12px auto; }

.cluster-tasks { max-width: 760px; margin: 0 auto 10px; text-align: left; }
.cluster-tasks table { width: 100% !important; border-collapse: collapse; }
.cluster-tasks td { padding: 0; }
.cluster-tasks div[style] { height: auto !important; overflow: visible !important; }   /* без вузького вікна з прокруткою */
.cluster-tasks p { margin: 0 0 6px; }
.cluster-tasks p strong {
  display: block;
  margin-top: 18px;
  font-family: var(--serif-head);
  font-size: 21px;
  color: var(--burgundy);
}
.cluster-tasks img { display: block; margin: 10px auto; width: auto !important; max-width: 100%; }

/* Матриця відповідей — як у бланку ЗНО/НМТ: рядки 1–3, стовпці А–Г, клітинки-квадрати */
.answer-matrix {
  margin: 4px auto 0;
  border-collapse: collapse;
  background: #fff;
}
.answer-matrix th,
.answer-matrix td {
  width: 52px;
  height: 46px;
  padding: 0;
  border: 1px solid var(--ink-soft);
  text-align: center;
  vertical-align: middle;
}
.answer-matrix thead th {
  height: 38px;
  font-family: var(--serif-head);
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  background: rgba(217, 195, 143, .35);
}
.answer-matrix thead th:first-child { background: transparent; border-top-color: transparent; border-left-color: transparent; }
.answer-matrix tbody th {
  width: 40px;
  font-family: var(--serif-head);
  font-size: 22px;
  font-weight: 700;
  background: rgba(217, 195, 143, .35);
}
.cell { display: grid; place-items: center; width: 100%; height: 100%; cursor: pointer; }
.cell input { position: absolute; opacity: 0; width: 1px; height: 1px; }
/* позначка — радіокнопка (кружечок із крапкою), як у демотестах з біології */
.cell__box {
  position: relative;
  width: 22px; height: 22px;
  border: 2px solid var(--ink-soft);
  border-radius: 50%;
  background: #fff;
  transition: border-color .15s, background .15s;
}
.cell:hover .cell__box { border-color: var(--burgundy); }
.cell input:focus-visible + .cell__box { outline: 2px solid var(--burgundy); outline-offset: 2px; }
.cell input:checked + .cell__box { border-color: var(--burgundy); }
.cell input:checked + .cell__box::after,
.cell__box.is-right::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--burgundy);
}

.is-answered .cell { cursor: default; }
.is-answered .cell:hover .cell__box { border-color: var(--ink-soft); }
.cell__box.is-right { border-color: var(--right) !important; background: var(--right-bg); }
.cell__box.is-right::after { background: var(--right); }
.cell__box.is-wrong { border-color: var(--wrong) !important; background: var(--wrong-bg); }
.cell input:checked + .cell__box.is-wrong::after { background: var(--wrong); }
.answer-matrix td:has(.is-right) { background: var(--right-bg); }
.answer-matrix td:has(.is-wrong) { background: var(--wrong-bg); }
.answer-matrix tr.row-right th { color: var(--right); }
.answer-matrix tr.row-wrong th { color: var(--wrong); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.jump {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 30px;
  padding-top: 18px;
  border-top: 1px dashed var(--gold-soft);
  font-size: 15px;
  color: var(--ink-soft);
}
.jump span { width: 100%; margin-bottom: 4px; font-style: italic; }
.jump a {
  min-width: 32px;
  padding: 3px 6px;
  border: 1px solid var(--gold-soft);
  border-radius: 4px;
  color: var(--ink);
  text-decoration: none;
}
.jump a:hover { border-color: var(--burgundy); color: var(--burgundy); }
.jump a.is-current { background: var(--burgundy); border-color: var(--burgundy); color: #f6ead0; }

/* ---- Абетка: словник, виділені терміни, таблиця «логічних пар» ----------- */
.question font[color], .question u font, .document font[color] {   /* виділені терміни в питаннях */
  color: var(--burgundy) !important;
  font-weight: 700;
}
.question u { text-decoration-color: var(--gold); text-underline-offset: 3px; }

.glossary {
  max-width: 760px;
  margin: 0 auto 28px;
  border: 1px solid var(--gold-soft);
  border-radius: var(--radius);
  background: rgba(217, 195, 143, .12);
}
.card--task .glossary { margin: 30px auto 0; }
.glossary summary {
  padding: 12px 18px;
  font-family: var(--serif-head);
  font-size: 22px;
  font-weight: 700;
  color: var(--burgundy);
  cursor: pointer;
  list-style: none;
}
.glossary summary::-webkit-details-marker { display: none; }
.glossary summary::before { content: "✦ "; color: var(--gold); }
.glossary__hint { margin: 0 0 10px; font-size: 15px; font-style: italic; color: var(--ink-soft); }
.glossary__letters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  padding: 0 16px 16px;
}
.glossary__letters a {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border: 1px solid var(--gold);
  border-radius: 6px;
  background: var(--paper);
  font-family: var(--serif-head);
  font-size: 21px;
  font-weight: 700;
  color: var(--burgundy);
  text-decoration: none;
  transition: background .15s, color .15s, transform .15s;
}
.glossary__letters a:hover { background: var(--burgundy); color: #f6ead0; transform: translateY(-2px); }
.glossary__entry { display: none; margin: 0 16px 16px; padding: 16px 20px; background: #fff;
                   border: 1px solid var(--gold-soft); border-radius: var(--radius); text-align: left; }
.glossary__entry:target { display: block; }
.glossary__title { margin: 0 0 8px; font-family: var(--serif-head); font-size: 22px; color: var(--burgundy); text-align: center; }
.glossary__body p { margin: 0 0 8px; }
.glossary__body strong u, .glossary__body u strong { color: var(--burgundy); text-decoration: none; }

.pairs-table { max-width: 760px; margin: 0 auto 24px; text-align: left; }
.pairs-table table { width: 100% !important; border-collapse: collapse; background: #fff; }
.pairs-table td { padding: 8px 12px; border: 1px solid var(--gold-soft); vertical-align: top; }
.pairs-table td:first-child { width: 36%; background: rgba(217, 195, 143, .15); }
.pairs-table p { margin: 0; }
.pairs-table strong { color: var(--burgundy); }

/* ---- Форми ----------------------------------------------------------------- */
.card--narrow { max-width: 440px; margin: 0 auto; }
.form { display: grid; gap: 14px; max-width: 560px; margin: 0 auto; text-align: left; }
.form__field { display: grid; gap: 5px; }
.form__field > span {
  font-size: 14px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.form__field small { text-transform: none; letter-spacing: 0; font-style: italic; float: right; }
.form input, .form select, .form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 17px;
}
.form textarea { resize: vertical; min-height: 110px; }
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--burgundy); outline-offset: 1px; }
.form .btn { justify-self: center; }
.form-errors {
  max-width: 560px;
  margin: 0 auto 18px;
  padding: 12px 16px 12px 34px;
  border-left: 4px solid var(--wrong);
  background: var(--wrong-bg);
  color: var(--wrong);
  text-align: left;
}
.hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---- Контакти -------------------------------------------------------------- */
.contact-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 24px; align-items: start; }
.contact-list { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 14px; }
.contact-list li { display: grid; gap: 2px; }
.contact-list__label { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.contact-list a { word-break: break-all; }
.contact-org { margin: 0; padding-top: 14px; border-top: 1px dashed var(--gold-soft); font-style: italic; color: var(--ink-soft); }
@media (max-width: 760px) { .contact-grid { grid-template-columns: 1fr; } }

/* ---- Повідомлення (адміністратор) ------------------------------------------ */
.card--wide { text-align: left; }
.admin-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--gold-soft);
}
.text-wrong { color: var(--wrong); }
.msg {
  margin: 0 0 16px;
  padding: 16px 20px;
  border: 1px solid var(--gold-soft);
  border-left: 4px solid var(--gold-soft);
  border-radius: var(--radius);
  background: #fff;
}
.msg--new { border-left-color: var(--burgundy); background: #fffaf2; }
.msg__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; }
.msg__subject { font-family: var(--serif-head); font-size: 22px; font-weight: 700; color: var(--burgundy); }
.msg__meta { font-size: 14px; color: var(--ink-soft); }
.msg__from { margin: 2px 0 10px; font-size: 15px; color: var(--ink-soft); word-break: break-word; }
.msg__text { margin-bottom: 10px; }
.msg__answer { margin: 10px 0; padding: 10px 14px; border-left: 3px solid var(--right); background: var(--right-bg); }
.msg__answer-label { display: block; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--right); }
.msg__reply summary { cursor: pointer; color: var(--burgundy); font-weight: 700; }
.msg__reply .form { max-width: none; margin-top: 10px; }
.msg__note { font-style: italic; color: var(--ink-soft); }
.btn--small { padding: 6px 16px; font-size: 16px; }

/* ---- Статистика ------------------------------------------------------------ */
.stats { max-width: 1100px; margin: 0 auto; }
.page:has(.stats) { max-width: 1160px; }
.muted { color: var(--ink-soft); }
.small { font-size: 14px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 14px;
  margin-bottom: 10px;
}
.filters label { display: grid; gap: 3px; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.filters select, .filters input {
  padding: 7px 10px;
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  text-transform: none;
  letter-spacing: 0;
}
.filters select:disabled { background: var(--parchment); color: var(--ink-soft); }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 22px; }
.chip {
  padding: 3px 12px;
  border: 1px solid var(--gold-soft);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  text-decoration: none;
}
.chip:hover { border-color: var(--burgundy); color: var(--burgundy); }
.chip.is-on { background: var(--burgundy); border-color: var(--burgundy); color: #f6ead0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 12px; margin-bottom: 26px; }
.kpi {
  display: grid;
  gap: 2px;
  padding: 14px 18px;
  border: 1px solid var(--gold-soft);
  border-top: 3px solid var(--gold);
  border-radius: var(--radius);
  background: #fff;
}
.kpi__num { font-family: var(--serif-head); font-size: 36px; font-weight: 700; line-height: 1.1; color: var(--ink); }
.kpi__lbl { font-size: 14px; color: var(--ink-soft); }

.stats__h { margin: 26px 0 8px; font-family: var(--serif-head); font-size: 26px; color: var(--burgundy); }
.stats__h small { font-family: var(--serif-body); font-size: 15px; font-weight: 400; color: var(--ink-soft); }
.chart-box { position: relative; height: 320px; padding: 10px 6px 4px; border: 1px solid var(--gold-soft); border-radius: var(--radius); background: #fffdf8; }
.chart-box--short { height: 220px; }

.donuts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 14px; }
.donut {
  margin: 0;
  padding: 12px 14px 10px;
  border: 1px solid var(--gold-soft);
  border-radius: var(--radius);
  background: #fffdf8;
}
.donut__title { margin-bottom: 4px; font-family: var(--serif-head); font-size: 21px; font-weight: 700; color: var(--burgundy); text-align: center; }
.donut__chart { position: relative; height: 180px; }
.donut__legend { list-style: none; margin: 8px 0 0; padding: 0; font-size: 13px; }
.donut__legend li { display: grid; grid-template-columns: 12px 1fr auto; gap: 6px; align-items: baseline; padding: 2px 0; }
.donut__legend i { width: 10px; height: 10px; border-radius: 2px; transform: translateY(1px); }
.donut__legend b { font-variant-numeric: tabular-nums; color: var(--ink); }
.donuts--single { grid-template-columns: minmax(0, 560px); justify-content: center; }
.donuts--single .donut { display: grid; grid-template-columns: 240px 1fr; grid-template-rows: auto 1fr; column-gap: 18px; align-items: center; }
.donuts--single .donut__title { grid-column: 1 / -1; }
.donuts--single .donut__chart { height: 240px; }
.donuts--single .donut__legend { font-size: 15px; }
@media (max-width: 560px) { .donuts--single .donut { grid-template-columns: 1fr; } }

.stats__cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 26px; }
@media (max-width: 900px) { .stats__cols { grid-template-columns: 1fr; } }

.stable { width: 100%; border-collapse: collapse; background: #fff; font-size: 15px; }
.stable th { padding: 8px 10px; border-bottom: 2px solid var(--gold); text-align: left; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.stable th.num { text-align: right; }
.stable td { padding: 7px 10px; border-bottom: 1px solid var(--parchment-2); vertical-align: top; }
.stable tr.is-on td { background: rgba(217, 195, 143, .22); }
.stable tr.is-error td { background: var(--wrong-bg); color: var(--wrong); }
.stable a { text-decoration: none; }
.stable a:hover { text-decoration: underline; }
.hbar { display: block; height: 6px; margin-top: 5px; border-radius: 3px; background: var(--parchment); overflow: hidden; }
.hbar span { display: block; height: 100%; border-radius: 0 3px 3px 0; }
.stable--tasks .qcell { min-width: 260px; }
.pctcell { white-space: nowrap; font-variant-numeric: tabular-nums; }
.pbar { display: inline-block; width: 70px; height: 6px; margin-right: 8px; vertical-align: middle; border-radius: 3px; background: var(--parchment); overflow: hidden; }
.pbar span { display: block; height: 100%; background: var(--ink-soft); border-radius: 0 3px 3px 0; }
.tag { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 13px; white-space: nowrap; border: 1px solid currentColor; }
.tag--easy  { color: var(--right); }
.tag--mid   { color: var(--ink-soft); }
.tag--hard  { color: #b05a1c; }
.tag--vhard { color: #fff; background: var(--wrong); border-color: var(--wrong); }
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 15px; }
.toolbar .chip { margin-left: 4px; }
.stats .note { padding: 14px 18px; border-left: 4px solid var(--gold); background: rgba(217, 195, 143, .18); }

.heat { display: grid; gap: 2px; font-size: 12px; overflow-x: auto; }
.heat__row { display: grid; grid-template-columns: 28px repeat(24, minmax(10px, 1fr)); gap: 2px; align-items: center; }
.heat__d { color: var(--ink-soft); font-size: 13px; }
.heat__h { color: var(--ink-soft); text-align: left; }
.heat__c { height: 20px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(168, 130, 58, .18); }
.heat__c:hover { outline: 2px solid var(--ink); outline-offset: 0; }
.heat__scale { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; color: var(--ink-soft); }
.heat__scale i { flex: 0 1 160px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #ead7b9, #5a1418); }

.viz-tip {
  position: absolute;
  z-index: 50;
  max-width: 260px;
  padding: 8px 10px;
  border: 1px solid var(--gold);
  border-radius: 6px;
  background: var(--ink);
  color: #f6ead0;
  font-size: 14px;
  line-height: 1.4;
  pointer-events: none;
  box-shadow: var(--shadow);
}
.viz-tip b { font-family: var(--serif-head); font-size: 16px; }

/* ---- Сторінки адміністратора: стандартний шрифт, більший розмір, високий контраст ---- */
body.admin {
  --ink:       #14100b;
  --ink-soft:  #3a2d20;
  --sans:      "Segoe UI", Arial, "Helvetica Neue", sans-serif;
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.55;
  color: var(--ink);
}
body.admin .banner__title,
body.admin .card__title,
body.admin .stats__h,
body.admin .msg__subject,
body.admin .kpi__num,
body.admin .btn,
body.admin .site-nav a,
body.admin .glossary summary { font-family: var(--sans); letter-spacing: 0; }
body.admin .banner { padding: 26px 16px 24px; }
body.admin .banner__title { font-size: 34px; font-weight: 700; }
body.admin .banner__subtitle { font-style: normal; font-size: 18px; }
body.admin .card__title { font-size: 28px; }
body.admin .stats__h { font-size: 24px; font-weight: 700; color: var(--burgundy-2); }
body.admin .stats__h small { font-family: var(--sans); font-size: 16px; color: var(--ink-soft); }
body.admin .lead { font-style: normal; color: var(--ink); }
body.admin .muted, body.admin .small, body.admin .muted.small { color: var(--ink-soft); font-size: 16px; }
body.admin .filters label { font-size: 15px; letter-spacing: .02em; color: var(--ink); font-weight: 600; text-transform: none; }
body.admin .filters select, body.admin .filters input { font-size: 17px; padding: 8px 10px; }
body.admin .chip { font-size: 16px; padding: 5px 14px; }
body.admin .kpi__num { font-size: 34px; }
body.admin .kpi__lbl { font-size: 16px; color: var(--ink-soft); }
body.admin .stable { font-size: 17px; }
body.admin .stable th { font-size: 15px; letter-spacing: .02em; text-transform: none; color: var(--ink); font-weight: 700; }
body.admin .stable td { color: var(--ink); }
body.admin .tag { font-size: 15px; font-weight: 600; }
body.admin .tag--mid { color: var(--ink-soft); }
body.admin .donut__title { font-family: var(--sans); font-size: 20px; }
body.admin .donut__legend { font-size: 15px; }
body.admin .heat { font-size: 14px; }
body.admin .heat__d, body.admin .heat__h { color: var(--ink); }
body.admin .msg__meta, body.admin .msg__from { font-size: 16px; color: var(--ink-soft); }
body.admin .form__field > span { font-size: 16px; text-transform: none; letter-spacing: 0; color: var(--ink); font-weight: 600; }
body.admin .btn { font-size: 17px; font-weight: 600; }
body.admin .btn--small { font-size: 16px; padding: 7px 16px; }
body.admin code { font-size: 16px; }
body.admin .site-footer { font-size: 15px; }

/* ---- Кнопки -------------------------------------------------------------- */
.btn {
  display: inline-block;
  cursor: pointer;
  padding: 10px 26px;
  border: 1px solid var(--burgundy);
  border-radius: var(--radius);
  background: var(--burgundy);
  color: #f6ead0;
  font-family: var(--serif-head);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .02em;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.btn:hover { background: var(--burgundy-2); color: #fff; }
.btn--ghost { background: transparent; color: var(--burgundy); }
.btn--ghost:hover { background: var(--burgundy); color: #f6ead0; }

/* ---- Підвал -------------------------------------------------------------- */
.site-footer { text-align: center; color: var(--ink-soft); font-size: 14px; }
.site-footer p { margin: 0; padding: 18px 16px 22px; background: var(--paper); }

/* ---- Ніщо не виїжджає за екран ------------------------------------------- */
html, body { overflow-x: hidden; }
.page, .card, .card > *, .contact-grid > * { min-width: 0; }
.card { overflow-wrap: anywhere; }
/* вміст із бази (таблиці, картинки з фіксованою шириною) */
.card img { max-width: 100% !important; height: auto !important; }
.card .trainer__img img { height: 100% !important; }   /* фото карток на головній заповнюють рамку */
.card table { max-width: 100%; }
.question, .document, .cluster-tasks, .pairs-table, .source-image,
.comment, .howto__body, .glossary__body, .option__text, .msg__text {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.question table, .document table, .cluster-tasks table, .pairs-table table,
.comment table, .howto__body table, .glossary__body table { width: 100% !important; table-layout: auto; }
.question td, .document td, .cluster-tasks td, .pairs-table td { word-break: break-word; }

/* ---- Телефони ------------------------------------------------------------ */
@media (max-width: 760px) {
  .page { padding-left: 10px; padding-right: 10px; }
  .card { padding-left: 14px; padding-right: 14px; }
  .card::before { inset: 4px; }
  .document { padding: 22px 14px 16px; }
  .intro p:first-child::first-letter { font-size: 2.6em; }
  .group__items, .group__items--wide { max-width: none; }
  .trainers { gap: 16px; }
  .options--letters { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .options--letters .option__letter { width: 40px; height: 40px; font-size: 21px; }
  .option__letter { width: 32px; height: 32px; font-size: 18px; }
  .answer-matrix th, .answer-matrix td { width: 44px; height: 42px; }
  .answer-matrix tbody th { width: 30px; }
  .answer-matrix thead th { font-size: 19px; }
  .date-fields { gap: 8px; }
  .date-fields input, .date-fields select { font-size: 19px; padding: 8px 6px; }
  .date-fields select { max-width: 46vw; }
  .glossary__letters a { width: 36px; height: 36px; font-size: 19px; }
  .glossary__entry { margin: 0 8px 12px; padding: 12px 12px; }
  .pairs-table td { padding: 6px 8px; }
  .pairs-table td:first-child { width: 40%; }
  .task-actions .btn { width: 100%; text-align: center; }
  .jump a { min-width: 30px; }
  .msg { padding: 12px 12px; }
  .banner--big { padding: 54px 14px 50px; }
  .banner--big .banner__subtitle { font-size: 18px; }
}
/* Меню на телефоні: вкладки ховаються під кнопку ☰ у правому верхньому куті */
@media (max-width: 760px) {
  body { font-size: 17px; }
  .site-header__bar {
    position: relative;
    justify-content: flex-start;
    padding-right: 64px;            /* місце для кнопки ☰ */
  }
  .site-logo img { height: 44px; }
  .nav-toggle__btn {
    display: block;
    position: absolute;
    top: 50%; right: 12px;
    transform: translateY(-50%);
    width: 44px; height: 44px;
    border: 1px solid var(--gold);
    border-radius: 6px;
    background: var(--paper);
    cursor: pointer;
  }
  .site-header__bar:has(.nav-toggle:checked) .nav-toggle__btn,
  .nav-open .nav-toggle__btn { top: 32px; transform: none; }
  .nav-toggle__btn span,
  .nav-toggle__btn span::before,
  .nav-toggle__btn span::after {
    position: absolute;
    left: 10px; right: 10px;
    height: 2.5px;
    border-radius: 2px;
    background: var(--burgundy);
    content: "";
    transition: transform .2s, opacity .2s;
  }
  .nav-toggle__btn span { top: 20px; }
  .nav-toggle__btn span::before { top: -7px; left: 0; right: 0; }
  .nav-toggle__btn span::after  { top: 7px;  left: 0; right: 0; }
  /* відкрите меню — риски стають хрестиком */
  .nav-toggle:checked + .nav-toggle__btn span { background: transparent; }
  .nav-toggle:checked + .nav-toggle__btn span::before { transform: translateY(7px) rotate(45deg); }
  .nav-toggle:checked + .nav-toggle__btn span::after  { transform: translateY(-7px) rotate(-45deg); }

  .site-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin-top: 10px;
    border-top: 1px solid var(--gold-soft);
  }
  .site-nav a { padding: 11px 6px; border-bottom: 1px solid rgba(217, 195, 143, .5); text-align: center; }
  .site-nav a.is-active { background: rgba(217, 195, 143, .25); }
  .nav-toggle:checked ~ .site-nav { display: flex; }

  .banner { padding: 36px 16px 32px; }
  .page { padding-top: 24px; }
  .card { padding-top: 30px; padding-bottom: 30px; }
  .option { padding: 10px 12px; gap: 12px; }
}
@media (max-width: 380px) {
  .answer-matrix th, .answer-matrix td { width: 38px; height: 38px; }
  .cell__box { width: 19px; height: 19px; }
  .site-logo img { height: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
