:root {
  --bg: #0f0f0f;
  --surface: #0f0f0f;
  --surface-2: #272727;
  --surface-3: #3f3f3f;
  --text: #f1f1f1;
  --muted: #aaaaaa;
  --line: #3f3f3f;
  --accent: #3ea6ff;          /* ссылки, хэштеги, переключатели */
  --primary: #f1f1f1;         /* главная кнопка: как «Подписаться» у YouTube */
  --primary-ink: #0f0f0f;
  --brand: #ff0000;
  --accent-soft: #272727;
  --danger: #ff6b6b;
  --ok: #2ba640;
  --radius: 12px;
  --header-h: 56px;
  --side-w: 240px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-2: #f2f2f2;
    --surface-3: #e5e5e5;
    --text: #0f0f0f;
    --muted: #606060;
    --line: #e5e5e5;
    --accent: #065fd4;
    --primary: #0f0f0f;
    --primary-ink: #ffffff;
    --accent-soft: #f2f2f2;
    --danger: #cc0000;
    --ok: #138a2e;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1 { font-size: 24px; margin: 0 0 12px; }
h2 { font-size: 18px; margin: 24px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Каркас ---------- */
.header {
  position: sticky; top: 0; z-index: 30; height: var(--header-h);
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
  background: var(--bg);
}
.logo { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 19px; letter-spacing: -0.04em; }
.logo-mark { width: 30px; height: 21px; border-radius: 6px; display: grid; place-items: center; background: var(--brand); color: #fff; }
.logo-mark svg { width: 13px; height: 13px; fill: currentColor; }
.search { flex: 1; max-width: 560px; margin: 0 auto; display: flex; }
.search input {
  flex: 1; min-width: 0; height: 40px; padding: 0 16px; border: 1px solid var(--line); border-right: 0;
  background: var(--bg); border-radius: 999px 0 0 999px;
}
.search input:focus { outline: none; border-color: var(--accent); }
.search button {
  height: 40px; width: 64px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 0 999px 999px 0; color: var(--text);
}
.layout { display: flex; min-height: calc(100vh - var(--header-h)); }
.side {
  width: var(--side-w); flex: none; padding: 14px 10px; position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h)); overflow-y: auto;
}
.side a, .side button.nav {
  display: flex; align-items: center; gap: 20px; width: 100%; padding: 0 12px; height: 40px; border-radius: 10px;
  background: none; border: 0; text-align: left; color: var(--text);
}
.side a:hover, .side button.nav:hover { background: var(--surface-2); }
.side a.active { background: var(--surface-2); font-weight: 600; }
.side svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.side .sep { height: 1px; background: var(--line); margin: 10px 8px; }
.side .sub-title { padding: 6px 14px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.side .sub-link { gap: 10px; padding: 7px 14px; }
.main { flex: 1; min-width: 0; padding: 20px 24px 60px; }
.page-narrow { max-width: 780px; margin: 0 auto; }

/* ---------- Кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 16px;
  border: 1px solid transparent; border-radius: 999px; background: var(--surface-2); font-weight: 600; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: var(--primary); opacity: 0.85; }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.sm { height: 32px; padding: 0 14px; font-size: 13px; }
.btn.on { background: var(--surface-3); }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.btn.on svg.fill, .btn.on .fillable { fill: currentColor; }
.btn-group { display: inline-flex; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.btn-group .btn { border-radius: 0; background: transparent; }
.btn-group .btn + .btn { border-left: 1px solid var(--line); }
.btn-group .btn:hover { background: var(--surface-3); }
.btn-group .btn.on { background: var(--surface-3); }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.input, textarea.input, select.input {
  width: 100%; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); outline: none;
}
.input:focus { border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 84px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { margin-top: 4px; accent-color: var(--text); }
.error-text { color: var(--danger); font-size: 14px; min-height: 20px; }
.switch { display: flex; gap: 14px; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.switch input { appearance: none; width: 44px; height: 26px; border-radius: 99px; background: var(--surface-3); position: relative; cursor: pointer; flex: none; transition: background 0.15s; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(18px); }

/* ---------- Аватар ---------- */
.avatar { width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; color: #fff; object-fit: cover; font-size: 15px; }
.avatar.lg { width: 80px; height: 80px; font-size: 32px; }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.avatar.xs { width: 24px; height: 24px; font-size: 11px; }
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: 48px; min-width: 260px; padding: 8px; z-index: 40;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}
.menu .who { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu button, .menu a { display: flex; width: 100%; gap: 10px; align-items: center; padding: 9px 12px; border: 0; border-radius: 9px; background: none; text-align: left; }
.menu button:hover, .menu a:hover { background: var(--surface-2); }
.menu .accent { font-weight: 600; }

/* ---------- Карточки видео ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 40px 16px; }
.card { display: block; min-width: 0; }
.thumb { position: relative; aspect-ratio: 16/9; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card:hover .thumb { border-radius: 0; }
.thumb { transition: border-radius 0.2s; }
.badge {
  position: absolute; right: 8px; bottom: 8px; padding: 1px 6px; border-radius: 6px; font-size: 12px; font-weight: 600;
  background: rgba(0, 0, 0, 0.78); color: #fff;
}
.card-info { display: flex; gap: 12px; margin-top: 10px; }
.card-title { font-weight: 600; font-size: 16px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.card-meta a:hover { color: var(--text); }

.rec-tile {
  aspect-ratio: 16/9; border-radius: var(--radius); background: var(--surface-2); padding: 14px;
  display: flex; flex-direction: column; justify-content: center; gap: 8px;
}
.rec-tile.idle { align-items: center; text-align: center; cursor: pointer; font-weight: 600; }
.rec-tile.idle:hover { background: var(--surface-3); }
.rec-tile.idle svg { width: 32px; height: 32px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.rec-tile textarea { min-height: 0; flex: 1; font-size: 14px; padding: 8px 12px; background: var(--bg); }
.rec-tile .row { gap: 6px; }
.rec-tile-wrap { min-width: 0; }
.rec-links { margin-top: 8px; display: flex; gap: 14px; font-size: 13px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); }
.link-btn:hover:not(:disabled) { text-decoration: underline; }
.link-btn:disabled { color: var(--muted); cursor: default; }
.link { color: var(--accent); }
.link:hover { text-decoration: underline; }
.prompt-box {
  white-space: pre-wrap; font: 13px/1.5 ui-monospace, 'SF Mono', Menlo, Consolas, monospace; background: var(--surface-2);
  border-radius: 12px; padding: 12px 14px; max-height: 320px; overflow: auto;
}
.skeleton { background: var(--surface-2); animation: pulse 1.2s infinite ease-in-out; border-radius: var(--radius); }
@keyframes pulse { 50% { opacity: 0.5; } }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--text); animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { display: grid; place-items: center; padding: 40px 0; text-align: center; }

.shelf-head { display: flex; align-items: center; gap: 10px; margin: 36px 0 12px; }
.shelf-head h2 { margin: 0; }
.shelf { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; }
.short-card { flex: none; width: 190px; scroll-snap-align: start; }
.short-card .thumb { aspect-ratio: 9/16; }

/* ---------- Просмотр ---------- */
.watch { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 24px; max-width: 1700px; margin: 0 auto; }
.watch-player { position: relative; }
.playback-feedback { position: absolute; top: 50%; left: 50%; width: 72px; height: 72px; margin: -36px 0 0 -36px; display: grid; place-items: center; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; pointer-events: none; opacity: 0; }
.playback-feedback svg { width: 36px; height: 36px; }
.playback-feedback.animate { animation: playback-pulse 600ms ease-out; }
@keyframes playback-pulse { 0% { opacity: 0; transform: scale(.7); } 18% { opacity: 1; transform: scale(1); } 65% { opacity: 1; } 100% { opacity: 0; transform: scale(1.25); } }
@media (prefers-reduced-motion: reduce) { .playback-feedback.animate { animation: playback-fade 300ms linear; } }
@keyframes playback-fade { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
.player { width: 100%; aspect-ratio: 16/9; max-height: 78vh; background: #000; border-radius: var(--radius); display: block; }
.player.vertical { aspect-ratio: auto; height: 78vh; width: auto; max-width: 100%; margin: 0 auto; }
.watch h1 { font-size: 21px; margin: 14px 0 10px; line-height: 1.3; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.desc { margin-top: 14px; padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius); white-space: pre-wrap; word-break: break-word; }
.desc.clamped { max-height: 110px; overflow: hidden; position: relative; cursor: pointer; }
.desc .tags { margin-top: 8px; color: var(--accent); }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin: 22px 0 14px; }
.tab { padding: 10px 16px; border: 0; background: none; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; margin-bottom: -1px; }
.tab.active { color: var(--text); border-color: var(--text); }
.summary { padding: 14px 16px; border-radius: var(--radius); background: var(--surface-2); white-space: pre-wrap; }
.summary .tag-ai { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 6px; background: var(--surface-3); margin-bottom: 8px; }
.related { display: grid; gap: 12px; align-content: start; }
.related .card { display: grid; grid-template-columns: 168px 1fr; gap: 10px; }
.related .card-info { margin: 0; }
.related .card-info > a:first-child { display: none; }
.comment { display: flex; gap: 12px; margin: 16px 0; }
.comment .body { min-width: 0; flex: 1; }
.comment .text { white-space: pre-wrap; word-break: break-word; }
.comment .who { font-size: 13px; font-weight: 600; }
.comment .who .ai { font-weight: 600; font-size: 11px; color: var(--muted); background: var(--surface-2); padding: 1px 7px; border-radius: 99px; margin-left: 6px; }
.comment .who .owner { background: var(--surface-3); color: var(--text); }
.comment .tools { display: flex; gap: 14px; font-size: 13px; color: var(--muted); margin-top: 2px; }
.comment .tools button { background: none; border: 0; padding: 2px 0; color: var(--muted); }
.comment .tools button:hover { color: var(--text); }
.replies { margin-left: 4px; border-left: 2px solid var(--line); padding-left: 14px; }
.compose { display: flex; gap: 12px; align-items: flex-start; }
.compose textarea { min-height: 44px; }
.compose .btn { justify-self: end; }

/* ---------- Shorts ---------- */
.shorts-page { position: fixed; top: var(--header-h); left: var(--side-w); right: 0; bottom: 0; }
.shorts-feed { height: 100%; overflow-y: scroll; scroll-snap-type: y mandatory; scrollbar-width: none; }
.shorts-feed::-webkit-scrollbar { display: none; }
.short { height: 100%; scroll-snap-align: start; scroll-snap-stop: always; display: flex; justify-content: center; align-items: center; gap: 18px; padding: 12px 0; }
.short-player { position: relative; height: 100%; aspect-ratio: 9/16; max-width: 100%; background: #000; border-radius: 18px; overflow: hidden; }
.short-player video { width: 100%; height: 100%; object-fit: contain; display: block; }
.short-seek { position: absolute; left: 12px; bottom: 0; width: calc(100% - 24px); height: 26px; margin: 0; padding: 0; z-index: 3; appearance: none; -webkit-appearance: none; background: transparent; border: 0; border-radius: 0; cursor: pointer; touch-action: none; }
.short-seek::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, #ff3030 var(--seek-progress, 0%), rgba(255,255,255,.45) var(--seek-progress, 0%)); }
.short-seek::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 12px; height: 12px; margin-top: -4px; border-radius: 50%; background: #ff3030; }
.short-seek::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(255,255,255,.45); }
.short-seek::-moz-range-progress { height: 4px; background: #ff3030; }
.short-seek::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: #ff3030; }
.short-seek:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
.short-seek:disabled { opacity: .4; cursor: default; }
.short-cap { position: absolute; left: 0; right: 0; bottom: 22px; padding: 40px 16px 16px; background: linear-gradient(transparent, rgba(0, 0, 0, 0.75)); color: #fff; pointer-events: none; }
.short-cap a, .short-cap button { pointer-events: auto; }
.short-cap .t { font-weight: 600; margin-top: 8px; }
.short-actions { display: flex; flex-direction: column; gap: 14px; align-items: center; align-self: flex-end; padding-bottom: 24px; }
.round { width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--surface-2); display: grid; place-items: center; }
.round:hover { background: var(--surface-3); }
.round.on { background: var(--surface-3); }
.round svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.short-actions .cnt { font-size: 12px; margin-top: -10px; color: var(--muted); }
.drawer {
  position: fixed; top: var(--header-h); right: 0; bottom: 0; width: min(440px, 100%); z-index: 35; background: var(--bg);
  border-left: 1px solid var(--line); padding: 16px; overflow-y: auto;
}

/* ---------- Канал и страницы ---------- */
.channel-head { display: flex; gap: 22px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.card-box { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.pill.warn { background: color-mix(in srgb, var(--danger) 22%, transparent); color: var(--danger); }
.pill.okk { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.legal h1 { font-size: 28px; }
.legal ul { line-height: 1.6; }
.legal h2 { margin-top: 28px; }
.legal p, .legal li { color: color-mix(in srgb, var(--text) 88%, transparent); }
.legal a { color: var(--accent); }
.legal ul { padding-left: 22px; }
code, .code { font: 13px ui-monospace, 'SF Mono', Menlo, Consolas, monospace; }
.keybox { display: flex; gap: 8px; align-items: center; padding: 10px 12px; background: var(--surface-2); border-radius: 12px; border: 1px solid var(--line); }
.keybox code { flex: 1; word-break: break-all; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }
.chips { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.chip { height: 32px; padding: 0 12px; border-radius: 8px; border: 0; background: var(--surface-2); font-weight: 500; }
.chip:hover:not(.active) { background: var(--surface-3); }
.chip.active { background: var(--text); color: var(--bg); }

/* ---------- Окна и уведомления ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.6); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.modal { width: min(480px, 100%); max-height: 100%; overflow-y: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 16px; padding: 24px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3); }
.code-input { text-align: center; font-size: 28px; letter-spacing: 0.5em; padding: 12px 0 12px 0.5em; font-variant-numeric: tabular-nums; }
.modal.wide { width: min(640px, 100%); }
.modal h2 { margin: 0 0 14px; font-size: 20px; }
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; justify-items: center; }
.toast { padding: 11px 18px; border-radius: 12px; background: var(--text); color: var(--bg); box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35); font-weight: 600; max-width: 90vw; }
.toast.err { background: var(--danger); color: #fff; }
.bottom-nav { display: none; }

@media (max-width: 1100px) {
  .watch { grid-template-columns: 1fr; }
  .related .card { grid-template-columns: 168px 1fr; }
}
@media (max-width: 860px) {
  .side { display: none; }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: 56px; background: var(--surface);
    border-top: 1px solid var(--line);
  }
  .bottom-nav a { flex: 1; display: grid; place-items: center; font-size: 10px; color: var(--text); align-content: center; }
  .bottom-nav a.active { color: var(--text); font-weight: 600; }
  .bottom-nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .main { padding: 14px 14px 80px; }
  .header { padding: 0 12px; gap: 10px; }
  .logo span.t { display: none; }
  .hide-sm { display: none; }
  .search { min-width: 0; }
  .shorts-page { left: 0; bottom: 56px; }
  .short-actions { position: absolute; right: 8px; bottom: 80px; z-index: 2; }
  .short-actions .round { background: rgba(0, 0, 0, 0.45); color: #fff; }
  .short { padding: 0; }
  .short-player { border-radius: 0; aspect-ratio: auto; width: 100%; }
  .grid { grid-template-columns: 1fr; gap: 22px; }
  .thumb, .rec-tile { border-radius: 10px; }
}
