:root {
  --bg: #ffffff; --bg2: #f2f2f2; --bg3: #e5e5e5; --fg: #0f0f0f; --fg2: #606060; --line: #e3e3e3;
  --hit: #15803d; --hit-bg: #dcfce7; --part: #a16207; --part-bg: #fef3c7; --miss: #b91c1c; --miss-bg: #fee2e2;
  --pend: #475569; --pend-bg: #e2e8f0; --nt-bg: transparent; --accent: #16a34a; --chart: #2563eb;
  --side-w: 220px; --top-h: 56px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f0f; --bg2: #212121; --bg3: #303030; --fg: #f1f1f1; --fg2: #aaaaaa; --line: #303030;
    --hit: #4ade80; --hit-bg: #14532d; --part: #fbbf24; --part-bg: #713f12; --miss: #f87171; --miss-bg: #7f1d1d;
    --pend: #cbd5e1; --pend-bg: #334155; --chart: #60a5fa; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f0f0f; --bg2: #212121; --bg3: #303030; --fg: #f1f1f1; --fg2: #aaaaaa; --line: #303030;
  --hit: #4ade80; --hit-bg: #14532d; --part: #fbbf24; --part-bg: #713f12; --miss: #f87171; --miss-bg: #7f1d1d;
  --pend: #cbd5e1; --pend-bg: #334155; --chart: #60a5fa; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Segoe UI", sans-serif; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* 상단 */
.top { position: fixed; inset: 0 0 auto 0; height: var(--top-h); display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: var(--bg); z-index: 20; }
.icon-btn { width: 40px; height: 40px; border: 0; background: none; border-radius: 50%; cursor: pointer; display: grid; place-items: center; flex: none; }
.icon-btn:hover { background: var(--bg2); }
.logo { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 18px; letter-spacing: -0.3px; flex: none; }
.logo .mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 15px; }
.search { flex: 1; max-width: 600px; margin: 0 auto; display: flex; min-width: 0; }
.search input { flex: 1; min-width: 0; height: 40px; padding: 0 16px; border: 1px solid var(--line); border-right: 0;
  border-radius: 20px 0 0 20px; background: var(--bg); color: var(--fg); font: inherit; font-size: 15px; outline: none; }
.search input:focus { border-color: #1c62b9; }
.search button { width: 60px; height: 40px; border: 1px solid var(--line); border-radius: 0 20px 20px 0; background: var(--bg2); cursor: pointer; display: grid; place-items: center; }

/* 왼쪽 메뉴 */
.side { position: fixed; top: var(--top-h); left: 0; bottom: 0; width: var(--side-w); padding: 8px 12px; overflow-y: auto; background: var(--bg); z-index: 15; }
.side a { display: flex; align-items: center; gap: 20px; height: 40px; padding: 0 12px; border-radius: 10px; font-size: 14px; }
.side a:hover { background: var(--bg2); }
.side a.on { background: var(--bg2); font-weight: 600; }
.side hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }
main { margin-left: var(--side-w); padding: calc(var(--top-h) + 8px) 24px 48px; min-height: 100vh; }
body.collapsed .side { display: none; }
body.collapsed main { margin-left: 0; }
@media (max-width: 900px) {
  .side { display: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  body.menu-open .side { display: block; }
  main { margin-left: 0; padding-left: 16px; padding-right: 16px; }
  .logo span:last-child { display: none; }
}

/* 칩 */
.chips { display: flex; gap: 10px; overflow-x: auto; padding: 4px 0 14px; scrollbar-width: none; }
.chip { flex: none; height: 32px; padding: 0 12px; border-radius: 8px; border: 0; background: var(--bg2); cursor: pointer; font-size: 14px; font-weight: 500; }
.chip.on { background: var(--fg); color: var(--bg); }
h2.sec { font-size: 20px; margin: 18px 0 12px; display: flex; align-items: baseline; gap: 10px; }
h2.sec small { font-size: 13px; color: var(--fg2); font-weight: 400; }

/* 영상 그리드 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 32px 16px; }
.card { display: block; border-radius: 12px; outline-offset: 4px; }
.card.sel { outline: 2px solid #1c62b9; }
.thumb { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: var(--bg3); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.card:hover .thumb img { transform: scale(1.03); }
.dur { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.8); color: #fff; font-size: 12px; font-weight: 500; padding: 1px 4px; border-radius: 4px; }
.watched { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: #e11; }
.meta { display: flex; gap: 12px; padding-top: 12px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; color: #fff; font-size: 15px; }
.meta-text { min-width: 0; }
.title { font-weight: 600; font-size: 16px; line-height: 22px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sub { color: var(--fg2); font-size: 13px; margin-top: 4px; }
.sub a:hover { color: var(--fg); }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.badge { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.s-hit { color: var(--hit); background: var(--hit-bg); }
.s-partial { color: var(--part); background: var(--part-bg); }
.s-miss { color: var(--miss); background: var(--miss-bg); }
.s-pending { color: var(--pend); background: var(--pend-bg); }
.s-not_triggered, .s-unscorable { color: var(--fg2); background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.s-wait { color: var(--fg2); background: var(--bg2); font-weight: 500; }

/* 영상 페이지 */
.watch { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 24px; max-width: 1700px; }
@media (max-width: 1100px) { .watch { grid-template-columns: 1fr; } }
.player { aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #000; }
.player iframe { width: 100%; height: 100%; border: 0; display: block; }
.w-title { font-size: 20px; font-weight: 700; margin: 12px 0 8px; line-height: 28px; }
.w-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.w-row .grow { flex: 1; min-width: 160px; }
.ch-name { font-weight: 600; font-size: 16px; }
.btn { height: 36px; padding: 0 14px; border-radius: 18px; border: 0; background: var(--bg2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.btn:hover { background: var(--bg3); }
.btn.on { background: var(--fg); color: var(--bg); }
.btn svg { width: 20px; height: 20px; }
.box { background: var(--bg2); border-radius: 12px; padding: 12px 14px; margin-top: 12px; }
.box p { margin: 4px 0; }
.muted { color: var(--fg2); }
.small { font-size: 12.5px; }

.pred { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; background: var(--bg); }
.pred-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pred-head .asset { font-weight: 700; font-size: 15px; }
.dir-up { color: var(--hit); } .dir-down { color: var(--miss); }
.pred .cond { margin-top: 6px; font-size: 13.5px; }
.pred blockquote { margin: 8px 0; padding: 6px 10px; border-left: 3px solid var(--line); color: var(--fg2); font-size: 13.5px; }
.pred .ts { color: #3ea6ff; font-weight: 600; cursor: pointer; }
.pred .ts:hover { text-decoration: underline; }
.result { font-size: 13px; margin-top: 6px; }
.chart { width: 100%; height: 110px; display: block; margin-top: 8px; }
.chart .ln { fill: none; stroke: var(--chart); stroke-width: 1.6; }
.chart .ref { stroke-width: 1; stroke-dasharray: 4 3; }
.chart .t { stroke: var(--hit); } .chart .s { stroke: var(--miss); } .chart .c { stroke: var(--part); } .chart .e { stroke: var(--fg2); }
.chart text { font-size: 10px; fill: var(--fg2); }

/* 채널 표 */
.table-wrap { overflow-x: auto; }
table.rank { width: 100%; border-collapse: collapse; min-width: 720px; }
table.rank th, table.rank td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.rank th:first-child, table.rank td:first-child { text-align: left; }
table.rank th { font-size: 12.5px; color: var(--fg2); font-weight: 600; }
table.rank td.name a { font-weight: 600; }
.bar { display: inline-block; height: 6px; border-radius: 3px; background: var(--accent); vertical-align: middle; margin-left: 6px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--bg2); }
.tag.good { color: var(--hit); background: var(--hit-bg); }
.ch-head { display: flex; align-items: center; gap: 16px; margin: 8px 0 16px; flex-wrap: wrap; }
.ch-head .avatar { width: 72px; height: 72px; font-size: 30px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin: 12px 0 20px; }
.stat { background: var(--bg2); border-radius: 12px; padding: 12px 14px; }
.stat b { display: block; font-size: 22px; margin-top: 2px; }
.prose { max-width: 760px; }
.prose h3 { margin-top: 26px; }
.prose li { margin: 4px 0; }
.empty { color: var(--fg2); padding: 40px 0; text-align: center; }
.loading { color: var(--fg2); padding: 40px; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 120px; margin: 12px 0 4px; }
.bars div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 1px; min-width: 6px; }
.bars .ok { background: var(--accent); } .bars .fail { background: var(--miss); }
.toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.topic-tabs { padding-bottom: 6px; }
.topic-tabs .chip { height: 36px; padding: 0 16px; font-size: 15px; font-weight: 600; }
.scatter { width: 100%; max-width: 680px; height: auto; display: block; margin: 8px 0 16px; }
.scatter circle { fill: var(--accent); fill-opacity: .55; stroke: var(--accent); }
.scatter text { font-size: 11px; fill: var(--fg2); }
.scatter .axis { stroke: var(--line); stroke-dasharray: 4 3; }
.brag-list { list-style: none; padding: 0; }
.brag-list li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
select.inp { height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); font: inherit; padding: 0 8px; }
.form { display: grid; gap: 10px; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--fg2); }
.form input { height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); font: inherit; font-size: 15px; }
.form input:focus { outline: 2px solid #1c62b9; border-color: transparent; }
.form .btn { justify-self: start; }
.btn:disabled { opacity: .5; cursor: default; }
.err { color: var(--miss); font-size: 13px; margin: 0; min-height: 1em; }
.help { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: grid; place-items: center; z-index: 50; }
.help[hidden] { display: none; }
.help-box { background: var(--bg); border-radius: 14px; padding: 20px 24px; min-width: 280px; }
.help-box dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; }
.help-box dt { font-family: ui-monospace, monospace; font-weight: 700; }
.help-box dd { margin: 0; }
