:root {
  --bg: #05060f;
  --panel: rgba(18, 22, 44, 0.72);
  --panel-solid: #12162c;
  --ink: #e8ecff;
  --ink-dim: #9aa3c7;
  --accent: #6d8bff;
  --accent-2: #ff6bd0;
  --line: rgba(255, 255, 255, 0.12);
  --chip-bg: rgba(0, 0, 0, 0.25);          /* icon-btn / chip well (dark base) */
  --chip-bg-hover: rgba(109, 139, 255, 0.18); /* hover tint of --accent (#6d8bff dark) */
  --on-accent: #ffffff;                     /* text/icon sitting on the saturated accent fill */
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
/* ===== 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: #f6f6f7;
  --panel-solid: #f6f6f7;
  --ink: #002bf5;
  --ink-dim: #5c6aa4;
  --accent: #2e59ff;
  --accent-2: #cd008c;
  --line: rgba(0,0,0,0.10);
  --chip-bg: #6c6c6c;
  --chip-bg-hover: #2e59ff;
  --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: 420px; }
.logo { font-family: "Orbitron", "Noto Sans KR", sans-serif; font-weight: 800; font-size: clamp(40px, 12vw, 76px);
  margin: 0 0 6px; letter-spacing: 2px;
  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); }

/* 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; }
.ctl-label { font-size: 11px; color: var(--ink-dim); padding: 0 2px; white-space: nowrap; }
.ctl-val { font-size: 12px; color: var(--ink); font-variant-numeric: tabular-nums; min-width: 26px; text-align: right; }

/* range slider */
.range { -webkit-appearance: none; appearance: none; width: 110px; height: 4px; border-radius: 999px;
  background: var(--chip-bg); outline: none; }
.range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: linear-gradient(120deg, var(--accent), var(--accent-2)); border: none; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.range::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; border: none;
  background: linear-gradient(120deg, var(--accent), var(--accent-2)); cursor: pointer; }

.seg-btn { font: inherit; font-size: 12px; font-weight: 600; color: var(--ink-dim); background: transparent; border: none;
  border-radius: 999px; padding: 6px 11px; cursor: pointer; transition: background .15s, color .15s; }
.seg-btn.is-on { background: var(--accent); color: var(--on-accent); }

/* V2: preset segmented control + hidden file input */
.preset-btn { font: inherit; font-size: 12px; font-weight: 600; color: var(--ink-dim); background: transparent; border: none;
  border-radius: 999px; padding: 6px 10px; cursor: pointer; transition: background .15s, color .15s; }
.preset-btn.is-on { background: var(--accent-2); color: var(--on-accent); }
.file-input { display: none; }
.icon-btn { font-size: 14px; 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: var(--chip-bg-hover); }

/* V3: BPM readout + secondary foot line */
.bpm-val { font-size: 13px; font-weight: 700; color: var(--accent-2); font-variant-numeric: tabular-nums;
  min-width: 30px; text-align: right; letter-spacing: 0.5px; }
.foot-sub { bottom: max(54px, calc(env(safe-area-inset-bottom) + 48px)); opacity: 0.55; font-size: 10.5px; }

/* V2: drag-drop zone overlay */
.dropzone { position: absolute; inset: 0; z-index: 12; display: flex; align-items: center; justify-content: center;
  background: color-mix(in oklab, var(--bg) 55%, transparent); backdrop-filter: blur(3px); pointer-events: none; }
.drop-card { text-align: center; padding: 30px 44px; border: 2px dashed var(--accent); border-radius: var(--radius);
  background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.drop-icon { font-size: 38px; line-height: 1; color: var(--accent); margin-bottom: 10px; }
.drop-title { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.drop-hint { margin: 0; font-size: 12px; color: var(--ink-dim); }

/* toast */
.toast { position: absolute; left: 50%; transform: translate(-50%, 10px); top: max(54px, calc(env(safe-area-inset-top) + 44px));
  z-index: 9; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px;
  font-size: 12.5px; color: var(--ink); backdrop-filter: blur(10px); box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; white-space: nowrap; max-width: calc(100vw - 28px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.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; }
  .ctl-label { display: none; }
  .range { width: 84px; }
  /* FAB/mobile collision: the .pmp-fab (position:fixed, bottom-right, ~34px tall,
     z-index ~2147483000) is always present. Reserve a right gutter (~56px) so the
     centered HUD stays usable and never overlaps the FAB on phones. The left:-50%
     translate is preserved; we shift the centering origin leftward by half the
     gutter and cap the width so the HUD can't extend under the FAB. */
  .controls { flex-wrap: wrap; max-width: calc(100vw - 56px - 12px); justify-content: center;
    left: calc(50% - 28px); }
}
@media (prefers-reduced-motion: reduce) { .spinner, .btn-primary, .toast { animation: none; transition: none; } }
