/* ============================================================================
   Fundraisers — "Counsel + Midnight" theme.
   All color is driven by CSS custom properties: Counsel (light) on :root, a true
   Midnight (dark) twin under [data-theme="dark"], and explicit [data-theme="light"]
   so the in-app toggle always wins over the OS preference. Components read tokens
   only — never hardcode a hex in a rule.
   ============================================================================ */
:root, :root[data-theme="light"] {
  color-scheme: light;
  /* accents */
  --grape: #0e7a5c;        /* primary = emerald */
  --grape-d: #0b5e47;
  --pink: #12a07a;         /* gradient partner (emerald → teal) */
  --gold: #b0832a;         /* gold: targets, money, senate */
  --gold-d: #8a6420;
  --teal: #12916e;
  --sky: #3f8f7a;
  --rose: #c0452f;         /* danger / brick */
  --mint: #12916e;         /* money / success */
  --ink: #16203a;          /* deep navy ink */
  --ink-soft: #5a6478;
  /* grounds & surfaces */
  --bg: #f3f3ee;           /* paper */
  --card: #ffffff;
  --surface-2: #f4f5f1;    /* secondary surface / tints */
  --line: #e3e4dd;         /* hairline */
  --shadow: 0 10px 28px rgba(20, 27, 46, .10);
  --shadow-sm: 0 6px 20px rgba(20, 27, 46, .07);
  --radius: 15px;
  /* text on accent fills (white in light, near-black in dark) */
  --btn-ink: #ffffff;
  --glass: rgba(255, 255, 255, .82);
  --accent-soft: #e7f1ec;
  --accent-soft-ink: #0c5c46;
  /* party */
  --dem: #2c5fa8; --dem-soft: #e2ecf7;
  --rep: #c0452f; --rep-soft: #f7e2de;
  --ind: #7c5cc4; --ind-soft: #ece4f7;
  /* semantic status */
  --good: #12916e; --good-soft: #dcece4; --good-ink: #0f6f52;
  --danger: #c0452f; --danger-soft: #f7e0dc; --danger-ink: #a5321f;
  --warn: #b0832a; --warn-soft: #f6edda; --warn-ink: #7a5a12;
  --house: #0f766e; --house-soft: #e0f2ee;
  --ring: #16a34a;         /* "can attend" green outline */
  --scrim: rgba(22, 27, 42, .45);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);     /* notch/Dynamic Island in landscape */
  --safe-right: env(safe-area-inset-right, 0px);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --grape: #8f7ff2;        /* primary = luminous lavender */
  --grape-d: #b3a6ff;
  --pink: #b3a6ff;
  --gold: #e0b24d;
  --gold-d: #caa14a;
  --teal: #37e0c8;
  --sky: #37e0c8;
  --rose: #ff6b78;
  --mint: #37e0c8;
  --ink: #e9ebf4;
  --ink-soft: #969bb0;
  --bg: #12141c;
  --card: #1b1e29;
  --surface-2: #232733;
  --line: #2a2e3d;
  --shadow: 0 14px 32px rgba(0, 0, 0, .52);
  --shadow-sm: 0 10px 26px rgba(0, 0, 0, .42);
  --btn-ink: #14161f;
  --glass: rgba(18, 20, 28, .82);
  --accent-soft: #262247;
  --accent-soft-ink: #b3a6ff;
  --dem: #7aa2f7; --dem-soft: #1f2740;
  --rep: #ff8f8f; --rep-soft: #38222a;
  --ind: #b3a6ff; --ind-soft: #272247;
  --good: #37e0c8; --good-soft: #17352f; --good-ink: #5fe8d3;
  --danger: #ff6b78; --danger-soft: #3a2126; --danger-ink: #ff8f8f;
  --warn: #e0b24d; --warn-soft: #332a16; --warn-ink: #e6c069;
  --house: #37e0c8; --house-soft: #17342f;
  --ring: #22c55e;
  --scrim: rgba(0, 0, 0, .6);
}
/* Honor the OS preference when the user hasn't chosen in-app (no data-theme set). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --grape: #8f7ff2; --grape-d: #b3a6ff; --pink: #b3a6ff;
    --gold: #e0b24d; --gold-d: #caa14a; --teal: #37e0c8; --sky: #37e0c8;
    --rose: #ff6b78; --mint: #37e0c8; --ink: #e9ebf4; --ink-soft: #969bb0;
    --bg: #12141c; --card: #1b1e29; --surface-2: #232733; --line: #2a2e3d;
    --shadow: 0 14px 32px rgba(0,0,0,.52); --shadow-sm: 0 10px 26px rgba(0,0,0,.42);
    --btn-ink: #14161f; --glass: rgba(18,20,28,.82);
    --accent-soft: #262247; --accent-soft-ink: #b3a6ff;
    --dem: #7aa2f7; --dem-soft: #1f2740; --rep: #ff8f8f; --rep-soft: #38222a; --ind: #b3a6ff; --ind-soft: #272247;
    --good: #37e0c8; --good-soft: #17352f; --good-ink: #5fe8d3;
    --danger: #ff6b78; --danger-soft: #3a2126; --danger-ink: #ff8f8f;
    --warn: #e0b24d; --warn-soft: #332a16; --warn-ink: #e6c069;
    --house: #37e0c8; --house-soft: #17342f; --ring: #22c55e; --scrim: rgba(0,0,0,.6);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
/* Guarantee the page never scrolls sideways (§3): clip horizontal overflow at the
   root scroller. `clip` (not `hidden`) so the sticky topbar keeps working. Real
   content fits at every width — this only ever catches a scrollbar-gutter sub-pixel. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overflow-x: clip; }
/* Kill the 300ms tap delay + double-tap zoom on interactive controls (snappier taps). */
button, a, .card, .row-item, .status-opt, .chip-btn, .tab, .cal-cell, .segment button, label { touch-action: manipulation; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1100px 520px at 50% -10%, color-mix(in srgb, var(--grape) 9%, var(--bg)) 0%, transparent 60%),
    var(--bg);
  min-height: 100vh; min-height: 100dvh;
  /* Hard guarantee the page body never scrolls sideways (§3). `clip` — not `hidden`
     — so the sticky topbar keeps working. Real content already fits; this only ever
     catches a stray sub-pixel/scrollbar overhang. */
  overflow-x: clip;
}
/* Subtle US Capitol / National Mall skyline anchored at the bottom of the viewport. */
body::before {
  content: ""; position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(1200px, 165%); height: 44vh; max-height: 440px;
  background: url("/assets/capitol-bg.svg") center bottom / contain no-repeat;
  opacity: 0.16; pointer-events: none; z-index: 0;
}
:root[data-theme="dark"] body::before { opacity: 0.10; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) body::before { opacity: 0.10; } }
.hidden { display: none !important; }
a { color: var(--grape-d); }
.login, .app { position: relative; z-index: 1; }

/* ===== Login ===== */
.login {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: calc(var(--safe-top) + 20px) calc(20px + var(--safe-right)) calc(var(--safe-bot) + 20px) calc(20px + var(--safe-left));
}
.login-card {
  background: var(--card); border-radius: 28px; box-shadow: var(--shadow);
  padding: 32px 26px; width: 100%; max-width: 360px; text-align: center;
  border: 1px solid var(--line);
}
.logo-big { font-size: 56px; line-height: 1; }
.logo-img { width: 78px; height: 78px; border-radius: 20px; box-shadow: var(--shadow); }
.login-card h1 { margin: 8px 0 2px; font-size: 28px; letter-spacing: -0.5px; font-family: Georgia, "Iowan Old Style", serif; font-weight: 600; }
.tagline { color: var(--ink-soft); margin: 0 0 18px; font-size: 14px; }
.pin-dots { display: flex; gap: 14px; justify-content: center; margin: 6px 0 4px; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; background: var(--line); transition: transform .15s, background .15s; }
.pin-dots span.on { background: var(--grape); transform: scale(1.15); }
.pin-error { color: var(--ink); font-size: 16px; min-height: 1.3em; margin: 6px 0; }
.login-card { touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.login.busy .pin-dots span.on { animation: pinpulse .9s ease-in-out infinite; }
@keyframes pinpulse { 50% { opacity: .35; } }
.login.bad .pin-dots { animation: pinshake .35s; }
@keyframes pinshake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.keypad { display: grid; grid-template-columns: repeat(3, clamp(64px, 22vw, 84px)); justify-content: center; gap: clamp(8px, 1.6vh, 14px); margin-top: 8px; touch-action: manipulation; }
.keypad button {
  font-size: clamp(26px, 4vh, 30px); height: clamp(58px, 9vh, 84px); padding: 0; border: none; border-radius: 16px; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  background: var(--surface-2); color: var(--ink); font-weight: 600; cursor: pointer; transition: transform .08s, background .15s;
}
.keypad button:active { transform: scale(0.94); background: var(--accent-soft); }
.keypad button:disabled { opacity: .5; }
.keypad .key-util { background: transparent; font-size: 24px; color: var(--ink); }

/* ===== App shell ===== */
/* Fully fluid — fills the whole browser window/device (the card grids, map, and
   stats flow into more columns as it widens); collapses to a single column on a
   phone. No fixed cap, so there's never dead margin on a wide monitor. */
.app { width: 100%; margin: 0 auto; padding-bottom: calc(92px + var(--safe-bot)); }
/* Reading/entry surfaces keep a comfortable max width (long lines stay readable)
   and CENTER within the full-width app rather than stranding in the top-left. */
#view-settings { max-width: 900px; margin-left: auto; margin-right: auto; }
#view-chat { max-width: 860px; margin-left: auto; margin-right: auto; }
.search, .cal-toolbar { max-width: 760px; }
.segment { max-width: 640px; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(var(--safe-top) + 14px) calc(18px + var(--safe-right)) 14px calc(18px + var(--safe-left));
  background: linear-gradient(120deg, var(--grape), var(--pink));
  color: var(--btn-ink); border-bottom-left-radius: 22px; border-bottom-right-radius: 22px;
  box-shadow: var(--shadow-sm); display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.brand { font-weight: 800; font-size: 19px; letter-spacing: -0.3px; display: inline-flex; align-items: center; gap: 9px; }
/* The navy tile measures only 3.04:1 against the dark-green end of the light header, so a thin
   ring in the button-ink color (white in light, near-black in dark) defines the edge rather
   than leaving it to that margin. 6.4px = the icon's own 22/96 corner at 28px. */
.brand-icon { width: 28px; height: 28px; flex: none; border-radius: 6.4px;
  box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--btn-ink) 38%, transparent); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.greeting { font-size: 13px; opacity: .92; }
.btn-onaccent { background: color-mix(in srgb, var(--btn-ink) 16%, transparent); color: var(--btn-ink); }

/* Light / Dark / Auto segmented pill on the top bar. */
.theme-seg { display: inline-flex; background: color-mix(in srgb, var(--btn-ink) 15%, transparent); border-radius: 999px; padding: 2px; gap: 1px; }
.theme-seg button {
  border: none; background: transparent; color: var(--btn-ink); opacity: .68;
  font-weight: 800; font-size: 11px; min-width: 26px; height: 22px; padding: 0 7px;
  border-radius: 999px; cursor: pointer; font-family: inherit; transition: background .15s, opacity .15s;
}
.theme-seg button.active { background: var(--btn-ink); color: var(--grape); opacity: 1; }

.view { padding: 16px calc(16px + var(--safe-right)) 8px calc(16px + var(--safe-left)); }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 2px 12px; }
.view-head h2 { font-size: 20px; margin: 0; letter-spacing: -0.3px; font-family: Georgia, "Iowan Old Style", serif; font-weight: 600; }
.section-title { font-size: 15px; margin: 22px 4px 10px; display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 700; }
.section-title:first-child { margin-top: 8px; }

/* Collapsible Settings sections — a plain <summary class="section-title"> row that
   expands its <div class="card soft">. Collapsed by default so opening Settings shows
   a compact list of headers instead of every card stacked open (was ~5.4x the screen
   tall). Chevron rotates open; only the tap target is padded so it stays touch-friendly. */
.settings-group { margin: 10px 0; }
.settings-group summary.section-title {
  margin: 0; padding: 12px 14px; cursor: pointer; user-select: none; list-style: none;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); justify-content: space-between;
}
.settings-group summary.section-title::-webkit-details-marker { display: none; }
.settings-group summary.section-title::after {
  content: "›"; font-size: 20px; font-weight: 400; color: var(--ink-soft); line-height: 1;
  transform: rotate(90deg); transition: transform .18s ease; flex: none;
}
.settings-group[open] summary.section-title { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.settings-group[open] summary.section-title::after { transform: rotate(-90deg); }
.settings-group summary.section-title:active { background: var(--surface-2); }
.settings-group .card.soft {
  margin: 0; border-top: none; border-top-left-radius: 0; border-top-right-radius: 0;
  animation: settingsOpen .16s ease;
}
@keyframes settingsOpen { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.hint { font-size: 12px; color: var(--ink-soft); font-weight: 500; }
.pill { background: var(--grape); color: var(--btn-ink); font-size: 12px; font-weight: 700; border-radius: 999px; padding: 1px 9px; min-width: 20px; text-align: center; }

/* segmented control */
.segment { display: flex; gap: 6px; background: var(--surface-2); border-radius: 12px; padding: 4px; }
.segment button { flex: 1; border: none; background: transparent; color: var(--ink-soft); font-weight: 700; font-size: 13px; padding: 8px 6px; border-radius: 9px; cursor: pointer; font-family: inherit; }
.segment button.active { background: var(--card); color: var(--grape-d); box-shadow: var(--shadow-sm); }

/* Lists + cards */
.list { display: flex; flex-direction: column; gap: 10px; }
/* Directory + member results flow into columns on wider windows (calendar-list keeps
   its day-by-day column layout, so it deliberately stays a flex column). */
#directory-list, #member-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; align-items: start; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 14px; position: relative; border: 1px solid var(--line); border-left: 5px solid var(--line); cursor: pointer;
}
.card.soft { border-left: 1px solid var(--line); box-shadow: var(--shadow-sm); margin-bottom: 10px; cursor: default; }
.card.flat { cursor: default; }
.card-row { display: flex; align-items: flex-start; gap: 10px; }

/* Avatars (Member of Congress + contact headshots) */
.avatar { position: relative; width: 46px; height: 46px; border-radius: 50%; flex: none; overflow: hidden; box-shadow: var(--shadow-sm); }
.avatar.sm { width: 38px; height: 38px; }
.avatar.lg { width: 64px; height: 64px; }
.avatar-fb { display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--btn-ink); font-size: 15px; background: linear-gradient(120deg, var(--grape), var(--pink)); }
.avatar.lg.avatar-fb { font-size: 22px; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card-main { flex: 1; min-width: 0; }
.card-title { font-weight: 700; font-size: 16px; line-height: 1.25; }
.card-sub { font-size: 13px; color: var(--ink-soft); margin-top: 3px; word-break: break-word; }
.card-when { font-size: 13px; font-weight: 700; color: var(--grape-d); margin-top: 4px; }
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

/* Party is shown by the red/blue badge tag only — the left edge is reserved for
   target (gold) and the whole-card outline for "in town", so those read clearly. */

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-soft-ink); }
.badge.dem { background: var(--dem-soft); color: var(--dem); }
.badge.rep { background: var(--rep-soft); color: var(--rep); }
.badge.ind { background: var(--ind-soft); color: var(--ind); }
.badge.house { background: var(--house-soft); color: var(--house); }
.badge.senate { background: var(--warn-soft); color: var(--warn-ink); }
.badge.outside { background: var(--warn-soft); color: var(--warn-ink); }
.badge.s-new { background: var(--surface-2); color: var(--ink-soft); }
.badge.s-interested { background: var(--warn-soft); color: var(--warn-ink); }
.badge.s-low { background: var(--surface-2); color: var(--ink-soft); }
.badge.s-registered { background: var(--good-soft); color: var(--good-ink); }
.badge.s-ignored { background: var(--surface-2); color: var(--ink-soft); }
.badge.attended { background: var(--good-soft); color: var(--good-ink); }

/* Ingestion / email log */
.log-summary { font-size: 12.5px; color: var(--ink-soft); font-weight: 700; margin-bottom: 12px; line-height: 1.6; }
.log-row { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-sm); padding: 10px 12px; margin-bottom: 8px; }
.log-row.tappable { cursor: pointer; }
.log-row.tappable:active { transform: scale(0.99); }
.log-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.log-when { font-size: 11px; color: var(--ink-soft); white-space: nowrap; }
.log-subj { font-weight: 700; font-size: 14px; word-break: break-word; line-height: 1.3; }
.log-from { font-size: 12px; color: var(--ink-soft); margin-top: 1px; }
.log-note { font-size: 12.5px; color: var(--grape-d); margin-top: 5px; line-height: 1.4; }

/* Data freshness / API list */
.diag-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 13px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.diag-row:last-child { border-bottom: none; }
.diag-row span { color: var(--ink-soft); }
.diag-row b { text-align: right; font-weight: 700; }
.api-list { display: flex; flex-direction: column; gap: 10px; }
.api-row { font-size: 12.5px; line-height: 1.5; color: var(--ink-soft); }
.api-row b { color: var(--ink); }

/* Full email viewer */
.email-body { white-space: pre-wrap; word-break: break-word; font-size: 14px; line-height: 1.5; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; max-height: 52dvh; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.att { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.att-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.att-head a { font-weight: 700; font-size: 14px; text-decoration: none; word-break: break-all; }
.att-meta { font-size: 11px; color: var(--ink-soft); white-space: nowrap; }
.att-text { margin-top: 8px; max-height: 40dvh; }

/* Month calendar grid */
.cal-toolbar { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.cal-toolbar .search { flex: 1; margin-top: 0; }
.cal-grid-toggle { white-space: nowrap; flex-shrink: 0; }
.cal-grid-wrap {
  max-width: 300px; margin: 10px auto 4px; background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 12px; box-shadow: var(--shadow-sm); display: flex; gap: 14px; flex-wrap: wrap; justify-content: center;
}
.cal-month { margin: 0; flex: 1; min-width: 124px; }
.cal-month-title { font-weight: 800; font-size: 11px; color: var(--ink-soft); margin: 0 2px 5px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; max-width: 130px; margin: 0 auto; }
.cal-dow { font-size: 8.5px; font-weight: 800; color: var(--ink-soft); text-align: center; padding: 1px 0; }
.cal-cell { aspect-ratio: 1 / 1; min-width: 0; max-width: 20px; display: flex; align-items: center; justify-content: center; position: relative; font-size: 10px; font-weight: 600; color: var(--ink); border-radius: 6px; }
.cal-cell.empty { visibility: hidden; }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--grape); }
.cal-cell.has-events { background: var(--accent-soft); color: var(--accent-soft-ink); font-weight: 800; cursor: pointer; }
.cal-cell.has-events:active { transform: scale(0.92); }
.cal-cell.selected { background: var(--grape); color: var(--btn-ink); box-shadow: none; }
.cal-dot { position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%); width: 5px; height: 5px; border-radius: 50%; background: var(--grape); }
.cal-dot.dem { background: var(--dem); } .cal-dot.rep { background: var(--rep); } .cal-dot.ind { background: var(--ind); } .cal-dot.unknown { background: var(--ink-soft); }
.cal-cell.selected .cal-dot { background: var(--btn-ink); }
.sel-day { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-sm); padding: 10px 14px; margin-bottom: 10px; font-weight: 800; color: var(--grape-d); font-size: 14px; }

/* Same-day travel */
.trip-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: linear-gradient(120deg, var(--grape), var(--pink)); color: var(--btn-ink); border-radius: 14px; padding: 11px 14px; margin-bottom: 10px; cursor: pointer; box-shadow: var(--shadow-sm); }
.trip-banner .tb-main { font-size: 14px; }
.trip-banner .tb-go { font-weight: 800; font-size: 13px; white-space: nowrap; }
.trip-list { display: flex; flex-direction: column; gap: 0; margin: 4px 0; }
.trip-stop { display: flex; gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-sm); padding: 10px 12px; cursor: pointer; }
.ts-num { width: 26px; height: 26px; border-radius: 50%; background: var(--grape); color: var(--btn-ink); font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 13px; flex: none; }
.ts-main { flex: 1; min-width: 0; }
.ts-title { font-weight: 700; font-size: 15px; }
.ts-sub { font-size: 12.5px; color: var(--ink-soft); }
.trip-leg { font-size: 12px; color: var(--ink-soft); padding: 6px 0 6px 40px; font-weight: 600; }
.trip-leg.tight { color: var(--danger); }

/* Agenda / calendar grouping */
.agenda-day { font-size: 13px; font-weight: 800; color: var(--ink-soft); margin: 16px 2px 8px; }
.agenda-day:first-child { margin-top: 4px; }
/* Fluid columns: 1 on a phone, then as many ~320px cards as the window fits. */
.day-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; align-items: start; }
/* Targeted legislator — gold stripe down the left edge. */
.card.is-target { border-left-color: var(--gold); }
/* "I'll be in town" — bold green outline + glow + faint wash so the fundraisers
   I could actually attend really jump out from the ones I'd miss traveling. */
.card.can-attend {
  background: color-mix(in srgb, var(--ring) 9%, var(--card));
  box-shadow: 0 0 0 3px var(--ring), 0 0 0 5px color-mix(in srgb, var(--ring) 20%, transparent), 0 8px 20px color-mix(in srgb, var(--ring) 26%, transparent), var(--shadow-sm);
}
.badge.target { background: var(--warn-soft); color: var(--warn-ink); }

/* Two times reported by the organizer for one event. */
.time-alt { font-weight: 600; color: var(--ink-soft); }
.time-note { font-size: 12px; font-weight: 600; color: var(--warn-ink); background: var(--warn-soft);
  border-radius: 8px; padding: 5px 8px; margin-top: 6px; line-height: 1.35; }
.detail-banner.time { background: var(--warn-soft); color: var(--warn-ink); }

/* Travel awareness (from GoThere) — can David attend? (binary) */
.badge.presence.in-town { background: var(--good-soft); color: var(--good-ink); }
.badge.presence.away    { background: var(--danger-soft); color: var(--danger-ink); }
.presence-banner { border-radius: 12px; padding: 10px 12px; font-size: 13px; font-weight: 600; margin: 12px 0; }
.presence-banner.in-town { background: var(--good-soft); color: var(--good-ink); }
.presence-banner.away    { background: var(--danger-soft); color: var(--danger-ink); }

/* Buttons */
.btn { border: none; border-radius: 12px; padding: 10px 14px; font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit; transition: transform .08s, filter .15s, background .15s; }
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--grape); color: var(--btn-ink); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-accent { background: linear-gradient(120deg, var(--grape), var(--pink)); color: var(--btn-ink); }
.btn-gold { background: linear-gradient(120deg, var(--gold), var(--gold-d)); color: var(--btn-ink); }
.btn-ghost { background: var(--surface-2); color: var(--grape-d); }
.btn-soft { background: var(--accent-soft); color: var(--accent-soft-ink); }
.btn-danger-ghost { background: var(--danger-soft); color: var(--danger-ink); }
.btn-mini { padding: 5px 11px; font-size: 12px; border-radius: 9px; }
.btn-block { width: 100%; margin-top: 10px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.empty { text-align: center; color: var(--ink-soft); padding: 30px 14px; font-size: 14px; line-height: 1.5; }
.empty .big { font-size: 38px; display: block; margin-bottom: 8px; }
.search { width: 100%; margin-bottom: 12px; }

/* form fields */
.field-label { display: block; font-size: 13px; font-weight: 700; color: var(--ink-soft); margin: 12px 2px 6px; }
input[type=text], input[type=date], input[type=time], input[type=number], input[type=url], input[type=email], input[type=tel], input[type=search], select, textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 12px;
  font-size: 16px; font-family: inherit; color: var(--ink); background: var(--card); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--grape); }
textarea { resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.msg { font-size: 13px; margin-top: 10px; min-height: 16px; }
.msg.ok { color: var(--good-ink); }
.msg.err { color: var(--rose); }
.version { text-align: center; color: var(--ink-soft); opacity: .7; font-size: 12px; margin: 18px 0 4px; }
.note { font-size: 12px; color: var(--ink-soft); line-height: 1.45; margin: 8px 2px 0; }

/* ===== Tab bar ===== */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 8px var(--safe-right) calc(8px + var(--safe-bot)) var(--safe-left);
  margin: 0 auto;
}
/* On phones the tabs spread evenly; on desktop cluster them centered so they don't
   float to the far edges of a wide bar. */
@media (min-width: 900px) { .tabbar { justify-content: center; gap: 46px; } }
.tab { border: none; background: none; color: var(--ink-soft); font-size: 10.5px; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; font-family: inherit; padding: 4px 8px; border-radius: 12px; }
.tab span { font-size: 21px; }
.tab.active { color: var(--grape); }

/* ===== Sheets / modals ===== */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: var(--scrim); }
.sheet-card {
  background: var(--card); width: 100%; max-width: 640px; border: 1px solid var(--line);
  border-top-left-radius: 26px; border-top-right-radius: 26px;
  padding: 18px 18px calc(20px + var(--safe-bot)); max-height: 93dvh; overflow-y: auto;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  box-shadow: 0 -14px 44px rgba(10, 14, 26, .30); animation: slideUp .22s ease;
}
@keyframes slideUp { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.sheet-head h3 { margin: 0; font-size: 19px; line-height: 1.2; font-family: Georgia, "Iowan Old Style", serif; font-weight: 600; }
.sheet-close { border: none; background: var(--surface-2); color: var(--ink-soft); border-radius: 10px; width: 32px; height: 32px; font-size: 15px; cursor: pointer; flex: none; }
.loading { text-align: center; color: var(--grape); padding: 16px; font-weight: 600; }

/* Event detail */
.detail-when { font-size: 15px; font-weight: 800; color: var(--grape-d); }
.detail-loc { font-size: 14px; color: var(--ink); margin-top: 2px; }
.detail-banner { background: var(--warn-soft); color: var(--warn-ink); border-radius: 12px; padding: 10px 12px; font-size: 13px; font-weight: 600; margin: 12px 0; }
.kv { display: flex; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.kv:first-of-type { border-top: none; }
.kv .k { color: var(--ink-soft); font-weight: 700; width: 92px; flex: none; }
.kv .v { flex: 1; min-width: 0; word-break: break-word; }
.linkrow { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.linkrow a, .linkrow .btn { text-decoration: none; }
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0 4px; }
.status-opt { border: 1.5px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; font-weight: 700; font-size: 13px; cursor: pointer; background: var(--card); color: var(--ink-soft); }
.status-opt.active { border-color: var(--grape); color: var(--grape-d); background: var(--accent-soft); }

/* Tiers table */
.tier-table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 14px; }
.tier-table th { text-align: left; font-size: 12px; color: var(--ink-soft); font-weight: 700; padding: 6px 8px; }
.tier-table td { padding: 8px; border-top: 1px solid var(--line); }
.tier-table .amt { font-weight: 800; color: var(--ink); white-space: nowrap; }
.cap-tag { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; }
.cap-personal { background: var(--dem-soft); color: var(--dem); }
.cap-pac { background: var(--warn-soft); color: var(--warn-ink); }
.cap-either { background: var(--accent-soft); color: var(--accent-soft-ink); }
.legal-box { background: var(--accent-soft); border-radius: 12px; padding: 10px 12px; font-size: 13px; margin-top: 10px; line-height: 1.5; }
.legal-box b { color: var(--grape-d); }

/* Map */
#map { width: 100%; height: 62dvh; min-height: 360px; border-radius: var(--radius); box-shadow: var(--shadow-sm); z-index: 1; }
.map-legend { display: flex; gap: 12px; flex-wrap: wrap; margin: 10px 2px; font-size: 12px; color: var(--ink-soft); }
.map-legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.leaflet-popup-content { font-size: 13px; line-height: 1.4; }

/* Activity / stats */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 14px; text-align: center; }
.stat-tile .num { font-size: 30px; font-weight: 800; letter-spacing: -1px; }
.stat-tile .lbl { font-size: 12px; color: var(--ink-soft); font-weight: 600; margin-top: 2px; }
.stat-tile.grape .num { color: var(--grape); }
.stat-tile.gold .num { color: var(--gold-d); }
.stat-tile.teal .num { color: var(--teal); }
.stat-tile.green .num { color: var(--good); }
.trivia { background: linear-gradient(120deg, var(--grape), var(--pink)); color: var(--btn-ink); border-radius: var(--radius); padding: 14px 16px; font-size: 14px; font-weight: 600; line-height: 1.45; box-shadow: var(--shadow-sm); }
.trivia .spark { font-size: 18px; }
.split-bar { display: flex; height: 26px; border-radius: 999px; overflow: hidden; margin-top: 8px; box-shadow: inset 0 0 0 1px var(--line); }
.split-bar > div { display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 800; min-width: 0; }
.bars { margin-top: 8px; }
.bar-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 13px; }
.bar-row .bl { width: 96px; flex: none; color: var(--ink-soft); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .bt { flex: 1; background: var(--surface-2); border-radius: 999px; height: 14px; overflow: hidden; }
.bar-row .bt > div { height: 100%; background: linear-gradient(90deg, var(--grape), var(--pink)); border-radius: 999px; }
.bar-row .bn { width: 28px; text-align: right; font-weight: 700; }

.match-reason { font-size: 12.5px; color: var(--grape-d); font-weight: 600; margin-top: 5px; line-height: 1.4; }

/* Committees */
.cmte-list { display: flex; flex-direction: column; gap: 6px; }
.cmte { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--surface-2); border-radius: 10px; padding: 8px 12px; font-size: 13.5px; }
.cmte-name { font-weight: 600; color: var(--ink); }
.role-tag { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-soft-ink); white-space: nowrap; flex: none; }
.role-tag.lead-chair { background: var(--warn-soft); color: var(--warn-ink); }
.role-tag.lead-rank { background: var(--dem-soft); color: var(--dem); }

/* Giving / FEC limits */
.give-card { padding: 12px 14px; }
.give-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.give-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.give-lbl { width: 120px; flex: none; font-size: 12.5px; font-weight: 700; color: var(--ink-soft); }
.give-bar { flex: 1; height: 14px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.give-fill { height: 100%; border-radius: 999px; background: var(--mint); }
.give-fill.near { background: var(--gold); }
.give-fill.over { background: var(--rep); }
.give-amt { width: 120px; flex: none; text-align: right; font-size: 12.5px; font-weight: 700; }
.give-amt.over { color: var(--rep); }
.give-warn { background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; font-size: 13px; font-weight: 600; color: var(--warn-ink); line-height: 1.6; }

/* Chat */
.chat-wrap { display: flex; flex-direction: column; height: calc(100dvh - 210px); min-height: 360px; }
.chat-log { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px 12px; }
.bubble { max-width: 86%; padding: 11px 14px; border-radius: 18px; font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.bubble.user { align-self: flex-end; background: var(--grape); color: var(--btn-ink); border-bottom-right-radius: 6px; }
.bubble.assistant { align-self: flex-start; background: var(--card); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow-sm); border-bottom-left-radius: 6px; }
.chat-input { display: flex; gap: 8px; padding-top: 8px; }
.chat-input input { flex: 1; }
.chat-suggest { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.chip-btn { border: 1.5px solid var(--line); background: var(--card); color: var(--grape-d); font-weight: 700; font-size: 12px; border-radius: 999px; padding: 7px 12px; cursor: pointer; }

/* Directory / member rows */
.row-item { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-sm); padding: 12px 14px; cursor: pointer; }
.row-item .ri-main { flex: 1; min-width: 0; }
.row-item .ri-title { font-weight: 700; font-size: 15px; }
.row-item .ri-sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.row-item .ri-go { color: var(--ink-soft); opacity: .6; font-size: 20px; }
.contact-links { display: flex; gap: 10px; margin-top: 6px; align-items: center; flex-wrap: wrap; }
.contact-links a { font-size: 13px; font-weight: 700; text-decoration: none; }
.copy-btn {
  border: none; background: var(--surface-2); color: var(--grape-d); font-size: 11px;
  width: 22px; height: 22px; border-radius: 6px; cursor: pointer; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  margin-left: 6px; vertical-align: middle; flex-shrink: 0;
}
.copy-btn:active { transform: scale(0.88); background: var(--accent-soft); }

/* Drag-and-drop upload overlay */
.drop-overlay {
  position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--grape) 55%, transparent); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); padding: 24px;
}
.drop-inner {
  border: 3px dashed #fff; border-radius: 22px; padding: 34px 40px; text-align: center;
  color: #fff; font-size: 22px; font-weight: 800; line-height: 1.5; background: color-mix(in srgb, var(--grape) 30%, transparent);
}
.drop-inner span { font-size: 13px; font-weight: 600; opacity: .9; }

.toast { position: fixed; left: 50%; bottom: calc(100px + var(--safe-bot)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 999px; font-size: 14px; z-index: 80; box-shadow: var(--shadow); max-width: 90%; text-align: center; }
.toast.ok { background: #16a34a; color: #fff; }
.toast.err { background: #e11d48; color: #fff; }

/* Appearance (theme) settings */
.appearance-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.sched-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 4px; }

@media (min-width: 740px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .row2 { gap: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* Researched identification: a guess has to LOOK like a guess. Dashed border rather than a
   solid one, so it reads as provisional next to the solid party and presence chips. */
.badge.match { border-style: dashed; }
.badge.match.researched { background: var(--amber-bg, #fdf3d8); color: var(--amber-ink, #7a5a12); border-color: currentColor; }
.badge.match.unresolved { background: var(--slate-bg, #eceef2); color: var(--slate-ink, #4a5262); border-color: currentColor; }
.match-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: 8px 0 12px; padding: 10px 12px; border-radius: 10px;
  border: 1px dashed currentColor; font-size: 0.92rem; line-height: 1.45;
}
.match-banner > div { flex: 1 1 260px; min-width: 0; }
.match-banner.researched { background: var(--amber-bg, #fdf3d8); color: var(--amber-ink, #7a5a12); }
.match-banner.unresolved { background: var(--slate-bg, #eceef2); color: var(--slate-ink, #4a5262); }
.match-banner .btn-mini { flex: 0 0 auto; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge.match.researched,
  :root:not([data-theme="light"]) .match-banner.researched { background: #3a2f12; color: #f0d493; }
  :root:not([data-theme="light"]) .badge.match.unresolved,
  :root:not([data-theme="light"]) .match-banner.unresolved { background: #23262e; color: #b8bfcc; }
}
:root[data-theme="dark"] .badge.match.researched,
:root[data-theme="dark"] .match-banner.researched { background: #3a2f12; color: #f0d493; }
:root[data-theme="dark"] .badge.match.unresolved,
:root[data-theme="dark"] .match-banner.unresolved { background: #23262e; color: #b8bfcc; }
/* Research log inside Settings: compact, scrollable, never a wall of text. */
.research-log { margin-top: 6px; font-size: 0.88rem; line-height: 1.5; max-height: 220px; overflow-y: auto; }
.research-log > div { padding: 3px 0; border-bottom: 1px solid var(--line); }
.research-log > div:last-child { border-bottom: none; }

/* Tiny version badge (index.html, filled from version.js). Top-left inside the safe area,
   clear of the L/D/A toggle and Settings on the right. Before sign-in (PIN screen, boot) it
   sits on the paper: ink-soft 5.35:1 light (#f3f3ee), 6.66:1 dark (#12141c). Once the app
   shows, it sits on the header's gradient, where white text falls to about 4.5:1 toward the
   teal end on a narrow phone, so it gets its own small plate in the gradient's deep stop:
   white on #0b5e47 7.76:1 light, #14161f on #b3a6ff 8.43:1 dark. The failure state is a brick
   plate: paper on #c0452f 4.56:1 light, #12141c on #ff6b78 6.67:1 dark. */
.app-version {
  position: fixed; z-index: 100; pointer-events: none;   /* above the drop overlay (90), toast (80), sheets (50) */
  top: var(--safe-top);
  left: calc(var(--safe-left) + 16px);
  font: 500 9px/9px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .2px; color: var(--ink-soft); white-space: nowrap;
}
body:has(#app:not(.hidden)) .app-version {
  top: calc(var(--safe-top) + 2px);
  background: var(--grape-d); color: var(--btn-ink); padding: 1px 4px; border-radius: 3px;
}
.app-version.fail,
body:has(#app:not(.hidden)) .app-version.fail {
  background: var(--rose); color: var(--bg); font-weight: 700; padding: 1px 4px; border-radius: 3px;
}

/* Search (2026-10-02): the "possible matches" divider and the "N more matches elsewhere" note. */
.search-divider { font-size: 12px; font-weight: 800; color: var(--ink-soft); margin: 16px 2px 8px; padding-top: 10px; border-top: 1px dashed var(--line, rgba(0,0,0,.12)); }
.search-hidden { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--ink-soft); margin: 14px 0 4px; }
.empty.slim { min-height: 0; padding: 10px 12px 2px; }
.empty.slim .big { font-size: 26px; margin-bottom: 2px; }
