@font-face {
  font-family: "Space Grotesk";
  src: url("/fonts/space-grotesk-latin.woff2?v=20260720.6") format("woff2");
  font-weight: 300 700;
  font-display: optional;
}

:root {
  color-scheme: dark light;
  --bg: #0f1420;
  --bg-2: #141a26;
  --stage: #0f1420;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.08);
  --border: rgba(210, 222, 240, 0.13);
  --border-strong: rgba(210, 222, 240, 0.28);
  --ink: #eef2f8;
  --ink-muted: #9aa6b8;
  --brand: #40b3cc;
  --brand-2: #57d0c2;
  --cut: #f2955a;
  --selected-ink: #06121a;
  /* Neutral full-tile legend colour; the canvas uses the selected live colour. */
  --tile: #e7e0d3;
  --display: "Space Grotesk", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 18px;
  --radius-lg: 26px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.42);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #eef1f6;
    --bg-2: #e4e9f1;
    --surface: rgba(255, 255, 255, 0.72);
    --surface-2: #ffffff;
    --border: rgba(30, 45, 70, 0.14);
    --border-strong: rgba(30, 45, 70, 0.26);
    --ink: #17202e;
    --ink-muted: #5a6678;
    --brand: #126b82;
    --brand-2: #0d7067;
    --selected-ink: #fff;
    --shadow: 0 22px 50px rgba(30, 45, 70, 0.14);
  }
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--body);
  color: var(--ink);
  background:
    radial-gradient(1200px 640px at 84% -8%, color-mix(in srgb, var(--brand) 12%, transparent), transparent 60%),
    radial-gradient(900px 560px at 6% 4%, color-mix(in srgb, var(--brand-2) 10%, transparent), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100svh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 30;
  background: var(--brand);
  color: #06121a;
  padding: 0.6rem 1rem;
  border-radius: 0 0 10px 0;
  font-weight: 700;
}

.skip-link:focus {
  left: 0;
}

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

.clipboard-fallback {
  position: fixed;
  opacity: 0;
  pointer-events: none;
}

.form-error {
  margin: 0;
  padding: 0.7rem 0.8rem;
  border: 1px solid color-mix(in srgb, var(--cut) 60%, var(--border));
  border-radius: 10px;
  color: var(--ink);
  background: color-mix(in srgb, var(--cut) 12%, transparent);
  font-size: 0.84rem;
}

[aria-invalid="true"] {
  outline: 2px solid var(--cut);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

:where(a, button, summary, input, select):focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 70%, transparent);
  outline-offset: 2px;
}

/* Header ------------------------------------------------------------------ */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1180px;
  min-height: 64px;
  margin: 0 auto;
  padding:
    max(1rem, env(safe-area-inset-top))
    max(clamp(1rem, 4vw, 2.2rem), env(safe-area-inset-right))
    0.8rem
    max(clamp(1rem, 4vw, 2.2rem), env(safe-area-inset-left));
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--ink);
  font-family: var(--display);
  font-size: 1.16rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: var(--brand);
  stroke-width: 1.6;
}

.brand-mark-fill {
  fill: var(--brand);
  stroke: none;
}

.brand b {
  font-weight: 700;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.trust {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.trust > span {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--brand-2);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--brand-2) 16%, transparent);
}

/* Layout ------------------------------------------------------------------ */

main {
  position: relative;
  max-width: 1180px;
  margin: 0 auto;
  padding:
    0 max(clamp(1rem, 4vw, 2.2rem), env(safe-area-inset-right))
    4rem max(clamp(1rem, 4vw, 2.2rem), env(safe-area-inset-left));
}

.studio {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 82% 0%, color-mix(in srgb, var(--brand) 10%, transparent), transparent 42%),
    color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow);
  padding: clamp(1.4rem, 3.5vw, 2.6rem);
}

.studio__intro {
  max-width: 680px;
}

.studio__intro h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2rem, 5.2vw, 3.3rem);
  font-weight: 700;
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.tagline {
  margin: 0.7rem 0 0;
  max-width: 40rem;
  color: var(--ink-muted);
  font-size: clamp(0.98rem, 1.9vw, 1.12rem);
  line-height: 1.5;
}

.studio__stage {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
  gap: clamp(1.4rem, 3.5vw, 2.6rem);
  margin-top: clamp(1.6rem, 3.5vw, 2.4rem);
  align-items: start;
}

/* Controls ---------------------------------------------------------------- */

.controls {
  display: flex;
  flex-direction: column;
  gap: 1.3rem;
  min-width: 0;
}

.field {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.field__label {
  display: block;
  margin-bottom: 0.6rem;
  color: var(--ink-muted);
  font-family: var(--display);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.field__hint {
  font-family: var(--body);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-transform: none;
  color: color-mix(in srgb, var(--ink-muted) 82%, transparent);
}

/* Segmented control */
.seg {
  display: inline-flex;
  padding: 4px;
  gap: 3px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.seg__btn {
  appearance: none;
  border: 0;
  border-radius: 9px;
  padding: 0.5rem 1.15rem;
  min-height: 40px;
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--display);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease;
}

.seg__btn:hover {
  color: var(--ink);
}

.seg__btn[aria-pressed="true"] {
  background: var(--brand);
  color: var(--selected-ink);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 32%, transparent);
}

/* Dimensions */
.dims {
  display: grid;
  gap: 0.6rem;
}

.dims--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dims--custom-tile {
  margin-top: 0.6rem;
}

.dim {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.dim > span:first-child {
  font-weight: 600;
}

.dim__control,
.adv-control {
  display: flex;
  align-items: center;
  min-height: 46px;
  padding: 0 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: var(--surface-2);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.dim__control:focus-within,
.adv-control:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}

.dim__control input,
.adv-control input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--display);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.dim__unit,
.adv-control > span:not(.adv-control__lead) {
  flex: 0 0 auto;
  padding-left: 0.35rem;
  color: var(--ink-muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

.adv-control__lead {
  flex: 0 0 auto;
  padding-right: 0.2rem;
  color: var(--ink-muted);
  font-size: 0.95rem;
}

/* Tile presets */
.presets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
}

.preset {
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--ink);
  border-radius: 9px;
  padding: 0.55rem 0.4rem;
  min-height: 42px;
  font-family: var(--display);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.preset:hover {
  border-color: var(--brand);
}

.preset[aria-pressed="true"] {
  border-color: var(--brand-2);
  color: var(--brand-2);
  box-shadow: inset 0 0 0 1px var(--brand-2);
}

/* Pattern chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.5rem 0.95rem;
  min-height: 40px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.chip:hover {
  border-color: var(--brand);
}

.chip[aria-pressed="true"] {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--selected-ink);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 30%, transparent);
}

/* Range sliders */
input[type="range"] {
  width: 100%;
  min-height: 40px;
  accent-color: var(--brand);
  cursor: pointer;
}

/* Exclusion mini-disclosure */
.mini {
  margin-top: 0.7rem;
}

.mini > summary {
  cursor: pointer;
  list-style: none;
  color: var(--ink-muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.mini > summary::-webkit-details-marker {
  display: none;
}

.mini__plus {
  color: var(--brand);
  font-weight: 700;
}

.mini__body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.6rem;
}

.exclusions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.exclusion-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.4rem;
  align-items: end;
}

.exclusion-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.exclusion-field input {
  min-height: 40px;
  padding: 0 0.55rem;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--display);
  font-variant-numeric: tabular-nums;
}

.exclusion-remove {
  height: 40px;
  width: 40px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--ink-muted);
  cursor: pointer;
}

.exclusion-remove:hover {
  border-color: var(--cut);
  color: var(--cut);
}

/* Swatches */
.swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: 0.45rem;
}

.swatch {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  background: #e7e0d3;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.swatch--1 { background: #e7e0d3; }
.swatch--2 { background: #efe9df; }
.swatch--3 { background: #d8c7a8; }
.swatch--4 { background: #c78c63; }
.swatch--5 { background: #b05a3c; }
.swatch--6 { background: #a7b0a0; }
.swatch--7 { background: #6f7885; }
.swatch--8 { background: #3c4149; }
.swatch--9 { background: #f2f1ee; }
.swatch--10 { background: #2b2e33; }

.swatch:hover {
  transform: translateY(-2px);
}

.swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--brand);
}

.swatch[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.9);
  mix-blend-mode: difference;
}

.custom-colour {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.7rem;
  color: var(--ink-muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.custom-colour input[type="color"] {
  width: 42px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.custom-colour input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.custom-colour input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 5px;
}

/* Advanced */
.advanced {
  border-top: 1px solid var(--border);
  padding-top: 0.4rem;
}

.advanced > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 48px;
  padding-right: 1.8rem;
  position: relative;
  cursor: pointer;
  list-style: none;
  font-family: var(--display);
  font-size: 0.88rem;
  font-weight: 650;
  color: var(--ink);
}

.advanced > summary::-webkit-details-marker {
  display: none;
}

.advanced > summary span:last-child {
  color: var(--ink-muted);
  font-family: var(--body);
  font-size: 0.74rem;
  font-weight: 500;
}

.advanced > summary::after {
  content: "+";
  position: absolute;
  right: 0.2rem;
  color: var(--brand);
  font-family: var(--display);
  font-size: 1.3rem;
  font-weight: 400;
  transition: transform 0.2s ease;
}

.advanced[open] > summary::after {
  transform: rotate(45deg);
}

.advanced__body {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 0.6rem 0 0.2rem;
}

.adv-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.adv-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.adv-field select {
  min-height: 46px;
  padding: 0 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--body);
  font-size: 0.9rem;
  cursor: pointer;
}

.adv-note {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

/* Preview (stage + result) ------------------------------------------------ */

.preview {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  min-width: 0;
}

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--stage);
  display: flex;
  touch-action: none;
}

.stage__canvas {
  flex: 1;
  width: 100%;
  height: 100%;
  display: block;
}

.stage-nudge {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: grid;
  grid-template-columns: repeat(3, 34px);
  gap: 4px;
}

.stage-nudge button {
  min-width: 34px;
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: #eef2f8;
  background: rgba(10, 14, 22, 0.78);
  cursor: pointer;
}

.stage-nudge [data-nudge="up"] { grid-column: 2; }
.stage-nudge [data-nudge="left"] { grid-column: 1; grid-row: 2; }
.stage-nudge [data-nudge="reset"] { grid-column: 2; grid-row: 2; }
.stage-nudge [data-nudge="right"] { grid-column: 3; grid-row: 2; }
.stage-nudge [data-nudge="down"] { grid-column: 2; grid-row: 3; }

.toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
  background: rgba(10, 14, 22, 0.7);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  backdrop-filter: blur(6px);
}

.toggle button {
  border: 0;
  background: transparent;
  color: #9aa6b8;
  font-family: var(--display);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
}

.toggle button[aria-pressed="true"] {
  background: var(--brand-2);
  color: var(--selected-ink);
}

.hud {
  position: absolute;
  left: 12px;
  bottom: 12px;
  margin: 0;
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  background: rgba(10, 14, 22, 0.6);
  border: 1px solid var(--border);
  color: #9aa6b8;
  font-size: 0.72rem;
  font-weight: 600;
  pointer-events: none;
}

/* Result */
.result {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(10px);
  padding: clamp(1.1rem, 2.6vw, 1.4rem);
}

.results {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
}

.stat {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  padding: 0.75rem 0.85rem;
  min-width: 0;
}

.stat__v {
  font-family: var(--display);
  font-size: clamp(1.4rem, 3.6vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.stat__v--sm {
  font-size: clamp(1.05rem, 2.6vw, 1.3rem);
}

.stat__k {
  margin-top: 0.2rem;
  color: var(--ink-muted);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat--buy {
  border-color: color-mix(in srgb, var(--brand) 45%, var(--border));
  background: color-mix(in srgb, var(--brand) 12%, var(--surface-2));
}

.stat--buy .stat__v {
  background: linear-gradient(108deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.result__secondary {
  margin: 0.9rem 0 0;
  color: var(--ink-muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  align-items: center;
  margin-top: 0.7rem;
  color: var(--ink-muted);
  font-size: 0.78rem;
}

.swatch-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  vertical-align: -1px;
  margin-right: 5px;
  border: 1px solid rgba(0, 0, 0, 0.25);
}

.swatch-dot--full {
  background: var(--tile);
}

.swatch-dot--cut {
  background: var(--cut);
}

.legend__pieces {
  flex-basis: 100%;
  color: color-mix(in srgb, var(--ink-muted) 88%, transparent);
}

.result__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.1rem;
}

.btn {
  appearance: none;
  min-height: 46px;
  padding: 0.7rem 1.2rem;
  border-radius: 12px;
  font-family: var(--display);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.18s ease, background 0.18s ease;
}

.btn--primary {
  border: 0;
  color: var(--selected-ink);
  background: linear-gradient(108deg, var(--brand), var(--brand-2));
  box-shadow: 0 9px 26px color-mix(in srgb, var(--brand) 26%, transparent);
}

.btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px color-mix(in srgb, var(--brand) 34%, transparent);
}

.btn--ghost {
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--ink);
}

.btn--ghost:hover {
  border-color: var(--brand);
  color: var(--brand);
  transform: translateY(-1px);
}

.btn--tiny {
  align-self: flex-start;
  min-height: 38px;
  padding: 0.45rem 0.85rem;
  border-radius: 9px;
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--ink-muted);
  font-size: 0.8rem;
}

.btn--tiny:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.action-note {
  display: block;
  min-height: 1.2em;
  margin-top: 0.55rem;
  color: var(--brand-2);
  font-size: 0.82rem;
}

/* Content sections -------------------------------------------------------- */

section {
  margin-top: clamp(2.6rem, 6vw, 4.2rem);
}

h2 {
  font-family: var(--display);
  font-size: clamp(1.4rem, 3.2vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 1.2rem;
}

.method__steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.method__steps li {
  display: flex;
  gap: 0.85rem;
  padding: 1.15rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(8px);
}

.method__num {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--brand) 16%, transparent);
  color: var(--brand);
  font-family: var(--display);
  font-weight: 700;
}

.method__steps h3 {
  margin: 0.1rem 0 0.35rem;
  font-family: var(--display);
  font-size: 1rem;
}

.method__steps p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.prose {
  max-width: 820px;
}

.prose p {
  margin: 0 0 1rem;
  color: var(--ink-muted);
}

.prose ul {
  margin: 0;
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.prose li {
  color: var(--ink-muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.prose b {
  color: var(--ink);
}

.pattern-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.9rem;
}

.pattern-guide-inline {
  margin-top: 1.4rem;
}

.pattern-guide-inline > h3 {
  margin: 0 0 0.7rem;
  font-family: var(--display);
  font-size: 1rem;
}

.pattern-card {
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.pattern-card h3,
.pattern-card h4 {
  margin: 0 0 0.35rem;
  font-family: var(--display);
  font-size: 1rem;
}

.pattern-card p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.88rem;
}

/* FAQ */
.faq {
  max-width: 820px;
}

.faq details {
  border-bottom: 1px solid var(--border);
}

.faq summary {
  position: relative;
  min-height: 58px;
  display: flex;
  align-items: center;
  padding: 0.95rem 2.6rem 0.95rem 0;
  cursor: pointer;
  list-style: none;
  font-family: var(--display);
  font-size: 0.98rem;
  font-weight: 600;
}

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

.faq summary::after {
  content: "+";
  position: absolute;
  right: 0.1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--brand);
  font-size: 1.4rem;
  transition: transform 0.25s ease;
}

.faq details[open] summary::after {
  transform: translateY(-50%) rotate(45deg);
}

.faq details p {
  margin: 0;
  padding: 0 0 1.15rem;
  max-width: 720px;
  color: var(--ink-muted);
  font-size: 0.94rem;
}

/* Footer ------------------------------------------------------------------ */

.site-footer {
  max-width: 1180px;
  margin: 0 auto;
  padding:
    2.4rem max(clamp(1rem, 4vw, 2.2rem), env(safe-area-inset-right))
    max(2.6rem, env(safe-area-inset-bottom))
    max(clamp(1rem, 4vw, 2.2rem), env(safe-area-inset-left));
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer-disclaimer {
  max-width: 660px;
  margin: 0 auto 0.8rem;
  color: var(--ink-muted);
  font-size: 0.84rem;
}

.footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.86rem;
}

.footer-link {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--border-strong);
}

.footer-link:hover {
  color: var(--brand);
  border-color: var(--brand);
}

/* Legal dialog + shared legal copy ---------------------------------------- */

.legal-dialog {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  padding: 0;
  width: min(680px, 92vw);
  max-height: 84svh;
}

.legal-dialog::backdrop {
  background: rgba(4, 8, 14, 0.62);
  backdrop-filter: blur(4px);
}

.legal-dialog-frame {
  position: relative;
  padding: 1.6rem clamp(1.1rem, 4vw, 2rem) 2rem;
}

.legal-close {
  position: sticky;
  top: 0.2rem;
  float: right;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--ink);
  border-radius: 999px;
  width: 2.2rem;
  height: 2.2rem;
  cursor: pointer;
  font-size: 0.95rem;
}

.legal-close:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.legal-page {
  background: var(--bg);
}

.legal-page-shell {
  max-width: 680px;
  margin: 0 auto;
  padding: 2.2rem clamp(1rem, 4vw, 2rem) 4rem;
}

.legal-back {
  display: inline-block;
  margin-bottom: 1.4rem;
  color: var(--brand);
  text-decoration: none;
  font-size: 0.92rem;
}

.legal-copy .eyebrow {
  margin: 0 0 0.4rem;
  color: var(--brand);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.legal-copy h1 {
  font-family: var(--display);
  font-size: clamp(1.5rem, 4vw, 2rem);
  letter-spacing: -0.02em;
  margin: 0 0 0.3rem;
}

.legal-copy .legal-updated {
  margin: 0 0 1.4rem;
  color: var(--ink-muted);
  font-size: 0.85rem;
}

.legal-copy h2 {
  font-size: 1.05rem;
  margin: 1.5rem 0 0.4rem;
}

.legal-copy p,
.legal-copy li {
  color: var(--ink-muted);
  font-size: 0.95rem;
}

.legal-copy a {
  color: var(--brand);
}

.legal-copy footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--ink-muted);
  font-size: 0.85rem;
}

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

.error-page main {
  text-align: center;
  padding-top: 14vh;
}

.error-code {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(4rem, 16vw, 7rem);
  font-weight: 700;
  background: linear-gradient(112deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Responsive -------------------------------------------------------------- */

@media (max-width: 900px) {
  .studio__stage {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .site-header {
    min-height: 56px;
    gap: 0.6rem;
  }

  .trust {
    font-size: 0.62rem;
    letter-spacing: 0.02em;
  }

  .results {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .studio {
    border-radius: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print ------------------------------------------------------------------- */

@media print {
  body {
    background: #fff;
    color: #000;
  }

  .site-header .trust,
  .controls,
  .toggle,
  .hud,
  .result__actions,
  .action-note,
  .method,
  .patterns-guide,
  .faq,
  .site-footer,
  .skip-link {
    display: none !important;
  }

  .studio,
  .result,
  .stat,
  .stage {
    border-color: #ccc;
    box-shadow: none;
    background: #fff;
  }

  .studio__stage {
    grid-template-columns: 1fr;
  }

  .stat__v,
  .stat--buy .stat__v {
    color: #000 !important;
    -webkit-text-fill-color: #000;
  }
}

/* v2 task-first workbench -------------------------------------------------
   The original visual tokens stay intact; these rules only give the new
   regions a deliberate composition and responsive order. */

.eyebrow,
.section-kicker {
  margin: 0;
  color: var(--brand);
  font-family: var(--display);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.studio__intro .eyebrow {
  margin-bottom: 0.35rem;
}

.studio__intro h1 {
  white-space: nowrap;
  font-size: clamp(2.2rem, 5vw, 3.15rem);
}

.tool-form {
  display: block;
  margin: 0;
}

.studio__stage {
  display: grid;
  grid-template-columns: minmax(280px, 0.76fr) minmax(0, 1.24fr);
  grid-template-areas:
    "quick visual"
    "fine visual";
  gap: 1.5rem clamp(1.4rem, 3.5vw, 2.6rem);
  align-items: start;
  margin-top: clamp(1.5rem, 3vw, 2.25rem);
}

.quick-inputs,
.fine-tune,
.visual-rail {
  min-width: 0;
  margin-top: 0;
}

.quick-inputs { grid-area: quick; }
.visual-rail { grid-area: visual; }
.fine-tune { grid-area: fine; }

.section-heading,
.stage-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.05rem;
}

.section-heading h2,
.stage-heading h2 {
  margin: 0.18rem 0 0;
  font-size: 1.15rem;
  letter-spacing: -0.025em;
}

.section-heading--fine {
  align-items: center;
  margin-bottom: 0.35rem;
}

.controls {
  display: contents;
}

.quick-inputs .field,
.fine-tune .advanced,
.fine-tune > .complexity-hint,
.fine-tune > .form-error {
  margin-top: 1.25rem;
}

.quick-inputs .field:first-of-type {
  margin-top: 0;
}

.dim__control--imperial .imperial-inches {
  display: none;
  width: 3.2rem;
  margin-left: 0.45rem;
  padding-left: 0.45rem;
  border-left: 1px solid var(--border);
}

body[data-units="imperial"] .dim__control--imperial .imperial-inches {
  display: block;
}

.presets {
  display: flex;
  overflow-x: auto;
  gap: 0.45rem;
  padding: 0.1rem 0.1rem 0.35rem;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}

.picker-help {
  max-width: 46rem;
  margin: -0.45rem 0 0.55rem;
  color: var(--ink-muted);
  font-size: 0.76rem;
  line-height: 1.4;
}

.picker-shell {
  position: relative;
  min-width: 0;
}

.picker-shell::before,
.picker-shell::after {
  position: absolute;
  top: 0;
  bottom: 2.2rem;
  z-index: 1;
  width: 1.7rem;
  pointer-events: none;
  content: "";
  opacity: 0;
  transition: opacity 0.16s ease;
}

.picker-shell::before {
  left: 0;
  background: linear-gradient(90deg, color-mix(in srgb, var(--bg) 94%, transparent), transparent);
}

.picker-shell::after {
  right: 0;
  background: linear-gradient(270deg, color-mix(in srgb, var(--bg) 94%, transparent), transparent);
}

.picker-shell[data-overflow="true"][data-at-start="false"]::before,
.picker-shell[data-overflow="true"][data-at-end="false"]::after {
  opacity: 1;
}

.presets,
.pattern-strip {
  overscroll-behavior-inline: contain;
  scroll-padding-inline: 0.35rem;
  cursor: ew-resize;
}

.picker-affordance {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  min-height: 2.15rem;
  margin-top: 0.15rem;
  color: var(--brand);
  font-size: 0.7rem;
  font-weight: 650;
  line-height: 1.2;
}

.picker-affordance[hidden] {
  display: none;
}

.picker-next {
  display: inline-grid;
  flex: 0 0 auto;
  width: 2.25rem;
  min-height: 2.25rem;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--brand) 42%, var(--border-strong));
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 10%, var(--surface-2));
  color: var(--brand-2);
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.picker-next:hover:not(:disabled),
.picker-next:focus-visible {
  border-color: var(--brand-2);
  background: color-mix(in srgb, var(--brand) 18%, var(--surface-2));
}

.picker-next:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.preset {
  flex: 0 0 92px;
  scroll-snap-align: start;
}

.preset--custom {
  color: var(--brand);
  border-style: dashed;
}

.pattern-strip {
  display: flex;
  overflow-x: auto;
  gap: 0.5rem;
  padding: 0.1rem 0.1rem 0.4rem;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}

.pattern-choice {
  display: flex;
  flex: 0 0 116px;
  min-height: 72px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.45rem;
  padding: 0.55rem 0.62rem;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--display);
  font-size: 0.72rem;
  font-weight: 650;
  line-height: 1.1;
  text-align: left;
  cursor: pointer;
  scroll-snap-align: start;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.pattern-choice:hover {
  border-color: var(--brand);
}

.pattern-choice[aria-pressed="true"] {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 14%, var(--surface-2));
  color: var(--brand-2);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 42%, transparent);
}

.pattern-choice:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.pattern-art {
  display: block;
  width: 56px;
  height: 28px;
  border: 1px solid color-mix(in srgb, var(--brand) 40%, var(--border));
  border-radius: 4px;
  background-color: color-mix(in srgb, var(--brand) 12%, transparent);
  background-size: 14px 14px;
}

.pattern-art--grid {
  background-image: linear-gradient(var(--brand) 1px, transparent 1px), linear-gradient(90deg, var(--brand) 1px, transparent 1px);
}

.pattern-art--offset {
  background-image: linear-gradient(var(--brand) 1px, transparent 1px), linear-gradient(90deg, var(--brand) 1px, transparent 1px);
  background-position: 0 0, 7px 0;
}

.pattern-art--third {
  background-image: linear-gradient(var(--brand) 1px, transparent 1px), linear-gradient(90deg, var(--brand) 1px, transparent 1px);
  background-size: 18px 14px, 18px 14px;
  background-position: 0 0, 6px 0;
}

.pattern-art--diagonal {
  background-image: repeating-linear-gradient(45deg, transparent 0 6px, var(--brand) 7px 8px);
}

.pattern-art--herringbone {
  background-image: linear-gradient(45deg, transparent 42%, var(--brand) 43% 49%, transparent 50%), linear-gradient(-45deg, transparent 42%, var(--brand) 43% 49%, transparent 50%);
  background-size: 14px 14px;
}

.mini__explain {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.mobile-result-dock {
  display: none;
}

.stage-heading {
  align-items: center;
}

.stage {
  touch-action: pan-y;
  user-select: none;
}

.stage.is-gesture-mode {
  touch-action: none;
  cursor: grab;
}

.stage.is-gesture-mode:active {
  cursor: grabbing;
}

.explore-button {
  display: none;
  margin-left: auto;
}

.preview-note {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(88%, 390px);
  margin: 0;
  padding: 0.7rem 0.85rem;
  border: 1px solid color-mix(in srgb, var(--cut) 48%, var(--border));
  border-radius: 10px;
  background: color-mix(in srgb, var(--stage) 92%, transparent);
  color: #eef2f8;
  font-size: 0.78rem;
  line-height: 1.45;
  text-align: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.stage-tools {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 0.35rem;
}

.tool-button {
  min-height: 34px;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(10, 14, 22, 0.72);
  color: #eef2f8;
  font-family: var(--display);
  font-size: 0.7rem;
  font-weight: 650;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.tool-button:hover:not(:disabled) {
  border-color: var(--brand-2);
  color: var(--brand-2);
}

.tool-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.stage-nudge button {
  font-family: var(--display);
  font-weight: 700;
}

.fine-tune .advanced {
  border-top: 1px solid var(--border);
}

.fine-tune .advanced:first-of-type {
  margin-top: 0;
}

.fine-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.fine-grid .adv-field {
  gap: 0.25rem;
}

.colour-line {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.colour-line .field__label {
  margin: 0;
}

.colour-line .swatches {
  display: flex;
  flex: 1 1 250px;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.colour-line .swatch {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
}

.text-button,
.undo-button {
  align-self: flex-start;
  border: 0;
  padding: 0.1rem 0;
  background: transparent;
  color: var(--brand);
  font-size: 0.76rem;
  cursor: pointer;
}

.text-button:hover,
.undo-button:hover {
  color: var(--brand-2);
  text-decoration: underline;
}

.inline-dependency,
.complexity-hint {
  margin: 0;
  color: var(--cut);
  font-size: 0.78rem;
  line-height: 1.45;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-height: 1.4rem;
}

.btn:disabled,
.text-button:disabled,
.undo-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.print-summary {
  display: none;
}

@media (min-width: 901px) and (min-height: 700px) {
  .visual-rail {
    position: sticky;
    top: 1rem;
  }
}

@media (pointer: coarse) {
  .explore-button[data-explore] {
    display: inline-flex;
  }
}

@media (max-width: 900px) {
  .studio__stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "quick-heading"
      "dims"
      "tile"
      "dock"
      "pattern"
      "visual"
      "fine";
    gap: 0.95rem;
  }

  .quick-inputs {
    display: contents;
  }

  .quick-inputs .section-heading { grid-area: quick-heading; }
  .quick-inputs .field--dims { grid-area: dims; }
  .quick-inputs .field--tile { grid-area: tile; }
  .quick-inputs .field--pattern { grid-area: pattern; }

  .quick-inputs .field,
  .fine-tune .advanced,
  .fine-tune > .complexity-hint,
  .fine-tune > .form-error {
    margin-top: 0;
  }

  .mobile-result-dock {
    position: sticky;
    top: max(0.5rem, env(safe-area-inset-top));
    z-index: 8;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 58px;
    padding: 0.65rem 0.75rem;
    border: 1px solid color-mix(in srgb, var(--brand) 38%, var(--border));
    border-radius: 14px;
    background: color-mix(in srgb, var(--bg-2) 94%, transparent);
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(12px);
  }

  .mobile-result-dock > div {
    display: flex;
    align-items: baseline;
    gap: 0.28rem;
    color: var(--ink-muted);
    font-size: 0.75rem;
    white-space: nowrap;
  }

  .mobile-result-dock strong {
    color: var(--ink);
    font-family: var(--display);
    font-size: 1.15rem;
    font-variant-numeric: tabular-nums;
  }

  .mobile-result-dock > div:first-child strong {
    color: var(--brand-2);
    font-size: 1.45rem;
  }

  .dock__label {
    color: var(--ink-muted);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
  }

  .mobile-result-dock .btn {
    margin-left: auto;
    white-space: nowrap;
  }

  .mobile-result-dock.is-updated {
    border-color: var(--brand-2);
    transition: border-color 0.15s ease;
  }

  .visual-rail .stage-heading {
    margin-bottom: 0.7rem;
  }

  .stage {
    aspect-ratio: 1 / 0.86;
  }

  .fine-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .studio {
    padding: 1.05rem;
    border-radius: 18px;
  }

  .studio__intro h1 {
    font-size: clamp(2rem, 11vw, 2.55rem);
  }

  .tagline {
    margin-top: 0.55rem;
    font-size: 0.94rem;
  }

  .section-heading,
  .stage-heading {
    align-items: flex-start;
  }

  .section-heading .seg {
    flex: 0 0 auto;
  }

  .seg__btn {
    min-height: 40px;
    padding-inline: 0.72rem;
  }

  .pattern-choice {
    flex-basis: 108px;
  }

  .stage-tools {
    top: auto;
    bottom: 12px;
    left: 12px;
  }

  .hud {
    bottom: 56px;
    left: 12px;
  }

  .stage-nudge {
    right: 10px;
    bottom: 10px;
  }

  .results {
    gap: 0.45rem;
  }

  .stat {
    padding: 0.65rem;
  }

  .result__actions .btn {
    flex: 1 1 calc(50% - 0.6rem);
    padding-inline: 0.7rem;
  }
}

@media print {
  .site-header .trust,
  .quick-inputs,
  .fine-tune,
  .mobile-result-dock,
  .stage-heading,
  .toggle,
  .hud,
  .stage-tools,
  .stage-nudge,
  .result__actions,
  .action-row,
  .method,
  .patterns-guide,
  .faq,
  .site-footer,
  .skip-link {
    display: none !important;
  }

  .studio {
    max-width: 100%;
    padding: 0;
    border: 0;
    background: #fff;
    box-shadow: none;
  }

  .studio__intro {
    margin-bottom: 1rem;
  }

  .studio__stage {
    display: block;
    margin-top: 0;
  }

  .visual-rail,
  .result,
  .stage {
    border-color: #ccc;
    background: #fff;
    box-shadow: none;
  }

  .stage {
    aspect-ratio: 4 / 3;
  }

  .print-summary {
    display: block;
    margin: 1rem 0 0;
    color: #000;
    font: 10pt/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
    white-space: pre-wrap;
  }

  .stat__v,
  .stat--buy .stat__v {
    color: #000 !important;
    -webkit-text-fill-color: #000;
  }
}
