:root {
  --banana: #f1ba27; --tongue: #e96a53; --ink: #0a0a09; --paper: #fff; --soft: #f7f4ec; --line: #ece7da; --muted: #6b6455;
  --word: 'Dela Gothic One', 'Arial Black', Impact, sans-serif; --body: 'Onest', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --rail: 232px; --r: 14px; --fast: 120ms; color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--body); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3 { margin: 0; font-family: var(--word); font-weight: 400; line-height: 1.1; }
.muted { color: var(--muted); }

.top { display: flex; align-items: center; gap: 32px; padding: 16px 28px; position: sticky; top: 0; background: var(--paper); z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; font: 400 18px var(--word); white-space: nowrap; background: none; border: 0; padding: 0; cursor: pointer; }
.brand img { width: 38px; height: 38px; border-radius: 50%; }
.tabs { display: flex; gap: 22px; overflow-x: auto; scrollbar-width: none; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: 2px 0; cursor: pointer; white-space: nowrap; font-weight: 700; transition: border-color var(--fast); }
.tabs button:hover, .tabs button.on { border-bottom-color: var(--banana); }

.layout { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); gap: 12px; padding: 8px 28px 40px; }
.rail { display: flex; flex-direction: column; gap: 24px; position: sticky; top: 72px; align-self: start; }
.label { font-weight: 700; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.field { width: 100%; padding: 11px 14px; border: 1px solid var(--line); background: var(--paper); border-radius: 12px; transition: border-color var(--fast); }
.field:hover, .field:focus { border-color: var(--ink); outline: none; }
:focus-visible { outline: 3px solid var(--banana); outline-offset: 2px; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 18px; border: 2px solid var(--ink); border-radius: 12px; background: var(--banana); box-shadow: 0 3px 0 var(--ink); font-weight: 700; cursor: pointer; transition: transform var(--fast), box-shadow var(--fast); }
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 0 var(--ink); }
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .5; cursor: wait; }
.btn.ghost { background: var(--paper); box-shadow: none; border: 1px solid var(--line); min-height: 40px; padding: 0 14px; font-weight: 500; }
.btn.ghost:hover { border-color: var(--ink); transform: none; }
.scope { display: flex; width: 100%; justify-content: space-between; gap: 8px; padding: 8px 12px; background: none; border: 0; border-radius: 10px; cursor: pointer; text-align: left; align-items: center; }
.scope:hover { background: var(--soft); }
.scope.on { background: var(--soft); font-weight: 700; }
.scope .n { font-size: 14px; color: var(--muted); font-weight: 400; }
.note { font-size: 14px; margin-top: 8px; color: var(--muted); }
.note.err { color: #b83a22; }

.main { min-width: 0; }
.bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 18px; }
.bar .grow { flex: 1 1 220px; min-width: 160px; }
.bar select.field { width: auto; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-weight: 700; }
.switch input { position: absolute; opacity: 0; }
.switch i { width: 42px; height: 24px; border-radius: 12px; position: relative; display: block; background: var(--line); transition: background var(--fast); }
.switch i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--paper); transition: transform var(--fast); }
.switch input:checked + i { background: var(--banana); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 3px solid var(--banana); outline-offset: 2px; }
.count { font-size: 14px; color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 22px 16px; }
.reel { background: none; border: 0; padding: 0; text-align: left; cursor: pointer; min-width: 0; }
.cover { position: relative; aspect-ratio: 9/16; background: var(--soft) center/cover no-repeat; border-radius: var(--r); overflow: hidden; transition: transform var(--fast); }
.reel:hover .cover { transform: translateY(-3px); }
.v { position: absolute; left: 8px; top: 8px; background: var(--paper); font: 700 15px/1 var(--body); padding: 6px 9px; border-radius: 9px; }
.v.hot { background: var(--banana); }
.meta { padding: 8px 2px 0; }
.meta .views { font-weight: 700; font-size: 17px; }
.meta .who { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { padding: 40px 0; max-width: 560px; }
.empty h2 { font-size: 26px; margin-bottom: 10px; }
.more { margin: 24px 0; }

.page { position: fixed; inset: 0; background: var(--paper); z-index: 10; overflow-y: auto; }
.page-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 28px; position: sticky; top: 0; background: var(--paper); z-index: 2; }
.page-body { max-width: 1160px; margin: 0 auto; padding: 8px 28px 48px; display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 36px; align-items: start; }
.side { position: sticky; top: 74px; }
.side video, .side .poster { width: 100%; aspect-ratio: 9/16; max-height: calc(100vh - 170px); background: #000 center/contain no-repeat; display: block; border-radius: var(--r); object-fit: contain; }
.side p { margin: 10px 0 0; }
.score { font: 400 52px/1 var(--word); }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 16px; margin: 20px 0; }
.kv b { display: block; font-size: 19px; }
.kv span { font-size: 14px; color: var(--muted); }
.block { margin-top: 28px; }
.block h3 { font-size: 20px; margin-bottom: 10px; }
.block p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.timeline { display: grid; }
.tl { display: grid; grid-template-columns: 56px 72px minmax(0, 1fr); gap: 14px; padding: 8px; border: 0; background: none; text-align: left; cursor: pointer; border-radius: 10px; align-items: start; width: 100%; }
.tl:hover { background: var(--soft); }
.tl .t { font-weight: 700; color: var(--muted); font-size: 15px; }
.tl img { width: 72px; aspect-ratio: 9/16; object-fit: cover; border-radius: 8px; background: var(--soft); display: block; }
.tl .say { font-weight: 500; }
.tl .see { color: var(--muted); font-size: 15px; margin-top: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--soft); border-radius: 9px; padding: 3px 9px; font-size: 14px; }
.chip button { border: 0; background: none; cursor: pointer; padding: 0 2px; color: var(--muted); font-size: 15px; line-height: 1; }
.chip button:hover { color: var(--ink); }
.chip-add { width: 150px; padding: 4px 10px; font-size: 14px; border-radius: 9px; }

table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-weight: 700; font-size: 14px; color: var(--muted); padding: 6px 14px 8px 0; white-space: nowrap; }
td { padding: 12px 14px 12px 0; border-top: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: right; }
.table-wrap { overflow-x: auto; }
.tag { font-size: 14px; padding: 2px 8px; border-radius: 8px; background: var(--soft); white-space: nowrap; }
.tag.running, .tag.queued { background: #fdf1cf; } .tag.waiting { background: #fdf1cf; } .tag.failed { background: #fbe1da; }
.best td { background: #fdf6e0; }
.best td:first-child { border-radius: 10px 0 0 10px; padding-left: 10px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px; margin: 12px 0 8px; }
.stats b { display: block; font: 400 30px var(--word); }
.section { margin-bottom: 40px; max-width: 1000px; }
.section h2 { font-size: 26px; margin-bottom: 14px; }
.section p { max-width: 68ch; }

.chat { max-width: 800px; display: flex; flex-direction: column; gap: 14px; }
.chat h2 { font-size: 26px; }
#log { display: flex; flex-direction: column; gap: 12px; }
.msg { padding: 12px 16px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { background: var(--soft); margin-left: 15%; font-weight: 500; }
.msg.ai-msg { padding-left: 0; }
.msg .src { display: block; font-size: 14px; color: var(--muted); margin-top: 8px; }
.ask { display: flex; gap: 10px; align-items: flex-end; }
.ask textarea { flex: 1; min-height: 64px; resize: vertical; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(340px, 100%); display: grid; gap: 12px; justify-items: stretch; }
.login img { width: 72px; height: 72px; border-radius: 50%; justify-self: center; }
.login h1 { font-size: 28px; text-align: center; margin-bottom: 8px; }

@media (max-width: 800px) {
  .top { padding: 12px 16px; gap: 14px; }
  .brand span { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); padding: 4px 16px 32px; gap: 18px; }
  .rail { position: static; gap: 14px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 10px; }
  .page-top { padding: 12px 16px; }
  .page-body { grid-template-columns: minmax(0, 1fr); padding: 4px 16px 32px; gap: 18px; }
  .side { position: static; max-width: 260px; }
  .tl { grid-template-columns: 44px 56px minmax(0, 1fr); gap: 10px; padding: 8px 2px; }
  .tl img { width: 56px; }
  .msg.user { margin-left: 8%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.page:not(.show-orig) .orig, .page.show-orig .ru { display: none; }
.lang { display: inline-flex; margin-bottom: 12px; border: 2px solid var(--ink); border-radius: 10px; overflow: hidden; }
.lang button { padding: 8px 14px; min-height: 40px; border: 0; background: transparent; color: inherit; font: inherit; font-weight: 600; cursor: pointer; }
.lang button:focus-visible { outline: 2px solid var(--ink); outline-offset: -4px; }
.lang button.on { background: var(--banana); }
