* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: #000;
}

body {
  display: flex;
}

#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2;
  width: 260px;
  height: 100%;
  padding: 24px 22px;
  background: #111;
  color: #eee;
  border-right: 1px solid #222;
  display: flex;
  flex-direction: column;
  gap: 26px;
  margin-left: 0;
  transition: margin-left 0.28s ease;
}

body.collapsed #sidebar {
  margin-left: -304px; /* width + horizontal padding */
}

#toggle {
  position: absolute;
  top: 16px;
  left: 260px;
  z-index: 10;
  width: 34px;
  height: 34px;
  background: #fff;
  color: #000;
  border: none;
  border-radius: 0 4px 4px 0;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: left 0.28s ease, opacity 0.15s;
}

#toggle:hover {
  opacity: 0.85;
}

body.collapsed #toggle {
  left: 0;
}

#sidebar {
  overflow-y: auto;
}

#sidebar h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #fff;
}

#sidebar h2 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #fff;
}

.divider {
  border: none;
  border-top: 1px solid #2a2a2a;
  margin: 0;
}

.hint {
  font-size: 12px;
  line-height: 1.4;
  color: #888;
}

/* Whisper-voice download progress bar */
.progress {
  width: 100%;
  height: 6px;
  background: #2a2a2a;
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: #fff;
  transition: width 0.2s ease;
}

textarea#wordList {
  width: 100%;
  resize: vertical;
  padding: 8px;
  background: #1c1c1c;
  color: #eee;
  border: 1px solid #333;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.4;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* A locked control stays hidden regardless of any show/hide logic (easter egg). */
.control.locked {
  display: none !important;
}

.control label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #999;
}

.control label.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
  color: #ccc;
  cursor: pointer;
}

.control label.checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: #fff;
  cursor: pointer;
}

textarea#wordSequence,
textarea#wordStages {
  width: 100%;
  resize: vertical;
  padding: 8px;
  background: #1c1c1c;
  color: #eee;
  border: 1px solid #333;
  border-radius: 4px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.5;
}

.control output {
  font-size: 12px;
  color: #777;
  font-variant-numeric: tabular-nums;
}

.control .num {
  width: 80px;
  padding: 4px 6px;
  background: #1c1c1c;
  color: #eee;
  border: 1px solid #333;
  border-radius: 4px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.control .num:focus {
  outline: none;
  border-color: #666;
}

input[type="range"] {
  width: 100%;
  accent-color: #fff;
  cursor: pointer;
}

#sidebar select {
  width: 100%;
  padding: 7px 8px;
  background: #1c1c1c;
  color: #eee;
  border: 1px solid #333;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(28px, 1fr));
  gap: 6px;
}

.swatches input[type="color"] {
  width: 100%;
  height: 28px;
  padding: 0;
  border: 1px solid #333;
  border-radius: 4px;
  background: none;
  cursor: pointer;
}

.swatches input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.swatches input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

#share,
#random,
#invert,
#reset,
#audioPlay,
#audioSync,
#audioFilePlay,
#ambienceStrike,
#radioPlay,
#sessionToggle,
#presetSleep,
#presetHypno,
#presetEdging,
#presetSaveMine,
#presetLoadMine {
  padding: 10px;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 0.15s;
}

#share {
  margin-top: auto;
  background: #fff;
  color: #000;
}

#random,
#invert,
#reset,
#audioPlay,
#audioSync,
#audioFilePlay,
#ambienceStrike,
#radioPlay,
#sessionToggle,
#presetSleep,
#presetHypno,
#presetEdging,
#presetSaveMine,
#presetLoadMine {
  background: #2a2a2a;
  color: #eee;
  border: 1px solid #444;
}

#share:hover,
#random:hover,
#invert:hover,
#reset:hover,
#audioPlay:hover,
#audioSync:hover,
#audioFilePlay:hover,
#ambienceStrike:hover,
#radioPlay:hover,
#sessionToggle:hover,
#presetSleep:hover,
#presetHypno:hover,
#presetEdging:hover,
#presetSaveMine:hover,
#presetLoadMine:hover {
  opacity: 0.85;
}

/* Collapsible sidebar sections */
#sidebar details.section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-top: 1px solid #2a2a2a;
  padding-top: 18px;
}

#sidebar summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #fff;
  user-select: none;
}

#sidebar summary::-webkit-details-marker {
  display: none;
}

#sidebar summary::after {
  content: "▾";
  color: #888;
  font-size: 12px;
  transition: transform 0.2s ease;
}

#sidebar details:not([open]) summary::after {
  transform: rotate(-90deg);
}

/* Nested sub-sections (e.g. Words → Flashing / Spoken, Audio → Beats / …) */
#sidebar details.subsection {
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-top: 1px solid #242424;
  padding-top: 14px;
}

#sidebar details.subsection > summary {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: #c8c8c8;
}

#sidebar input[type="file"] {
  font-size: 12px;
  color: #bbb;
}

/* Fullscreen toggle, bottom-right over the canvas */
#fullscreen {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 3;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.15s, background 0.15s;
}

#fullscreen svg {
  width: 20px;
  height: 20px;
}

#fullscreen:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.22);
}

#gl {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

/* Only the Fractal mode reads clicks on the canvas (to place the zoom focus). */
body.fractal-mode #gl {
  cursor: crosshair;
}

#words {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

#words span {
  position: absolute;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.6s ease;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  white-space: nowrap;
  text-shadow:
    0 0 10px rgba(0, 0, 0, 1),
    0 0 20px rgba(0, 0, 0, 0.85),
    0 2px 4px rgba(0, 0, 0, 1);
  user-select: none;
}
