*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  overflow-x: hidden;
}

:root {
  --radius: 8px;
  --dem: #5b8def;
  --rep: #e05555;
  --ind: #a0a0a0;
  --green: #3fb950;
  --amber: #d29922;
  --red: #f85149;
  --house: #e8823a;
  --senate: #a78bfa;
}

/* Dark theme (default) —  dark */
:root, [data-theme="dark"] {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-hover: #1c2128;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-dim: #388bfd;
  --chip-hover-bg: rgba(255, 255, 255, 0.04);
  --tag-bg: rgba(255, 255, 255, 0.06);
  --subject-bg: rgba(88, 166, 255, 0.1);
  --subject-border: rgba(88, 166, 255, 0.2);
  --focus-ring: rgba(88, 166, 255, 0.15);
  --overlay-bg: rgba(1, 4, 9, 0.8);
  --committee-role-bg: rgba(210, 153, 34, 0.15);
}

/* Light theme —  light */
[data-theme="light"] {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-hover: #f3f4f6;
  --border: #d0d7de;
  --text: #1f2328;
  --text-muted: #656d76;
  --accent: #0969da;
  --accent-dim: #54aeff;
  --chip-hover-bg: rgba(0, 0, 0, 0.04);
  --tag-bg: rgba(0, 0, 0, 0.04);
  --subject-bg: rgba(9, 105, 218, 0.08);
  --subject-border: rgba(9, 105, 218, 0.18);
  --focus-ring: rgba(9, 105, 218, 0.15);
  --overlay-bg: rgba(27, 31, 36, 0.5);
  --committee-role-bg: rgba(154, 103, 0, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  padding: 2rem 2rem 1rem;
  text-align: center;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* Controls */
.controls {
  display: flex;
  gap: 1rem;
  justify-content: center;
  padding: 1rem 2rem 1.5rem;
  flex-wrap: wrap;
}

.select-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.select-group label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

select {
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 2.5rem 0.6rem 0.8rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  min-width: 240px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b90a0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  transition: border-color 0.15s;
}

select:hover:not(:disabled) {
  border-color: var(--accent-dim);
}

select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

select optgroup {
  font-style: normal;
  font-weight: 700;
  color: var(--accent);
  background: var(--surface);
  padding: 0.25rem 0;
}

select optgroup[label="Your Representatives"] {
  color: var(--green);
}

select optgroup option {
  font-weight: 400;
  color: var(--text);
  padding-left: 0.5rem;
}

/* Location button */
.location-group {
  align-self: flex-end;
}

.locate-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.locate-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.locate-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.locate-btn:disabled:hover {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--accent-dim);
}

.locate-status {
  text-align: center;
  padding: 0.5rem 2rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.locate-status.error {
  color: var(--rep);
}

.locate-status.success {
  color: var(--green);
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 3rem;
  color: var(--text-muted);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.hidden {
  display: none !important;
}

/* Main layout */
main {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.5rem;
  padding: 0 2rem 3rem;
  max-width: 1400px;
  margin: 0 auto;
}

/* Role info box */
.role-info-box {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.role-info-box .role-info-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 0.1rem;
  color: var(--accent);
}

.role-info-box strong {
  color: var(--text);
}

/* Info panel */
#info-panel {
  align-self: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Legislator header: photo + text side by side */
.leg-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.leg-photo-wrap {
  flex-shrink: 0;
}

.leg-photo {
  width: 90px;
  height: 90px;
  border-radius: 10px;
  object-fit: cover;
  object-position: top;
  border: 3px solid var(--border);
}

.leg-header-text {
  min-width: 0;
}

#leg-name {
  font-size: 1.3rem;
  font-weight: 700;
}

.info-badges {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-dem { background: var(--dem); color: #fff; }
.badge-rep { background: var(--rep); color: #fff; }
.badge-ind { background: var(--ind); color: #fff; }
.badge-lib { background: #f5a623; color: #000; }
.badge-grn { background: var(--green); color: #000; }
.badge-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.info-detail {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.elected-badge {
  display: inline-block;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.election-years {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* District map */
.district-map {
  width: 100%;
  height: 160px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  margin: 0.5rem 0;
  background: var(--bg);
}

.district-map canvas {
  border-radius: var(--radius);
}

/* State overview district maps */
.state-maps {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem 1.5rem;
  box-sizing: border-box;
}

.state-maps-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  width: 100%;
}

.state-map-panel {
  min-width: 0;
  overflow: hidden;
  width: 100%;
}

.state-map-panel h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text);
  text-align: center;
}

.overview-map {
  width: 100%;
  height: 420px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--bg);
}

.overview-map canvas {
  border-radius: var(--radius);
}

.overview-map .maplibregl-ctrl-top-right {
  top: 4px;
  right: 4px;
}

.overview-map .maplibregl-popup-content {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.8rem;
  line-height: 1.4;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.overview-map .maplibregl-popup-tip {
  border-top-color: var(--surface);
}

.state-maps-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Ballotpedia section */
.bp-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 0.75rem;
  font-size: 0.8rem;
}

.bp-group {
  margin-bottom: 0.6rem;
}

.bp-group:last-of-type {
  margin-bottom: 0.5rem;
}

.bp-group-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--border);
}

.bp-row {
  display: flex;
  justify-content: space-between;
  padding: 0.15rem 0;
  gap: 0.5rem;
}

.bp-key {
  color: var(--text-muted);
  flex-shrink: 0;
}

.bp-val {
  text-align: right;
  color: var(--text);
  font-weight: 500;
}

.bp-link {
  display: block;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding-top: 0.4rem;
  border-top: 1px solid var(--border);
}

.bp-link:hover {
  text-decoration: underline;
}

.bp-contact-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.8rem;
  word-break: break-all;
}

.bp-contact-link:hover {
  text-decoration: underline;
}

/* Contact info */
.leg-contact {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.82rem;
  margin-top: 0.5rem;
}

.contact-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.82rem;
  word-break: break-all;
}

.contact-link:hover {
  text-decoration: underline;
}

.contact-office {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.contact-office-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
}

.contact-phone {
  color: var(--text);
  font-size: 0.82rem;
}

.contact-addr {
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.3;
}

/* Committees */
.committee-list {
  list-style: none;
  font-size: 0.82rem;
}

.committee-list li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  line-height: 1.35;
}

.committee-list li:last-child {
  border-bottom: none;
}

.committee-role {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--amber);
  background: var(--committee-role-bg);
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  margin-left: 0.3rem;
}

.info-section h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* Bill summary */
.bill-summary-stats {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.bill-summary-group-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin: 0 0 0.3rem 0;
  font-weight: 600;
}

.bill-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.bill-summary-stat {
  display: flex;
  flex-direction: column;
}

.bill-summary-stat .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.bill-summary-stat .value {
  font-size: 1.1rem;
  font-weight: 700;
}

.bill-summary-stat[data-type] {
  cursor: pointer;
  border-radius: 6px;
  padding: 0.3rem 0.4rem;
  margin: -0.3rem -0.4rem;
  transition: background 0.15s;
}
.bill-summary-stat[data-type]:hover {
  background: var(--surface-hover, rgba(128,128,128,0.1));
}
.bill-summary-stat[data-type].active {
  background: var(--surface-hover, rgba(128,128,128,0.15));
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.bill-summary-stat .value.house-color { color: var(--house); }
.bill-summary-stat .value.senate-color { color: var(--senate); }
.bill-summary-stat .value.enacted-color { color: var(--green); }
.bill-summary-stat .value.passed-color { color: var(--accent); }
.bill-summary-stat .value.active-color { color: var(--amber); }
.bill-summary-stat .value.dead-color { color: var(--red); }

.collapsible-bills {
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.collapsible-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  background: var(--surface-hover);
  border: none;
  padding: 0.5rem 0.6rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}

.collapsible-toggle:hover {
  background: var(--chip-hover-bg);
}

.collapsible-arrow {
  font-size: 0.65rem;
  transition: transform 0.2s;
}

.collapsible-toggle[aria-expanded="false"] .collapsible-arrow {
  transform: rotate(-90deg);
}

.collapsible-content {
  overflow: hidden;
}

.collapsible-content.collapsed {
  display: none;
}

.bill-passed-list {
  list-style: none;
}

.bill-passed-list li {
  padding: 0.45rem 0.6rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  line-height: 1.35;
}

.bill-passed-list li:last-child {
  border-bottom: none;
}

.bill-passed-list .bill-num {
  font-weight: 700;
  font-size: 0.75rem;
  margin-right: 0.3rem;
}

.bill-passed-list .bill-status-tag {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  width: fit-content;
  margin-top: 0.2rem;
}

.bill-passed-link {
  color: inherit;
  text-decoration: none;
  display: block;
}

.bill-passed-link:hover {
  color: var(--accent);
}

.bill-status-tag.tag-enacted {
  background: var(--green);
  color: #fff;
}

.bill-status-tag.tag-passed {
  background: var(--accent);
  color: #fff;
}

.muted {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}


/* Bill activity chart */
.activity-bars {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.activity-row-wrap {
  display: flex;
  flex-direction: column;
}

.activity-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 4px;
  margin: -2px -4px;
}

.activity-row:hover {
  background: var(--border);
}

.activity-year {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 2.5rem;
  text-align: right;
}

.activity-track {
  flex: 1;
  height: 10px;
  background: var(--border);
  border-radius: 5px;
  overflow: hidden;
}

.activity-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.3s ease;
  display: flex;
  overflow: hidden;
}

.activity-segment {
  height: 100%;
  min-width: 1px;
}

.activity-count {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text);
  min-width: 1.5rem;
}

.activity-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.75rem;
  padding: 0.35rem 0 0.25rem 3.5rem;
}

.breakdown-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.breakdown-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.breakdown-topic {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.breakdown-pct {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text);
}

/* Charts */
.chart-container {
  margin-bottom: 1rem;
}

.chart-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.bar-chart {
  display: block;
  max-width: 100%;
}

/* Timeline filters */
.timeline-filters {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.filter-input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  width: 100%;
  transition: border-color 0.15s;
}

.filter-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.filter-input::placeholder {
  color: var(--text-muted);
}

.filter-buttons {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.filter-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover {
  border-color: var(--accent-dim);
  color: var(--text);
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.filter-btn[data-filter="enacted"].active {
  background: var(--green);
  border-color: var(--green);
}

.filter-btn[data-filter="passed"].active {
  background: var(--accent);
  border-color: var(--accent);
}

.filter-btn[data-filter="active"].active {
  background: var(--amber);
  border-color: var(--amber);
  color: #000;
}

.filter-btn[data-filter="dead"].active {
  background: var(--rep);
  border-color: var(--rep);
}

/* Topic tags */
.topic-filter {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.topic-chip {
  background: transparent;
  border: 1px solid var(--chip-color, var(--border));
  color: var(--chip-color, var(--text-muted));
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.topic-chip:hover {
  background: var(--chip-hover-bg);
}

.topic-chip.active {
  background: var(--chip-color, var(--accent));
  color: #fff;
  border-color: var(--chip-color, var(--accent));
}

.chip-count {
  opacity: 0.7;
  font-size: 0.65rem;
}

.topic-tag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 3px;
  background: var(--tag-bg);
  color: var(--tag-color, var(--text-muted));
  border: 1px solid var(--tag-color, var(--border));
  white-space: nowrap;
}

#timeline-panel {
  min-width: 0;
}

/* Timeline panel */
.timeline-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.timeline-header h2 {
  font-size: 1.2rem;
}

.csv-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  margin-left: auto;
}

.csv-download-btn:hover {
  border-color: var(--accent-dim);
  color: var(--text);
}

/* Timeline */
#timeline-container {
  position: relative;
  padding-left: 2rem;
}

#timeline-container::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-year {
  position: relative;
  margin-bottom: 0.5rem;
}

.timeline-year-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 0.75rem;
  margin-left: -2rem;
  padding-left: 2rem;
  position: relative;
}

.timeline-year-label::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid var(--bg);
}

.timeline-item {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}

.timeline-item:hover {
  border-color: var(--accent-dim);
  background: var(--surface-hover);
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -2rem;
  top: 1.2rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg);
  transform: translateX(4px);
}

.timeline-item.status-enacted::before {
  border-color: var(--green);
  background: var(--green);
}

.timeline-item.status-passed::before {
  border-color: var(--accent);
  background: var(--accent);
}

.timeline-item.status-active::before {
  border-color: var(--amber);
  background: var(--amber);
}

.timeline-item.status-dead::before {
  border-color: var(--rep);
  background: var(--rep);
}

.bill-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}

.bill-header .bill-status-tag {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  margin-right: 0.3rem;
  flex-shrink: 0;
}

.bill-header-right {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.bill-header-right .bill-date {
  margin-left: 0.35rem;
}

.bill-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.3rem;
}

.bill-number {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent);
  white-space: nowrap;
}

.bill-number.bill-house {
  color: var(--house);
}

.bill-number.bill-senate {
  color: var(--senate);
}

.bill-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.bill-title {
  font-size: 0.9rem;
  line-height: 1.4;
  margin-bottom: 0.4rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.bill-action {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.bill-action strong {
  color: var(--text);
  font-weight: 600;
}

/* Bill detail modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  max-width: 700px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal h2 {
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
}

.modal .bill-number {
  font-size: 1rem;
  margin-bottom: 1rem;
  display: inline-block;
}

.modal-top-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.modal-close {
  float: right;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
}

.modal-section-title {
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.modal-subjects {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.subject-tag {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--subject-bg);
  color: var(--accent);
  border: 1px solid var(--subject-border);
}


.history-list {
  list-style: none;
  margin-top: 0.5rem;
}

.history-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  display: flex;
  gap: 0.75rem;
}

.history-list .hist-date {
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 6rem;
}

.party-dem { color: var(--dem); }
.party-rep { color: var(--rep); }
.party-ind { color: var(--ind); }

.modal-links {
  margin-top: 1rem;
  display: flex;
  gap: 0.75rem;
}

.modal-links a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
}

.modal-links a:hover {
  text-decoration: underline;
}

/* Theme toggle */
.theme-toggle {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  padding: 0;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }

[data-theme="light"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* Site Navigation */
.site-nav {
  display: flex;
  gap: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
}

.nav-link {
  padding: 0.65rem 1rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.nav-link:hover {
  color: var(--text);
}

.nav-link[aria-current="page"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Homepage */
.homepage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
}

.homepage-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.homepage-header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.homepage-header .subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  margin-top: 0.5rem;
}

.homepage-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  max-width: 700px;
  width: 100%;
}

.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
}

.card-icon {
  color: var(--accent);
  margin-bottom: 1rem;
}

.card h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.homepage-about {
  max-width: 700px;
  width: 100%;
  margin-top: 2.5rem;
  text-align: left;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.7;
}

.homepage-about h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
  margin-top: 1.25rem;
}

.homepage-about h2:first-child {
  margin-top: 0;
}

.homepage-about p {
  margin-bottom: 0;
}

/* Footer */
.site-footer {
  margin-top: auto;
  text-align: center;
  padding: 2rem 1rem 1rem;
  font-size: 0.8rem;
  background: var(--surface);
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
  .homepage-cards {
    grid-template-columns: 1fr;
  }

  .homepage {
    padding: 2rem 1rem;
  }

  .homepage-header h1 {
    font-size: 1.5rem;
  }

  header {
    padding: 1.25rem 1rem 0.75rem;
  }

  header h1 {
    font-size: 1.4rem;
  }

  main {
    grid-template-columns: 1fr;
    padding: 0 0.75rem 2rem;
    gap: 1rem;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
    padding: 0.75rem 1rem 1rem;
    gap: 0.75rem;
  }

  select {
    min-width: 100%;
  }

  .location-group {
    align-self: stretch;
  }

  .locate-btn {
    width: 100%;
    justify-content: center;
  }

  /* Info panel */
  #info-panel {
    position: static;
    max-height: none;
    padding: 1rem;
  }

  /* Timeline */
  .timeline-header h2 {
    font-size: 1rem;
  }

  #timeline-container {
    padding-left: 1.5rem;
  }

  #timeline-container::before {
    left: 5px;
  }

  .timeline-year-label {
    margin-left: -1.5rem;
    padding-left: 1.5rem;
  }

  .timeline-year-label::before {
    width: 10px;
    height: 10px;
    left: 1px;
  }

  .timeline-item {
    padding: 0.75rem;
  }

  .timeline-item::before {
    left: -1.5rem;
    width: 10px;
    height: 10px;
    transform: translateX(3px);
  }

  .bill-header {
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .bill-title {
    font-size: 0.85rem;
  }

  /* Activity chart */
  .activity-breakdown {
    padding-left: 2.5rem;
  }

  /* History list in modal */
  .history-list li {
    flex-direction: column;
    gap: 0.15rem;
  }

  .history-list .hist-date {
    min-width: unset;
  }

  /* Modal */
  .modal {
    padding: 1.25rem;
    width: 95%;
    max-height: 85vh;
    border-radius: var(--radius);
  }

  .modal h2 {
    font-size: 1rem;
    padding-right: 2rem;
  }

  .modal-links {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* Filter area */
  .filter-buttons {
    gap: 0.3rem;
  }

  .filter-btn {
    padding: 0.35rem 0.65rem;
    font-size: 0.72rem;
  }

  .topic-chip {
    font-size: 0.68rem;
    padding: 0.2rem 0.5rem;
  }

  /* District map */
  .district-map {
    height: 140px;
  }

  /* Overview maps responsive */
  .state-maps-grid {
    grid-template-columns: 1fr;
  }

  .overview-map {
    height: 320px;
  }

  .state-maps {
    padding: 0 1rem 1rem;
  }

  /* Theme toggle - stay visible */
  .theme-toggle {
    bottom: 0.75rem;
    right: 0.75rem;
  }

  /* Role info box */
  .role-info-box {
    font-size: 0.8rem;
    padding: 0.75rem 1rem;
  }

  /* Bill summary stats */
  .bill-summary-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
  }

  /* Footer */
  .site-footer {
    padding: 1.5rem 0.75rem 0.75rem;
  }
}

/* Small phones */
@media (max-width: 380px) {
  header h1 {
    font-size: 1.2rem;
  }

  main {
    padding: 0 0.5rem 1.5rem;
  }

  .controls {
    padding: 0.5rem 0.75rem 0.75rem;
  }

  .timeline-item {
    padding: 0.6rem;
  }

  .bill-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .bill-header-right {
    width: 100%;
    justify-content: space-between;
  }

  .modal {
    width: 100%;
    border-radius: 0;
    max-height: 100vh;
  }
}
