/* Layout: centered, full-width bands stacked like blocks. Lavender hero band,
   white policy-area band, pale-lavender database band, deep-ink footer band.
   Case pages use the same centered column.

   Color hierarchy (each color has one job):
   - Ink (violet-black): text and outlines.
   - Violet: the brand and primary actions. Headline accent, Search button,
     selected chips and tiles, logo dot, focus ring, hover shadows.
   - Lavender: brand surfaces. Hero band, selected and active backgrounds.
   - Green: means "worked". Nothing else.
   - Rose: means "didn't work". Nothing else.
   - Green/rose split: means "mixed" (it appears in both views).
   - Neutrals: white and a pale lavender for surfaces and alternating bands. */
:root {
  --bg: #ffffff;
  --band: #f7f5fc;
  --surface: #ffffff;
  --ink: #14102b;
  --soft: #5a5470;
  --line: #e6e2f0;
  --edge: #14102b;

  --brand: #5b3bd6;
  --on-brand: #ffffff;
  --brand-soft: #efeaff;
  --brand-tint: #e2d9ff;
  --hero-bg: #efeaff;
  --hero-ink: #14102b;
  --hero-soft: #4a4466;
  --footer-bg: #14102b;

  --worked: #2f9e6b;
  --worked-soft: #d6f2e3;
  --worked-ink: #13603d;
  --failed: #e0566c;
  --failed-soft: #ffe0e4;
  --failed-ink: #9c1f35;
  --mixed: linear-gradient(90deg, var(--worked) 50%, var(--failed) 50%);

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --radius: 18px;
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #110e1f;
    --band: #17132a;
    --surface: #1d1834;
    --ink: #f1eefb;
    --soft: #b4adc9;
    --line: #2e2846;
    --edge: #4a4368;
    --brand: #ab95ff;
    --on-brand: #14102b;
    --brand-soft: #2a2152;
    --brand-tint: #352a66;
    --hero-bg: #221a47;
    --hero-ink: #ffffff;
    --hero-soft: #cfc7ec;
    --footer-bg: #0a0814;
    --worked-soft: #163527;
    --worked-ink: #8fe0b6;
    --failed-soft: #3d1c25;
    --failed-ink: #ffa2b0;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #110e1f;
  --band: #17132a;
  --surface: #1d1834;
  --ink: #f1eefb;
  --soft: #b4adc9;
  --line: #2e2846;
  --edge: #4a4368;
  --brand: #ab95ff;
  --on-brand: #14102b;
  --brand-soft: #2a2152;
  --brand-tint: #352a66;
  --hero-bg: #221a47;
  --hero-ink: #ffffff;
  --hero-soft: #cfc7ec;
  --footer-bg: #0a0814;
  --worked-soft: #163527;
  --worked-ink: #8fe0b6;
  --failed-soft: #3d1c25;
  --failed-ink: #ffa2b0;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
}
a { color: var(--ink); text-decoration-color: var(--brand); text-decoration-thickness: 1.5px; text-underline-offset: 4px; }
a:hover { color: var(--brand); }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
[id] { scroll-margin-top: 64px; }
.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
}
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Outcome markers */
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot.ok { background: var(--worked); }
.dot.fail { background: var(--failed); }
.dot.mixed { background: var(--mixed); }

/* Bands */
.band .wrap { padding-block: clamp(56px, 8vw, 88px); }
.band-head { text-align: center; max-width: 640px; margin: 0 auto 36px; }
.band-head h2 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.8rem, 3.6vw, 2.5rem); letter-spacing: -0.015em; line-height: 1.1; }
.band-head p { margin: 10px 0 0; color: var(--soft); font-size: 17px; }

/* Top bar */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 14px; }
.wordmark {
  font-family: var(--serif); font-weight: 600; font-size: 23px; letter-spacing: -0.01em;
  color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 2px;
}
.wm-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); margin-left: 3px; margin-top: 8px; }
.topnav { display: flex; align-items: center; gap: 22px; }
.topnav a { font-size: 14.5px; font-weight: 600; text-decoration: none; }
.topnav a:hover { text-decoration: underline; }

/* Hero band: lavender, with violet as the accent */
.hero { background: var(--hero-bg); color: var(--hero-ink); text-align: center; }
.hero .wrap { padding-block: clamp(56px, 9vw, 104px); }
.hero h1 {
  font-family: var(--serif); font-weight: 600; color: var(--hero-ink);
  font-size: clamp(2.4rem, 6vw, 4.4rem); line-height: 1.04; letter-spacing: -0.02em;
}
.hero h1 .accent { color: var(--brand); }
.hero .lede { color: var(--hero-soft); font-size: clamp(1.05rem, 1.8vw, 1.2rem); max-width: 60ch; margin: 22px auto 32px; }
.search {
  display: flex; align-items: center; gap: 10px;
  max-width: 680px; margin: 0 auto;
  background: var(--surface); color: var(--ink);
  border: 1.5px solid var(--edge); border-radius: 999px;
  padding: 6px 6px 6px 20px;
  box-shadow: 0 10px 30px -18px rgba(20, 16, 43, 0.45);
}
.search:focus-within { border-color: var(--brand); }
.search > svg { flex: none; width: 19px; height: 19px; color: var(--soft); }
.search input {
  flex: 1; min-width: 0;
  font: inherit; font-size: 16.5px; color: var(--ink);
  background: transparent; border: 0; padding: 11px 0;
}
.search input:focus { outline: none; }
.search input::placeholder { color: var(--soft); }
.search .go {
  flex: none; font: inherit; font-weight: 700; font-size: 15px;
  background: var(--brand); color: var(--on-brand);
  border: 0; border-radius: 999px; padding: 11px 24px; cursor: pointer;
}
.search .go:hover { filter: brightness(1.08); }
.view-switch { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 20px; }
.toggle { display: inline-flex; padding: 4px; gap: 4px; background: var(--surface); border: 1.5px solid var(--edge); border-radius: 999px; }
.toggle button {
  font: inherit; font-size: 14.5px; font-weight: 600; color: var(--soft);
  background: transparent; border: 0; border-radius: 999px;
  padding: 8px 16px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
}
.toggle button:hover { color: var(--ink); }
.toggle button[aria-checked="true"] { background: var(--ink); color: var(--bg); }
.toggle-note { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--hero-soft); }

.hero-link {
  display: inline-block; margin-top: 22px;
  font-weight: 700; font-size: 15px; color: var(--brand); text-decoration: none;
}
.hero-link:hover { text-decoration: underline; }
.cta {
  display: inline-block; font-weight: 700; font-size: 15px; text-decoration: none;
  background: var(--brand); color: var(--on-brand);
  border-radius: 999px; padding: 13px 28px;
}
.cta:hover { filter: brightness(1.08); color: var(--on-brand); }

/* Homepage search results (top three) */
.quick { background: var(--band); }
.quick .wrap { padding-block: clamp(40px, 6vw, 64px); }
.quick-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }

/* All case studies page: compact title + search, then sidebar filters and results */
#db-view { background: var(--band); }
.db, .lib { padding-block: 28px 80px; }
.db-top { display: grid; gap: 14px; margin-bottom: 28px; }
.db-top h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.8rem, 3.6vw, 2.4rem); line-height: 1.1; letter-spacing: -0.015em; }
.db-search { max-width: none; margin: 0; box-shadow: none; }
.db-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 14px 24px; }
/* Kept small and to the side so the search bar stays the focus. */
.db-switch { display: grid; justify-items: end; gap: 6px; max-width: 330px; text-align: right; }
.db-switch-text { margin: 0; font-size: 13px; line-height: 1.4; color: var(--soft); }
.db-switch .toggle { padding: 3px; gap: 2px; }
.db-switch .toggle button { font-size: 13px; padding: 6px 12px; gap: 6px; }
.db-switch .toggle-note { font-size: 12px; color: var(--soft); }
.db-search input { padding: 12px 0; }
.db-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 28px; align-items: start; }
.sidebar { background: var(--surface); border: 1.5px solid var(--edge); border-radius: var(--radius); }
.sidebar > summary { display: none; }
.side-inner { padding: 18px; display: grid; gap: 22px; }
.side-group { display: grid; gap: 8px; }
.side-label { margin: 0; font-size: 12px; font-weight: 700; color: var(--soft); text-transform: uppercase; letter-spacing: 0.08em; }
.side-note { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--soft); }
.toggle-stack { display: grid; width: 100%; border-radius: 14px; }
.toggle-stack button { justify-content: flex-start; border-radius: 10px; padding: 9px 12px; }
.area-list { display: grid; gap: 2px; }
.area-list .chip {
  display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  width: 100%; text-align: left; border: 0; border-radius: 10px; padding: 8px 10px;
  background: transparent; font-size: 14px; font-weight: 500; line-height: 1.3;
}
.area-list .chip:hover { background: var(--band); }
.area-list .swatch { width: 12px; height: 12px; border-radius: 4px; background: var(--a, var(--ink)); }
.area-list .cnt { font-size: 12px; font-weight: 600; color: var(--soft); font-variant-numeric: tabular-nums; }
.area-list .chip[aria-pressed="true"] { background: var(--brand-soft); color: var(--ink); font-weight: 700; box-shadow: inset 3px 0 0 var(--brand); }
.sidebar .selects { grid-template-columns: minmax(0, 1fr); gap: 14px; }
.sidebar .linkbtn { justify-self: start; }
.results .resultbar { border-top: 0; padding-top: 0; margin-bottom: 16px; }
.results .grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }

@media (max-width: 860px) {
  .db-layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar > summary {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; font-weight: 700; cursor: pointer; list-style: none;
  }
  .sidebar > summary::-webkit-details-marker { display: none; }
  .sidebar > summary::after { content: "+"; font-size: 20px; line-height: 1; }
  .sidebar[open] > summary::after { content: "−"; }
  .sidebar[open] > summary { border-bottom: 1px solid var(--line); }
}

/* Policy area band */
.areas { background: var(--bg); }
.area-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
/* Each policy area carries its own color via --a (strong) and --as (soft),
   set inline from app.js. Elements read them through --ac-fg / --ac-bg so dark
   mode can adjust them. Area colors never use the outcome green or rose. */
.area, .topic { --ac-fg: var(--a); --ac-bg: var(--as); }
.area {
  width: 100%; height: 100%; text-align: left;
  font: inherit; color: var(--ink);
  background: var(--ac-bg); border: 1.5px solid transparent; border-radius: var(--radius);
  padding: 22px;
  display: grid; gap: 6px; align-content: start;
  cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s;
}
.area .ic {
  width: 46px; height: 46px; border-radius: 14px; margin-bottom: 8px;
  background: var(--a); color: #ffffff;
  display: grid; place-items: center;
}
.area .ic svg { width: 22px; height: 22px; }
.area .name { font-family: var(--serif); font-weight: 600; font-size: 1.3rem; line-height: 1.2; }
.area .desc { font-size: 14.5px; color: var(--ink); opacity: 0.75; line-height: 1.45; }
.area .n { font-size: 13px; font-weight: 700; margin-top: 6px; color: var(--ac-fg); font-variant-numeric: tabular-nums; }
.area:hover { transform: translate(-3px, -3px); box-shadow: 6px 6px 0 var(--ac-fg); }
.area[aria-pressed="true"] { border-color: var(--ac-fg); box-shadow: 0 0 0 2px var(--ac-fg); }

/* Database band */
.library { background: var(--band); }
.tray {
  background: var(--surface); border: 1.5px solid var(--edge); border-radius: var(--radius);
  padding: 20px; display: grid; gap: 16px; margin-bottom: 28px;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  font: inherit; font-size: 14px; font-weight: 500;
  padding: 7px 14px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer;
}
.chip:hover { border-color: var(--edge); }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.selects { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.select { display: grid; gap: 6px; }
.select span { font-size: 12px; font-weight: 700; color: var(--soft); text-transform: uppercase; letter-spacing: 0.08em; }
.select select {
  appearance: none; -webkit-appearance: none;
  font: inherit; font-size: 14.5px; color: var(--ink);
  background-color: var(--surface);
  background-image: linear-gradient(45deg, transparent 50%, var(--soft) 50%), linear-gradient(135deg, var(--soft) 50%, transparent 50%);
  background-position: calc(100% - 19px) 52%, calc(100% - 14px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  border: 1.5px solid var(--line); border-radius: 12px;
  padding: 10px 36px 10px 12px; min-width: 0; width: 100%; cursor: pointer;
  text-overflow: ellipsis;
}
.select select:hover { border-color: var(--edge); }
.select select.on { border-color: var(--brand); background-color: var(--brand-soft); }
.resultbar {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap;
  padding-top: 14px; border-top: 1px solid var(--line);
}
#count { display: grid; gap: 6px; }
#count p { margin: 0; font-size: 14px; color: var(--soft); }
#count b { color: var(--ink); }
.breakdown { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
.breakdown span { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.linkbtn { font: inherit; font-size: 14px; font-weight: 600; background: none; border: 0; padding: 0; color: var(--brand); text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }

/* Cards */
.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
}
.card {
  height: 100%;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--surface);
  border: 1.5px solid var(--edge);
  border-radius: var(--radius);
  padding: 22px;
  color: var(--ink); text-decoration: none;
  transition: transform .15s, box-shadow .15s;
}
.card:hover { transform: translate(-3px, -3px); box-shadow: 6px 6px 0 var(--brand); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.topic {
  font-size: 12px; font-weight: 700; color: var(--ac-fg, var(--soft)); background: var(--ac-bg, transparent);
  padding: 3px 10px; border-radius: 6px; text-align: right; line-height: 1.4;
}
.card h3 { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; line-height: 1.2; }
.card .meta { font-size: 13.5px; color: var(--soft); margin-top: -6px; }
.card .summary {
  margin: 0; font-size: 15px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.challenge {
  margin: 0; font-size: 14.5px; line-height: 1.5; color: var(--ink);
  padding: 8px 12px; border-left: 3px solid var(--card-a, var(--brand)); background: var(--band); border-radius: 0 8px 8px 0;
}
.challenge .lbl {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--soft); margin-bottom: 2px;
}
.quicklook .challenge { font-size: 15.5px; margin: 0 0 16px; }
.challenge-text { font-size: 1.05rem; }
.stat-box { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; display: grid; gap: 2px; }
.stat-box .v { font-family: var(--serif); font-weight: 600; font-size: 1.7rem; line-height: 1.1; }
.stat-box .l { font-size: 13px; color: var(--soft); }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.read { font-size: 14px; font-weight: 700; white-space: nowrap; color: var(--brand); }
.card:hover .read { text-decoration: underline; text-underline-offset: 4px; }

.pill {
  display: inline-flex; align-items: center;
  font-size: 12.5px; font-weight: 700;
  padding: 4px 12px; border-radius: 999px; white-space: nowrap;
}
.pill.ok { background: var(--worked-soft); color: var(--worked-ink); }
.pill.fail { background: var(--failed-soft); color: var(--failed-ink); }
.pill.mixed { background: var(--band); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); gap: 6px; }
.pill .dot { display: none; }
.pill.mixed .dot { display: inline-block; background: var(--mixed); width: 8px; height: 8px; }

.evidence { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--soft); }
.pips { display: inline-flex; gap: 2px; align-items: flex-end; }
.pips i { width: 4px; border-radius: 1px; background: var(--line); }
.pips i:nth-child(1) { height: 7px; }
.pips i:nth-child(2) { height: 11px; }
.pips i:nth-child(3) { height: 15px; }
.pips i.on { background: var(--ink); }

.empty {
  grid-column: 1 / -1;
  background: var(--surface); border: 1.5px dashed var(--edge); border-radius: var(--radius);
  padding: 56px 20px; text-align: center;
}
.empty h3 { font-family: var(--serif); font-size: 1.4rem; margin-bottom: 6px; }
.empty p { margin: 0; color: var(--soft); }

.more-wrap { display: flex; justify-content: center; margin-top: 32px; }
.more {
  font: inherit; font-size: 15px; font-weight: 700;
  background: var(--surface); color: var(--ink);
  border: 1.5px solid var(--edge); border-radius: 999px; padding: 12px 26px; cursor: pointer;
}
.more:hover { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.more[hidden] { display: none; }

/* Footer band */
.footer { background: var(--footer-bg); color: #ffffff; text-align: center; }
.footer .wrap { padding-block: 48px; display: grid; gap: 8px; justify-items: center; }
.footer .wordmark { color: #ffffff; font-size: 24px; }
.footer .wm-dot { background: #ab95ff; }
.footer p { margin: 0; color: rgba(255, 255, 255, 0.75); font-size: 14.5px; max-width: 56ch; }
.footer .fine { color: rgba(255, 255, 255, 0.5); font-size: 13px; }
.footer a:not(.wordmark) { color: rgba(255, 255, 255, 0.85); text-underline-offset: 3px; }
.footer a:not(.wordmark):hover { color: #ffffff; }

/* Case page */
.case { background: var(--bg); }
.case .wrap { padding-block: 32px 80px; }
.case-head { text-align: center; max-width: 820px; margin: 0 auto 36px; }
.back { display: inline-block; font-weight: 600; font-size: 14.5px; margin-bottom: 28px; }
.case-top { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: center; margin-bottom: 16px; }
.case-top .topic { text-align: center; }
.card { position: relative; overflow: hidden; padding-top: 28px; }
.card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 6px; background: var(--card-a, var(--edge)); }
.case h1 {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(2.1rem, 4.6vw, 3.4rem); line-height: 1.06; letter-spacing: -0.015em;
}
.glance { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 16px; max-width: 980px; margin: 0 auto; }
.big-stat {
  border-radius: var(--radius); padding: 26px; color: var(--ink);
  display: grid; gap: 14px; align-content: space-between;
}
.big-stat { background: var(--surface); border: 1.5px solid var(--edge); }
.big-stat.ok .v { color: var(--worked-ink); }
.big-stat.fail .v { color: var(--failed-ink); }
.big-stat .k { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.big-stat .v { font-family: var(--serif); font-weight: 600; font-size: clamp(2.3rem, 4.4vw, 3.2rem); line-height: 1.02; }
.big-stat .l { font-size: 15px; margin-top: 4px; }
.big-stat .evidence { color: inherit; }
.big-stat .pips i { background: currentColor; opacity: 0.25; }
.big-stat .pips i.on { opacity: 1; }
.facts {
  margin: 0; background: var(--surface); border: 1.5px solid var(--edge); border-radius: var(--radius); padding: 24px;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 24px;
}
.facts dt { font-size: 11.5px; font-weight: 700; color: var(--soft); margin-bottom: 2px; text-transform: uppercase; letter-spacing: 0.08em; }
.facts dd { margin: 0; font-size: 15px; }
.story { max-width: 700px; margin: 52px auto 0; display: grid; gap: 40px; }
.story h2 { font-family: var(--serif); font-size: 1.5rem; font-weight: 600; margin-bottom: 10px; }
.story p { margin: 0; font-size: 18px; line-height: 1.7; }
.analysis { border-radius: var(--radius); padding: 22px 24px; }
.analysis.ok { background: var(--worked-soft); }
.analysis.fail { background: var(--failed-soft); }
.analysis.mixed { background: var(--band); box-shadow: inset 0 0 0 1px var(--line); }
.analysis h2 { margin-bottom: 6px; font-size: 1.3rem; display: flex; align-items: center; gap: 10px; }
.analysis h2::before { content: ""; width: 14px; height: 14px; border-radius: 50%; flex: none; }
.analysis.ok h2::before { background: var(--worked); }
.analysis.fail h2::before { background: var(--failed); }
.analysis.mixed h2::before { background: var(--mixed); }
.sources ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.sources li { font-size: 14.5px; color: var(--soft); line-height: 1.5; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.tag {
  font: inherit; font-size: 13.5px; font-weight: 500;
  background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); border-radius: 999px;
  padding: 4px 12px; cursor: pointer;
}
.tag::before { content: "#"; color: var(--soft); margin-right: 1px; }
.tag:hover { border-color: var(--brand); background: var(--brand-soft); }
.related { margin-top: 72px; padding-top: 40px; border-top: 1px solid var(--line); }
.related h2 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.6rem, 3vw, 2rem); text-align: center; margin-bottom: 24px; }

/* Quick look pop-up */
.quicklook {
  width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 0; border: 1.5px solid var(--edge); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  box-shadow: 0 30px 80px -30px rgba(20, 16, 43, 0.5);
  overflow: hidden;
}
.quicklook[open] { display: flex; flex-direction: column; }
.quicklook::backdrop { background: rgba(20, 16, 43, 0.45); backdrop-filter: blur(3px); }
.ql-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--band);
}
.ql-nav { display: flex; align-items: center; gap: 8px; }
.ql-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 16px; cursor: pointer;
}
.ql-btn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.ql-btn:disabled { opacity: 0.35; cursor: default; }
.ql-pos { font-size: 13px; color: var(--soft); font-variant-numeric: tabular-nums; }
.ql-open { font-size: 14px; font-weight: 700; color: var(--brand); text-decoration: none; margin-right: 4px; }
.ql-open:hover { text-decoration: underline; }
.ql-body { overflow: auto; padding: 26px 28px 30px; display: grid; gap: 20px; }
.ql-head { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 24px; align-items: start; }
.ql-main { display: grid; gap: 14px; align-content: start; }
.ql-body .case-top { justify-content: flex-start; margin: 0; }
.ql-body h2 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.6rem, 3.2vw, 2.1rem); line-height: 1.12; }
.ql-stat { display: grid; gap: 2px; padding-top: 12px; border-top: 1px solid var(--line); }
.ql-stat .v { font-family: var(--serif); font-weight: 600; font-size: 1.9rem; line-height: 1.05; }
.ql-stat.ok .v { color: var(--worked-ink); }
.ql-stat.fail .v { color: var(--failed-ink); }
.ql-stat .l { font-size: 14px; color: var(--soft); margin-bottom: 6px; }
.ql-facts { margin: 0; display: grid; gap: 12px; align-content: start; background: var(--band); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.ql-facts dt { font-size: 11px; font-weight: 700; color: var(--soft); text-transform: uppercase; letter-spacing: 0.08em; }
.ql-facts dd { margin: 0; font-size: 14px; }
.ql-text { margin: 0; font-size: 16.5px; line-height: 1.7; }
.ql-body .analysis h3 { font-family: var(--serif); font-size: 1.2rem; margin: 0 0 6px; display: flex; align-items: center; gap: 10px; }
.ql-body .analysis h3::before { content: ""; width: 12px; height: 12px; border-radius: 50%; flex: none; }
.ql-body .analysis.ok h3::before { background: var(--worked); }
.ql-body .analysis.fail h3::before { background: var(--failed); }
.ql-body .analysis.mixed h3::before { background: var(--mixed); }
.ql-body .analysis p { margin: 0; line-height: 1.6; }
.ql-body .tags { margin: 0; }
.ql-body .sources h3 { font-family: var(--serif); font-size: 1.1rem; margin: 0 0 8px; }
@media (max-width: 600px) {
  .quicklook { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: var(--radius) var(--radius) 0 0; }
  .ql-head { grid-template-columns: minmax(0, 1fr); }
  .ql-body { padding: 20px 18px 28px; }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .area,
  :root:not([data-theme="light"]) .topic { --ac-bg: color-mix(in srgb, var(--a) 28%, #1d1834); --ac-fg: color-mix(in srgb, var(--a) 50%, #ffffff); }
}
:root[data-theme="dark"] .area,
:root[data-theme="dark"] .topic { --ac-bg: color-mix(in srgb, var(--a) 28%, #1d1834); --ac-fg: color-mix(in srgb, var(--a) 50%, #ffffff); }

@media (max-width: 900px) {
  .area-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .glance { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .wide-br { display: none; }
  .selects, .facts { grid-template-columns: minmax(0, 1fr); }
  .search { padding-left: 14px; }
  .search .go { padding: 11px 16px; }
  .tray { padding: 14px; }
  .topnav { gap: 14px; }
  .db-switch { justify-items: stretch; max-width: none; text-align: left; }
  .toggle { width: 100%; }
  .toggle button { flex: 1; justify-content: center; padding: 9px 8px; font-size: 14px; }
  .area { padding: 14px; gap: 4px; }
  .area .ic { width: 38px; height: 38px; border-radius: 11px; margin-bottom: 4px; }
  .area .ic svg { width: 19px; height: 19px; }
  .area .name { font-size: 1.05rem; }
  .area .desc { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .card, .area { transition: none; }
  .card:hover, .area:hover { transform: none; }
}

.q-active { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 4px 0 0; font-size: 14px; color: var(--soft); }
.q-active b { color: var(--ink); }
.empty-actions { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 10px; }
.empty.intro { display: grid; justify-items: center; gap: 4px; }
.empty.intro .cta { margin-top: 14px; font: inherit; font-weight: 700; cursor: pointer; border: 0; }

/* ---------- Accounts: save buttons, sign-in, folders, library ---------- */
.card-li { position: relative; }
.save-tools { display: none; }
.accounts-on .save-tools {
  display: flex; gap: 6px; position: absolute; right: 22px; bottom: 18px;
  transition: transform .15s;
}
.accounts-on .card-li:hover .save-tools { transform: translate(-3px, -3px); }
.accounts-on .card .read { margin-right: 84px; }
.save-btn, .folder-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 36px; height: 36px; padding: 0 9px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--soft);
  font: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer;
}
.save-btn svg, .folder-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.save-btn:hover, .folder-btn:hover { border-color: var(--brand); color: var(--brand); }
.save-btn[aria-pressed="true"] { color: #b7791f; border-color: #e9c46a; background: #fff6dd; }
.save-btn[aria-pressed="true"] svg { fill: #f2b84b; stroke: #b7791f; }
.folder-btn[aria-pressed="true"] { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }
.case-actions { display: flex; gap: 8px; margin-top: 14px; }
.case-actions .save-btn, .case-actions .folder-btn { padding: 0 14px; }
#ql-actions { display: inline-flex; gap: 6px; margin-right: 6px; }

.account { display: flex; align-items: center; gap: 16px; }
.signin-btn {
  font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
  padding: 7px 16px; border-radius: 999px; border: 1.5px solid var(--edge);
  background: var(--surface); color: var(--ink);
}
.signin-btn:hover { border-color: var(--brand); color: var(--brand); }
.acct-menu { position: relative; }
.acct-menu summary { list-style: none; cursor: pointer; }
.acct-menu summary::-webkit-details-marker { display: none; }
.avatar {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand); color: var(--on-brand); font-weight: 700; font-size: 14px;
}
.acct-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; min-width: 230px;
  display: grid; gap: 10px; padding: 14px 16px;
  background: var(--surface); border: 1.5px solid var(--edge); border-radius: 14px;
  box-shadow: 0 18px 40px -20px rgba(20, 16, 43, 0.45);
}
.acct-email { margin: 0; font-size: 13.5px; color: var(--soft); overflow-wrap: anywhere; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.acct-item { font: inherit; font-size: 15px; font-weight: 700; color: var(--ink); text-decoration: none; background: none; border: 0; padding: 0; cursor: pointer; justify-self: start; }
.acct-item:hover { color: var(--brand); text-decoration: underline; text-underline-offset: 4px; }
.acct-pop .linkbtn { justify-self: start; }
.linkbtn.danger { color: var(--failed-ink); }

.modal {
  width: min(440px, calc(100vw - 32px)); padding: 26px; position: relative;
  border: 1.5px solid var(--edge); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  box-shadow: 0 30px 80px -30px rgba(20, 16, 43, 0.5);
}
.modal::backdrop { background: rgba(20, 16, 43, 0.45); backdrop-filter: blur(3px); }
.modal h2 { font-family: var(--serif); font-weight: 600; font-size: 1.6rem; margin: 0 0 6px; }
.modal-sub { margin: 0 0 18px; color: var(--soft); font-size: 15px; }
.modal-x { position: absolute; top: 14px; right: 14px; }
.modal form { display: grid; gap: 8px; margin-bottom: 12px; }
.modal label { font-size: 13.5px; font-weight: 700; }
.modal input[type="email"], .modal input[inputmode="numeric"], .new-folder input {
  font: inherit; font-size: 16px; padding: 11px 14px; border-radius: 12px;
  border: 1.5px solid var(--edge); background: var(--bg); color: var(--ink); width: 100%;
}
.modal input:focus-visible, .new-folder input:focus-visible { outline: 3px solid var(--brand-soft); border-color: var(--brand); }
.modal .cta { border: 0; cursor: pointer; font: inherit; font-weight: 700; justify-self: stretch; text-align: center; }
.modal .fine { font-size: 12.5px; color: var(--soft); margin: 4px 0 0; }
.google-btn {
  width: 100%; font: inherit; font-weight: 700; cursor: pointer; padding: 11px 14px;
  border-radius: 999px; border: 1.5px solid var(--edge); background: var(--surface); color: var(--ink);
}
.or { display: flex; align-items: center; gap: 10px; color: var(--soft); font-size: 13px; margin: 14px 0; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.form-error { margin: 8px 0 0; color: var(--failed-ink); font-size: 14px; font-weight: 600; }
.folder-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 4px; max-height: 280px; overflow: auto; }
.folder-list label { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; cursor: pointer; font-weight: 600; }
.folder-list label:hover { background: var(--band); }
.folder-list input { width: 18px; height: 18px; accent-color: var(--brand); }
.folder-list .n { margin-left: auto; color: var(--soft); font-size: 13px; font-variant-numeric: tabular-nums; }
.folder-list .muted { color: var(--soft); font-size: 14px; padding: 8px 0; }
.new-folder { display: flex; gap: 8px; }
.new-folder input { font-size: 15px; padding: 9px 12px; }
.new-folder button {
  font: inherit; font-weight: 700; cursor: pointer; padding: 0 16px; border-radius: 12px;
  border: 1.5px solid var(--edge); background: var(--surface); color: var(--ink);
}
.new-folder button:hover { border-color: var(--brand); color: var(--brand); }
.modal-foot { display: flex; justify-content: flex-end; }
.modal-foot .cta { justify-self: end; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  padding: 11px 18px; border-radius: 999px; background: var(--ink); color: var(--bg);
  font-size: 14px; font-weight: 600; box-shadow: 0 12px 30px -12px rgba(20, 16, 43, 0.5);
  max-width: calc(100vw - 32px);
}
.lib-side .chip { text-align: left; }
.lib-side .new-folder { margin-top: 10px; }
.lib-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin-bottom: 16px; }
.lib-head h2 { font-family: var(--serif); font-weight: 600; font-size: 1.6rem; margin: 0; }
.lib-actions { display: flex; gap: 16px; }
.lib .empty.intro, .lib .empty { display: grid; justify-items: center; gap: 4px; }
.lib .empty .cta { margin-top: 12px; }
.lib-side .swatch { background: var(--brand); border-radius: 3px; }
.lib-side .swatch.fav { background: #f2b84b; border-radius: 50%; }

/* Privacy policy and other text pages */
.legal .wrap { max-width: 760px; padding-top: 48px; padding-bottom: 64px; }
.legal h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(2rem, 4vw, 2.6rem); margin: 0 0 6px; }
.legal h2 { font-family: var(--serif); font-weight: 600; font-size: 1.35rem; margin: 32px 0 8px; }
.legal p, .legal li { font-size: 16px; line-height: 1.7; }
.legal ul { padding-left: 20px; }
.legal .updated { color: var(--soft); font-size: 14px; }

/* Manage account */
.acct-facts { display: grid; gap: 10px; margin: 6px 0 18px; }
.acct-facts div { display: grid; gap: 2px; }
.acct-facts dt { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--soft); }
.acct-facts dd { margin: 0; font-size: 15px; overflow-wrap: anywhere; }
.manage-row + .manage-row { border-top: 0; padding-top: 0; }
.manage-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.manage-row .fine { font-size: 13px; color: var(--soft); }
.danger-zone { border-top: 1px solid var(--line); padding-top: 16px; }
.danger-zone h3 { margin: 0 0 4px; font-size: 15px; }
.danger-zone > p { margin: 0 0 12px; font-size: 14px; color: var(--soft); }
.danger-btn, .secondary-btn {
  font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
  padding: 9px 16px; border-radius: 999px; border: 1.5px solid var(--failed-ink);
  background: var(--surface); color: var(--failed-ink);
}
.danger-btn.solid { background: var(--failed-ink); color: #fff; }
.danger-btn:disabled { opacity: .6; cursor: progress; }
.secondary-btn { border-color: var(--edge); color: var(--ink); }
.delete-confirm { background: var(--failed-soft); border-radius: 14px; padding: 14px 16px; }
.delete-confirm p { margin: 0 0 12px; font-size: 14.5px; line-height: 1.5; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* Password fields */
.pw-field { position: relative; }
.pw-field input { width: 100%; font: inherit; font-size: 16px; padding: 11px 64px 11px 14px; border-radius: 12px; border: 1.5px solid var(--edge); background: var(--bg); color: var(--ink); }
.pw-field input:focus-visible { outline: 3px solid var(--brand-soft); border-color: var(--brand); }
.pw-show { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font: inherit; font-size: 13px; font-weight: 700; color: var(--brand); background: none; border: 0; padding: 6px; cursor: pointer; }
.pw-hint { margin: 0; font-size: 12.5px; color: var(--soft); }
.signin-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; margin: 2px 0 12px; }
.signin-links .linkbtn, .switch-mode .linkbtn { font-size: 13.5px; }
.switch-mode { margin: 0 0 6px; font-size: 14px; color: var(--soft); }

/* Feedback */
.feedback-link { display: none; }
.feedback-on .feedback-link { display: revert; }
.feedback { max-width: 720px; padding-block: 40px 80px; }
.feedback h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.9rem, 4vw, 2.5rem); margin: 0 0 8px; }
.lede-sm { color: var(--soft); font-size: 16.5px; margin: 0 0 26px; }
#feedback-form { display: grid; gap: 8px; }
#feedback-form label, .fb-types legend { font-size: 14px; font-weight: 700; }
#feedback-form .opt { font-weight: 500; color: var(--soft); }
#feedback-form textarea, #feedback-form input:not([type="radio"]) {
  font: inherit; font-size: 16px; padding: 11px 14px; border-radius: 12px; width: 100%;
  border: 1.5px solid var(--edge); background: var(--surface); color: var(--ink); margin-bottom: 10px;
}
#feedback-form textarea { resize: vertical; min-height: 150px; line-height: 1.5; }
#feedback-form textarea:focus-visible, #feedback-form input:focus-visible { outline: 3px solid var(--brand-soft); border-color: var(--brand); }
.fb-types { border: 0; padding: 0; margin: 0 0 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.fb-types legend { margin-bottom: 8px; padding: 0; }
.fb-types label {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600 !important;
  padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface);
}
.fb-types label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.fb-types input { accent-color: var(--brand); margin: 0; }
.fb-case { margin: 0 0 12px; padding: 10px 14px; border-radius: 12px; background: var(--band); font-size: 14.5px; }
.fb-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 16px; }
.fb-row > div { display: grid; gap: 8px; align-content: start; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
#feedback-form .cta { justify-self: start; border: 0; cursor: pointer; font: inherit; font-weight: 700; margin-top: 6px; }
#feedback-form .cta:disabled { opacity: .7; cursor: progress; }
#feedback-form .fine { font-size: 13px; color: var(--soft); margin: 6px 0 0; }
.fb-done { padding: 32px; border-radius: var(--radius); background: var(--worked-soft); }
.fb-done h2 { font-family: var(--serif); font-weight: 600; margin: 0 0 6px; }
.case-feedback { margin-top: 14px; font-size: 14px; color: var(--soft); }

/* Active search / filter chips above results */
.active-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 8px 0 2px; }
.af-chip {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font: inherit; font-size: 13.5px; font-weight: 600; padding: 5px 8px 5px 12px; border-radius: 999px;
  border: 1.5px solid var(--brand); background: var(--brand-soft); color: var(--brand);
}
.af-chip span { font-size: 16px; line-height: 1; }
.af-chip:hover { background: var(--brand); color: var(--on-brand); }
.active-filters .linkbtn { font-size: 13.5px; }
.fb-turnstile { min-height: 65px; margin: 4px 0 2px; }
#feedback-form[hidden], .fb-done[hidden] { display: none; }

/* Mobile menu */
.nav-toggle { display: none; }
@media (max-width: 640px) {
  .topbar .wrap { position: relative; }
  .nav-toggle {
    display: inline-flex; flex-direction: column; justify-content: center; gap: 5px;
    width: 42px; height: 42px; padding: 0 10px; border-radius: 12px;
    border: 1.5px solid var(--line); background: var(--surface); cursor: pointer;
  }
  .nav-toggle span { display: block; height: 2px; border-radius: 2px; background: var(--ink); transition: transform .2s, opacity .2s; }
  .nav-open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
  .nav-open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
  .topnav {
    display: none; position: absolute; top: calc(100% + 1px); left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--bg); border-bottom: 1px solid var(--line);
    box-shadow: 0 18px 30px -20px rgba(20, 16, 43, 0.35);
    padding: 6px 16px 14px;
  }
  .nav-open .topnav { display: flex; }
  .topnav a { font-size: 17px; padding: 13px 0; border-bottom: 1px solid var(--line); }
  .topnav a:last-of-type { border-bottom: 0; }
  .topnav .account { padding-top: 12px; }
}
.account[hidden] { display: none; }

/* Generated pages (case, area) */
.crumbs { font-size: 14px; color: var(--soft); margin-bottom: 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs a { color: var(--brand); font-weight: 600; text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
a.topic { text-decoration: none; }
a.topic:hover { text-decoration: underline; }
a.tag { text-decoration: none; color: inherit; display: inline-block; }
.area-hero { border-left: 6px solid var(--a, var(--brand)); padding: 4px 0 4px 18px; margin: 6px 0 30px; }
.area-hero h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(2rem, 4.5vw, 2.8rem); line-height: 1.1; margin: 0 0 10px; }
.area-hero .breakdown { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 14.5px; color: var(--soft); margin: 10px 0 0; }
.area-hero .breakdown span { display: inline-flex; align-items: center; gap: 6px; }
.area-group { margin-bottom: 36px; }
.area-group h2 { font-family: var(--serif); font-weight: 600; font-size: 1.6rem; margin: 0 0 16px; }
.footer-areas { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; max-width: 760px; margin: 10px 0 6px; }
.footer-areas a { font-size: 13.5px; color: rgba(255, 255, 255, 0.75); text-decoration: none; }
.footer-areas a:hover { color: #ffffff; text-decoration: underline; }
a.card:hover { color: var(--ink); }
.case-head .crumbs { justify-content: center; }
.fb-turnstile:empty { display: none; }
