:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #121620;
  --muted: #667085;
  --line: #d9e0ea;
  --primary: #2f6df6;
  --primary-2: #174ecf;
  --accent: #17a970;
  --danger: #d92d20;
  --shadow: 0 24px 70px rgba(15, 23, 42, .12);
  --radius: 24px;
}

body.dark {
  --bg: #0b1020;
  --surface: #121a2c;
  --surface-2: #1a2438;
  --text: #f4f7fb;
  --muted: #a5b4c8;
  --line: #26344c;
  --primary: #74a2ff;
  --primary-2: #9bbcff;
  --accent: #53d39b;
  --danger: #ff776d;
  --shadow: 0 24px 70px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(47, 109, 246, .16), transparent 34rem),
    radial-gradient(circle at top right, rgba(23, 169, 112, .14), transparent 30rem),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { cursor: pointer; }

.site-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 18px 0;
  backdrop-filter: blur(18px);
}
.brand { display: inline-flex; align-items: center; gap: 12px; min-width: max-content; }
.brand-mark {
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 15px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white; font-weight: 900; letter-spacing: -.05em;
  box-shadow: var(--shadow);
}
.brand strong { display: block; font-size: 17px; }
.brand small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.nav { display: flex; gap: 8px; padding: 7px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.55); }
body.dark .nav { background: rgba(18, 26, 44, .72); }
.nav a { color: var(--muted); padding: 9px 13px; border-radius: 999px; font-size: 14px; }
.nav a:hover { color: var(--text); background: var(--surface-2); }
.top-actions { display: flex; gap: 10px; }

.primary, .soft, .ghost, .danger, .tab {
  border: 0; border-radius: 14px; padding: 11px 15px; font-weight: 800;
}
.primary { background: var(--primary); color: white; }
.primary:hover { background: var(--primary-2); }
.soft { background: rgba(47,109,246,.11); color: var(--primary); border: 1px solid rgba(47,109,246,.2); }
.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.danger { background: rgba(217,45,32,.1); color: var(--danger); border: 1px solid rgba(217,45,32,.2); }
.link-button { display: inline-flex; align-items: center; justify-content: center; }

.notice {
  display: flex; gap: 10px; align-items: center;
  margin: 10px 0 22px; padding: 13px 16px;
  border: 1px solid rgba(47,109,246,.22);
  border-radius: 18px;
  background: rgba(47,109,246,.08);
  color: var(--muted);
}
.notice strong { color: var(--primary); }

.hero {
  display: grid; grid-template-columns: 1.15fr .85fr; gap: 24px; align-items: stretch;
  padding: 42px 0 26px;
}
.eyebrow { margin: 0 0 8px; color: var(--primary); font-weight: 900; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(38px, 6vw, 74px); line-height: .95; letter-spacing: -.06em; }
h2 { margin: 0 0 8px; font-size: 24px; letter-spacing: -.03em; }
p { line-height: 1.65; }
.lead { color: var(--muted); font-size: 18px; max-width: 650px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }
.glass, .panel {
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hero-card { padding: 24px; display: flex; flex-direction: column; justify-content: space-between; min-height: 330px; }
.hero-card-head { display: flex; justify-content: space-between; color: var(--muted); }
.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.metric-grid article { padding: 18px; border-radius: 20px; background: var(--surface-2); }
.metric-grid small { display: block; color: var(--muted); margin-bottom: 8px; }
.metric-grid strong { font-size: 28px; letter-spacing: -.05em; }

.panel { padding: 22px; margin: 18px 0; }
.search-panel { display: grid; grid-template-columns: 1fr minmax(280px, 420px); gap: 20px; align-items: center; }
.search-panel p, .recap-card p { color: var(--muted); margin: 0; }
.searchbox { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border: 1px solid var(--line); padding: 10px 14px; border-radius: 18px; }
.searchbox span { color: var(--muted); font-weight: 800; }
.searchbox input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); padding: 8px; }

.section-grid { display: grid; grid-template-columns: 1.55fr .85fr; gap: 18px; align-items: start; }
.section-grid .wide { grid-column: auto; }
.section-head { display: flex; align-items: start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.section-head.compact { margin-bottom: 12px; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab { background: var(--surface-2); color: var(--muted); padding: 9px 12px; }
.tab.active { background: var(--primary); color: white; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 760px; }
th, td { padding: 14px 10px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.avatar { width: 36px; height: 36px; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(135deg, var(--primary), var(--accent)); color: white; font-weight: 900; }
.person { display: flex; align-items: center; gap: 10px; }
.person b { display: block; }
.person small { color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 999px; background: rgba(23,169,112,.12); color: var(--accent); font-weight: 900; font-size: 12px; }
.icon-btn { padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); }
.icon-btn.active { color: white; background: var(--primary); border-color: var(--primary); }
.checklist { padding-left: 0; list-style: none; margin: 12px 0 0; }
.checklist li { padding: 12px 0 12px 30px; border-bottom: 1px solid var(--line); position: relative; color: var(--muted); }
.checklist li::before { content: "✓"; position: absolute; left: 0; color: var(--accent); font-weight: 900; }

.streamer-list { display: grid; gap: 10px; }
.streamer-item { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 13px; border-radius: 18px; background: var(--surface-2); border: 1px solid transparent; }
.streamer-item:hover, .streamer-item.selected { border-color: rgba(47,109,246,.38); }
.streamer-item p { margin: 2px 0 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail-card { min-height: 540px; }
.detail-hero { display: flex; gap: 16px; align-items: start; justify-content: space-between; margin-bottom: 18px; }
.detail-title { display: flex; gap: 14px; align-items: center; }
.detail-title .avatar { width: 54px; height: 54px; border-radius: 18px; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 18px 0; }
.stat { background: var(--surface-2); border-radius: 18px; padding: 14px; }
.stat small { color: var(--muted); display: block; margin-bottom: 6px; }
.stat strong { font-size: 20px; letter-spacing: -.04em; }
#viewerChart { width: 100%; height: auto; border-radius: 20px; background: var(--surface-2); }

.recap-output { margin: 20px 0; padding: 18px; border-radius: 20px; background: var(--surface-2); white-space: pre-line; line-height: 1.75; }
.recap-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.session-list { display: grid; gap: 10px; max-height: 360px; overflow: auto; }
.session { border: 1px solid var(--line); border-radius: 16px; padding: 12px; background: var(--surface-2); }
.session b { display: block; }
.session small { color: var(--muted); }
.footer { padding: 32px 0 56px; color: var(--muted); font-size: 14px; }
.footer p { margin: 6px 0; }

.dialog { border: 0; border-radius: 24px; padding: 0; background: transparent; color: var(--text); }
.dialog::backdrop { background: rgba(0,0,0,.45); backdrop-filter: blur(5px); }
.dialog-card { position: relative; width: min(420px, calc(100vw - 32px)); padding: 26px; border-radius: 24px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.close { position: absolute; right: 16px; top: 14px; border: 0; background: transparent; color: var(--muted); font-size: 26px; }
.dialog-card label { display: grid; gap: 8px; color: var(--muted); font-weight: 800; }
.dialog-card input { border: 1px solid var(--line); background: var(--surface-2); color: var(--text); border-radius: 14px; padding: 12px; outline: 0; }
.dialog-card menu { padding: 0; margin: 18px 0 0; }
.dialog-card .primary { width: 100%; }

.toast { position: fixed; right: 20px; bottom: 20px; background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow); z-index: 20; }

@media (max-width: 920px) {
  .topbar { flex-wrap: wrap; }
  .nav { order: 3; width: 100%; overflow-x: auto; justify-content: center; }
  .hero, .section-grid, .search-panel { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .site-shell { width: min(100% - 22px, 1180px); }
  .top-actions { width: 100%; }
  .top-actions button { flex: 1; }
  .metric-grid, .stat-row { grid-template-columns: 1fr; }
  .section-head { display: grid; }
  h1 { font-size: 42px; }
}

/* v5 live API additions */
.api-status {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 18px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  margin: 14px 0;
}
.api-status strong { color: var(--primary); }
.api-status span { color: var(--muted); font-size: 14px; }
.api-status button { justify-self: start; }
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-large { width: 54px; height: 54px; border-radius: 18px; }
.badge.off { opacity: .55; color: var(--muted); background: var(--surface-2); }
.badge.warn { color: #b54708; background: rgba(245, 158, 11, .14); }
body.dark .badge.warn { color: #ffd18a; }
.mini-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(47,109,246,.11);
  color: var(--primary);
  border: 1px solid rgba(47,109,246,.2);
  font-weight: 900;
  white-space: nowrap;
}
.inline-note {
  padding: 16px;
  border-radius: 18px;
  background: var(--surface-2);
  color: var(--muted);
  line-height: 1.7;
}
.inline-note strong { color: var(--text); }
.thumb {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: 20px;
  border: 1px solid var(--line);
  margin: 0 0 14px;
  background: var(--surface-2);
}
.detail-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0 16px;
}
.data-pill {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
}
button:disabled {
  opacity: .6;
  cursor: wait;
}
