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

/* One height for every header control: the nav links, the action buttons and the collapsed panel. */
:root {
  --header-size: 40px;
}

@media (max-width: 950px) {
  :root {
    --header-size: 44px;
  }
}

/* On narrow screens the gallery link is just its icon; the name stays for screen readers. */
@media (max-width: 950px) {
  #info a.home {
    width: var(--header-size);
    padding: 0;
    justify-content: center;

    span {
      position: absolute;
      width: 1px;
      height: 1px;
      overflow: hidden;
      clip-path: inset(50%);
      white-space: nowrap;
    }
  }
}

html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

.button {
  background-color: #2c2c2c;
  color: #e0e0e0;
  font-family: "Segoe UI", sans-serif;
  font-size: 13px;
  padding: 20px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 9999;
  cursor: pointer;

  &:hover {
    background-color: #3a3a3a;
  }

  &:active {
    background-color: #1e1e1e;
  }
}

#gui-container {
  flex: 1;
  min-width: 0;

  > .gui {
    padding: 0 16px;

    &:not(.collapsed) {
      padding-bottom: 16px;
    }

    > .gui-title {
      height: var(--header-size);
    }

    .gui-rows {
      border-top-width: 0;
    }

    .gui-rows.visible {
      margin-top: 0;
      border-top-width: 1px;
    }
  }
}

.hide-ui #main-gui {
  display: none;
}

.action,
#randomize-button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: var(--header-size);
  height: var(--header-size);
  padding: 0;

  img {
    display: block;
    width: 22px;
    height: 22px;
  }
}

canvas {
  position: absolute;
  inset: 0;
  touch-action: none;
  z-index: 2;
}

#main-gui {
  z-index: 10;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
}

@media (min-width: 951px) {
  #main-gui {
    position: fixed;
    top: 10px;
    right: 10px;
    width: 520px;
  }
}

@media (max-width: 950px) {
  /* Buttons in a row at the top right, the panel full width along the bottom. */
  #main-gui {
    position: fixed;
    top: calc(10px + env(safe-area-inset-top));
    bottom: calc(10px + env(safe-area-inset-bottom));
    left: calc(10px + env(safe-area-inset-left));
    right: calc(10px + env(safe-area-inset-right));
    flex-wrap: wrap;
    justify-content: flex-end;
    align-content: space-between;
    gap: 6px;
    pointer-events: none;

    > * {
      pointer-events: auto;
    }

    .gui-scroller {
      max-height: 50vh;
    }
  }

  #gui-container {
    flex: 0 0 100%;
  }
}

.paused #pause-button {
  background-color: #4a4a4a;
}

/* Shrunk or hidden by fitNav() in common.js when the header gets too narrow. */
#info.compact a.explainer {
  width: var(--header-size);
  padding: 0;
  justify-content: center;

  span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

#info.no-arrows a:not(.home, .explainer),
#info.no-explainer a.explainer,
#info.no-home a.home {
  display: none;
}

/* The gallery link, with the previous and next published days as buttons either side. */
#info {
  position: fixed;
  left: calc(10px + env(safe-area-inset-left));
  top: calc(10px + env(safe-area-inset-top));
  z-index: 10;
  display: flex;
  gap: 6px;
  font-family: "Segoe UI", sans-serif;
  font-size: 13px;

  a {
    background-color: #2c2c2c;
    color: #e0e0e0;
    display: flex;
    align-items: center;
    gap: 6px;
    height: var(--header-size);
    padding: 0 14px;
    font-variant-numeric: tabular-nums;

    svg {
      display: block;
      flex-shrink: 0;
    }

    /* Trimmed to the capitals, so the letters themselves sit in the middle. */
    span {
      text-box: trim-both cap alphabetic;
    }
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    text-decoration: none;
    white-space: nowrap;

    &:hover {
      background-color: #3a3a3a;
    }

    &:active {
      background-color: #1e1e1e;
    }
  }
}

.hide-ui #info {
  display: none;
}

/* The 02 project has no inherited gallery/header controls. */
#info,
.explainer,
a.explainer {
  display: none !important;
}

/* Auto change countdown (autoChange.js): the fill shrinks to the next change. */
#auto-change {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 4;
  transform: translateX(-50%);
  box-sizing: content-box;
  overflow: hidden;
  isolation: isolate;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--loading-pill, rgb(32, 32, 32));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14), 0 2px 10px rgba(0, 0, 0, 0.18);
  color: var(--loading-pill-color, rgb(240, 240, 240));
  font-family: "Segoe UI", sans-serif;
  font-size: 13px;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition:
    opacity 0.4s ease,
    width 0.35s ease;

  span {
    display: inline-block;
  }

  &::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--loading-progress, rgba(255, 255, 255, 0.16));
    transform-origin: left;
    transform: scaleX(var(--left, 1));
  }

  &.shown {
    opacity: 1;
  }

  &.shown.waiting {
    opacity: 0.6;
  }
}

@media (max-width: 950px) {
  /* Above the collapsed panel along the bottom. */
  #auto-change {
    bottom: calc(10px + var(--header-size) + 10px + env(safe-area-inset-bottom));
  }
}

.hide-ui #auto-change {
  display: none;
}

/* Placeholder from first paint until the sketch's first frame (see ready() in common.js). */
#loading {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  justify-content: center;
  background: var(--loading-background, #e9e7e3);
  color: var(--loading-color, rgba(0, 0, 0, 0.42));
  font-family: "Segoe UI", sans-serif;
  font-size: 13px;
  letter-spacing: 0.06em;
  pointer-events: none;
  transition:
    opacity 0.6s ease,
    background-color 0.6s ease;

  /* A solid pill, so the message reads on any backdrop. */
  span {
    padding: 8px 16px;
    border-radius: 999px;
    background: var(--loading-pill, rgb(32, 32, 32));
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14), 0 2px 10px rgba(0, 0, 0, 0.18);
    color: var(--loading-pill-color, rgb(240, 240, 240));
    animation: loading-pulse 1.4s ease-in-out infinite alternate;
  }

  /* Load progress (loadingStep() in common.js) fills the pill from the left. */
  &.progress span:first-child {
    position: relative;
    isolation: isolate;
    overflow: hidden;

    &::before {
      content: "";
      position: absolute;
      inset: 0;
      z-index: -1;
      background: var(--loading-progress, rgba(255, 255, 255, 0.16));
      transform-origin: left;
      transform: scaleX(var(--progress, 0));
      transition:
        transform 0.3s ease,
        opacity 0.25s ease;
    }
  }

  &.hint span:first-child::before {
    opacity: 0;
  }

  &.done {
    opacity: 0;
  }

  /* The pill turns into the hint (ready() in common.js): the backdrop clears, the text swaps as it resizes. */
  &.hint {
    background-color: transparent;

    span {
      display: inline-block;
      overflow: hidden;
      white-space: nowrap;
      max-width: calc(100vw - 32px);
      text-overflow: ellipsis;
      text-align: center;
      animation: none;
      color: transparent;
      transition:
        width 0.35s ease,
        color 0.25s ease;

      img {
        width: 16px;
        height: 16px;
        margin: 0 2px;
        vertical-align: -3px;
        opacity: 0;
        transition: opacity 0.25s ease;
      }
    }
  }

  &.hint.shown span {
    color: var(--loading-pill-color, rgb(240, 240, 240));

    img {
      opacity: 1;
    }
  }
}

/* Only the text pulses; the pill stays solid. */
@keyframes loading-pulse {
  from {
    color: rgba(240, 240, 240, 0.55);
  }
  to {
    color: var(--loading-pill-color, rgb(240, 240, 240));
  }
}

/*! guspira v0.2.0 — A reactive GUI toolkit for creative coding sketches
 * https://github.com/spite/guspira
 * MIT License, Copyright (c) 2026 Jaume Sanchez
 */
/* css/gui.css */
.gui {
  --gui-bg: #2c2c2c;
  --gui-fg: #e0e0e0;
  --gui-muted: #888;
  --gui-field-bg: #3e3e3e;
  --gui-border: #555;
  --gui-focus: #888;
  --gui-accent: #ffffff;
  --gui-btn-bg: #4a4a4a;
  --gui-btn-hover: #5a5a5a;
  --gui-btn-active: #333333;
  --gui-track: #333333;
  --gui-fill: #e0e0e0;
  --gui-thumb: #ffffff;
  --gui-thumb-hover: #f0f0f0;
  --gui-check: var(--gui-bg);
  --gui-font:
    "Segoe UI",
    system-ui,
    sans-serif;
  --gui-font-size: 13px;
  --gui-padding: 20px;
  --gui-gap: 8px;
  --gui-row-height: 24px;
  --gui-label-width: 140px;
  --gui-radius: 4px;
  --gui-panel-radius: 6px;
  --gui-check-size: 16px;
  --gui-track-height: 4px;
  --gui-graph-height: 38px;
  --gui-warn: #ff6b4a;
  --gui-series-1: #4c7c0c;
  --gui-series-2: #fcb300;
  --gui-series-3: #c74900;
  --gui-series-4: #850700;
  --gui-series-5: #284280;
  --gui-pad-height: 90px;
  --gui-pad-dot-size: 10px;
  --gui-max-height: calc(100vh - 80px);
  position: relative;
  background-color: var(--gui-bg);
  color: var(--gui-fg);
  font-family: var(--gui-font);
  font-size: var(--gui-font-size);
  padding: var(--gui-padding);
  border-radius: var(--gui-panel-radius);
  box-shadow: var(--shadow-panel, 0 2px 6px rgba(0, 0, 0, 0.3));
  z-index: 9999;
  user-select: none;
  display: none;
}
.gui.visible {
  display: block;
}
.gui.gui-light {
  --gui-bg: #f4f4f5;
  --gui-fg: #1c1c1e;
  --gui-muted: #6b6b70;
  --gui-field-bg: #ffffff;
  --gui-border: #c9c9cd;
  --gui-focus: #6b6b70;
  --gui-accent: #1c1c1e;
  --gui-btn-bg: #e6e6e9;
  --gui-btn-hover: #dcdce0;
  --gui-btn-active: #cfcfd4;
  --gui-track: #d4d4d8;
  --gui-fill: #3f3f46;
  --gui-thumb: #ffffff;
  --gui-thumb-hover: #f4f4f5;
  --gui-check: #f4f4f5;
  box-shadow: var(--shadow-panel, 0 2px 6px rgba(0, 0, 0, 0.12));
}
.gui-title,
.gui-section-title {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: inherit;
}
.gui-title:focus-visible,
.gui-section-title:focus-visible,
.gui-tab-btn:focus-visible {
  outline: 2px solid var(--gui-focus);
  outline-offset: 2px;
}
.gui-title {
  display: flex;
  flex-direction: row;
  font-size: calc(var(--gui-font-size) - 1px);
  font-weight: bold;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}
.gui-chevron {
  display: flex;
  align-items: center;
  transition: transform 150ms ease-in-out;
}
.gui-chevron svg {
  height: 12px;
  width: 12px;
}
.gui.collapsed .gui-title > .gui-chevron {
  transform: rotate(-90deg);
}
.gui-scroller {
  max-height: var(--gui-max-height);
  overflow: auto;
  scrollbar-width: none;
}
.gui-scroller::-webkit-scrollbar {
  display: none;
}
.gui-rows {
  interpolate-size: allow-keywords;
  display: flex;
  flex-direction: column;
  gap: var(--gui-gap);
  opacity: 0;
  height: 0;
  overflow: hidden;
  transition: height 100ms ease-in-out, opacity 100ms ease-in-out;
  border-top: 1px solid var(--gui-muted);
}
.gui-rows.visible {
  height: auto;
  margin-top: 12px;
  padding-top: 12px;
  opacity: 1;
}
.gui-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--gui-gap);
  min-height: var(--gui-row-height);
}
.gui-row.disabled,
.gui-section.disabled {
  pointer-events: none;
  opacity: 0.5;
}
.gui-hidden {
  display: none !important;
}
.gui-label {
  opacity: 0.8;
  flex: 1 1 auto;
  min-width: 0;
}
.gui-label.gui-randomizable {
  cursor: pointer;
  text-decoration: underline dotted transparent;
  text-underline-offset: 3px;
  transition: text-decoration-color 120ms ease-in-out, opacity 120ms ease-in-out;
}
.gui-label.gui-randomizable:hover {
  opacity: 1;
  text-decoration-color: var(--gui-muted);
}
:where(.gui) :where(input, select, button, textarea) {
  box-sizing: border-box;
  height: var(--gui-row-height);
  background: var(--gui-field-bg);
  border: 1px solid var(--gui-border);
  color: var(--gui-fg);
  padding: 0 6px;
  border-radius: var(--gui-radius);
  font-size: calc(var(--gui-font-size) - 1px);
  font-family: inherit;
  line-height: 1;
  outline: none;
}
.gui input:focus,
.gui select:focus,
.gui textarea:focus,
.gui button:focus-visible {
  border-color: var(--gui-focus);
}
.gui input[type=checkbox] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: var(--gui-check-size);
  height: var(--gui-check-size);
  padding: 0;
  border: 1px solid var(--gui-border);
  border-radius: var(--gui-radius);
  background: var(--gui-field-bg);
  cursor: pointer;
  transition: background-color 90ms ease-in-out, border-color 90ms ease-in-out;
}
.gui input[type=checkbox]:hover {
  border-color: var(--gui-focus);
}
.gui input[type=checkbox]:checked {
  background: var(--gui-accent);
  border-color: var(--gui-accent);
}
.gui input[type=checkbox]::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 46%;
  width: 0.3em;
  height: 0.62em;
  border: solid var(--gui-check);
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -50%) rotate(45deg) scale(0.6);
  opacity: 0;
  transition: opacity 90ms ease-in-out, transform 90ms ease-in-out;
}
.gui input[type=checkbox]:checked::after {
  opacity: 1;
  transform: translate(-50%, -50%) rotate(45deg) scale(1);
}
.gui-control,
.gui-select,
.gui-input-text,
.gui-input-number,
.gui-color {
  flex: 0 0 calc(100% - var(--gui-label-width));
  min-width: 0;
}
.gui-color {
  height: var(--gui-row-height);
  padding: 0;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
.gui-color::-webkit-color-swatch-wrapper {
  padding: 2px;
}
.gui-color::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}
.gui-segmented {
  display: flex;
}
.gui-segment {
  flex: 1 1 0;
  min-width: 0;
  font-size: calc(var(--gui-font-size) - 2px);
  color: var(--gui-muted);
  cursor: pointer;
  border-radius: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background-color 90ms ease-in-out, color 90ms ease-in-out;
}
.gui-segment + .gui-segment {
  margin-left: -1px;
}
.gui-segment:first-child {
  border-radius: var(--gui-radius) 0 0 var(--gui-radius);
}
.gui-segment:last-child {
  border-radius: 0 var(--gui-radius) var(--gui-radius) 0;
}
.gui-segment:hover {
  color: var(--gui-fg);
}
.gui-segment.active {
  background: var(--gui-btn-bg);
  color: var(--gui-fg);
  border-color: var(--gui-focus);
  position: relative;
  z-index: 1;
}
.gui-segment:focus-visible {
  outline: 2px solid var(--gui-focus);
  outline-offset: -2px;
  z-index: 2;
}
.gui-textarea {
  height: auto;
  padding: 4px 6px;
  width: 100%;
  resize: vertical;
  line-height: 1.45;
  font-family: inherit;
}
.gui-scrubbable {
  cursor: ew-resize;
  touch-action: pan-y;
}
.gui-scrubbable:focus {
  cursor: text;
}
body.gui-scrubbing,
body.gui-scrubbing * {
  cursor: ew-resize !important;
  user-select: none !important;
}
.gui-row.gui-row-block {
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
}
.gui-block-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--gui-gap);
}
.gui-graph {
  flex: 1 1 auto;
  min-width: 0;
}
.gui-graph-val {
  flex: 0 0 auto;
  text-align: right;
}
.gui-graph.gui-graph-paused {
  opacity: 0.45;
}
.gui-monitor.gui-over {
  color: var(--gui-warn);
  opacity: 1;
}
.gui-vector {
  display: flex;
  gap: 4px;
}
.gui-vector-axis {
  flex: 1 1 0;
  min-width: 0;
}
.gui-pad {
  position: relative;
  height: var(--gui-pad-height);
  cursor: crosshair;
  touch-action: none;
  border: 1px solid var(--gui-border);
  border-radius: var(--gui-radius);
  background:
    linear-gradient(var(--gui-border), var(--gui-border)) 50% 0 / 1px 100% no-repeat,
    linear-gradient(var(--gui-border), var(--gui-border)) 0 50% / 100% 1px no-repeat,
    var(--gui-field-bg);
}
.gui-pad:focus-visible {
  outline: 2px solid var(--gui-focus);
  outline-offset: 2px;
}
.gui-pad-dot {
  position: absolute;
  width: var(--gui-pad-dot-size);
  height: var(--gui-pad-dot-size);
  margin: calc(var(--gui-pad-dot-size) / -2) 0 0 calc(var(--gui-pad-dot-size) / -2);
  border-radius: 50%;
  background: var(--gui-thumb);
  pointer-events: none;
}
.gui-pad:hover .gui-pad-dot {
  background: var(--gui-thumb-hover);
}
.gui-btn {
  width: 100%;
  cursor: pointer;
  background: var(--gui-btn-bg);
}
.gui-btn:hover {
  background: var(--gui-btn-hover);
}
.gui-btn:active {
  background: var(--gui-btn-active);
}
.gui-btn-group {
  display: flex;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
}
.gui-btn-group .gui-btn {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
}
.gui-row.gui-compact {
  gap: 4px;
}
.gui-row.gui-compact > .gui-select,
.gui-row.gui-compact > .gui-input-text {
  flex: 1 1 auto;
}
.gui-btn-mini {
  flex: 0 0 auto;
  width: auto;
  padding: 0 9px;
}
.gui-monitor {
  flex: 0 0 auto;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
  font-size: calc(var(--gui-font-size) - 1px);
}
.gui-slider-container {
  display: flex;
  align-items: center;
  gap: var(--gui-gap);
  flex: 0 0 calc(100% - var(--gui-label-width));
  min-width: 0;
}
.gui-slider {
  flex: 1 1 auto;
  min-width: 0;
  cursor: pointer;
}
.gui-slider-val,
.gui-slider-edit {
  flex: 0 0 auto;
  width: 52px;
  text-align: right;
  opacity: 0.7;
  font-size: calc(var(--gui-font-size) - 2px);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.gui-range-val {
  width: auto;
  min-width: 52px;
}
.gui-slider-val {
  cursor: text;
}
.gui-slider-val:hover {
  opacity: 1;
}
.gui-slider-edit {
  opacity: 1;
  padding: 2px 4px;
}
.gui-text {
  width: 100%;
  opacity: 0.75;
  line-height: 1.4;
  font-size: calc(var(--gui-font-size) - 1px);
}
.gui-text a {
  color: inherit;
}
.gui-row:has(.gui-separator) {
  min-height: 12px;
  height: 12px;
}
.gui-separator {
  background: var(--gui-muted);
  opacity: 0.5;
  height: 1px;
  width: 100%;
}
.gui-tabbar {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}
.gui-tab-btn {
  flex: 1 1 auto;
  min-width: 46px;
  padding: 5px 4px;
  font-size: calc(var(--gui-font-size) - 2px);
  background: var(--gui-field-bg);
  border: 1px solid var(--gui-border);
  border-bottom: none;
  border-radius: var(--gui-radius) var(--gui-radius) 0 0;
  color: var(--gui-muted);
  cursor: pointer;
}
.gui-tab-btn:hover {
  color: var(--gui-fg);
}
.gui-tab-btn.active {
  background: var(--gui-bg);
  color: var(--gui-fg);
}
.gui-tab-panel {
  display: none;
}
.gui-tab-panel.active {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.gui-section {
  interpolate-size: allow-keywords;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.gui-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: calc(var(--gui-font-size) - 3px);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--gui-muted);
}
.gui-section-title.gui-collapsible {
  cursor: pointer;
}
.gui-section-title.gui-collapsible:hover {
  color: var(--gui-fg);
}
.gui-section-title .gui-chevron svg {
  height: 10px;
  width: 10px;
}
.gui-section:not(.open) .gui-section-title .gui-chevron {
  transform: rotate(-90deg);
}
.gui-section-body {
  display: flex;
  flex-direction: column;
  gap: var(--gui-gap);
  height: auto;
  overflow: hidden;
  transition: height 120ms ease-in-out;
}
.gui-section:not(.open) > .gui-section-body {
  height: 0;
}
@media (prefers-reduced-motion: reduce) {
  .gui-rows,
  .gui-section-body,
  .gui-chevron {
    transition: none;
  }
}

/* The old square buttons give way to the dock. */
#randomize-button,
#pause-button {
  display: none !important;
}

:root {
  --dock-bg: rgba(18, 19, 24, 0.72);
  --dock-line: rgba(255, 255, 255, 0.12);
  --dock-fg: #eceef5;
  --dock-dim: rgba(236, 238, 245, 0.55);
  --accent: #7be0ff;
  --accent-2: #ff8fb1;
}

.dock {
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: min(820px, calc(100vw - 20px));
  box-sizing: border-box;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--dock-fg);
  font: 500 12px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--dock-bg);
  border: 1px solid var(--dock-line);
  border-radius: 22px;
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  transition: opacity 0.4s, transform 0.4s;
  z-index: 20;
}
.dock.busy {
  opacity: 0.35;
}
.dock.busy:hover {
  opacity: 1;
}

.dk-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.dk-label {
  flex: none;
  width: 54px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dock-dim);
}
.dk-grow {
  flex: 1;
}
.dk-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
  min-width: 0;
}
.dk-chips::-webkit-scrollbar {
  display: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.dk-chip {
  flex: none;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid var(--dock-line);
  background: rgba(255, 255, 255, 0.05);
  transition: background 0.2s, border-color 0.2s, transform 0.15s, color 0.2s;
}
.dk-chip:hover {
  background: rgba(255, 255, 255, 0.12);
}
.dk-chip:active {
  transform: scale(0.95);
}
.dk-chip[aria-pressed="true"] {
  color: #07121a;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}

.dk-switch {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--dock-line);
  background: rgba(255, 255, 255, 0.05);
}
.dk-knob {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--dock-dim);
  transition: transform 0.25s, background 0.25s, box-shadow 0.25s;
}
.dk-switch[aria-checked="true"] .dk-knob {
  transform: translateX(2px);
  background: linear-gradient(135deg, #fff, var(--accent));
  box-shadow: 0 0 14px var(--accent);
}
.dk-swatches {
  display: flex;
  gap: 7px;
  opacity: 0.35;
  pointer-events: none;
  transition: opacity 0.3s;
}
.glass-on .dk-swatches {
  opacity: 1;
  pointer-events: auto;
}
.dk-swatch {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  background: radial-gradient(circle at 32% 30%, #fff 0 12%, var(--tint) 45%, color-mix(in srgb, var(--tint) 55%, #000) 100%);
  transition: transform 0.15s, border-color 0.15s;
}
.dk-swatch:hover {
  transform: scale(1.12);
}
.dk-swatch[aria-pressed="true"] {
  border-color: #fff;
}

.dk-segment {
  flex: none;
  display: flex;
  padding: 3px;
  gap: 2px;
  border-radius: 999px;
  border: 1px solid var(--dock-line);
  background: rgba(0, 0, 0, 0.25);
}
.dk-seg {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--dock-dim);
  transition: background 0.2s, color 0.2s;
}
.dk-seg[aria-pressed="true"] {
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
}
.dk-actions {
  flex: none;
  display: flex;
  gap: 6px;
}
.dk-action {
  flex: none;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px;
  border-radius: 12px;
  border: 1px solid var(--dock-line);
  background: rgba(255, 255, 255, 0.08);
  transition: background 0.2s, transform 0.15s;
}
.dk-action svg,
.dk-seg svg {
  flex: none;
}
.dk-action:hover {
  background: rgba(255, 255, 255, 0.18);
}
.dk-action:active {
  transform: scale(0.95);
}
.dk-action.dk-alt {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent-2), #ffb36b);
  color: #1b0a12;
  font-weight: 700;
}

canvas {
  cursor: crosshair;
}

@media (max-width: 640px) {
  .dock {
    padding: 9px 10px;
    border-radius: 18px;
  }
  .dk-label {
    width: 44px;
  }
  .dk-row:last-child {
    flex-wrap: wrap;
  }
  .dk-row:last-child .dk-label {
    display: none;
  }
  .dk-action span,
  .dk-seg span {
    display: none;
  }
}

/* Desktop control rail: a clearer, separated panel instead of a wide bottom dock. */
@media (min-width: 641px) {
  .dock {
    left: auto;
    right: calc(16px + env(safe-area-inset-right, 0px));
    bottom: auto;
    top: calc(16px + env(safe-area-inset-top, 0px));
    transform: none;
    width: 286px;
    max-height: calc(100vh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    gap: 12px;
    padding: 50px 12px 12px;
    border-radius: 18px;
    background:
      linear-gradient(145deg, rgba(42, 44, 54, 0.92), rgba(14, 15, 20, 0.82));
  }

  .dock::before {
    content: "SHATTER CONTROLS";
    position: absolute;
    top: 14px;
    left: 14px;
    right: 14px;
    color: rgba(236, 238, 245, 0.68);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.18em;
  }

  .dk-row {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 8px;
  }

  .dk-label {
    width: 100%;
  }

  .dk-chips,
  .dk-swatches,
  .dk-actions,
  .dk-segment,
  .dk-switch {
    max-width: 100%;
  }

  .dk-chips {
    width: 100%;
  }

  .dk-chip {
    padding-inline: 11px;
  }

  .dk-row:last-child {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .dk-row:last-child .dk-label {
    display: block;
  }

  .dk-row:last-child .dk-grow {
    display: none;
  }

  .dk-segment {
    grid-column: 1;
  }

  .dk-actions {
    grid-column: 2;
  }

  .dk-action {
    width: 38px;
    height: 38px;
    justify-content: center;
    padding: 0;
  }

  .dk-action span,
  .dk-seg span {
    display: none;
  }

  .dk-seg {
    padding-inline: 9px;
  }
}

/* Consistent project navigation */
.project-nav {
  position: fixed;
  z-index: 30;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: calc(10px + env(safe-area-inset-left, 0px));
  display: flex;
  align-items: stretch;
  gap: 6px;
  height: 40px;
  color: #eceef5;
  font: 600 12px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.project-nav__home,
.project-nav__title {
  display: flex;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(18, 19, 24, 0.72);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(14px);
}

.project-nav__home {
  gap: 8px;
  min-width: 40px;
  padding: 0 12px;
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
}

.project-nav__home svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.project-nav__title {
  padding: 0 12px;
  border-radius: 8px;
  color: rgba(236, 238, 245, 0.72);
}

/* The custom dock is the only control surface. */
#main-gui,
#randomize-button,
#pause-button {
  display: none !important;
}

.dock {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.dk-settings {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--dock-line);
}

/* Collapsible Object and Surface selectors */
.dk-dropdown {
  border: 1px solid var(--dock-line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  overflow: hidden;
}

.dk-dropdown summary {
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 11px;
  color: rgba(236, 238, 245, 0.82);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  list-style: none;
}

.dk-dropdown summary::-webkit-details-marker {
  display: none;
}

.dk-dropdown summary::after {
  content: "+";
  color: var(--accent);
  font-size: 16px;
  line-height: 1;
  transition: transform 0.2s ease;
}

.dk-dropdown[open] summary::after {
  content: "−";
}

.dk-dropdown-row {
  display: block;
  padding: 0 7px 8px;
  border: 0;
}

.dk-dropdown-row .dk-chips {
  width: 100%;
  flex-wrap: wrap;
  overflow: visible;
}

.dk-dropdown-row .dk-chip {
  flex: 1 0 auto;
}

.dk-setting {
  display: grid;
  grid-template-columns: 88px 1fr 42px;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  color: rgba(236, 238, 245, 0.82);
  font-size: 11px;
}

.dk-setting output {
  color: #fff;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.dk-setting input[type="range"] {
  width: 100%;
  height: 3px;
  margin: 0;
  accent-color: #7be0ff;
  cursor: pointer;
}

@media (max-width: 640px) {
  .project-nav {
    height: 38px;
  }

  .project-nav__home {
    width: 38px;
    padding: 0;
    justify-content: center;
  }

  .project-nav__home span {
    display: none;
  }

  .project-nav__title {
    padding: 0 10px;
  }

  .dock {
    left: 10px;
    right: 10px;
    width: auto;
    max-height: 48vh;
    overflow-y: auto;
  }
}

/* Shatter's own control surface; the library GUI remains only as an internal state helper. */
.control-panel {
  position: fixed;
  z-index: 50;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  display: flex;
  width: min(360px, calc(100vw - 24px));
  max-height: calc(100vh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 18px;
  background: linear-gradient(150deg, rgba(42, 44, 52, 0.96), rgba(17, 18, 23, 0.94));
  color: #eceef5;
  font: 500 12px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), inset 0 1px rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px) saturate(1.3);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.control-panel[hidden],
.control-toggle[hidden] {
  display: none;
}

.control-panel[aria-busy="true"] {
  opacity: 0.7;
}

.control-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 4px;
}

.control-heading {
  display: grid;
  gap: 5px;
}

.control-heading strong {
  font-size: 11px;
  letter-spacing: 0.18em;
}

.control-heading span {
  color: rgba(236, 238, 245, 0.52);
  font-size: 11px;
}

.control-close,
.control-toggle,
.control-button {
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.control-close {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 18px;
  line-height: 1;
}

.control-field {
  display: grid;
  gap: 6px;
}

.control-label {
  color: rgba(236, 238, 245, 0.62);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.control-select {
  width: 100%;
  min-height: 40px;
  padding: 0 36px 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 10px;
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, #b8bdc9 50%) calc(100% - 17px) 17px / 6px 6px no-repeat,
    linear-gradient(135deg, #b8bdc9 50%, transparent 50%) calc(100% - 12px) 17px / 6px 6px no-repeat,
    rgba(255, 255, 255, 0.055);
  color: #f1f2f6;
  font: inherit;
  cursor: pointer;
}

.control-select option {
  background: #252730;
  color: #f1f2f6;
}

.control-select:focus-visible,
.control-close:focus-visible,
.control-toggle:focus-visible,
.control-button:focus-visible,
.control-range input:focus-visible {
  outline: 2px solid #7be0ff;
  outline-offset: 2px;
}

.control-settings {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.control-settings summary {
  padding: 12px 0 10px;
  color: rgba(236, 238, 245, 0.76);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  list-style: none;
}

.control-settings summary::-webkit-details-marker {
  display: none;
}

.control-settings summary::after {
  float: right;
  color: #7be0ff;
  content: "+";
  font-size: 15px;
  line-height: 10px;
}

.control-settings[open] summary::after {
  content: "−";
}

.control-range {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  color: rgba(236, 238, 245, 0.72);
  font-size: 11px;
}

.control-range input {
  width: 100%;
  margin: 0;
  accent-color: #7be0ff;
  cursor: pointer;
}

.control-range output {
  color: #fff;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.control-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.control-button {
  min-height: 40px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  transition: background 150ms ease, transform 150ms ease;
}

.control-button:hover,
.control-close:hover {
  background: rgba(255, 255, 255, 0.14);
}

.control-button:active {
  transform: scale(0.97);
}

.control-button--accent {
  border-color: transparent;
  background: linear-gradient(135deg, #ff8fb1, #ffb36b);
  color: #201018;
  font-weight: 700;
}

.control-toggle {
  position: fixed;
  z-index: 50;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  min-height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #7be0ff, #b4f1ff);
  color: #10202a;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 8px 28px rgba(26, 166, 207, 0.38), 0 2px 6px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(14px);
  transition: transform 150ms ease, box-shadow 150ms ease, filter 150ms ease;
}

.control-toggle:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 10px 32px rgba(26, 166, 207, 0.48), 0 3px 8px rgba(0, 0, 0, 0.3);
}

.control-toggle:active {
  transform: translateY(0);
}

@media (max-width: 640px) {
  .control-panel {
    top: auto;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    left: 10px;
    width: auto;
    max-height: min(72vh, 620px);
  }

  .control-toggle {
    top: auto;
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }
}
