:root {
  --bg: #0a0d18;
  --panel: rgba(20, 24, 42, 0.74);
  --panel-solid: #12162c;
  --ink: #eef2ff;
  --ink-dim: #a3aacb;
  --accent: #6db0ff;
  --accent-2: #ff8fb0;
  --line: rgba(255, 255, 255, 0.12);
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  /* NEW theme-aware chips/accents-on-gradient tokens (Fix A) */
  --chip-bg: rgba(0, 0, 0, 0.25);          /* chip-well behind .icon-btn (dark base) */
  --chip-bg-hover: color-mix(in oklab, var(--accent) 18%, transparent);
  --on-accent: #ffffff;                     /* text/icon on accent gradient fills */
}
/* ===== 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: #0036e5;
  --ink-dim: #5e6aa4;
  --accent: #0066df;
  --accent-2: #d80040;
  --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); } }

/* black fade for node transitions */
#fade { position: absolute; inset: 0; z-index: 20; background: #000; opacity: 0; pointer-events: none; }

/* 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: 440px; }
.logo { font-family: "Sora", "Noto Sans KR", sans-serif; font-weight: 800; font-size: clamp(38px, 11vw, 68px);
  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, 176, 255, 0.4); }
.btn-primary:hover { transform: translateY(-2px); }
.btn-primary:active { transform: translateY(0); }

/* HUD: current node + controls */
.hud { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.node-tag { position: absolute; left: max(14px, env(safe-area-inset-left)); top: max(12px, env(safe-area-inset-top));
  display: inline-flex; align-items: center; gap: 8px; pointer-events: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px;
  backdrop-filter: blur(10px); box-shadow: var(--shadow); font-size: 13px; }
.node-tag .pin { font-size: 14px; }
.node-tag strong { font-weight: 700; }

.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; pointer-events: auto;
  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; }
.icon-btn { font: inherit; font-size: 13px; font-weight: 600; color: var(--ink); background: var(--chip-bg); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: background .15s, transform .15s; }
.icon-btn:hover { background: var(--chip-bg-hover); }
.icon-btn:active { transform: translateY(1px); }
.icon-btn.is-on { background: var(--accent); color: var(--on-accent); border-color: transparent; }

/* ===== V3: auto walk-tour button + status pill ===== */
/* Pulsing accent while the tour is actively driving the scene. */
.icon-btn.is-tour { background: linear-gradient(120deg, var(--accent), var(--accent-2)); color: var(--on-accent);
  border-color: transparent; animation: tour-pulse 1.6s ease-in-out infinite; }
@keyframes tour-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(109,176,255,0.0); } 50% { box-shadow: 0 0 0 6px rgba(109,176,255,0.28); } }
@media (prefers-reduced-motion: reduce) { .icon-btn.is-tour { animation: none; } }

/* one-line tour status hint (running / stopped). Empty → hidden via :empty. */
.tour-status { position: absolute; left: max(14px, env(safe-area-inset-left));
  top: calc(max(12px, env(safe-area-inset-top)) + 96px); z-index: 6;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; backdrop-filter: blur(10px); box-shadow: var(--shadow);
  font-size: 11.5px; font-weight: 600; color: var(--accent); pointer-events: none;
  max-width: min(220px, calc(100vw - 28px)); }
.tour-status:empty { display: none; }

/* hotspot overlay (projected divs) */
#hotspots { position: absolute; inset: 0; z-index: 7; pointer-events: none; }
.hotspot { position: absolute; transform: translate(-50%, -50%); width: 56px; height: 56px;
  border: none; background: transparent; cursor: pointer; pointer-events: auto;
  display: flex; align-items: center; justify-content: center; padding: 0; }
.hotspot-ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.12), 0 4px 14px rgba(0, 0, 0, 0.4); animation: hp-pulse 1.8s ease-in-out infinite; }
.hotspot-core { width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #fff7e0, #ffb24a 70%);
  box-shadow: 0 0 12px rgba(255, 200, 90, 0.9); }
.hotspot-label { position: absolute; top: 64px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 10px; font-size: 11.5px; font-weight: 600; backdrop-filter: blur(6px); }
@keyframes hp-pulse { 0%,100% { transform: scale(1); opacity: 0.9; } 50% { transform: scale(1.18); opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) { .hotspot-ring { animation: none; } }

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

@media (max-width: 540px) {
  .foot { display: none; }
  .icon-btn .lbl { display: none; }
  /* Cross-cutting Fix B: reserve a right gutter so the centered bottom .controls
     HUD does not collide with the fixed bottom-right .pmp-fab (~34px tall, ~44px
     wide incl. padding). Cap HUD width and shift it left of the FAB column. */
  .controls { max-width: calc(100vw - 56px - max(56px, env(safe-area-inset-right)));
    left: calc(50% - 22px); }
}
@media (prefers-reduced-motion: reduce) { .spinner, .btn-primary { animation: none; transition: none; } }

/* ===== V2: measurement readout (visited counter + next-step indicator) ===== */
.measure { position: absolute; left: max(14px, env(safe-area-inset-left)); top: calc(max(12px, env(safe-area-inset-top)) + 44px);
  display: flex; flex-direction: column; gap: 4px; z-index: 6;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 7px 12px;
  backdrop-filter: blur(10px); box-shadow: var(--shadow); font-size: 12px; color: var(--ink-dim); pointer-events: none;
  max-width: min(220px, calc(100vw - 28px)); }
.measure .visited { font-weight: 700; color: var(--ink); letter-spacing: 0.2px; }
.measure .distance { color: var(--accent); font-weight: 600; }
.measure .distance.muted { color: var(--ink-dim); opacity: 0.75; }

/* ===== V2: floorplan mini-map overlay ===== */
.minimap { position: absolute; right: max(12px, env(safe-area-inset-right));
  bottom: max(52px, calc(env(safe-area-inset-bottom) + 50px)); z-index: 8; pointer-events: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 8px;
  backdrop-filter: blur(10px); box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 4px; }
/* keep the minimap above the centered controls bar on small/mid screens */
@media (max-width: 720px) {
  .minimap { bottom: max(108px, calc(env(safe-area-inset-bottom) + 100px)); }
}
.minimap canvas { display: block; border-radius: 8px; cursor: pointer; touch-action: manipulation; }
.minimap canvas:hover { filter: brightness(1.06); }
.minimap-tip { font-size: 10.5px; color: var(--ink-dim); opacity: 0.8; text-align: center; max-width: 140px; }
@media (max-width: 720px) { .minimap-tip { display: none; } }
