/* Stream Derzkobt — интерфейс зрителя и панели. Тёмная тема основная. */
:root {
  --bg: #15121D;
  --surface: #1F1B2B;
  --raised: #2A2539;
  --line: #383149;
  --text: #EEEAF6;
  --muted: #9C95AF;
  --accent: #F4C24F;
  --accent-ink: #231A05;
  --live: #FF4D5E;
  --ok: #5BD69B;
  --warn: #F4A04F;
  --twitch: #A970FF;
  --boosty: #F2713A;
  --focus: #8FB8FF;
  --display: "Unbounded", "Golos Text", system-ui, sans-serif;
  --body: "Golos Text", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --gutter: clamp(16px, 3vw, 32px);
  --maxw: 1440px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 15px/1.5 var(--body); min-height: 100vh; overflow-x: hidden;
}
a { color: inherit; }
img { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -0.01em; margin: 0; line-height: 1.15; }
h1 { font-size: clamp(24px, 3.2vw, 36px); }
h2 { font-size: clamp(18px, 2vw, 22px); }
h3 { font-size: 16px; }
p { margin: 0 0 .75em; max-width: 72ch; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ------------------------------------------------------------------ шапка */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 24px;
  padding: 10px var(--gutter); background: rgba(21, 18, 29, .92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.logo { display: flex; align-items: baseline; gap: 6px; text-decoration: none; flex-shrink: 0; }
.logo span { font: 800 20px/1 var(--display); letter-spacing: -0.03em; color: var(--accent); }
.logo small { font: 500 12px/1 var(--display); color: var(--muted); }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  text-decoration: none; padding: 8px 12px; border-radius: var(--r-sm); color: var(--muted);
  white-space: nowrap; font-weight: 500; position: relative;
}
.nav a:hover { color: var(--text); background: var(--surface); }
.nav a[aria-current="page"] { color: var(--text); background: var(--raised); }
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--live); margin-left: 6px; vertical-align: 2px; }
.topbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.icon-btn { position: relative; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; color: var(--muted); }
.icon-btn:hover { background: var(--surface); color: var(--text); }
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }
.badge { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font: 700 11px/18px var(--body); text-align: center; }
.admin-link { text-decoration: none; font-weight: 600; color: var(--accent); padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); }
.avatar-link { display: block; width: 36px; height: 36px; border-radius: 50%; overflow: hidden; background: var(--raised); }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px 12px; padding-bottom: 6px; }
  .nav { order: 3; width: 100%; margin: 0 calc(var(--gutter) * -1); padding: 0 var(--gutter); }
  .admin-link { display: none; }
}

/* ------------------------------------------------------------------ раскладка */
main { max-width: var(--maxw); margin: 0 auto; padding: 24px var(--gutter) 64px; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.section { margin-top: 36px; }
.section > .section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head a { color: var(--muted); text-decoration: none; font-weight: 500; }
.section-head a:hover { color: var(--text); }

.grid { display: grid; gap: 22px 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
@media (max-width: 520px) { .grid { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------------ кнопки, поля */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px;
  border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  font-weight: 600; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--raised); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: #FF8C97; border-color: #5b2c37; }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 13px; border-radius: var(--r-sm); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface); }
.btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.btn svg { width: 18px; height: 18px; fill: currentColor; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

input[type=text], input[type=search], input[type=number], input[type=url], input[type=datetime-local], textarea, select {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 12px; min-height: 40px; width: 100%;
}
textarea { resize: vertical; min-height: 84px; }
input:focus, textarea:focus, select:focus { border-color: var(--focus); outline: none; }
label.field { display: grid; gap: 6px; font-weight: 500; }
label.field > span { font-size: 13px; color: var(--muted); }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ------------------------------------------------------------------ карточки */
.card { text-decoration: none; display: grid; gap: 10px; min-width: 0; }
.thumb { position: relative; aspect-ratio: 16 / 9; border-radius: var(--r-md); overflow: hidden; background: var(--surface); }
.thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s ease; }
.card:hover .thumb img { transform: scale(1.03); }
.thumb .placeholder { position: absolute; inset: 0; display: grid; place-items: center; font: 800 28px var(--display); color: var(--raised); background: linear-gradient(135deg, var(--surface), var(--raised)); }
.thumb .dur { position: absolute; right: 8px; bottom: 10px; background: rgba(10, 8, 15, .82); padding: 2px 7px; border-radius: 4px; font-size: 12px; font-weight: 600; }
.thumb .watched { position: absolute; left: 8px; top: 8px; background: rgba(10, 8, 15, .82); padding: 2px 8px; border-radius: 4px; font-size: 12px; color: var(--ok); }
.thumb .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, .15); }
.thumb .bar i { display: block; height: 100%; background: var(--accent); }
.card h3 { font: 600 15px/1.35 var(--body); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--muted); }
.plat { display: inline-flex; align-items: center; gap: 6px; }
.plat::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--muted); }
.plat.twitch::before { background: var(--twitch); }
.plat.boosty::before { background: var(--boosty); }

/* ------------------------------------------------------------------ эфир на главной */
.onair {
  display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr); gap: 0; border-radius: var(--r-lg);
  overflow: hidden; background: var(--surface); text-decoration: none; border: 1px solid var(--line);
}
.onair .screen { position: relative; aspect-ratio: 16/9; background: radial-gradient(120% 120% at 20% 10%, #3b2147 0%, #1c1528 55%, #120f19 100%); display: grid; place-items: center; }
.onair .screen .live-thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.onair .screen strong { font: 800 clamp(30px, 6vw, 72px)/1 var(--display); letter-spacing: -0.04em; color: var(--text); }
.onair .screen .pulse { position: absolute; left: 18px; top: 16px; display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: #fff; background: var(--live); padding: 4px 10px; border-radius: 4px; }
.onair .screen .pulse::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: blink 1.6s ease-in-out infinite; }
.onair .info { padding: 24px; display: grid; align-content: center; gap: 12px; }
.onair .info h2 { font-size: clamp(20px, 2.4vw, 28px); }
@keyframes blink { 50% { opacity: .25; } }
@media (max-width: 760px) { .onair { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .onair .screen .pulse::before { animation: none; } .thumb img { transition: none; } }

/* ------------------------------------------------------------------ вход и доступ */
.gate { min-height: calc(100vh - 120px); display: grid; place-items: center; }
.gate-box { width: min(560px, 100%); display: grid; gap: 22px; }
.gate-title { font: 800 clamp(40px, 9vw, 84px)/.92 var(--display); letter-spacing: -0.05em; color: var(--accent); margin: 0; }
.gate-title span { display: block; color: var(--text); font-size: .42em; letter-spacing: -0.02em; margin-top: 10px; font-weight: 700; }
.gate .steps { display: grid; gap: 10px; padding: 0; margin: 0; list-style: none; counter-reset: s; }
.gate .steps li { display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; color: var(--muted); }
.gate .steps li::before { counter-increment: s; content: counter(s); width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--raised); color: var(--text); font-weight: 700; font-size: 13px; }
.notice { padding: 14px 16px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); }
.notice.err { border-color: #6b2b37; background: #2a1720; }
.notice.warn { border-color: #6b4a22; background: #2a2116; }
.notice.ok { border-color: #1f5a40; background: #15261f; }

/* ------------------------------------------------------------------ плеер */
.watch { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; align-items: start; }
@media (max-width: 1100px) { .watch { grid-template-columns: 1fr; } }
.player {
  position: relative; background: #000; border-radius: var(--r-lg); overflow: hidden; aspect-ratio: 16/9; width: 100%;
  user-select: none; -webkit-user-select: none;
}
.player:fullscreen { border-radius: 0; aspect-ratio: auto; }
.player video, .player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.player .overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(8, 6, 12, .55); text-align: center; padding: 16px; }
.player .overlay .box { display: grid; gap: 12px; justify-items: center; max-width: 440px; }
.player .spinner { width: 44px; height: 44px; border-radius: 50%; border: 3px solid rgba(255,255,255,.2); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.controls {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 12px 8px;
  background: linear-gradient(to top, rgba(8,6,12,.9), rgba(8,6,12,0)); transition: opacity .2s; display: grid; gap: 6px;
}
.player.idle .controls { opacity: 0; }
.player.idle { cursor: none; }
.ctrl-row { display: flex; align-items: center; gap: 4px; }
.ctrl-row .spacer { flex: 1; }
.cbtn { background: none; border: 0; color: #fff; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 8px; cursor: pointer; }
.cbtn:hover { background: rgba(255,255,255,.12); }
.cbtn svg { width: 22px; height: 22px; fill: currentColor; }
.cbtn.text { width: auto; padding: 0 10px; font-weight: 600; font-size: 13px; }
.time { font-size: 13px; color: #ddd; padding: 0 8px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.seek { position: relative; height: 18px; cursor: pointer; touch-action: none; }
.seek .track { position: absolute; left: 0; right: 0; top: 7px; height: 4px; border-radius: 2px; background: rgba(255,255,255,.22); }
.seek:hover .track { height: 6px; top: 6px; }
.seek .buf { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255,255,255,.3); border-radius: 2px; }
.seek .played { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 2px; }
.seek .knob { position: absolute; top: 3px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--accent); }
.seek .tick { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(0,0,0,.65); }
.seek .tip { position: absolute; bottom: 22px; transform: translateX(-50%); background: rgba(10,8,15,.92); padding: 3px 8px; border-radius: 4px; font-size: 12px; white-space: nowrap; pointer-events: none; }
.volume { width: 80px; accent-color: var(--accent); }
@media (max-width: 520px) { .volume { display: none; } }
.menu { position: absolute; right: 12px; bottom: 64px; background: rgba(20,17,28,.97); border: 1px solid var(--line); border-radius: var(--r-md); padding: 6px; min-width: 180px; display: grid; z-index: 5; max-height: 70%; overflow: auto; }
.menu button { text-align: left; background: none; border: 0; padding: 8px 12px; border-radius: 6px; cursor: pointer; color: var(--text); }
.menu button:hover, .menu button:focus-visible { background: var(--raised); }
.menu button[aria-checked="true"] { color: var(--accent); font-weight: 600; }
.menu .menu-title { padding: 6px 12px; color: var(--muted); font-size: 12px; }
.live-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 4px; font-weight: 700; font-size: 13px; background: rgba(255,255,255,.12); color: #fff; border: 0; cursor: pointer; }
.live-badge.at-edge { background: var(--live); }
.live-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.watch-title { margin-top: 18px; display: grid; gap: 10px; }
.watch-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.desc { white-space: pre-wrap; color: #d9d4e4; }
.side-list { display: grid; gap: 2px; }
.side-list button, .side-list a { display: grid; grid-template-columns: 64px 1fr; gap: 10px; text-align: left; padding: 8px 10px; border-radius: var(--r-sm); background: none; border: 0; cursor: pointer; text-decoration: none; color: var(--text); }
.side-list button:hover, .side-list a:hover { background: var(--surface); }
.side-list .tc { color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; }
.side-list .current { background: var(--raised); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; display: grid; gap: 12px; }

/* ------------------------------------------------------------------ комментарии */
.comments { margin-top: 32px; display: grid; gap: 16px; max-width: 820px; }
.comment { display: grid; grid-template-columns: 36px 1fr; gap: 12px; }
.comment .av { width: 36px; height: 36px; border-radius: 50%; background: var(--raised); overflow: hidden; display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.comment .head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.comment .head b { color: var(--text); font-size: 14px; }
.comment .body { white-space: pre-wrap; word-break: break-word; margin: 4px 0 6px; }
.comment .body.gone { color: var(--muted); font-style: italic; }
.comment .tools { display: flex; gap: 2px; flex-wrap: wrap; }
.comment .replies { display: grid; gap: 14px; margin-top: 12px; }
.timecode { color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.composer { display: grid; gap: 8px; }
.composer .row { justify-content: flex-end; }

/* ------------------------------------------------------------------ списки, вкладки, таблицы */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs a, .tabs button { padding: 10px 14px; text-decoration: none; color: var(--muted); border: 0; background: none; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.tabs [aria-current="page"], .tabs [aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.filters { display: grid; grid-template-columns: minmax(200px, 2fr) repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 20px; }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--r-lg); display: grid; gap: 12px; justify-items: center; }
.skeleton { background: linear-gradient(90deg, var(--surface) 0%, var(--raised) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--r-md); }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton, .player .spinner { animation: none; } }
.list { display: grid; gap: 8px; }
.list-item { display: flex; gap: 14px; align-items: center; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.list-item.unread { border-color: #6b5a22; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 13px; background: var(--surface); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
.status { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; background: var(--raised); white-space: nowrap; }
.status.ready, .status.done, .status.online, .status.member, .status.confirmed { color: var(--ok); }
.status.needs_review, .status.queued, .status.reconnecting, .status.none { color: var(--warn); }
.status.error, .status.dead, .status.failed, .status.not_member, .status.wrong { color: #FF8C97; }
.status.live, .status.capturing { color: #fff; background: var(--live); }
.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; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; display: grid; gap: 4px; }
.stat b { font: 700 18px/1.3 var(--display); }
.admin { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 28px; }
.admin-nav { display: grid; gap: 2px; align-content: start; position: sticky; top: 76px; }
.admin-nav a { text-decoration: none; padding: 8px 12px; border-radius: var(--r-sm); color: var(--muted); }
.admin-nav a[aria-current="page"] { background: var(--raised); color: var(--text); }
@media (max-width: 900px) { .admin { grid-template-columns: 1fr; } .admin-nav { position: static; display: flex; overflow-x: auto; } }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.chapters-edit .ch { display: grid; grid-template-columns: 110px 110px 1fr 150px 40px; gap: 8px; align-items: center; margin-bottom: 6px; }
@media (max-width: 760px) { .chapters-edit .ch { grid-template-columns: 1fr 1fr; } }
pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px; overflow: auto; font-size: 12px; max-height: 260px; }

/* ------------------------------------------------------------------ профиль */
.profile-head { display: flex; gap: 18px; align-items: center; }
.profile-head .big-av { width: 72px; height: 72px; border-radius: 50%; overflow: hidden; background: var(--raised); display: grid; place-items: center; font: 800 26px var(--display); color: var(--muted); flex-shrink: 0; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-top: 24px; }

/* ------------------------------------------------------------------ уведомления */
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; width: min(440px, calc(100% - 32px)); }
.toast { background: var(--raised); border: 1px solid var(--line); padding: 12px 16px; border-radius: var(--r-md); box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.toast.err { border-color: #6b2b37; }
.noscript { padding: 40px; text-align: center; }
dialog { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px; width: min(520px, calc(100% - 32px)); }
dialog::backdrop { background: rgba(5, 4, 8, .7); }
