:root {
  --bg: #070a16;
  --panel: rgba(18, 22, 44, 0.72);
  --panel-solid: #0e1326;
  --ink: #e8ecff;
  --ink-dim: #9aa3c7;
  --accent: #6d8bff;
  --accent-2: #5fd0c0;
  --line: rgba(255, 255, 255, 0.12);
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --chip-bg: rgba(0, 0, 0, 0.25);
  --on-accent: #ffffff;
}
/* ===== 3-way theme (Light/Dark/System) — base :root above = native DARK. Opposite (light) WCAG-aware auto-generated (contrast-solving ink/accent vs worst-case surface). ===== */
:root[data-theme="light"]{
  --bg: #f4f4f6;
  --panel: #f5f6f7;
  --panel-solid: #f5f5f7;
  --ink: #002bf5;
  --ink-dim: #5c6aa5;
  --accent: #2e59ff;
  --accent-2: #23786c;
  --line: rgba(0,0,0,0.10);
  --chip-bg: #6c6c6c;
  --on-accent: #ffffff;
}












* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font-family: "Noto Sans KR", system-ui, -apple-system, "Apple SD Gothic Neo", sans-serif;
  -webkit-font-smoothing: antialiased; overflow: hidden; }

.app { position: fixed; inset: 0; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.hidden { display: none !important; }

/* overlays */
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 5; }
.loading { flex-direction: column; gap: 14px; color: var(--ink-dim); font-size: 14px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* topbar + language switcher */
.topbar { position: absolute; top: max(10px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); z-index: 8; }
.topbar [data-i18n-switcher] select,
.topbar select { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 10px; font-size: 12px; backdrop-filter: blur(8px); }

/* title card */
.title-card { text-align: center; padding: 36px 30px; max-width: 460px; }
.logo { font-family: "Sora", "Noto Sans KR", sans-serif; font-weight: 800; font-size: clamp(34px, 9vw, 64px);
  margin: 0 0 6px; letter-spacing: 1px;
  background: linear-gradient(120deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { color: var(--ink-dim); margin: 0 0 26px; font-size: 15px; }
.hint { color: var(--ink-dim); margin: 18px 0 0; font-size: 12.5px; opacity: 0.85; }

.btn { font: inherit; font-weight: 700; border: none; border-radius: 999px; padding: 13px 26px; cursor: pointer; transition: transform .15s, box-shadow .15s; }
.btn-primary { background: linear-gradient(120deg, var(--accent), var(--accent-2)); color: var(--on-accent); box-shadow: 0 8px 24px rgba(109, 139, 255, 0.4); }
.btn-primary:hover { transform: translateY(-2px); }
.btn-primary:active { transform: translateY(0); }

/* chart header + legend */
.chart-head { position: absolute; top: max(48px, calc(env(safe-area-inset-top) + 40px)); left: 50%; transform: translateX(-50%);
  z-index: 7; display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: calc(100vw - 200px); pointer-events: none; }
.ds-title { margin: 0; font-family: "Sora", "Noto Sans KR", sans-serif; font-weight: 700; font-size: clamp(16px, 4vw, 22px);
  color: var(--ink); text-align: center; text-shadow: 0 2px 12px rgba(0,0,0,0.5); }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 14px; }
.leg { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-dim); background: var(--panel);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; backdrop-filter: blur(8px); }
.leg-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* controls */
.controls { position: absolute; left: 50%; transform: translateX(-50%);
  bottom: max(16px, env(safe-area-inset-bottom)); z-index: 8; display: flex; gap: 10px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 7px 10px; backdrop-filter: blur(10px); box-shadow: var(--shadow); }
.ctl-group { display: flex; align-items: center; gap: 8px; }
.ctl-group + .ctl-group { border-left: 1px solid var(--line); padding-left: 10px; }
.seg-btn { font: inherit; font-size: 12.5px; font-weight: 700; color: var(--on-accent); background: linear-gradient(120deg, var(--accent), var(--accent-2));
  border: none; border-radius: 999px; padding: 8px 16px; cursor: pointer; transition: transform .15s, box-shadow .15s; box-shadow: 0 4px 14px rgba(109, 139, 255, 0.35); }
.seg-btn:hover { transform: translateY(-1px); }
.icon-btn { font-size: 16px; line-height: 1; color: var(--ink); background: var(--chip-bg); border: 1px solid var(--line);
  border-radius: 999px; width: 34px; height: 34px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: color-mix(in oklab, var(--accent) 18%, transparent); }

/* tooltip */
.tooltip { position: absolute; z-index: 12; min-width: 120px; padding: 9px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; backdrop-filter: blur(12px);
  box-shadow: var(--shadow); color: var(--ink); font-size: 13px; pointer-events: none; }
.tooltip.pinned { pointer-events: auto; border-color: rgba(109, 139, 255, 0.5); }
.tt-row { display: flex; align-items: center; gap: 7px; }
.tt-row strong { color: var(--ink); font-size: 14px; }
.tt-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.tt-cat { color: var(--ink-dim); font-size: 11.5px; margin: 3px 0 5px; }
.tt-val { font-family: "Sora", "Noto Sans KR", sans-serif; font-weight: 800; font-size: 20px; color: var(--ink); line-height: 1; }

.foot { position: absolute; left: 50%; transform: translateX(-50%); bottom: max(70px, calc(env(safe-area-inset-bottom) + 64px));
  z-index: 4; margin: 0; font-size: 11px; color: var(--ink-dim); opacity: 0.7; text-align: center; pointer-events: none; white-space: nowrap; }

@media (max-width: 540px) {
  .foot { display: none; }
  .chart-head { max-width: calc(100vw - 140px); top: max(44px, calc(env(safe-area-inset-top) + 36px)); }
}
@media (prefers-reduced-motion: reduce) { .spinner, .btn-primary, .seg-btn { animation: none; transition: none; } }

/* ===== V2: chart-type toggle + data panel ===== */
.ctl-label { font-size: 11.5px; font-weight: 700; color: var(--ink-dim); letter-spacing: .2px; }
.seg-btn.is-off { background: var(--chip-bg); color: var(--ink); box-shadow: none; opacity: .85; }
.seg-btn.is-off:hover { opacity: 1; }

/* data panel */
.data-panel { position: absolute; right: max(12px, env(safe-area-inset-right)); top: max(54px, calc(env(safe-area-inset-top) + 46px));
  z-index: 9; width: min(360px, calc(100vw - 24px)); background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 14px 14px 12px; backdrop-filter: blur(14px); box-shadow: var(--shadow); color: var(--ink); }
.dp-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.dp-head h3 { margin: 0; font-family: "Sora", "Noto Sans KR", sans-serif; font-weight: 700; font-size: 15px; }
.dp-close { font: inherit; font-size: 14px; line-height: 1; color: var(--ink-dim); background: transparent; border: none;
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer; }
.dp-close:hover { background: rgba(127,127,127,0.18); color: var(--ink); }
.dp-hint { margin: 0 0 8px; font-size: 11.5px; color: var(--ink-dim); line-height: 1.4; }
.dp-text { width: 100%; box-sizing: border-box; resize: vertical; font: 12px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  background: var(--panel-solid); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; }
.dp-text:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.dp-msg { margin: 8px 0 0; font-size: 12px; color: var(--accent-2); }
.dp-msg.is-err { color: #ff8a8a; }
.dp-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.dp-ghost { font: inherit; font-size: 12px; font-weight: 600; color: var(--ink-dim); background: rgba(127,127,127,0.14);
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 13px; cursor: pointer; }
.dp-ghost:hover { color: var(--ink); background: rgba(127,127,127,0.24); }
.dp-file { font: inherit; font-size: 12px; font-weight: 600; color: var(--ink-dim); background: rgba(127,127,127,0.14);
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 13px; cursor: pointer; display: inline-flex; align-items: center; }
.dp-file:hover { color: var(--ink); background: rgba(127,127,127,0.24); }
.dp-actions .seg-btn { margin-left: auto; padding: 9px 18px; }

@media (max-width: 540px) {
  .ctl-label { display: none; }
  .data-panel { top: auto; bottom: max(72px, calc(env(safe-area-inset-bottom) + 64px)); right: 12px; left: 12px; width: auto; }
  /* FAB collision fix: reserve a right gutter (~56px) so the centered bottom
     controls HUD never overlaps the fixed GitHub-Sponsors FAB. The HUD stays
     centered in the remaining band and remains fully usable. */
  .controls { max-width: calc(100vw - 56px); padding-right: max(56px, env(safe-area-inset-right)); }
}

/* ===== V3: share/record buttons + toast ===== */
.icon-btn[disabled] { opacity: .4; cursor: not-allowed; }
.icon-btn[disabled]:hover { background: var(--chip-bg); }
/* the share/record icon-btns carry a short label like the other controls */
.ctl-group .icon-btn[data-i18n] { width: auto; min-width: 34px; padding: 0 12px; font-size: 12.5px; font-weight: 700; gap: 4px; }
.icon-btn.is-rec { background: rgba(255, 90, 90, 0.28); border-color: rgba(255, 120, 120, 0.7); color: #ffd7d7; animation: rec-pulse 1.1s ease-in-out infinite; }
.icon-btn.is-rec:hover { background: rgba(255, 90, 90, 0.4); }
@keyframes rec-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,90,90,0.55); } 50% { box-shadow: 0 0 0 6px rgba(255,90,90,0); } }
@media (prefers-reduced-motion: reduce) { .icon-btn.is-rec { animation: none; } }

/* toast (share/record feedback) */
.toast { position: absolute; left: 50%; transform: translateX(-50%);
  bottom: max(74px, calc(env(safe-area-inset-bottom) + 66px)); z-index: 13;
  max-width: calc(100vw - 32px); padding: 10px 16px; background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px; backdrop-filter: blur(12px); box-shadow: var(--shadow);
  font-size: 13px; text-align: center; pointer-events: none; opacity: 1; transition: opacity .2s; }
.toast.is-err { border-color: rgba(255, 138, 138, 0.6); color: #ffb3b3; }
.toast.hidden { opacity: 0; }
@media (max-width: 540px) { .toast { bottom: max(132px, calc(env(safe-area-inset-bottom) + 124px)); } }


