@font-face {
  font-family: 'ABC Diatype';
  src: url('../fonts/ABCDiatype-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0a0a0a;
  --bg-2: #131313;
  --bg-3: #1e1e1e;
  --bg-4: #2e2e2e;
  --line: #383838;
  --line-2: #555555;
  --fg: #ffffff;
  --fg-dim: #c8c8c8;
  --fg-mute: #8a8a8a;
  --accent: #ffffff;
  --side-w: 320px;
  --r: 0px;
  --overlay-bg: rgba(0, 0, 0, 0.75);
  --overlay-bg-strong: rgba(20, 20, 20, 0.9);
  --modal-backdrop: rgba(0, 0, 0, 0.85);
}

body.light {
  --bg: #f5f5f5;
  --bg-2: #ffffff;
  --bg-3: #ececec;
  --bg-4: #dcdcdc;
  --line: #d2d2d2;
  --line-2: #a8a8a8;
  --fg: #0a0a0a;
  --fg-dim: #3a3a3a;
  --fg-mute: #6a6a6a;
  --accent: #000000;
  --overlay-bg: rgba(255, 255, 255, 0.85);
  --overlay-bg-strong: rgba(245, 245, 245, 0.92);
  --modal-backdrop: rgba(255, 255, 255, 0.88);
}

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

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: 'ABC Diatype', system-ui, -apple-system, sans-serif;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-size: 12px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.app {
  display: grid;
  grid-template-columns: 1fr var(--side-w);
  height: 100vh;
  width: 100vw;
}

/* ─── Stage ─────────────────────────────────────────────── */
.stage {
  position: relative;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 28px 28px 82px;
}

.canvas-wrap {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 0;
  box-shadow: 0 0 0 1px var(--line), 0 18px 50px -20px rgba(0,0,0,0.55);
}

/* Native animated-GIF compatibility clock. It remains rendered but outside the
   viewport so engines that freeze detached images continue advancing frames. */
.gif-clock-source {
  position: fixed;
  top: 0;
  left: -2px;
  width: 1px;
  height: 1px;
  opacity: 0.001;
  pointer-events: none;
}

.drop-overlay {
  position: absolute;
  inset: 0;
  background: var(--overlay-bg-strong);
  border: 2px dashed var(--accent);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  pointer-events: none;
}

.drop-overlay.active { display: flex; }

.drop-overlay-inner {
  text-align: center;
}

.drop-icon {
  font-size: 48px;
  font-weight: 100;
  color: var(--accent);
  margin-bottom: 12px;
  line-height: 1;
}

.drop-text {
  font-size: 14px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.stage-info {
  position: absolute;
  bottom: 12px;
  left: 12px;
  color: var(--fg-mute);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.fps-counter {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 3;
  color: var(--fg-mute);
  font-size: 11px;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* ─── Sidebar ──────────────────────────────────────────── */
.sidebar {
  background: var(--bg-2);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}

.sidebar-header h1 {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  /* Pull the bordered ? box past the 16px text grid so it sits closer to the edge. */
  margin-right: -8px;
}

#credits {
  position: relative;
  z-index: 4;
  flex: none;
  color: var(--fg);
}

#credits summary {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--fg);
  background: color-mix(in srgb, var(--bg-2) 78%, transparent);
  color: var(--fg);
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

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

#credits summary:hover,
#credits summary:focus-visible,
#credits[open] summary {
  background: var(--fg);
  color: var(--bg-2);
  outline: none;
}

.credits-card {
  position: absolute;
  z-index: 8;
  top: calc(100% + 7px);
  right: 0;
  width: 248px;
  padding: 14px;
  border: 1px solid var(--fg);
  background: color-mix(in srgb, var(--bg-2) 94%, transparent);
  box-shadow: 6px 6px 0 color-mix(in srgb, var(--fg) 12%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.credits-label {
  display: block;
  margin-bottom: 5px;
  color: var(--fg-mute);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.credits-card a {
  display: inline-block;
  color: var(--fg);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
  text-decoration: none;
}

.credits-card a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.credits-for {
  margin-top: 13px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
  color: var(--fg-dim);
  font-size: 10px;
  line-height: 1.45;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
}

.tab {
  flex: 1;
  background: none;
  border: none;
  padding: 12px;
  color: var(--fg-mute);
  cursor: pointer;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 11px;
  border-bottom: 2px solid transparent;
  transition: color 0.12s, border-color 0.12s;
}

.tab.active {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

.tab:hover:not(.active) { color: var(--fg-dim); }

.tab-pane {
  flex: 1;
  overflow-y: auto;
  display: none;
  padding: 16px;
}

.tab-pane.active { display: block; }

.tab-pane::-webkit-scrollbar { width: 6px; }
.tab-pane::-webkit-scrollbar-track { background: transparent; }
.tab-pane::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 0; }

/* ─── Groups & controls ─────────────────────────────────── */
.group {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.group:last-child { border-bottom: none; }

.label {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-mute);
  margin-bottom: 8px;
}

.label-mini {
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--fg-mute);
  margin-bottom: 6px;
}

.row {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Dropzone */
.dropzone {
  border: 1px dashed var(--line-2);
  border-radius: var(--r);
  padding: 18px 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  margin-bottom: 8px;
}

.dropzone:hover {
  border-color: var(--fg-dim);
  background: var(--bg-3);
}

.dropzone.over {
  border-color: var(--accent);
  background: var(--bg-3);
}

.dropzone-label {
  font-size: 12px;
  margin-bottom: 4px;
}

.dropzone-hint {
  font-size: 10px;
  color: var(--fg-mute);
}

.source-row { gap: 6px; }
.source-row .btn-small { flex: 1; }

/* Segmented control */
.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  background: var(--bg-3);
  padding: 2px;
  border-radius: var(--r);
}

.seg button {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  padding: 6px 8px;
  color: var(--fg-mute);
  cursor: pointer;
  border-radius: 0;
  font-size: 11px;
  letter-spacing: 0.02em;
  transition: background 0.1s, color 0.1s;
}

.seg button:hover:not(.active) { color: var(--fg-dim); }

.seg button.active {
  background: var(--bg-4);
  color: var(--fg);
}

/* Sliders */
.slider-row {
  margin-bottom: 10px;
}
.slider-row:last-child { margin-bottom: 0; }

.slider-row label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
  color: var(--fg-dim);
  margin-bottom: 4px;
}

.slider-row label .val {
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

input[type=range] {
  width: 100%;
  height: 18px;
  background: transparent;
  -webkit-appearance: none;
  cursor: pointer;
}

input[type=range]::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--line-2);
  border-radius: 0;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: var(--fg);
  border-radius: 50%;
  margin-top: -5px;
  cursor: pointer;
}

input[type=range]::-moz-range-track {
  height: 2px;
  background: var(--line-2);
  border-radius: 0;
}

input[type=range]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--fg);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

/* Toggles */
.toggle-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  font-size: 11px;
  color: var(--fg-dim);
}

.toggle input {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: 0;
  cursor: pointer;
  position: relative;
}

.toggle input:checked {
  background: var(--fg);
  border-color: var(--fg);
}

.toggle input:checked::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0;
  width: 5px;
  height: 9px;
  border: solid var(--bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Buttons */
.btn-primary {
  width: 100%;
  background: var(--bg-3);
  color: var(--fg);
  border: 1px solid var(--line-2);
  padding: 9px;
  border-radius: var(--r);
  cursor: pointer;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: background 0.12s, border-color 0.12s;
  margin-bottom: 6px;
}

.btn-primary:last-child { margin-bottom: 0; }

.btn-primary:hover {
  background: var(--bg-4);
  border-color: var(--fg-mute);
}

.btn-primary:active { background: var(--line-2); }

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary.recording {
  background: var(--fg);
  border-color: var(--fg);
  color: var(--bg);
}

.btn-small {
  background: var(--bg-3);
  color: var(--fg-dim);
  border: 1px solid var(--line-2);
  padding: 6px 10px;
  border-radius: var(--r);
  cursor: pointer;
  font-size: 11px;
  transition: background 0.1s, color 0.1s;
}

.btn-small:hover { background: var(--bg-4); color: var(--fg); }
.btn-small.active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.select {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  padding: 7px;
  border-radius: var(--r);
  color: var(--fg);
  cursor: pointer;
}

.custom-res {
  margin-top: 6px;
}

.custom-res input[type=number] {
  flex: 1;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  padding: 6px;
  border-radius: var(--r);
  color: var(--fg);
}

.hint {
  font-size: 10px;
  color: var(--fg-mute);
  line-height: 1.5;
  margin-top: 6px;
}

.export-fps-row {
  margin-bottom: 12px;
}

/* ─── Variations modal ─────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--modal-backdrop);
  cursor: pointer;
}

.modal-inner {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: 0;
  padding: 20px;
  max-width: min(900px, 92vw);
  max-height: 92vh;
  width: 900px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-header h2 {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-mute);
  font-weight: 500;
}

.modal-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.modal-tile {
  aspect-ratio: 1;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--r);
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: border-color 0.12s, transform 0.12s;
}

.modal-tile:hover {
  border-color: var(--fg);
  transform: scale(1.01);
}

.modal-tile canvas {
  max-width: 100%;
  max-height: 100%;
  display: block;
  box-shadow: none;
}

.modal-tile-meta {
  position: absolute;
  bottom: 4px;
  left: 6px;
  font-size: 9px;
  color: var(--fg-mute);
  background: rgba(0,0,0,0.6);
  padding: 1px 5px;
  border-radius: 0;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  transition: opacity 0.12s;
}

.modal-tile:hover .modal-tile-meta { opacity: 1; }

/* ─── Toggle list (Invert / Outline / Gradient) ───────── */
.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chip {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: var(--bg-3);
  color: var(--fg-dim);
  border: 1px solid var(--line);
  padding: 11px 14px;
  border-radius: var(--r);
  cursor: pointer;
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-align: left;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.chip-icon {
  flex-shrink: 0;
  display: block;
}
.chip:hover {
  background: var(--bg-4);
  color: var(--fg);
}
.chip.active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}
.chip.hidden { display: none; }

/* ─── Strips presets + controls ───────────────────────── */
.strips-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.strips-presets button {
  background: var(--bg-3);
  color: var(--fg);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  padding: 12px 10px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: -0.02em;
  text-align: left;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.strips-presets button:hover {
  border-color: var(--fg);
  background: var(--bg-4);
}
.strips-presets button.active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.select-inline {
  padding: 5px 7px;
  font-size: 11px;
  margin-top: 2px;
}

.slider-row.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.slider-row.toggle-row label {
  margin-bottom: 0;
  flex: 1;
}

.mini-toggle {
  width: 32px;
  height: 18px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: 0;
  padding: 0;
  cursor: pointer;
  position: relative;
  transition: background 0.12s, border-color 0.12s;
}
.mini-toggle span {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 14px;
  height: 14px;
  background: var(--fg-mute);
  border-radius: 50%;
  transition: transform 0.14s, background 0.14s;
}
.mini-toggle[aria-pressed="true"] {
  background: var(--fg);
  border-color: var(--fg);
}
.mini-toggle[aria-pressed="true"] span {
  background: var(--bg);
  transform: translateX(14px);
}

/* ─── Tooltips (JS-driven, position: fixed avoids scroll clipping) ── */
.tooltip {
  position: fixed;
  background: var(--fg);
  color: var(--bg);
  padding: 7px 9px;
  border-radius: 0;
  border: 1px solid var(--line-2);
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: 0.01em;
  text-transform: none;
  font-family: inherit;
  max-width: 240px;
  pointer-events: none;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.12s, transform 0.12s;
}
.tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}
[data-tip] {
  cursor: help;
}
[data-tip] input {
  cursor: pointer;
}

/* ─── Source preview ────────────────────────────────── */
.source-preview-wrap {
  margin-top: 10px;
}
.source-preview {
  position: relative;
  width: 100%;
  height: 130px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.source-preview canvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  filter: grayscale(1);
  border-radius: 0;
  box-shadow: none;
}
.source-preview-empty {
  color: var(--fg-mute);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.source-preview canvas + .source-preview-empty,
.source-preview.has-content .source-preview-empty {
  display: none;
}

/* ─── Rect editor overlay ──────────────────────────────── */
.rect-editor {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
}
.rect-editor.active {
  display: block;
  pointer-events: auto;
}
.rect-handle {
  position: absolute;
  border: 1px dashed var(--fg);
  background: var(--bg-3);
  cursor: move;
  box-sizing: border-box;
  transition: background 0.1s, border-color 0.1s;
}
.rect-handle:hover {
  border-style: solid;
  background: var(--bg-4);
}
.rect-handle .grip {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 10px;
  height: 10px;
  background: var(--fg);
  cursor: nwse-resize;
  border-radius: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}

/* ─── Floating artboard tools ─────────────────────────── */
.artboard-island {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  padding: 4px;
  background: var(--overlay-bg);
  color: var(--fg);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.28);
  z-index: 40;
}

.island-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--fg-dim);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, opacity 0.12s;
}

.island-btn:hover,
.island-btn:focus-visible {
  color: var(--fg);
  background: var(--bg-4);
  outline: none;
}

.island-btn.active {
  color: var(--bg);
  background: var(--fg);
}

.island-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  background: transparent;
}

.island-btn > svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.island-divider {
  width: 1px;
  height: 22px;
  margin: 0 3px;
  background: var(--line-2);
  opacity: 0.75;
}

.island-menu-wrap {
  position: relative;
}

.pattern-trigger {
  width: 48px;
  gap: 3px;
}

.pattern-current-icon {
  display: inline-flex;
  width: 23px;
  height: 23px;
}

.pattern-current-icon svg,
.pattern-diagram svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.island-btn .island-chevron {
  width: 10px;
  height: 10px;
  stroke-width: 1.5;
}

.pattern-popover {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 12px);
  width: 326px;
  transform: translateX(-50%);
  padding: 10px;
  background: var(--overlay-bg-strong);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  box-shadow: 0 18px 44px rgba(0,0,0,0.38);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.pattern-popover[hidden] { display: none; }

.pattern-popover-title {
  padding: 2px 3px 9px;
  color: var(--fg-mute);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pattern-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
}

.pattern-option {
  min-width: 0;
  height: 60px;
  padding: 5px 3px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--bg-3);
  color: var(--fg-mute);
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}

.pattern-option:hover,
.pattern-option:focus-visible {
  color: var(--fg);
  border-color: var(--line-2);
  outline: none;
}

.pattern-option.active {
  color: var(--fg);
  border-color: var(--fg);
  background: var(--bg-4);
}

.pattern-diagram {
  display: block;
  width: 39px;
  height: 29px;
}

.pattern-label {
  overflow: hidden;
  max-width: 100%;
  color: inherit;
  font-size: 8px;
  letter-spacing: 0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Sticky action bar at the bottom of the sidebar ── */
.sticky-actions {
  border-top: 1px solid var(--line);
  background: var(--bg-2);
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.sticky-actions .btn-primary {
  flex: 1;
  margin-bottom: 0;
}

.btn-variations {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn-variations .dice {
  transition: transform 0.2s;
}
.btn-variations:hover .dice {
  transform: rotate(-12deg);
}

/* Advanced sections collapsed behind a static +/– disclosure button. */
.disclosure {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 8px 10px;
  margin-top: 12px;
  cursor: pointer;
  color: var(--fg-mute);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: color 0.1s, border-color 0.1s;
}
.disclosure:hover { color: var(--fg-dim); border-color: var(--line-2); }
.disclosure.open { color: var(--fg-dim); }
.disclosure-mark { color: var(--fg-mute); font-size: 13px; }
.disclosure-body { margin-top: 12px; }

/* ─── Mobile fallback ──────────────────────────────────── */
@media (max-width: 720px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 40vh 1fr;
  }
  .sidebar {
    border-left: none;
    border-top: 1px solid var(--line);
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .stage {
    min-height: 0;
    padding: 14px 14px 66px;
  }
  .artboard-island {
    bottom: 10px;
  }
  .pattern-popover {
    position: fixed;
    left: 50%;
    bottom: calc(60vh + 58px);
    width: min(326px, calc(100vw - 20px));
  }
  .pattern-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  /* Source preview can be shorter on mobile to free room for controls. */
  .source-preview {
    height: 140px;
  }
}
