/* Court Action Navigator — Layout 2: filters | gallery of agenda items | reading pane.
   Tokens first; sizes in rem; light, dark and increased-contrast palettes. Color is reserved for
   meaning (outcomes, obligation type); everything else is neutral. */
:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --field: #ffffff;
  --ink: #1d2433;              /* 15.5:1 on panel */
  --muted: #5d6677;            /* 5.8:1 on panel */
  --line: #e3e6ec;
  --control-border: #8a92a2;   /* 3.1:1: edges of fields and buttons */
  --accent: #1f4e8c;           /* 8.3:1 */
  --accent-soft: #e8eef8;
  --row-hover: #f3f6fb;
  --row-sel: #e4ecf8;
  --chip-bg: #eef1f6;
  --chip-ink: #3e4a5e;         /* 7.9:1 */
  --ok: #1f8a3e;   --ok-ink: #1d6b35;   --ok-bg: #e6f4ea;
  --bad: #c9302c;  --bad-ink: #8a1f1b;  --bad-bg: #fdecea;
  --neutral-icon: #6b7484;
  --ob-rec-bg: #e6f4ea;  --ob-rec-ink: #1d6b35;
  --ob-ong-bg: #fff4e0;  --ob-ong-ink: #8a5300;
  --err-bg: #fdecea;     --err-ink: #8a1f1b;
  --mark-bg: #fff0a3;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath fill='%235d6677' d='M0 0h10L5 6z'/%3E%3C/svg%3E");
  --shadow: 0 8px 24px rgba(20, 30, 50, .14);
  --radius: .5rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101317; --panel: #181c22; --panel-2: #1e232a; --field: #13171c;
    --ink: #e8ebf0; --muted: #a7b0bd; --line: #2b3139; --control-border: #6c7584;
    --accent: #8db8ff; --accent-soft: #22324a; --row-hover: #1f252d; --row-sel: #233149;
    --chip-bg: #262c35; --chip-ink: #d0d6df;
    --ok: #4cc472; --ok-ink: #93e2ab; --ok-bg: #16351f;
    --bad: #ff7a70; --bad-ink: #ffb8b1; --bad-bg: #3a1a19;
    --neutral-icon: #8d96a4;
    --ob-rec-bg: #16351f; --ob-rec-ink: #93e2ab; --ob-ong-bg: #3a2a0f; --ob-ong-ink: #f5c36e;
    --err-bg: #3a1a19; --err-ink: #ffb8b1; --mark-bg: #5a4800;
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath fill='%23a7b0bd' d='M0 0h10L5 6z'/%3E%3C/svg%3E");
    --shadow: 0 8px 24px rgba(0, 0, 0, .5);
  }
}
@media (prefers-contrast: more) {
  :root { --muted: #3e4656; --line: #b9c0cb; --control-border: #4f5868; --chip-ink: #232b38; }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root { --muted: #d0d6df; --line: #4a525d; --control-border: #aab3c0; --chip-ink: #f1f3f6; }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 0.875rem/1.45 var(--font); color: var(--ink); background: var(--bg); display: flex; flex-direction: column; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
mark { background: var(--mark-bg); color: inherit; border-radius: 2px; padding: 0 1px; }
button, select, input { font: inherit; }

/* ── Top bar ── */
.topbar { display: flex; align-items: center; gap: 1rem; padding: .5rem 1.25rem; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .625rem; flex-wrap: wrap; }
.brand-mark { width: 1.5rem; height: 1.5rem; fill: var(--accent); flex: none; }
.brand h1 { margin: 0; font-size: 1.0625rem; color: var(--accent); }
.tagline { margin: 0; font-size: .75rem; color: var(--muted); }
.data-through { margin: 0 0 0 auto; font-size: .75rem; color: var(--muted); }

/* ── Three columns: fixed tracks, so selecting never resizes anything ── */
.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 16.5rem minmax(0, 1fr) minmax(0, 1.15fr);
  gap: .75rem;
  padding: .75rem;
}
.sidebar, .results, .detail { min-height: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.sidebar { overflow: auto; }
.results { display: flex; flex-direction: column; overflow: hidden; }
.detail { position: relative; overflow: auto; padding: 1rem 1.25rem 1.75rem; }
.detail:focus { outline: none; }

/* ── Filters (stacked) ── */
.filters { display: flex; flex-direction: column; gap: .75rem; padding: .875rem; }
.field { display: flex; flex-direction: column; gap: .25rem; min-width: 0; position: relative; }
.field > label, .field > .label, .label-row label { font-size: .75rem; font-weight: 600; color: var(--ink); }
.label-row { display: flex; align-items: center; justify-content: space-between; }
.help-btn { width: 1.375rem; height: 1.375rem; border-radius: 50%; border: 1px solid var(--control-border); background: var(--panel); color: var(--muted); font-size: .75rem; font-weight: 700; cursor: pointer; line-height: 1; }
.help-btn[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.help-pop { margin-top: .25rem; padding: .5rem .625rem; border: 1px solid var(--line); border-radius: .375rem; background: var(--panel-2); font-size: .75rem; color: var(--ink); }
.help-pop p { margin: 0 0 .375rem; }
.help-pop ul { margin: 0; padding-left: 1rem; }
.help-pop code { font-size: .75rem; background: var(--chip-bg); color: var(--chip-ink); padding: 0 .25rem; border-radius: .25rem; }
input[type="search"], input[type="date"], .filters select, .sort select {
  width: 100%;
  min-height: 2.125rem;
  padding: 0 .625rem;
  border: 1px solid var(--control-border);
  border-radius: .375rem;
  color: var(--ink);
  background: var(--field);
}
input::placeholder { color: var(--muted); opacity: .85; }
.searchbox { display: flex; align-items: center; min-height: 2.125rem; border: 1px solid var(--control-border); border-radius: .375rem; background: var(--field); }
.searchbox:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.search-icon { width: 1rem; height: 1rem; margin-left: .625rem; fill: var(--muted); flex: none; }
.searchbox input[type="search"] { border: 0; background: transparent; padding: 0 .5rem; }
.searchbox input:focus-visible { outline: none; }
.checkbox { display: flex; align-items: center; gap: .5rem; font-size: .8125rem; cursor: pointer; min-height: 1.75rem; }
.checkbox input { width: 1rem; height: 1rem; accent-color: var(--accent); }

/* dropdown buttons (multiselect + date) and their popovers (fixed-positioned by script) */
.ms, .datepick { position: relative; }
.ms-button {
  width: 100%; min-height: 2.125rem;
  display: flex; align-items: center; justify-content: space-between; gap: .375rem;
  padding: 0 .625rem; border: 1px solid var(--control-border); border-radius: .375rem;
  background: var(--field); color: var(--ink); cursor: pointer; text-align: left;
}
.ms-button .ms-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-button .ms-text.placeholder { color: var(--muted); }
.ms-button::after { content: ""; flex: none; width: .625rem; height: .375rem; background: var(--chevron) no-repeat center / contain; }
.ms-pop, .dp-pop {
  position: fixed; z-index: 40;
  background: var(--panel); border: 1px solid var(--control-border); border-radius: .5rem; box-shadow: var(--shadow);
}
.ms-pop { width: 18rem; max-height: 21rem; display: flex; flex-direction: column; }
.ms-pop input[type="search"] { border: 0; border-bottom: 1px solid var(--line); border-radius: .5rem .5rem 0 0; }
.ms-list { overflow: auto; padding: .25rem 0; }
.ms-opt { display: flex; align-items: center; gap: .5rem; padding: .3125rem .625rem; cursor: pointer; font-size: .8125rem; min-height: 1.75rem; }
.ms-opt:hover, .ms-opt:focus-within { background: var(--row-hover); }
.ms-opt input { accent-color: var(--accent); width: 1rem; height: 1rem; margin: 0; }
.ms-opt .n { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; font-size: .75rem; }
.ms-empty { padding: .625rem; color: var(--muted); font-size: .8125rem; }
.ms-foot { display: flex; justify-content: space-between; padding: .375rem .625rem; border-top: 1px solid var(--line); }

.dp-pop { width: min(36rem, calc(100vw - 1rem)); font-size: .8125rem; }
.dp-quick { display: flex; flex-wrap: wrap; gap: .375rem; padding: .625rem; border-bottom: 1px solid var(--line); }
.dp-cols { display: grid; grid-template-columns: 7rem 1fr 11rem; min-height: 12rem; }
.dp-col { padding: .5rem; border-right: 1px solid var(--line); }
.dp-col:last-child { border-right: 0; }
.dp-col h3 { margin: 0 0 .375rem; font-size: .6875rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.dp-years, .dp-days { display: flex; flex-direction: column; gap: .125rem; max-height: 14rem; overflow: auto; }
.dp-months { display: grid; grid-template-columns: repeat(4, 1fr); gap: .25rem; }
.dp-btn { display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-height: 1.75rem; padding: 0 .5rem; border: 1px solid transparent; border-radius: .375rem; background: none; color: var(--ink); cursor: pointer; text-align: left; }
.dp-btn:hover:not(:disabled) { background: var(--row-hover); }
.dp-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); font-weight: 600; }
.dp-btn.browsing:not([aria-pressed="true"]) { background: var(--row-hover); }
.dp-btn:disabled { color: var(--muted); opacity: .5; cursor: default; }
.dp-months .dp-btn { justify-content: center; }
.dp-btn .n { color: var(--muted); font-size: .75rem; font-weight: 400; font-variant-numeric: tabular-nums; }
.dp-quick .dp-btn { border-color: var(--control-border); }
.dp-empty { color: var(--muted); padding: .25rem .5rem; margin: 0; }
.dp-range { display: flex; flex-wrap: wrap; align-items: end; gap: .5rem; padding: .625rem; border-top: 1px solid var(--line); }
.dp-range label { display: flex; flex-direction: column; gap: .25rem; font-size: .75rem; font-weight: 600; }
.dp-range input[type="date"] { width: auto; }
.dp-foot { display: flex; justify-content: space-between; align-items: center; padding: .375rem .625rem; border-top: 1px solid var(--line); }

/* ── Buttons ── */
.btn { min-height: 1.875rem; padding: 0 .75rem; border-radius: .375rem; border: 1px solid var(--control-border); background: var(--panel); color: var(--ink); font-size: .8125rem; cursor: pointer; }
.btn:hover:not(:disabled) { background: var(--row-hover); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.small { min-height: 1.75rem; }
.icon-btn { min-width: 1.875rem; padding: 0; font-size: 1rem; }
.link-btn { border: 0; background: none; color: var(--accent); padding: .25rem 0; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; min-height: 1.5rem; }

/* ── Results: toolbar, gallery, pager ── */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem .75rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.count { margin: 0; font-size: .8125rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.count .muted { font-weight: 400; }
.toolbar-actions { display: flex; align-items: center; gap: .5rem; }
.sort select { min-height: 1.875rem; width: auto; font-size: .8125rem; }
.error { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin: .5rem .75rem 0; padding: .5rem .75rem; border-radius: .375rem; background: var(--err-bg); color: var(--err-ink); font-size: .8125rem; }
.error[hidden] { display: none; }
.gallery { flex: 1; min-height: 0; overflow: auto; transition: opacity .15s; }
.gallery[aria-busy="true"] { opacity: .45; }
@media (prefers-reduced-motion: reduce) { .gallery { transition: none; } }
.cards { list-style: none; margin: 0; padding: .375rem; display: flex; flex-direction: column; gap: .25rem; }
.card {
  width: 100%;
  display: block;
  padding: .5625rem .75rem .625rem;
  border: 1px solid transparent;
  border-radius: .5rem;
  background: none;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.card:hover { background: var(--row-hover); }
.card[aria-current="true"] { background: var(--row-sel); border-color: var(--line); box-shadow: inset 3px 0 0 var(--accent); }
.card-title {
  margin: 0 0 .25rem;
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .5rem; font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.card-meta .sep { opacity: .7; }
.card-follow { margin-top: .3125rem; font-size: .75rem; color: var(--ink); display: flex; gap: .375rem; align-items: baseline; }
.card-follow .owners { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }
.empty h2 { margin: 0 0 .5rem; font-size: .9375rem; color: var(--ink); }
.empty p { margin: 0 0 .75rem; }
.pager { display: flex; align-items: center; justify-content: center; gap: .5rem; padding: .375rem; border-top: 1px solid var(--line); font-size: .8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.chip { display: inline-block; max-width: 100%; padding: 0 .4375rem; border-radius: .3125rem; background: var(--chip-bg); color: var(--chip-ink); font-size: .75rem; line-height: 1.25rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.muted { color: var(--muted); }

/* ── Reading pane ── */
.back-btn { display: none; margin-bottom: .75rem; }
.prompt { margin: 3rem 1rem; text-align: center; color: var(--muted); }
.d-eyebrow { margin: 0 0 .25rem; font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.d-title { margin: 0 0 .5rem; font-size: 1.0625rem; line-height: 1.35; overflow-wrap: anywhere; }
.d-tags { display: flex; flex-wrap: wrap; gap: .375rem; align-items: center; }
.outcome { display: inline-flex; align-items: center; gap: .25rem; font-size: .75rem; font-weight: 600; padding: 0 .5rem; border-radius: 999px; line-height: 1.375rem; }
.outcome svg { width: .875rem; height: .875rem; }
.outcome.ok { background: var(--ok-bg); color: var(--ok-ink); } .outcome.ok svg { fill: var(--ok-ink); }
.outcome.bad { background: var(--bad-bg); color: var(--bad-ink); } .outcome.bad svg { fill: var(--bad-ink); }
.outcome.neutral { background: var(--chip-bg); color: var(--chip-ink); }
.jump { display: flex; flex-wrap: wrap; gap: .25rem .875rem; margin: .625rem 0 0; padding: 0; list-style: none; font-size: .8125rem; }
.d-sec { padding: .875rem 0; border-top: 1px solid var(--line); }
.d-sec:first-of-type { margin-top: .75rem; }
.d-sec > h3 { margin: 0 0 .5rem; font-size: .875rem; color: var(--accent); display: flex; align-items: center; gap: .5rem; }
.d-sec > h3 .n { color: var(--muted); font-weight: 400; }
.d-text { margin: .375rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.d-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .375rem .875rem; margin-top: .5rem; font-size: .8125rem; color: var(--muted); }
.d-meta b { color: var(--ink); font-weight: 600; }
.note { color: var(--muted); font-size: .8125rem; margin: 0; }

.motion-head { margin: .875rem 0 .25rem; font-size: .8125rem; font-weight: 600; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.motion-head:first-child { margin-top: 0; }
.task-card { border: 1px solid var(--line); border-radius: .5rem; padding: .625rem .75rem; margin-top: .5rem; }
.task-card h4 { margin: 0 0 .25rem; font-size: .84375rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.ob { font-size: .75rem; font-weight: 600; padding: .0625rem .5rem; border-radius: 999px; }
.ob.recurring { background: var(--ob-rec-bg); color: var(--ob-rec-ink); }
.ob.ongoing { background: var(--ob-ong-bg); color: var(--ob-ong-ink); }
.ob.one_time { background: var(--chip-bg); color: var(--chip-ink); }

.motion { padding: .625rem 0; border-bottom: 1px dashed var(--line); }
.motion:last-child { border-bottom: 0; }
.votes { display: grid; grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: .5rem; margin-top: .5rem; }
.vote { display: flex; align-items: center; gap: .4375rem; padding: .375rem .5rem; border: 1px solid var(--line); border-radius: .375rem; font-size: .78125rem; }
.vote svg { width: 1rem; height: 1rem; flex: none; }
.vote.aye svg { fill: var(--ok); } .vote.nay svg { fill: var(--bad); } .vote.other svg { fill: var(--neutral-icon); }
.vote small { display: block; color: var(--muted); font-size: .75rem; }

.mini { width: 100%; border-collapse: collapse; font-size: .8125rem; }
.mini th { text-align: left; font-size: .75rem; color: var(--muted); font-weight: 600; padding: .25rem .375rem; border-bottom: 1px solid var(--line); }
.mini td { padding: .375rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.mini td:first-child { white-space: nowrap; }
.attach { margin: 0; padding-left: 1.125rem; }
.attach li { margin: .1875rem 0; }

/* ── Medium widths: narrower filters ── */
@media (max-width: 80rem) {
  .layout { grid-template-columns: 14rem minmax(0, 1fr) minmax(0, 1fr); }
}

/* ── Narrow: results view (filters + gallery) and detail view take the width in turn ── */
@media (max-width: 64rem) {
  body { height: auto; min-height: 100%; }
  .layout { display: block; padding: .5rem; }
  .sidebar, .results, .detail { overflow: visible; margin-bottom: .5rem; }
  .gallery { overflow: visible; }
  .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters > .fgroup:nth-child(2) { grid-column: 1 / -1; }   /* search group spans both columns */
  .detail { display: none; }
  body.detail-open .sidebar, body.detail-open .results { display: none; }
  body.detail-open .detail { display: block; }
  .back-btn { display: inline-flex; align-items: center; }
  .dp-cols { grid-template-columns: 1fr; }
  .dp-col { border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (max-width: 36rem) {
  .filters { grid-template-columns: minmax(0, 1fr); }
}
.flag { display: inline-block; width: 1rem; height: 1rem; flex: none; }
.flag.pass { fill: var(--ok); } .flag.fail { fill: var(--bad); }
.help-pop .help-note { margin: .375rem 0 0; color: var(--muted); }

/* Native selects (Search In, Sort): drop the browser's own styling so they match the custom dropdowns
   in every browser — same border, height, padding, text size and arrow. */
.filters select, .sort select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  min-height: 2.125rem;
  padding: 0 1.875rem 0 .625rem;
  font-size: .875rem;
  line-height: 1.2;
  background-color: var(--field);
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right .625rem center;
  background-size: .625rem .375rem;
  cursor: pointer;
}
.sort select { min-height: 1.875rem; font-size: .8125rem; }
.filters select::-ms-expand { display: none; }

/* Agenda link: a subtle icon next to the file number at the top of the reading pane */
.agenda-link { display: inline-flex; align-items: center; justify-content: center; width: 1.5rem; height: 1.5rem; margin-left: .125rem; border-radius: .25rem; color: var(--muted); vertical-align: middle; }
.agenda-link svg { width: .875rem; height: .875rem; fill: currentColor; }
.agenda-link:hover, .agenda-link:focus-visible { color: var(--accent); background: var(--row-hover); }
.motion-summary { display: flex; flex-wrap: wrap; gap: .375rem; margin: 0 0 .25rem; }

/* Filter groups: Date | Search + Search In | RCA Department + Type | Follow-up */
.fgroup { display: flex; flex-direction: column; gap: .75rem; }
.fgroup + .fgroup { border-top: 1px solid var(--line); padding-top: .875rem; }
.filters > .btn { margin-top: .125rem; }
@media (max-width: 64rem) {
  .fgroup + .fgroup { border-top: 0; padding-top: 0; }
}

/* Export CSV: a quiet spreadsheet-download icon, tinted green */
.export-btn { display: inline-flex; align-items: center; justify-content: center; width: 2rem; min-height: 2rem; }
.export-btn svg { width: 1.125rem; height: 1.125rem; }
.export-btn .sheet { fill: var(--ok-bg); stroke: var(--ok); stroke-width: 1.4; stroke-linejoin: round; }
.export-btn .fold { fill: none; stroke: var(--ok); stroke-width: 1.4; stroke-linejoin: round; }
.export-btn .arrow { fill: var(--ok-ink); }
.export-btn:hover:not(:disabled) { background: var(--ok-bg); border-color: var(--ok); }
.export-btn[aria-busy="true"] svg { opacity: .5; }

.hint { margin: 0; font-size: .75rem; color: var(--muted); }

/* "Only items with directives" switch: track + thumb, with visible On/Off text (not color alone) */
.switch-field { display: flex; flex-direction: column; gap: .25rem; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: .75rem; min-height: 2rem; cursor: pointer; font-size: .8125rem; font-weight: 600; }
.switch-ctl { display: inline-flex; align-items: center; gap: .375rem; flex: none; }
.switch input {
  -webkit-appearance: none; appearance: none; margin: 0; flex: none; cursor: pointer;
  position: relative; width: 2.25rem; height: 1.25rem; border-radius: 999px;
  background: var(--control-border); transition: background .15s;
}
.switch input::before {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: calc(1.25rem - 4px); height: calc(1.25rem - 4px); border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .35); transition: transform .15s;
}
.switch input:checked { background: var(--accent); }
.switch input:checked::before { transform: translateX(1rem); }
.switch input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-state { min-width: 1.5rem; font-size: .75rem; font-weight: 600; color: var(--muted); }
.switch input:checked + .switch-state { color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .switch input, .switch input::before { transition: none; } }

/* Toolbar reminder that the switch is on */
.count-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; min-width: 0; }
.filter-chip {
  display: inline-flex; align-items: center; gap: .375rem;
  min-height: 1.625rem; padding: 0 .5rem 0 .625rem;
  border: 1px solid var(--accent); border-radius: 999px;
  background: var(--accent-soft); color: var(--ink);
  font-size: .75rem; font-weight: 600; cursor: pointer;
}
.filter-chip .x { font-size: 1rem; line-height: 1; color: var(--accent); }
.filter-chip:hover { background: var(--row-hover); }
.filter-chip[hidden] { display: none; }

/* "From motion 2 of 8" — subtle link to the motion; highlighted motion in Court Action and Votes */
.from-motion { color: var(--muted); }
.motion-link {
  border: 0; background: none; padding: .125rem 0; min-height: 1.5rem;
  color: var(--accent); font-size: inherit; cursor: pointer;
  text-decoration: underline dotted; text-underline-offset: 3px;
}
.motion-link:hover { text-decoration-style: solid; }
.from-motion .motion-link { min-width: 1.25rem; text-align: center; }
.motion { margin: 0 -.625rem; padding: .625rem; border-radius: .375rem; transition: background .3s, box-shadow .3s; }
.motion.hl { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.motion-head:focus { outline: none; }
.motion-head:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .motion { transition: none; } }

/* ── Round 6: department colors, calmer gallery, nested directives ───────────────────────── */
/* Department pills: one subtle hue per department (same hue wherever that department appears —
   as requester or as the department directed to act). Always labelled, never color alone. */
:root {
  --d0-bg: #e7effb; --d0-ink: #1f4777;   --d1-bg: #e6f3ec; --d1-ink: #1f5d3a;
  --d2-bg: #f8ece2; --d2-ink: #7a3e12;   --d3-bg: #f1e9f8; --d3-ink: #5a3182;
  --d4-bg: #e4f2f3; --d4-ink: #1b5b61;   --d5-bg: #f8e8ec; --d5-ink: #842a44;
  --d6-bg: #f4f0dc; --d6-ink: #5f5011;   --d7-bg: #ebebf8; --d7-ink: #3b3d8c;
  --d8-bg: #eef3e2; --d8-ink: #46601a;   --d9-bg: #f6ebe4; --d9-ink: #6e4127;
  --row-sel: #eef4fc;
}
@media (prefers-color-scheme: dark) {
  :root {
    --d0-bg: #1c2a40; --d0-ink: #a9c7f2;   --d1-bg: #193126; --d1-ink: #9fd8b6;
    --d2-bg: #3a281a; --d2-ink: #f0c19c;   --d3-bg: #2c2340; --d3-ink: #cdb4ef;
    --d4-bg: #17303a; --d4-ink: #9ad6dc;   --d5-bg: #3a1f28; --d5-ink: #f0b0c1;
    --d6-bg: #332e17; --d6-ink: #e2d38e;   --d7-bg: #24264a; --d7-ink: #b9bcf2;
    --d8-bg: #26301a; --d8-ink: #bfd99a;   --d9-bg: #362519; --d9-ink: #e6bd9f;
    --row-sel: #1b2535;
  }
}
.dept { display: inline-block; max-width: 100%; padding: 0 .4375rem; border-radius: .3125rem; font-size: .75rem; line-height: 1.25rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.dept-0 { background: var(--d0-bg); color: var(--d0-ink); } .dept-1 { background: var(--d1-bg); color: var(--d1-ink); }
.dept-2 { background: var(--d2-bg); color: var(--d2-ink); } .dept-3 { background: var(--d3-bg); color: var(--d3-ink); }
.dept-4 { background: var(--d4-bg); color: var(--d4-ink); } .dept-5 { background: var(--d5-bg); color: var(--d5-ink); }
.dept-6 { background: var(--d6-bg); color: var(--d6-ink); } .dept-7 { background: var(--d7-bg); color: var(--d7-ink); }
.dept-8 { background: var(--d8-bg); color: var(--d8-ink); } .dept-9 { background: var(--d9-bg); color: var(--d9-ink); }

/* Sidebar: room for the switch on one line; Reset as a quiet text button */
.layout { grid-template-columns: 17.5rem minmax(0, 1fr) minmax(0, 1.15fr); }
@media (max-width: 80rem) { .layout { grid-template-columns: 17rem minmax(0, 1fr) minmax(0, 1fr); } }
.switch-text { white-space: nowrap; }
.reset-link { align-self: flex-start; font-size: .8125rem; color: var(--accent); text-decoration: none; padding: .25rem 0; }
.reset-link:hover { text-decoration: underline; }

/* Gallery rows: faint dividers instead of gaps, slightly tighter, lighter selection */
.cards { gap: 0; padding: 0; }
.cards > li { border-bottom: 1px solid var(--line); }
.cards > li.empty { border-bottom: 0; }
.card { border: 0; border-radius: 0; padding: .5rem .875rem .5625rem; }
.card[aria-current="true"] { background: var(--row-sel); border-color: transparent; box-shadow: inset 3px 0 0 var(--accent); }
.card-title { font-size: .9375rem; font-weight: 500; line-height: 1.375rem; margin: 0 0 .1875rem; }
.card-meta { font-size: .78125rem; gap: .125rem .4375rem; }
.card-meta .dept { margin-left: .125rem; }

/* Directives nested under the request */
.dirs { list-style: none; margin: -.125rem .875rem .5rem 1.375rem; padding: 0 0 0 .5rem; border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: .0625rem; }
.dir-row {
  width: 100%; display: flex; align-items: center; gap: .5rem;
  padding: .25rem .5rem; border: 0; border-radius: .375rem;
  background: none; color: var(--ink); font-size: .8125rem; text-align: left; cursor: pointer;
}
.dir-row:hover { background: var(--row-hover); }
.dir-row[aria-current="true"] { background: var(--row-sel); box-shadow: inset 2px 0 0 var(--accent); }
.dir-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dir-motion { flex: none; color: var(--muted); font-size: .75rem; white-space: nowrap; }
.dir-row .dept { flex: none; max-width: 9rem; }
.dir-more { border: 0; background: none; padding: .125rem .5rem; color: var(--accent); font-size: .75rem; cursor: pointer; text-align: left; border-radius: .375rem; }
.dir-more:hover { background: var(--row-hover); text-decoration: underline; }

/* Reading pane: highlighted directive (opened from a gallery row) */
.task-card { transition: background .3s, box-shadow .3s; }
.task-card.hl { background: var(--row-sel); box-shadow: inset 3px 0 0 var(--accent); }
.task-card h4:focus { outline: none; }
.task-card h4:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .task-card { transition: none; } }
@media (max-width: 40rem) { .dir-motion { display: none; } }

/* ── Compact votes: one-line tally; expanded list with aligned names and vote labels ── */
.vote-box { margin-top: .375rem; }
.vote-summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .625rem; margin: 0; font-size: .8125rem; font-variant-numeric: tabular-nums; }
.vote-label { font-weight: 600; color: var(--muted); }
.vote-toggle { font-size: .8125rem; padding: 0; min-height: 1.5rem; }
.vote-list {
  display: grid;
  grid-template-columns: fit-content(18rem) auto;
  gap: .125rem 1.25rem;
  margin: .375rem 0 0;
  padding: .375rem .625rem;
  border-left: 2px solid var(--line);
  font-size: .8125rem;
  max-width: 28rem;
}
.vote-list[hidden] { display: none; }
.vote-list dt { margin: 0; overflow-wrap: anywhere; }
.vote-list dd { margin: 0; display: inline-flex; align-items: center; gap: .3125rem; justify-self: start; white-space: nowrap; }
.vote-val svg { width: .875rem; height: .875rem; flex: none; }
.vote-val.aye svg { fill: var(--ok); } .vote-val.nay svg { fill: var(--bad); } .vote-val.other svg { fill: var(--neutral-icon); }

/* ── Department names: short name, full name on hover ── */
.dept-none { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); font-weight: 400; }
.dept-text { text-decoration: underline dotted var(--line); text-underline-offset: 3px; }
.with-wrap { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .25rem .375rem; }
.with-list { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .25rem; }
.plain-owner { color: var(--muted); }
.ms-val { display: flex; flex-direction: column; min-width: 0; }
.ms-full { font-size: .6875rem; color: var(--muted); line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 13rem; }

/* ── Results toolbar: two rows (count + icons; active-filter pills) ── */
.toolbar { display: flex; flex-direction: column; align-items: stretch; gap: .375rem; padding: .5rem .75rem; }
.toolbar-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.toolbar-actions { gap: .125rem; }
.icon-ghost {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; padding: 0;
  border: 0; border-radius: .375rem; background: none; color: var(--muted); cursor: pointer;
}
.icon-ghost svg { width: 1.125rem; height: 1.125rem; fill: currentColor; }
.icon-ghost:hover, .icon-ghost[aria-expanded="true"] { background: var(--row-hover); color: var(--ink); }
.export-btn { border: 0; min-height: 0; }
.export-btn:hover:not(:disabled) { background: var(--ok-bg); border: 0; }
.sort-pop { position: fixed; z-index: 40; min-width: 12rem; padding: .25rem; background: var(--panel); border: 1px solid var(--control-border); border-radius: .5rem; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.sort-opt { display: flex; align-items: center; gap: .5rem; min-height: 1.875rem; padding: 0 .625rem 0 1.5rem; border: 0; border-radius: .375rem; background: none; color: var(--ink); font-size: .8125rem; text-align: left; cursor: pointer; position: relative; }
.sort-opt:hover, .sort-opt:focus-visible { background: var(--row-hover); }
.sort-opt[aria-checked="true"] { font-weight: 600; }
.sort-opt[aria-checked="true"]::before { content: "✓"; position: absolute; left: .5rem; color: var(--accent); }

.active-filters { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .375rem; }
.active-filters[hidden] { display: none; }
.fpill { display: inline-flex; align-items: center; gap: .125rem; max-width: 100%; padding: 0 .125rem 0 .5rem; border-radius: 999px; background: var(--accent-soft); color: var(--ink); font-size: .75rem; line-height: 1.5rem; }
.fpill-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 18rem; }
.fpill-x { display: inline-flex; align-items: center; justify-content: center; width: 1.25rem; height: 1.25rem; border: 0; border-radius: 50%; background: none; color: var(--accent); font-size: .9375rem; line-height: 1; cursor: pointer; }
.fpill-x:hover { background: var(--panel); }
.clear-all { font-size: .75rem; padding: 0 .25rem; min-height: 1.5rem; }
.count-row, .filter-chip { display: none; }

/* ── Votes: tally, then one row of small pills colored by vote ── */
.vote-line { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .5rem; margin: 0; font-size: .8125rem; }
.vote-tally { color: var(--muted); font-variant-numeric: tabular-nums; }
.vote-pills { display: inline-flex; flex-wrap: nowrap; gap: .25rem; min-width: 0; overflow: hidden; }
.vote-pill { flex: none; padding: 0 .4375rem; border-radius: 999px; font-size: .6875rem; font-weight: 600; line-height: 1.25rem; white-space: nowrap; cursor: default; }
.vote-pill.aye { background: var(--ok-bg); color: var(--ok-ink); }
.vote-pill.nay { background: var(--bad-bg); color: var(--bad-ink); }
.vote-pill.other { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--control-border); }

/* ── Directive numbers: a number in an attention-colored circle ── */
:root { --badge-bg: #c2410c; --badge-ink: #ffffff; }                       /* 5.2:1 */
@media (prefers-color-scheme: dark) { :root { --badge-bg: #fb923c; --badge-ink: #1a1206; } }   /* 8.2:1 */
.num-badge {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  min-width: 1.25rem; height: 1.25rem; padding: 0 .3125rem;
  border-radius: 999px; background: var(--badge-bg); color: var(--badge-ink);
  font-size: .6875rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
}
.dir-count { display: inline-flex; align-items: center; gap: .3125rem; font-weight: 500; }
.card-follow { align-items: center; }
.d-sec > h3 .num-badge { margin-left: .125rem; }
.task-card h4 .num-badge { margin-right: .125rem; }

/* ── Top bar About link and About dialog ── */
.about-btn { margin-left: auto; border: 0; background: none; padding: .375rem .5rem; border-radius: .375rem; color: var(--accent); font-size: .8125rem; font-weight: 600; cursor: pointer; }
.about-btn:hover { background: var(--row-hover); text-decoration: underline; }
dialog.about {
  width: min(40rem, calc(100vw - 2rem)); max-height: min(85vh, 48rem);
  padding: 0; border: 1px solid var(--line); border-radius: .75rem;
  background: var(--panel); color: var(--ink); box-shadow: var(--shadow);
}
dialog.about[open] { display: flex; flex-direction: column; }
dialog.about::backdrop { background: rgba(10, 15, 25, .45); }
.about-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .875rem 1.25rem; border-bottom: 1px solid var(--line); }
.about-head h2 { margin: 0; font-size: 1rem; color: var(--accent); }
.about-head .close { position: static; }
.about-body { overflow: auto; padding: .5rem 1.25rem 1.25rem; font-size: .84375rem; line-height: 1.55; }
.about-body h3 { margin: 1rem 0 .25rem; font-size: .8125rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.about-body p { margin: 0 0 .5rem; }
.about-lead { font-size: .9375rem; margin-top: .5rem !important; }
.about-official { margin-top: 1rem !important; padding: .625rem .75rem; border-radius: .5rem; background: var(--accent-soft); }
@media (max-width: 40rem) { dialog.about { width: 100vw; max-height: 100vh; border-radius: 0; } }

/* ── Page navigation in the top bar ── */
.pagenav { display: flex; align-items: stretch; gap: .125rem; align-self: stretch; margin: -.5rem 0; padding-left: .75rem; border-left: 1px solid var(--line); }
.pagenav a { display: inline-flex; align-items: center; min-height: 2.75rem; padding: 0 .75rem; border-bottom: 3px solid transparent; color: var(--ink); font-size: .8125rem; font-weight: 500; text-decoration: none; }
.pagenav a:hover { color: var(--accent); background: var(--row-hover); }
.pagenav a[aria-current="page"] { color: var(--accent); font-weight: 600; border-bottom-color: var(--accent); }
@media (max-width: 80rem) { .topbar .tagline { display: none; } }
@media (max-width: 40rem) { .pagenav { margin: 0; padding-left: 0; border-left: 0; order: 3; width: 100%; } .pagenav a { min-height: 2.25rem; } }

/* ── Department Follow-ups: three panes that scroll with the page ── */
body.page-scroll { height: auto; min-height: 100%; display: block; }
.fu-head { padding: 1rem 1.25rem 0; }
.fu-head h2 { margin: 0; font-size: 1.375rem; line-height: 1.25; }
.fu-sub { margin: .125rem 0 .625rem; color: var(--muted); font-size: .9375rem; }
.fu-scope { margin: 0; max-width: 64rem; padding: .5rem .75rem; border-left: 3px solid var(--accent); border-radius: .375rem; background: var(--accent-soft); font-size: .8125rem; line-height: 1.5; }
.fu-layout { display: grid; grid-template-columns: 17.5rem minmax(0, 1fr) minmax(19rem, 25rem); gap: .75rem; padding: .75rem; align-items: start; }
.fu-pane { min-width: 0; padding: .875rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.fu-pane-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; margin-bottom: .625rem; }
.fu-pane-head h3 { margin: 0; font-size: 1rem; }
.fu-count { margin: .125rem 0 0; color: var(--muted); font-size: .8125rem; font-variant-numeric: tabular-nums; }
.link-btn:disabled { color: var(--muted); text-decoration: none; cursor: default; opacity: .7; }

/* department list: click a line to add/remove; "only" appears on hover to keep just that one */
.fu-dhint { margin: -.25rem 0 .5rem; }
.fu-dlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .125rem; }
.fu-drow { position: relative; display: flex; align-items: center; border-radius: .375rem; }
.fu-drow:hover { background: var(--row-hover); }
.fu-drow.on { background: var(--row-sel); }
.fu-dtoggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: .5rem; min-height: 2.125rem; padding: .25rem 3rem .25rem .5rem; border: 0; border-radius: .375rem; background: none; color: var(--ink); font-size: .8125rem; text-align: left; cursor: pointer; }
.fu-check { flex: none; width: .875rem; height: .875rem; border: 1px solid var(--control-border); border-radius: .1875rem; background: var(--field); }
.fu-drow.on .fu-check { border-color: var(--accent); background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='M9.5 16.2 5.3 12l-1.4 1.4 5.6 5.6L20.1 8.4 18.7 7z'/%3E%3C/svg%3E") no-repeat center / .75rem; }
.fu-drow:not(.on) .dept { opacity: .7; }
.fu-dtoggle .dept { flex: none; max-width: 7.5rem; }
.fu-dname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .78125rem; color: var(--muted); }
.fu-dtoggle .n { flex: none; font-weight: 600; font-variant-numeric: tabular-nums; }
.fu-only { position: absolute; right: .25rem; top: 50%; transform: translateY(-50%); padding: .0625rem .4375rem; border: 1px solid var(--accent); border-radius: 999px; background: var(--panel); color: var(--accent); font-size: .6875rem; font-weight: 600; cursor: pointer; opacity: 0; pointer-events: none; }
.fu-drow:hover .fu-only, .fu-only:focus-visible { opacity: 1; pointer-events: auto; }
.fu-only:hover { background: var(--accent); color: var(--panel); }
@media (hover: none) and (pointer: coarse) { .fu-only { opacity: 1; pointer-events: auto; } }

/* subtle note beside the Follow-ups heading */
.fu-main-head { align-items: flex-start; flex-wrap: wrap; }
.fu-info { display: block; flex: 1 1 18rem; max-width: 32rem; margin: 0; padding: .25rem .5rem; border-left: 2px solid var(--line); color: var(--muted); font-size: .6875rem; line-height: 1.4; }
.fu-info p { margin: 0; }
.fu-dup { display: inline-block; margin-left: .5rem; padding: 0 .4375rem; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--control-border); color: var(--muted); font-size: .6875rem; font-weight: 600; line-height: 1.25rem; vertical-align: middle; white-space: nowrap; }
.fu-src-h { margin: 0 0 .25rem; color: var(--ink); font-weight: 600; }
.fu-src ul { margin: 0; padding-left: 1.125rem; }
.fu-src li { margin: .1875rem 0; }

/* follow-up groups and rows */
.fu-dayfilter { display: flex; align-items: center; gap: .5rem; margin-bottom: .625rem; }
.fu-dayfilter[hidden] { display: none; }
.fu-sec + .fu-sec { margin-top: 1rem; }
.fu-sec-h { display: flex; align-items: baseline; gap: .375rem; margin: 0 0 .125rem; padding: .375rem .625rem; border-radius: .375rem; background: var(--chip-bg); font-size: .875rem; }
.fu-sec-h .n { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.fu-rows { list-style: none; margin: 0; padding: 0; }
.fu-rows > li { border-bottom: 1px solid var(--line); }
.fu-rows > li:last-child { border-bottom: 0; }
.fu-toggle { width: 100%; display: grid; grid-template-columns: 1.25rem minmax(0, 1fr); column-gap: .25rem; padding: .5rem .375rem; border: 0; border-radius: .375rem; background: none; color: var(--ink); text-align: left; cursor: pointer; }
.fu-toggle:hover { background: var(--row-hover); }
.fu-chev { width: 1rem; height: 1rem; margin-top: .125rem; fill: var(--muted); transition: transform .15s; }
.fu-toggle[aria-expanded="true"] .fu-chev { transform: rotate(90deg); }
@media (prefers-reduced-motion: reduce) { .fu-chev { transition: none; } }
.fu-title { font-size: .9375rem; font-weight: 600; line-height: 1.375; overflow-wrap: anywhere; }
.fu-meta { grid-column: 2; display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .5rem; margin-top: .25rem; font-size: .8125rem; color: var(--muted); }
.fu-meta .when { font-variant-numeric: tabular-nums; }
.fu-led { font-size: .75rem; }
.fu-more { padding: 0 .5rem .875rem 1.875rem; }
.fu-more[hidden] { display: none; }
.fu-more .d-text { margin-top: 0; }
.fu-src { margin: .5rem 0 0; font-size: .8125rem; color: var(--muted); overflow-wrap: anywhere; }
.fu-req { color: var(--ink); }
.fu-empty { margin: .375rem .625rem .25rem; color: var(--muted); font-size: .8125rem; }

/* calendar */
.fu-months { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .875rem 1rem; margin-top: .75rem; }
.fu-month h4 { margin: 0 0 .25rem; font-size: .8125rem; text-align: center; }
.fu-month.current h4 { color: var(--accent); }
.fu-month table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: .6875rem; font-variant-numeric: tabular-nums; }
.fu-month th { padding: .125rem 0; color: var(--muted); font-weight: 600; }
.fu-month td { padding: 1px 0; text-align: center; }
.fu-day { display: inline-flex; align-items: center; justify-content: center; width: 1.375rem; height: 1.375rem; border-radius: 50%; color: var(--muted); }
.fu-day.today { box-shadow: inset 0 0 0 1px var(--control-border); color: var(--ink); font-weight: 700; }
button.fu-day { padding: 0; border: 0; font: inherit; font-weight: 700; color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); cursor: pointer; }
button.fu-day:hover, button.fu-day[aria-pressed="true"] { background: var(--accent); color: var(--panel); }

@media (max-width: 80rem) { .fu-layout { grid-template-columns: 15.5rem minmax(0, 1fr) 19rem; } }
@media (max-width: 64rem) {
  .fu-layout { grid-template-columns: minmax(0, 1fr); }
  .fu-months { grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); }
}

/* calendar: dates ahead brighter than dates already past */
:root { --cal-ahead-bg: #1d6fe0; --cal-ahead-ink: #ffffff; }            /* 4.9:1 */
@media (prefers-color-scheme: dark) { :root { --cal-ahead-bg: #5b9dff; --cal-ahead-ink: #0b1220; } }
button.fu-day.before { background: var(--chip-bg); color: var(--muted); box-shadow: inset 0 0 0 1px var(--control-border); font-weight: 600; }
button.fu-day.ahead { background: var(--cal-ahead-bg); color: var(--cal-ahead-ink); box-shadow: none; }
button.fu-day:hover { filter: brightness(.92); }
button.fu-day[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 1px; filter: none; }
button.fu-day.before[aria-pressed="true"] { background: var(--muted); color: var(--panel); }

/* Departments heading: the how-to is a hover tip */
.fu-tip { cursor: help; text-decoration: underline dotted var(--control-border); text-underline-offset: 4px; }
/* AI caution under the counts: small, slightly brighter than muted text */
:root { --caution-ink: #a14a00; }                                   /* 5.6:1 on white */
@media (prefers-color-scheme: dark) { :root { --caution-ink: #f5b25a; } }
.fu-ai { margin: .125rem 0 0; color: var(--caution-ink); font-size: .6875rem; line-height: 1.35; }
/* group titles with a short note */
.fu-sec-h { flex-wrap: wrap; column-gap: .625rem; row-gap: .125rem; }
.fu-sec-t .n { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.fu-sec-note { color: var(--muted); font-size: .6875rem; font-weight: 400; line-height: 1.35; }

/* Top bar: sticks to the top; page tabs sit at the right, just before About, in the same place on every page */
.topbar { position: sticky; top: 0; z-index: 30; }
.pagenav { margin-left: auto; }
.pagenav + .about-btn { margin-left: .25rem; }
/* Page title and subtitle (both pages), a little smaller */
.fu-head { padding: .75rem 1.25rem 0; }
.fu-head h2 { font-size: 1.1875rem; }
.fu-sub { margin: .125rem 0 0; font-size: .8125rem; }
.layout { padding-top: .625rem; }

/* Calendar month cards: a faint tint for months ahead, a light outline on this month, past months plain grey */
:root { --cal-future-tint: #f3f7fd; --cal-past-tint: #f7f8fa; }
@media (prefers-color-scheme: dark) { :root { --cal-future-tint: #1a2230; --cal-past-tint: #1b1f25; } }
.fu-months { gap: .5rem; }
.fu-month { padding: .375rem .375rem .25rem; border: 1px solid transparent; border-radius: .5rem; }
.fu-month.future { background: var(--cal-future-tint); }
.fu-month.current { border-color: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-soft); }
.fu-month.past { background: var(--cal-past-tint); }

/* Follow-ups banner: title on the left, the scope note on the right under the page tabs */
.fu-head-split { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem 2rem; flex-wrap: wrap; }
.fu-head-split .fu-info { flex: 0 1 30rem; max-width: 30rem; margin-top: .125rem; }
@media (max-width: 64rem) { .fu-head-split .fu-info { flex-basis: 100%; max-width: none; } }

/* Banner uses the same columns as the panes, so the scope note ends exactly at the Follow-ups pane's right edge */
.fu-head-split { display: grid; grid-template-columns: 17.5rem minmax(0, 1fr) minmax(19rem, 25rem); column-gap: .75rem; padding: .75rem .75rem 0; }
.fu-head-row { grid-column: 1 / 3; display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem 2rem; padding-left: .5rem; }
@media (max-width: 80rem) { .fu-head-split { grid-template-columns: 15.5rem minmax(0, 1fr) 19rem; } }
@media (max-width: 64rem) { .fu-head-split { grid-template-columns: minmax(0, 1fr); } .fu-head-row { grid-column: 1 / -1; flex-wrap: wrap; } }

/* Page tabs: two wide, equal tabs in the middle of the top bar. Same markup and fixed sizes on every page,
   so they never move when switching pages. */
.topbar { display: grid; grid-template-columns: 17rem minmax(0, 1fr) auto; align-items: stretch; gap: 0 1rem; padding: 0 1.25rem; flex-wrap: nowrap; }
.topbar .brand { align-self: center; flex-wrap: nowrap; }
.topbar .about-btn { align-self: center; margin-left: 0; }
.pagenav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin: 0; padding: 0; border-left: 0; align-self: stretch; max-width: 46rem; width: 100%; justify-self: center; }
.pagenav + .about-btn { margin-left: 0; }
.pagetab { display: flex; align-items: center; justify-content: center; gap: .625rem; min-height: 3.25rem; padding: 0 1rem; border-bottom: 3px solid transparent; color: var(--ink); font-size: .9375rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.pagetab .tab-icon { width: 1.25rem; height: 1.25rem; flex: none; fill: currentColor; }
.pagetab:hover { background: var(--row-hover); color: var(--accent); }
.pagetab[aria-current="page"] { background: var(--accent-soft); color: var(--accent); border-bottom-color: var(--accent); }
.pagenav a { min-height: 3.25rem; font-size: .9375rem; }   /* override the earlier, smaller tab style */
@media (max-width: 48rem) {
  .topbar { grid-template-columns: minmax(0, 1fr) auto; padding: 0 .75rem; }
  .topbar .brand { min-height: 2.75rem; }
  .pagenav { grid-column: 1 / -1; grid-row: 2; max-width: none; }
  .pagetab { min-height: 2.75rem; font-size: .875rem; }
}

/* ── Search page reading pane: shown only when an item is selected ── */
@media (min-width: 64.0625rem) {
  body:not(.has-detail) .layout { grid-template-columns: 17.5rem minmax(0, 1fr); }
  body:not(.has-detail) .detail { display: none; }
  .detail { display: flex; flex-direction: column; overflow: hidden; overflow: clip; padding: 0; }   /* clip: scrollIntoView must scroll only #detailBody */
  #detailBody { flex: 1; min-height: 0; overflow: auto; padding: 1rem 1.25rem 1.75rem; }
  body.has-detail .detail { animation: detail-in .22s ease-out; }
  .detail-close { position: absolute; top: .5rem; right: .625rem; z-index: 6; }
}
@media (min-width: 64.0625rem) and (max-width: 80rem) {
  body:not(.has-detail) .layout { grid-template-columns: 17rem minmax(0, 1fr); }
}
@keyframes detail-in { from { opacity: 0; transform: translateX(.75rem); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { body.has-detail .detail { animation: none; } }
.detail-close { display: inline-flex; align-items: center; gap: .25rem; padding: .125rem .375rem; border: 0; border-radius: .375rem; background: var(--panel); color: var(--muted); font-size: .75rem; cursor: pointer; }
.detail-close span { font-size: 1rem; line-height: 1; }
.detail-close:hover { color: var(--ink); background: var(--row-hover); }
@media (max-width: 64rem) { .detail-close { display: none; } }
/* sticky item header: eyebrow, title, tags and jump links */
.d-head { position: sticky; top: -1rem; z-index: 5; margin: -1rem -1.25rem 0; padding: 1rem 4.5rem .625rem 1.25rem; background: var(--panel); border-bottom: 1px solid var(--line); }
.d-head .jump { margin-bottom: 0; }
.d-head + .d-sec { border-top: 0; margin-top: 0; }
@media (max-width: 64rem) { .d-head { position: static; margin: 0; padding: 0 0 .625rem; } }
/* Scroll areas contain their own absolutely positioned bits (screen-reader labels), so they can't stretch the page */
.gallery, #detailBody, .sidebar { position: relative; }
/* Both tabs: same banner height and same gap below it, so the panes start at the same height */
@media (min-width: 64.0625rem) {
  .fu-head { height: 4.5rem; box-sizing: border-box; padding-top: .75rem; padding-bottom: 0; overflow: hidden; }
  .fu-head-split .fu-info { margin-top: 0; }
  .layout, .fu-layout { padding-top: .625rem; }
}

.fu-moved { color: var(--muted); }

/* ── Tab 2 on desktop: fits the window like tab 1; each pane keeps its header and scrolls its own content ── */
@media (min-width: 64.0625rem) {
  body.page-scroll { height: 100%; min-height: 0; display: flex; flex-direction: column; }
  .fu-layout { flex: 1; min-height: 0; align-items: stretch; }
  .fu-pane { display: flex; flex-direction: column; min-height: 0; overflow: hidden; padding-bottom: 0; }
  .fu-pane > * { flex: none; }
  .fu-pane > .fu-dlist, .fu-pane > #fuList, .fu-pane > .fu-months {
    flex: 1; min-height: 0; overflow: auto; position: relative;
    margin-right: -.875rem; padding-right: .875rem; padding-bottom: .875rem;   /* scrollbar at the pane edge */
  }
  .fu-pane > .fu-months { align-content: start; }
}
