:root {
  --void: #0B0D13; --shell: #12141C; --sticky: #151924; --panel: #1A1E29; --raised: #262B39;
  --stroke: #303646; --subtle: #262B39; --strong: #4A5164;
  --text: #F1F3F8; --soft: #B9C1D0; --muted: #8C94A6; --faint: #6B7385;
  --gold: #F0C64A; --gold-hi: #F5D77E; --gold-lo: #D9AE33; --ink: #1A1403;
  --teal: #4FD1C5; --red: #E0524F; --silver: #A9B3C4;
  --ui: 'Manrope', system-ui, sans-serif; --mono: 'JetBrains Mono', ui-monospace, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--void); color: var(--text); font: 13px/1.4 var(--ui); display: flex; flex-direction: column; overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
#app { display: contents; }

/* header */
.top { height: 52px; flex: none; display: flex; align-items: center; gap: 16px; padding: 0 16px; background: var(--shell); border-bottom: 1px solid var(--subtle); }
.logo { font: 26px/1 'Bebas Neue', sans-serif; letter-spacing: .04em; color: var(--text); text-decoration: none; white-space: nowrap; padding-top: 3px; }
.logo span { color: var(--gold); margin-left: 4px; }
.url { flex: 1; max-width: 680px; height: 34px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--stroke); background: var(--void); color: var(--text); font: 13px var(--ui); outline: none; }
.url:focus { border-color: rgba(240,198,74,.45); }
.url::placeholder { color: var(--faint); }
.pill { margin-left: auto; max-width: 380px; display: flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--stroke); background: var(--panel); font: 500 11px var(--mono); color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill.live { color: var(--gold); border-color: rgba(240,198,74,.3); }
.pill.ok { color: var(--teal); border-color: rgba(79,209,197,.35); }
.pill.bad { color: var(--red); border-color: rgba(224,82,79,.4); display: block; }
.spin { width: 11px; height: 11px; flex: none; border-radius: 50%; border: 2px solid rgba(240,198,74,.25); border-top-color: var(--gold); animation: spin .8s linear infinite; }

/* layout */
.grid { flex: 1; min-height: 0; display: grid; grid-template-columns: 300px minmax(0, 1fr) 320px; grid-template-rows: minmax(0, 1fr) auto; gap: 12px; padding: 12px; }
.panel { background: var(--shell); border: 1px solid var(--subtle); border-radius: 10px; min-height: 0; display: flex; flex-direction: column; }
.ph { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 12px 14px 8px; }
.ph b { font-size: 13px; font-weight: 700; }
.ph span { font-size: 11px; color: var(--muted); }
.ph.sm { padding-top: 6px; }

/* player */
.stage { position: relative; min-height: 0; border-radius: 10px; overflow: hidden; display: grid; place-items: center; container-type: size;
  background: linear-gradient(180deg, var(--void), var(--panel) 50%, var(--void)); border: 1px solid var(--subtle); }
.video { width: min(100cqw, 100cqh * 16 / 9); aspect-ratio: 16 / 9; }
.video:empty { display: none; }
.video > * { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; }
.msg { position: absolute; inset: 0; display: grid; place-content: center; gap: 6px; text-align: center; padding: 24px; }
.msg b { font-size: 16px; }
.msg span { color: var(--muted); max-width: 380px; }
.msg.bad { background: rgba(11,13,19,.85); }
.msg.bad b { color: var(--red); }

/* highlights */
.rows { flex: 1; overflow: auto; padding: 0 8px 8px; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; scrollbar-color: var(--stroke) transparent; }
.row { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 10px; align-items: center; padding: 6px; border-radius: 6px; border: 1px solid transparent; text-align: left; animation: rowin .2s ease-out; }
.row:hover { background: rgba(255,255,255,.04); }
.row.sel { background: rgba(255,255,255,.08); }
.row.best { background: rgba(240,198,74,.10); border-color: rgba(240,198,74,.16); }
.row.best .lbl { color: var(--gold); }
.row.now .th { outline: 2px solid var(--gold); outline-offset: -2px; }
.row.ghost { animation: none; cursor: default; }
.row.ghost.idle .shim { animation: none; opacity: .5; }
.th { position: relative; width: 128px; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; background: var(--void); }
.th img, .th > .shim { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 0; }
.th img { animation: fadein .25s ease-out; }
.cap { position: absolute; right: 4px; bottom: 4px; padding: 1px 5px; border-radius: 4px; background: rgba(0,0,0,.72); font: 500 9px var(--mono); color: var(--text); }
.info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.lbl { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub { display: flex; gap: 8px; font: 11px var(--mono); color: var(--muted); }
.sub time { color: var(--soft); }
.score { display: block; height: 3px; border-radius: 2px; background: var(--subtle); overflow: hidden; }
.score i { display: block; height: 100%; background: var(--gold); border-radius: 2px; }
.empty { padding: 24px 8px; text-align: center; color: var(--muted); }
.shim { display: block; border-radius: 6px; background: linear-gradient(90deg, #1A1E29 25%, #262B39 50%, #1A1E29 75%); background-size: 200% 100%; animation: shim 1.3s linear infinite; }
.shim.line { height: 10px; margin: 3px 0; }
.shim.short { width: 55%; }

/* stats */
.stats { overflow: auto; scrollbar-width: thin; scrollbar-color: var(--stroke) transparent; }
.vid { padding: 0 14px 12px; min-height: 52px; }
.vid .title { font-weight: 700; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vid .by { color: var(--muted); font-size: 11px; margin-top: 3px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 14px 10px; }
.tiles.three { grid-template-columns: repeat(3, 1fr); }
.tile { background: var(--panel); border: 1px solid var(--subtle); border-radius: 8px; padding: 10px; min-width: 0; }
.tile b { display: block; font: 600 22px/1.15 var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tiles.three .tile b { font-size: 16px; }
.tile span { font-size: 11px; color: var(--muted); }
.gold { color: var(--gold); } .teal { color: var(--teal); }
.bars { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.prog { display: grid; grid-template-columns: 44px 1fr 38px; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.prog > i { height: 4px; border-radius: 2px; background: var(--subtle); overflow: hidden; }
.prog > i i { display: block; height: 100%; background: var(--gold); transition: width .25s; }
.prog em { font: normal 11px var(--mono); text-align: right; color: var(--soft); }
.failmsg { margin: 0 14px 14px; padding: 10px; border-radius: 8px; color: var(--red); background: rgba(224,82,79,.08); border: 1px solid rgba(224,82,79,.25); }

/* timeline + transport */
.bottom { grid-column: 1 / -1; padding: 10px 12px; gap: 8px; }
.tl { position: relative; height: 56px; background: var(--sticky); border-radius: 6px; }
.tl canvas { display: block; width: 100%; height: 100%; }
.tip { position: absolute; bottom: calc(100% + 8px); transform: translateX(-50%); padding: 4px; border-radius: 8px; background: var(--void); border: 1px solid var(--strong); pointer-events: none; z-index: 2; }
.tip img { display: block; width: 160px; height: 90px; object-fit: cover; border-radius: 6px; margin-bottom: 3px; }
.tip time { display: block; text-align: center; font: 11px var(--mono); padding: 0 4px; }
.transport { display: flex; align-items: center; gap: 10px; }
.play { width: 32px; height: 32px; border-radius: 50%; background: var(--gold); display: grid; place-items: center; flex: none; }
.play:hover:not(:disabled) { background: var(--gold-hi); }
.play svg { width: 14px; height: 14px; fill: var(--ink); }
.clock { font: 12px var(--mono); color: var(--soft); min-width: 110px; }
.chip { padding: 4px 11px; border-radius: 14px; border: 1px solid var(--stroke); font-size: 11px; color: var(--soft); }
.chip:hover:not(:disabled) { background: var(--panel); color: var(--text); }
.keys { margin-left: auto; font-size: 11px; color: var(--faint); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shim { to { background-position: -200% 0; } }
@keyframes rowin { from { opacity: 0; transform: translateY(4px); } }
@keyframes fadein { from { opacity: 0; } }

/* narrow screens: stack */
@media (max-width: 900px) {
  body { overflow: auto; height: auto; }
  .top { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 8px 12px; }
  .url { order: 3; flex-basis: 100%; max-width: none; }
  .grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
  .stage { aspect-ratio: 16 / 9; order: 1; }
  .bottom { order: 2; grid-column: auto; }
  .hl { order: 3; max-height: 60vh; }
  .stats { order: 4; overflow: visible; }
  .keys { display: none; }
}
