@import url('https://fonts.googleapis.com/css2?family=Golos+Text:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap&subset=cyrillic');

/* ---------- токены ---------- */

:root {
  --font-ui: 'Golos Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', ui-monospace, monospace;

  --fs-11: 11px; --fs-12: 12px; --fs-13: 13px; --fs-14: 14px;
  --fs-16: 16px; --fs-20: 20px; --fs-28: 28px;

  --text-page-title: 600 var(--fs-20)/1.3 var(--font-ui);
  --text-section: 600 var(--fs-14)/1.4 var(--font-ui);
  --text-body-md: 400 var(--fs-13)/1.5 var(--font-ui);
  --text-label: 500 var(--fs-12)/1.4 var(--font-ui);

  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;
  --radius-sm: 4px; --radius-md: 6px; --radius-lg: 8px; --radius-full: 999px;
  --control-h-sm: 24px; --control-h-md: 28px; --control-h-lg: 32px;
  --sidebar-w: 220px;

  /* нейтральные — светлая тема */
  --bg-0: #fafafa; --bg-1: #ffffff; --bg-2: #f4f4f5; --bg-3: #ececee;
  --border-1: #e7e7e9; --border-2: #d9d9dc;
  --text-1: #18181b; --text-2: #55555e; --text-3: #9a9aa3;

  --accent: #2e6ff2; --accent-hover: #245fd6; --accent-soft: #eaf1fe; --accent-fg: #ffffff;
  --ok: #158f5f; --ok-soft: #e5f5ee;
  --warn: #b3660a; --warn-soft: #fdf2e2;
  --err: #d43a34; --err-soft: #fdecec;

  --surface-app: var(--bg-0); --surface-card: var(--bg-1); --surface-raised: var(--bg-2);
  --surface-hover: rgba(24, 24, 27, .045); --surface-press: rgba(24, 24, 27, .08);
  --text-body: var(--text-1); --text-muted: var(--text-2); --text-faint: var(--text-3);

  --focus-ring: 0 0 0 2px var(--bg-1), 0 0 0 4px var(--accent);
  --shadow-card: 0 1px 2px rgba(24, 24, 27, .05);
  --shadow-pop: 0 4px 16px rgba(24, 24, 27, .12), 0 1px 3px rgba(24, 24, 27, .08);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg-0: #101012; --bg-1: #17171a; --bg-2: #1f1f23; --bg-3: #28282e;
  --border-1: #28282e; --border-2: #36363e;
  --text-1: #f0f0f2; --text-2: #a3a3ad; --text-3: #65656f;

  --accent: #5c8dff; --accent-hover: #7aa2ff; --accent-soft: #1c2740; --accent-fg: #0d1524;
  --ok: #3ecf8e; --ok-soft: #132b21;
  --warn: #f0a13c; --warn-soft: #2e2213;
  --err: #f0645e; --err-soft: #331717;

  --surface-hover: rgba(240, 240, 242, .06); --surface-press: rgba(240, 240, 242, .1);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-pop: 0 4px 20px rgba(0, 0, 0, .5), 0 1px 3px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

/* ---------- база ---------- */

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font: var(--text-body-md);
  font-family: var(--font-ui);
  color: var(--text-body);
  background: var(--surface-app);
  -webkit-font-smoothing: antialiased;
}

.num { font-variant-numeric: tabular-nums lining-nums; }
::selection { background: var(--accent-soft); }
.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono { font-family: var(--font-mono); }
svg { flex-shrink: 0; }

@keyframes row-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes panel-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@keyframes scan { 0% { transform: translateX(-100%); } 100% { transform: translateX(500%); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- контролы ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control-h-md);
  padding: 0 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  background: var(--surface-card);
  color: var(--text-1);
  font: var(--text-label);
  font-family: var(--font-ui);
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn:hover { background: var(--surface-hover); }
.btn:active { background: var(--surface-press); }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn[disabled]:hover { background: var(--surface-card); }

.btn.sm { height: var(--control-h-sm); padding: 0 9px; font-size: var(--fs-11); }
.btn.lg { height: var(--control-h-lg); padding: 0 14px; }

.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.primary[disabled]:hover { background: var(--accent); }

.btn.ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn.ghost:hover { background: var(--surface-hover); color: var(--text-1); }

.btn.danger { color: var(--err); border-color: var(--border-2); }
.btn.danger:hover { background: var(--err-soft); border-color: var(--err); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-h-md);
  height: var(--control-h-md);
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text-1); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.icon-btn[disabled] { opacity: .4; cursor: not-allowed; }
.icon-btn[disabled]:hover { background: transparent; color: var(--text-muted); }
.icon-btn.sm { width: var(--control-h-sm); height: var(--control-h-sm); }
.icon-btn.danger:hover { background: var(--err-soft); color: var(--err); }

.input {
  width: 100%;
  height: var(--control-h-lg);
  padding: 0 10px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  background: var(--surface-card);
  color: var(--text-1);
  font: 400 var(--fs-13)/1 var(--font-ui);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.input.mono { font-family: var(--font-mono); font-size: var(--fs-12); }
.input::placeholder { color: var(--text-3); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.invalid { border-color: var(--err); }

.checkbox {
  appearance: none;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  cursor: pointer;
  position: relative;
  transition: background 120ms ease, border-color 120ms ease;
}
.checkbox:checked, .checkbox.partial { background: var(--accent); border-color: var(--accent); }
.checkbox:checked::after {
  content: '';
  position: absolute;
  left: 4px; top: 1px;
  width: 4px; height: 8px;
  border: solid var(--accent-fg);
  border-width: 0 1.8px 1.8px 0;
  transform: rotate(45deg);
}
.checkbox.partial::after {
  content: '';
  position: absolute;
  left: 3px; top: 6px;
  width: 7px; height: 0;
  border-top: 1.8px solid var(--accent-fg);
}
.checkbox:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ---------- отображение ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--radius-full);
  background: var(--surface-raised);
  color: var(--text-muted);
  font: 500 var(--fs-11)/1 var(--font-ui);
  white-space: nowrap;
}
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge .dot { width: 5px; height: 5px; border-radius: var(--radius-full); background: currentColor; }
.badge .dot.live { animation: pulse 1.6s ease-in-out infinite; }

.tag {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border: 1px solid var(--border-1);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font: 400 var(--fs-11)/1 var(--font-mono);
  white-space: nowrap;
}

.card {
  background: var(--surface-card);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.meter {
  display: flex;
  align-items: center;
  gap: 8px;
}
.meter .track {
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--surface-raised);
  overflow: hidden;
  flex: 1;
}
.meter .fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--accent);
  transition: width 200ms ease;
}
.meter.ok .fill { background: var(--ok); }
.meter.warn .fill { background: var(--warn); }
.meter.err .fill { background: var(--err); }
.meter .pct { font: 500 var(--fs-11)/1 var(--font-mono); color: var(--text-muted); min-width: 34px; text-align: right; }

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border-1);
}
.tabs button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border: none;
  border-bottom: 1.5px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font: var(--text-label);
  font-family: var(--font-ui);
  cursor: pointer;
  margin-bottom: -1px;
  transition: color 120ms ease, border-color 120ms ease;
}
.tabs button:hover { color: var(--text-1); }
.tabs button.active { color: var(--text-1); border-bottom-color: var(--accent); }
.tabs .count {
  font: 400 var(--fs-11)/1 var(--font-mono);
  color: var(--text-3);
  background: var(--surface-raised);
  border-radius: var(--radius-full);
  padding: 2px 6px;
}
.tabs button.active .count { color: var(--accent); background: var(--accent-soft); }

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

.shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  border-right: 1px solid var(--border-1);
  display: flex;
  flex-direction: column;
  padding: 12px 8px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 8px 16px;
  font: 700 var(--fs-16)/1 var(--font-ui);
  letter-spacing: -0.02em;
  color: var(--text-1);
}
.panel {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px;
  margin-bottom: 14px;
  background: var(--surface-raised);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
}
.panel .line { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel .label {
  display: flex;
  align-items: center;
  gap: 6px;
  font: var(--text-label);
  font-family: var(--font-ui);
  color: var(--text-muted);
}
.panel .val { font: 500 var(--fs-13)/1 var(--font-mono); color: var(--text-1); }
.panel .live-dot { width: 5px; height: 5px; border-radius: var(--radius-full); background: var(--accent); }
.panel .live-dot.live { animation: pulse 1.6s ease-in-out infinite; }
.panel .split { padding-top: 8px; border-top: 1px solid var(--border-1); display: flex; flex-direction: column; gap: 5px; }
.panel .cap { font: 400 var(--fs-11)/1 var(--font-ui); color: var(--text-3); }
.sidebar .foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border-1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sidebar .foot span { font: 400 var(--fs-12)/1.3 var(--font-ui); color: var(--text-3); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border-1);
  flex-shrink: 0;
}
.topbar h1 { font: var(--text-page-title); font-family: var(--font-ui); color: var(--text-1); margin: 0; }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.scan { position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; overflow: hidden; pointer-events: none; }
.scan i { display: block; width: 18%; height: 100%; background: var(--accent); opacity: .55; animation: scan 2.4s linear infinite; }

.content { flex: 1; overflow: auto; padding: 20px 24px 32px; }
.stack { max-width: 920px; display: flex; flex-direction: column; gap: 16px; }

.addbar { display: flex; gap: 8px; align-items: flex-start; }
.addbar .field { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.hint-err { font: 400 var(--fs-11)/1.4 var(--font-ui); color: var(--err); padding-left: 2px; }
.dropzone { border-radius: var(--radius-lg); transition: background 120ms ease, outline-color 120ms ease; outline: 1px dashed transparent; outline-offset: 4px; }
.dropzone.drag { background: var(--accent-soft); outline-color: var(--accent); }

/* ---------- строки задач ---------- */

/* На широком экране строка — это сетка: слева описание, справа кнопки,
   статистика во всю ширину. На узком те же блоки становятся столбцом. */
.row {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-1);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 12px;
  animation: row-in 200ms ease;
}
.row:last-child { border-bottom: none; }
.row-head { grid-column: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.row-actions { grid-column: 2; grid-row: 1; display: flex; align-items: center; gap: 6px; }
.row-stats, .row-err, .files { grid-column: 1 / -1; }
.row-head .title { font: 600 var(--fs-13)/1.3 var(--font-ui); color: var(--text-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-head .sub { font: 400 var(--fs-12)/1 var(--font-ui); color: var(--text-3); white-space: nowrap; }
.row-head .spacer { margin-left: auto; }
.chev { display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; border: none; background: transparent; color: var(--text-muted); cursor: pointer; padding: 0; flex-shrink: 0; }
.chev:hover { color: var(--text-1); }
.chev svg { transition: transform 150ms ease; }
.chev.open svg { transform: rotate(180deg); }
.row-stats { display: flex; align-items: center; gap: 14px; padding-left: 28px; flex-wrap: wrap; font: 400 var(--fs-12)/1 var(--font-ui); color: var(--text-3); }
.row-stats .meter { width: 200px; flex: 0 0 auto; }
.row-stats .speeds { display: flex; align-items: center; gap: 6px; flex-shrink: 0; font: 400 var(--fs-12)/1 var(--font-mono); color: var(--text-2); white-space: nowrap; }
.row-stats .live { width: 5px; height: 5px; border-radius: var(--radius-full); background: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.row-stats .push { margin-left: auto; }
.row-err { padding-left: 28px; font: 400 var(--fs-12)/1.4 var(--font-ui); color: var(--err); }

.files { display: flex; flex-direction: column; gap: 2px; padding: 6px 0 2px 28px; border-top: 1px solid var(--border-1); margin-top: 2px; animation: panel-in 180ms ease; }
.file { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: var(--radius-sm); }
.file.play { cursor: pointer; transition: background 120ms ease; }
.file.play:hover { background: var(--surface-hover); }
.file .name { font: 400 var(--fs-12)/1.3 var(--font-ui); color: var(--text-1); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file.dim .name { color: var(--text-3); }
.file .size { font: 400 var(--fs-11)/1 var(--font-mono); color: var(--text-3); flex-shrink: 0; }
.file .lead { width: 12px; display: flex; justify-content: center; flex-shrink: 0; color: var(--accent); }
.file .acts { display: flex; gap: 2px; flex-shrink: 0; }

.empty { padding: 40px 14px; text-align: center; font: 400 var(--fs-13)/1.5 var(--font-ui); color: var(--text-3); animation: fade-in 200ms ease; }

/* ---------- диалог ---------- */

.overlay { position: fixed; inset: 0; background: rgba(12, 12, 14, .4); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100; animation: fade-in 140ms ease; }
.dialog {
  width: min(560px, 100%);
  max-height: min(84vh, 640px);
  background: var(--surface-card);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: dialog-in 150ms ease;
}
.dialog-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border-1); }
.dialog-head .t { font: var(--text-section); font-family: var(--font-ui); color: var(--text-body); flex: 1; }
.dialog-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; overflow: hidden; flex: 1; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border-1); }

.picker-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.picker-top .name { font: 600 var(--fs-13)/1.3 var(--font-ui); color: var(--text-1); word-break: break-word; }
.picker-top .meta { font: 400 var(--fs-11)/1.4 var(--font-ui); color: var(--text-3); }
.crumbs { display: flex; align-items: center; gap: 6px; font: 400 var(--fs-11)/1 var(--font-mono); color: var(--text-3); overflow: hidden; }
.crumbs button { border: none; background: none; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
.crumbs button:hover { text-decoration: underline; }
.entries { display: flex; flex-direction: column; border-top: 1px solid var(--border-1); overflow-y: auto; flex: 1; min-height: 120px; }
.entry { display: flex; align-items: center; gap: 10px; padding: 7px 2px; border-bottom: 1px solid var(--border-1); transition: background 120ms ease; }
.entry:hover { background: var(--surface-hover); }
.entry .lead { color: var(--text-3); display: flex; flex-shrink: 0; }
.entry .name { font: 400 var(--fs-12)/1.3 var(--font-mono); color: var(--text-1); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry .name.dir { font-family: var(--font-ui); cursor: pointer; }
.entry .name.dir:hover { color: var(--accent); }
.entry .size { font: 400 var(--fs-11)/1 var(--font-ui); color: var(--text-3); flex-shrink: 0; }

/* Строки выдачи поиска по Рутрекеру: название в две строки, справа размер и сиды. */
.entry.result { cursor: pointer; padding: 8px 4px; min-height: 44px; }
.entry.result.busy { opacity: .45; pointer-events: none; }
.entry.result .result-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.entry.result .result-main .name { font-family: var(--font-ui); white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.entry.result .result-main .sub { font: 400 var(--fs-11)/1.3 var(--font-ui); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- плеер ---------- */

.player { position: fixed; inset: 0; background: var(--surface-app); display: flex; flex-direction: column; z-index: 50; animation: fade-in 160ms ease; }
.player-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border-1); flex-shrink: 0; }
.player-head .meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.player-head .up {
  font: 400 var(--fs-11)/1.3 var(--font-ui);
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-head .low { font: 600 var(--fs-13)/1.3 var(--font-ui); color: var(--text-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-head .right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.player-head .nav-btns { display: flex; gap: 4px; }
.player-body { flex: 1; display: flex; min-height: 0; }
.stage { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #0a0a0b; position: relative; }
.stage video { width: 100%; height: 100%; min-height: 0; flex: 1; background: #0a0a0b; }
.stage-note { flex: 1; display: grid; place-items: center; color: var(--text-3); font: 400 var(--fs-13)/1.5 var(--font-ui); }

.select {
  height: var(--control-h-md);
  max-width: 220px;
  padding: 0 8px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  background: var(--surface-card);
  color: var(--text-1);
  font: var(--text-label);
  font-family: var(--font-ui);
  cursor: pointer;
}
.select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.episodes { width: 280px; flex-shrink: 0; border-left: 1px solid var(--border-1); display: flex; flex-direction: column; overflow: hidden; }
.episodes .head { padding: 12px 14px; border-bottom: 1px solid var(--border-1); font: var(--text-section); font-family: var(--font-ui); color: var(--text-body); }
.episodes .list { flex: 1; overflow: auto; }
.ep { display: flex; align-items: center; gap: 10px; padding: 9px 14px; cursor: pointer; transition: background 120ms ease; }
.ep:hover { background: var(--surface-hover); }
.ep .num { font: 400 var(--fs-12)/1 var(--font-mono); color: var(--text-3); width: 20px; flex-shrink: 0; }
.ep .label { font: 400 var(--fs-13)/1.3 var(--font-ui); color: var(--text-1); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ep .tail { font: 400 var(--fs-11)/1 var(--font-mono); color: var(--text-3); flex-shrink: 0; }
.ep.active { background: var(--accent-soft); }
.ep.active .num { color: var(--accent); font-weight: 600; }
.ep.active .label { font-weight: 600; }
.ep.locked { opacity: .5; cursor: default; }
.ep.locked:hover { background: transparent; }

/* ---------- тост ---------- */

.toast-slot { position: fixed; right: 16px; bottom: 16px; z-index: 200; }
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 320px;
  padding: 12px 14px;
  background: var(--surface-card);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  animation: toast-in 180ms ease;
}
.toast .bar { width: 3px; align-self: stretch; border-radius: var(--radius-full); background: var(--ok); flex-shrink: 0; }
.toast.err .bar { background: var(--err); }
.toast.warn .bar { background: var(--warn); }
.toast .body { flex: 1; min-width: 0; }
.toast .t { font: 600 var(--fs-13)/1.3 var(--font-ui); color: var(--text-1); }
.toast .b { font: 400 var(--fs-12)/1.4 var(--font-ui); color: var(--text-muted); word-break: break-word; }

/* ---------- вход ---------- */

.login { display: grid; place-items: center; height: 100vh; padding: 20px; }
.login form { width: min(320px, 100%); padding: 24px; display: grid; gap: 12px; }
.login h1 { margin: 0; font: 700 var(--fs-16)/1 var(--font-ui); letter-spacing: -0.02em; color: var(--text-1); }
.login p { margin: 0; font: 400 var(--fs-12)/1.4 var(--font-ui); color: var(--text-3); }

/* ---------- шапка и нижняя панель узкого экрана ---------- */

.mhead, .bottombar { display: none; }
.brand-word { font: 700 17px/1 var(--font-ui); letter-spacing: -0.03em; color: var(--text-1); }
.tap { min-width: 44px; min-height: 44px; }
.btn.bar { width: 100%; height: 48px; font-size: var(--fs-13); }

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

@media (max-width: 720px) {
  .sidebar, .topbar, .desktop-only { display: none; }

  .shell { height: 100dvh; }
  .main { height: 100dvh; }

  .mhead {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
    padding: 12px 14px 10px;
    border-bottom: 1px solid var(--border-1);
  }
  .mhead-top { display: flex; align-items: center; gap: 8px; }
  .mhead-top .icon-btn { margin-left: auto; margin-right: -6px; }

  .strip {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 9px 12px;
    background: var(--surface-raised);
    border: 1px solid var(--border-1);
    border-radius: var(--radius-md);
  }
  .strip .cell { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
  .strip .cap { display: flex; align-items: center; gap: 5px; font: 400 var(--fs-11)/1 var(--font-ui); color: var(--text-3); }
  .strip .val { font: 500 var(--fs-13)/1 var(--font-mono); color: var(--text-1); }
  .strip svg { margin-left: auto; flex-shrink: 0; }
  .disk-line { font: 400 var(--fs-11)/1.3 var(--font-ui); color: var(--text-3); }

  .content { flex: 1; min-height: 0; padding: 0; display: flex; flex-direction: column; }
  .stack { max-width: none; gap: 0; flex: 1; min-height: 0; }

  /* Вкладки прокручиваются вбок, чтобы влезли все четыре. */
  .tabs {
    flex-shrink: 0;
    padding: 6px 14px 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { flex-shrink: 0; }

  /* Список задач — карточки, а не строки таблицы. */
  #list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px 96px;
    background: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    -webkit-overflow-scrolling: touch;
  }
  .row {
    display: flex;
    flex-direction: column;
    /* Обязательно сбросить центрирование от десктопной сетки: иначе блоки
       не растягиваются по карточке, а берут ширину по содержимому — длинные
       имена файлов вылезают за края с обеих сторон. */
    align-items: stretch;
    /* #list — прокручиваемая flex-колонка. Без запрета сжатия карточки
       ужимаются ниже своего содержимого, и overflow:hidden срезает кнопки;
       flex-shrink:0 заставляет список прокручиваться, а не давить карточки. */
    flex: none;
    gap: 9px;
    padding: 12px;
    overflow: hidden;
    background: var(--surface-card);
    border: 1px solid var(--border-1);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
  }
  .row-head { flex-wrap: wrap; }
  .row-head .chev, .row-head .badge.state-first { order: 2; }
  .row-head .title { flex: 1 0 100%; font-size: 15px; line-height: 1.25; white-space: normal; text-wrap: pretty; }
  .row-stats { order: 2; padding-left: 0; gap: 8px 10px; }
  .row-stats .meter { width: 100%; flex: 1 0 100%; }
  .row-stats .push { margin-left: auto; }
  .row-actions { order: 3; grid-column: auto; grid-row: auto; padding-top: 2px; gap: 8px; }
  .row-actions .btn { height: 44px; padding: 0 18px; font-size: var(--fs-13); }
  .row-actions .icon-btn { width: 44px; height: 44px; }
  .row-err, .files { order: 4; }
  .files { padding-left: 0; }
  .file { min-height: 44px; padding: 6px 4px; }
  .file .name { font-size: var(--fs-13); }
  .file .acts .icon-btn { width: 40px; height: 40px; }

  .bottombar {
    display: block;
    flex-shrink: 0;
    padding: 10px 14px calc(14px + env(safe-area-inset-bottom));
    background: var(--surface-app);
    border-top: 1px solid var(--border-1);
  }

  /* Диалоги превращаются в шторку снизу. */
  .overlay { align-items: flex-end; padding: 0; }
  .dialog {
    width: 100%;
    max-height: 88dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: none;
    animation: sheet-in 180ms ease;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .dialog-head { padding: 12px 12px 10px 14px; }
  .dialog-head .icon-btn { width: 44px; height: 44px; }
  .entry { min-height: 44px; padding: 8px 2px; }
  .entry .name { font-size: var(--fs-13); }
  .dialog-foot { flex-wrap: wrap; padding: 10px 14px 16px; }
  .dialog-foot .btn { flex: 1; height: 48px; }
  .dialog-foot .meta { flex: 1 0 100%; margin: 0 0 4px; }

  .toast-slot { left: 14px; right: 14px; bottom: 82px; }
  .toast { width: auto; }

  /* Плеер: видео фиксированной пропорции, крупные кнопки, серии снизу. */
  .player-body { flex-direction: column; }
  .stage { flex: 0 0 auto; }
  .stage video { aspect-ratio: 16 / 9; height: auto; flex: none; }
  .stage-note { min-height: 180px; }
  .episodes { display: flex; width: auto; flex: 1; min-height: 0; border-left: none; border-top: 1px solid var(--border-1); }
  .ep { min-height: 48px; padding: 8px 14px; border-bottom: 1px solid var(--border-1); }
  .player-head .icon-btn { width: 44px; height: 44px; }
  .player-head .select { max-width: 150px; height: 44px; }
}

@keyframes sheet-in { from { transform: translateY(14px); } to { transform: none; } }

/* ---------- Google Drive ---------- */

/* Код device flow: его переписывают с экрана, поэтому крупно и вразрядку. */
.devcode {
  align-self: center;
  padding: 10px 18px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: var(--text-1);
  font: 600 22px/1 var(--font-mono);
  letter-spacing: .18em;
}

/* Бейдж Drive кликабельный: это переключатель, а не подпись. */
button.badge {
  border: none;
  cursor: pointer;
  font: 500 var(--fs-11)/1 var(--font-ui);
}
button.badge:hover { background: var(--surface-hover); }
button.badge.ok:hover { background: var(--ok-soft); }
button.badge.err:hover { background: var(--err-soft); }
button.badge:focus-visible { outline: none; box-shadow: var(--focus-ring); }
