:root {
    --bg: oklch(0.97 0.006 248);
    --surface: oklch(0.995 0.003 248);
    --ink: oklch(0.28 0.028 248);
    --ink-muted: oklch(0.42 0.02 248);
    --line: oklch(0.90 0.008 248);
    --accent: oklch(0.44 0.055 242);
    --accent-soft: oklch(0.955 0.016 242);
    --yea: oklch(0.40 0.055 155);
    --yea-bg: oklch(0.965 0.018 155);
    --nay: oklch(0.42 0.055 22);
    --nay-bg: oklch(0.965 0.016 22);
    --absent: oklch(0.45 0.04 85);
    --absent-bg: oklch(0.965 0.016 85);
    --party-d: oklch(0.42 0.13 250);
    --party-d-bg: oklch(0.93 0.045 250);
    --party-r: oklch(0.46 0.15 25);
    --party-r-bg: oklch(0.93 0.05 25);
    --radius: 4px;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --z-sticky: 10;
    --z-sticky-row: 5;
    --z-sticky-col: 15;
    --z-sticky-corner: 20;
    --z-dropdown: 30;
}

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

html {
    color-scheme: light;
}

body {
    margin: 0;
    padding: 1.25rem 1.5rem 2.5rem;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.5;
    background: var(--bg);
    color: var(--ink);
}

.container {
    margin: 0 auto;
}

.page-header {
    margin-bottom: 1.25rem;
}

h1 {
    margin: 0 0 0.25rem;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    text-wrap: balance;
    color: var(--ink);
}

.subtitle {
    margin: 0;
    max-width: 65ch;
    color: var(--ink-muted);
    text-wrap: pretty;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    align-items: center;
    padding: 0 0 1rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--line);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control-group label,
.control-group > span {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--ink-muted);
}

select,
input[type="text"],
.btn,
.seg button {
    font: inherit;
    font-size: 0.875rem;
    color: var(--ink);
    border-radius: var(--radius);
}

select,
input[type="text"] {
    padding: 0.45rem 0.7rem;
    background: var(--surface);
    border: 1px solid var(--line);
}

select:hover,
input[type="text"]:hover {
    border-color: oklch(0.82 0.012 248);
}

select:focus-visible,
input[type="text"]:focus-visible,
.btn:focus-visible,
.seg button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.seg button:focus-visible {
    outline-offset: -2px;
    z-index: 1;
}

input[type="text"] {
    min-width: 14rem;
}

input[type="text"]::placeholder {
    color: var(--ink-muted);
    opacity: 1;
}

.seg {
    display: flex;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
}

.seg button {
    margin: 0;
    padding: 0.45rem 0.8rem;
    border: none;
    border-right: 1px solid var(--line);
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    transition: background 180ms var(--ease), color 180ms var(--ease);
}

.seg button:last-child {
    border-right: none;
}

.seg button:hover {
    background: var(--accent-soft);
}

.seg button.active {
    background: var(--ink);
    color: var(--surface);
}

.btn {
    padding: 0.45rem 0.8rem;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
    cursor: pointer;
    font-weight: 500;
    transition: background 180ms var(--ease), border-color 180ms var(--ease);
}

.btn:hover {
    background: var(--accent-soft);
    border-color: oklch(0.82 0.012 248);
}

.btn svg {
    width: 1rem;
    height: 1rem;
}

.toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    margin: 0 0 0.75rem;
    color: var(--ink-muted);
    font-size: 0.8125rem;
}

.stats strong {
    font-weight: 600;
    color: var(--ink);
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    margin: 0 0 0.75rem;
    font-size: 0.8125rem;
    color: var(--ink-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.legend-swatch {
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 2px;
    border: 1px solid var(--line);
}

.legend-swatch.yea { background: var(--yea-bg); border-color: oklch(0.88 0.03 155); }
.legend-swatch.nay { background: var(--nay-bg); border-color: oklch(0.88 0.03 22); }
.legend-swatch.absent { background: var(--absent-bg); border-color: oklch(0.88 0.03 85); }
.legend-swatch.none { background: var(--bg); }

.legend-party {
    font-weight: 600;
    font-size: 0.75rem;
}

.legend-party.party-d { color: var(--party-d); }
.legend-party.party-r { color: var(--party-r); }

.loading {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--ink-muted);
}

a {
    color: var(--accent);
    text-underline-offset: 0.12em;
}

a:hover {
    text-decoration: underline;
}

a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.source-link {
    color: inherit;
    text-decoration: none;
}

.source-link:hover,
.source-link:focus-visible {
    text-decoration: underline;
}

.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;
}

.compare-pickers {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    margin: 0 0 1rem;
}

.picker {
    flex: 1 1 16rem;
    max-width: 24rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.picker label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--ink-muted);
}

.combo {
    position: relative;
}

.combo input {
    width: 100%;
    padding-right: 2.4rem;
}

.combo-clear {
    position: absolute;
    right: 0.15rem;
    top: 50%;
    transform: translateY(-50%);
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--ink-muted);
    cursor: pointer;
    font-size: 1.15rem;
    line-height: 1;
}

.combo-clear:hover {
    color: var(--ink);
}

.combo-clear:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.combo-clear[hidden] {
    display: none;
}

.combo-list {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 2px);
    z-index: var(--z-dropdown);
    margin: 0;
    padding: 0.2rem 0;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    max-height: 16rem;
    overflow: auto;
}

.combo-list[hidden] {
    display: none;
}

.combo-option {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0.65rem 0.7rem;
    border: none;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: 0.875rem;
    text-align: left;
    cursor: pointer;
}

.combo-option:hover,
.combo-option[aria-selected="true"] {
    background: var(--accent-soft);
}

.combo-option.party-d { color: var(--party-d); }
.combo-option.party-r { color: var(--party-r); }

.combo-empty {
    padding: 0.55rem 0.7rem;
    color: var(--ink-muted);
    font-size: 0.875rem;
}

.empty-compare {
    padding: 2.5rem 1.15rem;
    color: var(--ink-muted);
    max-width: 42rem;
}

.empty-compare p {
    margin: 0 0 0.75rem;
    text-wrap: pretty;
}

.empty-compare p:last-child {
    margin-bottom: 0;
}

.example-btn {
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    color: var(--accent);
    cursor: pointer;
}

.example-btn:hover {
    text-decoration: underline;
}

.example-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.compare-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: auto;
    max-height: 80vh;
}

.compare-table {
    width: 100%;
    min-width: 36rem;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

.compare-table th,
.compare-table td {
    padding: 0.7rem 0.85rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.compare-table thead th {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    background: var(--bg);
    font-weight: 600;
    font-size: 0.875rem;
}

.compare-table .compare-bill {
    position: sticky;
    left: 0;
    z-index: var(--z-sticky-row);
    background: var(--surface);
    width: 46%;
    min-width: 12rem;
}

.compare-table thead .compare-bill {
    z-index: var(--z-sticky-corner);
    background: var(--bg);
}

.compare-bill .bill-id {
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
}

.compare-bill .bill-id:hover {
    text-decoration: underline;
}

.compare-bill .bill-meta {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.8125rem;
    color: var(--ink-muted);
}

.compare-bill .bill-desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 0.25rem;
    max-width: 62ch;
    font-size: 0.8125rem;
    color: var(--ink);
    text-wrap: pretty;
}

.compare-vote {
    width: 27%;
    min-width: 6.5rem;
    text-align: center;
    font-weight: 500;
    white-space: nowrap;
}

.compare-table thead .compare-vote {
    white-space: normal;
}

.compare-table .source-link.party-d { color: var(--party-d); }
.compare-table .source-link.party-r { color: var(--party-r); }

.compare-table tfoot th,
.compare-table tfoot td {
    background: var(--bg);
    border-bottom: none;
    font-weight: 600;
}

.compare-table tfoot .absence-detail {
    display: block;
    margin-top: 0.15rem;
    font-weight: 400;
    font-size: 0.8125rem;
    color: var(--ink-muted);
}

tr.differ .compare-bill {
    background: var(--accent-soft);
}

.compare-table .vote-yea { background: var(--yea-bg); color: var(--yea); }
.compare-table .vote-nay { background: var(--nay-bg); color: var(--nay); }
.compare-table .vote-absent { background: var(--absent-bg); color: var(--absent); }
.compare-table .vote-none { color: var(--ink-muted); font-weight: 400; }

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
