/* Code & Rules Assistant — shared styles.
   Layout: one reading column; a quiet header with section nav; statute citations
   rendered as monospace "chips" (the tool's core object); every collapsible
   source/context row shares one style. Fonts are self-hosted (the site's CSP
   allows no font CDN). */

@font-face { font-family: "Inter"; font-weight: 400; font-style: normal; font-display: swap; src: url("/fonts/inter-400.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 500; font-style: normal; font-display: swap; src: url("/fonts/inter-500.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-style: normal; font-display: swap; src: url("/fonts/inter-600.woff2") format("woff2"); }
@font-face { font-family: "Source Serif 4"; font-weight: 600; font-style: normal; font-display: swap; src: url("/fonts/serif-600.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-style: normal; font-display: swap; src: url("/fonts/mono-500.woff2") format("woff2"); }

:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --sunk: #eef1f5;
  --ink: #141b24;
  --muted: #5b6676;
  --line: #dde2e9;
  --accent: #1d4f8c;
  --accent-ink: #ffffff;
  --accent-soft: #e7eef8;
  --good: #2b6b45;
  --good-soft: #e3f1e8;
  --warn: #8a5800;
  --warn-soft: #fbf0d9;
  --bad: #a3362c;
  --bad-soft: #f8e4e1;
  --code-bg: #f0f2f5;
  --radius: 12px;
  --font: "Inter", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419;
    --panel: #161d25;
    --sunk: #121920;
    --ink: #e4e8ee;
    --muted: #95a1b0;
    --line: #26303b;
    --accent: #7fb0ea;
    --accent-ink: #0b1520;
    --accent-soft: #1a2a3c;
    --good: #7cc79a;
    --good-soft: #17291f;
    --warn: #e2b462;
    --warn-soft: #33281a;
    --bad: #ee8a7e;
    --bad-soft: #35201e;
    --code-bg: #1c242e;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--font);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); text-underline-offset: 2px; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 780px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.wrap.wide { max-width: 1200px; }

/* ---- header ---- */
header.site { background: var(--panel); border-bottom: 1px solid var(--line); }
header.site .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: var(--serif); font-size: 1.12rem; font-weight: 600; line-height: 1.2; }
.brand .mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font: 600 18px/1 var(--serif); flex: none; }
.brand small { display: block; font: 400 .76rem/1.3 var(--font); color: var(--muted); }
nav.top { display: flex; gap: 4px; align-items: center; }
nav.top a { text-decoration: none; color: var(--muted); font-size: .92rem; font-weight: 500; padding: 6px 10px; border-radius: 8px; }
nav.top a:hover { color: var(--ink); background: var(--sunk); }
nav.top a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
@media (max-width: 560px) { .brand small { display: none; } header.site .wrap { flex-wrap: nowrap; } }
.pill { font-size: .78rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; white-space: nowrap; text-decoration: none; }

/* ---- type ---- */
h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.75rem, 4.5vw, 2.35rem); line-height: 1.15; letter-spacing: -.01em; margin: 0; text-wrap: balance; }
.eyebrow { font-size: .74rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.lede { color: var(--muted); max-width: 60ch; margin: 0; font-size: 1.02rem; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.err { color: var(--bad); }

/* ---- controls ---- */
.btn {
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  border-radius: 9px; padding: 9px 18px; cursor: pointer; font-weight: 600; font-size: .95rem; line-height: 1.2;
}
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: transparent; color: var(--accent); border-color: var(--line); }
.btn.ghost:hover:not(:disabled) { border-color: var(--accent); filter: none; }
.btn.good { background: var(--good); border-color: var(--good); color: var(--panel); }
.btn.bad { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn.sm { padding: 6px 12px; font-size: .86rem; border-radius: 8px; }

textarea, input[type=text], input[type=password], input[type=search], input[type=email] {
  width: 100%; border: 1px solid var(--line); background: var(--panel);
  border-radius: 9px; padding: 10px 12px; outline: none;
}
textarea:focus, input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.chip { display: inline-flex; align-items: center; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 13px; font-size: .88rem; color: var(--ink); cursor: pointer; text-align: left; line-height: 1.35; }
.chip:hover { border-color: var(--accent); color: var(--accent); }

/* ---- citations: the tool's core object ---- */
.cite {
  font: 500 .8em/1.4 var(--mono); letter-spacing: -.01em;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 5px; padding: 1px 6px; white-space: nowrap;
}
.covers { display: flex; flex-wrap: wrap; gap: 6px; }
.covers .cite { font-size: .78rem; padding: 3px 8px; }

/* ---- rendered answers ---- */
.md { line-height: 1.65; }
.md p { margin: 0 0 .75em; }
.md ul, .md ol { margin: 0 0 .75em; padding-left: 1.3em; }
.md li { margin: .25em 0; }
.md h3, .md h4 { margin: 1em 0 .4em; font-size: 1rem; }
.md strong { font-weight: 600; }
.md code { font-family: var(--mono); background: var(--code-bg); padding: 1px 5px; border-radius: 4px; font-size: .86em; }
.md blockquote { margin: 0 0 .75em; padding-left: 12px; border-left: 3px solid var(--line); color: var(--muted); }
.md .tbl { overflow-x: auto; margin: 0 0 .9em; border: 1px solid var(--line); border-radius: 9px; }
.md table { border-collapse: collapse; font-size: .9rem; min-width: 100%; }
.md th, .md td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.md tr:last-child td { border-bottom: 0; }
.md th { background: var(--sunk); font-weight: 600; }
.md br + br { display: none; }
.md .cite { cursor: pointer; }
.md .cite:hover, .md .cite:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.md a { word-break: break-word; }

/* ---- source & context rows: one style for all of them ---- */
.sources { margin-top: 6px; }
.sources h3, .section-head { font-size: .74rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 16px 0 2px; }
details.src, details.hist { border-top: 1px solid var(--line); }
details.src > summary, details.hist > summary {
  cursor: pointer; list-style: none; display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 2px; font-size: .92rem;
}
details.src > summary::-webkit-details-marker, details.hist > summary::-webkit-details-marker { display: none; }
details.src > summary::before, details.hist > summary::before {
  content: ""; flex: none; width: 7px; height: 7px; margin: .5em 2px 0 0;
  border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted);
  transform: rotate(-45deg); transition: transform .15s;
}
details[open].src > summary::before, details[open].hist > summary::before { transform: rotate(45deg); }
details.src > summary:hover, details.hist > summary:hover { color: var(--accent); }
details.src pre { white-space: pre-wrap; font: .86rem/1.55 var(--font); background: var(--sunk); border: 1px solid var(--line); border-radius: 9px; padding: 12px 14px; margin: 0 0 12px; max-height: 340px; overflow: auto; }
details.hist > summary { font-weight: 600; }
details.src > summary .cite { margin-top: .15em; }
details.group > .rows { padding-left: 18px; margin-bottom: 8px; }
details.group > .rows > details.src:first-child { border-top: 0; }
.qa .sources { margin-top: 4px; }
details.hist ul { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 12px; }
details.hist li { font-size: .9rem; }
details.hist .when { font-weight: 600; margin-right: 6px; }
details.hist .sum { margin-top: 3px; color: var(--ink); }
details.hist p { margin: 0 0 10px; }
details.prop > summary { color: var(--warn); }
details.flash { animation: flash 1.4s ease-out; border-radius: 6px; }
@keyframes flash { 0% { background: var(--accent-soft); } 100% { background: transparent; } }
.changed { font-size: .7rem; font-weight: 600; border-radius: 5px; padding: 1px 6px; background: var(--warn-soft); color: var(--warn); white-space: nowrap; }

/* ---- notes ---- */
.learned-note, .warn-note { border-radius: 9px; padding: 9px 12px; font-size: .88rem; }
.learned-note { background: var(--good-soft); color: var(--good); }
.warn-note { background: var(--warn-soft); color: var(--warn); }

/* ---- admin badges ---- */
.badge { display: inline-block; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; border-radius: 5px; padding: 2px 7px; }
.badge.new { background: var(--warn-soft); color: var(--warn); }
.badge.approved, .badge.corrected { background: var(--good-soft); color: var(--good); }
.badge.dismissed { background: var(--code-bg); color: var(--muted); }
.badge.down { background: var(--bad-soft); color: var(--bad); }
.badge.up { background: var(--good-soft); color: var(--good); }
.badge.admin { background: var(--accent-soft); color: var(--accent); }

/* ---- footer ---- */
footer.site { border-top: 1px solid var(--line); margin-top: 40px; }
footer.site .wrap { padding-block: 18px 32px; display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--muted); font-size: .8rem; }

.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }
