    /* ===== Base layout ===== */
    body {
      margin: 0;
      overflow: hidden;
      display: flex;
      justify-content: center;
      align-items: center;
      background: #000;
      color: #fff;
    }

    /* ONLY the main canvas */
    #canvas {
      position: fixed;
      inset: 0;
      width: 100vw;
      height: 100vh;
      z-index: 0;
      display: block;
      pointer-events: none;
    }

    /* Hide/show class (so flex/restores properly) */
    #controls.is-hidden {
      display: none !important;
    }

    /* ===== Controls panel ===== */
    #controls {
      position: absolute;
      z-index: 10;
      top: 10px;
      left: 10px;
      font-family: Arial, sans-serif;
      font-size: 16px;
      color: #fff;
      background: rgba(0, 0, 0, .75);
      border-radius: 10px;
      box-shadow: 0 8px 20px rgba(0, 0, 0, .35);

      display: flex;
      flex-direction: column;
      max-height: calc(100vh - 20px);
      padding: 0;
      box-sizing: border-box;

      --label-w: 170px;
      /* keep labels stable (long names) */
      --val-w: 56px;
      /* default value col (non-FT rows) */
      --val-w-ft: 48px;
      /* tighter value col for slider rows */
      width: 520px;
      min-width: 520px;
      color-scheme: dark;
      /* make native form UI/popup dark and stop white flash */
    }

    /* ===== Header (sticky, same transparency) ===== */
    #controls .panel-header {
      position: sticky;
      top: 0;
      z-index: 2;
      background: transparent;
      padding: 1px 14px 10px;
      border-bottom: 0;
    }

    #controls .panel-header .header-row {
      display: flex;
      align-items: flex-end;
      gap: 12px;
      margin-bottom: 6px;
    }

    #controls .panel-header .brand {
      font-family: Arial, Helvetica, sans-serif;
      font-weight: 900;
      letter-spacing: .06em;
      font-size: 40px;
      line-height: 1;
      color: transparent;
      -webkit-text-stroke: 2px #ffffff;
      user-select: none;
    }

    #controls .panel-header .copyright {
      margin-left: auto;
      align-self: flex-end;
      font-size: 13px;
      line-height: 1;
      opacity: .9;
      white-space: nowrap;
    }

    #controls .panel-header .rgb-band {
      height: 4px;
      border-radius: 2px;
      background: linear-gradient(90deg, #ff0040 0%, #ffae00 20%, #ffee00 40%, #00ff8a 60%, #00b3ff 80%, #a86bff 100%);
      margin: 6px 0 8px;
      box-shadow: 0 0 6px rgba(255, 255, 255, .15) inset;
    }

    #controls .panel-header .helper-row {
      display: flex;
      align-items: center;
      gap: 10px;
      font-size: 16px;
      line-height: 1.1;
    }

    #controls .panel-header .kbd {
      display: inline-block;
      padding: 4px 10px;
      border: 1px solid rgba(255, 255, 255, .7);
      border-radius: 6px;
      background: rgba(255, 255, 255, .12);
      font-weight: 700;
      user-select: none;
    }

    #controls .panel-header .helper-text {
      opacity: .9;
    }

    /* ===== Scrolling body only ===== */
    #controls .panel-body {
      padding: 0px 14px 12px;
      overflow-y: auto;
      overscroll-behavior: contain;
      min-height: 0;
    }

    /* Scrollbar */
    #controls .panel-body::-webkit-scrollbar {
      width: 10px
    }

    #controls .panel-body::-webkit-scrollbar-track {
      background: transparent
    }

    #controls .panel-body::-webkit-scrollbar-thumb {
      background: rgba(255, 255, 255, .25);
      border-radius: 6px;
      border: 2px solid transparent;
      background-clip: content-box;
    }

    #controls .panel-body {
      scrollbar-width: thin;
      scrollbar-color: rgba(255, 255, 255, .35) transparent;
    }

    /* ===== Fieldsets / groups ===== */
    #controls fieldset.group {
      position: relative;

      --g-pad-top: 8px;
      --g-pad-right: 8px;
      --g-bw: 1px;
      --toggle-d: 26px;
      --occl-extra: 2px;

      --toggle-nudge-x: 2px;
      --toggle-nudge-y: 4px;
      --rng-nudge-y: 0px;

      border: var(--g-bw) solid rgba(255, 255, 255, .35);
      border-radius: 6px;
      padding: var(--g-pad-top) var(--g-pad-right) 10px;
      margin: 10px 0 12px;
      overflow: visible;
    }

    #controls fieldset.group legend {
      display: inline-block;
      margin-left: calc(var(--toggle-d)/2 + 8px);
      padding: 0 6px;
      color: #fff;
      font-weight: 600;
      letter-spacing: .2px;
    }

    #controls fieldset.group::before {
      content: "";
      position: absolute;
      width: calc(var(--toggle-d) + 2*var(--g-bw) + var(--occl-extra));
      height: calc(var(--toggle-d) + 2*var(--g-bw) + var(--occl-extra));
      top: 0;
      left: 0;
      transform:
        translate(calc(-50% - var(--g-bw) + var(--toggle-nudge-x)),
          calc(-50% - var(--g-bw) - var(--toggle-d)/2 + var(--toggle-nudge-y)));
      border-radius: 50%;
      background: rgba(0, 0, 0, .75);
      pointer-events: none;
    }

    .group-toggle {
      position: absolute;
      width: var(--toggle-d);
      height: var(--toggle-d);
      top: 0 !important;
      left: 0 !important;
      transform:
        translate(calc(-50% - var(--g-bw) + var(--toggle-nudge-x)),
          calc(-50% - var(--g-bw) - var(--toggle-d)/2 + var(--toggle-nudge-y))) !important;
      border-radius: 50%;
      border: 1px solid rgba(255, 255, 255, .55);
      background: rgba(255, 255, 255, .10);
      display: grid;
      place-items: center;
      color: #fff;
      font-size: 14px;
      line-height: 1;
      cursor: pointer;
      user-select: none;
    }

    #controls .group-toggle:hover {
      background: rgba(255, 255, 255, .18);
    }

    #controls fieldset.group .group-toggle::before {
      content: "−";
    }

    #controls fieldset.group.is-collapsed .group-toggle::before {
      content: "+";
    }

    #controls fieldset.group.is-collapsed>.row {
      display: none;
    }

    #controls fieldset.group .group-summary {
      display: none;
      margin: 6px 6px 8px;
      padding: 0 6px;
      font-size: 14px;
      line-height: 1.2;
      color: #fff;
      opacity: .9;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    #controls fieldset.group.is-collapsed .group-summary {
      display: block;
    }

    #controls fieldset.group.is-collapsed {
      --g-pad-top: 4px;
      --rng-nudge-y: -6px;
      padding: var(--g-pad-top) var(--g-pad-right) 6px;
    }

    #controls fieldset.group.is-collapsed legend {
      margin-bottom: 2px;
    }

    #controls fieldset.group.is-collapsed .group-summary {
      margin: 2px 6px 4px;
      font-size: 13px;
      line-height: 1.15;
    }

    /* ===== RNG lock badge (tighter) ===== */
    .rng-lock {
      position: absolute;
      top: calc(-1 * (var(--g-pad-top) + var(--g-bw)) + var(--rng-nudge-y));
      right: 0;
      z-index: 2;

      /* smaller box, same text size */
      padding: 0px 2px;
      /* was 4px 10px */
      font: 600 12px/1 system-ui, Arial, sans-serif;
      white-space: nowrap;

      color: #fff;
      background: rgba(255, 255, 255, .10);
      border: 1px solid rgba(255, 255, 255, .35);
      border-radius: 0 6px 0 6px;
      cursor: pointer;
      user-select: none;
    }

    .rng-lock:hover {
      background: rgba(255, 255, 255, .18);
    }

    .rng-lock .icon {
      margin-left: 6px;
    }

    .rng-lock[data-locked="true"] .icon::before {
      content: "🔒";
    }

    .rng-lock[data-locked="false"] .icon::before {
      content: "🔓";
    }


    /* ===== Rows / inputs ===== */
    #controls .row {
      display: grid;
      align-items: center;
      gap: 6px;
      margin: 6px 0;
      grid-template-columns: var(--label-w) 1fr var(--val-w);
    }

    #controls .row.ft {
      grid-template-columns: var(--label-w) min-content 1fr min-content var(--val-w-ft);
    }

    #controls .row .label {
      white-space: nowrap;
    }

    #controls .row .value {
      text-align: right;
      white-space: nowrap;
    }

    #controls .row.preset-row {
      grid-template-columns: var(--label-w) 1fr;
    }

    #controls .preset-inline {
      display: grid;
      grid-template-columns: 1fr 1fr;
      column-gap: 24px;
      align-items: center;
      width: 100%;
    }

    #controls .preset-inline select {
      justify-self: start;
    }

    #controls .preset-inline .rand {
      justify-self: center;
    }

    /* Range / step controls */
    #controls input[type="range"] {
      width: 100%;
      height: 28px;
      cursor: pointer;
      background: transparent;
      -webkit-appearance: none;
      appearance: none;
      outline: none;
    }

    #controls input[type="range"]::-webkit-slider-thumb {
      -webkit-appearance: none;
      appearance: none;
      width: 18px;
      height: 18px;
      border-radius: 50%;
      background: #fff;
      border: none;
      margin-top: -6px;
    }

    #controls input[type="range"]::-webkit-slider-runnable-track {
      height: 6px;
      border-radius: 4px;
      background: rgba(255, 255, 255, .25);
    }

    #controls input[type="range"]::-moz-range-thumb {
      width: 18px;
      height: 18px;
      border-radius: 50%;
      background: #fff;
      border: none;
    }

    #controls input[type="range"]::-moz-range-track {
      height: 6px;
      border-radius: 4px;
      background: rgba(255, 255, 255, .25);
    }

    .step {
      width: 22px;
      height: 22px;
      border: 1px solid rgba(255, 255, 255, .55);
      border-radius: 6px;
      background: rgba(255, 255, 255, .08);
      color: #fff;
      font-weight: 700;
      line-height: 1;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      user-select: none;
    }

    .step:hover {
      background: rgba(255, 255, 255, .14);
    }

    .step:active {
      transform: translateY(1px);
    }

    .step[disabled] {
      opacity: .35;
      cursor: default;
    }

    #controls input[type="checkbox"] {
      transform: scale(1.25);
      transform-origin: left center;
      cursor: pointer;
      accent-color: #fff;
    }

    /* Histograms */
    .histogram {
      width: 200px;
      height: 20px;
      background: grey;
      margin: 5px 0;
      position: relative;
    }

    .histogram div {
      height: 100%;
      position: absolute;
    }

    .rock-bar {
      background: rgba(255, 0, 0, 1);
    }

    .paper-bar {
      background: rgba(0, 255, 0, 1);
    }

    .scissors-bar {
      background: rgba(0, 191, 255, 1);
    }

    /* Reusable space badge */
    #spacebar {
      background: rgba(255, 255, 255, .2);
      border: 1px solid #fff;
      display: inline-block;
      padding: 2px 10px;
    }

    /* Preset row: compact, no stretch */
    #controls .preset-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
      margin: 10px 0 8px;
    }

    #controls .preset-left {
      display: flex;
      align-items: center;
      gap: 10px;
      white-space: nowrap;
    }

    /* Randomize button – make text same size as other controls, enlarge dice, no purple dot */
    #randomizeButton {
      font-size: 16px;
      /* match the control text size */
      padding: 6px 12px;
      /* compact width */
      border-radius: 2px;
    }

    /* kill the old glow badge if any */
    #randomizeButton.btn--glow::before {
      display: none !important;
    }

    /* the dice icon */
    #randomizeButton .dice {
      display: inline-block;
      font-size: 22px;
      /* << change this to taste */
      line-height: 1;
      margin-right: 8px;
      transform: translateY(1px);
    }

    /* keep the label at normal control size */
    #randomizeButton .label {
      font-size: inherit;
      font-weight: 700;
      letter-spacing: .15px;
    }

    /* ===== Color Picker Modal (custom) ===== */
    #colorPickerOverlay[hidden] {
      display: none !important;
    }

    #colorPickerOverlay {
      position: fixed;
      inset: 0;
      z-index: 1000;
      background: rgba(0, 0, 0, .55);
      display: grid;
      place-items: center;
    }

    .color-modal {
      width: min(980px, calc(100vw - 40px));
      max-height: calc(100vh - 40px);
      overflow: hidden;
      box-sizing: border-box;
      border-radius: 10px;
      background: rgba(0, 0, 0, .92);
      border: 1px solid rgba(255, 255, 255, .35);
      box-shadow: 0 20px 50px rgba(0, 0, 0, .6);
      color: #fff;
      font-family: Arial, sans-serif;
    }

    .color-modal .modal-header {
      padding: 14px 24px 8px;
      border-bottom: 1px solid rgba(255, 255, 255, .15);
    }

    .color-modal .modal-body {
      padding: 14px 24px 12px;
      display: grid;
      row-gap: 12px;
      overflow: auto;
    }

    .color-modal .modal-footer {
      padding: 12px 24px 14px;
      display: flex;
      justify-content: flex-end;
      gap: 10px;
      border-top: 1px solid rgba(255, 255, 255, .15);
    }

    .color-modal .kicker {
      font-size: 12px;
      letter-spacing: .12em;
      text-transform: uppercase;
      opacity: .8;
      margin-bottom: 4px;
    }

    .color-modal h2 {
      margin: 0;
      font-size: 22px;
      line-height: 1.2;
    }

    .picker-grid {
      display: grid;
      grid-template-columns: 360px 1fr;
      column-gap: 24px;
      align-items: start;
    }

    .picker-left {
      display: flex;
      flex-direction: column;
      gap: 10px;
      align-items: flex-start;
    }

    /* These are the picker canvases — unaffected by #canvas rule */
    #svCanvas {
      width: 320px;
      height: 320px;
      border-radius: 8px;
      border: 1px solid rgba(255, 255, 255, .35);
      cursor: crosshair;
    }

    #hueCanvas {
      width: 320px;
      height: 20px;
      border-radius: 6px;
      border: 1px solid rgba(255, 255, 255, .35);
      cursor: ew-resize;
    }

    .picker-hint {
      font-size: 12px;
      opacity: .75;
    }

    .picker-right {
      display: flex;
      flex-direction: column;
      gap: 10px;
    }

    .preview-row {
      display: flex;
      gap: 10px;
      align-items: center;
    }

    .swatch.big {
      width: 64px;
      height: 40px;
      border-radius: 8px;
      border: 1px solid rgba(255, 255, 255, .55);
    }

    .swatch.small {
      width: 28px;
      height: 28px;
      border-radius: 6px;
      border: 1px solid rgba(255, 255, 255, .35);
    }

    .group-label {
      margin-top: 6px;
      font-size: 12px;
      letter-spacing: .12em;
      text-transform: uppercase;
      opacity: .8;
    }

    .slider-row {
      display: grid;
      grid-template-columns: 34px 1fr 72px;
      gap: 10px;
      align-items: center;
    }

    .slider-row input[type="range"] {
      height: 22px;
    }

    .slider-row input[type="number"],
    #hexInput {
      height: 30px;
      padding: 4px 8px;
      border-radius: 6px;
      border: 1px solid rgba(255, 255, 255, .35);
      background: rgba(255, 255, 255, .06);
      color: #fff;
    }

    #hexInput {
      width: 180px;
    }

    .color-modal .btn {
      min-width: 84px;
      height: 32px;
      padding: 0 12px;
      border-radius: 8px;
      border: 1px solid rgba(255, 255, 255, .55);
      background: rgba(255, 255, 255, .08);
      color: #fff;
      font-weight: 700;
      cursor: pointer;
    }

    .color-modal .btn:hover {
      background: rgba(255, 255, 255, .14);
    }

    .color-modal .btn:active {
      transform: translateY(1px);
    }

    .color-modal .btn.primary {
      border-color: rgba(0, 180, 255, .85);
      background: rgba(0, 180, 255, .18);
    }

    .color-modal .btn[disabled] {
      opacity: .45;
      cursor: default;
      transform: none;
    }

    /* Photonic Frequency chips in collapsed summary */
    #controls fieldset.group .group-summary .chip {
      display: inline-block;
      width: 10px;
      height: 10px;
      border-radius: 3px;
      border: 1px solid rgba(255, 255, 255, .55);
      box-shadow: 0 0 0 1px rgba(0, 0, 0, .25) inset;
      margin: 0 10px 0 6px;
      vertical-align: -1px;
      background-color: var(--c, #fff);
    }

    #controls fieldset.group .group-summary .abbr {
      opacity: .9;
      font-weight: 600;
      letter-spacing: .2px;
    }

    #controls fieldset.group .group-summary .doppler {
      margin-left: 6px;
      opacity: .85;
    }

    /* === Realignment Dynamics: 3-up histograms === */
    #controls .row.hist-row {
      grid-template-columns: 1fr;
    }

    .hist-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      column-gap: 10px;
      align-items: center;
    }

    .hist-grid .hcell {
      display: grid;
      grid-template-columns: 16px 1fr;
      column-gap: 8px;
      align-items: center;
    }

    .hist-grid .hlabel {
      font-weight: 700;
      opacity: .9;
      user-select: none;
    }

    .histogram.mini {
      width: 100%;
      height: 12px;
      background: rgba(255, 255, 255, .10);
      border: 1px solid rgba(255, 255, 255, .25);
      border-radius: 6px;
      position: relative;
      overflow: hidden;
    }

    .histogram.mini .bar {
      position: absolute;
      top: 0;
      left: 0;
      right: auto;
      bottom: 0;
      width: 0%;
      height: 100%;
      background: #fff;
      transition: width .12s linear;
    }

    /* ===== Neon UI primitives ===== */
    :root {
      --ui-text: #EDE4FF;
      --ui-surface-1: rgba(12, 12, 20, .95);
      --ui-surface-2: rgba(6, 6, 12, .92);
      --ui-border: rgba(255, 255, 255, .16);
      --ui-border-hover: #b892ff;
      --ui-accent: #8a63ff;
      --ui-glow: rgba(138, 99, 255, .45);
    }

    /* cluster row (use anywhere) */
    .toolbar {
      display: flex;
      align-items: center;
      gap: 12px;
    }

    .toolbar--spread {
      justify-content: space-between;
    }

    /* ===================================================================
   NeonSelect (custom dropdown) — no native white popup
   Works with the NeonSelect JS enhancer. If you haven't wired it yet,
   the fallback native styling below still applies.
   =================================================================== */

    /* hide the real <select> but keep it in the DOM for a11y/events */
    .neonselect--hidden {
      position: absolute !important;
      opacity: 0 !important;
      pointer-events: none !important;
      width: 0 !important;
      height: 0 !important;
      margin: 0 !important;
      padding: 0 !important;
      border: 0 !important;
    }

    /* wrapper */
    .neonselect {
      position: relative;
      display: inline-block;
      min-width: 160px;
    }

    /* the visible control */
    .neonselect__btn {
      -webkit-appearance: none;
      appearance: none;
      position: relative;
      display: inline-flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      width: 100%;

      color: var(--ui-text);
      background: linear-gradient(180deg, var(--ui-surface-1), var(--ui-surface-2)) padding-box;
      border: 1px solid var(--ui-border);
      border-radius: 10px;
      box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, .06),
        0 0 16px var(--ui-glow);

      padding: 6px 38px 6px 10px;
      font: inherit;
      letter-spacing: .2px;
      cursor: pointer;
      transition: border-color .2s, box-shadow .2s, filter .2s;
    }

    .neonselect__btn::after {
      content: "";
      position: absolute;
      right: 12px;
      width: 12px;
      height: 12px;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23B892FF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-size: 12px 12px;
      pointer-events: none;
      transform: translateY(1px);
    }

    .neonselect__btn:hover {
      border-color: var(--ui-border-hover);
      box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, .10),
        0 0 20px var(--ui-glow);
      filter: saturate(1.03);
    }

    .neonselect__btn:focus {
      outline: none;
      border-color: var(--ui-accent);
      box-shadow: 0 0 0 2px rgba(184, 146, 255, .35), 0 0 24px var(--ui-glow);
    }

    .neonselect__btn:disabled {
      opacity: .6;
      cursor: not-allowed;
    }

    /* dropdown panel */
    .neonselect__menu {
      position: absolute;
      z-index: 50;
      top: calc(100% + 6px);
      left: 0;
      min-width: 100%;
      background: linear-gradient(180deg, var(--ui-surface-1), var(--ui-surface-2));
      border: 1px solid var(--ui-border);
      border-radius: 10px;
      box-shadow: 0 14px 30px rgba(0, 0, 0, .45), 0 0 16px var(--ui-glow);
      padding: 6px;
      display: none;
    }

    .neonselect.is-open .neonselect__menu {
      display: block;
    }

    .neonselect__list {
      list-style: none;
      margin: 0;
      padding: 0;
      max-height: 260px;
      overflow: auto;
    }

    .neonselect__opt {
      padding: 8px 10px;
      border-radius: 8px;
      color: var(--ui-text);
      font: inherit;
      letter-spacing: .2px;
      cursor: pointer;
      user-select: none;
    }

    .neonselect__opt:hover {
      background: rgba(255, 255, 255, .08);
    }

    .neonselect__opt[aria-selected="true"] {
      background: rgba(184, 146, 255, .15);
      border: 1px solid rgba(184, 146, 255, .35);
    }

    /* small size helper */
    .neonselect--sm .neonselect__btn {
      padding: 5px 34px 5px 8px;
      border-radius: 8px;
    }

    /* -------------------------------------------------------------------
   Fallback native select styling (used if NeonSelect JS is not applied)
   Targets selects that are NOT hidden by the enhancer.
   ------------------------------------------------------------------- */
    #controls select:not(.neonselect--hidden) {
      -webkit-appearance: none;
      -moz-appearance: none;
      appearance: none;
      color-scheme: dark;
      color: var(--ui-text);
      background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23B892FF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 12px center / 12px 12px,
        linear-gradient(180deg, var(--ui-surface-1), var(--ui-surface-2)) padding-box;
      border: 1px solid var(--ui-border);
      border-radius: 10px;
      box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, .06),
        0 0 16px var(--ui-glow);
      padding: 6px 38px 6px 10px;
      font: inherit;
      letter-spacing: .2px;
      cursor: pointer;
      transition: border-color .2s, box-shadow .2s;
    }

    #controls select:not(.neonselect--hidden):hover {
      border-color: var(--ui-border-hover);
      box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .10), 0 0 20px var(--ui-glow);
    }

    #controls select:not(.neonselect--hidden):focus {
      outline: none;
      border-color: var(--ui-accent);
      box-shadow: 0 0 0 2px rgba(184, 146, 255, .35), 0 0 24px var(--ui-glow);
    }

    #controls select:not(.neonselect--hidden):disabled {
      opacity: .6;
      cursor: not-allowed;
    }

    #controls select::-ms-expand {
      display: none;
    }

    #controls select::-webkit-focus-inner {
      border: 0;
      padding: 0;
    }

    /* ---------- Button ---------- */
    /* ---------- Button (normalized to panel font) ---------- */
    #controls button,
    #controls .btn {
      font: inherit;
      /* match #controls 16px font */
    }

    /* Main button */
    .btn {
      -webkit-appearance: none;
      appearance: none;
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 6px 12px;
      /* a hair tighter */
      border-radius: 12px;

      color: var(--ui-text);
      font: inherit;
      /* key fix */
      font-weight: 700;
      letter-spacing: .15px;
      line-height: 1.2;

      background:
        radial-gradient(120% 140% at 0% 0%, #2a0e3f 0%, #0e0e18 60%),
        linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, 0));
      border: 1px solid rgba(255, 255, 255, .18);
      box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, .05),
        0 8px 18px rgba(127, 0, 255, .28),
        0 0 12px rgba(127, 0, 255, .22);

      cursor: pointer;
      user-select: none;
      transition: transform .06s, box-shadow .2s, border-color .2s, filter .2s;
    }

    .btn:hover {
      border-color: #c19bff;
      box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, .08),
        0 10px 22px rgba(150, 80, 255, .34),
        0 0 18px rgba(150, 80, 255, .35);
      filter: saturate(1.1);
    }

    .btn:active {
      transform: translateY(1px) scale(.98);
      box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, .10),
        0 6px 14px rgba(120, 0, 255, .25),
        0 0 10px rgba(120, 0, 255, .25);
    }

    /* size + variant helpers */
    .btn--sm {
      padding: 6px 10px;
      border-radius: 10px;
      font: inherit;
      font-weight: 600;
    }

    .btn--ghost {
      background: linear-gradient(180deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, 0));
      border-color: rgba(255, 255, 255, .14);
    }

    /* Kill the old purple orb on Randomize */
    #randomizeButton.btn--glow::before {
      content: none !important;
    }

    /* Make Randomize button content-sized and not stretched by the grid cell */
    #controls .preset-row>#randomizeButton {
      justify-self: start;
      /* no stretch */
      inline-size: max-content;
      /* shrink to fit */
      white-space: nowrap;
    }

    /* ===== Neon Toggle — START (full replacement) ===== */
    .neontoggle--hidden {
      position: absolute !important;
      opacity: 0 !important;
      width: 1px !important;
      height: 1px !important;
      pointer-events: none !important;
      margin: 0 !important;
      padding: 0 !important;
      border: 0 !important;
    }

    .neontoggle {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      /* <-- added for the label */
      vertical-align: middle;
    }

    .neontoggle__btn {
      -webkit-appearance: none;
      appearance: none;
      position: relative;
      display: inline-block;
      width: 44px;
      height: 22px;
      padding: 0;
      border-radius: 9999px;
      background: linear-gradient(180deg, var(--ui-surface-1), var(--ui-surface-2));
      border: 1px solid var(--ui-border);
      box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, .06),
        0 0 14px var(--ui-glow);
      cursor: pointer;
      outline: none;
      transition: box-shadow .2s, border-color .2s, filter .2s;
    }

    .neontoggle__btn:hover {
      border-color: var(--ui-border-hover);
      box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, .10),
        0 0 20px var(--ui-glow);
      filter: saturate(1.03);
    }

    .neontoggle__btn:focus {
      box-shadow: 0 0 0 2px rgba(184, 146, 255, .35), 0 0 24px var(--ui-glow);
    }

    .neontoggle__thumb {
      position: absolute;
      top: 50%;
      left: 3px;
      transform: translate(0, -50%);
      width: 18px;
      height: 18px;
      border-radius: 50%;
      background: #fff;
      box-shadow: 0 2px 6px rgba(0, 0, 0, .45), 0 0 10px rgba(184, 146, 255, .35);
      transition: transform .18s ease;
    }

    /* ON state */
    .neontoggle__btn[aria-checked="true"] {
      background:
        radial-gradient(120% 140% at 0% 0%, rgba(90, 40, 160, .45) 0%, rgba(16, 16, 28, .9) 60%),
        linear-gradient(180deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, 0));
      border-color: rgba(184, 146, 255, .6);
    }

    .neontoggle__btn[aria-checked="true"] .neontoggle__thumb {
      transform: translate(22px, -50%);
      /* 44 - 18 - 4 ≈ 22 */
    }

    .neontoggle__btn[disabled] {
      opacity: .55;
      cursor: not-allowed;
    }

    /* On/Off text */
    .neontoggle__state {
      font: inherit;
      font-weight: 700;
      opacity: .9;
      user-select: none;
      white-space: nowrap;
    }

    .neontoggle__btn[disabled]+.neontoggle__state {
      opacity: .55;
    }

    /* ===== Neon Toggle — END ===== */

    /* ===== Swatch Button (neon frame + flat inner slab) ===== */
    .swatch-btn {
      -webkit-appearance: none;
      appearance: none;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      height: 26px;
      min-width: 120px;
      padding: 0 8px;
      border-radius: 4px;
      background:
        radial-gradient(120% 140% at 0% 0%, #2a0e3f 0%, #0e0e18 60%),
        linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, 0));
      border: 1px solid rgba(255, 255, 255, .18);
      box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, .05),
        0 8px 18px rgba(127, 0, 255, .28),
        0 0 12px rgba(127, 0, 255, .22);
      cursor: pointer;
      user-select: none;
      transition: transform .06s, box-shadow .2s, border-color .2s, filter .2s;
    }

    .swatch-btn:hover {
      border-color: #c19bff;
      box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, .08),
        0 10px 22px rgba(150, 80, 255, .34),
        0 0 18px rgba(150, 80, 255, .35);
      filter: saturate(1.05);
    }

    .swatch-btn:active {
      transform: translateY(1px) scale(.98);
    }

    .swatch-btn:focus {
      outline: none;
      box-shadow: 0 0 0 2px rgba(184, 146, 255, .35), 0 0 24px rgba(184, 146, 255, .35);
    }

    /* inner color slab */
    .swatch-fill {
      display: block;
      width: 100%;
      height: 18px;
      /* 70–75% of button height */
      margin: 0 8px;
      /* equal left/right breathing room */
      border-radius: 0;
      /* flat ends, not rounded */
      background: var(--swatch, #fff);
      box-shadow:
        inset 0 0 0 1px rgba(0, 0, 0, .45),
        inset 0 0 0 2px rgba(255, 255, 255, .10);
    }

/* === PATCH v3: Photonic hex overlay (align with slider values, keep short swatch) === */
/* Anchor: END OF FILE */
#controls .row.swatch {
  /* match slider-row grid so overall columns stay consistent */
  grid-template-columns: var(--label-w) min-content 1fr min-content var(--val-w-ft);
  position: relative; /* lets us absolutely-position the hex */
  align-items: center;
}

/* Story window defaults — no speaker alignment overrides (restored) */

/* keep the swatch short; do NOT span */
#controls .row.swatch .swatch-btn {
  grid-column: 2;      /* only the min-content column */
}

/* take the hex OUT of the grid flow and pin it to the right edge */
#controls .row.swatch .value {
  position: absolute;
  right: 0;            /* same edge as slider values */
  top: 50%;
  transform: translateY(-50%);
  width: auto;
  min-width: 72px;     /* fits '#RRGGBB' comfortably; bump if you show alpha */
  text-align: right;
  /* so it doesn’t block clicks on the swatch/row */
  pointer-events: none;
}
#controls .row.swatch .value > * { pointer-events: auto; } /* if you later make it editable */

.epoch-readout { display:flex; align-items:center; gap:8px; }
.chip {
  display:inline-block; width:12px; height:12px; border-radius:2px;
  background: var(--c, #fff);
  box-shadow: 0 0 0 1px rgba(255,255,255,.25) inset;
}

/* ===== Mode Gate ===== */
#modeGateOverlay[hidden] { display: none !important; }

.modegate {
  position: fixed; inset: 0; z-index: 1200;
  display: grid; place-items: center;
  background: rgba(0,0,0,.60);
  backdrop-filter: blur(2px);
  font-family: Arial, sans-serif; /* match panel */
  color: #fff;
}

.modegate-card {
  width: min(720px, calc(100vw - 40px));
  border-radius: 12px;
  background: rgba(0,0,0,.92);
  border: 1px solid rgba(255,255,255,.35);
  box-shadow: 0 20px 50px rgba(0,0,0,.6);
}

.modegate-header {
  padding: 18px 24px 8px;
  border-bottom: 1px solid rgba(255,255,255,.15);
  text-align: center;
}

/* Reuse brand style (same as panel) */
.modegate .brand {
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 900;
  letter-spacing: .06em;
  font-size: 40px;
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 2px #ffffff;
  user-select: none;
  margin: 0 auto;
}

.modegate-body {
  padding: 18px 24px 24px;
}

.modegate-stack {
  display: grid;
  justify-items: center;
  row-gap: 12px;
}

/* Upsized buttons but keep your .btn look */
.mode-btn {
  min-width: 360px;
  padding: 14px 22px;
  font-size: 20px;        /* larger text */
  border-radius: 14px;
}

.mode-blurb {
  max-width: 560px;
  text-align: center;
  margin: 4px 0 12px 0;
  opacity: .9;
  line-height: 1.35;
}

/* Disabled story button hints */
#modeStoryBtn[disabled] {
  opacity: .55;
  cursor: not-allowed;
}

/* ===== STORY WINDOW (Stage 1) — FULL REPLACEMENT ===== */
#storyWindow[hidden]{ display:none !important; }

#storyWindow{
  position:fixed;
  z-index:12;                 /* above #controls (10), below color picker (1000) */
  left:50%; top:50%;
  transform:translate(-50%,-50%);
  width:min(980px,calc(100vw - 80px));
  height:min(56vh,calc(100vh - 180px));
  display:grid;
  grid-template-rows:auto 1fr;        /* footer removed */
  background:rgba(0,0,0,.58);
  backdrop-filter:blur(1.5px);
  border:1px solid rgba(255,255,255,.28);
  border-radius:12px;
  box-shadow:0 14px 40px rgba(0,0,0,.5);
  color:#fff;
  font-family:Arial, sans-serif;      /* match panel */
  font-size:14px;                     /* JS syncs exact values at runtime */
  line-height:1.35;
}

/* header */
#storyWindow .sw-header{
  padding:14px 20px 8px;
  border-bottom:1px solid rgba(255,255,255,.15);
  text-align:left;
  position:relative;
}
#storyWindow .sw-header .brand{
  font-family:Arial, Helvetica, sans-serif;
  font-weight:900; letter-spacing:.06em;
  font-size:32px; line-height:1;
  color:transparent; -webkit-text-stroke:2px #ffffff;
  user-select:none;
}
#storyWindow .sw-header .sw-sub{ margin-top:6px; opacity:.85; font-size:14px; }

/* body */
#storyWindow .sw-body{
  padding:14px 20px;
  overflow:auto;
  display:grid;
  gap:10px;
  max-height:calc(100vh - 220px); /* header padding allowance */
}
#storyWindow .sw-body h3{ margin:0; font-size:20px; }
#storyWindow .sw-body #swText{ opacity:.95; line-height:1.45; }

/* hide any legacy footer/Close that might be in static HTML */
#storyWindow .sw-footer{ display:none !important; }

/* optional tools area in header (safe if present) */
#storyWindow .sw-tools{
  position:absolute; right:12px; top:10px;
  display:inline-flex; align-items:center; gap:8px; opacity:.9;
}
#storyWindow .sw-tools label{ font-size:.85em; opacity:.85; }
#storyWindow #swOpacity{ width:140px; }

/* ===== Scrollbar match with control panel ===== */
/* Firefox */
#controls .panel-body, #storyWindow .sw-body{
  scrollbar-width:thin; scrollbar-color:rgba(255,255,255,.35) transparent;
}
/* WebKit/Blink */
#controls .panel-body::-webkit-scrollbar, #storyWindow .sw-body::-webkit-scrollbar{ width:10px; height:10px; }
#controls .panel-body::-webkit-scrollbar-track, #storyWindow .sw-body::-webkit-scrollbar-track{ background:rgba(255,255,255,0.06); }
#controls .panel-body::-webkit-scrollbar-thumb, #storyWindow .sw-body::-webkit-scrollbar-thumb{
  background:rgba(255,255,255,.28); border-radius:8px; border:2px solid transparent; background-clip:content-box;
}
#controls .panel-body::-webkit-scrollbar-thumb:hover, #storyWindow .sw-body::-webkit-scrollbar-thumb:hover{
  background:rgba(255,255,255,.40);
}

/* ===== Story content formatting ===== */
#storyWindow .st-line{ margin:6px 0 8px; }
#storyWindow .st-gap{ height:10px; }

/* Dialog */
#storyWindow .st-dialog .st-speaker{
  font-weight:700; letter-spacing:.02em; margin-right:.35em;
  /* color is set via CSS vars (from XML) */
}
#storyWindow .st-dialog .st-speaker::after{ content:":"; opacity:.7; margin-left:.05em; }
#storyWindow .st-dialog .st-quote::before{ content:"“"; opacity:.65; margin-right:.06em; }
#storyWindow .st-dialog .st-quote::after{ content:"”"; opacity:.65; margin-left:.02em; }

/* Info callouts (cyan accent) */

/* Enforce 10% side gaps for speakers:
   - Mango occupies the left 90% and leaves 10% gap on the right
   - Pomegranate occupies the right 90% and leaves 10% gap on the left
*/
#storyWindow .st-dialog .st-quote { display:block; width:90%; }

#storyWindow .st-dialog .st-quote[data-char="mango"] {
  margin-left: 0;
  margin-right: 10%;
  text-align: left;
}

#storyWindow .st-dialog .st-quote[data-char="pomegranate"] {
  margin-left: 10%;
  margin-right: 0;
  text-align: left;
}

/* Speaker width layout: Mango left 80%, Pomegranate right 80% */
/* Keep quotes as blocks and constrain width to avoid overlap */
#storyWindow .st-dialog .st-quote { display:block; max-width:90%; }

/* Mango: anchor to left (occupies left 90%, leaving 10% gap on right) */
#storyWindow .st-dialog .st-quote[data-char="mango"] {
  width: 90%;
  margin-left: 0;
  margin-right: auto;
  text-align: left;
}

/* Pomegranate: anchor to right (occupies right 80%) */
# Pomegranate: anchor to right (occupies right 90%, leaving 10% gap on left) */
#storyWindow .st-dialog .st-quote[data-char="pomegranate"] {
  width: 90%;
  margin-left: auto;
  margin-right: 0;
  text-align: left;
}
#storyWindow .st-info{
  margin:8px 0; padding:6px 10px 6px 12px;
  border-left:2px solid rgba(0,200,255,.7);
  background:rgba(0,180,255,.08);
  color:#AEE8FF;
}

/* ===== Tasks (grey text) ===== */
#storyWindow .st-tasks{ background:transparent !important; border:0 !important; padding:0; margin:6px 0 0; }
#storyWindow .st-tasks-title{ margin:4px 0 8px; color:#B8B8B8; }
#storyWindow .st-tasks-title .st-tasks-group{ font-weight:700; color:#D0D0D0; }

#storyWindow .st-task{
  margin:4px 0; padding:2px 0;
  color:rgba(255,255,255,.70);     /* grey text */
  background:transparent !important;
  border:0 !important;
  line-height:1.35; font-weight:500;
}
#storyWindow .st-task .st-task-control{ color:#D0D0D0; }
#storyWindow .st-task .st-task-value{ color:#DADADA; }

/* Lock In button (neutral grey) */
#storyWindow .st-tasks-cta{ margin-top:10px; display:flex; justify-content:flex-start; }
#storyWindow .st-lockin.btn{
  background:rgba(255,255,255,.12) !important;
  border:1px solid rgba(255,255,255,.35) !important;
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.05), 0 8px 18px rgba(0,0,0,.35) !important;
  color:rgba(255,255,255,.92) !important;
}
#storyWindow .st-lockin.btn:hover{
  background:rgba(255,255,255,.18) !important;
  border-color:rgba(255,255,255,.50) !important;
}
#storyWindow .st-lockin.btn:active{
  transform:translateY(1px);
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.08), 0 6px 14px rgba(0,0,0,.30) !important;
}

/* Task state colors */
#storyWindow .st-task { color: rgba(255,255,255,.70); }
#storyWindow .st-task.is-ok { color: #71ff82; } /* green */

#storyWindow .st-tasks-cta .st-lockin { 
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.35);
  color: rgba(255,255,255,.92);
}
#storyWindow .st-tasks.is-ready .st-lockin,
#storyWindow .st-lockin.is-ready {
  background: rgba(40,200,90,.22);
  border-color: rgba(40,200,90,.65);
  box-shadow: inset 0 0 0 1px rgba(40,200,90,.25), 0 8px 18px rgba(0,0,0,.35);
  color: #aaffb8;
}

/* Make the entire line adopt the state color */
#storyWindow .st-task { color: rgba(255,255,255,.70); }
#storyWindow .st-task * { color: inherit !important; }         /* force inherit */
#storyWindow .st-task.is-ok { color: #71ff82; }                 /* green */

/* Lock In button states */
#storyWindow .st-tasks-cta .st-lockin {
  background: rgba(255,255,255,.12) !important;
  border: 1px solid rgba(255,255,255,.35) !important;
  color: rgba(255,255,255,.92) !important;
}

#storyWindow .st-lockin[disabled] {
  opacity: .55;
  cursor: not-allowed;
  filter: grayscale(.35);
  box-shadow: none !important;
}

#storyWindow .st-tasks.is-ready .st-lockin,
#storyWindow .st-lockin.is-ready {
  background: rgba(40,200,90,.22) !important;
  border-color: rgba(40,200,90,.65) !important;
  box-shadow: inset 0 0 0 1px rgba(40,200,90,.25), 0 8px 18px rgba(0,0,0,.35) !important;
  color: #aaffb8 !important;
}

/* ========= Plasmatron logo (overlay + subtle hue cycle) ========= */

/* Base: apply to the text node that currently holds "PLASMATRON" */
.logo-img {
  position: relative;
  display: inline-block;                 /* ensure the ::after has a box */
  color: transparent !important;         /* keep accessible name, hide paint */
  -webkit-text-stroke: 0 !important;
  min-height: 1em;                       /* safety: give it some height */
}

/* Draw the PNG over the same box and animate its hue */
.logo-img::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url("plasmatron.png") center / contain no-repeat;
  pointer-events: none;

  /* animated hue */
  --h: 0deg;
  animation: logoHue 20s linear infinite;
  filter: hue-rotate(var(--h));
  -webkit-filter: hue-rotate(var(--h));
  will-change: filter;
}

/* Size hints for the two placements you showed */
#modeGateTitle.logo-img { min-height: 48px; }
#storyWindow .sw-header .brand.logo-img { min-height: 28px; }

/* Let the custom property animate smoothly in Chromium/WebKit */
@property --h { syntax: '<angle>'; initial-value: 0deg; inherits: false; }
@keyframes logoHue { to { --h: 360deg; } }

/* ========= Optional: IMG-based variant (if you use a real <img>) ========= */
/* Tint mostly-white artwork by creating chroma, then hue-rotating it. */
.panel-header .brand img.logo-img {
  --h: 0deg;
  animation: logoHue 20s linear infinite;
  filter: invert(1) sepia(1) saturate(5000%) hue-rotate(var(--h)) brightness(1) contrast(1);
  -webkit-filter: invert(1) sepia(1) saturate(5000%) hue-rotate(var(--h)) brightness(1) contrast(1);
  will-change: filter;
}
