/* Saver · Видео. Семейство Saver: те же поверхности, оранжевый только у
   действий, Inter для текста и цифр, Onest для заголовков (fin theme.css).
   Контраст на --surface: sub 7.0:1, dim 5.5:1; на светлой теме — из fin. */

@font-face {
  font-family: 'Inter'; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url('/assets/inter-cyrillic-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url('/assets/inter-latin-wght-normal.woff2') format('woff2-variations');
  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+2074, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Onest'; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url('/assets/onest-cyrillic-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Onest'; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url('/assets/onest-latin-wght-normal.woff2') format('woff2-variations');
  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+2074, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #0b0b0c; --surface: #17171a; --surface2: #202024; --surface3: #28282d;
  --line: #2c2c31; --line-strong: #3a3a41;
  --hover: #1e1e22;
  --txt: #f2f2f3; --sub: #a1a1a9; --dim: #8e8e97;
  --accent: #ff6a00; --accent-hi: #ff7f26; --accent-soft: rgba(255, 106, 0, .14);
  --accent-line: rgba(255, 106, 0, .45); --ink: #0b0b0c;
  --accent-txt: var(--accent);
  --ok: #3fb950; --warn: #e3b341; --danger: #f85149;
  --danger-txt: #ff9d96; --danger-soft: rgba(248, 81, 73, .12); --danger-line: rgba(248, 81, 73, .4);
  --ok-soft: rgba(63, 185, 80, .12); --ok-line: rgba(63, 185, 80, .4);
  --r-card: 16px; --r-ctl: 10px;
  --ease: cubic-bezier(.2, 0, 0, 1);
  --shadow: 0 2px 6px rgba(0, 0, 0, .5), 0 14px 40px rgba(0, 0, 0, .45);
  --gutter: 16px;
  --f-display: 'Onest', 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --f-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f2f2f5; --surface: #ffffff; --surface2: #f4f4f6; --surface3: #e9e9ee;
  --line: #e2e2e8; --line-strong: #cfcfd7;
  --hover: #f6f6f8;
  --txt: #16161a; --sub: #55555f; --dim: #63636c;
  --accent: #ff6a00; --accent-hi: #ff7f26; --accent-soft: rgba(255, 106, 0, .1);
  --accent-line: rgba(255, 106, 0, .5); --ink: #0b0b0c;
  --accent-txt: #b84900;
  --ok: #1a7f37; --warn: #8a5a00; --danger: #cf222e;
  --danger-txt: #b42318; --danger-soft: rgba(207, 34, 46, .08); --danger-line: rgba(207, 34, 46, .35);
  --ok-soft: rgba(26, 127, 55, .08); --ok-line: rgba(26, 127, 55, .35);
  --shadow: 0 1px 3px rgba(20, 20, 30, .08), 0 12px 32px rgba(20, 20, 30, .12);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* display у наших блоков перебивает скрытие атрибутом hidden — guard обязателен. */
[hidden] { display: none !important; }

html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg); color: var(--txt);
  font-family: var(--f-ui);
  font-size: 15px; line-height: 1.45;
  font-variant-numeric: tabular-nums;
  min-height: 100dvh;
  display: flex; flex-direction: column;
}
h1, h2, h3 { font-family: var(--f-display); font-weight: 600; letter-spacing: -.01em; margin: 0; }
a { color: var(--accent-txt); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- шапка ---------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px var(--gutter);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky; top: 0; z-index: 5;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--txt); text-decoration: none;
  font-family: var(--f-display); font-weight: 600; font-size: 17px;
  min-width: 0;
}
.brand .mark {
  flex: none; width: 32px; height: 32px; display: grid; place-items: center;
  border-radius: 9px; background: var(--accent-soft); border: 1px solid var(--accent-line);
  color: var(--accent);
}
.brand .mark svg { display: block; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-tools { display: flex; align-items: center; gap: 10px; }

.theme-switch {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px;
  padding: 3px; border-radius: var(--r-ctl);
  background: var(--surface2); border: 1px solid var(--line);
}
.theme-opt {
  min-height: 30px; padding: 0 8px;
  border: 0; border-radius: 7px; background: none;
  color: var(--sub); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.theme-opt:hover { color: var(--txt); }
.theme-opt.is-on { background: var(--surface3); color: var(--txt); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

/* ---------- кнопки и поля ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); border: 1px solid var(--accent); color: var(--ink);
  border-radius: var(--r-ctl); padding: 10px 18px; font-family: inherit; font-size: 14.5px; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s var(--ease);
}
.btn:hover { background: var(--accent-hi); border-color: var(--accent-hi); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.ghost {
  background: transparent; border-color: var(--line-strong); color: var(--txt); font-weight: 550;
}
.btn.ghost:hover { background: var(--hover); border-color: var(--line-strong); }
.btn.small { padding: 6px 12px; font-size: 13.5px; }
.btn.danger-ghost { color: var(--danger-txt); border-color: var(--danger-line); }
.btn.danger-ghost:hover { background: var(--danger-soft); border-color: var(--danger-line); }
.btn.ghost.confirm { color: var(--danger-txt); border-color: var(--danger); }

.link-form {
  display: grid; grid-template-columns: 1fr auto; gap: 8px;
}
.link-form.is-pasting { grid-template-columns: 1fr auto auto; }
.input {
  width: 100%; min-width: 0; min-height: 44px;
  padding: 10px 14px;
  background: var(--surface2); border: 1px solid var(--line); border-radius: var(--r-ctl);
  color: var(--txt); font: inherit; font-size: 15px;
  transition: border-color .15s var(--ease);
}
.input::placeholder { color: var(--dim); }
.input:hover { border-color: var(--line-strong); }
.input:focus { outline: none; border-color: var(--accent); }
.input:disabled { opacity: .6; }

/* ---------- каркас ---------- */

.wrap { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 var(--gutter); }
main.wrap { flex: 1; padding-top: 24px; padding-bottom: 48px; }
.hint { color: var(--dim); font-size: 13.5px; margin: 10px 0 0; }
.error {
  margin-top: 16px; padding: 10px 12px; border-radius: var(--r-ctl);
  background: var(--danger-soft); border: 1px solid var(--danger-line);
  color: var(--danger-txt); font-size: 14px;
}
.section-title { font-size: 18px; margin: 36px 0 4px; }
.foot {
  padding-top: 12px; padding-bottom: 20px;
  color: var(--dim); font-size: 13px; border-top: 1px solid var(--line);
}
.foot a { color: var(--dim); text-decoration: none; }
.foot a:hover { color: var(--accent-txt); }

/* ---------- карточка видео ---------- */

.video-card {
  margin-top: 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  box-shadow: var(--shadow);
  padding: 16px;
  animation: reveal .28s var(--ease);
}
/* Кадр — главный элемент карточки: на всю ширину, в пропорции видео. */
.thumb {
  width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block;
  border-radius: 10px; background: var(--surface2); border: 1px solid var(--line);
  margin-bottom: 16px;
}
.video-info { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.video-info h2 {
  font-size: 20px; line-height: 1.25; overflow-wrap: anywhere;
}
.meta { color: var(--sub); font-size: 14px; margin: 0; overflow-wrap: anywhere; }
.meta.dim { color: var(--dim); font-size: 13.5px; }
.qualities { display: flex; flex-wrap: wrap; gap: 6px; }
.quality {
  min-height: 34px; padding: 0 12px;
  background: var(--surface2); border: 1px solid var(--line); border-radius: 9px;
  color: var(--txt); font: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer;
  transition: background .15s var(--ease), border-color .15s var(--ease);
}
.quality:hover { border-color: var(--line-strong); background: var(--surface3); }
.quality[aria-checked="true"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-txt); }
/* Размер слева, действие справа — кнопка не висит в пустоте. */
.video-actions {
  margin-top: 6px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}

/* ---------- загрузки ---------- */

.job-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); overflow: hidden; }
.job-list:empty { display: none; }
.job { padding: 14px 16px; display: grid; gap: 8px; }
.job + .job { border-top: 1px solid var(--line); }
.job-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; min-width: 0; }
.job-title {
  min-width: 0; flex: 1; font-family: var(--f-display); font-weight: 600; font-size: 15.5px;
  overflow-wrap: anywhere;
}
.job-meta { color: var(--sub); font-size: 13.5px; white-space: nowrap; }
.job-state { color: var(--sub); font-size: 13.5px; min-height: 1.45em; }
.job-state.ok { color: var(--ok); }
.job-state.bad { color: var(--danger-txt); }
.bar {
  height: 6px; border-radius: 4px; background: var(--surface3); overflow: hidden; position: relative;
}
.bar > i {
  display: block; height: 100%; width: 0; background: var(--accent); border-radius: 4px;
  transition: width .5s linear;
}
/* Объединение файлов прогресса не пишет: полоса бежит, а не стоит на месте. */
.bar.is-indeterminate > i { width: 36% !important; animation: run 1.4s var(--ease) infinite; }
.job-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.job-player { width: 100%; max-height: 420px; border-radius: 10px; background: #000; display: block; }
.empty { color: var(--dim); font-size: 14px; margin: 14px 0 0; padding: 18px 16px; border: 1px dashed var(--line-strong); border-radius: var(--r-card); text-align: center; }

@keyframes reveal { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes run { from { transform: translateX(-110%); } to { transform: translateX(290%); } }

/* ---------- узкий экран ---------- */

@media (max-width: 620px) {
  .topbar { flex-wrap: wrap; }
  .topbar-tools { width: 100%; justify-content: space-between; }
  .video-card { padding: 12px; }
  .video-info h2 { font-size: 18px; }
  /* Действие — на всю ширину, под пальцем; размер уже не делит с ним строку. */
  .video-actions { flex-direction: column-reverse; align-items: stretch; }
  .video-actions .btn { width: 100%; min-height: 44px; }
  .video-actions .meta { text-align: center; }
  .link-form, .link-form.is-pasting { grid-template-columns: minmax(0, 1fr); }
  .link-form .btn { width: 100%; min-height: 44px; }
  .job-head { flex-direction: column; align-items: flex-start; gap: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .quality, .theme-opt, .bar > i, .input { transition: none; }
  .video-card { animation: none; }
  .bar.is-indeterminate > i { animation: none; width: 100% !important; opacity: .45; }
}
