:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --surface-2: #f1f1ee;
  --text: #16161a;
  --muted: #5d5d66;
  --border: #e3e3de;
  --accent: #4646d8;
  --accent-ink: #ffffff;
  --accent-soft: #ebebfc;
  --good: #11744a;
  --good-soft: #e3f4ea;
  --warn: #8f5200;
  --warn-soft: #fbf0dc;
  --code-bg: #f4f4f1;
  --t-kw: #a3218f;
  --t-str: #1d7a3a;
  --t-num: #b25400;
  --t-com: #7d7d86;
  --t-builtin: #3341c9;
  --radius: 14px;
  --maxw: 1120px;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e11;
    --surface: #16161b;
    --surface-2: #1e1e25;
    --text: #ececf0;
    --muted: #a1a1ac;
    --border: #2b2b34;
    --accent: #9292ff;
    --accent-ink: #0e0e11;
    --accent-soft: #24243f;
    --good: #5ad596;
    --good-soft: #15291f;
    --warn: #f2b65e;
    --warn-soft: #2d2313;
    --code-bg: #111116;
    --t-kw: #f08bd8;
    --t-str: #7fd99a;
    --t-num: #f5ad6b;
    --t-com: #7c7c88;
    --t-builtin: #9ea8ff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
code, kbd { font-family: var(--mono); font-size: .9em; }
:not(pre) > code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; overflow-wrap: anywhere; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-family: var(--mono); font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; white-space: nowrap; }
.brand img { width: 28px; height: 28px; }
.brand small { font-family: system-ui, sans-serif; font-weight: 600; font-size: .72rem; color: var(--muted); letter-spacing: 0; border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; }
.site-nav { display: flex; gap: 22px; }
.site-nav a { color: var(--muted); text-decoration: none; font-weight: 500; font-size: .95rem; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--text); }

/* Hero */
.hero { padding: 88px 0 64px; }
.eyebrow { font-family: var(--mono); font-size: .78rem; text-transform: uppercase; letter-spacing: .14em; color: var(--accent); margin: 0 0 14px; }
.hero h1 { font-size: clamp(2.4rem, 6.5vw, 4.4rem); line-height: 1.04; letter-spacing: -0.035em; margin: 0 0 20px; max-width: 15ch; }
.lede { font-size: 1.2rem; color: var(--muted); max-width: 52ch; margin: 0 0 32px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 20px; border-radius: 999px; font: inherit; font-weight: 600; text-decoration: none; border: 1px solid var(--border); color: var(--text); background: var(--surface); cursor: pointer; transition: transform .15s, border-color .15s; }
.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.small { padding: 6px 12px; font-size: .85rem; }
.stats { display: flex; flex-wrap: wrap; gap: 28px; margin-top: 44px; color: var(--muted); font-size: .95rem; }
.stats strong { display: block; color: var(--text); font-size: 1.6rem; letter-spacing: -0.02em; }

/* Sections */
.section { padding: 56px 0; border-top: 1px solid var(--border); }
.section-head { margin-bottom: 24px; }
.section-head h2 { font-size: 1.6rem; letter-spacing: -0.02em; margin: 0 0 4px; }
.section-head p { color: var(--muted); margin: 0; }
.cat { font-family: var(--mono); font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 28px 0 12px; }
.cat:first-of-type { margin-top: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: inherit; transition: transform .15s, border-color .15s; }
.card h3 { margin: 2px 0 0; font-size: 1.1rem; letter-spacing: -0.01em; }
.card p { margin: 0; color: var(--muted); font-size: .95rem; }
a.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card .go { margin-top: auto; padding-top: 6px; color: var(--accent); font-weight: 600; font-size: .92rem; }
.card .icon { width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-family: var(--mono); font-weight: 800; font-size: .9rem; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding: 32px 0 48px; color: var(--muted); font-size: .88rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }
.site-footer a { color: var(--muted); }

/* Tool pages */
.tool-hero { padding: 48px 0 8px; }
.crumbs { font-size: .88rem; color: var(--muted); margin: 0 0 12px; }
.crumbs a { color: var(--muted); }
.tool-hero h1 { font-size: clamp(2rem, 5vw, 2.8rem); line-height: 1.1; letter-spacing: -0.03em; margin: 0 0 10px; }
.tool-hero .lede { margin-bottom: 0; font-size: 1.1rem; }
.tool { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin: 24px 0 48px; align-items: start; }
.tool.wide-right { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; min-width: 0; }
.panel h2 { font-size: 1rem; margin: 0 0 14px; letter-spacing: -0.01em; }
.panel + .panel { margin-top: 16px; }
.stack > * + * { margin-top: 16px; }

/* Form controls */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field label, .label { font-weight: 600; font-size: .9rem; }
.hint { color: var(--muted); font-size: .82rem; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; }
input[type="text"], input[type="number"], select, textarea {
  width: 100%; font: inherit; font-size: 1rem; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); min-width: 0;
}
input[type="number"] { font-variant-numeric: tabular-nums; }
textarea { font-family: var(--mono); font-size: .9rem; line-height: 1.5; resize: vertical; min-height: 120px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type="color"] { width: 48px; height: 44px; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); cursor: pointer; flex: none; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; font-size: .92rem; cursor: pointer; }
.check input { accent-color: var(--accent); width: 18px; height: 18px; }
.inline { display: flex; gap: 10px; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-size: .8rem; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer; }
.chip:hover { color: var(--text); }
.chip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* Code blocks */
.code { position: relative; background: var(--code-bg); border: 1px solid var(--border); border-radius: 12px; min-width: 0; }
.code pre { margin: 0; padding: 14px 16px; overflow-x: auto; font-family: var(--mono); font-size: .86rem; line-height: 1.6; tab-size: 4; }
.code .copy { position: absolute; top: 8px; right: 8px; font: inherit; font-size: .78rem; font-weight: 600; padding: 4px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; }
.code .copy:hover { color: var(--text); border-color: var(--accent); }
.code .copy.done { color: var(--good); border-color: var(--good); }
.code.line pre { padding-right: 76px; white-space: pre; }
.t-kw { color: var(--t-kw); }
.t-str { color: var(--t-str); }
.t-num { color: var(--t-num); }
.t-com { color: var(--t-com); font-style: italic; }
.t-builtin { color: var(--t-builtin); }
.outputs > * + * { margin-top: 10px; }
.out-label { font-size: .8rem; color: var(--muted); margin: 0 0 4px; font-weight: 600; }

/* Results */
.result-label { color: var(--muted); font-size: .9rem; margin: 0 0 4px; }
.result-big { font-size: clamp(2.2rem, 6vw, 3.2rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; margin: 0 0 20px; overflow-wrap: anywhere; }
.rows { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--border); }
.rows li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.rows li span:first-child { color: var(--muted); }
.rows li span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.status { margin-top: 18px; padding: 12px 14px; border-radius: 10px; font-size: .9rem; }
.status.good { background: var(--good-soft); color: var(--good); }
.status.warn { background: var(--warn-soft); color: var(--warn); }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 999px; margin-bottom: 20px; overflow-x: auto; }
.tab { flex: 1; white-space: nowrap; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; font-size: .9rem; padding: 8px 14px; border-radius: 999px; cursor: pointer; }
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / .08); }
.divider { border: 0; border-top: 1px solid var(--border); margin: 8px 0 18px; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
table.data th, table.data td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
table.data th { color: var(--muted); font-weight: 600; font-size: .8rem; }

/* Tool-specific */
.swatch-big { height: 140px; border-radius: 12px; border: 1px solid var(--border); margin-bottom: 16px; display: grid; place-items: center; font-family: var(--mono); font-weight: 700; font-size: 1.1rem; }
.screen { position: relative; width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.screen .el { position: absolute; background: color-mix(in srgb, var(--accent) 30%, transparent); border: 2px solid var(--accent); border-radius: 4px; }
.screen .anchor { position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: var(--accent); }
.screen .dim { position: absolute; left: 8px; bottom: 6px; font-size: .75rem; color: var(--muted); font-family: var(--mono); }
.curve { width: 100%; height: auto; display: block; background: var(--surface-2); border-radius: 10px; }
.curve .axis { stroke: var(--border); stroke-width: 1; }
.curve .line { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.curve .dot { fill: var(--accent); }
.track { position: relative; height: 56px; background: var(--surface-2); border-radius: 10px; margin-top: 12px; }
.track .ball { position: absolute; top: 12px; left: 0; width: 32px; height: 32px; border-radius: 8px; background: var(--accent); }
.mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.mini { border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 6px 6px 4px; cursor: pointer; font: inherit; color: var(--muted); font-size: .72rem; text-align: center; }
.mini svg { width: 100%; height: auto; display: block; }
.mini path { fill: none; stroke: currentColor; stroke-width: 4; }
.mini[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.gradient-preview { height: 160px; border-radius: 12px; border: 1px solid var(--border); margin-bottom: 16px; }
.stops > * + * { margin-top: 8px; }
.stop { display: grid; grid-template-columns: 48px minmax(0, 1fr) 84px 36px; gap: 8px; align-items: center; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; font: inherit; font-size: 1.1rem; line-height: 1; }
.icon-btn:hover:not(:disabled) { color: var(--text); border-color: var(--accent); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; align-items: center; }
.toolbar button { font: inherit; font-size: .85rem; min-width: 36px; height: 36px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.toolbar button:hover { border-color: var(--accent); }
.toolbar input[type="color"] { width: 36px; height: 36px; padding: 2px; }
.toolbar input[type="number"] { width: 72px; height: 36px; padding: 4px 8px; }
.toolbar .sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }
.rt-preview { min-height: 120px; padding: 18px; border-radius: 12px; background: #2b2d31; color: #fff; font-size: 22px; line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere; font-family: "Gotham", "Montserrat", system-ui, sans-serif; }
.asset-row { border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.asset-row + .asset-row { margin-top: 10px; }
.asset-row .meta { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; font-size: .88rem; }
.asset-row .kind { font-weight: 600; }
.asset-row .bad { color: var(--warn); }
.snip-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 8px 0 24px; }
.snip-filters input { max-width: 320px; }
.snippet { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; scroll-margin-top: 80px; }
.snippet + .snippet { margin-top: 16px; }
.snippet h2 { font-size: 1.2rem; margin: 0 0 6px; letter-spacing: -0.01em; }
.snippet h2 a { color: inherit; text-decoration: none; }
.snippet h2 a:hover { color: var(--accent); }
.snippet p { color: var(--muted); margin: 0 0 12px; }
.snippet .where { display: inline-flex; gap: 6px; align-items: center; font-size: .82rem; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 3px 10px; margin-bottom: 12px; }
.snippet .code + .where { margin-top: 14px; }
.prose { max-width: 72ch; padding-bottom: 56px; }
.prose h2 { font-size: 1.3rem; letter-spacing: -0.01em; margin: 32px 0 8px; }
.prose p, .prose li { color: var(--muted); }
.fineprint { font-size: .85rem; color: var(--muted); }

@media (max-width: 820px) {
  .tool, .tool.wide-right { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .hero { padding: 56px 0 40px; }
  .site-nav { gap: 14px; }
  .brand small { display: none; }
  .panel, .snippet { padding: 16px; }
  .tab { padding: 8px 6px; font-size: .82rem; }
  .stop { grid-template-columns: 44px minmax(0, 1fr) 72px 36px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
