:root {
  --bg: #171320;
  --panel: rgba(28, 22, 38, 0.92);
  --line: #3a2f4d;
  --txt: #efe7f5;
  --muted: #a796b8;
  --accent: #ff5d8f;
  --accent2: #7a5cff;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
body { font: 14px/1.4 system-ui, sans-serif; color: var(--txt); -webkit-user-select: none; user-select: none; }

#stage {
  position: fixed; inset: 0; width: 100vw; height: 100vh; display: block;
  touch-action: none;
}

/* ---- category panels (one per icon in the left nav) ---- */
.panel {
  position: fixed; top: 0; right: 0; width: 330px; max-width: 92vw; height: 100%;
  overflow-y: auto; padding: 12px 14px 60px;
  background: var(--panel); backdrop-filter: blur(8px);
  border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform .25s ease;
}
body[data-panel="scene"]  #panel-scene,
body[data-panel="boob"]   #panel-boob,
body[data-panel="decor"]  #panel-decor,
body[data-panel="jiggle"] #panel-jiggle,
body[data-panel="camera"] #panel-camera,
body[data-panel="share"]  #panel-share { transform: none; }

/* ---- left icon nav ---- */
#nav {
  position: fixed; top: 12px; left: 12px; z-index: 6;
  display: flex; flex-direction: column; gap: 8px;
}
.navbtn {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  background: #241b32ee; color: var(--txt); cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
}
.navbtn:hover { border-color: var(--accent); }
.navbtn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
#zoom {
  position: fixed; left: 12px; bottom: 16px; z-index: 6;
  display: flex; flex-direction: column; gap: 8px;
}
#zoom button {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: #241b32ee; color: var(--txt); font-size: 22px; line-height: 1; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
}
#zoom button:hover { border-color: var(--accent); }

/* bare mode: clean canvas only (for embeds / preview images) */
body.bare .panel, body.bare #nav, body.bare #zoom { display: none !important; }

button.act:disabled { opacity: .45; cursor: not-allowed; }

.section { border-bottom: 1px solid var(--line); padding: 6px 0; }
.shead { font-weight: 700; padding: 8px 2px; cursor: pointer; letter-spacing: .02em; }
.shead::before { content: "▾ "; color: var(--accent); }
.section.collapsed .sbody { display: none; }
.section.collapsed .shead::before { content: "▸ "; }
.sbody { padding: 2px 2px 8px; }

.field { display: flex; align-items: center; gap: 8px; margin: 7px 0; }
.field > label { flex: 0 0 96px; color: var(--muted); font-size: 12px; }
.field > .row, .field > input, .field > select, .field > .seg { flex: 1; }
.row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.val { flex: 0 0 38px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=color] { width: 38px; height: 26px; padding: 0; border: 1px solid var(--line); background: none; border-radius: 6px; }
select, button.act {
  background: #241b32; color: var(--txt); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; font: inherit; cursor: pointer;
}
button.act:hover { border-color: var(--accent); }
button.act.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segbtn {
  flex: 1; background: #241b32; color: var(--muted); border: none; border-right: 1px solid var(--line);
  padding: 7px 4px; font: inherit; cursor: pointer; text-transform: capitalize;
}
.segbtn:last-child { border-right: none; }
.segbtn.on { background: var(--accent); color: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  background: #241b32; color: var(--muted); border: 1px solid var(--line);
  border-radius: 14px; padding: 4px 10px; cursor: pointer; font-size: 12px;
}
.chip.on { background: var(--accent2); color: #fff; border-color: var(--accent2); }
.chip.cup { min-width: 34px; text-align: center; font-weight: 600; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%; padding: 0;
  border: 2px solid var(--line); cursor: pointer;
}
.swatch:hover { border-color: var(--accent); }

.num {
  width: 58px; text-align: center; background: #241b32; color: var(--txt);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 4px; font: inherit;
}
.step {
  width: 34px; height: 34px; background: #241b32; color: var(--txt);
  border: 1px solid var(--line); border-radius: 8px; font-size: 18px; line-height: 1; cursor: pointer;
}
.step:hover { border-color: var(--accent); }

label.inline { display: flex; align-items: center; gap: 6px; color: var(--muted); margin: 6px 2px; }
.hint { color: var(--muted); font-size: 11px; margin: 6px 2px 2px; }

.flash {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: #000a; color: #fff; padding: 8px 16px; border-radius: 20px;
  opacity: 0; transition: .2s; pointer-events: none; z-index: 20;
}
.flash.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- fallback ---- */
#fallback {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
  background: #0d0a13ee; padding: 20px; text-align: center;
}
#fallback[hidden] { display: none; }
#fallback > div { max-width: 360px; }

/* ---- mobile: panel becomes a bottom sheet ---- */
@media (max-width: 720px) {
  .panel {
    top: auto; bottom: 0; left: 0; right: 0; width: 100%; max-width: 100%;
    height: 72vh; border-left: none; border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0; transform: translateY(100%);
    transition: transform .25s ease;
  }
  body[data-panel="scene"]  #panel-scene,
  body[data-panel="boob"]   #panel-boob,
  body[data-panel="decor"]  #panel-decor,
  body[data-panel="jiggle"] #panel-jiggle,
  body[data-panel="camera"] #panel-camera,
  body[data-panel="share"]  #panel-share { transform: translateY(0); }
}
