.statutes-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 32px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.statutes-controls {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.search-row {
    display: flex;
    gap: 8px;
}

#search-input {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-primary);
    padding: 10px 12px;
    font-size: 0.95rem;
}

#search-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

#search-btn {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-primary);
    padding: 10px 14px;
    font-size: 0.95rem;
    cursor: pointer;
}

.controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.type-toggle {
    display: inline-flex;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
}

.type-btn {
    border: 0;
    border-right: 1px solid var(--border-color);
    background: var(--surface);
    color: var(--text-secondary);
    padding: 8px 12px;
    font-size: 0.9rem;
    cursor: pointer;
}

.type-btn:last-child {
    border-right: 0;
}

.type-btn.active {
    background: var(--background);
    color: var(--text-primary);
    font-weight: 600;
}

.sort-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

#sort-select {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-primary);
    padding: 8px 10px;
    font-size: 0.9rem;
}

.stats-summary,
.results-summary {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.toc-tabs {
    display: inline-flex;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    width: fit-content;
    max-width: 100%;
}

.toc-tab {
    border: 0;
    border-right: 1px solid var(--border-color);
    background: var(--surface);
    color: var(--text-secondary);
    padding: 8px 12px;
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
}

.toc-tab:last-child {
    border-right: 0;
}

.toc-tab.active {
    background: var(--background);
    color: var(--text-primary);
    font-weight: 600;
}

.toc-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toc-group {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.toc-group + .toc-group {
    margin-top: 8px;
}

.toc-group-details > summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    background: #f8fafc;
}

.toc-group-details > summary::-webkit-details-marker {
    display: none;
}

.toc-group-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
}

.toc-group-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.toc-group-body {
    padding: 8px 10px;
}

.toc-subgroup {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 8px;
    overflow: hidden;
}

.toc-subgroup:last-child {
    margin-bottom: 0;
}

.toc-subgroup-details > summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 8px 10px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
}

.toc-subgroup-details > summary::-webkit-details-marker {
    display: none;
}

.toc-subgroup-title {
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.toc-subgroup-count {
    font-size: 0.76rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.toc-entry-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.toc-entry-item {
    border-top: 1px solid var(--border-color);
}

.toc-entry-item:first-child {
    border-top: 0;
}

.toc-entry-link {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: baseline;
    text-decoration: none;
    color: inherit;
    padding: 8px 10px;
}

.toc-entry-link:hover {
    background: var(--background);
}

.toc-entry-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.toc-entry-citation {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.88rem;
}

.toc-entry-secondary-citation {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 1px;
}

.toc-entry-title {
    margin-top: 2px;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.toc-entry-meta {
    color: var(--text-muted);
    font-size: 0.75rem;
    white-space: nowrap;
}

.results-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.loading,
.empty-state,
.error-state {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 18px;
    color: var(--text-secondary);
}

.result-card-link {
    color: inherit;
    text-decoration: none;
    display: block;
}

.result-card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 14px;
    transition: border-color 0.15s ease;
}

.result-card-link:focus-visible {
    outline: none;
}

.result-card-link:focus-visible .result-card,
.result-card-link:hover .result-card {
    border-color: var(--accent-color);
}

.result-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.result-citation {
    margin: 0;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
}

.result-type {
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 3px 8px;
    white-space: nowrap;
}

.result-title {
    margin: 6px 0 0;
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.result-excerpt {
    margin: 8px 0 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

.result-meta {
    margin: 8px 0 0;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.pagination button {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-primary);
    padding: 8px 12px;
    cursor: pointer;
}

.pagination button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#page-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .search-row {
        flex-direction: column;
    }

    #search-btn {
        width: 100%;
    }

    .controls-row {
        flex-direction: column;
        align-items: stretch;
    }

    .type-toggle {
        width: 100%;
    }

    .type-btn {
        flex: 1;
        text-align: center;
    }

    .sort-wrap {
        justify-content: space-between;
    }

    #sort-select {
        flex: 1;
    }

    .toc-tabs {
        width: 100%;
    }

    .toc-tab {
        flex: 1;
        text-align: center;
    }

    .result-head {
        flex-direction: column;
        gap: 8px;
    }
}
