/* A painter's studio: the page is a dull neutral gray, like a gray glass palette, so colors
   are judged against a neutral surround, never a warm or bright one. Light mode is Munsell
   value 7 (CIELAB L* 70), dark mode value 3 (L* 30). Every gray here is neutral, and the
   muted text grays are the lightest (or darkest) that still read at 4.5:1 on the page.
   --tint is the most colorful main color of the current image (set by app.js); it's only
   decoration, so it never has to carry text contrast on its own. */
@property --tint { syntax: "<color>"; inherits: true; initial-value: #b4532a; }

:root {
  --bg: #ababab; /* value 7 */
  --surface: #b9b9b9; /* 7.5 */
  --raised: #c6c6c6; /* 8 */
  --sunk: #a2a2a2;
  --ink: #0f0f0f;
  --mut: #383838;
  --line: #949494;
  --line-strong: #777777;
  --accent: #1c1c1c;
  --accent-ink: #e8e8e8;
  --error: #7a1e10;
  --mat: #c6c6c6; /* the image's mat: value 8, a step lighter than the page */
  --tint-strong: color-mix(in oklab, var(--tint), var(--ink) 22%);
  --tint-soft: color-mix(in oklab, var(--tint) 14%, var(--surface));
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.1), 0 10px 30px -8px rgba(0, 0, 0, 0.18);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.1), 0 22px 48px -14px rgba(0, 0, 0, 0.35);
  --grain-opacity: 0.25;
  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  color-scheme: light;
  transition: --tint 0.6s ease;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #474747; /* value 3 */
    --surface: #3d3d3d;
    --raised: #525252; /* 3.5 */
    --sunk: #393939;
    --ink: #f2f2f2;
    --mut: #c8c8c8;
    --line: #5c5c5c;
    --line-strong: #727272;
    --accent: #ececec;
    --accent-ink: #1c1c1c;
    --error: #f0a493;
    --mat: #3b3b3b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px -8px rgba(0, 0, 0, 0.45);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.3), 0 22px 48px -14px rgba(0, 0, 0, 0.6);
    --grain-opacity: 0.15;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
/* A faint neutral grain over the whole page, under everything. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.3 0 0 0 0 0.3 0 0 0 0 0.3 0 0 0 0.22 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
a { color: inherit; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
code { font-family: var(--mono); font-size: 0.88em; }
kbd { display: inline-block; min-width: 1.6em; padding: 0 0.4em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); font: 600 0.78em/1.5 var(--sans); text-align: center; color: var(--mut); }
.mut { color: var(--mut); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- header ---------- */

.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 14px 28px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(12px) saturate(1.2); }
.brand { display: flex; align-items: center; gap: 11px; }
.brand h1 { margin: 0; font: 600 24px/1 var(--serif); font-variation-settings: "opsz" 72; letter-spacing: -0.02em; }
/* Three dabs of paint, recolored from the image. */
.mark { position: relative; width: 28px; height: 24px; }
.mark i { position: absolute; border-radius: 52% 48% 55% 45% / 48% 55% 45% 52%; box-shadow: inset 0 -2px 3px rgba(0, 0, 0, 0.18), inset 0 1px 2px rgba(255, 255, 255, 0.35); transition: background-color 0.6s ease; }
.mark i:nth-child(1) { left: 0; top: 4px; width: 15px; height: 15px; background: #bc002d; }
.mark i:nth-child(2) { left: 12px; top: 0; width: 12px; height: 12px; background: #e6c74f; }
.mark i:nth-child(3) { left: 14px; top: 11px; width: 13px; height: 13px; background: #865d22; }
.top-actions { margin-left: auto; display: flex; gap: 8px; }

main { max-width: 1360px; margin: 0 auto; padding: 28px; }

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

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 17px; border-radius: 999px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font: 600 14px var(--sans); text-decoration: none; cursor: pointer; white-space: nowrap; transition: transform 0.15s var(--ease), border-color 0.15s, background-color 0.15s, box-shadow 0.15s; }
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn.ghost { background: var(--raised); color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--line-strong); }
.btn.sm { height: 32px; padding: 0 13px; font-size: 13px; gap: 6px; }
.btn.sm .ic { width: 15px; height: 15px; }
.icon-btn { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 6px; background: transparent; color: inherit; cursor: pointer; }
.icon-btn:hover { background: var(--sunk); }

/* ---------- empty state ---------- */

.empty { max-width: 780px; margin: 6vh auto 0; text-align: center; animation: rise 0.5s var(--ease) both; }
.hero h2 { margin: 0; font: 500 clamp(36px, 6vw, 62px)/1.02 var(--serif); font-variation-settings: "opsz" 144; letter-spacing: -0.035em; }
.hero h2 em { font-style: italic; font-weight: 450; color: var(--tint-strong); }
.hero p { margin: 16px auto 32px; max-width: 520px; color: var(--mut); font-size: 17px; }
.drop { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; padding: 60px 24px; border: 1.5px dashed var(--line-strong); border-radius: 22px; background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; transition: border-color 0.2s, transform 0.2s var(--ease), box-shadow 0.2s; }
.drop:hover { border-color: var(--tint-strong); box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.drop-icon { display: grid; place-items: center; width: 60px; height: 60px; margin-bottom: 10px; border-radius: 48% 52% 46% 54% / 55% 45% 55% 45%; background: radial-gradient(circle at 30% 25%, #f6b46b, #d9583b 50%, #7a2e4b); color: #fff; box-shadow: 0 10px 24px -6px rgba(217, 88, 59, 0.55); }
.drop-icon .ic { width: 28px; height: 28px; }
.drop-title { font: 550 21px var(--serif); letter-spacing: -0.01em; }
.drop-sub { color: var(--mut); font-size: 14px; }
.samples { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-top: 36px; font-size: 14px; }
.sample-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; }
.sample { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0; border: 0; background: none; color: var(--ink); font: italic 500 15px var(--serif); cursor: pointer; }
.sample img { display: block; width: 110px; height: 133px; object-fit: cover; border: 6px solid var(--mat); border-radius: 3px; box-shadow: var(--shadow); transition: transform 0.25s var(--ease), box-shadow 0.25s; }
.sample:hover img { transform: translateY(-3px) rotate(-1.2deg); box-shadow: var(--shadow-lift); }
.privacy { display: inline-flex; align-items: center; gap: 8px; margin: 44px 0 0; color: var(--mut); font-size: 13px; }
.privacy .ic { width: 16px; height: 16px; }

.drop-overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; background: color-mix(in srgb, var(--bg) 75%, transparent); backdrop-filter: blur(6px); opacity: 0; pointer-events: none; transition: opacity 0.15s; }
.drop-overlay div { display: grid; place-items: center; width: 100%; height: 100%; border: 3px dashed var(--tint-strong); border-radius: 28px; font: 500 32px var(--serif); letter-spacing: -0.02em; }
body.dragging .drop-overlay { opacity: 1; }

/* ---------- workspace ---------- */

.tabbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin: -6px 0 26px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 6px; align-self: stretch; }
.paint-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; color: var(--mut); font-size: 13px; font-weight: 600; }
.paint-pick .pick { display: inline-flex; align-items: center; gap: 10px; }
.tabs button { display: inline-flex; align-items: center; gap: 9px; margin-bottom: -1px; padding: 10px 14px 12px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--mut); font: 500 19px var(--serif); letter-spacing: -0.01em; cursor: pointer; transition: color 0.15s, border-color 0.3s; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--tint-strong); }
.tabs kbd { font-family: var(--sans); font-size: 10px; opacity: 0.8; }

.work { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 40px; align-items: start; }
.figure { position: sticky; top: 92px; margin: 0; }
/* The picture hangs in a mat. */
.frame { width: fit-content; max-width: 100%; margin: 0 auto; padding: clamp(8px, 1.4vw, 16px); border-radius: 4px; background: var(--mat); box-shadow: var(--shadow-lift), inset 0 0 0 1px rgba(0, 0, 0, 0.08); }
.figure canvas { display: block; max-width: 100%; max-height: calc(100vh - 250px); border-radius: 1px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06); cursor: crosshair; touch-action: manipulation; }
.figure canvas.enter { animation: develop 0.6s var(--ease) both; }
.figure figcaption { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 14px; margin-top: 14px; color: var(--mut); font-size: 13px; text-align: center; }
/* The original and the painted image side by side in one mat, each labeled below. */
.pair { display: flex; gap: clamp(8px, 1.4vw, 16px); }
.pair .half { flex: 0 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pair .label { color: var(--mut); font: italic 13px var(--serif); line-height: 1.2; }
#caption { font: italic 14px var(--serif); }

.side { min-width: 0; display: grid; gap: 16px; }
.strip-wrap { position: relative; }
.bar { display: flex; height: 28px; border-radius: 6px; overflow: hidden; background: var(--sunk); box-shadow: inset 0 0 0 1px var(--line); }
.bar > div { min-width: 1px; transition: opacity 0.2s, flex-grow 0.2s; }
.bar > div:not(.rest) { cursor: pointer; }
.bar > .rest { flex: 1; cursor: default; background: repeating-linear-gradient(45deg, transparent 0 4px, var(--line) 4px 5px); }
.bar.focusing > div:not(.hot):not(.rest) { opacity: 0.25; }
.strip { height: 72px; border-radius: 14px; box-shadow: var(--shadow), inset 0 0 0 1px rgba(0, 0, 0, 0.06); }
.progress { position: absolute; left: 14px; right: 14px; bottom: -7px; height: 3px; border-radius: 3px; overflow: hidden; opacity: 0; transition: opacity 0.2s; }
.progress::after { content: ""; position: absolute; inset: 0; width: 40%; border-radius: inherit; background: var(--tint-strong); animation: slide 1s ease-in-out infinite; }
.side.busy .progress { opacity: 1; }
.side.busy .list, .side.busy .strip { opacity: 0.55; }
.list, .strip { transition: opacity 0.2s; }

.summary { display: flex; justify-content: space-between; gap: 12px; margin: -4px 2px 0; color: var(--mut); font-size: 13px; }
.busy { color: var(--ink); }

.exports { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 4px; }

.controls { display: grid; gap: 18px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.control-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; font-weight: 600; }
.control:first-child .control-head label { font: 550 18px var(--serif); letter-spacing: -0.01em; }
.control-head output { color: var(--mut); font: 500 12px var(--mono); }
.control input[type="range"] { width: 100%; margin: 8px 0 0; accent-color: var(--tint-strong); cursor: pointer; }
.ends { display: flex; justify-content: space-between; margin-top: 2px; color: var(--mut); font-size: 11px; letter-spacing: 0.07em; text-transform: uppercase; }
.hint { margin: 4px 0 0; color: var(--mut); font-size: 12px; }

.listbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.list-title { flex: 1 0 100%; margin: 0 0 2px; font: 550 22px var(--serif); letter-spacing: -0.015em; }
.list-title .mut { font: italic 400 15px var(--serif); letter-spacing: 0; }
.list-head { flex: 1 0 100%; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.list-head .list-title { flex: 1 1 auto; }
/* Share: copies a link that opens this section with this picture. */
.share { margin-left: auto; }
.figure figcaption .share { margin-left: 0; }
[data-section] { scroll-margin-top: 16px; }
.seg { display: inline-flex; padding: 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--sunk); }
.seg + .seg { margin-left: auto; }
.seg button { padding: 5px 11px; border: 0; border-radius: 999px; background: transparent; color: var(--mut); font: 600 12px var(--sans); cursor: pointer; transition: background-color 0.15s, color 0.15s; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--raised); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18); }

/* ---------- swatches and recipes ---------- */

/* The image's color; once mixed, the mix fills the lower right half. */
.sw { --got: var(--want); position: relative; display: grid; place-items: center; flex: none; width: 46px; height: 46px; padding: 0; border: 0; border-radius: 12px; background: linear-gradient(135deg, var(--want) 50%, var(--got) 50%); box-shadow: inset 0 0 0 1px rgba(127, 127, 127, 0.28); transition: transform 0.2s var(--ease); }
button.sw { cursor: pointer; }
button.sw:hover { transform: scale(1.06); }
.dot { display: inline-block; width: 10px; height: 10px; margin-right: 5px; border-radius: 50%; vertical-align: -1px; box-shadow: inset 0 0 0 1px rgba(127, 127, 127, 0.35); }
.paint { white-space: nowrap; }
.prop { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--sunk); }
.prop i { flex-basis: 0; min-width: 2px; }
.prop i + i { box-shadow: -1px 0 0 var(--surface); }
.far { color: var(--error); }

.list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.list li { animation: rise 0.35s var(--ease) both; animation-delay: calc(var(--i, 0) * 18ms); }
.list.settled li { animation: none; }
.row { display: grid; grid-template-columns: 50px minmax(0, 1fr) auto; align-items: center; gap: 14px; width: 100%; padding: 8px 12px 8px 8px; border: 0; border-radius: 14px; background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; transition: background-color 0.15s, box-shadow 0.15s; }
.row:hover, .row:focus-visible, li.hot .row { background: var(--raised); box-shadow: 0 0 0 1px var(--line), var(--shadow); }
.row:focus-visible { outline-offset: 0; }
.row .sw { width: 50px; height: 50px; border-radius: 13px; }
.row:hover .sw { transform: scale(1.05); }
.sw .ic { width: 22px; height: 22px; stroke-width: 2.4; opacity: 0; transform: scale(0.5); transition: opacity 0.15s, transform 0.25s var(--ease); }
.copied .sw .ic { opacity: 1; transform: none; }
.val { display: grid; gap: 6px; min-width: 0; }
.recipe { font-size: 14px; font-weight: 600; line-height: 1.35; }
.pending .recipe { font-weight: 400; color: var(--mut); }
.pending .prop { background: linear-gradient(100deg, var(--sunk) 30%, var(--surface) 50%, var(--sunk) 70%) 0 0 / 300% 100%; animation: shimmer 1.4s linear infinite; }
.code { overflow: hidden; color: var(--mut); font: 11.5px var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.pct { align-self: start; padding-top: 2px; font: 600 13px var(--mono); font-variant-numeric: tabular-nums; text-align: right; }

/* ---------- inspector, toast ---------- */

.peek { position: fixed; z-index: 40; left: 0; top: 0; display: flex; align-items: center; gap: 9px; max-width: 360px; padding: 6px 12px 6px 6px; border-radius: 14px; background: var(--raised); box-shadow: 0 0 0 1px var(--line), var(--shadow-lift); font-size: 13px; pointer-events: none; opacity: 0; transition: opacity 0.12s; }
.peek.on { opacity: 1; }
/* What a step in a mixing tree asks for, over its arrow. */
.tip { position: fixed; z-index: 40; left: 0; top: 0; display: grid; gap: 4px; max-width: min(340px, calc(100vw - 16px)); padding: 9px 12px; border-radius: 12px; background: var(--raised); box-shadow: 0 0 0 1px var(--line), var(--shadow-lift); font-size: 13px; line-height: 1.4; pointer-events: none; opacity: 0; transition: opacity 0.12s; }
.tip.on { opacity: 1; }
.tip b { font-weight: 600; }
.tip span { color: var(--mut); font-size: 12.5px; }
.step[data-tip] { cursor: help; }
.how:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.peek .sw { width: 30px; height: 30px; border-radius: 8px; }
.peek .mixv { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.peek .v { font-weight: 600; }
.peek .prop:empty { display: none; }
.peek .p { color: var(--mut); font: 12px var(--mono); font-variant-numeric: tabular-nums; }

.toast { position: fixed; z-index: 60; left: 50%; bottom: 28px; display: flex; align-items: center; gap: 10px; padding: 10px 18px 10px 10px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font: 600 14px var(--sans); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25); transform: translate(-50%, 16px) scale(0.96); opacity: 0; pointer-events: none; transition: opacity 0.18s, transform 0.3s var(--ease); }
.toast.on { opacity: 1; transform: translate(-50%, 0) scale(1); }
.toast .chip { width: 24px; height: 24px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(127, 127, 127, 0.4); }
.toast.plain { padding-left: 18px; }
.toast.plain .chip { display: none; }

.error { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 780px; margin: 24px auto; padding: 10px 10px 10px 16px; border: 1px solid var(--line); border-left: 4px solid var(--error); border-radius: 12px; background: var(--surface); color: var(--error); }

/* ---------- simplify ---------- */

.steps-intro { max-width: 760px; margin: 0 0 22px; font-size: 14px; }
.strings { margin: 0 0 44px; padding-bottom: 36px; border-bottom: 1px solid var(--line); }
.strings-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin-bottom: 8px; }
.strings-head h3, .steps-title { margin: 0; font: 550 28px var(--serif); letter-spacing: -0.02em; }
.strings-head .mut { flex: 1; font-size: 13px; }
/* One row per mixing tree, biggest first. */
.strings-list { margin: 0; padding: 0; list-style: none; }
.strings-list:empty { display: none; }
.tree { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: start; gap: 8px 16px; padding: 12px 2px 4px; border-top: 1px solid var(--line); animation: rise 0.3s var(--ease) both; }
.tree .amount { padding-top: 6px; }
.amount { display: grid; gap: 6px; }
.amount b { font: 600 15px var(--mono); font-variant-numeric: tabular-nums; }
.meter { height: 5px; border-radius: 3px; background: var(--sunk); overflow: hidden; }
.meter i { display: block; height: 100%; min-width: 2px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(127, 127, 127, 0.28); }
/* A tree reads left to right: tubes, then piles joined by steps. A wide one scrolls inside
   its own row. Lines meet at the middle of the swatches, --mid from the top of a row. */
.graph-scroll { min-width: 0; overflow-x: auto; padding-bottom: 6px; }
.graph { --mid: 18px; --trunk: 8px; --edge: var(--mut); display: grid; width: max-content; align-items: start; }
.tree-body { display: flex; align-items: flex-start; min-width: 0; }
.tree-body .graph-scroll { flex: 1; }
.tree .tubes { display: grid; flex: none; gap: 1px; min-height: 36px; align-content: center; padding-right: 6px; font-size: 13px; font-weight: 600; line-height: 1.35; white-space: nowrap; }
.step { position: relative; align-self: stretch; min-width: 44px; padding: 0 14px 0 18px;
  background: linear-gradient(var(--edge), var(--edge)) no-repeat; background-size: 0 0; }
.step.up { background-size: 1.5px calc(var(--mid) + 1px); background-position: var(--trunk) 0; }
.step.down { background-size: 1.5px calc(100% - var(--mid)); background-position: var(--trunk) var(--mid); }
.step.up.down { background-size: 1.5px 100%; background-position: var(--trunk) 0; }
.step.in::before, .step.elbow::before { content: ""; position: absolute; left: 0; right: 5px; top: calc(var(--mid) - 0.75px); height: 1.5px; background: var(--edge); }
.step.elbow::before { left: var(--trunk); }
.step.in::after, .step.elbow::after { content: ""; position: absolute; right: 0; top: calc(var(--mid) - 4px); border: 4px solid transparent; border-right: 0; border-left: 6px solid var(--edge); }
.how { display: grid; grid-template-rows: calc(var(--mid) - 1px) auto; justify-items: center; font: 500 10.5px/1.25 var(--mono); }
.how .what { display: flex; align-items: center; gap: 4px; align-self: end; max-width: 150px; overflow: hidden; color: var(--mut); font: 600 11px/1.2 var(--sans); white-space: nowrap; text-overflow: ellipsis; }
.how .parts { padding-top: 4px; color: var(--ink); font-weight: 600; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.pile { display: grid; justify-items: center; gap: 2px; padding-bottom: 12px; color: var(--mut); font: 500 10.5px/1.3 var(--mono); font-variant-numeric: tabular-nums; }
.pile .sw { width: 48px; height: 36px; border-radius: 8px; font: 600 11px var(--mono); }
.pile.lead .share { color: var(--ink); font-weight: 700; }
/* Not in the picture: a base, or an in-between pile that evens out the steps. */
.pile.between .sw { box-shadow: none; outline: 1.5px dashed var(--mut); outline-offset: -1.5px; }
.pile.between .share { font-style: italic; }
.minor { margin-top: 6px; border-top: 1px solid var(--line); }
.minor summary { padding: 10px 2px; color: var(--mut); font-size: 13px; cursor: pointer; }
.minor summary:hover { color: var(--ink); }

.steps { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 40px 28px; align-items: start; }
.step { margin: 0; animation: rise 0.4s var(--ease) both; }
.step { --matw: clamp(6px, 1vw, 10px); }
.step canvas { display: block; width: 100%; height: auto; border: var(--matw) solid var(--mat); border-radius: 3px; background: var(--surface); box-shadow: var(--shadow-lift); }
.step.pending canvas { background: linear-gradient(100deg, var(--sunk) 30%, var(--surface) 50%, var(--sunk) 70%) 0 0 / 300% 100%; animation: shimmer 1.4s linear infinite; }
.step figcaption { display: flex; align-items: center; gap: 10px; margin: 14px 0 8px; font-size: 14px; }
.step figcaption b { font: 550 19px var(--serif); letter-spacing: -0.01em; }
.step figcaption .note { flex: 1; color: var(--mut); font: 12px var(--mono); }
.step .bar { height: 24px; border-radius: 8px; }
.paints { display: flex; flex-wrap: wrap; gap: 6px 14px; max-width: 760px; margin: -8px 0 28px; color: var(--mut); font-size: 12px; }
.mixes { margin-top: 16px; }
.mixes h4 { margin: 0 0 10px; color: var(--mut); font-size: 11px; font-weight: 650; letter-spacing: 0.07em; text-transform: uppercase; }
.mixes ol { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.mix { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; animation: rise 0.3s var(--ease) both; }
.mix .sw { width: 40px; height: 40px; border-radius: 10px; }
.how { display: grid; gap: 4px; min-width: 0; font-size: 13px; }
.parts { font-weight: 600; }
.mix.pending .parts { font-weight: 400; color: var(--mut); }
.meta { color: var(--mut); font: 12px var(--mono); }

/* Tubes to put out: the tubes the strings use, the tubes you have as switches, then every
   count of tubes to pick from, with a preview of the picture mixed from it. */
.fewest .steps-intro:first-of-type { margin-bottom: 14px; }
.fewest .sub { margin: 32px 0 6px; color: var(--mut); font-size: 11px; font-weight: 650; letter-spacing: 0.07em; text-transform: uppercase; }
.fewest .sub + .steps-intro { margin-bottom: 12px; }
.tube-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tube { display: inline-flex; align-items: center; gap: 2px; padding: 6px 12px 6px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font: 600 14px var(--sans); }
.tube .dot { width: 14px; height: 14px; margin-right: 6px; }
.tube.touchup { font-weight: 400; color: var(--mut); border-style: dashed; }
.tube.toggle { padding: 4px 10px 4px 8px; font-size: 13px; cursor: pointer; transition: opacity 0.15s, border-color 0.15s; }
.tube.toggle:hover { border-color: var(--ink); }
.tube.toggle[aria-pressed="false"] { background: transparent; color: var(--mut); font-weight: 400; text-decoration: line-through; opacity: 0.7; }
.tube.toggle[aria-pressed="false"] .dot { opacity: 0.35; }
.fewest-pick { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; gap: 20px 32px; }
.sizes { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.size { display: grid; grid-template-columns: 92px minmax(0, 1fr) 150px; align-items: center; gap: 4px 14px; width: 100%; padding: 8px 10px; border: 1px solid transparent; border-top-color: var(--line); border-radius: 6px; background: none; color: var(--ink); font: 13px var(--sans); text-align: left; cursor: pointer; }
.size:hover, .size.shown { background: var(--surface); }
.size[aria-pressed="true"] { border-color: var(--ink); background: var(--surface); }
.size .k { display: grid; }
.size .k b { font-weight: 650; }
.size .k em { color: var(--mut); font: italic 12px var(--serif); }
.size .names { color: var(--mut); line-height: 1.35; }
.size[aria-pressed="true"] .names { color: var(--ink); }
.size .m { display: grid; grid-template-columns: minmax(0, 1fr) 40px; align-items: center; gap: 8px; }
.size .m b { font: 600 13px var(--mono); text-align: right; }
.size .meter i { background: var(--ink); }
.size .hv { grid-column: 3; color: var(--mut); font: 11px var(--mono); }
.fewest-preview { position: sticky; top: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fewest-preview figure { margin: 0; }
.fewest-preview { --matw: 6px; }
.fewest-preview canvas { display: block; width: 100%; height: auto; border: var(--matw) solid var(--mat); border-radius: 3px; background: var(--surface); box-shadow: var(--shadow-lift); }
.fewest-preview figcaption { margin-top: 8px; color: var(--mut); font: italic 13px var(--serif); text-align: center; }


/* ---------- values ---------- */

.value-range { display: grid; grid-template-columns: minmax(0, 460px) minmax(0, 1fr); align-items: end; gap: 16px 32px; margin: 0 0 36px; }
.value-scale { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 3px; }
.vcol { display: grid; gap: 4px; }
.vbar { display: flex; align-items: flex-end; height: 56px; }
.vbar i { width: 100%; min-height: 1px; border-radius: 3px 3px 0 0; background: var(--mut); opacity: 0.55; }
.vchip { display: grid; place-items: center; height: 30px; border-radius: 6px; font: 600 12px var(--mono); box-shadow: inset 0 0 0 1px rgba(127, 127, 127, 0.28); }
#valueSummary { max-width: 440px; margin: 0; font-size: 14px; }
.value-studies { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.value-studies canvas { cursor: crosshair; }
.bar.bands { height: 26px; border-radius: 8px; }
.bar.bands > div { display: grid; place-items: center; min-width: 3.2em; overflow: hidden; font: 600 11px var(--mono); white-space: nowrap; cursor: default; }
.bar.bands.many > div { min-width: 3px; }

/* ---------- grid ---------- */

/* Its settings, under the tabs while the grid is on. */
.grid-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin: -12px 0 26px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--mut); font-size: 13px; font-weight: 600; animation: rise 0.25s var(--ease) both; }
.gfield { display: inline-flex; align-items: center; gap: 7px; }
.gfield > span:first-child { margin-right: 3px; }
.grid-bar input[type="number"] { width: 5.2em; height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--raised); color: var(--ink); font: 500 13px var(--mono); font-variant-numeric: tabular-nums; }
.grid-bar input[type="number"]:hover { border-color: var(--line-strong); }
.grid-bar input[type="color"] { width: 34px; height: 30px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--raised); cursor: pointer; }
.gcheck { display: inline-flex; align-items: center; gap: 7px; font-weight: 500; cursor: pointer; }
.gcheck input { margin: 0; accent-color: var(--tint-strong); }
.gunit { font-weight: 500; }
.grid-info { flex: 1 1 260px; margin: 0; font: italic 400 13.5px var(--serif); }

/* The grid sits over each image's picture (inside any mat border) and lets the pointer through. */
.gridded { position: relative; max-width: 100%; line-height: 0; }
.grid-over { position: absolute; inset: var(--matw, 0); width: calc(100% - 2 * var(--matw, 0px)); height: calc(100% - 2 * var(--matw, 0px)); display: none; pointer-events: none; }
.show-grid .grid-over { display: block; }
.grid-over .lines { fill: none; stroke: var(--grid-line, #fff); stroke-width: 1.25px; vector-effect: non-scaling-stroke; }
.grid-over .crop { fill: var(--bg); fill-opacity: 0.72; }

/* ---------- bookmarklet ---------- */

.install { max-width: 780px; margin-top: 72px; padding-top: 32px; border-top: 1px solid var(--line); }
.install h2 { margin: 0; font: 550 28px var(--serif); letter-spacing: -0.02em; }
.install > p.mut { margin: 4px 0 18px; }
.install h3 { margin: 26px 0 6px; font: 550 18px var(--serif); }
.install ol { padding-left: 20px; }
.install li { margin-bottom: 6px; }
.install-row { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; }
.install-row p { margin: 0; }
.bm { height: 46px; padding: 0 22px; font-size: 16px; cursor: grab; box-shadow: var(--shadow); }
.bm.wiggle { animation: wiggle 0.5s ease; }
.nudge { margin: 12px 0 0; padding: 8px 12px; border-radius: 10px; background: var(--sunk); font-size: 14px; animation: rise 0.3s var(--ease) both; }
.install details { margin-top: 16px; }
.install summary { font-weight: 600; cursor: pointer; }
.install textarea { width: 100%; height: 80px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: 11px var(--mono); }

.keys { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 44px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 12px; }

/* ---------- motion ---------- */

@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes develop { from { opacity: 0; filter: saturate(0) blur(6px); transform: scale(0.985); } }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@keyframes shimmer { to { background-position: -300% 0; } }
@keyframes wiggle { 20%, 60% { transform: rotate(-4deg); } 40%, 80% { transform: rotate(4deg); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (hover: none) {
  .hint-pointer { display: none; }
  .keys, .tabs kbd { display: none; }
}

@media (max-width: 960px) {
  .top { padding: 10px 16px; }
  main { padding: 16px; }
  .hide-sm { display: none; }
  .work { grid-template-columns: 1fr; gap: 22px; }
  .figure { position: static; }
  .figure canvas { max-height: 55vh; }
  .strip { height: 56px; }
  .empty { margin-top: 2vh; }
  .drop { padding: 40px 16px; }
}

@media (max-width: 900px) {
  .fewest-pick { grid-template-columns: 1fr; }
  .fewest-preview { position: static; order: -1; }
}

@media (max-width: 640px) {
  .size { grid-template-columns: 76px minmax(0, 1fr); }
  .size .m, .size .hv { grid-column: 2; }

  .tree { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .tree .amount { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; padding-top: 0; }
  .tree-body { flex-direction: column; align-items: stretch; gap: 6px; }
  .tree .tubes { display: flex; flex-wrap: wrap; gap: 1px 12px; min-height: 0; white-space: normal; }
  .step.start { display: none; }
  .value-range { grid-template-columns: 1fr; }
  .paint-pick { order: -1; margin-top: 4px; }
  /* A wide picture stacks the two so each gets the full width. */
  .pair.wide { flex-direction: column; align-items: center; }
  .pair.wide canvas { max-height: 40vh; }
}
