:root {
  --bg: #0b0e14; --surface: #121722; --surface-2: #182033; --line: #263049; --line-2: #33405e;
  --ink: #eef1f6; --mute: #a6afc0; --faint: #7c879c;
  --gold: #e2b65e; --gold-ink: #1c1405; --blue: #6f9bff; --ok: #5fd39a; --warn: #f2b84b; --bad: #ff8080;
  --shot-a: #23314f; --shot-b: #2c3b5e;
  --r-sm: 8px; --r: 12px; --r-lg: 16px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f5f6fa; --surface: #ffffff; --surface-2: #eef1f7; --line: #d8deea; --line-2: #c3cbdc;
  --ink: #0f172a; --mute: #475569; --faint: #64748b;
  --gold: #8a5a08; --gold-ink: #ffffff; --blue: #1e40af; --ok: #15803d; --warn: #a16207; --bad: #b91c1c;
  --shot-a: #dbe3f3; --shot-b: #c9d4ec;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 var(--s4); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* top bar */
.bar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(12px); -webkit-backdrop-filter: saturate(140%) blur(12px); border-bottom: 1px solid var(--line); }
.bar .wrap { display: flex; align-items: center; gap: var(--s2); min-height: 60px; }
.brand { display: flex; align-items: center; gap: var(--s2); font-weight: 700; letter-spacing: .2px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.brand b { color: var(--gold); }
.brand img { width: 28px; height: 28px; border-radius: 8px; }
.search { flex: 1; min-width: 0; position: relative; }
.search input { width: 100%; height: 44px; padding: 0 var(--s3) 0 40px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); }
.search svg { position: absolute; left: 13px; top: 12px; color: var(--faint); }
.iconbtn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); transition: border-color .2s, background .2s; text-decoration: none; }
.iconbtn:hover { border-color: var(--line-2); background: var(--surface-2); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s4);
  border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600; text-decoration: none; transition: background .2s, border-color .2s; }
.btn:hover { background: var(--surface-2); border-color: var(--line-2); }
.btn.gold { background: var(--gold); color: var(--gold-ink); border-color: transparent; }
.btn.gold:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn[disabled] { opacity: .55; cursor: progress; }

/* chips */
.chips { display: flex; gap: var(--s2); overflow-x: auto; padding: var(--s3) 0; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--mute); font-size: 14px; font-weight: 600; white-space: nowrap; transition: all .2s; }
.chip:hover { color: var(--ink); border-color: var(--line-2); }
.chip[aria-pressed="true"] { background: var(--gold); color: var(--gold-ink); border-color: transparent; }
.chip .n { font: 12px var(--mono); opacity: .75; }
select.chip { appearance: none; -webkit-appearance: none; padding-right: 14px; }

/* grid + cards */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); padding-bottom: var(--s6); }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); } }
@media (min-width: 1000px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  overflow: hidden; text-decoration: none; color: var(--ink); transition: border-color .2s, transform .2s; }
.card:hover { border-color: var(--line-2); }
.thumb { position: relative; aspect-ratio: 4 / 5; background: var(--surface-2); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.badge { position: absolute; display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px; font: 600 12px/1.3 var(--sans);
  background: rgba(8, 10, 16, .72); color: #fff; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.badge.tl { top: 8px; left: 8px; } .badge.tr { top: 8px; right: 8px; } .badge.bl { bottom: 8px; left: 8px; }
.badge.hot { background: var(--gold); color: #1c1405; }
.proc { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: var(--s2); padding: var(--s3);
  background: linear-gradient(160deg, var(--surface-2), var(--bg)); color: var(--mute); font-size: 13px; text-align: center; }
.proc.err { color: var(--bad); }
.spin { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--gold); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.meta { padding: var(--s3); display: grid; gap: 2px; min-width: 0; }
.meta .t { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta .s { color: var(--mute); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta .f { color: var(--faint); font-size: 12px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty { padding: 56px var(--s4); text-align: center; color: var(--mute); }
.empty h2 { color: var(--ink); margin: 0 0 var(--s2); font-size: 20px; }
.more { display: flex; justify-content: center; padding: var(--s4) 0 var(--s6); }

/* detail */
.detail { display: grid; gap: var(--s5); padding: var(--s4) 0 var(--s6); }
@media (min-width: 960px) { .detail { grid-template-columns: 380px minmax(0, 1fr); align-items: start; } .side { position: sticky; top: 76px; } }
.side { display: grid; gap: var(--s3); }
.player { background: #000; border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--line); }
.player video { width: 100%; display: block; max-height: 70vh; background: #000; }
.player img { width: 100%; display: block; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; min-width: 0; }
.stat .k { color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.stat .v { font: 600 17px/1.3 var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.h1 { font-size: clamp(22px, 4vw, 30px); line-height: 1.2; margin: 0; letter-spacing: -.01em; }
.subline { color: var(--mute); margin-top: 6px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--s3); }
.tag { padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; color: var(--mute); text-decoration: none; }
.tag.gold { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 45%, var(--line)); }
.callout { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: var(--r); padding: var(--s4); }
.callout p { margin: 0; }
.note { display: grid; gap: var(--s2); }
.note textarea { width: 100%; min-height: 76px; padding: var(--s3); border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); }

/* tabs */
.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; position: sticky; top: 60px; background: var(--bg); z-index: 10; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; min-height: 46px; padding: 0 14px; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--mute); font-weight: 600; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--gold); }
.panel { padding-top: var(--s4); }

/* markdown */
.md { max-width: 76ch; }
.md h1, .md h2, .md h3 { line-height: 1.25; margin: 1.4em 0 .5em; letter-spacing: -.005em; }
.md h1 { font-size: 22px; } .md h2 { font-size: 19px; } .md h3 { font-size: 16px; color: var(--gold); text-transform: uppercase; letter-spacing: .05em; }
.md p, .md ul, .md ol { margin: .6em 0; }
.md li { margin: .25em 0; }
.md code { font: 14px var(--mono); background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.md pre { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s3); overflow-x: auto; font: 13px/1.5 var(--mono); }
.md blockquote { margin: .8em 0; padding: .2em var(--s4); border-left: 3px solid var(--line-2); color: var(--mute); }
.md table { border-collapse: collapse; width: 100%; font-size: 14px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1.6em 0; }
.md .ts { font-family: var(--mono); color: var(--blue); cursor: pointer; text-decoration: underline dotted; }

/* timeline */
.tl { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s3); }
.tl svg { width: 100%; height: auto; display: block; cursor: crosshair; touch-action: pan-y; }
.tl .legend { display: flex; flex-wrap: wrap; gap: var(--s3); color: var(--mute); font-size: 12px; margin-top: var(--s2); }
.tl .legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--c); }
.shots { display: flex; gap: 6px; overflow-x: auto; padding: var(--s3) 0; }
.shot { flex: none; width: 74px; text-align: center; font: 11px var(--mono); color: var(--mute); background: none; border: 0; padding: 0; }
.shot div { width: 74px; height: 131px; border-radius: 8px; background-repeat: no-repeat; border: 1px solid var(--line); }
.events { list-style: none; margin: var(--s3) 0 0; padding: 0; display: grid; gap: 2px; }
.events li { display: grid; grid-template-columns: 64px 74px minmax(0, 1fr); gap: var(--s2); padding: 8px 10px; border-radius: var(--r-sm); font-size: 14px; }
.events li:nth-child(odd) { background: var(--surface); }
.events .t { font-family: var(--mono); color: var(--blue); cursor: pointer; }
.events .k { color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding-top: 2px; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--faint); } .kv dd { margin: 0; overflow-wrap: anywhere; }

/* setup */
.setup { max-width: 760px; padding: var(--s5) 0 64px; }
.setup h1 { font-size: 26px; margin: 0 0 var(--s2); }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s4) var(--s4) var(--s3); margin: var(--s3) 0; }
.step h2 { font-size: 17px; margin: 0 0 var(--s2); display: flex; gap: var(--s2); align-items: center; }
.step h2 .num { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--gold); color: var(--gold-ink); font: 700 14px var(--mono); flex: none; }
.step ol, .step ul { padding-left: 1.3em; margin: var(--s2) 0; } .step li { margin: 6px 0; }
.copy { display: flex; gap: var(--s2); align-items: stretch; margin: var(--s2) 0; }
.copy code { flex: 1; min-width: 0; padding: 10px 12px; border-radius: var(--r-sm); background: var(--bg); border: 1px solid var(--line); font: 13px var(--mono); overflow-x: auto; white-space: nowrap; }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); margin: var(--s3) 0; }
.seg button { min-height: 38px; padding: 0 16px; border: 0; border-radius: 999px; background: none; color: var(--mute); font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 0 var(--line-2); }
.muted { color: var(--mute); } .small { font-size: 14px; } .mono { font-family: var(--mono); }

/* dialogs / toast */
dialog { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); color: var(--ink); padding: var(--s5); width: min(520px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
dialog input, dialog textarea { width: 100%; padding: 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--bg); margin: 6px 0 12px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px;
  font-weight: 600; font-size: 14px; z-index: 50; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.on { opacity: 1; }
.login { min-height: 80vh; display: grid; place-items: center; text-align: center; padding: var(--s5); color: var(--mute); }
.login h1 { color: var(--ink); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
