:root {
  --bg: #05060f;
  --panel: rgba(18, 22, 44, 0.72);
  --panel-solid: #12162c;
  --ink: #e8ecff;
  --ink-dim: #9aa3c7;
  --accent: #ff7ad9;          /* shader/creative accent (pink-violet) */
  --accent-2: #7ad9ff;        /* complementary cyan */
  --line: rgba(255, 255, 255, 0.12);
  /* chip-well / recessed-control background — tinted toward ink, never pure
     white (which vanishes on the light theme). Tokenized so both themes stay
     readable. */
  --chip-bg: rgba(0, 0, 0, 0.25);
  /* text/glyph sitting on a saturated accent fill (buttons on gradients). */
  --on-accent: #0b0b18;
  --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: #cc0092;
  --accent-2: #0073a1;
  --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: "Space Grotesk", "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: "Space Grotesk", "Noto Sans KR", sans-serif; font-weight: 700; 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 color-mix(in oklab, var(--accent) 35%, transparent); }
.btn-primary:hover { transform: translateY(-2px); }
.btn-primary:active { transform: translateY(0); }

/* side panel: presets + sliders */
.panel { position: absolute; left: max(14px, env(safe-area-inset-left)); top: 50%; transform: translateY(-50%);
  z-index: 9; width: min(280px, calc(100vw - 28px));
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  backdrop-filter: blur(12px); box-shadow: var(--shadow); }
.panel-section + .panel-section { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.panel-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--ink-dim); margin-bottom: 10px; }

.preset-list { display: flex; flex-direction: column; gap: 8px; }
.preset-btn { font: inherit; text-align: left; color: var(--ink); background: var(--chip-bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; cursor: pointer; transition: background .15s, border-color .15s; }
.preset-btn strong { display: block; font-size: 14px; font-weight: 700; }
.preset-btn small { display: block; font-size: 11.5px; color: var(--ink-dim); margin-top: 2px; }
.preset-btn.is-on { background: linear-gradient(120deg, color-mix(in oklab, var(--accent) 22%, transparent), color-mix(in oklab, var(--accent-2) 22%, transparent)); border-color: var(--accent); }
.preset-btn:hover { background: color-mix(in oklab, var(--accent) 12%, transparent); }

/* sliders */
.slider-row { display: flex; align-items: center; gap: 10px; }
.slider-row .s-val { font-size: 12px; color: var(--ink); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; border-radius: 999px;
  background: var(--chip-bg); outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--panel-solid); cursor: pointer; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 2px solid var(--panel-solid); cursor: pointer; }

/* small action buttons under sliders */
.row-btns { display: flex; gap: 8px; margin-top: 14px; }
.mini-btn { flex: 1; font: inherit; font-size: 12px; font-weight: 600; color: var(--ink); background: var(--chip-bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 0; cursor: pointer; }
.mini-btn:hover { background: color-mix(in oklab, var(--accent-2) 16%, transparent); }

/* top-center HUD: fps / elapsed / play-pause */
.hud { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  z-index: 8; display: flex; gap: 8px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; backdrop-filter: blur(10px); box-shadow: var(--shadow); }
.hud-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink); font-variant-numeric: tabular-nums; }
.hud-pill .lbl { color: var(--ink-dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.5px; }
.hud-pill small { color: var(--ink-dim); }
.icon-btn { font-size: 14px; line-height: 1; color: var(--ink); background: var(--chip-bg); border: 1px solid var(--line);
  border-radius: 999px; width: 30px; height: 30px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: color-mix(in oklab, var(--accent-2) 18%, transparent); }

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

/* ===== V2: LIVE GLSL EDITOR — right-side collapsible panel ===== */
.editor { position: absolute; right: max(14px, env(safe-area-inset-right)); top: 50%; transform: translateY(-50%);
  z-index: 10; width: min(440px, calc(100vw - 28px)); max-height: min(78vh, 640px);
  display: flex; flex-direction: column; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
  backdrop-filter: blur(12px); box-shadow: var(--shadow); }
.editor-head { display: flex; align-items: center; justify-content: space-between; }
.editor-head .panel-label { margin-bottom: 0; }
.editor-close { font: inherit; font-size: 15px; line-height: 1; color: var(--ink-dim); background: transparent;
  border: none; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.editor-close:hover { color: var(--ink); background: color-mix(in oklab, var(--accent-2) 16%, transparent); }
.editor-source { flex: 1 1 auto; min-height: 220px; resize: none;
  font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 11.5px; line-height: 1.5; tab-size: 2;
  color: var(--ink); background: var(--chip-bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; outline: none; white-space: pre; overflow: auto; }
.editor-source:focus { border-color: var(--accent); }
.editor-actions { display: flex; align-items: center; gap: 10px; }
.mini-btn-accent { background: linear-gradient(120deg, var(--accent), var(--accent-2)); color: var(--on-accent);
  border: none; font-weight: 700; }
.mini-btn-accent:hover { filter: brightness(1.08); }
.editor-status { flex: 1; font-size: 11.5px; color: var(--ink-dim); font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-status.is-ok { color: var(--accent-2); }
.editor-status.is-error { color: var(--accent); }
.editor-hint { margin: 0; font-size: 10.5px; color: var(--ink-dim); opacity: 0.8; line-height: 1.4; }

/* ===== V3: SHARE button + share status (reuses .mini-btn) ===== */
/* The share button sits next to Compile in .editor-actions. .mini-btn provides
   the base; this only tunes it so the accent Compile stays primary visual. */
#shareBtn { flex: 0 0 auto; }
/* When a share URL can't be copied automatically, the full URL is dropped into
   the status line — let it wrap & become selectable in that case. */
.editor-status.is-url { white-space: normal; word-break: break-all; overflow-wrap: anywhere;
  user-select: all; -webkit-user-select: all; max-height: 3em; overflow: auto; }

@media (max-width: 720px) {
  /* editor becomes a bottom sheet on small screens so it sits above the panel */
  .editor { right: 50%; top: auto; bottom: max(60px, env(safe-area-inset-bottom)); transform: translateX(50%);
    left: auto; width: min(440px, calc(100vw - 24px)); max-height: 46vh; }
  .editor-source { min-height: 120px; }
}

@media (max-width: 720px) {
  /* slide panel to bottom sheet on small screens so it doesn't cover the render */
  .panel { left: 50%; top: auto; bottom: max(60px, env(safe-area-inset-bottom)); transform: translateX(-50%);
    width: min(440px, calc(100vw - 24px)); }
  .preset-list { flex-direction: row; flex-wrap: wrap; }
  .preset-btn { flex: 1 1 calc(33.333% - 8px); }
  .foot { display: none; }
}

/* ===== CROSS-CUTTING FIX B: FAB/mobile collision ===== */
/* The GitHub-Sponsors .pmp-fab is position:fixed bottom-right (~34px tall,
   ~50px wide, z-index ~2147483000) and always present. On phones the bottom
   .editor/.panel sheets are centered and can stretch under it. Below 540px we
   de-center them, anchor left, and reserve a right gutter (~56px) so their
   right edge never reaches the FAB — keeping both the sheet controls and the
   FAB tappable. Vertically the sheets already sit at bottom:60px, above the
   FAB band. */
@media (max-width: 540px) {
  .panel, .editor {
    left: max(12px, env(safe-area-inset-left));
    right: auto;
    transform: none;
    width: calc(100vw - 56px - max(12px, env(safe-area-inset-left)));
    max-width: calc(100vw - 56px - max(12px, env(safe-area-inset-left)));
  }
}
@media (prefers-reduced-motion: reduce) { .spinner, .btn-primary { animation: none; transition: none; } }
