/* ==========================================================================
   MZLDP tools — shared design system
   Per-tool identity comes from --accent / --accent-2 (injected by build.py).
   ========================================================================== */
:root {
  --accent: #be123c;
  --accent-2: #a3e635;

  --bg: #f6f5f1;
  --surface: #ffffff;
  --raised: #fbfaf7;
  --ink: #16161a;
  --ink-2: #3d3d45;
  --muted: #6b6b74;
  --line: #e4e1d9;
  --line-strong: #d2cec3;
  --field: #ffffff;

  --link: var(--accent);
  --tint: color-mix(in oklab, var(--accent) 8%, var(--bg));
  --tint-2: color-mix(in oklab, var(--accent-2) 22%, var(--bg));
  --accent-hover: color-mix(in oklab, var(--accent) 86%, black);
  --ring: color-mix(in oklab, var(--accent) 30%, transparent);

  --ok: #12804a;
  --warn: #b26b00;
  --bad: #c42b2b;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(22, 22, 26, .05);
  --shadow: 0 1px 2px rgba(22, 22, 26, .04), 0 8px 24px -8px rgba(22, 22, 26, .10);
  --shadow-lg: 0 2px 4px rgba(22, 22, 26, .04), 0 24px 48px -16px rgba(22, 22, 26, .18);

  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --body: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111113;
    --surface: #19191c;
    --raised: #1e1e22;
    --ink: #f1f0ec;
    --ink-2: #cfcdc7;
    --muted: #9b9aa2;
    --line: #2b2b31;
    --line-strong: #3a3a42;
    --field: #141417;
    --link: color-mix(in oklab, var(--accent) 55%, white);
    --tint: color-mix(in oklab, var(--accent) 16%, var(--bg));
    --tint-2: color-mix(in oklab, var(--accent-2) 18%, var(--bg));
    --ok: #4ccf8a;
    --warn: #f0b545;
    --bad: #ff7272;
    --shadow-sm: none;
    --shadow: 0 0 0 1px rgba(255, 255, 255, .02), 0 12px 32px -12px rgba(0, 0, 0, .6);
    --shadow-lg: 0 24px 48px -16px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

/* Serif display variant (typographic tools) */
.font-serif { --display: "Fraunces", Georgia, "Times New Roman", serif; }
.font-serif .hero h1 { font-weight: 700; letter-spacing: -0.03em; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 16px; }
body {
  margin: 0;
  font: 16px/1.6 var(--body);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
img, svg, canvas { max-width: 100%; }
h1, h2, h3 { font-family: var(--display); color: var(--ink); line-height: 1.15; letter-spacing: -0.02em; }
::selection { background: color-mix(in oklab, var(--accent-2) 55%, transparent); color: var(--ink); }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: var(--r-sm); z-index: 100; }
.skip:focus { left: 8px; }

/* ---------- Header ---------- */
.site-header { position: relative; z-index: 5; background: var(--tint); }
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 64px; gap: 12px; }
.crumbs { display: flex; align-items: center; gap: 10px; min-width: 0; }
.org { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.org img { display: block; height: 28px; width: auto; }
.brand-mark { display: none; }
.crumb-sep { color: var(--line-strong); font-size: 22px; font-weight: 300; }
.tool-home { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 650; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-home img { flex: none; width: 26px; height: 26px; }
.tool-home span { overflow: hidden; text-overflow: ellipsis; }
.top-nav { display: flex; align-items: center; gap: 6px; }
.top-nav a { color: var(--ink-2); text-decoration: none; font-size: 15px; font-weight: 550; padding: 7px 12px; border-radius: 999px; }
.top-nav a:hover { background: color-mix(in oklab, var(--accent) 10%, transparent); color: var(--ink); }
.top-nav .nav-pill { border: 1px solid var(--line-strong); background: var(--surface); white-space: nowrap; }
@media (max-width: 600px) {
  .top-nav a:not(.nav-pill) { display: none; }
  .crumb-sep ~ .tool-home { margin-left: 0; }
  .crumbs:has(.tool-home) .brand-word { display: none; }
  .crumbs:has(.tool-home) .brand-mark { display: block; }
}

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  background: var(--tint);
  padding: 40px 0 120px;
  border-bottom: 1px solid color-mix(in oklab, var(--accent) 14%, var(--line));
}
.hero::before { /* fine dot grid in the tool color */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(color-mix(in oklab, var(--accent) 22%, transparent) 1px, transparent 1.4px);
  background-size: 20px 20px;
  mask-image: linear-gradient(to bottom, transparent, #000 30%, #000 60%, transparent);
  opacity: .7;
}
.hero-inner { position: relative; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 24px; }
.eyebrow { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; padding: 0; list-style: none; }
.eyebrow li {
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  padding: 4px 10px 4px 8px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  display: inline-flex; align-items: center; gap: 6px;
}
.eyebrow li::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 0 2px color-mix(in oklab, var(--accent-2) 30%, transparent); }
.hero h1 { font-size: clamp(34px, 5.6vw, 58px); font-weight: 800; margin: 0 0 14px; max-width: 16ch; }
.lede { color: var(--ink-2); font-size: clamp(17px, 2vw, 19px); line-height: 1.55; margin: 0; max-width: 60ch; }
.hero-logo {
  width: clamp(170px, 20vw, 240px); height: auto; margin-right: 8px;
  filter: drop-shadow(0 18px 28px color-mix(in oklab, var(--accent) 28%, transparent));
  transform: rotate(-4deg); animation: float 7s ease-in-out infinite;
}
@keyframes float { 0%, 100% { transform: rotate(-4deg) translateY(0); } 50% { transform: rotate(-2deg) translateY(-8px); } }
@media (max-width: 760px) {
  .hero { padding: 28px 0 96px; }
  .hero-inner { grid-template-columns: 1fr; }
  .hero-logo { order: -1; width: 88px; margin: 0 0 4px; animation: none; transform: rotate(-4deg); }
}

/* ---------- Tool card ---------- */
.tool {
  position: relative; z-index: 2;
  margin: -88px 0 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px;
}
@media (max-width: 600px) { .tool { padding: 18px; margin-top: -72px; border-radius: var(--r); } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }

/* ---------- Form controls ---------- */
label { font-weight: 650; font-size: 14px; color: var(--ink-2); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field small { font-size: 13px; }
input[type=text], input[type=number], input[type=date], input[type=password], input[type=url],
input[type=email], input[type=tel], select, textarea {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--field);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  padding: 10px 12px; width: 100%; min-height: 44px;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: color-mix(in oklab, var(--muted) 80%, transparent); }
select {
  appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%236b6b74' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
}
textarea { min-height: 240px; resize: vertical; line-height: 1.6; padding: 14px 16px; }
textarea.mono, .mono { font-family: var(--mono); font-size: 14px; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in oklab, var(--accent) 40%, var(--line-strong)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; cursor: pointer; }
input[type=range] { accent-color: var(--accent); width: 100%; cursor: pointer; }
.check {
  display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none;
  font-weight: 550; font-size: 15px; color: var(--ink);
  padding: 8px 12px; margin: 0 6px 8px 0; border: 1px solid var(--line); border-radius: 999px; background: var(--raised);
  transition: border-color .15s, background .15s;
}
.check:hover { border-color: color-mix(in oklab, var(--accent) 45%, var(--line)); }
.check:has(input:checked) { border-color: color-mix(in oklab, var(--accent) 55%, var(--line)); background: color-mix(in oklab, var(--accent) 8%, var(--surface)); }

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-weight: 650; font-size: 15px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s, color .15s, transform .06s;
}
.btn:hover { border-color: color-mix(in oklab, var(--accent) 50%, var(--line-strong)); background: color-mix(in oklab, var(--accent) 6%, var(--surface)); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 6px 16px -8px var(--accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.small { min-height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: color-mix(in oklab, var(--accent) 8%, transparent); border-color: transparent; }
.btns { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 14px 0; }

/* ---------- Segmented tabs ---------- */
.tabs {
  display: inline-flex; flex-wrap: wrap; gap: 4px; margin-bottom: 20px; padding: 4px;
  background: var(--raised); border: 1px solid var(--line); border-radius: 12px;
}
.tabs button {
  font: inherit; font-size: 14px; font-weight: 650; cursor: pointer; color: var(--ink-2);
  padding: 8px 14px; border-radius: 9px; border: 0; background: transparent;
  transition: background .15s, color .15s;
}
.tabs button:hover { color: var(--ink); background: color-mix(in oklab, var(--accent) 7%, transparent); }
.tabs button[aria-selected=true] { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }
@media (prefers-color-scheme: dark) { .tabs button[aria-selected=true] { color: var(--link); background: var(--line); } }
@media (max-width: 600px) {
  .tabs { display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { white-space: nowrap; flex: none; }
}

/* ---------- Layout helpers & results ---------- */
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 18px 0 0; }
.stat { background: var(--raised); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.stat b { display: block; font: 750 28px/1.15 var(--display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--ink); }
.stat span { color: var(--muted); font-size: 13px; font-weight: 550; }
.stat:first-child b { color: var(--accent); }
@media (prefers-color-scheme: dark) { .stat:first-child b { color: var(--link); } }
.result { font: 750 26px/1.25 var(--display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.error { color: var(--bad); font-weight: 600; }
.ok { color: var(--ok); font-weight: 600; }
.panel-h { font: 700 15px/1.3 var(--body); letter-spacing: 0; color: var(--ink-2); margin: 0 0 12px; text-transform: uppercase; font-size: 12.5px; letter-spacing: .06em; }

/* ---------- Article + TOC ---------- */
.article-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 40px; align-items: start; margin-top: 8px; }
.toc { position: sticky; top: 20px; font-size: 14px; }
.toc p { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 6px 0 10px; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.toc a { display: block; padding: 5px 0 5px 14px; margin-left: -2px; border-left: 2px solid transparent; color: var(--ink-2); text-decoration: none; line-height: 1.35; }
.toc a:hover { color: var(--ink); border-left-color: var(--line-strong); }
.toc a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 650; }
@media (prefers-color-scheme: dark) { .toc a.active { color: var(--link); } }
@media (max-width: 900px) { .article-layout { grid-template-columns: minmax(0, 1fr); } .toc { display: none; } }

.content { max-width: 720px; color: var(--ink-2); font-size: 17px; line-height: 1.72; }
.content > :first-child { margin-top: 0; }
.content h2 { font-size: clamp(24px, 3vw, 30px); font-weight: 750; margin: 48px 0 12px; }
.content h3 { font-size: 19px; font-weight: 700; margin: 28px 0 6px; letter-spacing: -0.01em; }
.content p, .content ul, .content ol { margin: 0 0 16px; }
.content li { margin-bottom: 6px; padding-left: 2px; }
.content li::marker { color: var(--accent); font-weight: 700; }
.content strong { color: var(--ink); }
.content table { border-collapse: separate; border-spacing: 0; width: 100%; margin: 18px 0 24px; font-size: 15px; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.content thead th { background: var(--tint); color: var(--ink); font-weight: 700; font-size: 13.5px; }
.content th, .content td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.content tbody tr:last-child td { border-bottom: 0; }
.content tbody tr:hover td { background: var(--raised); }
.content table { display: table; }
@media (max-width: 640px) { .content table { display: block; } }
.content code { font-family: var(--mono); font-size: .86em; background: var(--tint); color: var(--ink); border-radius: 5px; padding: 2px 6px; }
.content blockquote { margin: 18px 0; padding: 16px 20px; background: var(--tint-2); border-radius: var(--r); font-style: italic; color: var(--ink); }
.content blockquote p { margin: 0; }

/* FAQ */
.faq { margin-top: 48px; }
.faq details { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); margin-bottom: 10px; transition: border-color .15s; }
.faq details[open] { border-color: color-mix(in oklab, var(--accent) 35%, var(--line)); }
.faq summary { cursor: pointer; font-weight: 650; color: var(--ink); padding: 16px 52px 16px 18px; list-style: none; position: relative; line-height: 1.4; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: ""; position: absolute; right: 18px; top: 50%; width: 20px; height: 20px; margin-top: -10px; border-radius: 50%;
  background: var(--tint) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M5 1v8M1 5h8' stroke='%236b6b74' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") center no-repeat;
  transition: transform .2s;
}
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { margin: 0; padding: 0 18px 18px; color: var(--ink-2); font-size: 16px; }

.legal { padding: 48px 0 16px; }
.legal h1 { font-size: clamp(32px, 5vw, 44px); margin: 0 0 18px; }

/* ---------- Related tools ---------- */
.related { margin-top: 64px; padding-top: 32px; border-top: 1px solid var(--line); }
.related-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.related h2 { font-size: 24px; margin: 0; }
.related-head a { font-weight: 650; font-size: 15px; }
.tool-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.tool-link {
  display: flex; align-items: center; gap: 12px; height: 100%;
  padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  text-decoration: none; color: var(--ink); transition: border-color .15s, transform .15s, box-shadow .15s;
}
.tool-link:hover { border-color: var(--c); transform: translateY(-2px); box-shadow: var(--shadow); }
.tool-icon { flex: none; width: 48px; height: 48px; transition: transform .2s; }
.tool-link:hover .tool-icon { transform: rotate(-6deg) scale(1.06); }
.tool-link b { display: block; font-size: 15px; line-height: 1.3; }
.tool-link small { display: block; color: var(--muted); font-size: 13px; line-height: 1.35; margin-top: 2px; }

/* ---------- Ads (reserved height avoids CLS) ---------- */
.ad { margin: 32px auto; min-height: 120px; text-align: center; }
.ad::before { content: "Advertisement"; display: block; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }

/* ---------- Footer ---------- */
.site-footer { margin-top: 80px; background: var(--surface); border-top: 1px solid var(--line); font-size: 15px; }
.footer-grid { display: grid; grid-template-columns: 1.3fr 2fr 0.8fr; gap: 40px; padding-top: 48px; padding-bottom: 32px; }
.footer-brand p { color: var(--muted); max-width: 34ch; margin: 14px 0 0; font-size: 14.5px; }
.org-lg img { height: 36px; }
.site-footer h2 { font: 700 12px/1 var(--body); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 6px 0 14px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 8px; }
.site-footer nav a { color: var(--ink-2); text-decoration: none; }
.site-footer nav a:hover { color: var(--ink); text-decoration: underline; }
.footer-tools { columns: 2; column-gap: 24px; }
.footer-tools a { display: inline-flex; align-items: center; gap: 9px; }
.footer-tools img { width: 20px; height: 20px; flex: none; }
.footer-tools a[aria-current] { color: var(--ink); font-weight: 650; }
.footer-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding-top: 18px; padding-bottom: 28px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13.5px; }
@media (max-width: 820px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-brand { grid-column: 1 / -1; } }
@media (max-width: 480px) { .footer-grid { grid-template-columns: 1fr; } .footer-tools { columns: 1; } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 16px);
  background: var(--ink); color: var(--bg); padding: 11px 18px 11px 14px; border-radius: 12px;
  font-weight: 650; font-size: 14px; box-shadow: var(--shadow-lg);
  display: inline-flex; align-items: center; gap: 10px;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 50;
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
.page-content { max-width: 820px; margin: 8px auto 0; }
.related-pages { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; }
.related-pages li { margin: 0; padding: 0; }
.related-pages a { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); text-decoration: none; font-size: 14.5px; font-weight: 550; }
.related-pages a:hover { border-color: var(--accent); }
