/* Saul's Bean Lab — styled to sit next to imsaul.lol.
   Tokens and fonts are the blog's; the blog serves its fonts with CORS open,
   so they load from there and fall back to system faces when offline. */

@font-face {
  font-family: "Anthropic Sans";
  src: url("https://imsaul.lol/fonts/AnthropicSans-Roman-Web.woff2") format("woff2");
  font-weight: 300 800;
  font-display: swap;
}
@font-face {
  font-family: "Anthropic Serif";
  src: url("https://imsaul.lol/fonts/AnthropicSerif-Roman-Web.woff2") format("woff2");
  font-weight: 300 800;
  font-display: swap;
}
@font-face {
  font-family: "Anthropic Mono";
  src: url("https://imsaul.lol/fonts/AnthropicMono-Roman-Web.woff2") format("woff2");
  font-weight: 300 800;
  font-display: swap;
}

:root {
  --bg: #faf9f6;
  --fg: #191815;
  --ink: #141413;
  --muted: #5d5751;
  --subtle: #8a837c;
  --panel: #e9e7e6;
  --soft: #f0eee7;
  --border: #d5d1ce;
  --card: #e3dacc;
  --card-strong: #d8ccb9;

  --font-sans: "Anthropic Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-serif: "Anthropic Serif", "Iowan Old Style", Georgia, "PingFang SC", "Hiragino Sans GB", serif;
  --font-mono: "Anthropic Mono", "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;

  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --page-max: 1400px;
  --gutter: 32px;
  --topbar-h: 64px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

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

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

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

main { flex: 1; }

button,
input,
select { font: inherit; color: inherit; }

button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

::selection { background: var(--card-strong); }

.hidden { display: none !important; }
.mono { font-family: var(--font-mono); }

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--bg);
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

.eyebrow {
  margin: 0 0 14px;
  font: 12px/1.3 var(--font-mono);
  letter-spacing: -0.02em;
  color: var(--muted);
}

/* Top bar ---------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 max(var(--gutter), calc((100vw - var(--page-max)) / 2 + var(--gutter)));
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.brand {
  font: 700 19px/1 var(--font-sans);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg);
  text-decoration: none;
  white-space: nowrap;
}

/* The blog's wordmark trick: the middle of the name folds away once you scroll. */
.logo-mid {
  display: inline-block;
  max-width: var(--logo-mid-w, 12em);
  overflow: hidden;
  white-space: nowrap;
  vertical-align: bottom;
  transition: max-width 0.6s cubic-bezier(0.77, 0, 0.175, 1), opacity 0.38s ease-in-out;
}
.topbar.is-scrolled .logo-mid { max-width: 0; opacity: 0; }

.topnav {
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 15px;
}
.tagline { color: var(--muted); font-family: var(--font-serif); font-size: 16px; }
.topnav a { color: var(--fg); text-decoration: none; }
.topnav a:hover { text-decoration: underline; text-underline-offset: 3px; }

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

.button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  min-height: 40px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: 500 15px/1 var(--font-sans);
  letter-spacing: -0.005em;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, transform 0.15s;
}
.button:active { transform: translateY(1px); }
.button span { font-size: 17px; line-height: 1; }

.button-primary { background: var(--ink); color: var(--bg); }
.button-primary:hover { background: #433e39; }

.button-secondary { border-color: var(--fg); background: transparent; color: var(--fg); }
.button-secondary:hover { background: var(--soft); }

.button-quiet { background: var(--card); color: var(--fg); }
.button-quiet:hover { background: var(--card-strong); }

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

.link-button {
  appearance: none;
  padding: 0;
  border: 0;
  border-bottom: 1px solid currentColor;
  background: none;
  font-size: 13px;
  line-height: 1.3;
  color: var(--muted);
  cursor: pointer;
}
.link-button:hover { color: var(--fg); }

/* Landing ---------------------------------------------------------------- */

.landing {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--gutter) 96px;
}

.hero {
  min-height: calc(100dvh - var(--topbar-h) - 120px);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 64px;
  align-items: center;
  padding: 72px 0 56px;
}

.hero h1 {
  margin: 0;
  max-width: 640px;
  font: 700 clamp(40px, 4.6vw, 66px)/1.08 var(--font-sans);
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.intro {
  max-width: 520px;
  margin: 24px 0 32px;
  font: 20px/1.6 var(--font-serif);
  color: #433e39;
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-actions .button { min-width: 168px; }

.hint {
  max-width: 460px;
  margin: 18px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.resume {
  display: inline-flex;
  gap: 6px;
  margin-top: 28px;
  padding: 0 0 2px;
  border: 0;
  border-bottom: 1px solid var(--fg);
  background: none;
  font-size: 14px;
}
.resume b { font-weight: 600; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.hero-art {
  position: relative;
  aspect-ratio: 1 / 0.92;
  border-radius: var(--radius-xl);
  background: var(--card);
  overflow: hidden;
  cursor: pointer;
  transition: outline-offset 0.2s, background-color 0.2s;
}
.hero-art:hover { background: #dfd5c5; }
.hero-art.dragging { outline: 2px dashed var(--fg); outline-offset: 6px; }
.hero-art canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
@media (hover: none) { .hero-art-caption { display: none; } }
.hero-art-caption {
  position: absolute;
  right: 20px;
  bottom: 16px;
  margin: 0;
  font: 12px var(--font-mono);
  color: var(--muted);
}

.features {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.feature {
  padding: 28px;
  border-radius: var(--radius-lg);
  background: var(--soft);
}
.feature h3 { margin: 0 0 10px; font: 600 21px/1.25 var(--font-sans); letter-spacing: -0.01em; }
.feature p:last-child { margin: 0; font: 16px/1.6 var(--font-serif); color: #433e39; }

/* Ready-made patterns ---------------------------------------------------- */

.gallery {
  padding: 16px 0 72px;
  scroll-margin-top: calc(var(--topbar-h) + 24px);
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 28px;
}
.section-head h2 {
  margin: 0;
  font: 700 clamp(30px, 3vw, 40px)/1.1 var(--font-sans);
  letter-spacing: -0.02em;
}
.section-note {
  max-width: 440px;
  margin: 0;
  font: 17px/1.6 var(--font-serif);
  color: #433e39;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.preset-card { position: relative; }
.preset-open {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--soft);
  text-align: left;
  overflow: hidden;
  transition: background-color 0.25s;
}
.preset-open:hover { background: #ebe7de; }
.preset-art {
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 0.8;
}
.preset-art canvas {
  display: block;
  height: auto;
  image-rendering: pixelated;
  transition: transform 0.4s var(--ease);
}
.preset-open:hover .preset-art canvas { transform: translateY(-5px); }
.preset-meta {
  display: grid;
  gap: 3px;
  padding: 0 72px 16px 18px; /* room on the right for the PNG button */
}
.preset-meta b { font-size: 15px; font-weight: 600; white-space: nowrap; }
.preset-meta b::after {
  content: " →";
  opacity: 0;
  transition: opacity 0.2s;
}
.preset-open:hover .preset-meta b::after { opacity: 1; }
.preset-meta span { font: 11px var(--font-mono); color: var(--muted); white-space: nowrap; }

.preset-download {
  position: absolute;
  right: 14px;
  bottom: 16px;
  padding: 5px 10px;
  border: 0;
  border-radius: 99px;
  background: var(--bg);
  font: 11px/1 var(--font-mono);
  color: var(--fg);
  opacity: 0;
  transition: opacity 0.2s, background-color 0.2s;
}
.preset-card:hover .preset-download,
.preset-download:focus-visible { opacity: 1; }
.preset-download:hover { background: #fff; }
@media (hover: none) { .preset-download { opacity: 1; } }

.fineprint { margin: 18px 0 0; font-size: 12px; color: var(--subtle); }

/* Collections: one card per set on the landing page. */
.collection-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.collection-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--soft);
  text-align: left;
  overflow: hidden;
  transition: background-color 0.25s;
}
.collection-card:hover { background: #ebe7de; }
.collection-cover {
  position: relative;
  min-height: 0; /* let the aspect ratio, not the stacked logos, set the height */
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6%;
  aspect-ratio: 16 / 8;
  padding: 0 8%;
}
.collection-cover canvas {
  flex: 0 1 auto;
  height: auto;
  image-rendering: pixelated;
  transition: transform 0.45s var(--ease);
}
.collection-card:hover .collection-cover canvas:nth-child(1) { transform: translateY(-6px) rotate(-3deg); }
.collection-card:hover .collection-cover canvas:nth-child(2) { transform: translateY(-9px); }
.collection-card:hover .collection-cover canvas:nth-child(3) { transform: translateY(-6px) rotate(3deg); }
.collection-card.is-dark { background: var(--ink); color: var(--bg); }
.collection-card.is-dark:hover { background: #22211f; }
.collection-card.is-dark .collection-cover { flex-direction: column; gap: 7%; }
.collection-cover img {
  display: block;
  min-height: 0;
  max-width: 64%;
  max-height: 22%;
  object-fit: contain;
  transition: transform 0.45s var(--ease);
}
.collection-card:hover .collection-cover img { transform: scale(1.04); }
.collection-meta {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px 20px;
}
.collection-meta b { display: block; font: 600 20px/1.2 var(--font-sans); letter-spacing: -0.01em; }
.collection-meta small { display: block; margin-top: 3px; font-size: 13px; color: var(--muted); }
.collection-count { font: 12px var(--font-mono); color: var(--muted); white-space: nowrap; }
.collection-count::after { content: "→"; display: inline-block; margin-left: 6px; transition: transform 0.2s; }
.collection-card:hover .collection-count::after { transform: translateX(3px); }
.collection-card.is-dark small,
.collection-card.is-dark .collection-count { color: #a39d95; }

/* The sheet a collection opens in: a centred panel, a bottom sheet on phones. */
.sheet {
  width: min(1180px, calc(100% - 48px));
  max-width: none;
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 0;
  border-radius: var(--radius-xl);
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 30px 80px rgba(20, 20, 19, 0.28);
  overflow: hidden;
}
.sheet::backdrop { background: rgba(20, 20, 19, 0.45); backdrop-filter: blur(3px); }
.sheet[open] { animation: sheet-in 0.32s var(--ease); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(18px); } }
.sheet-body {
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 36px 36px 30px;
}
.sheet-head { max-width: 640px; margin-bottom: 28px; }
.sheet-head .eyebrow { margin-bottom: 10px; }
.sheet-head h2 { margin: 0; font: 700 clamp(30px, 3vw, 40px)/1.1 var(--font-sans); letter-spacing: -0.02em; }
.sheet-note { margin: 12px 0 0; font: 17px/1.6 var(--font-serif); color: #433e39; }
.sheet-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--soft);
  color: var(--fg);
  transition: background-color 0.2s;
}
.sheet-close:hover { background: var(--panel); }
.sheet-close svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
body.sheet-open { overflow: hidden; }

/* Wide items (title logos) sit three to a row on a dark ground. */
.preset-grid.is-wide { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.preset-grid.is-wide .preset-art { aspect-ratio: 16 / 7; padding: 0 8%; }
.preset-card.is-dark .preset-open { background: var(--ink); color: var(--bg); }
.preset-card.is-dark .preset-open:hover { background: #22211f; }
.preset-card.is-dark .preset-meta span { color: #a39d95; }
.preset-art img {
  display: block;
  max-width: 100%;
  max-height: 62%;
  object-fit: contain;
  transition: transform 0.4s var(--ease);
}
.preset-open:hover .preset-art img { transform: scale(1.04); }

/* Workspace -------------------------------------------------------------- */

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 320px;
  height: calc(100dvh - var(--topbar-h));
  min-height: 560px;
  border-bottom: 1px solid var(--border);
}

.panel {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.controls { border-right: 1px solid var(--border); }
.materials {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  padding-bottom: 0;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.panel-head h2 {
  margin: 0;
  font: 600 22px/1.2 var(--font-sans);
  letter-spacing: -0.015em;
}

.source {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin: 22px 0 6px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--soft);
}
.source img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: repeating-conic-gradient(#e6e2dc 0 25%, #f5f3ee 0 50%) 0 0 / 10px 10px;
}
.source-meta { min-width: 0; display: grid; gap: 2px; }
.source-meta strong {
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.source-meta span { font-size: 11px; color: var(--muted); }

.group {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}
.group:last-child { border-bottom: 0; }
.group-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 12px;
  font: 600 13px/1.3 var(--font-sans);
}
.group-note { font: 11px var(--font-mono); font-weight: 400; color: var(--muted); }

details.group > summary {
  margin: 0;
  list-style: none;
  cursor: pointer;
}
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary::after {
  content: "+";
  margin-left: 8px;
  font: 16px/1 var(--font-mono);
  color: var(--muted);
}
details.group[open] > summary { margin-bottom: 12px; }
details.group[open] > summary::after { content: "−"; }
details.group > summary .group-note { margin-left: auto; }

/* Segmented controls */
.segmented {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--panel);
}
.segmented + .segmented,
.dimensions + .segmented { margin-top: 12px; }
.segmented button {
  min-height: 30px;
  padding: 4px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 13px;
  color: var(--muted);
  transition: background-color 0.15s, color 0.15s;
}
.segmented button:hover { color: var(--fg); }
.segmented button[aria-pressed="true"] {
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 1px 2px rgba(25, 24, 21, 0.12), 0 0 0 0.5px rgba(25, 24, 21, 0.06);
}
.segmented-tall button { min-height: 48px; }
.segmented-tall b,
.segmented-tall span { display: block; }
.segmented-tall b { font-weight: 600; font-size: 14px; }
.segmented-tall span { margin-top: 2px; font: 10px var(--font-mono); color: var(--subtle); }
.segmented-tall button[aria-pressed="true"] span { color: var(--muted); }
.segmented-inline { display: inline-grid; }
.segmented-inline button { min-height: 26px; padding: 2px 12px; font-size: 12px; }

.dimensions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px minmax(0, 1fr);
  align-items: end;
  gap: 6px;
  margin-top: 12px;
}
.dimensions label { font-size: 11px; color: var(--muted); }
.dimensions input,
.unit-input input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font: 13px var(--font-mono);
  color: var(--fg);
  transition: border-color 0.15s;
}
.dimensions input:hover,
.unit-input input:hover { border-color: var(--subtle); }
.dimensions input:focus,
.unit-input input:focus { outline: none; border-color: var(--fg); }

.lock {
  display: grid;
  place-items: center;
  height: 33px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--subtle);
}
.lock svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}
.lock:hover { background: var(--soft); }
.lock[aria-pressed="true"] { color: var(--fg); }
.lock[aria-pressed="false"] svg { opacity: 0.55; stroke-dasharray: 3 3; }

/* Select */
.select { position: relative; }
.select::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.select select {
  appearance: none;
  width: 100%;
  padding: 9px 32px 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 14px;
  cursor: pointer;
}
.select select:hover { border-color: var(--subtle); }

/* Range */
.range-field { margin-top: 14px; }
.range-field:first-of-type { margin-top: 0; }
.select + .range-field { margin-top: 16px; }
.range-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
}
.range-head output { font: 12px var(--font-mono); color: var(--fg); }
input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 22px;
  margin: 6px 0 0;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(var(--fg), var(--fg)) 0 / var(--fill, 50%) 100% no-repeat, var(--border);
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 99px; background: var(--border); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 99px; background: var(--fg); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: var(--fg);
  box-shadow: 0 0 0 1px var(--fg);
  transition: transform 0.15s;
}
input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: var(--fg);
  box-shadow: 0 0 0 1px var(--fg);
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.15); }
.range-labels {
  display: flex;
  justify-content: space-between;
  font: 10px var(--font-mono);
  color: var(--subtle);
}

/* Switch rows */
.switch-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  font-size: 13px;
  cursor: pointer;
}
.switch-row + .switch-row { margin-top: 14px; }
.switch-row small {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--muted);
}
.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 32px;
  height: 19px;
  margin: 1px 0 0;
  border-radius: 99px;
  background: var(--border);
  cursor: pointer;
  transition: background-color 0.2s;
}
.switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s var(--ease);
}
.switch:checked { background: var(--fg); }
.switch:checked::before { transform: translateX(13px); }
.switch:disabled { opacity: 0.4; cursor: not-allowed; }
.switch-row:has(.switch:disabled) { cursor: default; }

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}
.field-row + .field-row { margin-top: 12px; }
.unit-input { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.unit-input input { width: 62px; margin: 0; text-align: center; }

#resetAdjust { margin-top: 14px; }

/* Stage ------------------------------------------------------------------ */

.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 24px clamp(20px, 2.6vw, 36px) 16px;
  background: var(--soft);
}

.stage-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}
.stage-head .eyebrow { margin-bottom: 6px; }
.stage-title { min-width: 0; flex: 1; }
.title-input {
  width: 100%;
  margin: 0 0 0 -6px;
  padding: 2px 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  font: 600 24px/1.25 var(--font-sans);
  letter-spacing: -0.015em;
  text-overflow: ellipsis;
}
.title-input:hover { border-color: var(--border); }
.title-input:focus { outline: none; border-color: var(--fg); background: var(--bg); }

.stage-tools { display: flex; align-items: center; gap: 10px; flex: none; }

.zoom {
  display: flex;
  align-items: center;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--panel);
}
.zoom button {
  min-width: 28px;
  height: 26px;
  padding: 0 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 17px;
  line-height: 1;
}
.zoom button:hover { background: var(--bg); }
.zoom .zoom-value { min-width: 52px; font: 11px var(--font-mono); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 12px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--bg);
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s, color 0.15s;
}
.chip:hover { border-color: var(--subtle); }
.chip input {
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  place-items: center;
  width: 13px;
  height: 13px;
  margin: 0;
  border: 1.5px solid var(--subtle);
  border-radius: 4px;
}
.chip input:checked { border-color: var(--fg); background: var(--fg); }
.chip input:checked::after {
  content: "";
  width: 5px;
  height: 8px;
  margin-top: -2px;
  border: solid var(--bg);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}
.chip:has(input:checked) { color: var(--fg); border-color: var(--fg); }

.viewer {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: var(--radius-lg);
  background: var(--panel);
  overflow: hidden;
  touch-action: pan-y;
  cursor: grab;
}
.viewer.is-zoomed { touch-action: none; }
.viewer:focus-visible { outline-offset: 3px; border-radius: var(--radius-lg); }
.viewer.is-panning { cursor: grabbing; }
.viewer.is-pointing { cursor: pointer; }
.viewer canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.viewer-empty,
.viewer-busy {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  padding: 24px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}
.viewer-busy {
  inset: auto 16px 16px auto;
  padding: 6px 12px;
  border-radius: 99px;
  background: var(--ink);
  color: var(--bg);
  font-size: 12px;
}

.stage-status {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 36px;
  padding-top: 10px;
  font-size: 12px;
  color: var(--muted);
}
.hover-info { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.highlight-info {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 10px 3px 4px;
  border-radius: 99px;
  background: var(--bg);
  color: var(--fg);
  white-space: nowrap;
}
.highlight-info i { width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); }
.highlight-info .link-button { font-size: 12px; }
.stage-hint { margin-left: auto; color: var(--subtle); white-space: nowrap; }

/* Materials -------------------------------------------------------------- */

.pill {
  flex: none;
  padding: 4px 9px;
  border-radius: 99px;
  background: var(--card);
  font: 12px var(--font-mono);
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 22px 0 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--border);
}
.stats div { padding: 10px 12px; background: var(--soft); }
.stats dt { font-size: 11px; color: var(--muted); }
.stats dd { margin: 2px 0 0; font: 600 14px/1.3 var(--font-mono); letter-spacing: -0.02em; }

.progress { margin-top: 14px; }
.progress-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.progress-bar { height: 6px; margin-top: 6px; border-radius: 99px; background: var(--panel); overflow: hidden; }
.progress-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--fg); transition: width 0.3s var(--ease); }

.materials-hint { margin: 16px 0 6px; font-size: 12px; line-height: 1.6; color: var(--muted); }

.palette-list { flex: 1; margin: 0; padding: 0; list-style: none; }
.palette-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.palette-main {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 6px 8px 2px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
  transition: background-color 0.15s;
}
.palette-main:hover { background: var(--soft); }
.palette-item.is-active .palette-main { background: var(--card); }
.bead-chip {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--bg) 0 22%, rgba(0, 0, 0, 0.12) 23% 27%, transparent 28%), var(--c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12), inset -2px -3px 5px rgba(0, 0, 0, 0.12), inset 2px 2px 4px rgba(255, 255, 255, 0.35);
}
.palette-text { min-width: 0; display: grid; }
.palette-text b {
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.palette-text b span { margin-left: 6px; font-weight: 400; color: var(--muted); }
.palette-text small { font: 10.5px var(--font-mono); color: var(--subtle); }
.palette-count { text-align: right; font: 12px/1.3 var(--font-mono); }
.palette-count small { display: block; font-size: 10px; color: var(--subtle); }

.done-toggle {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-left: 4px;
  padding: 0;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: transparent;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.done-toggle svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.done-toggle:hover { border-color: var(--fg); color: var(--subtle); }
.done-toggle[aria-pressed="true"] { border-color: var(--fg); background: var(--fg); color: var(--bg); }
.palette-item.is-done .palette-text b { text-decoration: line-through; text-decoration-color: var(--subtle); color: var(--muted); }
.palette-item.is-done .bead-chip { opacity: 0.45; }

.actions {
  position: sticky;
  bottom: 0;
  display: grid;
  gap: 8px;
  margin: 0 -24px;
  padding: 16px 24px 20px;
  background: linear-gradient(transparent, var(--bg) 18px);
}
.actions .button { width: 100%; }
.actions .link-button { justify-self: center; margin-top: 4px; }

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

.footer {
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 24px var(--gutter);
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}
.footer-mark { font-family: var(--font-mono); color: var(--fg); }
.footer a { color: var(--fg); text-underline-offset: 3px; }
body.in-workspace .footer { border-top: 0; }

/* Overlays --------------------------------------------------------------- */

.drop-overlay {
  position: fixed;
  inset: 12px;
  z-index: 50;
  display: grid;
  place-items: center;
  border: 2px dashed var(--fg);
  border-radius: var(--radius-xl);
  background: rgba(250, 249, 246, 0.92);
  pointer-events: none;
}
.drop-overlay p { font: 600 22px var(--font-sans); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  opacity: 0;
  transform: translate(-50%, 16px);
  transition: opacity 0.2s, transform 0.25s var(--ease);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.print-root { display: none; }

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

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 290px minmax(0, 1fr);
    grid-template-rows: calc(100dvh - var(--topbar-h)) auto;
    height: auto;
  }
  .materials {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--border);
    overflow: visible;
    padding-bottom: 8px;
  }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .palette-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); column-gap: 24px; }
  .actions { position: static; grid-template-columns: 1fr 1fr auto; align-items: center; margin: 8px 0 0; padding: 16px 0 20px; background: none; }
  .actions .link-button { margin: 0 8px; }
  .stage-hint { display: none; }
}

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 40px; min-height: 0; padding: 48px 0; }
  .preset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .preset-meta { padding: 0 46px 14px 14px; }
  .preset-meta span { white-space: normal; }
  .preset-download { right: 10px; bottom: 12px; display: grid; place-items: center; width: 30px; height: 30px; padding: 0; font-size: 13px; }
  .preset-download span { display: none; }
  .preset-grid.is-wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-head { flex-direction: column; align-items: flex-start; gap: 12px; }
  .hero-art { aspect-ratio: 1 / 0.8; }
  .features { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  :root { --gutter: 18px; --topbar-h: 56px; }
  .tagline { display: none; }
  .brand { font-size: 17px; }
  .hero h1 { font-size: clamp(36px, 10vw, 48px); }
  .intro { font-size: 18px; }
  .hero-actions .button { flex: 1; min-width: 0; }

  .workspace { display: flex; flex-direction: column; height: auto; min-height: 0; }
  .stage { order: -1; padding: 18px var(--gutter) 10px; }
  .viewer { flex: none; height: var(--viewer-h, min(68vh, 560px)); min-height: 280px; }
  .stage-head { flex-wrap: wrap; align-items: flex-start; }
  .stage-tools { width: 100%; justify-content: space-between; }
  .title-input { font-size: 20px; }
  .panel { overflow: visible; padding: 24px var(--gutter); }
  .controls { border-right: 0; border-bottom: 1px solid var(--border); }
  .materials { border-top: 0; }
  .stats { grid-template-columns: 1fr 1fr; }
  .palette-list { grid-template-columns: 1fr; }
  .actions { grid-template-columns: 1fr; }
  .footer { flex-wrap: wrap; }
  .sheet { width: 100%; max-height: calc(100dvh - 32px); margin: auto 0 0; border-radius: 20px 20px 0 0; }
  .sheet[open] { animation-name: sheet-up; }
  .sheet-body { max-height: calc(100dvh - 32px); padding: 26px 18px 24px; }
  .sheet-close { top: 12px; right: 12px; }
  .sheet-head { padding-right: 40px; }
  .preset-grid.is-wide { grid-template-columns: 1fr; }
  .collection-grid { grid-template-columns: 1fr; }
}
@keyframes sheet-up { from { transform: translateY(100%); } }

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

/* Print: only the pages assembled in #printRoot ------------------------- */

@media print {
  @page { size: A4 portrait; margin: 10mm; }
  body.has-print { display: block; min-height: 0; background: #fff; }
  body.has-print > *:not(.print-root) { display: none !important; }
  body.has-print .print-root { display: block; color: #191815; font-family: var(--font-sans); }
  .print-page { break-after: page; page-break-after: always; }
  .print-page:last-child { break-after: auto; page-break-after: auto; }
  .print-page canvas { display: block; }
  .print-page h1 { margin: 0 0 4mm; font-size: 20pt; line-height: 1.15; }
  .print-page h2 { margin: 0; font-size: 11pt; }
  .print-meta { margin: 0 0 6mm; font-size: 9.5pt; color: #5d5751; }
  .print-note { margin: 4mm 0 0; font-size: 8.5pt; color: #5d5751; }
  .print-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 6mm; margin-bottom: 4mm; }
  .print-head p { margin: 1mm 0 0; font-size: 8.5pt; color: #5d5751; }
  .print-overview { margin: 0 0 6mm; }
  .print-key { columns: 3; column-gap: 6mm; margin: 2mm 0 0; padding: 0; list-style: none; font-size: 9pt; }
  .print-key li { display: flex; align-items: center; gap: 2mm; padding: 1.1mm 0; border-bottom: 0.2mm solid #e2ded9; break-inside: avoid; }
  .print-key i { flex: none; width: 4mm; height: 4mm; border-radius: 50%; border: 0.2mm solid rgba(0, 0, 0, 0.25); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-key b { min-width: 9mm; }
  .print-key span { flex: 1; color: #5d5751; }
  .print-key em { font-style: normal; font-family: var(--font-mono); }
  .print-key.compact { columns: 4; font-size: 8pt; margin-top: 4mm; }
  .print-page canvas { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
