:root {
  --bg: #0f0f0f; --fg: #f1f1f1; --muted: #aaa; --panel: #212121; --panel-2: #2c2c2c;
  --accent: #ff0033; --radius: 14px; --gap: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font: 18px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; background: var(--panel); border-radius: 999px; padding: 12px 22px; min-height: 52px; cursor: pointer; }
button:active { filter: brightness(1.3); }
button.primary { background: var(--accent); color: #fff; font-weight: 600; }
input, textarea, select { background: var(--panel); border: 1px solid #3a3a3a; border-radius: 12px; padding: 12px 16px; min-height: 52px; }
.logo { color: var(--accent); }

/* login */
body.login { display: grid; place-items: center; padding: 16px; }
.login-card { display: grid; gap: 14px; width: min(420px, 100%); }
.login-card h1 { margin: 0 0 8px; font-size: 32px; }
.err { color: #ff6b6b; margin: 0; }

/* app shell */
body.app { display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; position: sticky; top: 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); z-index: 5; }
.brand { font-weight: 700; font-size: 22px; margin-right: 8px; white-space: nowrap; }
.tabs { display: flex; gap: 8px; }
.tabs a { text-decoration: none; color: var(--fg); padding: 12px 20px; border-radius: 999px; background: var(--panel); white-space: nowrap; }
.tabs a.active { background: var(--fg); color: var(--bg); font-weight: 600; }
.searchbox { flex: 1; display: flex; gap: 8px; min-width: 0; }
.searchbox input { flex: 1; min-width: 0; border-radius: 999px; }
.icon-btn { padding: 0; width: 52px; }
main { flex: 1; min-height: 0; overflow: auto; padding: 8px 16px 24px; }

/* grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 28px var(--gap); }
.card { display: block; color: inherit; text-decoration: none; }
.thumb { position: relative; aspect-ratio: 16/9; border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.badge { position: absolute; right: 8px; bottom: 8px; background: #000c; padding: 2px 6px; border-radius: 6px; font-size: 14px; font-weight: 600; }
.badge.live { background: var(--accent); }
.card h3 { margin: 10px 0 4px; font-size: 18px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .sub { color: var(--muted); font-size: 15px; }
.more { display: flex; justify-content: center; margin: 28px 0; }
.empty { color: var(--muted); text-align: center; margin: 60px 16px; }
.empty button { margin-top: 16px; }

/* watch */
.watch { display: flex; flex-direction: column; height: 100%; gap: 10px; }
.stage { position: relative; flex: 1; min-height: 240px; background: #000; border-radius: var(--radius); overflow: hidden; }
.stage:fullscreen { border-radius: 0; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.status { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; font-size: 22px; text-shadow: 0 1px 6px #000; }
.debug { position: absolute; top: 10px; right: 10px; white-space: pre; font: 13px/1.3 ui-monospace, monospace;
  background: #000a; padding: 8px 10px; border-radius: 8px; pointer-events: none; }
.watch h2 { margin: 0; font-size: 20px; }
.watch .sub { color: var(--muted); }
.controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.controls input[type=range] { flex: 1 1 260px; accent-color: var(--accent); height: 40px; padding: 0; border: 0; background: none; }
.live-dot { color: var(--accent); }
.time { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 120px; text-align: right; }

/* settings */
.settings { max-width: 820px; display: grid; gap: 22px; }
.settings section { background: var(--panel); border-radius: var(--radius); padding: 18px; display: grid; gap: 12px; }
.settings h2 { margin: 0; font-size: 20px; }
.settings p { margin: 0; color: var(--muted); }
.settings textarea { min-height: 140px; font: 13px/1.4 ui-monospace, monospace; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.ok { color: #4ade80; } .bad { color: #ff6b6b; }
label.check { display: flex; gap: 10px; align-items: center; min-height: 44px; }
label.check input { width: 26px; height: 26px; min-height: 0; }

@media (max-width: 760px) {
  .brand { display: none; }
  .tabs a { padding: 12px 14px; }
}
