:root {
  --bg: #0b0806;
  --panel: rgba(20, 15, 12, 0.74);
  --line: rgba(255, 214, 170, 0.12);
  --text: #f3e7da;
  --muted: #b9a593;
  --accent: #f0a45a;
  --accent-2: #ffcf8a;
  --chip: rgba(255, 235, 210, 0.06);
  --chip-on: rgba(240, 164, 90, 0.22);
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#stage {
  position: fixed;
  inset: 0;
  isolation: isolate;
  background: #000;
}
#stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
#c-shade { mix-blend-mode: multiply; }
#c-glow { mix-blend-mode: screen; }
#stage #c-fire { inset: auto; }
#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 75% 70% at 50% 62%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

/* ---------- splash ---------- */
#splash {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 50% 70%, rgba(40, 18, 6, 0.55), rgba(5, 3, 2, 0.92) 70%);
  z-index: 20;
  transition: opacity 1.6s ease, visibility 1.6s;
  padding: 24px;
}
#splash.gone { opacity: 0; visibility: hidden; }
.splash-inner { text-align: center; max-width: 520px; }
.splash-inner .hf-logo { display: block; width: min(400px, 82vw); height: auto; margin: 0 auto 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#panel h2.brand { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 500; line-height: 1; display: flex; align-items: baseline; gap: 8px; }
#panel h2.brand span { font-family: 'Pinyon Script', 'Cormorant Garamond', serif; font-weight: 400; font-size: 1.35em; color: #dcb878; }
#panel h2.brand em { font-style: normal; font-size: 0.62em; letter-spacing: 0.32em; color: #efe2cc; }
.splash-inner h1 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 500;
  font-size: clamp(54px, 9vw, 96px);
  margin: 10px 0 6px;
  letter-spacing: 0.01em;
  background: linear-gradient(180deg, #fff1dc, #f0a45a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.splash-inner p { color: var(--muted); font-size: 16px; line-height: 1.6; margin: 0 0 32px; }
.splash-inner small { display: block; margin-top: 28px; color: rgba(185, 165, 147, 0.7); font-size: 12.5px; }
.splash-inner small.version { margin-top: 10px; opacity: 0.6; letter-spacing: 0.08em; }
kbd {
  font-family: inherit;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
}
.ember-dot {
  width: 14px;
  height: 14px;
  margin: 0 auto;
  border-radius: 50%;
  background: #ffb763;
  box-shadow: 0 0 20px 6px rgba(255, 140, 40, 0.65), 0 0 60px 20px rgba(255, 90, 20, 0.3);
  animation: ember 2.4s ease-in-out infinite;
}
@keyframes ember { 50% { transform: scale(0.8); opacity: 0.7; } }
#light-btn {
  font: 600 15px 'Inter', sans-serif;
  letter-spacing: 0.04em;
  color: #2a1406;
  background: linear-gradient(180deg, #ffd29a, #f09a4c);
  border: 0;
  padding: 15px 34px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 10px 40px rgba(240, 130, 40, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
#light-btn:hover { transform: translateY(-1px); box-shadow: 0 14px 50px rgba(240, 130, 40, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.5); }
#light-btn:focus-visible, .dock-btn:focus-visible, .chip:focus-visible, .preset:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* ---------- dock ---------- */
#dock {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  z-index: 10;
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.dock-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(20, 14, 10, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}
.dock-btn:hover { background: rgba(60, 36, 20, 0.75); transform: translateY(-1px); }
.dock-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.dock-btn .ico-off { display: none; }
body.muted .dock-btn .ico-on { display: none; }
body.muted .dock-btn .ico-off { display: block; }
body.idle { cursor: none; }
body.idle #dock { opacity: 0; transform: translateY(8px); pointer-events: none; }
body.hidden-ui #dock { opacity: 0; pointer-events: none; }

/* ---------- pages menu (v0.34) ---------- */
#pages-menu {
  position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: calc(max(18px, env(safe-area-inset-bottom)) + 58px);
  z-index: 11; display: flex; flex-direction: column; min-width: 240px; padding: 10px;
  border-radius: 14px; border: 1px solid var(--line); background: rgba(20, 14, 10, 0.82);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity 0.25s ease, transform 0.25s ease;
}
#pages-menu.open { opacity: 1; transform: none; pointer-events: auto; }
#pages-menu .pm-title { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); padding: 4px 10px 8px; }
#pages-menu a { color: var(--text); text-decoration: none; font-size: 14px; padding: 8px 10px; border-radius: 8px; }
#pages-menu a:hover, #pages-menu a:focus-visible { background: rgba(240, 164, 90, 0.14); color: var(--accent-2); outline: none; }
body.idle #pages-menu:not(.open), body.hidden-ui #pages-menu { opacity: 0; pointer-events: none; }

/* ---------- panel ---------- */
#panel {
  position: fixed;
  top: 14px;
  right: 14px;
  bottom: 14px;
  width: min(380px, calc(100vw - 28px));
  background: var(--panel);
  backdrop-filter: blur(22px) saturate(1.2);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  z-index: 12;
  display: flex;
  flex-direction: column;
  transform: translateX(calc(100% + 30px));
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}
#panel.open { transform: none; }
#panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--line);
}
#panel h2 { font: 600 26px 'Cormorant Garamond', Georgia, serif; margin: 0; color: var(--accent-2); }
#panel .sub { font-size: 12px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
#panel .close {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
  background: transparent; color: var(--text); font-size: 22px; line-height: 1; cursor: pointer;
}
.panel-body { overflow-y: auto; padding: 8px 20px 26px; scrollbar-width: thin; scrollbar-color: rgba(255, 220, 180, 0.2) transparent; }
.section { padding: 16px 0 6px; }
.section h3 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
}
.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.preset {
  text-align: left;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(255, 190, 120, 0.08), rgba(255, 255, 255, 0.02));
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.preset:hover { border-color: rgba(240, 164, 90, 0.5); }
.preset b { display: block; font-size: 13px; font-weight: 600; }
.preset span { font-size: 11.5px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--text);
  font: 500 12.5px 'Inter', sans-serif;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.chip:hover { border-color: rgba(240, 164, 90, 0.45); }
.chip.on { background: var(--chip-on); border-color: rgba(240, 164, 90, 0.7); color: #fff3e4; }
.row { display: flex; align-items: center; gap: 12px; margin: 10px 0; }
.row label { flex: 0 0 82px; font-size: 13px; color: var(--text); }
.row output { flex: 0 0 34px; text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
input[type='range'] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent) var(--p, 50%), rgba(255, 255, 255, 0.12) var(--p, 50%));
  outline: none;
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: #ffe2bd; border: 0; box-shadow: 0 0 0 4px rgba(240, 164, 90, 0.25); cursor: pointer;
}
input[type='range']::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: #ffe2bd; border: 0; cursor: pointer;
}
.toggle-row { display: flex; align-items: center; justify-content: space-between; margin: 10px 0; font-size: 13px; }
.switch { position: relative; width: 40px; height: 22px; border-radius: 22px; background: rgba(255, 255, 255, 0.14); border: 0; cursor: pointer; transition: background 0.2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(18px); }
.hint { font-size: 11.5px; color: rgba(185, 165, 147, 0.75); line-height: 1.6; margin-top: 18px; }

@media (max-width: 520px) {
  #panel { top: auto; height: 72vh; left: 10px; right: 10px; bottom: 10px; width: auto; transform: translateY(calc(100% + 30px)); }
}
@media (prefers-reduced-motion: reduce) {
  #panel, #splash, #dock { transition: none; }
}

#light-btn:disabled { opacity: 0.6; cursor: progress; }
#stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

#explore-hint {
  position: fixed; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translate(-50%, 10px);
  padding: 9px 16px; border-radius: 999px; background: rgba(20, 14, 10, 0.6); border: 1px solid var(--line);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); color: var(--text); font-size: 12.5px;
  opacity: 0; pointer-events: none; transition: opacity 0.5s ease, transform 0.5s ease; z-index: 9; white-space: nowrap;
}
#explore-hint.show { opacity: 1; transform: translate(-50%, 0); }
body.idle #explore-hint { opacity: 0; }
#explore-hint { display: flex; align-items: center; gap: 10px; }
#explore-hint.dismissed { display: none; }
#explore-hint .hint-close {
  pointer-events: auto; flex: none; width: 24px; height: 24px; margin: -4px -8px -4px 0; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); color: var(--text); font-size: 15px; line-height: 1;
  cursor: pointer; display: grid; place-items: center; padding: 0;
}
#explore-hint .hint-close:hover { background: rgba(255, 255, 255, 0.14); }
body.idle #explore-hint .hint-close { pointer-events: none; }
/* the scene handles every touch gesture itself (no page zoom, double-tap zoom or scroll) */
#stage canvas { touch-action: none; }
body.exploring #stage canvas { cursor: grab; }
body.exploring #stage canvas:active { cursor: grabbing; }
@media (max-width: 640px) { #explore-hint { white-space: normal; width: calc(100vw - 32px); text-align: center; bottom: 80px; } }
