:root {
    --bg: #fbfbfa;
    --panel: #ffffff;
    --panel-2: #f6f6f4;
    --ink: #171717;
    --muted: #62676f;
    --soft: #8c9299;
    --line: #e8e7e3;
    --line-strong: #d7d6d1;
    --brand: #c91f26;
    --brand-dark: #9f171d;
    --gold: #99711d;
    --teal: #28746e;
    --indigo: #465a90;
    --shadow: 0 10px 30px rgba(17, 24, 39, .05);
    --sidebar: 294px;
    --topbar: 62px;
    color-scheme: light;
}

html[data-theme="dark"] {
    --bg: #0f1115;
    --panel: #14171d;
    --panel-2: #191d24;
    --ink: #f1f3f5;
    --muted: #adb4bd;
    --soft: #747d88;
    --line: #272c34;
    --line-strong: #343b45;
    --brand: #f05259;
    --brand-dark: #ff747a;
    --gold: #d9b45f;
    --teal: #56bdb2;
    --indigo: #94a4e8;
    --shadow: 0 12px 36px rgba(0, 0, 0, .24);
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
    font-size: 14.5px;
    line-height: 1.65;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input {
    font: inherit;
}

.topbar {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 50;
    width: 100%;
    max-width: 100vw;
    height: var(--topbar);
    display: grid;
    grid-template-columns: 154px minmax(150px, 1fr) minmax(260px, 500px) 38px;
    gap: 16px;
    align-items: center;
    padding: 0 18px;
    background: color-mix(in srgb, var(--panel) 94%, transparent);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

.brand {
    display: flex;
    align-items: center;
    min-width: 0;
}

.brand img {
    width: 140px;
    max-width: 100%;
    height: auto;
    display: block;
}

.topbar__meta {
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 10px;
    white-space: nowrap;
}

.topbar__meta span {
    color: var(--soft);
    font-size: 12px;
    letter-spacing: .11em;
    text-transform: uppercase;
}

.topbar__meta strong {
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-search {
    height: 38px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
}

.top-search input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    color: var(--ink);
    background: transparent;
}

.icon-btn {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: var(--ink);
    background: var(--panel);
    cursor: pointer;
}

.moon,
html[data-theme="dark"] .sun {
    display: none;
}

html[data-theme="dark"] .moon {
    display: inline;
}

.sidebar {
    position: fixed;
    z-index: 20;
    inset: var(--topbar) auto 0 0;
    width: var(--sidebar);
    overflow: auto;
    padding: 20px 16px 28px;
    border-right: 1px solid var(--line);
    background: color-mix(in srgb, var(--panel) 70%, var(--bg));
}

.sidebar__block + .sidebar__block {
    margin-top: 26px;
}

.eyebrow,
.section-kicker {
    color: var(--soft);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.act-list,
.chapter-nav {
    display: grid;
    gap: 2px;
    margin-top: 10px;
}

.act-link,
.chapter-nav a {
    display: grid;
    gap: 2px;
    padding: 10px 11px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
}

.act-link.is-active {
    color: color-mix(in srgb, var(--ink) 88%, var(--soft));
    background:
        linear-gradient(90deg, rgba(130, 138, 150, .15), rgba(130, 138, 150, .055)),
        var(--panel);
    border-color: #d1d5db;
    border-left-color: #7b8491;
    border-left-width: 3px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .65), 0 8px 22px rgba(29, 36, 48, .045);
}

html[data-theme="dark"] .act-link.is-active {
    background:
        linear-gradient(90deg, rgba(156, 166, 181, .16), rgba(156, 166, 181, .055)),
        var(--panel);
    border-color: #3c444f;
    border-left-color: #8f99a8;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035), 0 10px 24px rgba(0, 0, 0, .18);
}

.act-link span,
.chapter-nav strong {
    font-size: 14px;
    line-height: 1.25;
}

.act-link small,
.chapter-nav small,
.chapter-nav span {
    color: var(--soft);
    font-size: 12px;
    line-height: 1.35;
}

.act-link.is-active small {
    color: var(--muted);
}

.chapter-nav a {
    transition: border-color .14s ease, background .14s ease, color .14s ease;
}

.chapter-nav a:hover {
    border-color: var(--line);
    background: var(--panel);
}

.page {
    margin-left: var(--sidebar);
    padding-top: var(--topbar);
    min-height: 100vh;
}

.masthead {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 34px;
    align-items: end;
    padding: 36px clamp(24px, 5vw, 64px) 28px;
    color: var(--ink);
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.act-code {
    width: fit-content;
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    margin-bottom: 15px;
    padding: 3px;
    border: 1px solid #d6d9de;
    border-radius: 8px;
    color: #3f4650;
    background:
        linear-gradient(110deg, rgba(255, 255, 255, .82), rgba(238, 240, 243, .92)),
        #f2f3f4;
    box-shadow: 0 8px 24px rgba(25, 33, 45, .06), inset 0 1px 0 rgba(255, 255, 255, .9);
    font-family: "Consolas", "Courier New", monospace;
    font-size: 12px;
    overflow: hidden;
    position: relative;
}

.act-code::after {
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 0%, transparent 34%, rgba(255, 255, 255, .78) 48%, transparent 62%, transparent 100%);
    content: "";
    pointer-events: none;
    transform: translateX(-115%);
    animation: act-shimmer 4.6s ease-in-out infinite;
}

.act-code span {
    position: relative;
    z-index: 1;
    padding: 5px 9px;
    border: 0;
    border-radius: 5px;
    background: transparent;
}

.act-code span:first-child {
    font-weight: 800;
}

.act-code span + span {
    border-left: 1px solid #d7dbe1;
    color: #606875;
}

html[data-theme="dark"] .act-code {
    border-color: #3a414b;
    color: #e4e9ef;
    background:
        linear-gradient(110deg, rgba(32, 37, 46, .96), rgba(24, 28, 35, .98)),
        #1b2027;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .26), inset 0 1px 0 rgba(255, 255, 255, .05);
}

html[data-theme="dark"] .act-code::after {
    background: linear-gradient(110deg, transparent 0%, transparent 34%, rgba(255, 255, 255, .13) 48%, transparent 62%, transparent 100%);
}

html[data-theme="dark"] .act-code span + span {
    border-left-color: #3a414b;
    color: #aeb7c2;
}

@keyframes act-shimmer {
    0%, 52% {
        transform: translateX(-115%);
    }

    78%, 100% {
        transform: translateX(115%);
    }
}

@media (prefers-reduced-motion: reduce) {
    .act-code::after {
        animation: none;
        display: none;
    }
}

.masthead h1 {
    max-width: 820px;
    margin: 0;
    font-size: clamp(27px, 3vw, 40px);
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: 0;
}

.masthead p {
    max-width: 700px;
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 15px;
}

.quick-panel {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    border-top: 1px solid var(--line);
}

.quick-stat {
    min-height: auto;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: baseline;
    padding: 9px 0;
    border-bottom: 1px solid var(--line);
    background: transparent;
}

.quick-stat strong {
    font-family: "Consolas", "Courier New", monospace;
    font-size: 18px;
    line-height: 1;
}

.quick-stat span {
    margin-top: 0;
    color: var(--soft);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.source-strip,
.reader-tools,
.preamble,
.chapter,
.empty-state,
.site-footer {
    width: min(1120px, calc(100% - 48px));
    margin-inline: auto;
}

.source-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    padding: 18px 0 0;
}

.source-strip span {
    padding: 0;
    border: 0;
    border-radius: 0;
    color: var(--muted);
    background: transparent;
    font-family: "Consolas", "Courier New", monospace;
    font-size: 12px;
}

.reader-tools {
    position: sticky;
    top: var(--topbar);
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-top: 18px;
    padding: 10px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px);
    box-shadow: none;
}

.reader-tools strong {
    font-family: "Consolas", "Courier New", monospace;
    font-size: 17px;
}

.reader-tools span {
    color: var(--muted);
}

.tool-actions {
    display: flex;
    gap: 8px;
}

.tool-actions button {
    min-height: 30px;
    padding: 4px 8px;
    border: 1px solid var(--line);
    border-radius: 5px;
    color: var(--ink);
    background: transparent;
    cursor: pointer;
}

.preamble {
    margin-top: 22px;
    padding: 0 0 0 16px;
    border-left: 2px solid var(--line-strong);
    background: transparent;
}

.preamble h2 {
    margin: 3px 0 10px;
    font-size: 22px;
    line-height: 1.15;
}

.preamble p {
    margin: 0;
    color: var(--muted);
    white-space: pre-line;
    line-height: 1.68;
}

.sections {
    padding: 14px 0 34px;
}

.chapter {
    scroll-margin-top: 100px;
    margin-top: 30px;
}

.chapter-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 8px;
    padding-bottom: 9px;
    border-bottom: 1px solid var(--line);
}

.chapter-heading span,
.chapter-heading small {
    color: var(--soft);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.chapter-heading h2 {
    margin: 3px 0 0;
    font-size: 22px;
    line-height: 1.12;
}

.section-card {
    scroll-margin-top: 124px;
    margin-top: 0;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    overflow: visible;
    background: transparent;
    box-shadow: none;
}

.section-card[hidden] {
    display: none;
}

.chapter[data-accent="red"] .section-card {
    box-shadow: inset 1px 0 0 var(--line-strong);
}

.chapter[data-accent="gold"] .section-card {
    box-shadow: inset 1px 0 0 var(--line-strong);
}

.chapter[data-accent="teal"] .section-card {
    box-shadow: inset 1px 0 0 var(--line-strong);
}

.chapter[data-accent="indigo"] .section-card {
    box-shadow: inset 1px 0 0 var(--line-strong);
}

summary {
    min-height: 62px;
    display: grid;
    grid-template-columns: 68px minmax(0, 1fr) 28px;
    gap: 12px;
    align-items: center;
    padding: 12px 0 12px 14px;
    cursor: pointer;
    list-style: none;
}

summary::-webkit-details-marker {
    display: none;
}

.sec-no {
    display: inline-grid;
    place-items: center;
    min-height: 28px;
    border: 0;
    border-radius: 0;
    color: #737b86;
    background: transparent;
    font-family: "Consolas", "Courier New", monospace;
    font-weight: 800;
}

.sec-title {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.sec-title strong {
    font-size: 16px;
    line-height: 1.25;
}

.sec-title small {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
}

.open-mark {
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 0;
    color: var(--muted);
    transition: transform .14s ease, color .14s ease;
}

details[open] .open-mark {
    transform: rotate(45deg);
    color: #737b86;
}

.section-body {
    border-top: 1px dashed var(--line);
    padding: 10px 0 14px 82px;
}

.section-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 0;
}

.tag-row span {
    padding: 0;
    border-radius: 0;
    color: var(--soft);
    background: transparent;
    font-family: "Consolas", "Courier New", monospace;
    font-size: 11px;
    font-weight: 700;
}

.copy-actions {
    flex: 0 0 auto;
    display: flex;
    gap: 6px;
}

.copy-btn {
    flex: 0 0 auto;
    min-height: 26px;
    padding: 3px 8px;
    border: 1px solid var(--line);
    border-radius: 5px;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
    font-family: "Consolas", "Courier New", monospace;
    font-size: 11px;
    transition: border-color .14s ease, color .14s ease, background .14s ease;
}

.copy-btn:hover,
.copy-btn.is-copied {
    border-color: var(--line-strong);
    color: var(--ink);
    background: var(--panel-2);
}

.xref-section,
.defined-term {
    color: #48505a;
    border-bottom: 1px solid #c7ccd3;
    text-decoration: none;
}

html[data-theme="dark"] .xref-section,
html[data-theme="dark"] .defined-term {
    color: #c8d0da;
    border-bottom-color: #58616d;
}

.xref-section {
    padding: 0 1px;
    font-weight: 600;
}

.xref-section:hover,
.xref-section:focus {
    background: var(--panel-2);
    outline: 0;
}

.defined-term {
    position: relative;
    cursor: help;
    font-weight: 600;
}

.defined-term::after {
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    z-index: 80;
    width: min(330px, 78vw);
    padding: 10px 11px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: var(--ink);
    background: var(--panel);
    box-shadow: var(--shadow);
    content: attr(data-definition);
    font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
    font-size: 12.5px;
    font-weight: 400;
    line-height: 1.45;
    opacity: 0;
    pointer-events: none;
    transform: translateY(3px);
    transition: opacity .12s ease, transform .12s ease;
    white-space: normal;
}

.defined-term::before {
    position: absolute;
    left: 10px;
    bottom: calc(100% + 3px);
    z-index: 81;
    width: 9px;
    height: 9px;
    border-right: 1px solid var(--line-strong);
    border-bottom: 1px solid var(--line-strong);
    background: var(--panel);
    content: "";
    opacity: 0;
    pointer-events: none;
    transform: rotate(45deg) translateY(3px);
    transition: opacity .12s ease, transform .12s ease;
}

.defined-term:hover::after,
.defined-term:focus::after,
.defined-term:hover::before,
.defined-term:focus::before {
    opacity: 1;
    transform: translateY(0);
}

.defined-term:hover::before,
.defined-term:focus::before {
    transform: rotate(45deg) translateY(0);
}

.law-text {
    white-space: pre-wrap;
    color: var(--ink);
    font-size: 15px;
    line-height: 1.58;
}

.empty-state {
    margin-top: 20px;
    padding: 24px;
    border: 1px dashed var(--line-strong);
    border-radius: 6px;
    background: transparent;
    text-align: center;
}

.empty-state h2 {
    margin: 0 0 6px;
}

.empty-state p {
    margin: 0;
    color: var(--muted);
}

.site-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
    padding: 28px 0 40px;
    color: var(--muted);
    border-top: 1px solid var(--line);
}

.site-footer strong {
    color: var(--brand);
}

mark {
    padding: 0 2px;
    border-radius: 3px;
    color: inherit;
    background: color-mix(in srgb, var(--gold) 34%, transparent);
}

@media (max-width: 1080px) {
    :root {
        --sidebar: 278px;
    }

    .topbar {
        grid-template-columns: 150px minmax(120px, 1fr) minmax(210px, 380px) 42px;
        gap: 12px;
    }

    .brand img {
        width: 132px;
    }

    .masthead {
        grid-template-columns: 1fr;
    }

    .quick-panel {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 840px) {
    :root {
        --sidebar: 0px;
        --topbar: 108px;
    }

    .topbar {
        height: var(--topbar);
        grid-template-columns: minmax(0, 1fr) 38px;
        grid-template-areas:
            "brand theme"
            "search search";
        gap: 8px 10px;
        align-content: center;
        padding: 10px 12px;
        overflow: hidden;
    }

    .brand {
        grid-area: brand;
    }

    .brand img {
        width: min(128px, calc(100vw - 76px));
    }

    .topbar__meta {
        display: none;
    }

    .top-search {
        grid-area: search;
        width: 100%;
        min-width: 0;
        height: 36px;
    }

    .icon-btn {
        grid-area: theme;
        justify-self: end;
        width: 38px;
        height: 38px;
    }

    .sidebar {
        display: none;
    }

    .page {
        margin-left: 0;
    }

    .masthead {
        padding: 24px 16px 24px;
    }

    .quick-panel {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .source-strip,
    .reader-tools,
    .preamble,
    .chapter,
    .empty-state,
    .site-footer {
        width: min(100% - 28px, 1120px);
    }

    .reader-tools {
        position: static;
        align-items: stretch;
        flex-direction: column;
    }

    .tool-actions {
        width: 100%;
    }

    .tool-actions button {
        flex: 1;
    }

    summary {
        grid-template-columns: 62px minmax(0, 1fr) 28px;
        gap: 10px;
        padding: 14px;
    }

    .section-body {
        padding: 15px;
    }

    .section-meta {
        align-items: flex-start;
        flex-direction: column;
    }

    .copy-actions {
        flex-wrap: wrap;
    }
}

@media (max-width: 520px) {
    :root {
        --topbar: 104px;
    }

    .topbar {
        padding-inline: 10px;
    }

    .brand img {
        width: min(118px, calc(100vw - 68px));
    }

    .masthead h1 {
        font-size: 28px;
    }

    .masthead p {
        font-size: 15px;
    }

    .quick-panel {
        grid-template-columns: 1fr;
    }

    .quick-stat {
        min-height: auto;
    }

    .quick-stat strong {
        font-size: 18px;
    }

    .source-strip span {
        width: 100%;
    }

    summary {
        grid-template-columns: 1fr 28px;
    }

    .sec-no {
        width: fit-content;
    }

    .sec-title {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .open-mark {
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
    }
}
