/* Toolbench design system. Workers use these classes; they never write page CSS. */
:root {
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f2f2f4;
  --ink: #18181b;
  --ink-2: #52525b;
  --ink-3: #8a8a94;
  --line: #e4e4e7;
  --line-strong: #d4d4d8;
  --ok: #15803d;
  --err: #b91c1c;
  --err-soft: #fef2f2;
  --mark: #fde68a;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 4px 16px rgb(0 0 0 / 0.04);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Consolas, Menlo, monospace;
  --content: 960px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f12; --surface: #18181c; --surface-2: #222228; --ink: #f4f4f5; --ink-2: #b4b4bd;
    --ink-3: #7c7c87; --line: #2c2c33; --line-strong: #3a3a43; --ok: #4ade80; --err: #f87171;
    --err-soft: #2a1414; --mark: #a16207; --accent-soft: color-mix(in srgb, var(--accent) 22%, transparent);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f0f12; --surface: #18181c; --surface-2: #222228; --ink: #f4f4f5; --ink-2: #b4b4bd;
  --ink-3: #7c7c87; --line: #2c2c33; --line-strong: #3a3a43; --ok: #4ade80; --err: #f87171;
  --err-soft: #2a1414; --mark: #a16207; --accent-soft: color-mix(in srgb, var(--accent) 22%, transparent);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; } /* kit classes set display:flex/grid, which would otherwise beat the hidden attribute */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 2px; }
img, svg { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.015em; margin: 0 0 0.5em; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.5rem); font-weight: 750; }
h2 { font-size: 1.35rem; font-weight: 700; margin-top: 0; }
h3 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0 0 1em; }
code, kbd { font-family: var(--mono); font-size: 0.9em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- site chrome ---------- */
.wrap { max-width: var(--content); margin: 0 auto; padding: 0 16px; }
.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 750; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink); }
.brand-mark svg { width: 16px; height: 16px; }
.site-nav { display: flex; gap: 6px; align-items: center; }
.site-nav a { color: var(--ink-2); text-decoration: none; font-size: 0.94rem; padding: 6px 10px; border-radius: 8px; }
.site-nav a:hover { background: var(--surface-2); color: var(--ink); }
.theme-toggle { background: none; border: 1px solid var(--line); border-radius: 8px; width: 36px; height: 36px; color: var(--ink-2); cursor: pointer; display: grid; place-items: center; }
.theme-toggle:hover { color: var(--ink); border-color: var(--line-strong); }

.crumbs { font-size: 0.875rem; color: var(--ink-3); margin: 22px 0 10px; }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.page-head { margin-bottom: 18px; }
.lead { font-size: 1.08rem; color: var(--ink-2); max-width: 70ch; margin: 0; }
.privacy-note { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--ink-3); margin-top: 10px; }
.privacy-note svg { width: 14px; height: 14px; }

.tool {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: clamp(16px, 2.5vw, 24px); margin-bottom: 40px;
}
.tool > * + * { margin-top: 16px; } /* worker fragments often stack top-level blocks without a gap */
.section { margin: 0 0 40px; }
.section > h2 { font-size: 1.25rem; }
.prose { max-width: 72ch; color: var(--ink-2); }
.prose p { margin-bottom: 0.9em; }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; max-width: 72ch; }
.steps li { counter-increment: step; position: relative; padding-left: 40px; color: var(--ink-2); }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 0.85rem; display: grid; place-items: center;
}
.faq { display: grid; gap: 8px; max-width: 80ch; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 16px; }
.faq summary { cursor: pointer; font-weight: 600; padding: 14px 0; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--ink-3); font-weight: 400; font-size: 1.2rem; line-height: 1; }
.faq details[open] summary::after { content: "–"; }
.faq details p { color: var(--ink-2); margin: 0 0 14px; }
.related { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.tool-card {
  display: block; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; transition: border-color 0.15s, transform 0.15s;
}
.tool-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.tool-card strong { display: block; font-weight: 650; margin-bottom: 2px; }
.tool-card span { color: var(--ink-3); font-size: 0.875rem; line-height: 1.45; display: block; }
.site-footer { border-top: 1px solid var(--line); color: var(--ink-3); font-size: 0.875rem; padding: 28px 0 40px; margin-top: 24px; }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }
.site-footer a { color: var(--ink-2); }
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }
.legal { max-width: 72ch; color: var(--ink-2); padding-bottom: 24px; }
.legal h1 { color: var(--ink); }
.legal h2 { color: var(--ink); font-size: 1.15rem; margin-top: 28px; }
.legal li { margin-bottom: 6px; }
.home-hero { padding: 40px 0 28px; }
.home-hero h1 { max-width: 20ch; }
.section > .cat-title, .cat-title { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); margin: 28px 0 10px; }

/* ---------- widget kit (worker-facing) ---------- */
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr; }
.grid-3 { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}
.spacer { flex: 1; }
.grow { flex: 1 1 200px; min-width: 0; }
.row.bottom { align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: 0.875rem; font-weight: 600; color: var(--ink-2); }
.hint { font-size: 0.82rem; color: var(--ink-3); margin: 0; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; min-height: 34px; }

.input, .select, .textarea {
  width: 100%; font: inherit; font-size: 0.95rem; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 9px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input[readonly], .textarea[readonly] { background: var(--surface-2); }
.select { appearance: none; padding-right: 34px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
.textarea { min-height: 220px; resize: vertical; line-height: 1.5; }
.textarea[rows] { min-height: 0; } /* an explicit rows= sets the height */
.mono, .textarea.mono, .input.mono { font-family: var(--mono); font-size: 0.875rem; tab-size: 2; font-variant-ligatures: none; }
/* input + attached button(s): <div class="input-group"><input class="input"><button class="btn">Copy</button></div> */
.input-group { display: flex; align-items: stretch; min-width: 0; }
.input-group > .input, .input-group > .select { flex: 1; min-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group > .btn { border-radius: 0; margin-left: -1px; }
.input-group > .btn:last-child { border-top-right-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); }
.input-group > input[type="color"].color { border-radius: var(--radius-sm) 0 0 var(--radius-sm); height: auto; width: 46px; flex: none; border-right: 0; }
.input-group > input[type="color"].color + .input { border-radius: 0; }
.input-group > input[type="color"].color + .input:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
/* a sub-section inside the tool (only when the tool has 2+ distinct parts) */
.panel { background: var(--surface-2); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.panel-title { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-3); margin: 0; }
.panel .input, .panel .select, .panel .textarea { background: var(--surface); }
.panel .input[readonly], .panel .textarea[readonly], .panel .output { background: var(--surface); }
.input.sm, .select.sm { padding: 6px 10px; font-size: 0.875rem; width: auto; }
.select.sm { padding-right: 30px; background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%; }
input[type="color"].color { width: 44px; height: 38px; padding: 3px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
.range { width: 100%; accent-color: var(--accent); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 0.92rem; color: var(--ink-2); cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-size: 0.92rem; font-weight: 600;
  padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink); cursor: pointer; transition: background 0.15s, border-color 0.15s, transform 0.05s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-sm { padding: 5px 10px; font-size: 0.82rem; }
.btn.is-done { color: var(--ok); border-color: currentColor; }

.output {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px;
  min-height: 46px; overflow-wrap: anywhere; white-space: pre-wrap;
}
.output.mono { font-size: 0.875rem; }
.error { color: var(--err); background: var(--err-soft); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 0.9rem; }
.error:empty { display: none; }
.ok-text { color: var(--ok); }

.stat-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat-value { font-size: 1.6rem; font-weight: 750; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 0.8rem; color: var(--ink-3); margin-top: 4px; }

.result-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.result-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.result-item .result-text { overflow-wrap: anywhere; min-width: 0; }
.result-item .result-meta { font-size: 0.78rem; color: var(--ink-3); }

.swatch-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.swatch {
  border-radius: var(--radius); min-height: 120px; border: 1px solid rgb(0 0 0 / 0.08); display: flex; flex-direction: column;
  justify-content: flex-end; padding: 10px; font-family: var(--mono); font-size: 0.85rem; cursor: pointer; position: relative;
}
.swatch.sm { min-height: 44px; width: 44px; padding: 0; }
.swatch.lg { min-height: 160px; width: 100%; font-size: 1rem; }
.preview-box { border: 1px solid var(--line); border-radius: var(--radius); min-height: 220px; display: grid; place-items: center; background: var(--surface-2); padding: 24px; }
.checkerboard {
  background-color: #fff;
  background-image: linear-gradient(45deg, #e5e5e5 25%, transparent 25%), linear-gradient(-45deg, #e5e5e5 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e5e5 75%), linear-gradient(-45deg, transparent 75%, #e5e5e5 75%);
  background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; overflow-x: auto; }
.tab {
  font: inherit; font-size: 0.9rem; font-weight: 600; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--ink-3); padding: 8px 12px; cursor: pointer; margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: 0.8rem; font-weight: 600; padding: 3px 9px;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent);
}
.big-number { font-size: clamp(3rem, 2rem + 6vw, 5.5rem); font-weight: 800; letter-spacing: -0.04em; line-height: 1; font-variant-numeric: tabular-nums; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.frame.tall { min-height: 470px; }
.frame { width: 100%; min-height: 320px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
.log { font-family: var(--mono); font-size: 0.85rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); min-height: 140px; max-height: 360px; overflow: auto; padding: 6px 0; }
.log-line { padding: 3px 12px; white-space: pre-wrap; overflow-wrap: anywhere; border-bottom: 1px solid var(--line); }
.log-line:last-child { border-bottom: 0; }
.log-line.is-error { color: var(--err); background: var(--err-soft); }
.log-line.is-warn { color: #b45309; }
.log-line.is-muted { color: var(--ink-3); font-style: italic; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 999px; font-size: 0.9rem; font-weight: 600;
  transition: opacity 0.2s, transform 0.2s; z-index: 50;
}
.toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
