/* Токены из дизайн-системы v4.
   Значения перенесены как есть, чтобы интерфейс совпадал с прототипом
   и чтобы дизайн и код правились в одних и тех же понятиях. */

:root {
  --page: #16161b; --bg: #0c0c10; --surf: #1e1e27; --bar: #111116;
  --barLine: #23232b; --seg: #16161d; --chip: #2a2a33; --line: #2e2e39;
  --div: #2a2a33; --handle: #3a3a46; --dash: #45454f; --dis: #5a5a66;
  --inact: #6e6e7a; --muted: #9c9ba8; --sec: #c4c3ce; --ink: #f2f1f6;
  --onInk: #0c0c10; --vid: #17171e; --screen: #15151c;
  --acc: #f2f1f6; --onAcc: #0c0c10; --focus: #f2f1f6;
  --safety: oklch(0.38 0.08 75); --vis: oklch(0.36 0.07 160); --visOff: #2a2a33;
  --rework: oklch(0.36 0.09 20); --err: oklch(0.72 0.16 22);
  --segSh: 0 1px 3px rgba(0, 0, 0, .5);

  --flex: oklch(0.74 0.16 25);   --flexBg: oklch(0.31 0.07 25);
  --strength: oklch(0.72 0.14 255); --strengthBg: oklch(0.31 0.06 255);
  --balance: oklch(0.78 0.14 165);  --balanceBg: oklch(0.31 0.06 165);
  --special: oklch(0.72 0.17 305);  --specialBg: oklch(0.31 0.08 305);
}

/* Светлая тема включается классом на <html>, а не медиазапросом:
   в дизайне это переключатель в настройках, а не системная настройка. */
html.light {
  --page: #e4e7ef; --bg: #f5f6fa; --surf: #fff; --bar: #fff;
  --barLine: #e6e8ef; --seg: #ebedf3; --chip: #ebedf3; --line: #e3e6ee;
  --div: #eef0f5; --handle: #d2d6e0; --dash: #c2c7d3; --dis: #b1b6c3;
  --inact: #9399a8; --muted: #626979; --sec: #3d4352; --ink: #10121a;
  --onInk: #f5f6fa; --vid: #1b1d2b; --screen: #10121a;
  --acc: oklch(0.5 0.23 275); --onAcc: #fff; --focus: oklch(0.5 0.23 275);
  --safety: oklch(0.94 0.06 85); --vis: oklch(0.94 0.04 185); --visOff: #ebedf3;
  --rework: oklch(0.94 0.04 20); --err: oklch(0.58 0.2 22);
  --segSh: 0 1px 3px rgba(16, 18, 26, .1);

  --flex: oklch(0.64 0.2 15);    --flexBg: oklch(0.95 0.03 15);
  --strength: oklch(0.54 0.19 262); --strengthBg: oklch(0.95 0.025 262);
  --balance: oklch(0.62 0.13 185);  --balanceBg: oklch(0.95 0.03 185);
  --special: oklch(0.56 0.22 300);  --specialBg: oklch(0.95 0.03 300);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 500 15px/1.5 Manrope, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Приложением пользуются в зале: случайное выделение текста при
     промахе по кнопке только мешает. */
  user-select: none;
  padding-bottom: 92px;
}

h1, h2, .display { font-family: Unbounded, Manrope, sans-serif; font-weight: 600; }

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }

/* --- Общая раскладка --- */
.wrap { max-width: 520px; margin: 0 auto; padding: 0 20px; }
.row { display: flex; align-items: center; gap: 10px; }
.spread { justify-content: space-between; }
.scroll-x {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: none;
}
.scroll-x::-webkit-scrollbar { display: none; }

header.top { padding-top: 14px; }
h1 { font-size: 28px; line-height: 1.1; margin: 12px 0 0; }
.count { font-size: 13px; font-weight: 600; color: var(--muted); }

/* --- Кнопки и чипы.
   44 px — минимальный размер цели нажатия: в зале по телефону
   попадают пальцем, часто одной рукой. --- */
.pill {
  height: 44px; padding: 0 16px; border-radius: 22px;
  background: var(--surf); border: 1px solid var(--line);
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; white-space: nowrap; flex: none;
}
.pill.on { background: var(--acc); color: var(--onAcc); border-color: var(--acc); }
.pill.sm { height: 36px; padding: 0 12px; border-radius: 18px; font-size: 12px; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; background: var(--surf);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}

.seg { display: flex; background: var(--seg); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; height: 34px; border-radius: 10px; font-size: 13px; font-weight: 700;
  color: var(--muted);
}
.seg button.on { background: var(--surf); color: var(--ink); box-shadow: var(--segSh); }

.primary {
  height: 52px; width: 100%; border-radius: 18px;
  background: var(--ink); color: var(--onInk); font-weight: 700; font-size: 15px;
}
.primary:disabled { background: var(--dis); }

.search {
  height: 52px; width: 100%; border-radius: 16px; background: var(--surf);
  border: 1px solid var(--surf); color: var(--ink); padding: 0 16px;
  font: 500 16px Manrope, sans-serif;
}
.search:focus { outline: none; border-color: var(--focus); }

.divider { width: 1px; height: 28px; background: var(--line); flex: none; align-self: center; }

/* --- Карточки витрины --- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-top: 14px; }
.card { text-align: left; display: block; width: 100%; }

.thumb {
  position: relative; aspect-ratio: 16/9; border-radius: 14px; overflow: hidden;
  /* Штриховка на подложке категории: пока видео нет, плитка всё равно
     читается и цветом говорит, что это за элемент. */
  background-image: repeating-linear-gradient(45deg,
    rgba(255,255,255,.05) 0 6px, transparent 6px 12px);
}
/* Плитка с иллюстрацией.

   Квадрат, а не 16:9: картинки в сборнике правил квадратные, и в
   широкой плитке их пришлось бы либо обрезать (тогда от фигуры
   остаётся середина и элемент не узнать), либо вписывать с широкими
   полями по бокам. Квадрат снимает обе беды.

   Белая подложка — под цвет фона самих иллюстраций: фигуры там
   вырезаны по белому, и так вписывание не видно стыком. */
.thumb.has-image {
  aspect-ratio: 1 / 1;
  background-color: #fff;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.thumb .play {
  position: absolute; inset: 0; margin: auto; width: 44px; height: 44px;
  border-radius: 50%; background: rgba(16,18,26,.72); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.thumb .lvl {
  position: absolute; top: 8px; left: 8px; height: 24px; padding: 0 8px;
  border-radius: 12px; background: var(--surf); color: var(--ink);
  display: flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700;
}
.thumb .bars { display: flex; align-items: flex-end; gap: 2px; height: 14px; }
.thumb .bars i { width: 3px; background: var(--line); border-radius: 1px; }
.thumb .bars i.on { background: var(--ink); }
.thumb .warn {
  position: absolute; top: 8px; right: 8px; width: 24px; height: 24px;
  border-radius: 50%; background: var(--safety); color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.thumb .len {
  position: absolute; right: 8px; bottom: 8px; font: 500 10px ui-monospace, monospace;
  background: rgba(0,0,0,.55); color: #fff; padding: 2px 5px; border-radius: 5px;
}

.card .name { font-size: 14px; font-weight: 700; margin-top: 8px; }
.card .meta { font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.card .score { font-size: 12px; font-weight: 700; color: var(--sec); margin-top: 2px; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 5px; }

/* Вид списком */
.list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.list .card {
  display: flex; gap: 12px; align-items: center;
  background: var(--surf); border-radius: 16px; padding: 10px;
}
.list .thumb { width: 96px; height: 54px; aspect-ratio: auto; flex: none; }
.list .thumb .play { width: 28px; height: 28px; font-size: 11px; }
.list .thumb .lvl, .list .thumb .warn, .list .thumb .len { display: none; }
.list .name { margin-top: 0; font-size: 15px; }

/* --- Нижний лист --- */
.backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40;
  animation: fade .2s ease;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--bg); border-radius: 28px 28px 0 0;
  max-height: 88vh; display: flex; flex-direction: column;
  animation: up .28s cubic-bezier(.2, .8, .2, 1);
}
.sheet .handle {
  width: 38px; height: 4px; border-radius: 2px; background: var(--handle);
  margin: 10px auto 4px;
}
.sheet .body { overflow-y: auto; padding: 8px 20px 12px; }
.sheet .foot {
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--barLine); background: var(--bg);
}
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.param { margin-top: 16px; }
.param .label { display: flex; justify-content: space-between; align-items: baseline; }
.param .label b { font-size: 13px; font-weight: 700; }
.param .label span { font-size: 12px; color: var(--muted); }
.param .vals { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.param .vals button { flex: 1 1 calc(50% - 4px); min-height: 44px; }

/* --- Экран карточки --- */
.detail { padding-bottom: 24px; }
.back { margin: 10px 0 4px; }
.kicker { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.detail h1 { font-size: 26px; margin: 4px 0 10px; }

.facts { display: flex; gap: 8px; margin: 12px 0; }
.fact {
  flex: 1; background: var(--seg); border-radius: 14px; padding: 10px 12px;
}
.fact b { display: block; font-size: 15px; font-weight: 700; }
.fact span { font-size: 11px; color: var(--muted); font-weight: 600; }
.fact.warn { background: var(--safety); }

.block { margin-top: 22px; }
.block h2 { font-size: 16px; margin: 0 0 10px; }
.note {
  background: var(--safety); border-radius: 16px; padding: 12px 14px;
  font-size: 14px; line-height: 1.5;
}
.states { display: flex; flex-direction: column; gap: 6px; }
.state-row {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center;
  background: var(--surf); border-radius: 12px; padding: 9px 12px; font-size: 13px;
}
.state-row .k { font-size: 11px; color: var(--muted); display: block; font-weight: 600; }
.state-row .arrow { color: var(--muted); }
.state-row.changed { border: 1px solid var(--acc); }
.state-row.changed .v2 { font-weight: 700; }

.variant {
  background: var(--surf); border-radius: 16px; padding: 12px 14px; margin-bottom: 8px;
}
.variant .vt { display: flex; justify-content: space-between; gap: 10px; }
.variant .vt b { font-size: 14px; }
.variant .vt .pts { font-weight: 700; color: var(--sec); white-space: nowrap; }
.variant ul { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: var(--sec); }

.steps { counter-reset: s; padding: 0; margin: 0; list-style: none; }
.steps li { display: flex; gap: 10px; margin-bottom: 10px; font-size: 15px; }
.steps li::before {
  counter-increment: s; content: counter(s);
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  border: 1px solid var(--line); display: flex; align-items: center;
  justify-content: center; font-size: 12px; font-weight: 700;
}

.link-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surf); border-radius: 14px; padding: 12px 14px;
  margin-bottom: 8px; width: 100%; text-align: left; font-size: 14px;
}
.chev { color: var(--muted); }

/* --- Таб-бар --- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; height: 82px; z-index: 30;
  background: var(--bar); border-top: 1px solid var(--barLine);
  display: flex; padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 4px; color: var(--inact);
  font-size: 11px; font-weight: 700; padding-bottom: 14px;
}
.tabbar button.on { color: var(--ink); }
.tabbar .glyph { font-size: 19px; line-height: 1; }

/* --- Прочее --- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 100px; z-index: 60;
  background: var(--ink); color: var(--onInk); padding: 12px 18px;
  border-radius: 14px; font-size: 14px; font-weight: 600; animation: fade .25s;
}
.badge {
  display: inline-block; height: 24px; line-height: 24px; padding: 0 10px;
  border-radius: 12px; font-size: 11px; font-weight: 700; background: var(--visOff);
}
.badge.review { background: var(--safety); }
.badge.rework { background: var(--rework); }
.badge.approved { background: var(--vis); }

.field { width: 100%; height: 52px; border-radius: 16px; background: var(--surf);
  border: 1px solid var(--line); color: var(--ink); padding: 0 16px;
  font: 500 16px Manrope, sans-serif; margin-bottom: 10px; }
.field:focus { outline: none; border-color: var(--focus); }
.err { color: var(--err); font-size: 13px; font-weight: 600; margin: 4px 0 10px; }

/* --- Полноэкранное видео --- */
.player {
  position: fixed; inset: 0; z-index: 70; background: #000;
  display: flex; flex-direction: column; animation: fade .2s;
}
.player video { flex: 1; width: 100%; height: 100%; object-fit: contain; background: #000; }
.player .bar {
  /* z-index обязателен: <video controls> создаёт собственный слой
     и иначе перехватывает нажатия на кнопки поверх себя. */
  position: absolute; left: 0; right: 0; top: 0; z-index: 2; padding: 14px 16px;
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(rgba(0,0,0,.6), transparent);
}
.player .bar button { color: #fff; font-size: 15px; font-weight: 700; }
.player .info {
  /* bottom: 60px, а не 0: внизу стоят родные кнопки плеера
     (громкость, полный экран), и подпись на них налезала.
     pointer-events: none — чтобы нажатия проходили к видео. */
  position: absolute; left: 0; right: 0; bottom: 60px; z-index: 2;
  padding: 14px 20px; pointer-events: none;
  background: linear-gradient(transparent, rgba(0,0,0,.72)); color: #fff;
}
.player .info h3 { font-family: Unbounded, Manrope, sans-serif; font-size: 20px; margin: 0 0 6px; }
.player .info .meta { font-size: 13px; opacity: .8; }
.player .speed {
  height: 36px; padding: 0 14px; border-radius: 18px;
  background: rgba(255,255,255,.18); color: #fff; font-weight: 700; font-size: 13px;
}

/* --- Выбор файла --- */
.upload {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: var(--surf); border: 1px dashed var(--dash); border-radius: 16px;
  padding: 14px 16px; margin-bottom: 10px; font-size: 14px; text-align: left;
}
.upload.done { border-style: solid; border-color: var(--acc); }
/* Полоска хода загрузки. Лежит внутри текстовой части, то есть
   не является flex-ребёнком .upload — поэтому display: block
   (у инline-элемента height не работает) и ширина в 100%. */
.upload .bar-bg {
  display: block; width: 100%; height: 4px; margin-top: 8px;
  border-radius: 2px; background: var(--line); overflow: hidden;
}
.upload .bar-fill { height: 100%; background: var(--acc); width: 0; transition: width .2s; }


/* Просмотр картинки во весь экран.

   Отдельно от .player: там <video> со своими родными кнопками
   и целым слоем поверх, здесь же достаточно картинки и фона.
   Закрывается нажатием в любом месте — на телефоне искать
   маленький крестик неудобно. */
.lightbox {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(10, 10, 14, .92);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; animation: fade .2s;
}
.lightbox img {
  max-width: 100%; max-height: 100%;
  border-radius: 12px; background: #fff;
}
.lightbox .hint {
  position: absolute; left: 0; right: 0; bottom: 24px;
  text-align: center; color: rgba(255,255,255,.7); font-size: 13px;
}

/* Крупная иллюстрация в карточке элемента. */
.shot {
  display: block; width: 100%; background: #fff;
  border-radius: 14px; cursor: zoom-in;
}
