/* ============================================================
   HeyDub — дизайн-система в стиле monday.com
   Светлая тема в :root, тёмная в [data-theme="dark"].
   ============================================================ */
:root {
  --bg:        #f6f7fb;
  --bg-grad:   none;
  --surface:   #ffffff;
  --surface-2: #f3f4f8;
  --elevated:  #ffffff;
  --line:      #e3e6ee;
  --line-2:    #d3d7e3;
  --text:      #323338;
  --muted:     #676879;
  --faint:     #9699a6;

  --brand:     #ec7211;
  --brand-2:   #ff9900;
  --brand-grad: linear-gradient(135deg, #ff9900 0%, #ec7211 100%);
  --accent:    #0972d3;
  --yt:        #ff3b3b;
  --appbar:    #232f3e;
  --appbar-2:  #131a22;
  --appbar-h:  56px;

  --ok:    #00c875;
  --info:  #0086c0;
  --warn:  #fdab3d;
  --err:   #e2445c;
  --skip:  #9699a6;

  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;
  --sidebar: 248px;
  --maxw: 1000px;
  --shadow:    0 8px 24px rgba(29, 33, 64, .10);
  --shadow-sm: 0 1px 4px rgba(29, 33, 64, .08);
  --on-accent: #ffffff;
}

[data-theme="dark"] {
  --bg:        #11131c;
  --bg-grad:   radial-gradient(1100px 500px at 85% -10%, rgba(97,97,255,.10), transparent 60%);
  --surface:   #1c1f2b;
  --surface-2: #242838;
  --elevated:  #2a2f42;
  --line:      rgba(255, 255, 255, .08);
  --line-2:    rgba(255, 255, 255, .15);
  --text:      #e8eaf2;
  --muted:     #99a0b3;
  --faint:     #6a7088;
  --shadow:    0 10px 30px rgba(0, 0, 0, .40);
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg-grad), var(--bg);
  color: var(--text);
  font-family: "Figtree", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ---------- App bar (Amazon-style top header) ---------- */
.appbar {
  position: sticky; top: 0; z-index: 40; height: var(--appbar-h);
  display: flex; align-items: center; gap: 14px; padding: 0 18px;
  background: var(--appbar); color: #fff;
  border-bottom: 1px solid var(--appbar-2);
}
.appbar .brand { padding: 0; }
.appbar .brand .title, .appbar .brand .title span { color: #fff; }
.appbar .brand .title span { color: #ff9900; }
.appbar .spacer { flex: 1; }
.appbar .theme-toggle { width: auto; margin: 0; padding: 7px 12px;
  background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.18); color: #fff; }
.appbar .theme-toggle:hover { background: rgba(255,255,255,.15); }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: calc(100vh - var(--appbar-h)); }

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky; top: var(--appbar-h); height: calc(100vh - var(--appbar-h));
  display: flex; flex-direction: column;
  padding: 16px 14px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand .mark {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 34px;
  background: var(--brand-grad); display: grid; place-items: center;
  box-shadow: 0 4px 12px rgba(236,114,17,.4);
}
.brand .mark svg { width: 19px; height: 19px; fill: #fff; }
.brand .title { font-weight: 800; font-size: 15px; letter-spacing: -.02em; line-height: 1.1; }
.brand .title span { display: block; font-weight: 500; font-size: 11px; color: var(--muted); letter-spacing: .01em; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav .label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--faint); padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--muted); font-weight: 600; font-size: 14px;
  transition: background .15s, color .15s;
}
.nav a svg { width: 19px; height: 19px; fill: currentColor; flex: 0 0 19px; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }
.nav a.active svg { fill: var(--brand); }
.nav a .soon { margin-left: auto; font-size: 10px; font-weight: 700; color: var(--faint);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 7px; }

.side-foot { margin-top: auto; padding: 12px 6px 4px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.conn { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); padding: 4px 6px; }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--err); box-shadow: 0 0 0 3px color-mix(in srgb, var(--err) 18%, transparent); }
.conn .dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); }

/* тема */
.theme-toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; margin: 6px 0 10px;
  padding: 9px 12px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface-2);
  color: var(--text); font: inherit; font-size: 13px; font-weight: 600; width: 100%; transition: background .15s; }
.theme-toggle:hover { background: var(--line); }
.theme-toggle svg { width: 17px; height: 17px; fill: currentColor; }
.theme-toggle .moon { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: inline; }
[data-theme="dark"] .theme-toggle .sun { display: none; }

/* ---------- Main ---------- */
.main { min-width: 0; }
.inner { max-width: none; margin: 0; padding: 22px 32px 80px; }

.topbar {
  position: sticky; top: var(--appbar-h); z-index: 20;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  border-bottom: 1px solid var(--line);
}
.topbar .row { max-width: none; margin: 0; padding: 18px 32px;
  display: flex; align-items: center; gap: 16px; }
.topbar h1 { font-size: 23px; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.topbar .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.topbar .next-pub { margin-top: 6px; color: var(--text); }
.topbar .next-pub b { color: var(--brand); }
.topbar .next-pub .dim { color: var(--faint); }
.topbar .spacer { flex: 1; }
.refresh-note { font-size: 12px; color: var(--faint); display: flex; align-items: center; gap: 6px; }
.refresh-note .live { width: 7px; height: 7px; border-radius: 50%; background: var(--ok);
  animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: 0; font-family: inherit; font-weight: 700; font-size: 14px;
  padding: 10px 18px; border-radius: var(--r-sm); transition: transform .08s, filter .15s, background .15s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(236,114,17,.3); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn svg { width: 17px; height: 17px; fill: currentColor; }
form.inline { display: inline; margin: 0; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin: 24px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px 18px; position: relative; overflow: hidden; box-shadow: var(--shadow-sm); }
.stat::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; opacity: .95; }
.stat .n { font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.stat .l { font-size: 12px; color: var(--muted); margin-top: 6px; }
.stat.t-all::after  { background: var(--brand); }
.stat.t-ok::after   { background: var(--ok); }
.stat.t-info::after { background: var(--info); }
.stat.t-warn::after { background: var(--warn); }
.stat.t-err::after  { background: var(--err); }
.stat.t-ok .n   { color: var(--ok); }
.stat.t-info .n { color: var(--info); }
.stat.t-warn .n { color: var(--warn); }
.stat.t-err .n  { color: var(--err); }

/* ---------- Warning ---------- */
.warn-box { display: flex; gap: 12px; align-items: flex-start;
  background: color-mix(in srgb, var(--warn) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); color: var(--text);
  border-radius: var(--r); padding: 14px 16px; margin-bottom: 24px; font-size: 14px; }
.warn-box code { background: color-mix(in srgb, var(--text) 8%, transparent); padding: 1px 6px; border-radius: 5px; }

/* ---------- Section header ---------- */
.section-h { display: flex; align-items: center; gap: 10px; margin: 4px 0 14px; }
.section-h h2 { font-size: 16px; font-weight: 800; margin: 0; }
.section-h .count { font-size: 13px; color: var(--muted); }

/* ---------- Feed ---------- */
.feed { display: flex; flex-direction: column; gap: 12px; }
.card {
  display: flex; gap: 16px; padding: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, transform .12s, box-shadow .15s;
}
.card:hover { border-color: var(--line-2); transform: translateY(-1px); box-shadow: var(--shadow); }

.thumb { position: relative; flex: 0 0 168px; width: 168px; aspect-ratio: 16/9;
  border-radius: 10px; overflow: hidden; background: #0a0d14; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .play { position: absolute; inset: 0; display: grid; place-items: center;
  background: linear-gradient(180deg, transparent 40%, rgba(0,0,0,.45)); }
.thumb .play svg { width: 34px; height: 34px; fill: #fff; opacity: .92;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.5)); }
.thumb.player { background: #000; }
.thumb.player video { width: 100%; height: 100%; object-fit: contain; display: block; }
.thumb .en-tag { position: absolute; top: 6px; left: 6px; z-index: 2;
  background: var(--ok); color: #04130b; font-size: 10px; font-weight: 800;
  padding: 2px 7px; border-radius: 6px; letter-spacing: .04em; }

.card .body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.card .head { display: flex; align-items: flex-start; gap: 10px; }
.card .vtitle { font-size: 15.5px; font-weight: 700; letter-spacing: -.01em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .vtitle:hover { color: var(--brand); }
.card .meta { font-size: 12.5px; color: var(--muted); margin-top: 5px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card .meta .src { display: inline-flex; align-items: center; gap: 5px; }
.card .meta .src svg { width: 14px; height: 14px; fill: var(--yt); }
.card .meta .pl-time { color: var(--brand); font-weight: 700; }
.card .err { margin-top: 8px; font-size: 13px; color: var(--err);
  background: color-mix(in srgb, var(--err) 10%, transparent); border: 1px solid color-mix(in srgb, var(--err) 28%, transparent);
  border-radius: 10px; padding: 8px 10px; }
.card .foot { margin-top: auto; padding-top: 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* сгенерированные GPT метаданные */
.gen { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.gen-block { background: color-mix(in srgb, var(--brand) 7%, var(--surface)); border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent);
  border-radius: 10px; padding: 9px 11px; }
.gen-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.gen-label { font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--brand); }
.copy { background: var(--surface); border: 1px solid var(--line-2); color: var(--muted);
  border-radius: 999px; padding: 3px 10px; font-size: 11px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: all .12s; }
.copy:hover { background: var(--surface-2); color: var(--text); }
.copy.done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, transparent); }
.gen-title { font-size: 14px; font-weight: 600; }
.gen-desc { font-size: 13px; color: var(--muted); white-space: pre-wrap; }

/* ---------- Badge ---------- */
.badges { margin-left: auto; display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.badge { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto;
  padding: 5px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 700;
  border: 1px solid transparent; white-space: nowrap; text-decoration: none; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.b-done       { color: var(--ok);   background: color-mix(in srgb, var(--ok) 14%, var(--surface));  border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.b-processing,
.b-submitting { color: var(--info); background: color-mix(in srgb, var(--info) 14%, var(--surface)); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.b-processing::before { animation: pulse 1.4s infinite; }
.b-new        { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, var(--surface)); border-color: color-mix(in srgb, var(--warn) 38%, transparent); }
.b-failed     { color: var(--err);  background: color-mix(in srgb, var(--err) 12%, var(--surface));  border-color: color-mix(in srgb, var(--err) 35%, transparent); }
.b-skipped    { color: var(--skip); background: color-mix(in srgb, var(--skip) 14%, var(--surface)); border-color: color-mix(in srgb, var(--skip) 35%, transparent); }
.b-pub        { color: var(--yt);   background: color-mix(in srgb, var(--yt) 12%, var(--surface));   border-color: color-mix(in srgb, var(--yt) 38%, transparent); }
.b-unpub      { color: var(--faint); background: var(--surface-2); border-color: var(--line-2); }

/* action chips */
.chip { display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 600;
  font-family: inherit; transition: background .12s; }
.chip:hover { background: var(--surface-2); }
.chip svg { width: 15px; height: 15px; fill: currentColor; }
.chip.dl { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.chip.dl:hover { background: color-mix(in srgb, var(--ok) 12%, transparent); }
.chip.yt { color: var(--yt); border-color: color-mix(in srgb, var(--yt) 45%, transparent); }
.chip.yt:hover { background: color-mix(in srgb, var(--yt) 12%, transparent); }
.chip.pub { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 50%, transparent); }
.chip.pub:hover { background: color-mix(in srgb, var(--brand) 12%, transparent); }
.chip.soc { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.chip.soc:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.chip.soc-done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); cursor: default; }

/* выбор соцсетей в настройках */
.net-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.net-item { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-sm); position: relative; }
.net-item input { position: absolute; top: 12px; right: 12px; }
.net-item.off { opacity: .55; cursor: not-allowed; }
.net-name { font-weight: 700; font-size: 14px; }
.net-status { font-size: 11px; color: var(--muted); }
@media (max-width: 820px) { .net-grid { grid-template-columns: 1fr; } }

/* ---------- Доска (monday board) ---------- */
.board { display: flex; flex-direction: column; gap: 16px; }
.grp { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-sm); overflow: hidden; border-left: 4px solid var(--gc); }
.grp > .grp-h { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; font-weight: 800; color: var(--gc); }
.grp > .grp-h::-webkit-details-marker { display: none; }
.grp-h .chev { width: 15px; height: 15px; fill: var(--gc); transition: transform .15s; }
.grp[open] > .grp-h .chev { transform: rotate(90deg); }
.grp-name { font-size: 15px; }
.grp-n { font-size: 12px; font-weight: 700; color: var(--muted); background: var(--surface-2);
  border-radius: 999px; padding: 1px 9px; }
.grp-stat { font-size: 12px; font-weight: 700; color: var(--text); background: var(--surface-2);
  border-radius: 999px; padding: 1px 9px; }
.grp-stat:last-child { color: var(--brand); }
.grp-chan { font-size: 12px; font-weight: 700; color: var(--ok); text-decoration: none;
  background: color-mix(in srgb, var(--ok) 12%, transparent); border-radius: 999px; padding: 1px 10px; }
.grp-chan:hover { text-decoration: underline; }
.grp-chan-off { color: var(--muted); background: var(--surface-2); font-weight: 600; }

.cols { display: grid; grid-template-columns: minmax(0,1fr) 150px 150px 160px 38px; gap: 12px;
  padding: 7px 16px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--faint); border-top: 1px solid var(--line); background: var(--surface-2); }
.cols span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.brow { border-top: 1px solid var(--line); }
.brow > .rsum { list-style: none; cursor: pointer; display: grid;
  grid-template-columns: minmax(0,1fr) 150px 150px 160px 38px; gap: 12px; align-items: center;
  padding: 9px 16px; transition: background .12s; }
.brow > .rsum::-webkit-details-marker { display: none; }
.brow > .rsum:hover { background: var(--surface-2); }
.c { min-width: 0; }
.c-title { display: flex; align-items: center; gap: 11px; }
.rthumb { width: 50px; height: 30px; border-radius: 6px; overflow: hidden; flex: 0 0 50px; background: #0a0d14; }
.rthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rttl { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scell { display: block; width: 100%; text-align: center; color: #fff; font-weight: 700; font-size: 12.5px;
  padding: 6px 8px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scell-ghost { background: var(--surface-2) !important; color: var(--muted); border: 1px dashed var(--line-2); }
.c-pub .dash { color: var(--faint); }
.c-date { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.c-date b { color: var(--text); font-weight: 700; }
.c-exp { display: flex; justify-content: flex-end; }
.c-exp .chev { width: 15px; height: 15px; fill: var(--faint); transition: transform .15s; }
.brow[open] > .rsum .c-exp .chev { transform: rotate(90deg); }

.rbody { display: grid; grid-template-columns: 240px 1fr; gap: 18px; padding: 4px 16px 18px; }
.rbody .thumb { flex: none; width: 100%; }
.rb-info { min-width: 0; display: flex; flex-direction: column; }
.rb-info .foot { margin-top: 12px; padding-top: 0; }

@media (max-width: 820px) {
  .cols { display: none; }
  .brow > .rsum { grid-template-columns: 1fr auto auto; gap: 8px; }
  .brow > .rsum .c-pub, .brow > .rsum .c-date { display: none; }
  .rbody { grid-template-columns: 1fr; }
  .rbody .thumb { max-width: 240px; }
}

/* ---------- Мультфильмы ---------- */
.newseries, .newep { display: flex; gap: 8px; align-items: center; }
.newseries input, .newep input, .newep select {
  background: var(--surface); color: var(--text); border: 1px solid var(--line-2);
  border-radius: var(--r-sm); padding: 9px 12px; font: inherit; }
.newseries input { width: 200px; }
.newep { padding: 12px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.newep input { flex: 1; min-width: 160px; }

.ep-list { display: flex; flex-direction: column; }
.ep { display: flex; flex-direction: column; gap: 10px; padding: 13px 16px; border-top: 1px solid var(--line); }
.ep-row { display: flex; align-items: center; gap: 18px; }
.ep-main { min-width: 180px; flex: 1 1 auto; }
.ep-title { font-weight: 700; font-size: 14px; }
.ep-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.ep-yt { font-size: 12.5px; font-weight: 600; color: var(--brand); margin-top: 3px; }
.ep-cost { flex: 0 0 118px; display: flex; flex-direction: column;
  align-items: flex-end; gap: 1px; white-space: nowrap; text-align: right; }
.ep-cost-sum { font-weight: 800; font-size: 14px; color: var(--text); }
.ep-cost-sub { font-size: 11px; color: var(--muted); }
.ep-build { flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.ep-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ep-prog { display: inline-flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 13px;
  font-weight: 600; color: var(--muted); }
.ep-prog.run { color: var(--brand); }
.ep-prog .spin { width: 13px; height: 13px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--brand) 30%, transparent);
  border-top-color: var(--brand); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ep-when { flex: 0 0 150px; display: flex; flex-direction: column; align-items: flex-end;
  gap: 1px; white-space: nowrap; }
.ep-when-sum { font-weight: 700; font-size: 13px; color: var(--text); }
.ep-when-sub { font-size: 11px; color: var(--muted); }
.ep-when-pub { font-weight: 700; font-size: 13px; color: var(--ok); }
@media (max-width: 820px) {
  .ep-when { align-items: flex-start; text-align: left; padding: 2px 0; flex-direction: row; gap: 8px; }
}
.ep-empty { padding: 14px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

.stepper { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.stepper.mini { margin-left: 0; gap: 5px; }
.stepper.mini .step { padding: 3px 9px; font-size: 11px; }
.stepper.mini .step-dot { width: 6px; height: 6px; }
.step { display: flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); }
.step-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.step.s-done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.step.s-active { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 45%, transparent); }
.step.s-active .step-dot { animation: pulse 1.4s infinite; }
.step.s-error { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, transparent); }
@media (max-width: 820px) {
  .ep-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .stepper { margin-left: 0; }
  /* в колоночном режиме фикс-ширина не должна превращаться в высоту */
  .ep-cost, .ep-when, .ep-build { flex: 0 0 auto; align-items: flex-start; justify-content: flex-start; text-align: left; }
  .ep-cost { flex-direction: row; gap: 8px; }
  .newseries input { width: 140px; }
}

/* ---------- Страница эпизода ---------- */
.ep-title { color: var(--text); }
a.ep-title:hover { color: var(--brand); }
.concept-form textarea { width: 100%; background: var(--surface); color: var(--text);
  border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 11px 13px; font: inherit; resize: vertical; }
.concept-form .row-actions { display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.kv { font-size: 14px; margin-bottom: 6px; }
.kv.muted { color: var(--muted); }
.scenes { display: flex; flex-direction: column; gap: 10px; }
.scene { display: flex; gap: 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 14px; box-shadow: var(--shadow-sm); }
.scene-no { flex: 0 0 56px; font-weight: 800; font-size: 18px; color: var(--brand);
  display: flex; flex-direction: column; align-items: center; }
.scene-no span { font-size: 11px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.scene-body { min-width: 0; flex: 1; }
.scene-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.scene-tags .tag { font-size: 12px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 10px; color: var(--muted); }
.scene-vis { font-size: 13.5px; }
.scene-line { margin-top: 8px; font-size: 13.5px; color: var(--accent); font-weight: 600; }
.scene-frame { width: 90px; height: 135px; object-fit: cover; border-radius: 8px; flex: 0 0 90px;
  background: var(--surface-2); border: 1px solid var(--line); }
.media-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.series-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 14px; align-items: start; }
.series-grid .set-card { max-width: none; }
.avatar-img { width: 100%; max-width: 280px; border-radius: var(--r); border: 1px solid var(--line); aspect-ratio: 2/3; object-fit: cover; }
.avatar-empty { width: 100%; max-width: 280px; aspect-ratio: 2/3; border: 1px dashed var(--line-2);
  border-radius: var(--r); display: grid; place-items: center; color: var(--muted); font-size: 13px; background: var(--surface-2); }
.avatar-mini { width: 80px; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); flex: 0 0 80px; }
.ref-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.ref-item { margin: 0; }
.ref-item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); }
.ref-item figcaption { text-align: center; font-size: 11px; color: var(--muted); margin-top: 3px; }
.field textarea { width: 100%; background: var(--surface); color: var(--text); border: 1px solid var(--line-2);
  border-radius: var(--r-sm); padding: 10px 12px; font: inherit; resize: vertical; }
.field input[type="text"], .field input:not([type]) { width: 100%; background: var(--surface); color: var(--text);
  border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 10px 12px; font: inherit; }
@media (max-width: 820px) { .series-grid { grid-template-columns: 1fr; } }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 70px 24px; color: var(--muted); }
.empty .ico { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 18px;
  background: var(--surface); border: 1px solid var(--line); display: grid; place-items: center; box-shadow: var(--shadow-sm); }
.empty .ico svg { width: 30px; height: 30px; fill: var(--faint); }
.empty .big { font-size: 20px; font-weight: 800; color: var(--text); margin-bottom: 6px; }

/* ---------- Settings ---------- */
.settings { display: flex; flex-direction: column; gap: 16px; max-width: 660px; margin-top: 24px; }
.set-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; box-shadow: var(--shadow-sm); }
.set-head h2 { font-size: 16px; margin: 0 0 4px; }
.set-head p { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 0; border-top: 1px solid var(--line); }
.toggle-row span small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; font-weight: 400; }
.field { padding: 16px 0 4px; border-top: 1px solid var(--line); }
.field label { display: block; margin-bottom: 8px; }
.field select, .field input[type="number"] { width: 100%; background: var(--surface); color: var(--text);
  border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 10px 12px; font: inherit; }
.field .hint { display: block; margin-top: 8px; color: var(--muted); font-size: 12px; }
.set-card .btn { margin-top: 18px; }
.conn-line { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.conn-line code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: 12px; }
.time-range { display: flex; align-items: center; gap: 8px; }
.time-range input { width: 90px; background: var(--surface); color: var(--text);
  border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 10px 12px; font: inherit; }
.time-range span { color: var(--muted); font-size: 14px; }
.plan-status { display: flex; flex-wrap: wrap; gap: 18px; margin: 4px 0 8px; padding: 12px 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm);
  font-size: 13px; color: var(--muted); }
.plan-status b { color: var(--text); }

/* switch */
.switch { position: relative; width: 48px; height: 28px; flex: 0 0 48px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; cursor: pointer; background: var(--line-2);
  border-radius: 999px; transition: .2s; }
.switch .slider::before { content: ""; position: absolute; height: 20px; width: 20px; left: 4px; top: 4px;
  background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ---------- Диапазоны дат ---------- */
.ranges { margin-left: auto; display: inline-flex; gap: 4px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.ranges a { padding: 5px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 700;
  color: var(--muted); }
.ranges a:hover { color: var(--text); }
.ranges a.on { background: var(--brand); color: #fff; }

/* ---------- График по дням ---------- */
.chart-panel { margin-bottom: 14px; }
.chart { display: flex; align-items: flex-end; gap: 2px; height: 160px; }
.cbar { flex: 1; height: 100%; display: flex; align-items: flex-end; min-width: 2px; }
.cbar-fill { display: block; width: 100%; background: var(--brand-grad); border-radius: 3px 3px 0 0;
  min-height: 2px; transition: opacity .12s; }
.cbar:hover .cbar-fill { opacity: .65; }
.chart-x { display: flex; justify-content: space-between; margin-top: 8px;
  font-size: 11px; color: var(--faint); }

/* ---------- Панели аналитики ---------- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 8px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.panel-h { font-size: 13px; font-weight: 800; color: var(--muted); margin-bottom: 14px;
  text-transform: uppercase; letter-spacing: .04em; }
.bar { display: grid; grid-template-columns: 130px 1fr 64px; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar:last-child { margin-bottom: 0; }
.bar-l { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--brand-grad); border-radius: 999px; }
.bar-v { text-align: right; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.muted-row { color: var(--muted); font-size: 13px; }

/* ---------- Таблица аналитики ---------- */
.atable { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow-sm); }
.atrow { display: grid; grid-template-columns: 1fr 130px 110px 130px; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--text); background: var(--surface); transition: background .12s; }
.atrow:last-child { border-bottom: 0; }
.atrow:not(.ahead):hover { background: var(--surface-2); }
.ahead { background: var(--surface-2); color: var(--muted); font-size: 12px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.acol-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.acol-title img { width: 64px; height: 36px; object-fit: cover; border-radius: 6px; flex: 0 0 64px; background:#000; }
.atitle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 14px; }
.acol-num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---------- Toast ---------- */
#toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--elevated); color: var(--text); border: 1px solid var(--line-2);
  border-radius: 999px; padding: 12px 22px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .25s; z-index: 100; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.ok { border-color: color-mix(in srgb, var(--ok) 50%, transparent); }
#toast.err { border-color: color-mix(in srgb, var(--err) 50%, transparent); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center;
    overflow-x: auto; padding: 10px 14px; }
  .sidebar .nav { flex-direction: row; }
  .sidebar .nav .label, .side-foot, .brand .title span { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .thumb { flex-basis: 120px; width: 120px; }
  .atrow { grid-template-columns: 1fr 70px 60px 70px; padding: 10px; }
  .acol-title img { display: none; }
  .bar { grid-template-columns: 100px 1fr 54px; }
}
