:root {
  --ink: #1d1d1b;
  --ink-2: #4a4a45;
  --muted: #66635c;
  --line: #cfcac0;
  --bg: #f1eee6;
  --card: #ffffff;
  --accent: #b4372a;
  --accent-ink: #ffffff;
  --sun: #f2f0ea;
  --warn-bg: #fff4dc;
  --warn-ink: #7a5300;
  --upcoming: #5b6a2c;
  --vacant: #a23b3b;
  --radius: 2px;
  --shadow: 0 0 0 1px #1d1d1b;
  --panel-w: 400px;
  --top-h: 52px;
  --foot-h: 0px;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
a { color: #8f2a20; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }

/* Top bar */
.topbar {
  height: var(--top-h); display: flex; align-items: center; gap: 20px;
  padding: 0 16px; background: var(--ink); color: #fff; position: relative; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; letter-spacing: .2px; }
.modes { display: flex; gap: 4px; background: rgba(255,255,255,.08); padding: 4px; border-radius: 2px; }
.modes button {
  border: 0; background: transparent; color: #d8d4c8; padding: 6px 14px; border-radius: 2px;
  font: inherit; font-size: 14px; cursor: pointer;
}
.modes button[aria-pressed="true"] { background: var(--sun); color: var(--ink); font-weight: 600; }

/* Stage */
.stage { position: absolute; top: var(--top-h); bottom: var(--foot-h); left: 0; right: 0; }
#map { position: absolute; inset: 0; right: var(--panel-w); }

.search-card {
  position: absolute; top: 14px; left: 14px; width: min(420px, calc(100% - var(--panel-w) - 28px));
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; z-index: 3;
}
.search-card form { display: flex; gap: 8px; }
.search-card input, .search-card select {
  flex: 1; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 2px; min-width: 0;
}
.search-card select { width: 100%; margin-top: 6px; }
.search-card button {
  border: 0; background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600;
  padding: 0 16px; border-radius: 2px; cursor: pointer;
}
.search-card button:disabled { opacity: .6; cursor: progress; }
.hint { margin: 8px 2px 0; font-size: 13px; color: var(--muted); }
#browse-controls label { font-size: 13px; font-weight: 600; }

.layers-card {
  position: absolute; left: 14px; bottom: 14px; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 10px 12px; z-index: 3; max-height: 60%; overflow: auto; font-size: 13px; min-width: 230px;
}
.layers-toggle { border: 0; background: none; font: inherit; font-weight: 700; color: var(--ink); padding: 0; cursor: pointer; }
.layers-toggle::after { content: " ▾"; }
.layers-toggle[aria-expanded="false"]::after { content: " ▸"; }
#layer-list { list-style: none; margin: 8px 0 0; padding: 0; }
#layer-list li { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
#layer-list label { display: flex; align-items: center; gap: 8px; cursor: pointer; flex: 1; }
.swatch { width: 14px; height: 14px; border-radius: 2px; border: 2px solid; flex: none; }
.tag-upcoming { font-size: 11px; color: var(--upcoming); }
.switch { display: flex; align-items: center; gap: 6px; margin-top: 8px; color: var(--ink-2); }

/* Panel */
.panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: var(--panel-w); background: var(--card);
  border-left: 1px solid var(--line); overflow-y: auto; padding: 18px 18px 28px; z-index: 4;
}
.panel h1 { font-size: 22px; line-height: 1.25; margin: 4px 0 10px; }
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 0 8px; }
.panel p { line-height: 1.5; }
.loc { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
.loc small { display: block; font-weight: 400; color: var(--muted); margin-top: 2px; }
.notice { background: var(--warn-bg); color: var(--warn-ink); padding: 10px 12px; border-radius: 2px; font-size: 14px; margin: 10px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 9px; border-radius: 2px;
  background: var(--bg); border: 1px solid var(--line); cursor: default;
}
.chip i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

.rep {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px;
}
.rep.upcoming { border-style: dashed; border-color: #a9b27a; background: #f6f7ec; }
.avatar {
  width: 48px; height: 48px; border-radius: 2px; background: #e6e1d4; color: var(--ink-2); font-weight: 700;
  display: grid; place-items: center; overflow: hidden; font-size: 16px;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.rep .office { font-size: 12px; color: var(--muted); }
.rep .name { font-size: 16px; font-weight: 700; margin: 2px 0; }
.rep .party { font-weight: 400; color: var(--muted); font-size: 13px; }
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 2px; margin-left: 4px; vertical-align: 1px; }
.pill.upcoming { background: #e8ecd0; color: var(--upcoming); }
.pill.vacant { background: #f3dcd6; color: var(--vacant); }
.rep ul { list-style: none; padding: 0; margin: 6px 0 0; font-size: 13px; line-height: 1.6; }
.rep .note { font-size: 13px; color: var(--ink-2); margin: 6px 0 0; }
.rep .srcs { font-size: 12px; color: var(--muted); margin-top: 6px; }
.rep .srcs a { color: var(--muted); }
.district-link { font-size: 12px; }

.tooltip {
  position: absolute; pointer-events: none; z-index: 6; background: var(--ink); color: #fff; font-size: 12px;
  padding: 6px 9px; border-radius: 2px; max-width: 280px; line-height: 1.45; box-shadow: var(--shadow);
}

.about-btn {
  margin-left: auto; border: 1px solid rgba(255,255,255,.3); background: transparent; color: #fff;
  font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 2px; cursor: pointer;
}
.about-btn:hover { background: rgba(255,255,255,.1); }
dialog.about {
  border: 0; border-radius: var(--radius); box-shadow: var(--shadow); max-width: 640px; width: calc(100% - 32px);
  max-height: 85vh; padding: 20px 24px; color: var(--ink); line-height: 1.5; font-size: 14px;
}
dialog.about::backdrop { background: rgba(29, 29, 27, .5); }
dialog.about h2 { margin-top: 0; }
dialog.about h3 { font-size: 15px; margin: 18px 0 6px; }
dialog.about .close { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 24px; cursor: pointer; color: var(--muted); }
.src-list { padding-left: 18px; }
.src-list li { margin-bottom: 6px; }

.maplibregl-ctrl-attrib { font-size: 11px; }

/* Phone: panel becomes a bottom sheet */
@media (max-width: 760px) {
  :root { --panel-w: 0px; --foot-h: auto; }
  .modes button { padding: 6px 10px; font-size: 13px; }
  .brand span { display: none; }
  #map { right: 0; bottom: 45vh; bottom: 45dvh; }
  .search-card { width: calc(100% - 28px); padding: 8px 10px; top: 8px; left: 14px; }
  .search-card .instruction { margin: 0 0 6px; font-size: 13px; }
  /* After a lookup the box keeps just the address field, so it covers less of the map. */
  body.has-result .search-card .instruction { display: none; }
  /* Zoom and locate buttons sit bottom right, clear of the search box. */
  .maplibregl-ctrl-top-right { top: auto; bottom: 40px; }
  .layers-card { bottom: calc(45vh + 10px); bottom: calc(45dvh + 10px); max-height: 30vh; min-width: 0; }
  .panel { top: auto; height: 45vh; height: 45dvh; width: 100%; border-left: 0; border-top: 1px solid var(--line); }
  .site-footer { position: static; white-space: normal; padding: 8px 16px; }
  .stage { bottom: 0; }
}

/* Feedback: missing info, suggest dialog, admin page */
.rep .missing { color: var(--muted); }
.rep .missing a, .report-link a { color: var(--ink-2); }
.report-link { font-size: 12px; margin: 4px 0 0; }
dialog.fb { max-width: 460px; }
.fb-row { display: block; font-size: 13px; font-weight: 600; margin: 0 0 12px; }
.fb-row[hidden], .fb-hp { display: none; }
.fb-row input, .fb-row textarea {
  display: block; width: 100%; margin-top: 4px; font: inherit; font-weight: 400; font-size: 14px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 2px; color: var(--ink);
}
.fb-row textarea { resize: vertical; }
.fb-send {
  font: inherit; font-weight: 600; border: 0; border-radius: 2px; padding: 8px 16px;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
.fb-send:disabled { opacity: .6; cursor: progress; }
.fb-msg { font-size: 13px; color: var(--warn-ink); min-height: 1em; margin: 8px 0 0; }

body.admin { height: auto; }
.admin-main { max-width: 860px; margin: 0 auto; padding: 20px 16px 60px; }
.admin-login { max-width: 320px; margin: 40px auto; display: grid; gap: 8px; }
.admin-login input, .admin-bar select, .admin-card select, .admin-card textarea {
  font: inherit; font-size: 14px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 2px; background: var(--card); color: var(--ink);
}
.admin-login button, .admin-card .save {
  font: inherit; border: 0; border-radius: 2px; padding: 7px 14px; background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
.admin-msg { color: var(--vacant); font-size: 14px; min-height: 1em; }
.admin-bar { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; font-size: 14px; margin-bottom: 8px; }
.admin-card { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; font-size: 14px; }
.admin-card.status-fixed, .admin-card.status-wontfix { border-left-color: var(--line); opacity: .8; }
.admin-card.status-spam { border-left-color: var(--vacant); opacity: .6; }
.admin-card.status-triaged { border-left-color: var(--sun); }
.admin-card p { margin: 6px 0; overflow-wrap: anywhere; }
.admin-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.admin-head .pill { background: var(--bg); color: var(--ink-2); }
.admin-head select { margin-left: auto; }
.admin-subject { font-weight: 600; margin-top: 6px; }
.admin-text { white-space: pre-wrap; }
.admin-card textarea { display: block; width: 100%; margin: 4px 0 6px; }
.small { font-size: 12px; }

/* Rep card: no picture column; collapsible details */
.rep .party { display: block; font-size: 13px; color: var(--ink-2); margin: 0 0 2px; font-weight: 400; }
.rep .official { margin: 6px 0 0; font-size: 14px; font-weight: 700; }
.rep details { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 6px; }
.rep summary { cursor: pointer; font-size: 13px; font-weight: 700; color: var(--ink); }
.rep details ul { margin: 6px 0 2px; }
.rep details a { overflow-wrap: anywhere; }
.rep .name a.person-link { color: var(--ink); text-decoration-thickness: 1px; }
.rep .news-btn { display: block; margin-top: 8px; padding: 7px 10px; border: 1px solid var(--ink); color: var(--ink); background: var(--card); font-size: 13px; font-weight: 700; text-decoration: none; }
.rep .news-btn:hover { background: var(--ink); color: #fff; }
.panel .jump { display: block; margin: 8px 0; font-size: 13px; font-weight: 700; }
.panel .jump select { display: block; width: 100%; margin-top: 4px; font: inherit; padding: 8px; border: 1px solid var(--line); background: var(--card); }
.modes button:focus-visible, .rep summary:focus-visible, .rep a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pill.unofficial { background: #f4e7c4; color: #6b4a00; }

/* Recent news row: styled like Contact info / Additional info */
.rep .row-btn {
  display: flex; justify-content: space-between; align-items: center; width: 100%; margin-top: 8px;
  border: 0; border-top: 1px solid var(--line); background: transparent; padding: 6px 0 0;
  font: inherit; font-size: 13px; font-weight: 700; color: var(--ink); cursor: pointer; text-align: left;
}
.rep .row-btn:hover span:first-child { text-decoration: underline; }
.rep .row-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rep.xp-source { opacity: .55; }

/* Expanded card */
.xp-back { position: fixed; inset: 0; background: rgba(29, 29, 27, .28); z-index: 20; }
.xp-box {
  position: fixed; z-index: 21; background: var(--card); border: 2px solid var(--ink);
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 6px 6px 0 rgba(29, 29, 27, .25);
}
.xp-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.xp-head h2 { margin: 2px 0 0; font-size: 24px; }
.xp-office { font-size: 12px; color: var(--muted); }
.xp-party { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.xp-close { font: inherit; font-size: 13px; font-weight: 700; border: 1px solid var(--ink); background: var(--card); color: var(--ink); padding: 7px 12px; cursor: pointer; white-space: nowrap; }
.xp-close:hover { background: var(--ink); color: #fff; }
.xp-body { padding: 4px 18px 18px; overflow: auto; flex: 1; }
.xp-body h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.xp-more { font-size: 13px; margin-top: 16px; }
.ai-btn { font: inherit; font-weight: 700; border: 0; background: var(--accent); color: #fff; padding: 9px 16px; cursor: pointer; }
.ai-btn:disabled { opacity: .5; cursor: default; }
.ai-box { border: 1px solid var(--ink); padding: 12px 14px; margin: 12px 0; background: var(--card); }
.ai-box .tag { display: inline-block; font-size: 11px; font-weight: 700; background: var(--ink); color: #fff; padding: 2px 6px; margin-bottom: 6px; }
.ai-box p { margin: 6px 0; line-height: 1.5; white-space: pre-wrap; }
.ai-box .meta { font-size: 12px; color: var(--muted); }
.heads { list-style: none; padding: 0; margin: 12px 0 0; }
.heads li { padding: 9px 0; border-bottom: 1px solid var(--line); }
.heads .n { color: var(--muted); font-size: 12px; margin-right: 6px; }
.heads a { font-weight: 700; }
.heads .src { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.heads .top { display: inline-block; margin-left: 6px; padding: 0 5px; border: 1px solid var(--line); color: var(--ink); font-size: 11px; }
.xp-body .note { font-size: 12px; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .xp-back, .xp-box { animation: none; } }
