:root {
  --bg: #0f1115;
  --card: #181b22;
  --card-off: #14171d;
  --border: #262a33;
  --text: #e8eaee;
  --text-off: #b8beca;
  --muted: #8b93a1;
  --accent: #2f6df6;
  --badge-bg: #2a2f3a;
  --badge-text: #9aa3b2;
  --error: #ff8a8a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}
#app { max-width: 880px; margin: 0 auto; padding: 24px 16px 48px; }
h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.noscript { padding: 24px 16px; text-align: center; color: var(--muted); }

/* Шапка */
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.link-btn {
  background: none; border: 0; padding: 6px 4px; color: var(--muted);
  font: inherit; font-size: 14px; cursor: pointer;
}
.link-btn:hover { color: var(--text); }

/* Плитки */
.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;
}
.tile {
  display: flex; flex-direction: column; gap: 6px; height: 100%; min-height: 128px; padding: 18px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  color: inherit; text-decoration: none;
}
.tile-title { font-size: 17px; font-weight: 600; }
.tile-desc { font-size: 14px; color: var(--muted); }
.badge {
  align-self: flex-start; margin-top: auto; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--badge-bg); color: var(--badge-text);
}
.tile.live { border-color: var(--accent); }
.tile.live .badge { background: var(--accent); color: #fff; }
.tile.off { background: var(--card-off); }
.tile.off .tile-title { color: var(--text-off); }
@media (prefers-reduced-motion: no-preference) {
  .tile.live { transition: transform 0.15s ease, box-shadow 0.15s ease; }
  .tile.live:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(47, 109, 246, 0.18); }
}

/* Вход */
.center { min-height: 80vh; display: grid; place-items: center; }
.card {
  width: 100%; max-width: 360px; padding: 28px 24px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
}
.login { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.field input {
  padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
}
.field input:focus { border-color: var(--accent); outline: none; }
.btn {
  padding: 11px 16px; font: inherit; font-weight: 600; color: #fff;
  background: var(--accent); border: 0; border-radius: 8px; cursor: pointer;
}
.btn:hover:not(:disabled) { filter: brightness(1.1); }
.btn:disabled { opacity: 0.6; cursor: default; }
.form-error { min-height: 1.5em; font-size: 14px; color: var(--error); }

@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  #app { padding-top: 16px; }
}

/* ---- Нарезка под рилсы ---- */
[hidden] { display: none !important; }
a.link-btn { text-decoration: none; }
#app { max-width: 960px; }
.topbar-left { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.topbar-right { display: flex; gap: 6px; align-items: center; }
.back { color: var(--muted); text-decoration: none; font-size: 14px; }
.back:hover { color: var(--text); }
h2 { margin: 0 0 12px; font-size: 17px; font-weight: 600; }
.panel {
  padding: 20px; margin-bottom: 20px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
}
.stack { display: flex; flex-direction: column; gap: 16px; }
.tabs { display: flex; gap: 6px; }
.tab {
  padding: 7px 14px; font: inherit; font-size: 14px; color: var(--muted);
  background: var(--bg); border: 1px solid var(--border); border-radius: 999px; cursor: pointer;
}
.tab[aria-pressed="true"] { color: #fff; background: var(--accent); border-color: var(--accent); }
.field input[type="url"], .field input[type="text"], .field select, .field textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
}
.field textarea { min-height: 70px; resize: vertical; }
.field select:focus, .field textarea:focus { border-color: var(--accent); outline: none; }
.row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 14px; }
.checks label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.drop {
  display: grid; place-items: center; min-height: 110px; padding: 16px; text-align: center;
  border: 1px dashed var(--border); border-radius: 10px; color: var(--muted); font-size: 14px; cursor: pointer;
}
.drop.over, .drop:hover { border-color: var(--accent); color: var(--text); }
.hint { font-size: 13px; color: var(--muted); }
.bar { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }

.jobs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.job {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center;
  padding: 14px 16px; background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  color: inherit; text-decoration: none;
}
.job:hover { border-color: var(--accent); }
.job-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-meta { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
.job .bar { grid-column: 1 / -1; }
.status { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--badge-bg); color: var(--badge-text); }
.status.done { background: #17391f; color: #7ee29a; }
.status.error { background: #3a1a1a; color: var(--error); }
.status.running { background: var(--accent); color: #fff; }

.steps { list-style: none; margin: 12px 0 0; padding: 0; font-size: 14px; color: var(--muted); }
.steps li { padding: 3px 0; }
.steps li.done { color: var(--text); }
.steps li.done::before { content: "✓ "; color: #7ee29a; }
.steps li.now { color: var(--text); font-weight: 600; }
.steps li.now::before { content: "▸ "; color: var(--accent); }
.steps li.wait::before { content: "· "; }
.error-box { padding: 12px 14px; border-radius: 8px; background: #2a1414; color: var(--error); font-size: 14px;
  white-space: pre-wrap; word-break: break-word; }

.clips { list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.clip { display: flex; flex-direction: column; gap: 8px; padding: 10px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.clip video { width: 100%; aspect-ratio: 9 / 16; background: #000; border-radius: 8px; }
.clip-title { font-weight: 600; font-size: 15px; line-height: 1.3; }
.clip-hook { font-size: 13px; color: var(--muted); }
.clip-wisdom { font-size: 14px; font-style: italic; border-left: 3px solid var(--accent, currentColor); padding-left: 8px; }
.clip-meta { font-size: 12px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-ghost {
  padding: 8px 12px; font: inherit; font-size: 14px; color: var(--text); text-decoration: none;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
.btn-ghost:hover { border-color: var(--accent); }
.btn-ghost.danger:hover { border-color: var(--error); color: var(--error); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.ok { color: #7ee29a; }
.bad { color: var(--error); }
.empty { color: var(--muted); font-size: 14px; }

@media (max-width: 560px) {
  .row { grid-template-columns: 1fr; }
  .clips { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
}

/* ---- разделы, загрузка, транскрибация ---- */
.topbar-right { flex-wrap: wrap; justify-content: flex-end; }
.nav-link {
  padding: 6px 12px; border-radius: 999px; font-size: 14px; color: var(--muted); text-decoration: none;
  border: 1px solid transparent;
}
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--text); border-color: var(--border); background: var(--card); }
.upload-box { gap: 8px; }
.transcript {
  margin: 0; max-height: 420px; overflow: auto; padding: 14px 16px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  font: 15px/1.6 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--text);
  white-space: pre-wrap; word-break: break-word;
}
.analyses { display: flex; flex-direction: column; gap: 12px; margin-bottom: 8px; }
.analysis { padding: 16px 18px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.analysis-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.analysis-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.analysis .actions { margin-top: 12px; }
.analysis .error-box { margin-top: 10px; }
.md { margin-top: 10px; line-height: 1.6; }
.md h2 { font-size: 20px; margin: 14px 0 8px; }
.md h3 { font-size: 17px; margin: 14px 0 6px; }
.md h4, .md h5 { font-size: 15px; margin: 12px 0 4px; }
.md p { margin: 8px 0; }
.md ul, .md ol { margin: 6px 0; padding-left: 22px; }
.md li { margin: 3px 0; }
.md .checks-list { list-style: none; padding-left: 4px; }
.md blockquote { margin: 10px 0; padding: 4px 12px; border-left: 3px solid var(--accent); color: var(--text-off); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.md code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }
@media (max-width: 560px) {
  header.topbar { flex-direction: column; align-items: flex-start; gap: 10px; }
  header.topbar .topbar-right { justify-content: flex-start; margin-left: -12px; }
}
