/* ==========================================================================
   SuperPrint — design system
   Paper-warm light theme, ink-dark night theme. No external assets.
   ========================================================================== */

:root {
  --paper: #f6f2ea;
  --surface: #fffdf8;
  --surface-2: #f0ebe0;
  --ink: #1c1915;
  --ink-soft: #4c453b;
  --muted: #7b7365;
  --line: #e3dbcc;
  --line-strong: #cfc4ae;
  --accent: #b8492c;
  --accent-soft: #f4e2db;
  --accent-ink: #ffffff;
  --teal: #2c6b66;
  --teal-soft: #dfeceb;

  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(40, 30, 15, 0.06), 0 2px 6px rgba(40, 30, 15, 0.05);
  --shadow: 0 2px 6px rgba(40, 30, 15, 0.07), 0 12px 28px -10px rgba(40, 30, 15, 0.18);
  --shadow-lg: 0 4px 10px rgba(40, 30, 15, 0.08), 0 30px 60px -22px rgba(40, 30, 15, 0.3);

  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

  --wrap: 1180px;
  --nav-h: 62px;
}

html[data-theme='dark'] {
  --paper: #15130f;
  --surface: #1e1b16;
  --surface-2: #262219;
  --ink: #f3ede2;
  --ink-soft: #ddd4c5;
  --muted: #9d9484;
  --line: #322c22;
  --line-strong: #47402f;
  --accent: #e08a6c;
  --accent-soft: #38261f;
  --accent-ink: #1b1512;
  --teal: #6fb8b1;
  --teal-soft: #1d2f2d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.4), 0 14px 30px -12px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 4px 10px rgba(0, 0, 0, 0.45), 0 30px 60px -22px rgba(0, 0, 0, 0.8);
}

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

/*
 * The `hidden` attribute only sets `display: none` from the user agent
 * stylesheet, so any class of ours that sets `display` silently outranks it and
 * the element stays on screen. Every component that ever hides itself would
 * otherwise need its own `[hidden]` rule, and the failure is invisible until
 * someone notices a control that should not be there.
 */
[hidden] { display: none !important; }

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
}

h1 { font-size: clamp(2.1rem, 5.2vw, 3.5rem); }
h2 { font-size: clamp(1.5rem, 3.2vw, 2.15rem); }
h3 { font-size: 1.15rem; }

p { margin: 0 0 1em; }
a { color: inherit; }

img, svg { max-width: 100%; }

:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 22px; }
.wrap-wide { max-width: 1420px; }

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 200;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  transition: top 0.18s;
}
.skip-link:focus { top: 12px; }

.eyebrow {
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.85em;
}

.lede { font-size: clamp(1.02rem, 1.6vw, 1.18rem); color: var(--ink-soft); max-width: 62ch; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.mono { font-family: var(--mono); font-size: 0.9em; }

/* ------------------------------------------------------------------ nav -- */

.nav {
  position: sticky;
  top: 0;
  z-index: 60;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}

.nav-inner {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--serif);
  font-size: 1.24rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  text-decoration: none;
  margin-right: auto;
}
.brand svg { display: block; }
.brand b { font-weight: 600; }
.brand span { color: var(--accent); }

/*
 * Header mark — same bloom as the favicon, but themed. Pale petals are filled
 * with the page surface rather than left hollow so they occlude the petals
 * behind them, exactly as in the icon.
 */
.mark path {
  fill: var(--surface);
  stroke: currentColor;
  stroke-width: 3;
  stroke-linejoin: round;
}
.mark path.is-filled { fill: var(--accent); }
.mark circle { fill: currentColor; stroke: none; }
.mark circle.is-eye { fill: var(--surface); }

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

.nav-links a {
  padding: 8px 13px;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.925rem;
  font-weight: 520;
  color: var(--ink-soft);
  transition: background 0.15s, color 0.15s;
}
.nav-links a:hover { background: var(--surface-2); color: var(--ink); }
.nav-links a[aria-current='page'] { background: var(--ink); color: var(--paper); }

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

.nav-toggle { display: none; }

@media (max-width: 820px) {
  .nav-toggle { display: inline-flex; }
  .nav-links {
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 10px 16px 16px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
  }
  .nav-links a { padding: 12px 14px; border-radius: var(--radius-sm); }
}

/* -------------------------------------------------------------- buttons -- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 17px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.925rem;
  font-weight: 560;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn svg { flex: none; }

.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }

.btn-dark { background: var(--ink); color: var(--paper); }
.btn-dark:hover { background: color-mix(in srgb, var(--ink) 85%, var(--accent)); }

.btn-outline { border-color: var(--line-strong); background: transparent; }
.btn-outline:hover { background: var(--surface); border-color: var(--ink); }

.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn-lg { padding: 14px 26px; font-size: 1.02rem; }
.btn-sm { padding: 7px 13px; font-size: 0.86rem; }

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
}
.btn-icon:hover { background: var(--surface-2); color: var(--ink); }

.btn[disabled] { opacity: 0.5; pointer-events: none; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------------------------------------------------------------- cards -- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 560;
  letter-spacing: 0.02em;
}

/* ----------------------------------------------------------------- hero -- */

.hero { padding: clamp(48px, 8vw, 92px) 0 clamp(36px, 5vw, 60px); }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.92fr);
  gap: clamp(28px, 5vw, 72px);
  align-items: center;
}

.hero h1 { margin-bottom: 0.35em; }
.hero h1 em { font-style: italic; color: var(--accent); }

.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 26px;
  margin-top: 36px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}
.hero-stat strong {
  display: block;
  font-family: var(--serif);
  font-size: 1.5rem;
  line-height: 1.1;
}
.hero-stat span { font-size: 0.83rem; color: var(--muted); }

.hero-stack { position: relative; aspect-ratio: 1 / 1.05; }
.hero-stack .sheet {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.hero-stack .sheet:nth-child(1) { transform: rotate(-7deg) translate(-7%, 2%) scale(0.9); opacity: 0.92; }
.hero-stack .sheet:nth-child(2) { transform: rotate(5deg) translate(7%, -2%) scale(0.93); opacity: 0.96; }
.hero-stack .sheet:nth-child(3) { transform: rotate(-1.2deg); }
.hero-stack .sheet svg { display: block; width: 100%; height: 100%; }

@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
  /* Needs an explicit width: the auto side margins stop the grid item from
     stretching, and every sheet inside is absolutely positioned, so
     shrink-to-fit would collapse it to nothing. */
  .hero-stack { width: 100%; max-width: 440px; margin: 8px auto 0; }

  /* The stack's sheets are rotated out past their box by design; contain that
     here so it cannot become a horizontal page scroll. */
  .hero { overflow-x: hidden; overflow-x: clip; }
}

/* -------------------------------------------------------------- section -- */

.section { padding: clamp(44px, 6.5vw, 80px) 0; }
.section-alt { background: var(--surface); border-block: 1px solid var(--line); }

.section-head { max-width: 64ch; margin-bottom: 34px; }
.section-head.center { margin-inline: auto; text-align: center; }

.grid { display: grid; gap: 20px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

/* ------------------------------------------------------- design tiles --- */

.tile {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-strong); }

.tile-art {
  position: relative;
  display: block;
  background: #fff;
  border-bottom: 1px solid var(--line);
  aspect-ratio: 17 / 22;
  overflow: hidden;
}
.tile-art svg { display: block; width: 100%; height: 100%; }
.tile-art.square { aspect-ratio: 1 / 1; }
.tile-art.landscape { aspect-ratio: 22 / 17; }

.tile-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.tile-title { font-family: var(--serif); font-size: 1.06rem; font-weight: 600; }
.tile-seed { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); word-break: break-all; }
.tile-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 4px; }
.tile-actions .btn { flex: 1; }

.tile-skeleton { background: var(--surface-2); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* ------------------------------------------------------------- studio --- */

.studio {
  display: grid;
  grid-template-columns: 336px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  padding: 28px 0 64px;
}


.studio-panel {
  /* The full-bleed divider mirrors this, so they must not drift apart. */
  --panel-pad: 20px;
  position: sticky;
  top: calc(var(--nav-h) + 18px);
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--panel-pad);
  box-shadow: var(--shadow-sm);
  max-height: calc(100vh - var(--nav-h) - 36px);
  overflow-y: auto;
}

.field { margin-bottom: 20px; }
.field:last-child { margin-bottom: 0; }

.field-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
  font-size: 0.78rem;
  font-weight: 640;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.field-label b { font-size: 0.84rem; letter-spacing: 0; text-transform: none; color: var(--ink); font-weight: 560; }

.style-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }

.style-opt {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 560;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s;
}
.style-opt { overflow-wrap: anywhere; }
.style-opt:hover { border-color: var(--line-strong); }
.style-opt[aria-pressed='true'] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.seg { display: flex; gap: 5px; flex-wrap: wrap; }
.seg button {
  flex: 1 1 auto;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 550;
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s, color 0.14s;
}
.seg button:hover { border-color: var(--line-strong); color: var(--ink); }
.seg button[aria-pressed='true'] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.seed-row { display: flex; gap: 8px; }

.input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.86rem;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

input[type='range'] {
  width: 100%;
  height: 26px;
  margin: 0;
  background: transparent;
  accent-color: var(--accent);
  cursor: pointer;
}

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 0.9rem; }
.switch input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }

.panel-divider { height: 1px; background: var(--line); margin: 20px calc(var(--panel-pad) * -1); }

/* stage */

.studio-stage { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.stage-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.stage-bar .spacer { margin-left: auto; }

.sheet-frame {
  position: relative;
  display: grid;
  place-items: center;
  padding: clamp(14px, 3vw, 34px);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  min-height: 320px;
}

/* Expand-to-full-screen affordances; only shown in the compact layout. */
.zoom-hint,
.zoom-close { display: none; }

.zoom-hint {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 5px 6px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line);
  color: var(--muted);
  line-height: 0;
  pointer-events: none;
}

.zoom-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.sheet {
  position: relative;
  background: #fff;
  box-shadow: var(--shadow-lg);
  border-radius: 3px;
  overflow: hidden;
  max-width: 100%;
}
.sheet svg { display: block; width: 100%; height: 100%; }
.sheet.is-busy { opacity: 0.45; }

/*
 * The studio preview is sized entirely in CSS so media queries own the height
 * budget; studio.js only publishes the paper's width/height ratio as
 * --sheet-num. Scoped to .sheet-frame so the hero's absolutely-positioned
 * sheets keep their own sizing.
 */
.sheet-frame .sheet {
  --sheet-h: min(74vh, 880px);
  --sheet-num: 0.773;
  aspect-ratio: var(--sheet-num);
  width: min(100%, calc(var(--sheet-h) * var(--sheet-num)));
}

/*
 * Below the two-column breakpoint the preview is pinned to the top of the
 * viewport and the controls scroll underneath it. Stacking them instead would
 * mean scrolling up to see the effect of every setting you change, which is
 * the whole interaction on this page.
 */
@media (max-width: 1000px) {
  .studio {
    display: flex;
    flex-direction: column;
    /* The grid layout's `start` would leave the panel sized to its content,
       which overflows narrow phones. */
    align-items: stretch;
    gap: 14px;
    padding: 14px 0 52px;
  }

  .studio-stage {
    order: -1;
    position: sticky;
    top: var(--nav-h);
    z-index: 20;
    gap: 10px;
    /* Padding is inside the pinned box, so it holds the bar clear of the
       translucent nav instead of letting it graze the underside. */
    padding-top: 8px;
    padding-bottom: 10px;
    background: var(--paper);
  }
  /* Fade the controls out from under the pinned preview. */
  .studio-stage::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 16px;
    transform: translateY(100%);
    background: linear-gradient(var(--paper), transparent);
    pointer-events: none;
  }

  .studio-panel {
    --panel-pad: 16px;
    position: static;
    max-height: none;
    overflow: visible;
  }

  .sheet-frame {
    padding: 10px;
    min-height: 0;
    border-radius: var(--radius);
  }
  .sheet-frame .sheet {
    --sheet-h: 40vh;
    --sheet-h: 40dvh;
  }

  .studio-shortcuts { display: none; }

  /*
   * Tap the preview to fill the screen with it; tap anywhere to come back.
   * The pinned preview has to be small enough to leave room for the controls,
   * so this is how you actually inspect a design's detail on a phone.
   */
  .sheet-frame { cursor: zoom-in; }
  .zoom-hint { display: block; }

  body.is-zoomed { overflow: hidden; }

  /*
   * The stage is a sticky, z-indexed element, so it forms a stacking context
   * and the overlay's own z-index cannot escape it — without this the
   * full-screen preview is painted beneath the navigation bar.
   */
  body.is-zoomed .studio-stage { z-index: 200; }

  body.is-zoomed .sheet-frame {
    position: fixed;
    inset: 0;
    z-index: 100;
    padding: 10px;
    border: 0;
    border-radius: 0;
    background: var(--paper);
    cursor: zoom-out;
    animation: zoom-open 0.18s ease-out;
  }
  body.is-zoomed .sheet-frame .sheet {
    --sheet-h: calc(100vh - 20px);
    --sheet-h: calc(100dvh - 20px);
  }
  body.is-zoomed .zoom-hint { display: none; }
  body.is-zoomed .zoom-close { display: grid; }

  @keyframes zoom-open {
    from { opacity: 0; transform: scale(0.97); }
    to { opacity: 1; transform: none; }
  }

  /* Seed + detail, relocated into the pinned block by studio.js. */
  .quick-controls {
    display: grid;
    gap: 8px;
    padding-top: 2px;
  }
  .quick-controls .field { margin-bottom: 0; }
  .quick-controls .field-label { margin-bottom: 6px; }
  .quick-controls #seed-help { display: none; }
  .quick-controls input[type='range'] { height: 32px; }

  /*
   * Anything scrolled into view — a tabbed-to control, a focused field — must
   * clear the pinned preview, or the browser parks it underneath where it
   * cannot be clicked. --pinned-h is measured by studio.js.
   */
  .studio-panel button,
  .studio-panel input,
  .studio-panel label,
  .studio-panel .field { scroll-margin-top: calc(var(--pinned-h, 0px) + 12px); }
}

/* --------------------------------------------------------------- steps -- */

.steps { counter-reset: step; display: grid; gap: 22px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.step { position: relative; padding-top: 46px; }
.step::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  top: 0;
  left: 0;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
}
.step h3 { margin-bottom: 0.35em; }
.step p { color: var(--ink-soft); font-size: 0.95rem; margin: 0; }

/* ---------------------------------------------------------------- faq --- */

.faq { max-width: 760px; margin: 0 auto; }
.faq details {
  border-bottom: 1px solid var(--line);
  padding: 4px 0;
}
.faq summary {
  padding: 16px 0;
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: '+';
  font-family: var(--sans);
  font-size: 1.4rem;
  color: var(--accent);
  transition: transform 0.2s;
}
.faq details[open] summary::after { transform: rotate(45deg); }
.faq p { color: var(--ink-soft); margin: 0 0 16px; }

/* --------------------------------------------------------------- misc --- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 14px 0 26px;
}

.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filter {
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.87rem;
  font-weight: 540;
  cursor: pointer;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
}
.filter:hover { border-color: var(--line-strong); color: var(--ink); }
.filter[aria-pressed='true'] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.empty {
  text-align: center;
  padding: 72px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--muted);
}
.empty h3 { color: var(--ink); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  z-index: 120;
  padding: 11px 20px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.9rem;
  font-weight: 520;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.callout {
  display: flex;
  gap: 14px;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--teal-soft);
  border: 1px solid color-mix(in srgb, var(--teal) 24%, transparent);
  font-size: 0.94rem;
}
.callout strong { display: block; margin-bottom: 2px; }

/* ------------------------------------------------------------- dialog --- */

.support-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}
.support-dialog::backdrop { background: rgba(20, 15, 8, 0.45); }
.support-dialog h2 { font-size: 1.4rem; margin-bottom: 0.45em; }
.support-dialog p { color: var(--ink-soft); font-size: 0.94rem; }
.support-dialog p:last-of-type { margin-bottom: 0; }
.support-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.support-actions .btn { flex: 1 1 auto; }

.push-end { margin-left: auto; }

/* -------------------------------------------------------------- mobile -- */

@media (max-width: 720px) {
  .wrap { padding: 0 16px; }

  /* A phone has to fund the pinned preview and a usable control window out of
     the same screen, so the preview takes a smaller share here. */
  .sheet-frame .sheet {
    --sheet-h: 34vh;
    --sheet-h: 34dvh;
  }

  /* Portrait and short means the on-screen keyboard is up: give the preview
     less so it and the seed field share what is left. */
  @media (max-height: 620px) {
    .sheet-frame .sheet {
      --sheet-h: 22vh;
      --sheet-h: 22dvh;
    }
    .studio-stage { gap: 6px; padding-top: 4px; padding-bottom: 6px; }
  }

  /* Keep the live region for screen readers, but stop it costing a line. */
  #sheet-meta {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  /*
   * Fit the six actions on one row: the icon carries the meaning for
   * surprise/save/link, while PNG and SVG need their labels to be told apart
   * (both would otherwise be a bare download arrow).
   */
  .stage-bar { gap: 6px; }
  .stage-bar .spacer { display: none; }
  .stage-bar .btn { padding: 9px; font-size: 0.84rem; }
  #act-surprise span,
  #act-save span,
  #act-link span { display: none; }
  #act-png svg,
  #act-svg svg { display: none; }
  #act-surprise,
  #act-save,
  #act-link { min-width: 42px; justify-content: center; }

  /* One scrollable row of chips beats six stacked rows of them. */
  .toolbar { flex-direction: column; align-items: stretch; }
  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 4px;
    min-width: 0;
    max-width: 100%;
  }
  .filters::-webkit-scrollbar { display: none; }
  .filter { flex: none; }
  .push-end { margin-left: 0; }

  /* iOS zooms the page when a focused field is under 16px. */
  .input { font-size: 16px; }

  .hero-stats { gap: 18px; }
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 12px; }
}

/* Touch targets: 44px is the smallest comfortable tap area. */
@media (pointer: coarse) {
  .btn { min-height: 42px; }
  .btn-icon { width: 44px; height: 44px; }
  .seg button,
  .style-opt { min-height: 44px; }
  .filter { min-height: 40px; }
  .nav-links a { min-height: 44px; display: flex; align-items: center; }
  input[type='range'] { height: 38px; }
  .switch input { width: 20px; height: 20px; }
}


.site-footer {
  border-top: 1px solid var(--line);
  padding: 40px 0 56px;
  margin-top: 20px;
  font-size: 0.9rem;
  color: var(--muted);
}
.footer-inner { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; justify-content: space-between; }
.footer-links { display: flex; flex-wrap: wrap; gap: 18px; }
.footer-links a { text-decoration: none; }
.footer-links a:hover { color: var(--ink); text-decoration: underline; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

#print-root { display: none; }

/*
 * Short viewports (landscape phones) have no vertical room to stack a pinned
 * preview above the controls — but they have width to spare, so put the two
 * side by side instead. Both columns stay in view, the panel scrolls itself.
 */
@media (max-width: 1000px) and (min-width: 620px) and (max-height: 560px) {
  .studio {
    display: grid;
    grid-template-columns: minmax(0, 262px) minmax(0, 1fr);
    gap: 12px;
    padding: 10px 0 16px;
    align-items: start;
  }
  /* Two columns in a panel this narrow would break style names mid-word. */
  .style-list { grid-template-columns: minmax(0, 1fr); }
  .studio-panel {
    position: sticky;
    top: calc(var(--nav-h) + 8px);
    max-height: calc(100vh - var(--nav-h) - 24px);
    max-height: calc(100dvh - var(--nav-h) - 24px);
    overflow-y: auto;
  }
  .studio-stage {
    order: 0;
    position: sticky;
    top: calc(var(--nav-h) + 8px);
    padding-bottom: 0;
    background: none;
  }
  .studio-stage::after { display: none; }
  .sheet-frame .sheet {
    --sheet-h: 58vh;
    --sheet-h: 58dvh;
  }
}

/* ---------------------------------------------------------------- pwa --- */

/*
 * The bar offering a newly downloaded version. It has buttons in it, so it
 * cannot be a toast: those are pointer-events: none so they never swallow a
 * click meant for the page beneath.
 */
.update-bar {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 130;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 20px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.9rem;
  font-weight: 520;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, 20px);
  transition: opacity 0.2s, transform 0.2s;
}
.update-bar.show { opacity: 1; transform: translate(-50%, 0); }
.update-bar .btn {
  padding: 6px 14px;
  background: var(--paper);
  color: var(--ink);
  border-color: transparent;
}
.update-bar .btn-ghost {
  background: transparent;
  color: var(--paper);
  opacity: 0.75;
}
.update-bar .btn-ghost:hover { opacity: 1; }

@media (max-width: 420px) {
  .update-bar {
    left: 12px;
    right: 12px;
    transform: translateY(20px);
    justify-content: space-between;
  }
  .update-bar.show { transform: translateY(0); }
}

/* The install button only exists when a browser says the app can be installed. */
.install-btn { white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  .update-bar { transition: none; }
}

/* ====================================================================== */
/* Colouring                                                              */
/*                                                                        */
/* A mode rather than a page: no navigation, no footer, no scrolling — the */
/* sheet takes whatever height is left and the controls sit at the bottom, */
/* where a thumb already is. Everything here is sized for one-handed use   */
/* on a phone and simply looks generous on a desktop.                      */
/* ====================================================================== */

body.colouring { overflow: hidden; overscroll-behavior: none; }

/* Toasts live at the bottom of the window, which on this page is the palette
   and the tools. Above the sheet is the only clear band — so it moves up, and
   its entrance flips with it so it still arrives from off-screen. */
body.colouring .toast {
  top: calc(env(safe-area-inset-top) + 62px);
  bottom: auto;
  transform: translate(-50%, -20px);
}

.colour-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

.colour-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.colour-bar-actions { display: flex; gap: 8px; margin-left: auto; }

.colour-title {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.86rem;
  color: var(--muted);
}

.colour-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 10px;
  overflow: hidden;
  background: var(--surface-2);
}

/*
 * The sheet is two layers in one box: the artwork, with the paint canvas
 * stretched over it. Being positioned would otherwise put the paint layer on
 * top of the artwork, hence the z-index on the lines.
 *
 * Its width is set by color.js rather than here. Fitting a fixed ratio inside a
 * box with `max-width` and `max-height` needs both to resolve, and the height
 * percentage has no definite container to resolve against inside a flex column
 * — which silently does nothing and lets the sheet run off the bottom of a
 * landscape window. One measurement is worth more than the trick.
 */
.colour-paper {
  position: relative;
  line-height: 0;
  background: #fff;
  box-shadow: var(--shadow-lg);
  transform-origin: center;
  /* The browser's own pan and zoom would fight every gesture on this page. */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  /* Ignored by touch, and the right shape for every tool here: all three act on
     a point, and the brush's own size is shown by the ring. */
  cursor: crosshair;
}
.colour-paper canvas,
.colour-paper img { display: block; }
#colour-lines {
  position: relative;
  z-index: 1;
  width: 100%;
  height: auto;
  -webkit-user-drag: none;
}
#colour-paint { position: absolute; inset: 0; width: 100%; height: 100%; }

/*
 * A ring showing where the brush is and how big it is, for pointers precise
 * enough to aim with. It lives inside the sheet so the page's own transform
 * scales it, which is what keeps it honest at every zoom level. A finger covers
 * it entirely, so touch never sees it.
 */
.brush-cursor {
  position: absolute;
  z-index: 2;
  aspect-ratio: 1;
  border: 1px solid rgba(0, 0, 0, 0.55);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.75) inset;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.colour-hint {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  margin: 0;
  padding: 7px 14px;
  max-width: calc(100% - 24px);
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 82%, transparent);
  color: var(--paper);
  font-size: 0.8rem;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.3s;
}
.colour-hint.is-gone { opacity: 0; }

.colour-reset { position: absolute; top: 10px; right: 10px; background: var(--surface); }

.colour-tools {
  display: grid;
  gap: 10px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
/*
 * The bar spans the window, but its contents are held to a readable width and
 * centred: on a wide monitor a full-width row leaves the palette at one end of
 * the screen and Clear at the other, and the eye has to travel the whole way.
 */
.colour-tools > * {
  width: 100%;
  max-width: 1180px;
  margin-inline: auto;
}

/*
 * Two rows of swatches that scroll sideways, rather than a grid that wraps: a
 * wrapping grid of twenty-six colours is five rows tall on a phone and eats the
 * sheet. Light tone above its own deep tone keeps a family in one column.
 */
.swatches {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(2, auto);
  /* Centred where the whole palette fits, which is most desktops; where it does
     not, it starts at the left edge and scrolls. */
  justify-content: safe center;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 3px 2px;
  scrollbar-width: thin;
}

.swatch {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--swatch);
  cursor: pointer;
  transition: transform 0.12s;
}
.swatch:hover { transform: scale(1.08); }
/* A ring rather than a tick: a tick has to be legible on white and on near
   black, and a ring in the page's own ink is legible on both. */
.swatch[aria-checked='true'] {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink);
  transform: scale(1.08);
}

.tool-row { display: flex; align-items: center; gap: 10px; }
.tool-row .spacer { margin-left: auto; }
.tool-seg { flex: 0 1 auto; }
.tool-seg button { display: inline-flex; align-items: center; gap: 6px; }

.brush-size { flex: 1 1 90px; max-width: 190px; display: flex; align-items: center; }

.colour-shortcuts { margin: 0; white-space: nowrap; }
/* No keyboard to press them on, and the row is full without them. */
@media (max-width: 900px), (pointer: coarse) {
  .colour-shortcuts { display: none; }
}

/*
 * Landscape phones and small landscape tablets: there is width to spare and
 * almost no height, so the tools stand up as a rail beside the sheet. Left as a
 * bottom bar they take half the window and the sheet shrinks to a postage
 * stamp — the one thing this page exists to show.
 */
@media (max-height: 560px) and (min-width: 620px) {
  .colour-app {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .colour-bar { grid-column: 1 / -1; }

  .colour-tools {
    grid-template-rows: minmax(0, 1fr) auto;
    width: auto;
    max-width: 44vw;
    padding: 8px;
    border-top: 0;
    border-left: 1px solid var(--line);
  }
  .colour-tools > * { width: auto; max-width: none; }

  /* Two columns that scroll downwards, keeping each family's pair side by side
     exactly as the wide layout keeps them one above the other. */
  .swatches {
    grid-auto-flow: row;
    grid-template-rows: none;
    grid-template-columns: repeat(2, auto);
    align-content: start;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .tool-row { flex-wrap: wrap; justify-content: center; gap: 6px; }
  .tool-row .spacer { display: none; }
  .tool-seg { flex: 1 1 100%; justify-content: center; }
  .brush-size { flex: 1 1 100%; max-width: none; }
  /* Every pixel the rail gives up is a pixel of sheet, and this is the widest
     thing in it by some way. */
  .tool-seg button span { display: none; }
  .tool-seg button { padding: 9px 12px; }
}

@media (max-width: 560px) {
  .colour-bar { padding: 6px 8px; }
  .colour-title { display: none; }
  .colour-stage { padding: 6px; }
  .swatch { width: 34px; height: 34px; }
  /* Labels go, icons stay: three named tools plus undo and clear do not fit
     across a phone, and a bucket needs no caption once it has been used once. */
  .tool-seg button span { display: none; }
  .tool-seg button { padding: 9px 12px; }
  .brush-size { flex: 1 1 60px; }
}

@media (prefers-reduced-motion: reduce) {
  .swatch { transition: none; }
  .colour-hint { transition: none; }
}
