/* =========================================================================
   bgcolor — design system
   Every color token below is overwritten at runtime from the background
   the visitor picks. The values here are only the first-paint defaults.
   ========================================================================= */

:root {
  /* live-themed tokens (JS rewrites these) */
  --bg: #0b1220;
  --surface: #111a2b;
  --surface-2: #162034;
  --surface-3: #1b273e;
  --border: #22304a;
  --border-strong: #2e3f5e;
  --text: #e8edf7;
  --text-muted: #a9b8d1;
  --text-subtle: #74849f;
  --accent: #4c9aff;
  --accent-text: #061020;
  --shadow-color: rgb(0 0 0 / 0.45);

  /* fixed semantics */
  --good: #34d399;
  --ok: #7dd3a0;
  --warn: #fbbf24;
  --bad: #f87171;

  /* type */
  --font-sans: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', SFMono-Regular, 'JetBrains Mono', 'Fira Code', Menlo, Consolas, monospace;

  --step--1: clamp(0.78rem, 0.76rem + 0.1vw, 0.84rem);
  --step-0: clamp(0.95rem, 0.92rem + 0.15vw, 1.02rem);
  --step-1: clamp(1.12rem, 1.05rem + 0.35vw, 1.3rem);
  --step-2: clamp(1.35rem, 1.2rem + 0.7vw, 1.75rem);
  --step-3: clamp(1.7rem, 1.4rem + 1.4vw, 2.5rem);
  --step-4: clamp(2.1rem, 1.5rem + 2.8vw, 3.6rem);
  --step-5: clamp(2.6rem, 1.6rem + 4.6vw, 5rem);

  /* space */
  --sp-1: 0.25rem; --sp-2: 0.5rem; --sp-3: 0.75rem; --sp-4: 1rem;
  --sp-5: 1.5rem; --sp-6: 2rem; --sp-7: 3rem; --sp-8: 4.5rem; --sp-9: 7rem;

  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 24px;
  --shell: 1180px;
  --shell-wide: 1480px;

  --ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  --shadow-1: 0 1px 2px var(--shadow-color);
  --shadow-2: 0 4px 16px -4px var(--shadow-color);
  --shadow-3: 0 24px 60px -20px var(--shadow-color);
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

/* ------------------------------------------------------------- reset */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
}

body {
  min-height: 100svh;
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.45s var(--ease), color 0.45s var(--ease);
  overflow-x: hidden;
}

body.is-locked { overflow: hidden; }

img, svg, video, canvas { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }

h1, h2, h3, h4 { line-height: 1.12; font-weight: 660; letter-spacing: -0.022em; text-wrap: balance; }
h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-1); }
p { text-wrap: pretty; }

a { color: inherit; text-decoration-color: color-mix(in oklab, currentColor 35%, transparent); text-underline-offset: 0.18em; }
a:hover { text-decoration-color: currentColor; }

code, kbd, pre, samp { font-family: var(--font-mono); font-size: 0.9em; }

kbd {
  display: inline-block;
  padding: 0.1em 0.42em;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  font-size: 0.78em;
  line-height: 1.5;
  color: var(--text-muted);
}

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 4px; }

::selection { background: color-mix(in oklab, var(--accent) 40%, transparent); color: var(--text); }

.skip-link {
  position: absolute; left: -9999px; top: var(--sp-3); z-index: 200;
  padding: 0.6rem 1rem; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-text); font-weight: 600;
}
.skip-link:focus { left: var(--sp-4); }

/* ------------------------------------------------------------ layout */

.shell { width: min(100% - 2.5rem, var(--shell)); margin-inline: auto; }
.main-wide .shell { width: min(100% - 2.5rem, var(--shell-wide)); }
.section { padding-block: var(--sp-8); }
.section:first-child { padding-top: var(--sp-7); }

.section-head { max-width: 62ch; margin-bottom: var(--sp-6); }
.section-head h2 { margin-bottom: var(--sp-3); }
.section-head p { color: var(--text-muted); font-size: var(--step-1); }
.section-head.row {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--sp-4); max-width: none; flex-wrap: wrap;
}
.section-head.row p { font-size: var(--step-0); }

.page-head { padding-block: var(--sp-8) var(--sp-5); max-width: 78ch; }
.page-head h1 { margin-bottom: var(--sp-4); }
.eyebrow {
  font-size: var(--step--1); font-weight: 640; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--accent); margin-bottom: var(--sp-3);
}
.lede { font-size: var(--step-1); color: var(--text-muted); max-width: 68ch; }
.muted { color: var(--text-muted); }

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

.site-header {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in oklab, var(--bg) 78%, transparent);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid color-mix(in oklab, var(--border) 70%, transparent);
}
.header-inner {
  display: flex; align-items: center; gap: var(--sp-5);
  height: 62px;
  width: min(100% - 2.5rem, var(--shell-wide));
}
.logo {
  display: inline-flex; align-items: center; gap: 0.55rem;
  font-weight: 700; letter-spacing: -0.03em; font-size: 1.06rem;
  text-decoration: none; flex-shrink: 0;
}
.logo-mark { width: 24px; height: 24px; flex-shrink: 0; }
.logo-accent { color: var(--accent); }
.logo-lockup { display: flex; flex-direction: column; line-height: 1.05; }
.logo-tagline {
  font-size: 0.63rem; font-weight: 560; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--text-subtle);
}
/* The header is tight on a phone; the wordmark alone carries the brand. */
@media (max-width: 560px) { .logo-tagline { display: none; } }

.nav { display: flex; gap: 0.25rem; margin-right: auto; }
.nav-link {
  padding: 0.42rem 0.8rem; border-radius: 999px;
  font-size: 0.92rem; font-weight: 520; color: var(--text-muted);
  text-decoration: none; transition: color 0.18s, background-color 0.18s;
}
.nav-link:hover { color: var(--text); background: var(--surface); }
.nav-link.is-active { color: var(--text); background: var(--surface-2); }

.header-actions { display: flex; align-items: center; gap: var(--sp-2); }
.search-trigger {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.36rem 0.5rem 0.36rem 0.7rem;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text-subtle);
  font-size: 0.86rem; transition: border-color 0.18s, color 0.18s;
}
.search-trigger:hover { border-color: var(--border-strong); color: var(--text-muted); }
.search-trigger kbd { font-size: 0.7rem; }

.nav-toggle { display: none; width: 38px; height: 34px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); padding: 0.5rem 0.55rem; }
.nav-toggle span { display: block; height: 1.5px; background: var(--text); border-radius: 2px; }
.nav-toggle span + span { margin-top: 4px; }

@media (max-width: 860px) {
  .search-trigger-text, .search-trigger kbd { display: none; }
  .search-trigger { padding: 0.5rem; }
  .nav-toggle { display: block; }
  .nav {
    position: absolute; inset: 62px 0 auto; display: none; flex-direction: column;
    padding: var(--sp-3); gap: 0.15rem;
    background: var(--bg); border-bottom: 1px solid var(--border);
  }
  .nav.is-open { display: flex; }
  .nav-link { padding: 0.6rem 0.8rem; }
}

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  padding: 0.58rem 1.05rem;
  border: 1px solid transparent; border-radius: 999px;
  font-size: 0.9rem; font-weight: 570; text-decoration: none; white-space: nowrap;
  transition: transform 0.16s var(--ease), background-color 0.18s, border-color 0.18s, color 0.18s;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: color-mix(in oklab, var(--accent) 86%, var(--text)); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-quiet { background: transparent; color: var(--text-muted); }
.btn-quiet:hover { background: var(--surface); color: var(--text); }
.btn-icon { display: inline-flex; }
.btn[aria-pressed='true'] { background: var(--accent); color: var(--accent-text); border-color: transparent; }

.text-link {
  color: var(--accent); font-weight: 560; text-decoration: none;
  border-bottom: 1px solid color-mix(in oklab, var(--accent) 40%, transparent);
  white-space: nowrap;
}
.text-link:hover { border-bottom-color: var(--accent); }

.pill {
  display: inline-flex; align-items: center; padding: 0.15rem 0.6rem;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); font-size: 0.76rem; font-weight: 600;
  letter-spacing: 0.04em; color: var(--text-muted);
}

.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.18rem 0.55rem; border-radius: 999px;
  font-size: 0.76rem; font-weight: 640; font-family: var(--font-mono);
  border: 1px solid currentColor;
}
.badge.tone-good { color: var(--good); }
.badge.tone-ok { color: var(--ok); }
.badge.tone-warn { color: var(--warn); }
.badge.tone-bad { color: var(--bad); }

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

.tool-grid {
  display: grid; gap: var(--sp-4);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 268px), 1fr));
}
.tool-card {
  position: relative; display: flex; flex-direction: column; gap: 0.4rem;
  padding: var(--sp-5); min-height: 178px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); text-decoration: none;
  transition: transform 0.22s var(--ease), border-color 0.22s, background-color 0.22s;
  overflow: hidden;
}
.tool-card::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 0%), color-mix(in oklab, var(--accent) 13%, transparent), transparent 62%);
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
}
.tool-card:hover { transform: translateY(-3px); border-color: var(--border-strong); background: var(--surface-2); }
.tool-card:hover::after { opacity: 1; }
.tool-card-cat { font-size: 0.72rem; font-weight: 650; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.tool-card-title { font-size: 1.05rem; }
.tool-card-text { color: var(--text-muted); font-size: 0.9rem; flex: 1; }
.tool-card-go { font-size: 0.85rem; font-weight: 600; color: var(--text-subtle); transition: color 0.2s; }
.tool-card:hover .tool-card-go { color: var(--accent); }

.cat-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); }
.cat-card {
  padding: var(--sp-5); border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
  text-decoration: none; transition: border-color 0.2s, transform 0.2s var(--ease);
}
.cat-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.cat-card h3 { margin-bottom: 0.35rem; }
.cat-card p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: var(--sp-3); }
.cat-count { font-size: 0.78rem; font-weight: 650; color: var(--accent); letter-spacing: 0.05em; }

.cta-panel {
  display: grid; gap: var(--sp-5); align-items: center;
  grid-template-columns: 1fr auto;
  padding: var(--sp-7); border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in oklab, var(--accent) 16%, transparent), transparent 60%),
    var(--surface);
}
.cta-panel h2 { margin-bottom: var(--sp-3); }
.cta-panel p { color: var(--text-muted); max-width: 60ch; }
.cta-actions { display: flex; gap: var(--sp-3); flex-wrap: wrap; }
@media (max-width: 760px) { .cta-panel { grid-template-columns: 1fr; padding: var(--sp-5); } }

/* --------------------------------------------------------------- blog */

.post-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 310px), 1fr)); }
.post-card {
  display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); overflow: hidden;
  transition: border-color 0.2s, transform 0.2s var(--ease);
}
.post-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.post-card-link { display: flex; flex-direction: column; gap: 0.5rem; padding: var(--sp-5); text-decoration: none; flex: 1; }
.post-card-swatches { display: flex; height: 7px; border-radius: 999px; overflow: hidden; margin-bottom: 0.4rem; }
.post-card-swatches i { flex: 1; }
.post-card-meta { display: flex; gap: 0.5rem; align-items: center; font-size: 0.78rem; color: var(--text-subtle); font-family: var(--font-mono); flex-wrap: wrap; }
.post-card-title { font-size: 1.08rem; }
.post-card-text { color: var(--text-muted); font-size: 0.9rem; }
.post-card-tags { display: flex; gap: 0.35rem; padding: 0 var(--sp-5) var(--sp-4); flex-wrap: wrap; }
.post-card-tags a {
  min-height: 24px; display: inline-flex; align-items: center;
  font-size: 0.73rem; padding: 0.12rem 0.5rem; border-radius: 999px;
  background: var(--surface-2); color: var(--text-subtle); text-decoration: none;
}
.post-card-tags a:hover { color: var(--accent); }
.post-card.is-compact .post-card-link { padding: var(--sp-4); }

.post-lead {
  display: grid; grid-template-columns: 1.4fr 1fr; gap: var(--sp-6); align-items: stretch;
  padding: var(--sp-6); border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); text-decoration: none; margin-top: var(--sp-4);
  transition: border-color 0.2s;
}
.post-lead:hover { border-color: var(--accent); }
.post-lead-body { display: flex; flex-direction: column; gap: var(--sp-3); justify-content: center; }
.post-lead-body h2 { font-size: var(--step-2); }
.post-lead-body p { color: var(--text-muted); }
.post-lead-art { display: grid; grid-auto-flow: column; border-radius: var(--radius); overflow: hidden; min-height: 180px; }
@media (max-width: 820px) { .post-lead { grid-template-columns: 1fr; } .post-lead-art { min-height: 90px; } }

.tag-row { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: var(--sp-4); }
.tag {
  /* min-height 24px is the WCAG 2.5.8 target floor; these chips sat at 23.1. */
  display: inline-flex; align-items: center; gap: 0.35rem; min-height: 24px;
  padding: 0.3rem 0.7rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 0.8rem; color: var(--text-muted); text-decoration: none;
}
.tag:hover { border-color: var(--accent); color: var(--text); }
.tag span { color: var(--text-subtle); font-family: var(--font-mono); font-size: 0.74rem; }

}

/* -------------------------------------------------------- post layout */

.post-header { padding-block: var(--sp-8) var(--sp-5); max-width: 80ch; }
.post-header h1 { margin-bottom: var(--sp-4); font-size: var(--step-4); }
.post-meta { display: flex; gap: 0.5rem; align-items: center; margin-top: var(--sp-4); font-size: 0.85rem; color: var(--text-subtle); font-family: var(--font-mono); flex-wrap: wrap; }
.post-hero-colors { display: flex; gap: 0.5rem; margin-top: var(--sp-5); flex-wrap: wrap; }
.post-hero-color {
  width: 92px; height: 56px; border-radius: var(--radius-sm);
  border: 1px solid color-mix(in oklab, var(--text) 18%, transparent);
  display: flex; align-items: flex-end; padding: 0.3rem;
  transition: transform 0.18s var(--ease);
}
.post-hero-color:hover { transform: translateY(-3px) scale(1.02); }
.post-hero-color span {
  font-family: var(--font-mono); font-size: 0.66rem; padding: 0.1rem 0.3rem;
  /* 0.7, not 0.45: the scrim has to guarantee white passes over any colour a
     post declares. Over pure white this composites to #4d4d4d — 8.5:1. */
  border-radius: 4px; background: rgb(0 0 0 / 0.7); color: #fff;
}
.post-hero-hint { font-size: 0.8rem; color: var(--text-subtle); margin-top: var(--sp-2); }

.post-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: var(--sp-7); align-items: start; padding-bottom: var(--sp-8); }
@media (max-width: 1000px) { .post-layout { grid-template-columns: minmax(0, 1fr); gap: var(--sp-5); } }

.post-toc { position: sticky; top: 5rem; font-size: 0.86rem; }
.post-toc h2 { font-size: 0.74rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-subtle); margin-bottom: var(--sp-3); }
.post-toc ol { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.1rem; border-left: 1px solid var(--border); }
.post-toc a { display: block; padding: 0.28rem 0 0.28rem 0.85rem; margin-left: -1px; border-left: 2px solid transparent; color: var(--text-subtle); text-decoration: none; }
.post-toc a:hover { color: var(--text); }
.post-toc a.is-current { color: var(--accent); border-left-color: var(--accent); }
@media (max-width: 1000px) { .post-toc { display: none; } }

/* ------------------------------------------------------------- prose */

.prose { max-width: 72ch; min-width: 0; font-size: 1.06rem; line-height: 1.78; }
.prose > * + * { margin-top: 1.15em; }
.prose h2 { font-size: var(--step-2); margin-top: 2.4em; scroll-margin-top: 5rem; }
.prose h3 { font-size: var(--step-1); margin-top: 1.9em; scroll-margin-top: 5rem; }
.prose h4 { font-size: 1.02rem; margin-top: 1.6em; color: var(--text-muted); }
.prose p { color: color-mix(in oklab, var(--text) 90%, var(--text-muted)); }
.prose a { color: var(--accent); text-decoration: underline; text-decoration-color: color-mix(in oklab, var(--accent) 45%, transparent); }
.prose strong { color: var(--text); font-weight: 640; }
.prose ul, .prose ol { padding-left: 1.35em; display: flex; flex-direction: column; gap: 0.5em; }
.prose li { padding-left: 0.2em; }
.prose li::marker { color: var(--accent); }
.prose blockquote {
  border-left: 3px solid var(--accent); padding: 0.1em 0 0.1em 1.2em;
  color: var(--text-muted); font-style: italic;
}
.prose blockquote > * + * { margin-top: 0.8em; }
.prose hr { border: none; height: 1px; background: var(--border); margin-block: 2.4em; }
.prose img { border-radius: var(--radius); border: 1px solid var(--border); }
.prose code { background: var(--surface-2); padding: 0.14em 0.36em; border-radius: 5px; color: var(--text); }
.prose mark { background: color-mix(in oklab, var(--accent) 30%, transparent); color: var(--text); padding: 0.05em 0.2em; border-radius: 3px; }

.anchor {
  margin-left: 0.4em; opacity: 0; color: var(--text-subtle);
  text-decoration: none; font-weight: 400; transition: opacity 0.18s;
}
h2:hover .anchor, h3:hover .anchor, .anchor:focus-visible { opacity: 1; }

.codeblock { position: relative; }
.codeblock pre {
  overflow-x: auto; padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--border); border-radius: var(--radius);
  background: color-mix(in oklab, var(--surface) 80%, #000 8%);
  font-size: 0.85rem; line-height: 1.65;
}
.codeblock pre code { background: none; padding: 0; }
.codeblock-copy {
  position: absolute; top: 0.6rem; right: 0.6rem; z-index: 1;
  padding: 0.2rem 0.6rem; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface-2);
  font-size: 0.72rem; color: var(--text-subtle); opacity: 0; transition: opacity 0.18s;
}
.codeblock:hover .codeblock-copy, .codeblock-copy:focus-visible { opacity: 1; }
.codeblock-copy:hover { color: var(--text); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { padding: 0.62rem 0.9rem; border-bottom: 1px solid var(--border); }
th { background: var(--surface-2); font-weight: 620; font-size: 0.82rem; letter-spacing: 0.02em; }
tbody tr:last-child td { border-bottom: none; }

.callout {
  padding: var(--sp-4) var(--sp-5); border-radius: var(--radius);
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  background: var(--surface); font-size: 0.96rem;
}
.callout > * + * { margin-top: 0.7em; }
.callout-title { font-weight: 660; font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.callout.tone-warn { border-left-color: var(--warn); }
.callout.tone-warn .callout-title { color: var(--warn); }
.callout.tone-tip { border-left-color: var(--good); }
.callout.tone-tip .callout-title { color: var(--good); }

.mdswatches, .prose .mdswatches {
  list-style: none; padding-left: 0; margin-left: 0;
  display: flex; flex-direction: row; flex-wrap: wrap; gap: var(--sp-2);
}
.mdswatch { display: flex; flex-direction: column; gap: 0.3rem; }
.mdswatch-chip {
  display: block; width: 104px; height: 62px; border-radius: var(--radius-sm);
  border: 1px solid color-mix(in oklab, var(--text) 15%, transparent);
}
.mdswatch-label {
  background: none; border: none; padding: 0; text-align: left;
  font-family: var(--font-mono); font-size: 0.74rem; color: var(--text-subtle);
}
.mdswatch-label:hover { color: var(--accent); }

.mddemo { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-5); background: var(--surface); }

.post-footer { padding-bottom: var(--sp-8); max-width: var(--shell); }
.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); margin-top: var(--sp-6); }
.post-nav-item {
  display: flex; flex-direction: column; gap: 0.3rem; padding: var(--sp-4);
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); text-decoration: none;
  transition: border-color 0.2s;
}
.post-nav-item:hover { border-color: var(--accent); }
.post-nav-item span { font-size: 0.78rem; color: var(--text-subtle); }
.post-nav-item strong { font-weight: 570; font-size: 0.95rem; }
.post-nav-item.align-end { text-align: right; }
@media (max-width: 660px) { .post-nav { grid-template-columns: 1fr; } .post-nav-item.align-end { text-align: left; } }

/* -------------------------------------------------------------- learn */

.learn-path { padding-block: var(--sp-7); border-top: 1px solid var(--border); }
.learn-path-head { max-width: 60ch; margin-bottom: var(--sp-5); }
.learn-path-head p { color: var(--text-muted); margin-top: var(--sp-2); }
.learn-path-body { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-6); }
.learn-path-body h3 { font-size: 0.76rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-subtle); margin-bottom: var(--sp-3); }
@media (max-width: 780px) { .learn-path-body { grid-template-columns: 1fr; } }

.section-head h2 a { color: inherit; text-decoration: none; }
.section-head h2 a:hover { color: var(--accent); }
.section-more { margin-top: var(--sp-4); font-size: 0.9rem; }
.section-more a { color: var(--accent); text-decoration: underline; text-decoration-color: color-mix(in oklab, var(--accent) 45%, transparent); }
.section-more a:hover { text-decoration: underline; }

/* The answer block: one self-contained sentence, set apart because it is
   the thing a reader in a hurry and a search snippet both want. */
.answer {
  margin-top: var(--sp-4); padding: var(--sp-4) var(--sp-5);
  border-left: 3px solid var(--accent); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface); color: var(--text);
  font-size: 1.02rem; line-height: 1.65; max-width: 74ch;
}
.answer code { font-size: 0.94em; }

/* Search */
.search-form { display: flex; gap: 0.5rem; margin-top: var(--sp-5); max-width: 34rem; }
.search-form input {
  flex: 1; min-width: 0; font: inherit; font-size: 1rem;
  padding: 0.6rem 0.9rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
}
.search-form input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.search-status { margin-top: var(--sp-3); font-size: 0.86rem; color: var(--text-subtle); }
/* `order` only takes effect in a flex container, which is how results are
   ranked without touching the DOM on every keystroke. */
.search-list.is-ranked { display: flex; flex-direction: column; }
.search-item a { display: grid; grid-template-columns: 5.5rem 1fr; gap: 0.15rem 0.8rem; align-items: baseline; }
.search-item a > span:last-child { grid-column: 2; }
.search-kind {
  grid-row: span 2; font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-subtle); padding-top: 0.2rem;
}
.search-empty { color: var(--text-muted); padding: var(--sp-6) 0; }
@media (max-width: 560px) {
  .search-item a { grid-template-columns: 1fr; }
  .search-item a > span:last-child { grid-column: 1; }
  .search-kind { grid-row: auto; }
}

/* Glossary */
.glossary-index {
  display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: var(--sp-7);
  padding-bottom: var(--sp-5); border-bottom: 1px solid var(--border);
}
.glossary-index a {
  font-size: 0.8rem; padding: 0.26rem 0.6rem; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text-muted); text-decoration: none;
}
.glossary-index a:hover { border-color: var(--accent); color: var(--accent); }
.glossary-list { max-width: 74ch; }
.glossary-item { scroll-margin-top: 5rem; padding-top: var(--sp-6); }
.glossary-item + .glossary-item { border-top: 1px solid var(--border); }
.glossary-item h3 { margin-bottom: 0.5rem; }
.glossary-item h3 .anchor { color: inherit; text-decoration: none; }
.glossary-item h3 .anchor:hover { color: var(--accent); }
.glossary-short { font-size: 1.08rem; color: var(--text); font-weight: 480; }
.glossary-meta {
  display: flex; flex-wrap: wrap; gap: 0.3rem 1.2rem;
  font-size: 0.82rem; color: var(--text-subtle);
}
.glossary-meta a { color: var(--text-muted); }

/* Tag pages: an introduction to the subject, then the archive. */
.tag-intro { margin-bottom: var(--sp-7); }
.tag-intro h2 { margin-top: 0; }
.section-h {
  font-size: 0.76rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-subtle); font-weight: 600; margin-bottom: var(--sp-4);
}

.link-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.link-list a {
  display: flex; flex-direction: column; gap: 0.1rem;
  padding: 0.55rem 0.8rem; border-radius: var(--radius-sm);
  text-decoration: none; transition: background-color 0.18s;
}
.link-list a:hover { background: var(--surface); }
.link-list a span { font-size: 0.82rem; color: var(--text-subtle); }
.link-list strong { font-weight: 560; }

/* -------------------------------------------------------------- tools */

.tool-head { padding-block: var(--sp-6) var(--sp-5); }
.tool-head h1 { font-size: var(--step-3); margin-bottom: var(--sp-3); }
.crumbs { display: flex; gap: 0.5rem; font-size: 0.82rem; color: var(--text-subtle); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--accent); }

.tool-mount { min-height: 320px; }
.tool-skeleton { display: grid; gap: var(--sp-4); grid-template-columns: 1fr 1fr; }
.tool-skeleton span {
  display: block; height: 200px; border-radius: var(--radius);
  background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%);
  background-size: 220% 100%; animation: shimmer 1.4s infinite linear;
}
.tool-skeleton span:first-child { grid-row: span 2; height: 100%; min-height: 300px; }
@keyframes shimmer { to { background-position: -220% 0; } }

.tool-about { display: grid; min-width: 0; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--sp-7); padding-top: var(--sp-6); border-top: 1px solid var(--border); }
.tool-about h2 { font-size: var(--step-1); margin-bottom: var(--sp-3); }
.tool-about p { color: var(--text-muted); }
.tool-about p + p { margin-top: var(--sp-3); }
.tool-side h2 { font-size: 0.76rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-subtle); }
.tool-side h2 + ul { margin-bottom: var(--sp-5); }
@media (max-width: 860px) { .tool-about { grid-template-columns: minmax(0, 1fr); gap: var(--sp-5); } }

/* --------------------------------------------------------- app panels */

.panel {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); overflow: hidden; min-width: 0;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--surface-2) 60%, transparent);
  flex-wrap: wrap;
}
.panel-title { font-size: 0.95rem; font-weight: 620; letter-spacing: -0.01em; }
.panel-sub { font-size: 0.82rem; color: var(--text-subtle); margin-top: 0.15rem; }
.panel-actions { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.panel-body { padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }
.panel-body.is-flush { padding: 0; }

.grid-2 { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid-3 { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.tool-layout { display: grid; gap: var(--sp-4); grid-template-columns: minmax(0, 360px) minmax(0, 1fr); align-items: start; }
@media (max-width: 940px) { .tool-layout { grid-template-columns: minmax(0, 1fr); } }
.stack { display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }
.row-wrap { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------ inputs */

.slider { display: block; }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.35rem; }
.slider-label { font-size: 0.82rem; font-weight: 560; color: var(--text-muted); }
.slider-value { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-subtle); }
.slider-input {
  -webkit-appearance: none; appearance: none; width: 100%; height: 22px;
  background: none; cursor: pointer;
}
.slider-input::-webkit-slider-runnable-track {
  height: 10px; border-radius: 999px;
  background: var(--track, var(--surface-3));
  border: 1px solid color-mix(in oklab, var(--text) 12%, transparent);
}
.slider-input::-moz-range-track {
  height: 10px; border-radius: 999px;
  background: var(--track, var(--surface-3));
  border: 1px solid color-mix(in oklab, var(--text) 12%, transparent);
}
.slider-input::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; margin-top: -5px; border-radius: 50%;
  background: #fff; border: 2px solid rgb(0 0 0 / 0.35);
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.4);
}
.slider-input::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 2px solid rgb(0 0 0 / 0.35);
}

.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field-label { font-size: 0.82rem; font-weight: 560; color: var(--text-muted); }

.color-field {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.3rem 0.3rem 0.3rem 0.35rem;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-2);
}
.color-field-chip { width: 30px; height: 30px; border-radius: 50%; overflow: hidden; flex-shrink: 0; border: 1px solid color-mix(in oklab, var(--text) 15%, transparent); }
.color-native { width: 60px; height: 60px; border: none; padding: 0; margin: -15px; background: none; cursor: pointer; }
.color-text {
  flex: 1; min-width: 0; border: none; background: none; outline: none;
  font-family: var(--font-mono); font-size: 0.88rem; padding-right: 0.5rem;
}
.color-text.is-invalid { color: var(--bad); }

input[type='text'].input, textarea.input, select.input {
  width: 100%; padding: 0.55rem 0.8rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); outline: none;
  font-size: 0.9rem;
}
textarea.input { font-family: var(--font-mono); font-size: 0.82rem; line-height: 1.6; resize: vertical; }
input.input:focus, textarea.input:focus, select.input:focus { border-color: var(--accent); }

.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2);
  flex-wrap: wrap;
}
.seg {
  padding: 0.32rem 0.75rem; border: none; border-radius: 999px;
  background: none; color: var(--text-subtle); font-size: 0.82rem; font-weight: 550;
  transition: background-color 0.18s, color 0.18s;
}
.seg:hover { color: var(--text); }
.seg[aria-checked='true'] { background: var(--accent); color: var(--accent-text); }

.checkbox { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.86rem; color: var(--text-muted); cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ----------------------------------------------------------- swatches */

.swatch {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end;
  gap: 0.1rem; padding: 0.55rem; border: none; border-radius: var(--radius-sm);
  text-align: left; overflow: hidden;
  transition: transform 0.18s var(--ease), box-shadow 0.18s;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.07);
}
.swatch:hover { transform: translateY(-2px); box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.2), var(--shadow-2); z-index: 1; }
.swatch.size-sm { min-height: 52px; }
.swatch.size-md { min-height: 84px; }
.swatch.size-lg { min-height: 130px; }
.swatch.size-xl { min-height: 200px; }
.swatch-label { font-family: var(--font-mono); font-size: 0.74rem; font-weight: 600; }
/* No opacity here. The swatch text colour is solved against the swatch by
   bestTextOn(), and fading it afterwards throws that away — 4.9:1 became
   3.78:1. Hierarchy comes from size and weight instead. */
.swatch-sub { font-size: 0.68rem; font-family: var(--font-mono); }

.swatch-row { display: grid; gap: 0.35rem; grid-auto-flow: column; grid-auto-columns: 1fr; }
.swatch-strip { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border-radius: var(--radius-sm); overflow: hidden; }
.swatch-strip .swatch { border-radius: 0; box-shadow: none; }
.swatch-strip .swatch:hover { transform: none; box-shadow: inset 0 0 0 2px rgb(255 255 255 / 0.35); }
.swatch-wrap { display: grid; gap: 0.35rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 110px), 1fr)); }

.format-grid { display: grid; gap: 0.35rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); }
.format-chip {
  display: flex; align-items: baseline; gap: 0.55rem;
  padding: 0.45rem 0.7rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); text-align: left; overflow: hidden;
  transition: border-color 0.18s;
}
.format-chip:hover { border-color: var(--accent); }
.format-key { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.08em; color: var(--text-subtle); flex-shrink: 0; width: 4.4em; }
.format-value { font-family: var(--font-mono); font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.readout { display: grid; gap: 0.5rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 120px), 1fr)); }
.readout-item { padding: 0.6rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.readout-key { font-size: 0.68rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-subtle); }
.readout-value { font-family: var(--font-mono); font-size: 1rem; font-weight: 600; margin-top: 0.1rem; }

.code-out {
  margin: 0; padding: var(--sp-4); border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: color-mix(in oklab, var(--surface-2) 80%, #000 6%);
  font-family: var(--font-mono); font-size: 0.78rem; line-height: 1.7;
  overflow-x: auto; white-space: pre; max-height: 380px; overflow-y: auto;
}

.empty-note { color: var(--text-subtle); font-size: 0.88rem; text-align: center; padding: var(--sp-6); }

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

/*
 * Reserve the studio's eventual height before it mounts.
 *
 * The loading placeholder was ~850px and the mounted picker is 2300–3900px
 * depending on width, so everything below it jumped by up to 2,700px on
 * first paint. That measured as a cumulative layout shift of 1.397 — Core
 * Web Vitals calls anything above 0.1 poor, and it is a ranking signal.
 *
 * The values below are measured, not guessed, at the widths either side of
 * each breakpoint. They only need to be close: CLS is a ratio, so being
 * within a few percent costs effectively nothing.
 */
.studio { position: relative; }
/* Only reserve space where something is going to arrive. Applying this
   unconditionally left no-JS visitors staring at 3,620px of nothing under a
   loading message that would never resolve. */
.js .studio { min-height: 3860px; }
@media (min-width: 400px) { .js .studio { min-height: 3620px; } }
@media (min-width: 620px) { .js .studio { min-height: 3360px; } }
@media (min-width: 1100px) { .js .studio { min-height: 2400px; } }
/* Once the real UI is in, its own content decides the height. */
.js-ready .studio { min-height: 0; }
.studio-loading { display: none; }
.js .studio-loading { min-height: 62vh; display: grid; place-items: center; text-align: center; padding: var(--sp-7); }
.studio-loading h1 { font-size: var(--step-4); margin-bottom: var(--sp-3); }
.studio-loading p { color: var(--text-subtle); }
.js-ready .studio-loading { display: none; }
.noscript-hero { padding-block: var(--sp-8); }

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 400px);
  gap: var(--sp-6);
  align-items: start;
  width: min(100% - 2.5rem, var(--shell-wide)); margin-inline: auto;
  padding-block: var(--sp-7) var(--sp-8);
}
.hero-main { display: flex; flex-direction: column; gap: var(--sp-5); min-width: 0; }
.hero-controls { align-self: start; }
.hero-copy { max-width: 62ch; }
.hero-swatch { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.hero-meta { display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }
.hero-preview { min-width: 0; }

/* Below the two-column breakpoint `display: contents` promotes the left
   column's children into the hero's own flex line, so `order` can lift the
   picker up between the swatch and the explainer. Leading a color tool with
   a screenful of prose is the worst thing the old layout did on a phone. */
@media (max-width: 1000px) {
  .hero {
    display: flex; flex-direction: column;
    gap: var(--sp-4);
    padding-block: var(--sp-5) var(--sp-7);
  }
  .hero-main { display: contents; }
  .hero-copy { order: 1; }
  .hero-swatch { order: 2; }
  .hero-controls { order: 3; }
  .hero-lede { order: 4; }
  .hero-meta { order: 5; }
  .hero-preview { order: 6; }
}

.hero-copy h1 { font-size: var(--step-4); letter-spacing: -0.035em; }
.hero-lede { font-size: var(--step-1); color: var(--text-muted); max-width: 48ch; }
.hero-lede a { color: var(--accent); font-weight: 560; white-space: nowrap; }
.hero-hex {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-family: var(--font-mono); font-weight: 700; letter-spacing: -0.03em;
  font-size: var(--step-5); line-height: 1;
  background: none; border: none; padding: 0;
  max-width: 100%;
}
.hero-hex:hover { color: var(--accent); }

@media (max-width: 700px) {
  .hero-copy h1 { font-size: clamp(1.75rem, 6.5vw, 2.3rem); margin-bottom: var(--sp-3); }
  .hero-lede { font-size: 0.95rem; }
  .hero-copy .eyebrow { margin-bottom: var(--sp-2); }
  .hero-hex { font-size: clamp(2.1rem, 11vw, 3rem); }
  /* two-up instead of four stacked full-width rows */
  .hero-meta .format-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-meta .format-chip { padding: 0.4rem 0.55rem; }
  .hero-meta .format-key { width: auto; margin-bottom: 0.1rem; }
  .hero-meta .format-chip { flex-direction: column; align-items: flex-start; gap: 0.1rem; }
  .hero-meta .format-value { font-size: 0.72rem; }
}

.canvas-preview {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; background: var(--bg); box-shadow: var(--shadow-3);
}

/* mini site preview rendered inside the picker */
.mini {
  --mini-radius: 10px;
  display: flex; flex-direction: column; min-height: 430px;
  font-size: 0.82rem;
}
.mini-bar {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--mini-border);
}
.mini-dots { display: flex; gap: 0.28rem; }
.mini-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--mini-border-strong); display: block; }
.mini-url {
  flex: 1; padding: 0.2rem 0.6rem; border-radius: 999px;
  background: var(--mini-surface); color: var(--mini-subtle);
  font-family: var(--font-mono); font-size: 0.68rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mini-body { flex: 1; padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-4); }
.mini-nav { display: flex; gap: 1rem; align-items: center; font-size: 0.76rem; color: var(--mini-muted); }
.mini-nav strong { color: var(--mini-text); font-size: 0.9rem; margin-right: auto; }
.mini-h { font-size: 1.55rem; font-weight: 680; letter-spacing: -0.03em; color: var(--mini-text); line-height: 1.15; }
.mini-p { color: var(--mini-muted); max-width: 42ch; }
.mini-actions { display: flex; gap: 0.5rem; }
.mini-btn { padding: 0.42rem 0.9rem; border-radius: 999px; font-size: 0.76rem; font-weight: 600; }
.mini-btn.primary { background: var(--mini-accent); color: var(--mini-accent-text); }
.mini-btn.ghost { border: 1px solid var(--mini-border-strong); color: var(--mini-text); }
.mini-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; margin-top: auto; }
.mini-card {
  padding: 0.75rem; border-radius: var(--mini-radius);
  background: var(--mini-surface); border: 1px solid var(--mini-border);
}
.mini-card b { display: block; color: var(--mini-text); font-size: 0.8rem; margin-bottom: 0.2rem; }
.mini-card span { color: var(--mini-subtle); font-size: 0.72rem; }
.mini-swatchbar { display: grid; grid-auto-flow: column; height: 8px; border-radius: 999px; overflow: hidden; }
@media (max-width: 560px) { .mini-cards { grid-template-columns: 1fr; } .mini-cards .mini-card:nth-child(n+3) { display: none; } }

.control-stack { display: flex; flex-direction: column; gap: var(--sp-4); }

.spectrum {
  position: relative; width: 100%; aspect-ratio: 1.35 / 1;
  border-radius: var(--radius); cursor: crosshair; touch-action: none;
  border: 1px solid color-mix(in oklab, var(--text) 15%, transparent);
  overflow: hidden;
}
.spectrum canvas { width: 100%; height: 100%; display: block; }
.spectrum-cursor {
  position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.5), 0 2px 6px rgb(0 0 0 / 0.45);
  transform: translate(-50%, -50%); pointer-events: none;
}

.wheel { position: relative; width: 100%; max-width: 340px; margin-inline: auto; aspect-ratio: 1; touch-action: none; }
.wheel canvas { width: 100%; height: 100%; border-radius: 50%; }
.wheel-dot {
  position: absolute; width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 0 1px rgb(0 0 0 / 0.55);
  transform: translate(-50%, -50%); pointer-events: none;
}
.wheel-dot.is-sub { width: 13px; height: 13px; border-width: 2px; opacity: 0.9; }

.chip-row { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.chip {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid color-mix(in oklab, var(--text) 15%, transparent);
  padding: 0; transition: transform 0.16s var(--ease);
}
.chip:hover { transform: scale(1.12); }
.chip.is-active { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }

.preset-grid { display: grid; gap: 0.4rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 88px), 1fr)); }
.preset {
  display: flex; flex-direction: column; gap: 0.25rem; padding: 0;
  border: none; background: none; text-align: left;
}
.preset-chip { height: 44px; border-radius: 9px; border: 1px solid color-mix(in oklab, var(--text) 15%, transparent); transition: transform 0.16s var(--ease); }
.preset:hover .preset-chip { transform: translateY(-2px); }
.preset-name { font-size: 0.7rem; color: var(--text-subtle); }

/* --------------------------------------------------------- cmd palette */

.cmdk-root { position: fixed; inset: 0; z-index: 200; }
.cmdk-backdrop { position: absolute; inset: 0; background: rgb(0 0 0 / 0.55); backdrop-filter: blur(4px); }
.cmdk {
  position: absolute; inset: 0; display: grid; place-items: start center;
  padding: clamp(1rem, 8vh, 7rem) 1rem 1rem; pointer-events: none;
}
.cmdk-box {
  pointer-events: auto; width: min(100%, 620px);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-3); overflow: hidden;
  animation: cmdk-in 0.18s var(--ease);
}
@keyframes cmdk-in { from { opacity: 0; transform: translateY(-8px) scale(0.985); } }
.cmdk-head { display: flex; align-items: center; gap: 0.6rem; padding: 0.85rem 1rem; border-bottom: 1px solid var(--border); }
.cmdk-icon { color: var(--text-subtle); font-size: 1rem; }
.cmdk-input { flex: 1; border: none; background: none; outline: none; font-size: 1rem; }
.cmdk-results { list-style: none; margin: 0; padding: 0.4rem; max-height: 52vh; overflow-y: auto; }
.cmdk-item {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.5rem 0.65rem; border-radius: var(--radius-sm); cursor: pointer;
}
.cmdk-item.is-active { background: var(--surface-2); }
.cmdk-kind {
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-subtle); width: 2.6rem; flex-shrink: 0;
}
.cmdk-swatch { width: 26px; height: 26px; border-radius: 7px; flex-shrink: 0; border: 1px solid color-mix(in oklab, var(--text) 18%, transparent); }
.cmdk-text { display: flex; flex-direction: column; min-width: 0; }
.cmdk-title { font-size: 0.92rem; font-weight: 550; }
.cmdk-desc { font-size: 0.78rem; color: var(--text-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdk-empty { padding: var(--sp-5); text-align: center; color: var(--text-subtle); font-size: 0.88rem; }
.cmdk-foot {
  display: flex; gap: 1rem; padding: 0.55rem 1rem; border-top: 1px solid var(--border);
  font-size: 0.74rem; color: var(--text-subtle); flex-wrap: wrap;
  background: var(--surface-2);
}
.cmdk-foot kbd { font-size: 0.68rem; }
@media (max-width: 620px) { .cmdk-foot span:last-child { display: none; } }

/* ------------------------------------------------------------ toasts */

.toast-host {
  position: fixed; bottom: var(--sp-5); left: 50%; transform: translateX(-50%);
  z-index: 300; display: flex; flex-direction: column; gap: 0.5rem; align-items: center;
  pointer-events: none;
}
.toast {
  padding: 0.5rem 1rem; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface-3);
  box-shadow: var(--shadow-2); font-size: 0.85rem; font-weight: 520;
  opacity: 0; transform: translateY(10px); transition: opacity 0.22s, transform 0.22s var(--ease);
  max-width: 90vw; text-align: center;
}
.toast.is-in { opacity: 1; transform: none; }
.toast.tone-good { border-color: color-mix(in oklab, var(--good) 60%, var(--border)); }
.toast.tone-warn { border-color: color-mix(in oklab, var(--warn) 60%, var(--border)); }
.toast.tone-bad { border-color: color-mix(in oklab, var(--bad) 60%, var(--border)); }
.toast.has-action { display: flex; align-items: center; gap: 0.6rem; }
.toast-action {
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font: inherit; font-size: 0.82rem; font-weight: 560;
  padding: 0.28rem 0.7rem; border-radius: var(--radius-sm); cursor: pointer;
  white-space: nowrap;
}
.toast-action:hover { background: var(--surface-raised); }
.toast-close {
  border: 0; background: none; color: var(--text-subtle); cursor: pointer;
  font-size: 1.1rem; line-height: 1; padding: 0.1rem 0.2rem;
}
.toast-close:hover { color: var(--text); }

/* ------------------------------------------------------------ footer */

.site-footer { border-top: 1px solid var(--border); margin-top: var(--sp-8); padding-top: var(--sp-7); background: color-mix(in oklab, var(--surface) 45%, transparent); }
.footer-inner { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 2fr); gap: var(--sp-6); padding-bottom: var(--sp-6); }
.footer-blurb { color: var(--text-subtle); font-size: 0.86rem; margin-top: var(--sp-3); max-width: 44ch; }
.footer-nav { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-5); }
/* h2, not h3 — these are the only headings on pages whose body has none,
   and an h1 followed by an h3 is a broken document outline. */
.footer-nav h2 { font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-subtle); margin-bottom: var(--sp-3); font-weight: 600; }
.footer-nav a { display: block; font-size: 0.87rem; color: var(--text-muted); text-decoration: none; padding: 0.16rem 0; }
.footer-nav a:hover { color: var(--accent); }
.footer-bottom {
  display: flex; justify-content: space-between; gap: var(--sp-4);
  padding-block: var(--sp-4); border-top: 1px solid var(--border);
  font-size: 0.8rem; color: var(--text-subtle); flex-wrap: wrap;
}
@media (max-width: 760px) {
  .footer-inner { grid-template-columns: 1fr; }
  .footer-nav { grid-template-columns: repeat(2, 1fr); }
}

.not-found { padding-block: var(--sp-9); }
.not-found p:last-child { display: flex; gap: var(--sp-3); margin-top: var(--sp-5); flex-wrap: wrap; }

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

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

.dropzone {
  display: grid; place-items: center; gap: var(--sp-3); text-align: center;
  min-height: 220px; padding: var(--sp-6);
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--surface-2); color: var(--text-muted); cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--surface-3); }

.matrix { border-collapse: separate; border-spacing: 2px; font-size: 0.7rem; }
.matrix th { background: none; padding: 0.2rem; font-family: var(--font-mono); font-weight: 500; font-size: 0.65rem; color: var(--text-subtle); border: none; }
.matrix td { padding: 0; border: none; }
.matrix-cell {
  width: 100%; min-width: 54px; height: 46px; border-radius: 6px; border: none;
  font-family: var(--font-mono); font-size: 0.68rem; font-weight: 640;
  display: flex; align-items: center; justify-content: center;
}

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

@media print {
  .site-header, .site-footer, .cmdk-root, .toast-host, .post-toc { display: none; }
  body { background: #fff; color: #000; }
}

/* =========================================================================
   Touch and small-screen ergonomics
   ========================================================================= */

/* Coarse pointers need real targets. A 18px slider thumb is fine with a
   mouse and unusable with a thumb. */
@media (pointer: coarse) {
  .slider-input { height: 34px; }
  .slider-input::-webkit-slider-runnable-track { height: 14px; }
  .slider-input::-moz-range-track { height: 14px; }
  .slider-input::-webkit-slider-thumb { width: 26px; height: 26px; margin-top: -7px; }
  .slider-input::-moz-range-thumb { width: 24px; height: 24px; }

  .chip { width: 40px; height: 40px; border-radius: 11px; }
  .btn { padding: 0.68rem 1.1rem; }
  .seg { padding: 0.5rem 0.9rem; }
  .spectrum-cursor { width: 24px; height: 24px; border-width: 3px; }
  .wheel-dot { width: 26px; height: 26px; border-width: 3px; }
  .format-chip, .swatch, .preset { min-height: 44px; }
}

/* Stop the gray flash on tap without removing any focus affordance. */
button, a, .swatch, .chip, .preset, .format-chip {
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 700px) {
  /* Tighter gutters buy ~20px of usable width on a 390px screen. */
  .shell, .main-wide .shell, .hero { width: min(100% - 1.75rem, var(--shell-wide)); }
  .header-inner { width: min(100% - 1.75rem, var(--shell-wide)); }

  .section { padding-block: var(--sp-7); }
  .page-head { padding-block: var(--sp-6) var(--sp-4); }
  .tool-head { padding-block: var(--sp-5) var(--sp-4); }

  /* A taller spectrum is easier to hit accurately with a thumb. */
  .spectrum { aspect-ratio: 1.05 / 1; }

  .panel-body { padding: var(--sp-4); gap: var(--sp-3); }
  .panel-head { padding: var(--sp-3) var(--sp-4); }

  /* The preview is a demo, not a control — it can be shorter on a phone. */
  .mini { min-height: 300px; }
  .mini-body { padding: var(--sp-4); gap: var(--sp-3); }
  .mini-h { font-size: 1.25rem; }

  .readout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .swatch-wrap { grid-template-columns: repeat(auto-fill, minmax(min(100%, 88px), 1fr)); }
  .code-out { font-size: 0.72rem; padding: var(--sp-3); }
  .prose { font-size: 1rem; }
  .post-header h1 { font-size: clamp(1.8rem, 7vw, 2.4rem); }
  .lede { font-size: 1rem; }
  .page-head h1, .tool-head h1 { font-size: clamp(1.7rem, 6.5vw, 2.2rem); }
}

@media (max-width: 420px) {
  /* At this width a four-across swatch strip is 90px per stop — the hex
     labels stop fitting, so drop them rather than let them clip. */
  .swatch-strip .swatch-label { font-size: 0.66rem; }
  .preset-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 74px), 1fr)); }
}

/* Stat strip — the fastest way to say "suite of tools plus a blog". */
.stat-strip {
  list-style: none; padding: 0; margin: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-3);
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding-block: var(--sp-4);
}
.stat-strip a {
  display: flex; flex-direction: column; gap: 0.1rem; text-decoration: none;
  padding: 0.2rem 0; border-radius: var(--radius-sm);
}
.stat-strip strong {
  font-size: clamp(1.4rem, 4vw, 2rem); font-weight: 700; letter-spacing: -0.03em;
  line-height: 1; color: var(--text);
}
.stat-strip span { font-size: 0.78rem; color: var(--text-subtle); }
.stat-strip a:hover strong { color: var(--accent); }
@media (max-width: 560px) {
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4) var(--sp-3); }
}

/* =========================================================================
   Double-tap behavior on touch devices
   -------------------------------------------------------------------------
   `touch-action: manipulation` removes double-tap-to-zoom (and the ~300ms
   tap delay that comes with it) while leaving pan and pinch-zoom alone.

   Deliberately NOT done with `user-scalable=no` / `maximum-scale=1` on the
   viewport meta: that kills pinch-zoom outright, which fails WCAG 2.2
   1.4.4 and is a poor look on a site whose own tools check contrast.
   ========================================================================= */

html, body { touch-action: manipulation; }

/* The drag surfaces keep `touch-action: none` — their class selectors
   outrank this, so panning stays suppressed while a drag is in progress. */
button, a, summary, label, input, select, textarea,
.btn, .chip, .swatch, .preset, .seg, .format-chip, .nav-link,
.tool-card, .post-card, .cat-card, .stat-strip a, .tag, .cmdk-item {
  touch-action: manipulation;
}

/* Double-tapping a control also selects the word under it and raises the
   selection handles. Controls are for tapping, so opt them out — the copy
   is on the clipboard anyway, since tapping these copies the value. */
button, .btn, .chip, .swatch, .preset, .seg, .segmented, .format-chip,
.nav-link, .logo, .stat-strip, .tag, .pill, .badge, .slider-head,
.field-label, .panel-head, .tool-card, .cat-card, .post-card-meta,
.crumbs, kbd, .cmdk-foot, .swatch-label, .swatch-sub, .preset-name {
  -webkit-user-select: none;
  user-select: none;
}

/* Anything worth reading or copying by hand stays selectable. */
.prose, .code-out, pre, code, samp,
input, textarea, .color-text, .readout-value, .mdswatch-label {
  -webkit-user-select: text;
  user-select: text;
}

/* Some tools are output-led — the swatches are the point and the sliders
   are optional tuning. Those flip on mobile so the result comes first. */
@media (max-width: 940px) {
  .tool-layout.output-first > :first-child { order: 2; }
  .tool-layout.output-first > :last-child { order: 1; }
}

/* =========================================================================
   Long-form tool content: reference tables, steps and FAQs
   ========================================================================= */

.tool-article {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 260px);
  gap: var(--sp-7); align-items: start;
}
@media (max-width: 940px) {
  .tool-article { grid-template-columns: minmax(0, 1fr); gap: var(--sp-5); }
}
.prose-wide { max-width: 78ch; }
.prose-wide > section { margin-top: 2.6em; }
.prose-wide h2 { font-size: var(--step-2); margin-top: 0; scroll-margin-top: 5rem; }

.step-list { counter-reset: step; list-style: none; padding-left: 0; display: flex; flex-direction: column; gap: 0.75em; }
.step-list li {
  counter-increment: step; position: relative; padding-left: 2.6rem;
  color: color-mix(in oklab, var(--text) 90%, var(--text-muted));
}
.step-list li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0.05em;
  width: 1.8rem; height: 1.8rem; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 0.78rem; font-weight: 640; color: var(--accent);
}

.seo-table { font-size: 0.88rem; }
.seo-table th { white-space: nowrap; }
.seo-table td { vertical-align: middle; }
.seo-table code { font-size: 0.8rem; background: none; padding: 0; color: var(--text-muted); }
.seo-swatch {
  display: inline-block; width: 1.1em; height: 1.1em; border-radius: 4px;
  vertical-align: -0.2em; margin-right: 0.45em;
  border: 1px solid color-mix(in oklab, var(--text) 20%, transparent);
}

.faq { margin-top: 2.6em; }
.faq-list { display: flex; flex-direction: column; gap: 0.5rem; margin-top: var(--sp-4); }
.faq-item {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); overflow: hidden;
}
.faq-item summary {
  cursor: pointer; padding: 0.9rem 1.1rem; list-style: none;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: '+'; font-family: var(--font-mono); font-size: 1.2rem;
  color: var(--accent); flex-shrink: 0; line-height: 1;
}
.faq-item[open] summary::after { content: '−'; }
.faq-item summary h3 { font-size: 0.98rem; font-weight: 600; margin: 0; }
.faq-item summary:hover h3 { color: var(--accent); }
.faq-answer { padding: 0 1.1rem 1rem; color: var(--text-muted); font-size: 0.94rem; }
.faq-answer p { margin: 0; }
.faq-answer a { color: var(--accent); }
.faq-answer code { background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }

/* Heading permalink on the learn paths, matching the article headings. */
.learn-path-head h2 .anchor-h { color: inherit; text-decoration: none; }
.learn-path-head h2 .anchor-h:hover { color: var(--accent); }
.learn-path { scroll-margin-top: 5rem; }
