/*
 * Author:  Daryl Jones <daryl@tcomeng.com>
 * Date Created: 08/04/2026
 * Copyright: (c) Daryl D. Jones, Inc. 2026
 * Revision History:  <placeholder>
 *
 * Application layout & components. All colors/spacing come from theme.css tokens.
 */

/* --- App shell --- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  padding: var(--space-6) var(--space-4);
}
/* Brand mark: the TrakORC wordmark, drawn for dark surfaces so it needs no
   backing chip. Text stays in the markup for screen readers. */
.brand {
  height: 48px;
  background: url("/static/img/trakorc-logo.png") center / auto 44px no-repeat;
  border-radius: var(--radius-card);
  text-indent: -9999px;
  overflow: hidden;
  white-space: nowrap;
}
.sidebar .brand { margin-bottom: var(--space-8); }
.sidebar nav a {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-input);
  color: var(--text-secondary);
  border-left: 3px solid transparent;
  margin-bottom: var(--space-1);
}
.sidebar nav a:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }
.sidebar nav a.active {
  background: var(--accent-muted);
  color: var(--text-primary);
  border-left-color: var(--accent);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-6);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}
.topbar-title { flex: 1 1 auto; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: var(--space-3); }

/* Off-canvas nav controls — hidden on desktop, shown at <=768px. */
.nav-toggle { display: none; }
.nav-backdrop { display: none; }

.content { padding: var(--space-8) var(--space-6); max-width: 1280px; width: 100%; }
.content--narrow { max-width: 720px; }

/* --- Security advisory modal (after login) --- */
.advisory-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: rgba(0, 0, 0, 0.6);
}
.advisory-modal {
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  padding: var(--space-6);
}
.advisory-title {
  margin: 0 0 var(--space-3);
  color: var(--text-primary);
}
.advisory-body {
  overflow-y: auto;
  white-space: pre-wrap;
  color: var(--text-secondary);
  line-height: 1.5;
  font-size: 0.9375rem;
}
.advisory-actions {
  margin-top: var(--space-4);
  display: flex;
  justify-content: flex-end;
}

/* --- Sticky footer (all pages) --- */
.site-footer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  padding: var(--space-2) var(--space-4);
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
}
/* Reserve space so the fixed footer never covers page content. */
body { padding-bottom: 40px; }

/* --- Cards --- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: var(--space-6);
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-4);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-input);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); text-decoration: none; }
.btn--ghost { background: transparent; border-color: var(--border-strong); color: var(--text-primary); }
.btn--ghost:hover { background: var(--bg-hover); text-decoration: none; }
/* Destructive action: outlined in danger, filling in only on hover so it never
   competes with the primary action for attention. */
.btn--danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn--danger:hover { background: var(--danger); color: #fff; text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] {
  background: var(--bg-hover);
  color: var(--text-disabled);
  cursor: not-allowed;
}

/* --- Forms --- */
.field { margin-bottom: var(--space-4); }
.field label { display: block; margin-bottom: var(--space-1); font-weight: 500; color: var(--text-secondary); }
.input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-input);
  color: var(--text-primary);
  font: inherit;
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
  outline: none;
}

/* --- Tables --- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}
.table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-surface-raised);
  color: var(--text-secondary);
  font-weight: 500;
}
.table tbody tr:hover { background: var(--bg-hover); }

/* --- Badges / pills --- */
.badge {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--bg-hover);
  color: var(--text-secondary);
}
.badge--danger { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); }
.badge--warning { background: color-mix(in srgb, var(--warning) 20%, transparent); color: var(--warning); }
.badge--success { background: color-mix(in srgb, var(--success) 20%, transparent); color: var(--success); }
.badge--info { background: color-mix(in srgb, var(--info) 20%, transparent); color: var(--info); }

/* --- Category filter chips (inbox) --- */
.cat-filter { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.cat-filter__label { font-size: 0.75rem; color: var(--text-secondary); margin-right: var(--space-1); }
.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease-out, color 150ms ease-out, border-color 150ms ease-out;
}
.cat-chip:hover { background: var(--bg-hover); }
.cat-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cat-chip[aria-pressed="true"] {
  background: var(--accent-muted);
  border-color: var(--accent);
  color: var(--text-primary);
}
.cat-chip__box { font-size: 0.85em; opacity: 0.9; }

/* Checkbox-driven variant (search): the <label> is the chip, native box hidden.
   Scoped with :has(.cat-chip__input) so it never touches the inbox button chips. */
label.cat-chip { margin: 0; }
.cat-chip .cat-chip__input {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}
.cat-chip:has(.cat-chip__input:checked) {
  background: var(--accent-muted);
  border-color: var(--accent);
  color: var(--text-primary);
}
.cat-chip:has(.cat-chip__input) .cat-chip__box::before { content: "\2610"; }        /* ☐ */
.cat-chip:has(.cat-chip__input:checked) .cat-chip__box::before { content: "\2611"; } /* ☑ */
.cat-chip:has(.cat-chip__input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }

/* --- Alerts --- */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-input);
  border: 1px solid var(--border-subtle);
  margin-bottom: var(--space-4);
}
.alert--error { border-color: var(--danger); color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }

/* --- Empty state --- */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--text-secondary);
}

/* --- Auth screen --- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: var(--space-6); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand {
  height: 88px;
  max-width: 260px;
  margin: 0 auto var(--space-6);
  background-size: auto 80px;
  padding: var(--space-3);
}
/* Auth-page logo as a real <img> (robust: renders whenever the file loads,
   independent of the .brand background rule, with alt-text fallback). */
.auth-logo {
  display: block;
  height: 56px;
  max-width: 100%;
  margin: 0 auto var(--space-6);
}

/* --- Helpers --- */
.muted { color: var(--text-secondary); font-size: 0.875rem; }
.btn--sm { padding: var(--space-1) var(--space-2); font-size: 0.875rem; }

/* Day/night toggle: show the icon for the mode you'll switch TO. */
.theme-toggle { padding: var(--space-1) var(--space-2); font-size: 1rem; line-height: 1; }
.theme-icon-night { display: none; }
:root[data-theme="light"] .theme-icon-day { display: none; }
:root[data-theme="light"] .theme-icon-night { display: inline; }
.checkbox { display: flex; align-items: center; gap: var(--space-2); color: var(--text-primary); font-weight: 400; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--space-4); }
.summary { list-style: none; padding: 0; margin: 0 0 var(--space-4); }
.summary li { padding: var(--space-1) 0; border-bottom: 1px solid var(--border-subtle); }
fieldset { border: 1px solid var(--border-subtle); border-radius: var(--radius-input); margin: 0 0 var(--space-4); padding: var(--space-3) var(--space-4); }
legend { color: var(--text-secondary); font-weight: 500; padding: 0 var(--space-2); }

/* --- Authoring wizard layout --- */
.wizard {
  display: grid;
  grid-template-columns: 160px minmax(360px, 1fr) minmax(320px, 1fr);
  gap: var(--space-6);
  align-items: start;
}
.wizard-steps ol { list-style: none; margin: 0; padding: 0; }
.wizard-steps a {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-input);
  color: var(--text-secondary); border-left: 3px solid transparent; margin-bottom: var(--space-1);
}
.wizard-steps a:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }
.wizard-steps a.active { background: var(--accent-muted); color: var(--text-primary); border-left-color: var(--accent); }
.wizard-steps .step-num {
  display: inline-grid; place-items: center; width: 22px; height: 22px;
  border-radius: 999px; background: var(--bg-hover); font-size: 0.75rem;
}
.wizard-form { min-width: 0; }
.wizard-actions { display: flex; justify-content: space-between; margin-top: var(--space-6); }
.subject-card { margin-bottom: var(--space-4); }
.subject-card-hdr { display: flex; justify-content: space-between; align-items: center; }

/* Photo uploader / grid */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
.photo-card { margin: 0; background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-input); padding: var(--space-2); text-align: center; }
.photo-card img { width: 100%; height: 100px; object-fit: cover; border-radius: 4px; }
.photo-card figcaption { font-size: 0.75rem; color: var(--text-secondary); margin: var(--space-1) 0; }
/* Click-to-edit a photo's description. */
[x-cloak] { display: none !important; }
.photo-desc-edit {
  background: none; border: 0; padding: 0; width: 100%;
  font: inherit; color: var(--text-secondary); cursor: pointer; text-align: center;
}
.photo-desc-edit:hover { color: var(--accent-hover); text-decoration: underline; }
.photo-desc-form { display: flex; flex-direction: column; gap: var(--space-2); margin: var(--space-1) 0; }
.photo-desc-form .input { font-size: 0.8rem; padding: var(--space-1) var(--space-2); }
.photo-desc-actions { display: flex; gap: var(--space-2); justify-content: center; }
.uploader { margin-top: var(--space-4); }
/* Drag & drop / paste target feedback. */
.uploader { border: 1px dashed transparent; transition: border-color 120ms ease, background 120ms ease; }
.uploader--drag { border-color: var(--accent); background: var(--accent-muted); }
.uploader__hint { color: var(--text-secondary); font-size: 13px; margin: var(--space-1) 0 0; }
.cropper-holder { max-height: 320px; margin-bottom: var(--space-2); }

/* --- Preview "paper" --- */
.wizard-preview { position: sticky; top: var(--space-4); }
.preview-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-2); color: var(--text-secondary); }
.preview-pane { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-card); padding: var(--space-3); overflow: auto; max-height: 80vh; }
.detail-actions { display: flex; gap: var(--space-2); }

.paper { background: #ffffff; color: #111; border-radius: 6px; padding: 20px; font-size: 13px; line-height: 1.35; }
.paper-safety-alert { background: #cc0000; color: #fff; padding: 3px; font-weight: 700; letter-spacing: .06em; text-align: center; margin-bottom: 4px; }
.paper-tags { text-align: center; margin-bottom: 6px; }
.paper-tag { display: inline-block; border: 1px solid #333; border-radius: 3px; padding: 1px 8px; margin: 0 3px; font-size: 11px; font-weight: 700; letter-spacing: .04em; color: #111; }
/* Free-form tags read as secondary against the curated Special Tags. */
.paper-tag--free { border-color: #999; color: #444; font-weight: 400; text-transform: lowercase; }

/* Live delivery progress (bulletin detail). */
.send-progress__row { display: flex; gap: var(--space-2); align-items: baseline; flex-wrap: wrap; }
.send-progress__bar {
  margin-top: var(--space-2); height: 8px; border-radius: 999px;
  background: var(--bg-hover); overflow: hidden; max-width: 420px;
}
.send-progress__fill {
  display: block; height: 100%; background: var(--success);
  transition: width 300ms ease-out;
}
@media (prefers-reduced-motion: reduce) { .send-progress__fill { transition: none; } }

/* Photo lightbox (bulletin detail). */
.paper-photo img.lightbox-enabled { cursor: zoom-in; }
.tc-img--zoom { cursor: zoom-in; }
body.lightbox-open { overflow: hidden; }
.lightbox {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.85); padding: var(--space-4);
}
.lightbox[hidden] { display: none; }
.lightbox__stage {
  margin: 0; max-width: 92vw; max-height: 92vh;
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
}
.lightbox__img {
  max-width: 92vw; max-height: 82vh; object-fit: contain;
  border-radius: 6px; box-shadow: var(--shadow-md); background: #fff;
}
.lightbox__caption { color: #fff; text-align: center; font-size: 14px; max-width: 80vw; }
.lightbox__close, .lightbox__nav {
  position: absolute; background: rgba(0, 0, 0, 0.5); color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 999px;
  cursor: pointer; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.lightbox__close { top: 16px; right: 16px; width: 44px; height: 44px; font-size: 28px; }
.lightbox__nav { top: 50%; transform: translateY(-50%); width: 48px; height: 48px; font-size: 34px; }
.lightbox__prev { left: 16px; }
.lightbox__next { right: 16px; }
.lightbox__close:hover, .lightbox__nav:hover { background: rgba(0, 0, 0, 0.8); }
.lightbox__close:focus-visible, .lightbox__nav:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lightbox__count { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); color: #fff; font-size: 13px; opacity: 0.8; }

/* Reaction controls (save / interested / not-interested) on the bulletin detail. */
.reaction-controls { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; margin-top: var(--space-3); }
.reaction-controls form { margin: 0; }
.reaction-btn.is-active { border-color: var(--accent); color: var(--accent); }
.reaction-counts { margin-left: var(--space-2); }

/* Compact per-row reaction icons (inbox / dashboard rows). */
.row-reactions { display: inline-flex; gap: 2px; align-items: center; flex: 0 0 auto; }
.row-reactions form { margin: 0; }
.icon-btn {
  background: transparent; border: 0; cursor: pointer; line-height: 1;
  font-size: 18px; padding: 6px; border-radius: 6px; color: var(--text-secondary);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn.is-active { color: var(--accent); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.paper-title { border: 2px solid #cc0000; text-align: center; padding: 5px 8px; margin-bottom: 6px; }
.paper-title .organization { color: #1d4ed8; font-size: 12px; font-weight: 600; margin-bottom: 1px; }
.paper-title .org-location { font-weight: 400; font-size: 11px; }
.paper-title h1 { color: #cc0000; font-size: 22px; margin: 0; font-weight: 700; }
.paper-meta { display: flex; justify-content: space-between; gap: 8px; color: #111; margin-bottom: 8px; }
.paper-photos { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 8px; }
.paper-photo { margin: 0; flex: 1 1 30%; max-width: 33%; min-width: 120px; text-align: center; }
/* Uniform fit-to-box: fixed-height cell, image centered (orientation preserved),
   matching the PDF layout. */
.paper-photo img { width: 100%; height: 170px; object-fit: contain; background: #fff; }
.paper-photo figcaption { border: 1px solid #000; font-size: 11px; padding: 2px 3px; margin-top: 2px; }

/* --- List thumbnail carousel (home + inbox rows): one thumb, prev/next.
   Photos are never cropped (object-fit: contain). The prev/next controls stay
   hidden until you hover the thumbnail, so at rest you just see a clean photo;
   on touch devices (no hover) they remain visible. */
.thumb-carousel {
  position: relative; flex: 0 0 auto; width: 84px; height: 60px;
  border: 1px solid var(--border-subtle); border-radius: var(--radius-input);
  overflow: hidden; background: var(--bg-canvas);
}
.thumb-carousel .tc-img { width: 100%; height: 100%; object-fit: contain; display: block; }
.thumb-carousel .tc-nav {
  position: absolute; top: 0; bottom: 0; width: 22px; border: 0; padding: 0; cursor: pointer;
  color: #fff; font-size: 15px; line-height: 1;
  opacity: 0; transition: opacity 120ms ease;
}
.thumb-carousel .tc-prev {
  left: 0; background: linear-gradient(to right, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
}
.thumb-carousel .tc-next {
  right: 0; background: linear-gradient(to left, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
}
/* Reveal on hover or keyboard focus. */
.thumb-carousel:hover .tc-nav,
.thumb-carousel:focus-within .tc-nav { opacity: 1; }
/* Touch devices have no hover — keep the controls visible there. */
@media (hover: none) {
  .thumb-carousel .tc-nav { opacity: 1; }
}
.thumb-carousel .tc-count {
  position: absolute; bottom: 2px; right: 2px; font-size: 9px;
  padding: 0 5px; border-radius: 999px; background: rgba(0, 0, 0, 0.6); color: #fff;
}
/* Row layout: thumbnail beside the (linked) text body. Compound selectors so
   the flex layout wins over the base .inbox-row/.search-hit display rules. */
.inbox-row.inbox-row--media,
.search-hit.search-hit--media { display: flex; gap: var(--space-3); align-items: center; }
.inbox-row__body, .search-hit__body {
  flex: 1 1 auto; min-width: 0; display: block; color: inherit; text-decoration: none;
}
.paper-narrative { border: 1px solid #000; padding: 8px 10px; min-height: 160px; white-space: pre-wrap; }
.paper-details { border: 1px solid #000; border-top: none; padding: 6px 10px; font-size: 12px; }
.paper-details b { display: inline-block; min-width: 68px; }
.paper-footer { border: 2px solid #1d4ed8; text-align: center; padding: 6px 8px; margin-top: 12px; }
.paper-footer div { color: #1d4ed8; font-size: 12px; }
.paper-confidential { text-align: center; font-style: italic; font-size: 10px; margin-top: 6px; color: #111; }

/* --- Search --- */
.topbar-search .input { width: 260px; padding: var(--space-1) var(--space-3); }
.search-controls { display: flex; gap: var(--space-2); }
.search-list { display: flex; flex-direction: column; gap: var(--space-2); }
/* Trimmed vertical padding on list cards (not .card globally) so more
   bulletins fit per page — vertical matches the home dashboard's .inbox-row
   (space-2) so inbox/search tiles are the same height as the home rows. */
.search-hit { display: block; padding: var(--space-2) var(--space-6); }
.search-hit:hover { background: var(--bg-hover); text-decoration: none; }
.search-hit-hdr { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-1); }
.search-snippet { margin-top: var(--space-2); color: var(--text-secondary); font-size: 0.875rem; }
.search-snippet mark { background: var(--accent-muted); color: var(--text-primary); padding: 0 2px; border-radius: 3px; }
.search-pager { display: flex; justify-content: space-between; align-items: center; margin-top: var(--space-4); }

/* --- County-map picker --- */
.cm-toolbar { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-2); }
.cm-zoom { display: inline-flex; gap: var(--space-1); }
.cm-zoom .btn { min-width: 32px; justify-content: center; }
.county-map {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: var(--space-2);
  overflow: hidden;
}
/* Zoom/pan: block page scroll/gestures over the map; show a grab cursor. */
.county-map svg { width: 100%; height: auto; display: block; cursor: grab; touch-action: none; }
.county-map svg.cm-panning { cursor: grabbing; }
.cm-loading { padding: var(--space-8); text-align: center; color: var(--text-secondary); }
.cm-county { fill: var(--bg-hover); stroke: var(--bg-canvas); stroke-width: 0.3; cursor: pointer; }
.cm-county:hover { fill: var(--accent-hover); }
.cm-county.selected { fill: var(--accent); }
.cm-county.home { stroke: var(--warning); stroke-width: 1.2; }
.cm-borders { fill: none; stroke: var(--border-strong); stroke-width: 0.5; pointer-events: none; }
.cm-nation { fill: none; stroke: var(--border-strong); stroke-width: 0.8; pointer-events: none; }

/* --- Responsive --- */
@media (max-width: 1024px) {
  .wizard { grid-template-columns: 1fr; }
  .wizard-preview { position: static; }
}

@media (max-width: 768px) {
  /* Off-canvas nav: sidebar becomes a slide-in drawer toggled by the hamburger. */
  .app-shell { display: block; }
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    margin-left: calc(var(--space-6) * -1 + var(--space-2));
    border-radius: var(--radius-input);
    font-size: 1.25rem;
    color: var(--text-primary);
    cursor: pointer;
    user-select: none;
  }
  .nav-toggle:hover { background: var(--bg-hover); }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 78%;
    max-width: 300px;
    z-index: 100;
    border-right: 1px solid var(--border-subtle);
    transform: translateX(-100%);
    overflow-y: auto;
  }
  .nav-toggle-cb:checked ~ .sidebar { transform: translateX(0); box-shadow: var(--shadow-md); }
  .nav-toggle-cb:checked ~ .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(0, 0, 0, 0.6);
  }

  /* Topbar reflows: title on row 1 with the menu button; search/actions wrap. */
  .topbar { flex-wrap: wrap; padding: var(--space-2) var(--space-4); row-gap: var(--space-2); }
  .topbar-right { width: 100%; }
  .topbar-search { flex: 1 1 auto; }
  .topbar-search .input { width: 100%; }
  .topbar-user { display: none; }        /* hide the email chip to save space */

  .content { padding: var(--space-4) var(--space-4); }
  .grid-2 { grid-template-columns: 1fr; }
  .detail-actions { flex-wrap: wrap; }
  .search-controls { flex-wrap: wrap; }
  .search-controls #scope { max-width: none !important; }

  /* Comfortable touch targets. */
  .btn { min-height: 40px; }
  .sidebar nav a { padding: var(--space-3); }

  /* Bulletin preview "paper" fits a phone. */
  .preview-pane { max-height: none; padding: var(--space-2); }
  .paper { padding: 12px; }
  .paper-title h1 { font-size: 18px; }
  .paper-meta { flex-direction: column; gap: 2px; }
}

@media (prefers-reduced-motion: no-preference) {
  .sidebar { transition: transform 180ms ease-out; }
}

/* --- PhotoMatch specimen dropzone ------------------------------------------ */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 180px;
  padding: var(--space-6);
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: var(--bg-surface);
  cursor: pointer;
  transition: border-color 150ms ease-out, background 150ms ease-out;
}
.dropzone:hover { background: var(--bg-hover); }
.dropzone:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}
.dropzone--active {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-muted);
}
.dropzone--has-image { border-style: solid; padding: var(--space-3); }
.dropzone--error {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}
.dropzone__title { font-weight: 500; color: var(--text-primary); }
.dropzone__hint { font-size: 12px; margin-top: var(--space-1); }
.dropzone__preview {
  max-width: 100%;
  max-height: 320px;
  border-radius: 6px;
  object-fit: contain;
}
.dropzone__actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  margin-top: var(--space-4);
}
/* .btn sets its own display, which would otherwise defeat the [hidden] attr. */
.dropzone__actions .btn[hidden] { display: none; }

/* --- Dashboard inbox tile: scrollable clickable list ---------------------- */
.inbox-scroll {
  max-height: 380px;
  overflow-y: auto;
  /* Match the inbox/search grids: separate row cards with an 8px gap between
     them, instead of contiguous rows divided by borders. */
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.inbox-row {
  display: block;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  color: var(--text-primary);
}
.inbox-row:hover { background: var(--bg-hover); text-decoration: none; }

/* --- Organization follow-list chips (subscription page) -------------------------- */
.organization-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }
.organization-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  font-size: 0.875rem;
}
.organization-chip__x {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}
.organization-chip__x:hover { color: var(--danger); }

/* --- County typeahead (subscriber form) ----------------------------------- */
.county-autocomplete, .city-autocomplete { position: relative; }
.county-menu {
  position: absolute;
  z-index: 20;
  left: 0; right: 0;
  top: 100%;
  margin-top: 4px;
  background: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  max-height: 260px;
  overflow-y: auto;
  padding: var(--space-1);
}
.county-menu__item {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  cursor: pointer;
}
.county-menu__item:hover,
.county-menu__item.is-active { background: var(--bg-hover); }
.county-menu__empty { padding: var(--space-2) var(--space-3); }
input[readonly].input { color: var(--text-secondary); cursor: default; }

/* --- Rich-text announcement editor --- */
.rich-text {
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-surface);
}
.rt-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-wrap: wrap;
  padding: var(--space-1) var(--space-2);
  background: var(--bg-surface-raised);
  border-bottom: 1px solid var(--border-subtle);
}
.rt-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 var(--space-2);
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  line-height: 1;
  cursor: pointer;
}
.rt-btn:hover { background: var(--bg-hover); }
.rt-btn:active { border-color: var(--border-strong); }
.rt-sep {
  width: 1px;
  align-self: stretch;
  margin: 2px var(--space-1);
  background: var(--border-subtle);
}
.rt-editor {
  min-height: 220px;
  max-height: 480px;
  overflow-y: auto;
  border: 0;
  border-radius: 0;
  background: var(--bg-surface);
}
.rt-editor:focus { outline: none; box-shadow: none; }
.rich-text:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-muted); }
.rt-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-disabled);
}
/* Shared content styling for the editor surface and the sent-body preview. */
.rt-editor h2, .rt-content h2 { font-size: 20px; margin: 0.6em 0 0.3em; }
.rt-editor h3, .rt-content h3 { font-size: 16px; margin: 0.6em 0 0.3em; }
.rt-editor p, .rt-content p { margin: 0 0 0.6em; }
.rt-editor ul, .rt-editor ol, .rt-content ul, .rt-content ol { margin: 0 0 0.6em 1.4em; }
.rt-editor a, .rt-content a { color: var(--accent); }
.rt-content blockquote, .rt-editor blockquote {
  margin: 0 0 0.6em; padding-left: var(--space-3);
  border-left: 3px solid var(--border-strong); color: var(--text-secondary);
}

/* --- Legal / long-form content pages (Terms of Use, etc.) ------------------ */
.legal { max-width: 780px; margin: 0 auto; }
.legal h1 { font-size: 2rem; font-weight: 600; line-height: 1.2; margin: 0 0 .1em; }
.legal h2 { font-size: 1.375rem; font-weight: 600; line-height: 1.25; margin: 1.8em 0 .5em;
  padding-bottom: .3em; border-bottom: 1px solid var(--border-subtle); }
.legal h3 { font-size: 1.0625rem; font-weight: 600; margin: 1.4em 0 .4em; }
.legal p, .legal li { color: var(--text-primary); line-height: 1.6; }
.legal a { color: var(--accent); }
.legal a:hover { color: var(--accent-hover); text-decoration: underline; }
.legal ul { padding-left: 1.3em; }
.legal li { margin: .3em 0; }
.legal hr { border: 0; border-top: 1px solid var(--border-subtle); margin: 2em 0; }
.legal code { font-family: 'JetBrains Mono', ui-monospace, monospace; background: var(--bg-hover);
  padding: 1px 5px; border-radius: 4px; font-size: .9em; }
/* Plain-language summaries: a paragraph that is entirely emphasized. */
.legal p > em:only-child { display: block; color: var(--text-secondary); font-style: italic;
  border-left: 3px solid var(--accent); background: var(--accent-muted);
  padding: 8px 14px; border-radius: 0 6px 6px 0; margin: .2em 0 1em; }
.legal blockquote { margin: 1em 0; padding: 10px 16px; border-left: 3px solid var(--border-strong);
  background: var(--bg-surface); border-radius: 0 8px 8px 0; color: var(--text-secondary); }
.legal > p:first-of-type { color: var(--text-secondary); }

/* Public (signed-out) wrapper for legal pages. */
.legal-public { max-width: 820px; margin: 0 auto; padding: var(--space-8) var(--space-6) var(--space-10); }
.legal-public__brand { display: block; text-align: center; margin-bottom: var(--space-6); }
.legal-public__brand img { height: 40px; }
.legal-public .legal.card { padding: var(--space-8); }
.legal-public__back { text-align: center; margin-top: var(--space-6); }

/* Footer link separator. */
.site-footer__sep { margin: 0 6px; }
