:root {
  --bg: #05060f;
  --panel: rgba(14, 18, 38, 0.62);
  --panel-solid: #0e1226;
  --ink: #eef2ff;
  --ink-dim: #9aa3c7;
  --accent: #7be0ff;
  --accent-2: #ff7ab8;
  --accent-3: #b58bff;
  --line: rgba(255, 255, 255, 0.12);
  --radius: 16px;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  /* chip-well / subtle hover fill: dark under dark base so light text-on-panel stays
     legible. Overridden to a paper-tint under the light theme (see below). */
  --chip-bg: rgba(0, 0, 0, 0.25);
  --chip-bg-hover: rgba(255, 255, 255, 0.06);
  /* foreground that sits on the accent fill (campath .is-on uses color: var(--bg), which
     already flips correctly, but expose --on-accent for any accent-filled text/icon). */
  --on-accent: #04141a;
}
/* ===== 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: #f5f5f7;
  --panel-solid: #f5f5f7;
  --ink: #0036e5;
  --ink-dim: #5c6aa4;
  --accent: #007598;
  --accent-2: #d40063;
  --accent-3: #813aff;
  --line: rgba(0,0,0,0.10);
  --chip-bg: #6c6c6c;
  --chip-bg-hover: #6c6c6c;
  --on-accent: #ffffff;
}












* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; 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; }
body { overflow-x: hidden; }

.hidden { display: none !important; }

/* fixed full-screen canvas behind the text — stays put while document scrolls */
#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: pan-y; z-index: 0; }

/* loading overlay (before scene boots) */
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 30; }
.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); } }

/* top bar: brand + language switcher */
.topbar { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  pointer-events: none; }
.topbar > * { pointer-events: auto; }
.brand { font-family: "Space Grotesk", "Noto Sans KR", sans-serif; font-weight: 700; font-size: 15px; letter-spacing: 0.5px;
  color: var(--ink); display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; backdrop-filter: blur(10px); }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: linear-gradient(120deg, var(--accent), var(--accent-2)); box-shadow: 0 0 10px var(--accent); }
.topbar [data-i18n-switcher] select,
.topbar select { background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 12px; font-size: 12px; backdrop-filter: blur(10px); }

/* progress rail (top, under topbar) */
.progress-rail { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 25; background: var(--chip-bg); }
.progress-bar { height: 100%; width: 100%; transform-origin: left center; transform: scaleX(0);
  background: linear-gradient(90deg, var(--accent), var(--accent-3), var(--accent-2)); }

/* the tall scroll container with text sections */
.story { position: relative; z-index: 10; }
section.panel { min-height: 100vh; display: flex; align-items: center; padding: 0 max(20px, env(safe-area-inset-left)); }
section.panel.right { justify-content: flex-end; }
section.panel.center { justify-content: center; }

.story-card { max-width: 460px; width: 100%; padding: 26px 28px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(14px); box-shadow: var(--shadow);
  opacity: 0; transform: translateY(24px); transition: opacity .7s ease, transform .7s ease; }
.story-card.in { opacity: 1; transform: translateY(0); }

.story-card .eyebrow { font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--accent); margin: 0 0 8px; font-weight: 700; }
.story-card h2 { font-family: "Space Grotesk", "Noto Sans KR", sans-serif; font-weight: 700;
  font-size: clamp(26px, 4.4vw, 38px); line-height: 1.12; margin: 0 0 14px; color: var(--ink); }
.story-card h2 .grad { background: linear-gradient(120deg, var(--accent), var(--accent-3)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.story-card p { margin: 0; font-size: 15.5px; line-height: 1.65; color: var(--ink-dim); }

/* intro hero card (section 1, larger) */
.hero { text-align: center; max-width: 560px; }
.hero .eyebrow { letter-spacing: 3px; }
.hero h1 { font-family: "Space Grotesk", "Noto Sans KR", sans-serif; font-weight: 800;
  font-size: clamp(38px, 8vw, 72px); line-height: 1.05; margin: 0 0 16px; color: var(--ink); letter-spacing: -0.5px; }
.hero h1 .grad { background: linear-gradient(120deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { font-size: 16px; color: var(--ink-dim); }

/* scroll hint (mouse) */
.scroll-hint { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 15; display: inline-flex; flex-direction: column; align-items: center; gap: 6px;
  color: var(--ink-dim); font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase;
  transition: opacity .4s ease; pointer-events: none; }
.scroll-hint .mouse { width: 22px; height: 34px; border: 2px solid var(--ink-dim); border-radius: 12px; position: relative; }
.scroll-hint .mouse::after { content: ""; position: absolute; left: 50%; top: 6px; width: 3px; height: 7px; border-radius: 2px;
  background: var(--ink-dim); transform: translateX(-50%); animation: wheel 1.4s ease-in-out infinite; }
@keyframes wheel { 0% { opacity: 0; transform: translate(-50%, 0); } 40% { opacity: 1; } 80% { opacity: 0; transform: translate(-50%, 10px); } 100% { opacity: 0; } }
.scroll-hint.gone { opacity: 0; }

/* top button (section 4 hero) */
.top-btn { font: inherit; font-weight: 700; font-size: 14px; border: 1px solid var(--line); border-radius: 999px;
  padding: 12px 24px; margin-top: 22px; cursor: pointer; color: var(--ink);
  background: var(--panel); backdrop-filter: blur(10px); transition: transform .15s, background .15s, border-color .15s; }
.top-btn:hover { transform: translateY(-2px); background: color-mix(in oklab, var(--accent) 16%, transparent); border-color: var(--accent); }

/* section dot nav (right edge) */
.dotnav { position: fixed; right: max(14px, env(safe-area-inset-right)); top: 50%; transform: translateY(-50%); z-index: 18;
  display: flex; flex-direction: column; gap: 12px; }
.dotnav button { width: 9px; height: 9px; border-radius: 50%; border: none; padding: 0; cursor: pointer;
  background: var(--chip-bg); transition: background .2s, transform .2s; }
.dotnav button.is-on { background: var(--accent); transform: scale(1.4); box-shadow: 0 0 10px var(--accent); }
.dotnav button:hover { background: var(--ink-dim); }

/* V2 — camera-path template switcher (segmented control, top-left under topbar) */
.campath { position: fixed; top: calc(max(12px, env(safe-area-inset-top)) + 48px); left: max(16px, env(safe-area-inset-left));
  z-index: 19; display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 5px 7px 5px 12px;
  backdrop-filter: blur(10px); }
.campath-label { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--ink-dim); font-weight: 700; }
.campath-seg { display: inline-flex; gap: 2px; }
.campath-btn { font: inherit; font-size: 12px; font-weight: 600; border: 1px solid transparent; border-radius: 999px;
  padding: 6px 12px; cursor: pointer; color: var(--ink-dim); background: transparent;
  transition: background .18s, color .18s, border-color .18s; }
.campath-btn:hover { color: var(--ink); background: var(--chip-bg-hover); }
.campath-btn.is-on { color: var(--bg); background: var(--accent); border-color: var(--accent); }
.campath-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* V3 — EMBED/SHARE button + panel (matches campath panel aesthetic).
   Campath control sits on row 1 (top+48px); share button sits on row 2 just below it
   so the two never overlap regardless of campath width. */
.share-btn { position: fixed; top: calc(max(12px, env(safe-area-inset-top)) + 84px); left: max(16px, env(safe-area-inset-left));
  z-index: 19; display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 12px; font-weight: 600;
  color: var(--ink-dim); background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; cursor: pointer; backdrop-filter: blur(10px);
  transition: color .18s, background .18s, border-color .18s, transform .15s; }
.share-btn:hover { color: var(--ink); background: color-mix(in oklab, var(--accent) 16%, transparent); border-color: var(--accent); transform: translateY(-1px); }
.share-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.share-btn .share-icon { font-size: 13px; line-height: 1; }

.share-panel { position: fixed; top: calc(max(12px, env(safe-area-inset-top)) + 122px); left: max(16px, env(safe-area-inset-left));
  z-index: 21; width: min(340px, calc(100vw - 32px)); padding: 16px 16px 14px;
  background: var(--panel-solid); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); backdrop-filter: blur(14px);
  display: flex; flex-direction: column; gap: 8px;
  opacity: 1; transform: translateY(0); transition: opacity .18s ease, transform .18s ease; }
.share-panel.hidden { display: none; }
.share-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; }
.share-head strong { font-family: "Space Grotesk", "Noto Sans KR", sans-serif; font-size: 14px; color: var(--ink); }
.share-close { font: inherit; font-size: 20px; line-height: 1; color: var(--ink-dim); background: transparent;
  border: none; cursor: pointer; padding: 2px 6px; border-radius: 8px; transition: color .15s, background .15s; }
.share-close:hover { color: var(--ink); background: var(--chip-bg-hover); }
.share-label { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-dim); font-weight: 700; margin-top: 4px; }
.share-row { display: flex; gap: 6px; align-items: stretch; }
.share-input { flex: 1; min-width: 0; font: inherit; font-size: 12px; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; }
.share-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.share-embed { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; line-height: 1.5;
  color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
  resize: vertical; min-height: 56px; }
.share-embed:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.share-copy { font: inherit; font-size: 12px; font-weight: 600; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .15s; align-self: flex-start; }
.share-copy:hover { background: color-mix(in oklab, var(--accent) 16%, transparent); border-color: var(--accent); transform: translateY(-1px); }
.share-copy:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.share-note { margin: 4px 0 0; font-size: 11px; line-height: 1.5; color: var(--ink-dim); }

@media (max-width: 540px) {
  /* On phones, nudge share button + panel down a touch (campath wraps taller). */
  .share-btn { top: calc(max(12px, env(safe-area-inset-top)) + 92px); }
  .share-panel { top: calc(max(12px, env(safe-area-inset-top)) + 130px); }
}
@media (prefers-reduced-motion: reduce) {
  .share-btn, .share-copy, .share-close, .share-panel { transition: none; }
}

@media (max-width: 540px) {
  .brand { font-size: 13px; padding: 6px 12px; }
  .scroll-hint { display: none; }
  .dotnav { right: 8px; gap: 10px; }
  .story-card { padding: 22px 20px; }
  /* Cross-cutting FAB/mobile collision: the GitHub Sponsors .pmp-fab is fixed
     bottom-right (~34px tall, z-index ~2147483000), always present. The dotnav sits at
     vertical-center and normally clears the FAB, but on short viewports its lower dots
     can drop into the FAB band — clamp its height so it never overlaps the bottom 64px. */
  .dotnav { bottom: auto; top: 50%; transform: translateY(-50%); max-height: calc(50vh - 64px); overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .spinner, .scroll-hint .mouse::after { animation: none; }
  .story-card { transition: none; }
}
