:root {
  --bg: #121316; --panel: #1b1d22; --panel2: #23262d; --line: #30343c;
  --fg: #e6e6e6; --muted: #9aa0aa; --acc: #e3b54a; --acc2: #6fb3ff; --red: #ff5a5a; --green: #6ad48a;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.red { color: var(--red); }

/* header */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 10px 18px; background: rgba(18,19,22,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: baseline; gap: 10px; }
.logo { font-weight: 800; letter-spacing: .5px; color: var(--acc); font-size: 18px; }
.sub { color: var(--muted); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: 7px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.tabs button:hover { background: var(--panel2); color: var(--fg); }
.tabs button.on { background: var(--panel2); color: var(--fg); box-shadow: inset 0 -2px 0 var(--acc); }

main { padding: 14px 18px 40px; }
.tab { display: none; }
.tab.on { display: block; }

/* controls */
.controls { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: end; margin-bottom: 12px; }
.group { display: flex; flex-direction: column; gap: 4px; }
.group > label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.zoomgrp { flex-direction: row; align-items: end; gap: 8px; }
.zoomgrp > label { align-self: center; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.seg.wrap { flex-wrap: wrap; }
.seg button { background: none; border: 0; padding: 5px 11px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.seg button:hover:not(:disabled) { background: var(--panel2); }
.seg button.on { background: var(--acc); color: #1a1a1a; font-weight: 600; }
.seg button:disabled { opacity: .35; cursor: default; }

/* scene strip */
.scenes { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; }
.scene { flex: 0 0 auto; width: 150px; cursor: pointer; border-radius: 8px; overflow: hidden;
  border: 2px solid transparent; background: var(--panel); }
.scene img { display: block; width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.scene span { display: block; padding: 3px 7px; font-size: 12px; color: var(--muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.scene.on { border-color: var(--acc); }
.scene.on span { color: var(--fg); }

/* model list + viewer */
.viewer-wrap { display: grid; grid-template-columns: 250px 1fr; gap: 12px; }
@media (max-width: 900px) { .viewer-wrap { grid-template-columns: 1fr; } }
.models { display: flex; flex-direction: column; gap: 4px; }
@media (max-width: 900px) { .models { flex-direction: row; overflow-x: auto; } .models .m { min-width: 150px; } }
.m { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px;
  cursor: pointer; position: relative; }
.m:hover { border-color: #4a505b; }
.m .k { position: absolute; right: 8px; top: 7px; font-size: 11px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }
.m .n { font-weight: 600; }
.m .d { font-size: 12px; color: var(--muted); }
.m .s { font-size: 12px; margin-top: 2px; display: flex; gap: 8px; }
.m .s b { color: var(--acc); }
.m.win .n::after { content: "★"; color: var(--acc); margin-left: 6px; font-size: 12px; }
.m.on { border-color: var(--acc2); background: #1e2633; box-shadow: inset 3px 0 0 var(--acc2); }
.m.orig.on { border-color: var(--acc); background: #2a261b; box-shadow: inset 3px 0 0 var(--acc); }

.viewer { position: relative; background: #0b0c0e; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  height: calc(100vh - 320px); min-height: 380px; cursor: grab; touch-action: none; user-select: none; }
.viewer.tall { height: calc(100vh - 200px); }
.viewer.grabbing { cursor: grabbing; }
.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.stage img { position: absolute; left: 0; top: 0; image-rendering: auto; pointer-events: none; -webkit-user-drag: none; }
.viewer.pixel .stage img { image-rendering: pixelated; }
.tag { position: absolute; top: 10px; padding: 4px 10px; border-radius: 6px; font-weight: 600; font-size: 13px;
  background: rgba(0,0,0,.72); pointer-events: none; z-index: 5; }
.tag.l { left: 10px; color: var(--acc); }
.viewer.slider .tag { text-transform: uppercase; letter-spacing: .06em; font-size: 12px; color: #fff; }
.viewer.slider .tag .q { text-transform: none; letter-spacing: 0; }
.tag.r { right: 10px; color: var(--acc2); }
.tag .q { color: var(--muted); font-weight: 400; margin-left: 6px; }

/* slider: wide invisible hit strip, thin visible line, pill knob */
.divider { position: absolute; top: 0; bottom: 0; width: 36px; margin-left: -18px; z-index: 4;
  cursor: ew-resize; touch-action: none; }
.divider::before { content: ""; position: absolute; top: 0; bottom: 0; left: 17px; width: 2px;
  background: rgba(255,255,255,.9); box-shadow: 0 0 4px rgba(0,0,0,.6); }
.divider .knob { position: absolute; top: 50%; left: 50%; width: 12px; height: 46px; transform: translate(-50%,-50%);
  border-radius: 7px; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.55); transition: transform .12s, width .12s; }
.divider:hover .knob, .divider.drag .knob { width: 16px; transform: translate(-50%,-50%) scale(1.08); }

.loading { position: absolute; right: 10px; bottom: 10px; z-index: 6; font-size: 12px; color: var(--muted);
  background: rgba(0,0,0,.6); padding: 2px 8px; border-radius: 5px; display: none; }
.loading.on { display: block; }

/* grid mode */
.grid { position: absolute; inset: 0; display: grid; gap: 2px; background: #000; }
.cell { position: relative; overflow: hidden; background: #0b0c0e; }
.cell .stage img { position: absolute; }
.cell .tag { top: 6px; left: 6px; right: auto; font-size: 12px; padding: 2px 7px; }

.hint { color: var(--muted); font-size: 13px; margin: 8px 0; max-width: 1100px; }
kbd { background: var(--panel2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px;
  padding: 0 5px; font: 12px ui-monospace, monospace; color: var(--fg); }

/* turntable */
.turnvideo { background: #0b0c0e; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.turnvideo video { width: 100%; max-height: calc(100vh - 220px); display: block; margin: auto; object-fit: contain; }

/* prose */
.prose { max-width: 1050px; }
.prose h2 { margin: 26px 0 8px; font-size: 18px; }
.prose li { margin: 4px 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.card.win { border-color: #6b5520; background: linear-gradient(180deg, #2a2416, var(--panel)); }
.card .sc { font-size: 26px; font-weight: 800; color: var(--acc); }
.card .nm { font-weight: 700; }
.card .kd { color: var(--muted); font-size: 12px; }
.card p { margin: 6px 0 0; }
.tbl { border-collapse: collapse; font-variant-numeric: tabular-nums; margin: 6px 0; }
.tbl th, .tbl td { padding: 5px 10px; border-bottom: 1px solid var(--line); text-align: right; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 12px; }
.tbl td.hi { background: rgba(227,181,74,.12); }
