/* Steam Indie Radar — 대시보드 스타일
   라이트/다크 모두 지원. 색은 전부 토큰으로 정의합니다. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --border: #dfe3ea;
  --text: #12151b;
  --text-dim: #5b6472;
  --text-faint: #8b95a4;
  --accent: #2f6df6;
  --accent-soft: #e6eeff;
  --up: #12874a;
  --down: #c0392b;
  --warn: #b7791f;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 14px rgba(16, 24, 40, .06);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1017;
    --surface: #151a23;
    --surface-2: #1c222d;
    --border: #262d3a;
    --text: #e6eaf2;
    --text-dim: #9aa5b6;
    --text-faint: #6b7686;
    --accent: #5b8dff;
    --accent-soft: #1a2740;
    --up: #3ddc84;
    --down: #ff6b6b;
    --warn: #e0b341;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
        "Pretendard", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; }

/* ---------------------------------------------------------------- topbar */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; padding: 14px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  font-size: 26px; line-height: 1; color: var(--accent);
}
.topbar h1 { font-size: 17px; letter-spacing: -.01em; }
.tagline { margin: 2px 0 0; font-size: 12px; color: var(--text-dim); }

.topbar-right { display: flex; align-items: center; gap: 16px; }

#search {
  width: 260px; padding: 8px 12px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px;
}
#search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* 뷰 전환 탭 */
.viewtabs { display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 9px; }
.viewtabs button {
  padding: 6px 14px; border: 0; border-radius: 7px; cursor: pointer;
  background: transparent; color: var(--text-dim); font-size: 13px; font-weight: 550;
}
.viewtabs button:hover { color: var(--text); }
.viewtabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.stat-pills { display: flex; gap: 8px; }
.pill {
  padding: 5px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12px; color: var(--text-dim); white-space: nowrap;
}
.pill b { color: var(--text); font-weight: 650; }
.pill.warn { color: var(--warn); border-color: var(--warn); }

/* ---------------------------------------------------------------- layout */

.layout { display: grid; grid-template-columns: 268px 1fr; align-items: start; }
/* 요약·가이드 화면에서는 사이드바를 접고 본문을 넓게 씁니다 */
.layout.no-sidebar { grid-template-columns: 1fr; }
.layout.no-sidebar .sidebar { display: none; }

.sidebar {
  position: sticky; top: 63px;
  max-height: calc(100vh - 63px); overflow-y: auto;
  padding: 18px 16px 40px;
  border-right: 1px solid var(--border);
}

.panel { margin-bottom: 26px; }
.panel h2 {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-faint); margin-bottom: 10px;
}

.hint { margin: 6px 0 10px; font-size: 12px; color: var(--text-dim); }

.link {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--accent); font-size: 11px; text-transform: none; letter-spacing: 0;
}

/* segmented sort control */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  padding: 6px 11px; border-radius: 7px; cursor: pointer;
  background: var(--surface); color: var(--text-dim);
  border: 1px solid var(--border); font-size: 12.5px;
}
.seg button:hover { color: var(--text); }
.seg button.active {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}

.slider-row { margin-bottom: 12px; }
.slider-row label {
  display: flex; justify-content: space-between;
  font-size: 12.5px; color: var(--text-dim); margin-bottom: 4px;
}
.slider-row label span { color: var(--text); font-variant-numeric: tabular-nums; }
.slider-row input[type=range] { width: 100%; accent-color: var(--accent); }
.slider-row.disabled { opacity: .4; pointer-events: none; }

.field { display: block; margin-bottom: 12px; font-size: 12.5px; color: var(--text-dim); }
.field select {
  display: block; width: 100%; margin-top: 4px; padding: 7px 9px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 7px; font-size: 13px;
}

.check {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text-dim); margin-bottom: 8px; cursor: pointer;
}
.check input { accent-color: var(--accent); }

/* --------------------------------------------------------------- content */

.content { padding: 18px 22px 60px; min-width: 0; }

.results-bar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px; font-size: 12.5px; color: var(--text-dim);
}
.spacer { flex: 1; }
.legend-note { color: var(--text-faint); }

.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
}

/* ------------------------------------------------------------------ card */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; cursor: pointer;
  box-shadow: var(--shadow); transition: transform .12s, border-color .12s;
  display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }

.card-media { position: relative; aspect-ratio: 460 / 215; background: var(--surface-2); }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }

.card-rank {
  position: absolute; top: 8px; left: 8px;
  display: flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  background: rgba(0, 0, 0, .72); color: #fff;
  font-size: 12px; font-weight: 650; backdrop-filter: blur(4px);
}
.delta { font-size: 11px; font-weight: 600; }
.delta.up { color: #3ddc84; }
.delta.down { color: #ff8080; }
.delta.new { color: #ffd479; }

.card-watch {
  position: absolute; top: 8px; right: 8px;
  width: 28px; height: 28px; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, .6); color: #fff; cursor: pointer;
  font-size: 14px; line-height: 1; backdrop-filter: blur(4px);
}
.card-watch.on { background: var(--accent); }

.card-body { padding: 12px 13px 13px; display: flex; flex-direction: column; gap: 9px; flex: 1; }

.card-title {
  font-size: 14.5px; font-weight: 650; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta { font-size: 11.5px; color: var(--text-faint); }

.score-row { display: flex; align-items: center; gap: 10px; }
.score-big {
  font-size: 22px; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.bars { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.bar { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--text-faint); }
.bar-label { width: 34px; flex: none; }
.bar-track { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 2px; background: var(--accent); }

.metrics {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  padding-top: 9px; border-top: 1px solid var(--border);
}
.metric { text-align: center; }
.metric .v { font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.metric .k { font-size: 10px; color: var(--text-faint); }

.spark { height: 26px; width: 100%; display: block; }
.spark-empty { font-size: 10.5px; color: var(--text-faint); text-align: center; padding: 6px 0; }

.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag {
  padding: 2px 7px; border-radius: 5px; font-size: 10.5px;
  background: var(--surface-2); color: var(--text-dim);
}

.empty { text-align: center; padding: 70px 20px; color: var(--text-dim); }
.empty code { background: var(--surface-2); padding: 2px 6px; border-radius: 4px; }

/* ---------------------------------------------------------------- drawer */

.drawer-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, .45);
}

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: min(620px, 94vw); overflow-y: auto;
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: -8px 0 30px rgba(0, 0, 0, .25);
}

.drawer-close {
  position: absolute; top: 12px; right: 14px; z-index: 2;
  width: 30px; height: 30px; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, .6); color: #fff; cursor: pointer; font-size: 13px;
}

.drawer-hero { width: 100%; aspect-ratio: 460 / 215; object-fit: cover; display: block; }
.drawer-inner { padding: 18px 22px 50px; }
.drawer-inner h2 { font-size: 20px; margin-bottom: 4px; }
.drawer-sub { font-size: 12.5px; color: var(--text-dim); margin-bottom: 14px; }
.drawer-desc { font-size: 13.5px; color: var(--text-dim); margin: 14px 0; line-height: 1.6; }

.kv { display: grid; grid-template-columns: 84px 1fr; gap: 6px 12px; font-size: 13px; margin: 14px 0; }
.kv dt { color: var(--text-faint); }
.kv dd { margin: 0; }

.score-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 8px; margin: 16px 0;
}
.score-cell {
  background: var(--surface-2); border-radius: 9px; padding: 10px; text-align: center;
}
.score-cell .v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.score-cell .k { font-size: 11px; color: var(--text-faint); margin-top: 2px; }

.chart-block { margin: 18px 0; }
.chart-block h3 { font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; }
.chart { width: 100%; height: 110px; display: block; }
.chart-note { font-size: 11.5px; color: var(--text-faint); }

.btn {
  display: inline-block; padding: 8px 14px; border-radius: 8px;
  background: var(--accent); color: #fff; text-decoration: none;
  font-size: 13px; font-weight: 600; border: 0; cursor: pointer;
}
.btn.ghost { background: var(--surface-2); color: var(--text); }
.drawer-actions { display: flex; gap: 8px; margin: 16px 0; }

/* ------------------------------------------------------- 가이드 / 요약 문서 */

.doc { max-width: 820px; }
.doc h2 { font-size: 21px; margin-bottom: 10px; }
.doc h3 {
  font-size: 14.5px; margin: 26px 0 8px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.doc p { margin: 8px 0; color: var(--text-dim); line-height: 1.7; }
.doc-lead {
  padding: 12px 14px; border-radius: 9px;
  background: var(--accent-soft); color: var(--text) !important;
  border-left: 3px solid var(--accent);
}
.doc strong, .doc b { color: var(--text); font-weight: 650; }
.doc ul { margin: 8px 0; padding-left: 20px; color: var(--text-dim); line-height: 1.8; }
.doc code {
  background: var(--surface-2); padding: 1px 5px; border-radius: 4px;
  font-size: 12.5px; color: var(--text);
}
.doc-table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13px; }
.doc-table th {
  text-align: left; padding: 8px 12px 8px 0; width: 130px;
  color: var(--text); font-weight: 600; vertical-align: top;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.doc-table td {
  padding: 8px 0; color: var(--text-dim);
  border-bottom: 1px solid var(--border); line-height: 1.6;
}
.doc-warn {
  padding: 11px 14px; border-radius: 9px; margin-top: 12px !important;
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border-left: 3px solid var(--warn);
}
.doc-code {
  background: var(--surface-2); padding: 12px 14px; border-radius: 9px;
  font-size: 12.5px; line-height: 1.7; overflow-x: auto; color: var(--text-dim);
}

/* ------------------------------------------------------------ 요약 분석 */

.sum-head { margin-bottom: 20px; }
.sum-head h2 { font-size: 21px; }
.sum-head p { margin: 4px 0 0; font-size: 13px; color: var(--text-dim); }

.sum-stats {
  display: grid; gap: 10px; margin: 18px 0 26px;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}
.sum-stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 13px 14px;
}
.sum-stat .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sum-stat .k { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }

.sum-section { margin-bottom: 30px; }
.sum-section h3 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-faint); margin-bottom: 4px;
}
.sum-section .sub { font-size: 12.5px; color: var(--text-dim); margin: 0 0 12px; }

.pick {
  display: flex; gap: 13px; padding: 12px; margin-bottom: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer; transition: border-color .12s;
}
.pick:hover { border-color: var(--accent); }
.pick img { width: 108px; aspect-ratio: 460/215; object-fit: cover; border-radius: 6px; flex: none; }
.pick-body { min-width: 0; flex: 1; }
.pick-name { font-weight: 650; font-size: 14px; }
.pick-num {
  float: right; font-size: 17px; font-weight: 700;
  color: var(--accent); font-variant-numeric: tabular-nums;
}
.pick-meta { font-size: 11.5px; color: var(--text-faint); margin: 3px 0 6px; }
.pick-why { display: flex; flex-wrap: wrap; gap: 5px; }
.why {
  font-size: 11px; padding: 3px 8px; border-radius: 5px;
  background: var(--accent-soft); color: var(--text);
}

.lift-row { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; font-size: 12.5px; }
.lift-name { width: 150px; flex: none; color: var(--text); }
.lift-track { flex: 1; height: 7px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.lift-fill { height: 100%; background: var(--accent); border-radius: 4px; }
.lift-val { width: 96px; flex: none; text-align: right; color: var(--text-faint); font-size: 11.5px; }

.note {
  padding: 11px 14px; border-radius: 9px; font-size: 12.5px; line-height: 1.65;
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border-left: 3px solid var(--warn); color: var(--text-dim); margin-bottom: 10px;
}
.note b { color: var(--text); }

@media (max-width: 900px) {
  .viewtabs { order: -1; width: 100%; }
  .pick img { width: 76px; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--border); }
  .topbar { flex-wrap: wrap; }
  #search { width: 100%; }
}
