/* Neutral base. Violet only marks actions, the selected state, the main answer, links and the wordmark. */
:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f0f0f2;
  --field: #ffffff;
  --text: #202124;
  --muted: #53565d;
  --line: #d8d9de;
  --control-line: #777a84;
  --accent: #5b3fd1;
  --accent-ink: #ffffff;
  --accent-soft: #eee9ff;
  --accent-line: #cbbefa;
  --focus: #5437c4;
  --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%2353565d' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='9' cy='9' r='6'/%3E%3Cpath d='m14 14 4 4'/%3E%3C/svg%3E");
  --radius: 14px;
  --shadow: 0 1px 2px rgb(32 33 36 / 0.04);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --wide: 1120px;
  --read: 820px;
  --tool: 1040px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121315;
    --surface: #1c1d20;
    --surface-2: #25262a;
    --field: #191a1d;
    --text: #f2f2f4;
    --muted: #b7bac3;
    --line: #383a41;
    --control-line: #80838e;
    --accent: #b5a5ff;
    --accent-ink: #19112d;
    --accent-soft: #2d2544;
    --accent-line: #524475;
    --focus: #b5a5ff;
    --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%23b7bac3' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='9' cy='9' r='6'/%3E%3Cpath d='m14 14 4 4'/%3E%3C/svg%3E");
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); color: var(--text); font: 16px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-underline-offset: 2px; }
img { max-width: 100%; height: auto; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
::placeholder { color: var(--muted); opacity: 1; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.skip-link { position: absolute; left: -9999px; top: 0; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; z-index: 10; border-radius: 8px; }
.skip-link:focus { left: 8px; top: 8px; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.site-bar { max-width: var(--wide); margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 20px; }
.site-brand, .footer-brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 750; font-size: 1.16rem; letter-spacing: -0.02em; white-space: nowrap; }
.site-brand b, .footer-brand b { color: var(--accent); font-weight: 750; }
.wordmark { display: inline-flex; flex: none; }
.wordmark img { height: 36px; width: auto; display: block; }
.footer-brand .wordmark img { height: 30px; }
.logo-mark { display: inline-flex; flex: none; }
.logo-mark img { width: auto; height: 30px; display: block; }
.site-tabs { display: flex; flex-wrap: wrap; gap: 2px; min-width: 0; margin-left: auto; }
.site-tab { position: relative; display: inline-flex; align-items: center; min-height: 40px; color: var(--muted); text-decoration: none; padding: 6px 12px; border-radius: 8px; white-space: nowrap; font-size: 0.93rem; font-weight: 500; }
.site-tab:hover { background: var(--surface-2); color: var(--text); }
.site-tab.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.site-tab.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 3px; height: 2px; border-radius: 2px; background: currentColor; }
@media (min-width: 641px) { html { scroll-padding-top: 72px; } }
@media (max-width: 640px) {
  .site-header { position: static; }
  .site-bar { flex-wrap: wrap; gap: 4px; padding: 8px 16px 6px; }
  .site-brand .wordmark img { height: 32px; }
  .site-brand { min-height: 44px; }
  .site-tabs { width: 100%; margin: 0 0 0 -10px; gap: 0 2px; }
  .site-tab { min-height: 44px; padding: 6px 10px; }
}

/* Layout */
.page { flex: 1 0 auto; width: 100%; max-width: var(--wide); margin: 0 auto; padding: 24px 16px 56px; }
.page.has-rail { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
@media (min-width: 1440px) { .page.has-rail { max-width: 1440px; grid-template-columns: minmax(0, 1fr) 300px; } }
.ad-rail { display: none; }
@media (min-width: 1440px) { .ad-rail { display: block; position: sticky; top: 80px; align-self: start; min-height: 600px; } }
.app-shell { max-width: var(--read); margin: 0 auto; width: 100%; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }

.crumbs { font-size: 0.88rem; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; display: inline-block; padding: 2px 0; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }

/* Hero */
.hero { display: flex; gap: 16px; align-items: flex-start; padding: 6px 0 2px; }
.hero-icon { flex: none; width: 56px; height: 56px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: 1.8rem; }
.eyebrow { margin: 0; color: var(--muted); font-weight: 650; font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; }
.hero h1 { margin: 2px 0 8px; font-size: clamp(1.75rem, 4.6vw, 2.5rem); line-height: 1.12; letter-spacing: -0.03em; }
.hero .description { margin: 0; color: var(--muted); font-size: 1.07rem; max-width: 62ch; }
.home-hero { padding: 28px 0 10px; text-align: center; justify-content: center; }
.home-hero h1 { font-size: clamp(2rem, 6vw, 3.1rem); }
.home-hero .description { margin: 0 auto; }
.tool-search { margin: 22px auto 0; max-width: 560px; }
.tool-search input { width: 100%; font: inherit; font-size: 1.06rem; min-height: 48px; padding: 12px 18px 12px 46px; border-radius: 999px; border: 1px solid var(--control-line); background: var(--field) var(--glyph) no-repeat 17px 50%; color: var(--text); }
.tool-search input:focus { border-color: var(--accent); }
.search-empty { text-align: center; color: var(--muted); margin: 0; }
.search-empty[hidden] { display: none; }
.jurisdiction { margin: 10px 0 6px; padding: 8px 12px; border-left: 4px solid var(--control-line); background: var(--surface-2); border-radius: 8px; font-size: 0.95rem; }

/* Cards and prose */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { margin: 0 0 12px; font-size: 1.28rem; letter-spacing: -0.015em; line-height: 1.25; }
.card h2 a { color: var(--text); text-decoration: none; }
.card h2 a:hover { color: var(--accent); text-decoration: underline; }
/* Prose and link lists sit on the page, not in boxes, so the tool is the one box that stands out. */
.card.prose, .card.flat, .card:has(> .hub-grid) { background: transparent; border: 0; box-shadow: none; padding: 4px 0; border-radius: 0; }
.prose > :is(p, ul, ol, h3, blockquote) { max-width: 68ch; }
.prose h3 { margin: 18px 0 6px; font-size: 1.06rem; }
.prose li + li { margin-top: 4px; }
.prose > :last-child { margin-bottom: 0; }
.prose img { display: block; margin: 12px auto; max-width: 100%; }
.tool-card { border-color: var(--line); }

/* Tool layout: the form, then the answer right under it. Side by side when there is room. */
[data-tool] { container-type: inline-size; }
.tool-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-items: start; }
.tool-form { min-width: 0; }
.tool-layout > .tool-results { min-width: 0; }
@container (min-width: 700px) {
  .tool-layout.is-split { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 24px; }
  .tool-layout.is-split > .tool-results { position: sticky; top: 76px; }
  .tool-layout.is-split .input-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
  .tool-layout.is-split .summary-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
}
@media (min-width: 900px) {
  /* Tool pages: the tool gets the full width, the reading parts keep a reading width, all on one left edge. */
  .app-shell:has(> .tool-card) { max-width: var(--tool); }
  .app-shell:has(> .tool-card) > :not(.tool-card, .ad-slot) { max-width: var(--read); width: 100%; }
}
/* Phones: while a long form scrolls, its main answer stays pinned at the top of the screen. */
.answer-peek { display: none; }
@media (max-width: 640px) {
  .tool-layout.is-long .answer-peek {
    display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
    position: sticky; top: 0; z-index: 2; margin: -4px -4px 12px; padding: 8px 12px;
    background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 10px;
    box-shadow: 0 2px 8px rgb(0 0 0 / 0.12); transition: opacity 0.15s;
  }
  .tool-layout.is-long.answer-in-view .answer-peek { opacity: 0; pointer-events: none; }
  .answer-peek span { color: var(--muted); font-size: 0.86rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .answer-peek strong { color: var(--accent); font-size: 1.15rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
}

/* Tool inputs */
.input-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 14px 16px; }
.field { display: grid; gap: 6px; align-content: start; min-width: 0; }
.field[hidden], .toggle[hidden] { display: none; }
.field-label { font-weight: 600; font-size: 0.93rem; line-height: 1.35; }
.field-help { color: var(--muted); font-size: 0.84rem; line-height: 1.45; }
.field input, .field select, .field textarea { font: inherit; font-size: 1.05rem; padding: 10px 12px; border: 1px solid var(--control-line); border-radius: 10px; background-color: var(--field); color: var(--text); width: 100%; min-height: 44px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { resize: vertical; line-height: 1.45; }
.field input[type="file"] { font-size: 0.95rem; padding: 8px; }
.field:has(.pill-row) { grid-column: 1 / -1; }
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { font: inherit; font-size: 0.95rem; min-height: 40px; padding: 7px 15px; border-radius: 999px; border: 1px solid var(--control-line); background: var(--field); color: var(--text); cursor: pointer; }
.pill:hover { border-color: var(--accent); }
.pill.on, .pill[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.toggle { display: flex; gap: 10px; align-items: flex-start; min-height: 44px; padding: 4px 0; cursor: pointer; }
.toggle input { flex: none; width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); }
.toggle small { display: block; color: var(--muted); font-size: 0.84rem; line-height: 1.45; }
.tool-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin: 12px 0 0; }
.tool-btn { font: inherit; font-size: 0.93rem; min-height: 40px; padding: 7px 15px; border-radius: 10px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); cursor: pointer; font-weight: 600; }
.tool-btn.ghost { background: var(--field); color: var(--text); border-color: var(--control-line); }
.tool-btn.ghost:hover { border-color: var(--accent); color: var(--accent); }

/* Tool results: the main answer first, then any picture, then the details. */
.tool-results { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-content: start; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 10px; }
.summary-stat { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.summary-stat.is-wide { grid-column: 1 / -1; }
.summary-stat.is-main { background: var(--accent-soft); border: 1px solid var(--accent-line); grid-column: 1 / -1; }
.summary-label { margin: 0; color: var(--muted); font-size: 0.86rem; }
.summary-value { margin: 2px 0 0; font-size: 1.22rem; font-weight: 700; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.summary-stat.is-main .summary-value { font-size: clamp(1.8rem, 6vw, 2.4rem); line-height: 1.15; color: var(--accent); letter-spacing: -0.02em; }
.tool-visual { overflow-x: auto; min-width: 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.tool-visual canvas { display: block; max-width: 100%; height: auto; margin-inline: auto; border-radius: 6px; }
.tool-visual .tool-actions { justify-content: flex-start; margin: 10px 0 0; }
.tool-visual .mc-scroll { background: var(--surface); }
.tool-visual > div > p:last-child { margin-bottom: 0; }
.note { margin: 0; color: var(--muted); font-size: 0.9rem; }

/* Wide tables scroll inside their box. The edge shadows show only when there is more to see. */
.table-wrap {
  overflow-x: auto; max-width: 100%; border: 1px solid var(--line); border-radius: 12px;
  background:
    linear-gradient(to right, var(--surface) 30%, transparent) left / 40px 100% no-repeat local,
    linear-gradient(to left, var(--surface) 30%, transparent) right / 40px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgb(0 0 0 / 0.22), transparent) left / 12px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgb(0 0 0 / 0.22), transparent) right / 12px 100% no-repeat scroll,
    var(--surface);
}
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
th { color: var(--muted); font-weight: 600; background: var(--surface-2); font-size: 0.88rem; }
td:not(:first-child), th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }

.faq-list { display: grid; gap: 8px; }
.faq-list details { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.faq-list details[open] { background: var(--surface-2); }
.faq-list summary { cursor: pointer; font-weight: 600; padding: 12px 16px; min-height: 44px; }
.faq-list p { margin: 0; padding: 0 16px 12px; color: var(--muted); max-width: 68ch; }
.checked { color: var(--muted); font-size: 0.86rem; margin: 0 4px; }

/* Tool cards */
.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 10px; }
.hub-card { display: flex; gap: 12px; align-items: flex-start; padding: 13px 14px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--text); background: var(--surface); transition: border-color 0.15s; }
.hub-card:hover { border-color: var(--accent); }
.hub-card:hover strong { color: var(--accent); }
.hub-card[hidden] { display: none; }
.hub-icon { flex: none; width: 40px; height: 40px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: 1.25rem; line-height: 1; }
.hub-text { min-width: 0; }
.hub-card strong { display: block; font-size: 0.98rem; line-height: 1.3; }
.hub-card small { display: block; color: var(--muted); font-size: 0.85rem; line-height: 1.45; margin-top: 3px; }
.topic[hidden], .newest[hidden] { display: none; }
/* The home directory is for scanning: short blurbs there, the full text on the section pages. */
.topic .hub-card small { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 640px) { .topic .hub-card small { -webkit-line-clamp: 2; } }
.topic h2 { display: flex; align-items: center; gap: 8px; }
.topic h2 a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; }

/* Footer and ads */
.ad-slot { min-height: 280px; margin-block: 24px; padding-top: 8px; border-top: 1px solid var(--line); }
.site-footer { margin-top: auto; border-top: 1px solid var(--line); background: var(--surface); padding: 28px 16px 36px; text-align: center; display: grid; justify-items: center; gap: 12px; }
.footer-brand { font-size: 1.05rem; }
.footer-brand .logo-mark img { height: 26px; }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 10px; }
.footer-links a { display: inline-flex; align-items: center; min-height: 32px; padding: 0 6px; color: var(--muted); text-decoration: none; font-size: 0.93rem; }
.footer-links a:hover { color: var(--accent); text-decoration: underline; }
.legal { color: var(--muted); font-size: 0.83rem; margin: 0 auto; max-width: 640px; }
.tip-btn { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 16px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); text-decoration: none; }

/* Phones: tighter spacing, bigger tap targets, short fields in pairs. */
@media (max-width: 640px) {
  .pill, .tool-btn { min-height: 44px; }
  .footer-links a { min-height: 44px; }
  th, td { padding: 8px 8px; }
}
@media (max-width: 520px) {
  .page { padding-top: 16px; }
  .app-shell { gap: 12px; }
  .hero { gap: 8px; }
  .hero-icon { display: none; }
  .card { padding: 16px; }
  .card.prose, .card.flat, .card:has(> .hub-grid) { padding: 4px 0; }
  .card h2 { margin-bottom: 10px; }
  .input-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; }
  .input-grid > * { grid-column: 1 / -1; }
  .input-grid > .field.half { grid-column: auto; }
  .field { gap: 4px; }
  .tool-actions { margin-top: 8px; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .summary-stat { padding: 10px 12px; }
  .tool-visual { padding: 8px; }
}
/* A pair's inputs line up even when one label wraps. */
@supports (grid-template-rows: subgrid) {
  @media (max-width: 520px) {
    .input-grid > .field { grid-row: span 3; grid-template-rows: subgrid; row-gap: 4px; }
  }
}
