/* 색은 여기에서만 정한다. 차트 색은 dataviz 기준 팔레트의 slot 1(파랑) 하나 — 차트마다 계열이 하나라 범례가 없다. */
:root {
  color-scheme: light;
  --surface-0: #f4f4f2;
  --surface-1: #fcfcfb;
  --line: #e4e3df;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #7a7974;
  --series-1: #2a78d6;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --user-bubble: #2a78d6;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface-0: #121211;
    --surface-1: #1a1a19;
    --line: #2e2e2c;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8e86;
    --series-1: #3987e5;
    --accent: #3987e5;
    --user-bubble: #2f6fbf;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--surface-0); color: var(--text-primary);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", system-ui, sans-serif; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 8px; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }

.login { max-width: 360px; margin: 18vh auto 0; padding: 0 20px; text-align: center; }
.login form { margin-top: 24px; display: grid; gap: 12px; }
.login input { padding: 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-1); color: inherit; font: inherit; }
.login button, .chat-form button { padding: 12px 16px; border: 0; border-radius: var(--radius); background: var(--accent); color: var(--accent-ink); font-weight: 600; }

.top { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: baseline;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 10px; background: var(--surface-0); }
main { padding: 0 12px calc(env(safe-area-inset-bottom) + 84px); max-width: 720px; margin: 0 auto; }
.view { display: grid; gap: 12px; }

.card { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.tile .label { font-size: 12px; color: var(--text-secondary); }
.tile .value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile .sub { font-size: 12px; color: var(--text-muted); }

.filters { display: flex; gap: 8px; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-1); color: var(--text-secondary); }
.chip.on { background: var(--text-primary); color: var(--surface-1); border-color: var(--text-primary); }

.list { display: grid; gap: 8px; }
.row { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; text-align: left; width: 100%;
  background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; color: inherit; }
.row .icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-0); font-size: 18px; }
.row .main { min-width: 0; }
.row .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { font-size: 13px; color: var(--text-secondary); }
.row .right { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: right; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--text-secondary); font-weight: 500; font-size: 12px; }

/* 차트: 얇은 막대(최대 24px, 끝만 둥글게), 2px 선, 1px 실선 격자 */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--text-muted); font-size: 11px; }
.chart .bar { fill: var(--series-1); }
.chart .bar.dim { opacity: .45; }
.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; }
.chart .end-label { fill: var(--text-primary); font-size: 12px; font-weight: 600; }
.chart .hit { fill: transparent; }
.chart .cross { stroke: var(--text-muted); stroke-width: 1; }
.tip { position: absolute; pointer-events: none; background: var(--text-primary); color: var(--surface-1); font-size: 12px;
  padding: 4px 8px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, -110%); }
details.table-view summary { font-size: 12px; color: var(--text-muted); cursor: pointer; margin-top: 6px; }

.coach { min-height: calc(100vh - 160px); align-content: end; }
.chat { display: grid; gap: 10px; }
.msg { max-width: 88%; padding: 10px 12px; border-radius: 16px; white-space: pre-wrap; word-break: break-word; }
.msg.user { justify-self: end; background: var(--user-bubble); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot { justify-self: start; background: var(--surface-1); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg .tools { display: block; margin-top: 6px; font-size: 11px; color: var(--text-muted); }
.suggest { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0; }
.suggest button { flex: none; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-1); color: var(--text-secondary); font-size: 13px; }
.chat-form { position: sticky; bottom: calc(env(safe-area-inset-bottom) + 72px); display: flex; gap: 8px; background: var(--surface-0); padding: 6px 0; }
.chat-form textarea { flex: 1; resize: none; padding: 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-1); color: inherit; font: inherit; max-height: 140px; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px); background: var(--surface-1); border-top: 1px solid var(--line); z-index: 3; }
.tabs button { border: 0; background: none; color: var(--text-muted); padding: 10px 0; font-size: 14px; }
.tabs button.on { color: var(--text-primary); font-weight: 700; }

.sheet { position: fixed; inset: 0; background: rgb(0 0 0 / .35); z-index: 5; display: grid; align-items: end; }
.sheet-body { background: var(--surface-0); max-height: 88vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 16px 14px calc(env(safe-area-inset-bottom) + 20px); }
.sheet .close { float: right; border: 0; background: none; color: var(--text-secondary); }
.sheet h2 { margin-top: 4px; }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.kv div { background: var(--surface-1); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.kv b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.kv span { font-size: 11px; color: var(--text-secondary); }
