/* ==========================================================================
   artvine — stylesheet
   Minimal, Apple-style. Light by default; dark follows the OS through
   prefers-color-scheme. System fonts only, no external requests.
   ========================================================================== */

/* ---------- Tokens ---------- */

:root {
  color-scheme: light dark;

  --bg: #ffffff;
  --bg-alt: #f5f5f7;
  --control: #e8e8ed;
  --control-hover: #dcdce1;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --hairline: #d2d2d7;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --link: #0066cc;

  --nav-bg: rgba(255, 255, 255, 0.72);
  --seg-on: #ffffff;
  --switch-on: #34c759;
  --canvas-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
  --focus-ring: 0 0 0 3px rgba(0, 113, 227, 0.6);

  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', 'Segoe UI', Roboto,
    Helvetica, Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --nav-h: 48px;
  --content: 1200px;
  --gutter: clamp(20px, 4vw, 48px);
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-alt: #161617;
    --control: #2c2c2e;
    --control-hover: #3a3a3c;
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #6e6e73;
    --hairline: #424245;
    --link: #2997ff;

    --nav-bg: rgba(22, 22, 23, 0.72);
    --seg-on: #636366;
    --canvas-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  }
}

/* ---------- Base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.47;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.no-scroll {
  overflow: hidden;
}

img,
canvas {
  display: block;
  max-width: 100%;
}

a {
  color: var(--link);
  text-decoration: none;
}

@media (hover: hover) {
  a:hover {
    text-decoration: underline;
  }
}

button,
input {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

code,
kbd {
  font-family: var(--mono);
  font-size: 0.88em;
  letter-spacing: 0;
}

code {
  padding: 0.1em 0.35em;
  border-radius: 5px;
  background: var(--control);
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ---------- Navigation ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--nav-h);
  flex: none;
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 100%;
  max-width: calc(var(--content) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 6px;
  color: var(--text);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.nav {
  display: flex;
  align-items: center;
  gap: 28px;
}

.nav a {
  border-radius: 4px;
  color: var(--text-2);
  font-size: 14px;
  transition: color 0.2s var(--ease);
}

@media (hover: hover) {
  .nav a:hover {
    color: var(--text);
    text-decoration: none;
  }
}

.nav a[aria-current='page'] {
  color: var(--text);
}

.boot-warning {
  width: calc(100% - 2 * var(--gutter));
  max-width: 720px;
  margin: 20px auto 0;
  padding: 14px 20px;
  border-radius: 14px;
  background: var(--bg-alt);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 9px 20px;
  border: 0;
  border-radius: 980px;
  background: var(--control);
  color: var(--text);
  font-size: 15px;
  font-weight: 400;
  line-height: 20px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease), opacity 0.2s var(--ease),
    transform 0.2s var(--ease);
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-ghost {
  background: var(--control);
  color: var(--text);
}

@media (hover: hover) {
  .btn:hover,
  .brand:hover {
    text-decoration: none;
  }

  .btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
  }

  .btn-ghost:hover:not(:disabled) {
    background: var(--control-hover);
  }
}

.btn-ghost[aria-pressed='true'],
.btn-ghost[aria-pressed='true']:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 14%, var(--control));
  color: var(--link);
}

.btn.lg {
  min-height: 44px;
  padding: 12px 24px;
  font-size: 17px;
}

.btn.sm {
  min-height: 28px;
  padding: 4px 12px;
  font-size: 13px;
  line-height: 20px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--control);
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.2s var(--ease), opacity 0.2s var(--ease);
}

@media (hover: hover) {
  .icon-btn:hover:not(:disabled) {
    background: var(--control-hover);
  }
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.icon-btn.sm {
  width: 28px;
  height: 28px;
}

.icon-btn svg,
.lb-nav svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn.sm svg {
  width: 14px;
  height: 14px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 0;
  border-radius: 980px;
  background: var(--control);
  color: var(--text);
  font-size: 14px;
  line-height: 20px;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

@media (hover: hover) {
  .chip:hover {
    background: var(--control-hover);
  }
}

.chip[aria-pressed='true'],
.chip[aria-pressed='true']:hover {
  background: var(--text);
  color: var(--bg);
}

.chip .count {
  font-size: 12px;
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
}

.chip-sm {
  padding: 3px 11px;
  font-size: 12px;
}

/* ---------- Gallery ---------- */

.gallery-page {
  flex: 1;
  width: 100%;
  max-width: calc(var(--content) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter) clamp(72px, 10vw, 120px);
}

.hero {
  padding: clamp(64px, 10vw, 128px) 0 clamp(56px, 8vw, 96px);
  text-align: center;
}

.hero h1 {
  margin: 0;
  font-size: clamp(48px, 8vw, 96px);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.025em;
}

.tagline {
  max-width: 860px;
  margin: 14px auto 0;
  color: var(--text-2);
  font-size: clamp(19px, 2.4vw, 28px);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.012em;
  text-wrap: balance;
}

.hero-meta {
  margin: 20px 0 0;
  color: var(--text-2);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.hero-meta:empty {
  visibility: hidden;
}

.hero-cta {
  margin-top: 32px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 0 0 48px;
}

.masonry {
  columns: 3 280px;
  column-gap: 32px;
}

.card {
  position: relative;
  display: block;
  width: 100%;
  margin: 0 0 44px;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
  break-inside: avoid;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
  transition-delay: var(--delay, 0ms);
}

.card.loaded,
.card.broken {
  opacity: 1;
  transform: none;
}

.card img {
  width: 100%;
  height: auto;
  border-radius: 18px;
  background: var(--bg-alt);
  transition: transform 0.4s var(--ease), box-shadow 0.2s var(--ease);
}

@media (hover: hover) {
  .card:hover img {
    transform: scale(1.02);
  }
}

.card:focus-visible {
  box-shadow: none;
}

.card:focus-visible img {
  box-shadow: var(--focus-ring);
}

.card.broken img {
  min-height: 160px;
}

.card-caption {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 14px;
}

.card-title {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.card-year {
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.badge {
  position: absolute;
  z-index: 1;
  top: 12px;
  left: 12px;
  padding: 3px 9px;
  border-radius: 980px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  line-height: 16px;
  letter-spacing: 0;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.empty {
  max-width: 560px;
  margin: 0 auto;
  padding: 24px 0 40px;
  text-align: center;
}

.empty h2 {
  margin: 0;
  font-size: 32px;
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.02em;
}

.empty p {
  margin: 14px 0 28px;
  color: var(--text-2);
  text-wrap: balance;
}

.site-footer {
  flex: none;
  background: var(--bg-alt);
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.33;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  max-width: calc(var(--content) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 20px var(--gutter) calc(20px + env(safe-area-inset-bottom));
}

.site-footer a {
  color: var(--text-2);
}

/* ---------- Lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  background: var(--bg);
  animation: lb-in 0.3s var(--ease);
}

@keyframes lb-in {
  from {
    opacity: 0;
  }
}

.lb-stage {
  position: relative;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 64px 104px;
}

#lb-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 12px;
  opacity: 0;
  transform: scale(0.98);
  transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
}

#lb-img.ready {
  opacity: 1;
  transform: none;
}

.lb-nav {
  position: absolute;
  top: 50%;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-top: -22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--control);
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.2s var(--ease);
}

@media (hover: hover) {
  .lb-nav:hover {
    background: var(--control-hover);
  }
}

.lb-prev {
  left: 32px;
}

.lb-next {
  right: 32px;
}

.lb-counter {
  position: absolute;
  bottom: 24px;
  left: 0;
  right: 0;
  color: var(--text-3);
  font-size: 12px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* --text-3 on black is too faint for a counter; use --text-2 in dark mode. */
@media (prefers-color-scheme: dark) {
  .lb-counter {
    color: var(--text-2);
  }
}

.lb-info {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: 72px 48px 64px 40px;
}

/* Absolute against .lightbox (not .lb-info) so it stays put and stays in the focus loop. */
.lb-close {
  position: absolute;
  z-index: 2;
  top: 16px;
  right: 16px;
}

#lb-title {
  margin: auto 0 0;
  font-size: 32px;
  font-weight: 600;
  line-height: 1.125;
  letter-spacing: -0.02em;
}

.lb-meta {
  margin: 8px 0 0;
  color: var(--text-2);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.lb-desc {
  margin: 20px 0 0;
  color: var(--text-2);
  line-height: 1.47;
}

.lb-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 20px;
}

.lb-tags:empty {
  display: none;
}

.lb-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 32px 0 auto;
}

.lb-actions .btn-primary {
  grid-column: 1 / -1;
}

/* ---------- Generator ---------- */

body.page-gen {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* Full-bleed nav on the generator: the brand lines up with the stage padding,
   the links with the panel's right padding. */
body.page-gen .nav-inner {
  max-width: none;
  padding-inline: var(--gutter) 28px;
}

.gen {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
}

.stage {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
  min-height: 0;
  padding: 32px var(--gutter) 14px;
  background: var(--bg-alt);
}

.canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#canvas {
  border-radius: 12px;
  box-shadow: var(--canvas-shadow);
}

.busy {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: calc(100% - 32px);
  padding: 10px 20px;
  border-radius: 980px;
  background: rgba(29, 29, 31, 0.85);
  color: #fff;
  font-size: 14px;
  text-align: center;
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}

.stage-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px 32px;
}

.seed-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.seed-label {
  margin-right: 2px;
  color: var(--text-2);
  font-size: 14px;
}

#seed {
  width: 132px;
  height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: 0;
  text-align: center;
  transition: box-shadow 0.2s var(--ease);
}

@media (prefers-color-scheme: dark) {
  #seed {
    background: var(--control);
  }
}

#seed:focus {
  outline: none;
  box-shadow: var(--focus-ring);
}

.stage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.variations {
  flex: none;
  width: 100%;
  max-width: 720px;
  margin-inline: auto;
}

.variations-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--text-2);
  font-size: 13px;
}

.variations-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.variations-grid {
  display: flex;
  justify-content: safe center;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 4px 8px;
  margin: -4px -4px 0;
  scrollbar-width: thin;
}

.variation {
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  cursor: pointer;
  transition: transform 0.2s var(--ease), opacity 0.2s var(--ease);
}

@media (hover: hover) {
  .variation:hover {
    transform: translateY(-2px);
  }
}

.variation canvas {
  width: auto;
  height: 104px;
  border-radius: 8px;
}

.render-info {
  flex: none;
  margin: 0;
  color: var(--text-3);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.panel {
  min-height: 0;
  overflow-y: auto;
  padding: 0 28px 40px;
  background: var(--bg);
  border-left: 1px solid var(--hairline);
  scrollbar-width: thin;
}

.panel,
.panel-section {
  scroll-margin-top: calc(var(--nav-h) + 12px);
}

.panel-section {
  padding: 28px 0;
  border-bottom: 1px solid var(--hairline);
}

.panel-section h2 {
  margin: 0 0 20px;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.panel-head h2 {
  margin: 0;
}

.row-actions {
  display: flex;
  gap: 6px;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.ctrl {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ctrl-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.3;
}

.ctrl-head output {
  color: var(--text-2);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* Sliders. generator.js sets --fill (a percentage) inline on each range input. */

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

input[type='range']::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--fill, 0%), var(--hairline) var(--fill, 0%));
}

input[type='range']::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  margin-top: -9px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
  -webkit-appearance: none;
  appearance: none;
  transition: box-shadow 0.2s var(--ease);
}

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

input[type='range']::-moz-range-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
}

input[type='range']::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25), 0 0 0 0.5px rgba(0, 0, 0, 0.06);
}

input[type='range']:focus-visible {
  box-shadow: none;
}

input[type='range']:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25), var(--focus-ring);
}

input[type='range']:focus-visible::-moz-range-thumb {
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25), var(--focus-ring);
}

/* Segmented control (generator.js builds .seg > button[role=radio]). */

.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 2px;
  border-radius: 9px;
  background: var(--control);
}

.seg:has(> :nth-child(6)) {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.seg button {
  flex: 1 1 auto;
  min-width: 0;
  padding: 5px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  line-height: 18px;
  letter-spacing: -0.005em;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

@media (hover: hover) {
  .seg button:hover:not([aria-checked='true']) {
    background: rgba(127, 127, 127, 0.12);
  }
}

.seg button[aria-checked='true'] {
  background: var(--seg-on);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.seg button:focus-visible {
  box-shadow: var(--focus-ring);
}

/* iOS-style switch (generator.js builds label.ctrl-toggle > span + input + .switch). */

.ctrl-toggle {
  position: relative;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  cursor: pointer;
}

.ctrl-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.switch {
  position: relative;
  flex: none;
  width: 44px;
  height: 26px;
  border-radius: 13px;
  background: var(--control);
  transition: background-color 0.25s var(--ease), box-shadow 0.2s var(--ease);
}

.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.25s var(--ease);
}

.ctrl-toggle input:checked + .switch {
  background: var(--switch-on);
}

.ctrl-toggle input:checked + .switch::after {
  transform: translateX(18px);
}

.ctrl-toggle input:focus-visible + .switch {
  box-shadow: var(--focus-ring);
}

.shortcuts {
  margin: 24px 0 0;
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.85;
}

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 0 5px;
  border: 1px solid var(--hairline);
  border-radius: 5px;
  background: var(--bg-alt);
  color: var(--text);
  font-family: var(--font);
  font-size: 11px;
  line-height: 16px;
  text-align: center;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 16px;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 12px 22px;
  border-radius: 980px;
  background: rgba(29, 29, 31, 0.92);
  color: #fff;
  font-size: 14px;
  line-height: 1.3;
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  opacity: 0;
  transform: translate(-50%, 16px);
  pointer-events: none;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.toast-action {
  flex: none;
  color: #2997ff;
}

@media (prefers-color-scheme: dark) {
  .toast,
  .busy {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
  }

  /* Lighter than the #2c2c2e controls it can overlap. */
  .toast {
    background: rgba(58, 58, 60, 0.92);
  }
}

/* ---------- 404 ---------- */

.notfound {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 96px var(--gutter) 120px;
  text-align: center;
}

.notfound h1 {
  margin: 0;
  font-size: clamp(40px, 6vw, 64px);
  font-weight: 600;
  line-height: 1.06;
  letter-spacing: -0.025em;
}

.notfound p {
  max-width: 520px;
  margin: 14px 0 0;
  color: var(--text-2);
  font-size: clamp(19px, 2vw, 24px);
  line-height: 1.25;
  text-wrap: balance;
}

.notfound-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 36px;
}

/* ---------- Tablet ---------- */

@media (max-width: 960px) {
  body.page-gen {
    height: auto;
    overflow: visible;
  }

  .gen {
    display: block;
  }

  body.page-gen .nav-inner {
    padding-inline: var(--gutter);
  }

  .stage {
    gap: 16px;
    padding: 24px var(--gutter) 16px;
  }

  .canvas-wrap {
    flex: none;
    height: min(calc((100vw - 2 * var(--gutter)) * 4 / 3), 64vh);
    height: min(calc((100vw - 2 * var(--gutter)) * 4 / 3), 64svh);
  }

  .panel {
    overflow: visible;
    padding: 0 var(--gutter) 48px;
    border-left: 0;
    border-top: 1px solid var(--hairline);
  }

  .lightbox {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .lb-stage {
    padding: 60px var(--gutter) 72px;
  }

  .lb-stage:has(#lb-prev[hidden]) {
    padding-bottom: 24px;
  }

  /* Phone/tablet: prev and next flank the counter under the image. */
  .lb-nav {
    top: auto;
    bottom: 14px;
    margin: 0;
  }

  .lb-prev {
    left: calc(50% - 104px);
  }

  .lb-next {
    right: calc(50% - 104px);
  }

  .lb-counter {
    bottom: 28px;
  }

  .lb-info {
    align-items: center;
    max-height: 42vh;
    max-height: 42dvh;
    padding: 8px var(--gutter) calc(28px + env(safe-area-inset-bottom));
    text-align: center;
  }

  #lb-title {
    margin-top: 0;
    font-size: 24px;
    line-height: 1.17;
  }

  .lb-desc {
    max-width: 480px;
  }

  .lb-tags {
    justify-content: center;
  }

  .lb-actions {
    width: 100%;
    max-width: 440px;
    margin-top: 24px;
  }
}

/* ---------- Phone ---------- */

@media (max-width: 734px) {
  .nav {
    gap: 22px;
  }

  .brand {
    font-size: 17px;
  }

  .hero {
    padding: 56px 0 44px;
  }

  .tagline {
    margin-top: 12px;
  }

  .hero-cta {
    margin-top: 28px;
  }

  .filters {
    margin-bottom: 32px;
  }

  .masonry {
    columns: 2;
    column-gap: 12px;
  }

  .card {
    margin-bottom: 24px;
    border-radius: 14px;
  }

  .card img {
    border-radius: 14px;
  }

  .card-caption {
    padding-top: 10px;
  }

  .card-title {
    font-size: 15px;
  }

  .card-year {
    font-size: 13px;
  }

  .badge {
    top: 8px;
    left: 8px;
  }

  .empty h2 {
    font-size: 28px;
  }

  .stage-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .seed-group {
    width: 100%;
  }

  #seed {
    flex: 1;
    width: auto;
    min-width: 0;
  }

  .stage-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .stage-actions .btn {
    padding-left: 12px;
    padding-right: 12px;
  }

  .variations-head {
    align-items: flex-start;
  }

  .variation canvas {
    height: 88px;
  }

  .variations-grid {
    justify-content: flex-start;
    margin-inline: calc(-1 * var(--gutter));
    padding-inline: var(--gutter);
    scroll-padding-inline: var(--gutter);
  }

  .stage-bar .icon-btn {
    width: 44px;
    height: 44px;
  }

  #seed {
    height: 44px;
  }

  .btn.sm {
    min-height: 36px;
    padding: 8px 14px;
  }

  .shortcuts {
    display: none;
  }

  .panel-section h2 {
    font-size: 17px;
  }
}

/* No keyboard on touch-only devices: hide the shortcut hints. */
@media (hover: none) and (pointer: coarse) {
  .shortcuts {
    display: none;
  }
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
}

/* On the generator the toast sits at the top, so it never covers the stage buttons. */
body.page-gen .toast {
  top: calc(48px + 16px + env(safe-area-inset-top));
  bottom: auto;
  transform: translate(-50%, -16px);
}

body.page-gen .toast.show {
  transform: translate(-50%, 0);
}

/* Simple generator: just the drawing and two buttons. */
body.page-gen .gen.gen-simple {
  grid-template-columns: 1fr;
}

.gen-simple .stage {
  align-items: center;
}

.gen-simple .canvas-wrap {
  width: 100%;
}

.gen-simple #canvas {
  cursor: pointer;
}

.gen-simple .stage-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.gen-hint {
  margin: 0;
  font-size: 13px;
  color: var(--text-3);
  text-align: center;
}

