:root {
  --bg: #0f0f10;
  --bg-elev: #1b1b1e;
  --bg-hover: #2a2a2e;
  --border: #303035;
  --text: #f1f1f1;
  --text-dim: #aaaaaf;
  --accent: #ff4f3a;
  --accent-text: #fff;
  --danger: #ff6b6b;
  --ok: #3ecf8e;
  --radius: 12px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    --bg: #ffffff;
    --bg-elev: #f2f2f2;
    --bg-hover: #e5e5e5;
    --border: #d9d9d9;
    --text: #0f0f0f;
    --text-dim: #606060;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  height: 56px; padding: 0 16px;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.logo { display: flex; align-items: center; font-weight: 800; font-size: 20px; letter-spacing: -0.6px; flex-shrink: 0; color: var(--text); }
.search { flex: 1; min-width: 0; max-width: 640px; margin: 0 auto; display: flex; }
.search input {
  flex: 1; min-width: 0; width: 0; height: 40px; padding: 0 16px;
  background: var(--bg); border: 1px solid var(--border); border-right: 0;
  border-radius: 40px 0 0 40px; outline: none;
}
.search input:focus { border-color: #3b82f6; }
.search button {
  width: 64px; height: 40px; border: 1px solid var(--border);
  background: var(--bg-elev); border-radius: 0 40px 40px 0; cursor: pointer;
  display: grid; place-items: center;
}
.search button:hover { background: var(--bg-hover); }
.top-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 16px; border-radius: 18px;
  border: 0; background: var(--bg-elev); cursor: pointer; font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.icon { width: 20px; height: 20px; fill: currentColor; }

/* ---------- home grid ---------- */
main { padding: 24px; max-width: 2200px; margin: 0 auto; }
.chips { display: flex; gap: 12px; margin-bottom: 24px; overflow-x: auto; }
.chip { padding: 6px 12px; border-radius: 8px; background: var(--bg-elev); cursor: pointer; white-space: nowrap; border: 0; }
.chip.active { background: var(--text); color: var(--bg); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 40px 16px; }
.card { display: block; }
.thumb {
  position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius);
  background: var(--bg-elev) center / cover no-repeat; overflow: hidden;
}
.card:hover .thumb { border-radius: 0; transition: border-radius .2s; }
.badge {
  position: absolute; right: 8px; bottom: 8px; padding: 1px 4px; border-radius: 4px;
  background: rgba(0,0,0,.8); color: #fff; font-size: 12px; font-weight: 500;
}
.badge.processing { background: rgba(0,0,0,.8); left: 8px; right: auto; }
.card .meta { display: flex; gap: 12px; margin-top: 12px; }
.avatar {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700;
}
.card h3 {
  margin: 0 0 4px; font-size: 16px; font-weight: 600; line-height: 22px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.dim { color: var(--text-dim); }
.empty { text-align: center; padding: 80px 16px; color: var(--text-dim); }
.empty h2 { color: var(--text); }

/* ---------- watch page ---------- */
.watch { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 24px; max-width: 1760px; margin: 0 auto; }
.player-wrap { background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; }
.player-wrap video { width: 100%; height: 100%; display: block; background: #000; }
.watch h1 { font-size: 20px; margin: 12px 0 8px; font-weight: 700; }
.channel-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.channel { display: flex; align-items: center; gap: 12px; }
.desc-box { margin-top: 12px; padding: 12px; background: var(--bg-elev); border-radius: var(--radius); }
.desc-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.desc-box .stats { font-weight: 600; margin-bottom: 4px; }
.desc-box.collapsed .desc-text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.desc-box .more { background: none; border: 0; padding: 4px 0 0; font-weight: 600; cursor: pointer; }
.side-list { display: flex; flex-direction: column; gap: 8px; }
.side-item { display: grid; grid-template-columns: 168px 1fr; gap: 8px; }
.side-item .thumb { border-radius: 8px; }
.side-item h4 { margin: 0 0 4px; font-size: 14px; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.side-item .dim { font-size: 12px; }

/* ---------- forms / upload / studio ---------- */
.panel { max-width: 820px; margin: 0 auto; background: var(--bg-elev); border-radius: var(--radius); padding: 24px; }
.panel h1 { margin-top: 0; font-size: 22px; }
.drop {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 48px 16px; text-align: center; cursor: pointer;
}
.drop.over { border-color: var(--accent); background: var(--bg-hover); }
.drop .big { width: 64px; height: 64px; fill: var(--text-dim); }
label { display: block; font-weight: 600; margin: 16px 0 6px; }
input[type=text], input[type=password], input[type=email], select, textarea {
  width: 100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; outline: none;
}
input:focus, textarea:focus { border-color: #3b82f6; }
textarea { min-height: 120px; resize: vertical; }
.bar { height: 6px; background: var(--bg-hover); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.bar > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.upload-item { padding: 12px 0; border-top: 1px solid var(--border); }
.upload-item:first-child { border-top: 0; }
.row { display: flex; align-items: center; gap: 8px; justify-content: space-between; flex-wrap: wrap; }
.error { color: var(--danger); }
.okc { color: var(--ok); }

table.studio { width: 100%; border-collapse: collapse; }
table.studio td, table.studio th { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
table.studio .thumb { width: 120px; border-radius: 6px; }
.status-pill { padding: 2px 8px; border-radius: 10px; font-size: 12px; background: var(--bg-hover); white-space: nowrap; }
.status-pill.ready { color: var(--ok); }
.status-pill.failed { color: var(--danger); }

dialog { background: var(--bg-elev); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); width: min(560px, calc(100vw - 32px)); padding: 24px; }
dialog::backdrop { background: rgba(0,0,0,.6); }

.login-wrap { min-height: calc(100vh - 56px); display: grid; place-items: center; padding: 16px; }
.login-wrap .panel { width: 100%; max-width: 380px; }

/* ---------- v0.0.1: navigation, accounts, People ---------- */
.nav { display: flex; gap: 2px; flex-shrink: 0; }
.nav-link { padding: 8px 12px; border-radius: 8px; color: var(--text-dim); font-weight: 500; white-space: nowrap; }
.nav-link:hover { background: var(--bg-elev); color: var(--text); }
.nav-link.active { background: var(--bg-elev); color: var(--text); font-weight: 600; }
.avatar-sm { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-text); display: inline-grid; place-items: center; font-size: 13px; font-weight: 700; }
.btn.who { padding-left: 6px; }
.section-title { font-size: 20px; margin: 0; }
.hint { color: var(--text-dim); font-size: 13px; margin: 6px 0 0; }
.notice { padding: 10px 12px; border-radius: 8px; background: var(--bg-hover); margin: 12px 0; }
.notice.ok { color: var(--ok); }
.btn.block { width: 100%; justify-content: center; height: 42px; margin-top: 20px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 10px; background: var(--bg); margin: 16px 0 4px; }
.tabs button { border: 0; border-radius: 8px; padding: 9px 8px; background: transparent; cursor: pointer; font-weight: 600; color: var(--text-dim); }
.tabs button[aria-selected=true] { background: var(--bg-hover); color: var(--text); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: 18px; height: 18px; }
.link-box { display: flex; gap: 8px; margin-top: 8px; }
.link-box input { flex: 1; min-width: 0; font-family: ui-monospace, monospace; font-size: 12px; }
.people-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; max-width: 1200px; margin: 0 auto; align-items: start; }
.people-grid .panel { max-width: none; margin: 0; }
.table-scroll { overflow-x: auto; }
table.people { width: 100%; border-collapse: collapse; min-width: 560px; }
table.people td, table.people th { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
table.people th { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }
.pill { padding: 2px 8px; border-radius: 10px; font-size: 12px; background: var(--bg-hover); white-space: nowrap; }
.pill.ok { color: var(--ok); }
.pill.warn { color: #e0a030; }
.pill.off { color: var(--text-dim); }
.menu-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.menu-actions .btn { height: 30px; padding: 0 10px; font-size: 13px; }
.account-grid { display: grid; gap: 24px; max-width: 620px; margin: 0 auto; }
.account-grid .panel { margin: 0; }

@media (max-width: 1100px) {
  .people-grid { grid-template-columns: 1fr; }
  .watch { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  main { padding: 16px 0; }
  .chips, .watch-info, .side-list, .panel-pad, main > .row { padding: 0 16px; }
  .account-grid, .people-grid { gap: 16px; }
  .grid { grid-template-columns: 1fr; gap: 24px; }
  .grid .card .meta { padding: 0 16px; }
  .grid .thumb, .player-wrap { border-radius: 0; }
  .logo { font-size: 18px; }
  .topbar { gap: 8px; padding: 8px 12px; height: auto; flex-wrap: wrap; }
  .topbar .search { order: 2; }
  .topbar .top-actions { order: 3; }
  .topbar .nav { order: 4; width: 100%; overflow-x: auto; }
  .top-actions .label { display: none; }
  .top-actions { gap: 4px; }
  .top-actions .btn { padding: 0; width: 36px; justify-content: center; }
  .top-actions a.btn[href='/login'] { width: auto; padding: 0 12px; }
  .search input { padding: 0 12px; }
  .search button { width: 44px; }
  .panel { border-radius: 0; padding: 16px; }
  .side-item { grid-template-columns: 140px 1fr; }
  table.studio .hide-sm { display: none; }
}

/* ---------- v0.0.2: projects and events ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; max-width: 1200px; margin: 0 auto 20px; }
.page-head h1 { margin: 0; font-size: 24px; }
.wide { max-width: 1200px; margin: 0 auto; }
.event-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.event-card { display: block; background: var(--bg-elev); border-radius: var(--radius); overflow: hidden; border: 1px solid transparent; }
.event-card:hover { border-color: var(--border); }
.event-band { position: relative; height: 72px; background: var(--brand, var(--accent)); display: flex; align-items: center; padding: 0 16px; }
.event-band img { max-height: 44px; max-width: 60%; object-fit: contain; }
.event-band .pill { position: absolute; right: 10px; top: 10px; background: rgba(0,0,0,.55); color: #fff; }
.event-body { padding: 12px 16px 16px; }
.event-body h3 { margin: 0 0 6px; font-size: 16px; }
.pill.state-live { background: #d93025; color: #fff; }
.section-label { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); margin: 28px 0 12px; }
.event-hero { border-radius: var(--radius); overflow: hidden; background: var(--bg-elev); max-width: 1200px; margin: 0 auto 24px; }
.event-hero .band { background: var(--brand, var(--accent)); min-height: 120px; padding: 20px 24px; display: flex; align-items: center; gap: 16px; }
.event-hero .band img { max-height: 80px; max-width: 50%; object-fit: contain; }
.event-hero .info { padding: 20px 24px; }
.event-hero h1 { margin: 0 0 6px; font-size: 26px; }
.event-hero .desc { white-space: pre-wrap; margin-top: 12px; overflow-wrap: anywhere; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.setup-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; max-width: 1200px; margin: 0 auto; align-items: start; }
.setup-grid .panel { max-width: none; margin: 0; }
.setup-grid .span { grid-column: 1 / -1; }
.panel h2 { margin: 0 0 4px; font-size: 18px; }
.person { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.person:last-child { border-bottom: 0; }
.person .who-line { min-width: 0; overflow-wrap: anywhere; }
.person .btn { height: 30px; padding: 0 10px; font-size: 13px; flex-shrink: 0; }
.add-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.add-row input { flex: 1 1 200px; min-width: 0; }
.add-row select { width: auto; flex: 0 0 auto; }
.key-box { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.key-box code { flex: 1 1 200px; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; font-size: 13px; overflow-wrap: anywhere; }
input[type=color] { width: 100%; padding: 8px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
input[type=color] { height: 42px; padding: 4px; width: 80px; }
.dt { display: grid; grid-template-columns: minmax(0, 1fr) 86px; gap: 6px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.crumb { color: var(--text-dim); margin-bottom: 4px; }
.crumb a { text-decoration: underline; }
@media (max-width: 900px) {
  .setup-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .page-head, .section-label, .wide > .dim, .crumb { padding: 0 16px; }
  .event-grid { padding: 0 16px; }
  .event-hero { border-radius: 0; }
  .two { grid-template-columns: 1fr; }
}

/* ---------- v0.0.5: live ---------- */
.live-stage { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; max-width: 1200px; margin: 0 auto 16px; }
.live-stage video { width: 100%; height: 100%; display: block; background: #000; }
.live-stage .over { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: #fff; padding: 24px; background: linear-gradient(135deg, var(--brand, #222), #000); }
.live-stage .over h2 { margin: 0 0 6px; font-size: 22px; }
.live-stage .tag { position: absolute; left: 12px; top: 12px; z-index: 2; }
.live-stage .warn-over { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 14px; background: rgba(0,0,0,.7); color: #fff; z-index: 2; }
.pill.live { background: #d93025; color: #fff; font-weight: 700; letter-spacing: .04em; }
.pill.preview { background: #e0a030; color: #000; font-weight: 700; }
.signal { display: inline-flex; align-items: center; gap: 6px; }
.signal::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--text-dim); }
.signal.on::before { background: var(--ok); box-shadow: 0 0 0 3px rgba(62,207,142,.25); }
.ingest { width: 100%; border-collapse: collapse; margin-top: 8px; }
.ingest td { padding: 6px 4px; vertical-align: middle; }
.ingest td:first-child { color: var(--text-dim); white-space: nowrap; width: 1%; padding-right: 12px; }
.ingest code { display: block; padding: 8px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; font-size: 12.5px; overflow-wrap: anywhere; }
.ingest .btn { height: 32px; padding: 0 12px; }
.big-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 4px; }
.big-actions .btn { height: 44px; padding: 0 22px; font-size: 15px; }
.btn.golive { background: #d93025; color: #fff; }
details.guide { margin-top: 12px; }
details.guide summary { cursor: pointer; font-weight: 600; }
details.guide p, details.guide li { color: var(--text-dim); }
@media (max-width: 640px) {
  .live-stage { border-radius: 0; }
  .ingest td:first-child { white-space: normal; }
}

/* v0.0.6 viewer table in Live control */
.audience { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 16px; }
.audience h3 { margin: 0 0 12px; font-size: 15px; }
.audience .stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.audience .stat { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; min-width: 130px; }
.audience .stat strong { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.audience .stat span { font-size: 12px; color: var(--text-dim); }
table.audience-table { width: 100%; border-collapse: collapse; min-width: 640px; }
table.audience-table td, table.audience-table th { padding: 9px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; font-size: 14px; }
table.audience-table th { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
table.audience-table td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
table.audience-table .hint { margin: 2px 0 0; font-size: 12px; }

/* v0.0.7 recording on/off */
.rec { font-weight: 600; color: var(--text-dim); }
.rec.on { color: #e5482d; }
