/* Цвета — переменными: светлая тема по умолчанию, тёмная — по системе или вручную (data-theme) */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #1c2330;
  --muted: #5d6878;
  --line: #dde2ea;
  --accent: #2563eb;
  --accent-soft: #e3ecfd;
  --know: #15803d;
  --know-soft: #e2f4e8;
  --learn: #b45309;
  --learn-soft: #fbf0df;
  --skip: #6b7280;
  --skip-soft: #eceef1;
  --danger: #b91c1c;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 6px 20px rgba(16, 24, 40, .07);
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1f26;
    --surface: #232831;
    --surface-2: #2b313b;
    --text: #d4d8de;
    --muted: #9aa3af;
    --line: #353c48;
    --accent: #8eaae0;
    --accent-soft: #2b3650;
    --know: #86c09d;
    --know-soft: #253a2e;
    --learn: #d6ac70;
    --learn-soft: #3a3224;
    --skip: #a2a9b4;
    --skip-soft: #2e333c;
    --danger: #e09090;
    --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .22);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1f26;
  --surface: #232831;
  --surface-2: #2b313b;
  --text: #d4d8de;
  --muted: #9aa3af;
  --line: #353c48;
  --accent: #8eaae0;
  --accent-soft: #2b3650;
  --know: #86c09d;
  --know-soft: #253a2e;
  --learn: #d6ac70;
  --learn-soft: #3a3224;
  --skip: #a2a9b4;
  --skip-soft: #2e333c;
  --danger: #e09090;
  --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .22);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  min-height: 100vh; min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- шапка и вкладки ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 760px; width: 100%; margin: 0 auto; padding: 16px 16px 8px;
}
.brand { font-size: 1.15rem; margin: 0; font-weight: 650; }
/* название — кнопка меню тренажёров; выглядит как заголовок, стрелка подсказывает, что оно раскрывается */
.brand-wrap { position: relative; min-width: 0; }
.brand-btn {
  display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; margin-left: -4px;
  border: 0; border-radius: 12px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.brand-btn:hover, .brand-btn[aria-expanded="true"] { background: var(--surface-2); }
.brand-caret {
  flex: none; width: 7px; height: 7px; margin: -4px 0 0 2px;
  border: solid var(--muted); border-width: 0 1.8px 1.8px 0; transform: rotate(45deg);
}
.apps-menu {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: -4px; min-width: 230px; margin: 0; padding: 6px;
  list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.apps-menu[hidden] { display: none; }
.app-item {
  display: flex; justify-content: space-between; gap: 12px; padding: 9px 10px; border-radius: 8px;
  color: var(--text); text-decoration: none; font-size: .95rem; font-weight: 500;
}
a.app-item:hover { background: var(--surface-2); color: var(--accent); }
.app-cur { color: var(--accent); font-weight: 650; }
.app-cur::after { content: "✓"; }
.brand-mark {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px;
  background: var(--accent); color: #fff; font-family: Georgia, serif; font-size: 1.2rem;
}
.top-actions { display: flex; gap: 6px; }
.icon-btn {
  display: inline-grid; place-items: center; min-width: 40px; height: 40px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer;
  font-size: .9rem;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Режим «По шагам / Всё сразу» — над вкладками: он решает, чем они наполняются */
/* подсказка привязана к строке, а не к кнопке «?»: на телефоне кнопка по центру, и подсказка от неё вылезала за край */
.flowbar {
  position: relative; display: flex; align-items: center; gap: 8px;
  max-width: 760px; width: 100%; margin: 0 auto; padding: 4px 16px 6px; box-sizing: border-box;
}
.qtip { display: inline-flex; }
/* От режима зависит логика всего тренажёра — он заметнее прочих переключателей: подложка, подпись,
   крупнее кнопки и залитая выбранная половина */
.flowbar::before {
  content: ""; position: absolute; inset: 2px 12px 2px; z-index: -1;
  background: var(--accent-soft); border-radius: 14px;
}
/* isolation держит подложку под кнопками, но запирает z-index подсказки внутри строки — поэтому сама строка
   поднята над вкладками и фильтрами, иначе подсказка уходила под них */
.flowbar { isolation: isolate; z-index: 25; padding: 8px 20px 10px; margin-bottom: 4px; }
.flow-label { font-weight: 600; font-size: .95rem; color: var(--accent); }
#flow { background: var(--surface); }
#flow button { min-height: 36px; padding: 6px 16px; font-size: .95rem; }
/* текст — цветом поверхности, а не белым: в тёмной теме акцент светлый, и белое на нём не читалось */
#flow button[aria-checked="true"] { background: var(--accent); color: var(--surface); box-shadow: none; }
.qmark {
  width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); font-size: .8rem; font-weight: 600; cursor: help; padding: 0; line-height: 1;
}
.qmark:hover, .qtip.open .qmark { color: var(--accent); border-color: var(--accent); }
.tip {
  display: none; position: absolute; z-index: 30; top: calc(100% + 2px); left: 16px;
  width: min(360px, calc(100% - 32px)); box-sizing: border-box; padding: 10px 12px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); font-size: .86rem; line-height: 1.45;
}
.qtip:hover .tip, .qtip.open .tip, .qmark:focus-visible + .tip { display: block; }
@media (max-width: 520px) {
  .flowbar { justify-content: center; }
  .tip { right: 16px; width: auto; }
}

/* Линия под вкладками — внутренняя тень, а не рамка: рамку подчёркивание активной вкладки перекрывало
   через margin-bottom: -1px, этот пиксель вылезал за полосу, и на телефоне полоса ездила ещё и вверх-вниз */
.tabs {
  display: flex; gap: 4px; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: none;
  max-width: 760px; width: 100%; margin: 0 auto; padding: 4px 16px 0;
  box-shadow: inset 0 -1px 0 var(--line);
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; border: 0; background: none; cursor: pointer; padding: 10px 12px; border-radius: 10px 10px 0 0;
  color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap;
  font-size: .92rem;
}
.tab small { display: block; font-size: .72rem; opacity: .85; }
/* заливка — только у вкладки, которая сейчас открыта */
.tab[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
/* вкладка-источник: из её «Знаю» собираются все остальные занятия — обведена рамкой по контуру вкладки,
   а заливается, как любая другая, только когда открыта: иначе она выглядела бы активной всегда */
.tab-source { box-shadow: inset 0 0 0 1px var(--accent); margin-right: 34px; position: relative; }
/* стрелка к остальным вкладкам: слова идут отсюда туда. В «По шагам» это главная подсказка, как открыть остальное, —
   поэтому крупно и в полный цвет */
.tab-source::after {
  content: "→"; position: absolute; right: -32px; top: 50%; transform: translateY(-50%);
  width: 30px; text-align: center; color: var(--accent); font-size: 1.6rem; font-weight: 700; line-height: 1;
  pointer-events: none;
}
.tab-count { font-variant-numeric: tabular-nums; }
.tab:not([aria-disabled="true"]):hover { color: var(--text); }

main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 16px; }
.panel { display: flex; flex-direction: column; gap: 14px; }

.storage-warning {
  background: var(--learn-soft); color: var(--learn); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px;
  font-size: .9rem;
}

/* ---------- фильтры ---------- */
.controls { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; }
.levels, .dir { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.chip, .dir button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 11px;
  cursor: pointer; font-size: .86rem; min-height: 32px; white-space: nowrap;
}
.seg-n { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip[aria-pressed="true"]::before { content: "✓ "; }

/* выпадающие списки «Уровень» и «Спряжение» */
.filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; position: relative; }
/* список привязан к ряду фильтров, а не к своей кнопке: у правой кнопки он иначе уезжал за край экрана */
.ms { position: static; }
.ms-btn {
  display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 4px 9px 4px 11px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface); cursor: pointer; font-size: .86rem;
}
.ms-btn::after { content: ""; width: 7px; height: 7px; margin: -3px 0 0 4px; border: solid var(--muted); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.ms-btn[aria-expanded="true"] { border-color: var(--accent); }
.ms-label { color: var(--muted); }
.ms-value { font-weight: 600; }
.ms-pop {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; width: min(420px, 100%); box-sizing: border-box;
  padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.ms-pop[hidden] { display: none; }
.ms-item {
  display: grid; grid-template-columns: auto 4.6em 1fr auto; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: 8px; cursor: pointer; font-size: .92rem;
}
.ms-item:hover { background: var(--surface-2); }
.ms-item input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
.ms-item input:disabled { opacity: .55; }
.ms-name { font-weight: 600; }
.ms-hint { color: var(--muted); font-size: .84rem; line-height: 1.3; }
.ms-count { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.ms-all { display: block; margin: 4px 8px 2px; font-size: .88rem; }
.ms-all[hidden] { display: none; }
.dir { background: var(--surface-2); border-radius: 999px; padding: 3px; gap: 2px; }
.dir button { border: 0; background: none; }
.dir button[aria-checked="true"] { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }

.counter { margin: 0; color: var(--muted); font-size: .9rem; text-align: center; }
.counter b { color: var(--text); font-weight: 600; }

/* ---------- карточка ---------- */
.stage { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.card {
  position: relative; width: 100%; min-height: 230px; padding: 32px 20px 40px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  display: grid; place-items: center; text-align: center; cursor: pointer; user-select: none;
  transition: background .18s ease;
}
/* Сжатие при нажатии — только для мыши: на телефоне оно накладывалось на переворот, и карточка дёргалась дважды */
@media (hover: hover) { .card:active { transform: scale(.99); } }
.card.is-back { background: var(--surface); border-color: var(--accent); }
/* Одно движение: новый текст уже на месте, карточка разворачивается к зрителю. Прежнее «завалиться и вернуться»
   показывало новый текст на отворачивающейся карточке */
.card.flip { animation: flip .22s ease-out; }
@keyframes flip { from { transform: perspective(900px) rotateX(75deg); } to { transform: perspective(900px) rotateX(0); } }
@media (prefers-reduced-motion: reduce) { .card.flip { animation: none; } }
.card-word { font-size: clamp(1.7rem, 6vw, 2.5rem); font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; }
.card-word.is-ru { font-size: clamp(1.3rem, 4.6vw, 1.85rem); font-weight: 500; }
.card-alt { margin-top: 10px; color: var(--muted); font-size: .95rem; }
.card-meta { margin-top: 10px; display: flex; gap: 10px; justify-content: center; align-items: center; }
.card-meta .conj { font-size: .8rem; color: var(--muted); }
.card-meta .lvl {
  display: inline-block; font-size: .75rem; font-weight: 600; letter-spacing: .03em; padding: 2px 8px;
  border-radius: 999px; background: var(--surface-2); color: var(--muted);
}
.card-hint { position: absolute; bottom: 12px; left: 0; right: 0; font-size: .78rem; color: var(--muted); }
.speak {
  position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; display: grid; place-items: center;
}
.speak:hover { background: var(--surface-2); }
.speak svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.speak-inline { position: static; display: inline-grid; width: 32px; height: 32px; vertical-align: middle; margin-left: 6px; }

/* ---------- кнопки ответа ---------- */
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; }
.actions.two { grid-template-columns: repeat(2, 1fr); }
.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px 16px;
  cursor: pointer; font-weight: 600; min-height: 48px;
}
.btn:hover { background: var(--surface-2); }
.btn-know { background: var(--know-soft); border-color: transparent; color: var(--know); }
.btn-learn { background: var(--learn-soft); border-color: transparent; color: var(--learn); }
.btn-skip { background: var(--skip-soft); border-color: transparent; color: var(--skip); }
.btn-know:hover, .btn-learn:hover, .btn-skip:hover { filter: brightness(.97); }
.btn-pass { width: 100%; color: var(--muted); }
.btn-link {
  border: 0; background: none; color: var(--accent); cursor: pointer; padding: 6px 8px; font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px;
}
.btn-link.danger { color: var(--danger); }

.example {
  width: 100%; background: var(--surface); border: 1px dashed var(--line); border-radius: 12px; padding: 12px 16px;
}
.example p { margin: 0; }
.example-el { font-size: 1.08rem; }
.example-ru { color: var(--muted); margin-top: 4px !important; }

.empty {
  text-align: center; padding: 40px 20px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--muted);
}
.empty-title { font-size: 1.15rem; color: var(--text); font-weight: 600; margin-top: 0; }

.foot {
  max-width: 760px; width: 100%; margin: 0 auto; padding: 18px 16px 28px; color: var(--muted); font-size: .8rem;
  text-align: center;
}

/* ---------- окно списков ---------- */
.dialog {
  width: min(640px, calc(100vw - 32px)); padding: 0;
  /* dvh — видимая высота: 100vh на телефоне считает и место под адресной строкой, и шапка окна уходила под неё */
  max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(10, 14, 20, .45); }
.dialog > *:not(.dialog-head) { margin-left: 18px; margin-right: 18px; }
.dialog-head {
  display: flex; justify-content: space-between; align-items: center; padding: 14px 14px 6px 18px;
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.dialog h2 { font-size: 1.1rem; margin: 0; }
.dialog h3 { font-size: 1rem; margin-top: 22px; margin-bottom: 4px; }
.help h3 { margin-top: 14px; }
.help ul { margin: 0; padding-left: 20px; font-size: .92rem; line-height: 1.45; }
.help li { margin: 3px 0; }
.help ul:last-child { margin-bottom: 18px; }
.list-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.list-tabs button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; cursor: pointer;
  font-size: .88rem;
}
.list-tabs button[aria-selected="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.badge { font-weight: 600; opacity: .8; }
.search {
  width: calc(100% - 36px); margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); font-size: 16px;
}
/* поиск и направление списка — одной строкой; на узком экране переключатель уходит вниз целиком */
.list-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.list-row .search { flex: 1 1 200px; width: auto; margin-top: 0; }
.dir-small button { min-height: 32px; padding: 4px 10px; font-size: .82rem; white-space: nowrap; }
.dir-small { flex-wrap: nowrap; }
/* высота постоянная: окно не прыгает при переходе между «Знаю», «Освоено» и «Не учим» */
.list { list-style: none; padding: 0; margin-top: 8px; height: min(42vh, 360px); overflow-y: auto; border-top: 1px solid var(--line); }
.list li { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--line); }
.list .w { font-weight: 600; min-width: 0; }
.list .t { color: var(--muted); font-size: .88rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .lvl { font-size: .72rem; color: var(--muted); }
.list li .btn-link { flex: none; font-size: .88rem; }
/* разделитель времён в «Освоено»: подзаголовок, а не строка списка */
.list li.sep { position: sticky; top: 0; background: var(--surface); padding: 10px 2px 4px; font-size: .72rem;
  font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
/* пустой список занимает то же место, что и полный */
.list-empty { color: var(--muted); text-align: center; height: min(42vh, 360px); margin-top: 8px; padding-top: 18px; border-top: 1px solid var(--line); }
.list-foot { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 6px; min-height: 36px; }
.confirm { color: var(--danger); font-size: .9rem; }
.note { color: var(--muted); font-size: .88rem; margin-top: 4px; }
/* раздел «Усвоение» в окне ⚙ */
.switch-row, .goal-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; cursor: pointer; }
.switch-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.goal-row input {
  width: 4em; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); font-size: 16px; text-align: center;
}
.goal-row.off { opacity: .5; cursor: default; }

/* плашка после «Верно» — поверх строки счётчика: ничего не сдвигает и через пару секунд уходит */
.counter-wrap { position: relative; }
.toast {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 2; white-space: nowrap; margin: 0;
  padding: 4px 14px; border-radius: 999px; font-size: .9rem; font-weight: 600; box-shadow: var(--shadow);
  background: var(--know-soft); color: var(--know);
}
.toast.done { background: var(--accent-soft); color: var(--accent); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.confirm-box { margin-top: 12px; padding: 12px; background: var(--surface-2); border-radius: 12px; }
.confirm-box p { margin-top: 0; }
.status { min-height: 1.5em; font-size: .9rem; margin-bottom: 0; }
.status.ok { color: var(--know); }
.status.err { color: var(--danger); }
#voice-note { margin-bottom: 18px; }

@media (max-width: 520px) {
  .top { padding-top: 12px; }
  /* Фильтры — сеткой во всю ширину: курс и направление на всю строку с равными половинками, уровень и
     спряжение пополам. По центру по отдельности блоки разной ширины стояли лесенкой */
  .controls { flex-direction: column; align-items: stretch; gap: 8px; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  #course { grid-column: 1 / -1; }
  #course, #dir { display: grid; grid-template-columns: 1fr 1fr; }
  #course button, #dir button { text-align: center; }
  .ms-btn { width: 100%; justify-content: space-between; }
  .ms-btn .ms-label { margin-right: auto; }
  .card { min-height: 210px; }
  .actions { gap: 8px; }
  .btn { padding: 12px 8px; }
  /* три вкладки списков — ровными колонками в один ряд, «Не учим» не уезжает на вторую строку */
  .list-tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
  .list-tabs button { padding: 6px 4px; white-space: nowrap; }
  /* в одну строку перевод сжимался до нуля — на узком экране строка списка в два этажа */
  .list li:not(.sep) { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "w t" "lvl back"; column-gap: 10px; row-gap: 2px; }
  .list .w { grid-area: w; }
  .list .t { grid-area: t; }
  .list .lvl { grid-area: lvl; align-self: center; }
  .list li .btn-link { grid-area: back; justify-self: end; }
}

/* ---------- справочник ---------- */
/* у #dir свой display, он сильнее атрибута hidden — в справочнике направление прячется явно */
#dir[hidden] { display: none !important; }
/* кнопка справочника в шапке: подсвечена, пока справочник открыт; на телефоне — одна иконка */
/* справочник отодвинут от служебных кнопок (тема, настройки, помощь): это раздел сайта, а не настройка */
.ref-btn { display: inline-flex; align-items: center; gap: 6px; margin-right: 12px; }
.ref-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
@media (max-width: 520px) {
  .ref-btn-label { display: none; }
  /* четвёртая кнопка в шапке выталкивала шестерёнку за край — на телефоне кнопки и промежутки плотнее */
  .top { gap: 8px; }
  .top-actions { gap: 4px; }
  .icon-btn { min-width: 36px; height: 36px; padding: 0 8px; }
  .ref-btn { margin-right: 6px; }
  .brand { font-size: 1rem; }
  .brand-btn { gap: 8px; }
}
.ref-scope { margin: 6px 0 0; padding: 8px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--text); font-size: .85rem; }

#panel-ref { position: relative; }
/* поиск и алфавит прилипают к верху: список длинный, и к букве нужно попадать из любого места */
.ref-bar {
  position: sticky; top: 0; z-index: 5; display: flex; flex-direction: column; gap: 8px;
  padding: 8px 0; background: var(--bg);
}
.ref-abc { display: flex; flex-wrap: wrap; gap: 3px; }
.ref-abc button {
  min-width: 26px; height: 28px; padding: 0 3px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--surface); color: var(--text); font: inherit; font-size: .85rem; cursor: pointer;
}
.ref-abc button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.ref-abc button:disabled { opacity: .3; cursor: default; }
.ref-count { margin: 4px 0 0; color: var(--muted); font-size: .85rem; }
.ref-list { list-style: none; margin: 4px 0 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
/* разделитель-буква уходит под липкую полосу без отступа — scroll-margin держит его видимым */
.ref-list li.sep {
  scroll-margin-top: 110px; padding: 10px 14px 4px; font-weight: 700; color: var(--accent);
  border-bottom: 1px solid var(--line); font-size: .9rem;
}
.ref-row {
  display: flex; align-items: baseline; gap: 10px; width: 100%; padding: 9px 14px; border: 0;
  border-bottom: 1px solid var(--line); background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.ref-list li:last-child .ref-row { border-bottom: 0; }
.ref-row:hover { background: var(--surface-2); }
.ref-row .w { font-weight: 600; white-space: nowrap; }
.ref-row .t { flex: 1; min-width: 0; color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ref-row .lvl { font-size: .72rem; color: var(--muted); }
.ref-empty { padding: 18px 14px; color: var(--muted); text-align: center; }

.ref-back { align-self: flex-start; padding-left: 0; }
.ref-head { margin: 4px 0 6px; }
.ref-title { margin: 0; font-size: 1.6rem; font-weight: 650; }
.ref-ru { margin: 2px 0 0; font-size: 1.05rem; }
.ref-meta { margin: 4px 0 0; color: var(--muted); font-size: .85rem; }
/* друг под другом: в три колонки «θα γράψουμε» и русская форма переносились, строку приходилось собирать глазами */
.ref-tables { display: grid; gap: 12px; }
.ref-tense { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 6px; }
.ref-tense h3 { margin: 0 0 6px; font-size: .95rem; }
/* колонки одной ширины во всех трёх таблицах: иначе русские формы стоят лесенкой от таблицы к таблице */
.ref-tense table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.ref-tense td.pron { width: 92px; }
.ref-tense td.form { width: 44%; }
.ref-tense td { padding: 5px 4px; border-top: 1px solid var(--line); vertical-align: baseline; }
.ref-tense td.pron { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ref-tense td.form { font-weight: 600; white-space: nowrap; }
.ref-tense td.ru { color: var(--muted); font-size: .85rem; }
/* пунктир — «здесь есть пример»: формы без примера остаются простым текстом */
.ref-form {
  padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer;
  text-decoration: underline dotted var(--accent); text-underline-offset: 4px; text-decoration-thickness: 1.5px;
}
.ref-form:hover { color: var(--accent); }

.ref-tip {
  position: absolute; z-index: 20; width: min(340px, 100%); box-sizing: border-box; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--accent); border-radius: 10px; box-shadow: var(--shadow);
}
.ref-tip p { margin: 0; }
.ref-tip-el { font-size: 1rem; }
.ref-tip-ru { margin-top: 4px !important; color: var(--muted); font-size: .9rem; }

/* фильтры вынесены из панели карточек (их делит справочник) — отступ, который давала панель, теперь свой */
#controls { margin-bottom: 14px; }
@media (max-width: 520px) {
  /* на телефоне перевод встаёт под форму: колонкам не хватало ширины, и «θα καταλάβουμε» наезжала на перевод */
  .ref-tense td.pron { width: 86px; }
  .ref-tense td.form { width: auto; }
  .ref-tense td.ru { display: none; }
  .ru-inline { display: block !important; font-weight: 400; font-size: .82rem; color: var(--muted); white-space: normal; margin-top: 1px; }
}
.ru-inline { display: none; }

/* поиск справочника с крестиком: поле во всю ширину (как список под ним), справа — место под крестик */
.search-wrap { position: relative; }
.search-wrap .search { width: 100%; margin-top: 0; padding-right: 40px; box-sizing: border-box; }
/* встроенный крестик поля поиска есть не везде — прячем его, чтобы со своим не было двух */
#ref-search::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; display: none; }
.search-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; border: 0; border-radius: 50%; background: none;
  color: var(--muted); font: inherit; font-size: 1.3rem; line-height: 1; cursor: pointer;
}
.search-clear:hover { background: var(--surface-2); color: var(--text); }
.search-clear[hidden] { display: none; } /* у кнопки свой display — правило браузера для hidden его не перебивает */

/* дата выкладки и набора курса — своей строкой под источниками */
.foot-updated { display: block; margin-top: 6px; }
.foot-updated[hidden] { display: none; }

/* «Рандом»: ряд вкладок спрятан — у .tabs свой display, правило браузера для hidden его не перебивает */
.tabs[hidden] { display: none; }
.tense-tag { font-weight: 600; color: var(--accent); }
@media (max-width: 520px) {
  /* три режима в строку не влезали вместе с подписью — на телефоне подпись «Режим» уходит, кнопки плотнее */
  .flow-label { display: none; }
  #flow button { padding: 6px 12px; }
}
