/* Фирменный стиль NeZhmi: «чётко, без мыла».
   Один фирменный зелёный из лого, мотив сегментов из кольца на лого
   (полоса прогресса — сегмент на каждую часть ролика), Unbounded для
   названия и заголовков, системный шрифт для текста. Описание — brand/README.md. */

/* Unbounded (OFL 1.1, public/fonts/unbounded-OFL.txt). Свои файлы, а не
   Google Fonts: страница изолирована COEP, и чужие шрифты без CORP не грузятся */
@font-face {
  font-family: "Unbounded";
  src: url("/fonts/unbounded-cyrillic.woff2") format("woff2");
  font-weight: 500 800;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Unbounded";
  src: url("/fonts/unbounded-latin.woff2") format("woff2");
  font-weight: 500 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Фирменный зелёный: светлый и тёмный край градиента лого и середина */
  --brand-bright: #1fb57d;
  --brand: #128c5e;
  --brand-deep: #0e7a50;

  --bg: #f2f6f4;
  --glow: rgb(31 181 125 / .16);
  --surface: #ffffff;
  --surface-2: #e9f0ec;
  --ink: #0f1a15;
  --muted: #5b6a63;
  --line: #dce6e0;
  --accent: var(--brand);
  --accent-ink: #ffffff;
  --accent-soft: #e0f3e9;
  --track: #dbe6e0;
  --warn-bg: #fff3d6;
  --warn-ink: #7a5300;
  --err: #c0352b;
  --shadow: 0 1px 2px rgb(15 26 21 / .05), 0 10px 30px -12px rgb(15 26 21 / .14);

  --font-display: "Unbounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-text: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;

  --r-l: 24px;
  --r-m: 16px;
  --r-s: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #09110d;
    --glow: rgb(31 181 125 / .14);
    --surface: #111b16;
    --surface-2: #182520;
    --ink: #e8f2ec;
    --muted: #8ea097;
    --line: #213129;
    --accent: #2fbf83;
    --accent-ink: #04140c;
    --accent-soft: #11291e;
    --track: #213129;
    --warn-bg: #3a2e12;
    --warn-ink: #f3d48a;
    --err: #ff8a80;
    --shadow: 0 1px 0 rgb(255 255 255 / .03) inset, 0 10px 30px -12px rgb(0 0 0 / .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(120% 60% at 50% -10%, var(--glow), transparent 70%) no-repeat,
    var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font-text);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

.wrap {
  max-width: 520px;
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 16px max(32px, env(safe-area-inset-bottom));
}

/* Шапка: знак + название */
.head { margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 44px; height: 44px; flex: none; border-radius: 12px; box-shadow: 0 6px 16px -6px rgb(14 122 80 / .55); }
.brand h1 {
  margin: 0;
  font: 700 28px/1 var(--font-display);
  letter-spacing: -0.01em;
}
.lead { margin: 14px 0 0; color: var(--muted); }

/* Кнопка «Установить» в шапке */
.install {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font: 600 14px/1 var(--font-text);
  cursor: pointer;
  box-shadow: var(--shadow);
}
.install:active { transform: scale(.97); }
.install:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lead b { color: var(--ink); font-weight: 600; }

/* Карточки */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

/* Выбор файла: кольцо из сегментов вокруг значка, как на лого */
.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 28px 16px 24px;
  border: 1.5px dashed var(--line);
  border-radius: var(--r-m);
  background: var(--surface-2);
  cursor: pointer;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.has-file { border-color: var(--accent); background: var(--accent-soft); }
.drop-icon { color: var(--accent); margin-bottom: 10px; }
.drop-icon svg { display: block; }
.drop-title { font-weight: 600; font-size: 17px; word-break: break-word; }
.drop-sub { color: var(--muted); font-size: 14px; }

.field { border: 0; padding: 0; margin: 20px 0 0; }
.field legend { font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; padding: 0; }

/* Сегментированный переключатель */
.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
}
.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 15px;
  padding: 9px 6px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgb(0 0 0 / .14);
  font-weight: 600;
}
.seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Кнопки: капсулы, главная — фирменный зелёный */
.btn {
  appearance: none;
  display: block;
  width: 100%;
  margin-top: 18px;
  padding: 15px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: transform .1s, filter .15s, background .15s;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn.primary {
  background: linear-gradient(135deg, var(--brand-bright), var(--brand-deep));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 20px -10px rgb(14 122 80 / .8);
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.05); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.danger { color: var(--err); }
.btn:disabled { opacity: .4; cursor: default; box-shadow: none; }
.btn.small { margin: 0; padding: 11px 12px; font-size: 15px; }

/* Обработка */
.stage { margin: 0 0 14px; font: 600 17px/1.3 var(--font-display); letter-spacing: -0.01em; }
.stage.err { color: var(--err); }

/* Бегущая полоса, пока видео читается */
.bar { display: flex; gap: 6px; }
.bar span {
  flex: 1;
  position: relative;
  height: 6px;
  border-radius: 3px;
  background: var(--track);
  overflow: hidden;
}
.bar span::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--fill, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-bright), var(--accent));
  transition: width .3s;
}
.bar.indeterminate span::after { width: 35%; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(300%); } }

/* Карточки частей: обложка, длительность, галочка и своя полоса.
   Вместе полосы повторяют сегменты кольца с лого. */
.parts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.part { width: 72px; }
.parts.landscape .part { width: 112px; }
.part-thumb {
  position: relative;
  /* Ниже, чем сам ролик 9:16: обложка обрезается по краям (object-fit) */
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: 10px;
  background: linear-gradient(110deg, var(--surface-2) 30%, var(--line) 50%, var(--surface-2) 70%) 0 0 / 300% 100%;
  animation: shimmer 1.4s linear infinite;
  transition: box-shadow .2s, transform .1s;
}
.parts.landscape .part-thumb { aspect-ratio: 16 / 9; }
.part-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.part-thumb:has(.part-img) { animation: none; }
@keyframes shimmer { to { background-position: -150% 0; } }
.part.active .part-thumb { box-shadow: 0 0 0 2px var(--accent); }
.part-dur {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgb(0 0 0 / .6);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(4px);
}
.part-done {
  position: absolute;
  right: 4px;
  bottom: 4px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 6px rgb(0 0 0 / .35);
  animation: pop .25s ease-out;
}
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
.part-bar {
  margin-top: 6px;
  height: 4px;
  border-radius: 2px;
  background: var(--track);
  overflow: hidden;
}
.part-bar span {
  display: block;
  height: 100%;
  width: var(--fill, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-bright), var(--accent));
  transition: width .3s;
}

.note { margin: 0 0 14px; padding: 12px 14px; border-radius: var(--r-s); font-size: 14px; }
.note.warn { background: var(--warn-bg); color: var(--warn-ink); }
.fine { color: var(--muted); font-size: 13px; margin: 12px 0 0; }

/* Результат: те же карточки частей, по нажатию — просмотр */
.part.playable { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.part.playable:active .part-thumb { transform: scale(.96); }
.part.playable:focus-visible { outline: none; }
.part.playable:focus-visible .part-thumb { box-shadow: 0 0 0 2px var(--accent); }
.part-play {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin: -16px 0 0 -16px;
  padding-left: 2px;
  border-radius: 50%;
  background: rgb(0 0 0 / .45);
  color: #fff;
  backdrop-filter: blur(4px);
}
#done-actions .note { margin: 16px 0 0; }

/* Окно просмотра части */
/* Окно при открытии ставит фокус на плеер, и браузер обводит его рамкой.
   У кнопок плеера своя подсветка фокуса, рамка вокруг всего видео не нужна. */
.viewer:focus, .viewer video:focus { outline: none; }
.viewer video {
  display: block;
  width: 100%;
  max-height: 58vh;
  border-radius: var(--r-m);
  background: #000;
}
.viewer-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 14px 0 12px; }
.viewer-meta h2 { margin: 0; font: 600 16px/1.3 var(--font-display); }
.viewer-meta span { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.viewer .btn.ghost { margin-top: 8px; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.tips h2 { margin: 0 0 12px; font: 600 16px/1.3 var(--font-display); }

/* Нумерованные шаги в зелёных кружках */
.steps { margin: 0; padding: 0; list-style: none; counter-reset: tip; }
.steps li { position: relative; padding-left: 36px; counter-increment: tip; }
.steps li + li { margin-top: 10px; }
.steps li::before {
  content: counter(tip);
  position: absolute;
  left: 0;
  top: 0;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font: 700 12px/1 var(--font-display);
}

/* Окно с инструкцией по установке: на телефоне — снизу, как системные меню */
.sheet {
  width: min(440px, calc(100% - 24px));
  margin: auto auto max(12px, env(safe-area-inset-bottom));
  padding: 24px 20px 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 20px 60px -20px rgb(0 0 0 / .5);
}
@media (min-width: 600px) { .sheet { margin: auto; } }
.sheet::backdrop { background: rgb(5 12 9 / .5); backdrop-filter: blur(3px); }
.sheet-icon { display: block; border-radius: 16px; margin-bottom: 14px; }
.sheet h2 { margin: 0; font: 700 20px/1.25 var(--font-display); }
.sheet .fine { margin: 6px 0 18px; font-size: 14px; }
.sheet .steps li { font-size: 15px; }
.inline-icon { display: inline-block; vertical-align: -3px; color: var(--accent); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions .btn { margin-top: 0; }

.foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  margin-top: 24px;
}
.foot svg { color: var(--accent); flex: none; }
