:root {
    --bg: #1a1b1e;
    --inset: #202125;
    --card: #25262b;
    --surface: #2c2e33;
    --border: #373a40;
    --border-strong: #5c5f66;
    --line: #2c2e33;
    --text: #f4f5f7;
    --soft: #c1c2c5;
    --muted: #909296;
    --subtle: #6b6e75;
    --warning: #d8b05a;
    --top: 64px;
    --side: 272px;
    color-scheme: dark;
}

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

html {
    scroll-padding-top: calc(var(--top) + 24px);
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.65 'Geist', 'Segoe UI', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

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

button,
input {
    font: inherit;
    color: inherit;
    border: 0;
    background: none;
    outline: none;
}

button {
    cursor: pointer;
}

svg {
    width: 16px;
    height: 16px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

kbd {
    padding: 1px 6px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--bg);
    color: var(--muted);
    font: 500 11px 'Geist Mono', ui-monospace, Consolas, monospace;
}

:focus-visible {
    outline: 2px solid var(--border-strong);
    outline-offset: 2px;
}

.hidden {
    display: none !important;
}

.top {
    position: fixed;
    inset: 0 0 auto;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 16px;
    height: var(--top);
    padding: 0 24px;
    background: rgba(26, 27, 30, .86);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    width: calc(var(--side) - 40px);
    flex: none;
}

.brand img {
    width: 26px;
    height: auto;
}

.brand-word {
    font: 500 18px 'Jost', 'Geist', sans-serif;
    letter-spacing: .2em;
}

.brand-sep {
    width: 1px;
    height: 16px;
    background: var(--border);
}

.brand-sub {
    color: var(--muted);
    font-size: 13px;
}

.icon-btn {
    display: none;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    color: var(--muted);
}

.icon-btn:hover {
    background: var(--surface);
    color: var(--text);
}

.search-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: min(420px, 100%);
    height: 38px;
    margin-left: auto;
    padding: 0 8px 0 12px;
    border-radius: 9px;
    background: var(--inset);
    box-shadow: inset 0 0 0 1px var(--border);
    color: var(--muted);
    font-size: 13px;
    transition: box-shadow .15s, color .15s;
}

.search-btn:hover {
    box-shadow: inset 0 0 0 1px var(--border-strong);
    color: var(--text);
}

.search-btn span {
    flex: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.side {
    position: fixed;
    top: var(--top);
    bottom: 0;
    left: 0;
    z-index: 15;
    display: flex;
    flex-direction: column;
    width: var(--side);
    padding: 26px 16px 16px;
    background: var(--bg);
    border-right: 1px solid var(--line);
    overflow-y: auto;
}

.side nav {
    flex: 1;
}

.side-group + .side-group {
    margin-top: 24px;
}

.side-group h2 {
    margin-bottom: 6px;
    padding: 0 10px;
    color: var(--subtle);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.side-group a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 7px 10px;
    border-radius: 7px;
    color: var(--muted);
    font-size: 14px;
    transition: background .12s, color .12s;
}

.side-group a b {
    width: 18px;
    flex: none;
    font-size: 14px;
    font-weight: 400;
    line-height: 1;
    text-align: center;
}

.side-group a:hover {
    background: var(--inset);
    color: var(--text);
}

.side-group a.active {
    background: var(--surface);
    color: var(--text);
    font-weight: 500;
}

.side-foot {
    margin-top: 24px;
    padding: 14px 10px 0;
    border-top: 1px solid var(--line);
    color: var(--subtle);
    font-size: 12px;
}

.account {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 10px;
}

.account a,
.account button {
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: color .12s;
}

.account a:hover,
.account button:hover {
    color: var(--text);
}

.editing .side,
.editing .menu-btn {
    display: none;
}

.editing .main {
    padding-right: 24px;
    padding-left: 24px;
}

.shade {
    display: none;
}

.main {
    min-height: 100vh;
    padding: calc(var(--top) + 56px) 48px 72px calc(var(--side) + 48px);
    outline: none;
}

.page,
.home {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    animation: rise .22s ease-out;
}

.home {
    max-width: 880px;
}

@keyframes rise {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.draft {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 28px;
    padding: 5px 11px;
    border-radius: 99px;
    background: rgba(216, 176, 90, .1);
    box-shadow: inset 0 0 0 1px rgba(216, 176, 90, .28);
    color: var(--warning);
    font-size: 12px;
}

.draft span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--warning);
}

.home-logo {
    display: block;
    width: 58px;
    height: auto;
    margin-bottom: 26px;
}

.eyebrow {
    margin-bottom: 10px;
    color: var(--subtle);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
}

h1 {
    font-size: 38px;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -.025em;
}

.home h1 {
    font-size: 50px;
}

.lead {
    max-width: 620px;
    margin-top: 12px;
    color: var(--muted);
    font-size: 16px;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    margin-top: 44px;
}

.card {
    position: relative;
    min-height: 172px;
    padding: 20px;
    border-radius: 12px;
    background: var(--inset);
    box-shadow: inset 0 0 0 1px var(--line);
    transition: background .15s, box-shadow .15s, transform .15s;
}

.card:hover {
    background: var(--card);
    box-shadow: inset 0 0 0 1px var(--border-strong);
    transform: translateY(-2px);
}

.card h2 {
    font-size: 16px;
    font-weight: 600;
}

.card ul {
    margin-top: 12px;
    list-style: none;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.9;
}

.card-go {
    position: absolute;
    top: 20px;
    right: 18px;
    color: var(--subtle);
    transition: color .15s, transform .15s;
}

.card:hover .card-go {
    color: var(--text);
    transform: translateX(2px);
}

.rules {
    margin-top: 36px;
    list-style: none;
    border-top: 1px solid var(--line);
}

.rule {
    position: relative;
    display: grid;
    grid-template-columns: 52px 1fr 30px;
    align-items: start;
    gap: 8px;
    padding: 15px 8px 15px 0;
    border-bottom: 1px solid var(--line);
    transition: background .4s;
}

.rule-ref {
    padding: 3px 0 0 2px;
    color: var(--subtle);
    font: 500 12.5px 'Geist Mono', ui-monospace, Consolas, monospace;
}

.rule p {
    color: var(--soft);
}

.rule strong,
.note strong,
.term strong {
    color: var(--text);
    font-weight: 600;
}

.rule-link {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    color: var(--subtle);
    opacity: 0;
    transition: opacity .12s, background .12s, color .12s;
}

.rule:hover .rule-link,
.rule-link:focus-visible {
    opacity: 1;
}

.rule-link:hover {
    background: var(--surface);
    color: var(--text);
}

.rule.flash {
    animation: flash 2s ease-out;
}

@keyframes flash {
    0%, 40% { background: rgba(255, 255, 255, .07); }
    100% { background: transparent; }
}

.note {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding: 14px 16px;
    border-radius: 10px;
    background: var(--inset);
    box-shadow: inset 0 0 0 1px var(--line);
    color: var(--muted);
    font-size: 14px;
}

.note svg {
    margin-top: 3px;
    color: var(--soft);
}

.terms {
    margin-top: 36px;
    border-top: 1px solid var(--line);
}

.term {
    border-bottom: 1px solid var(--line);
}

.term summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 2px;
    font-weight: 500;
    list-style: none;
    cursor: pointer;
}

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

.term summary svg {
    color: var(--subtle);
    transition: transform .15s;
}

.term[open] summary svg {
    transform: rotate(180deg);
}

.term p {
    padding: 0 28px 16px 2px;
    color: var(--muted);
}

.table {
    margin-top: 36px;
    border-radius: 10px;
    box-shadow: inset 0 0 0 1px var(--line);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th {
    padding: 11px 16px;
    background: var(--inset);
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    text-align: left;
}

td {
    padding: 12px 16px;
    border-top: 1px solid var(--line);
    color: var(--soft);
}

td:first-child {
    color: var(--text);
    font-weight: 500;
}

.table + .rules {
    margin-top: 28px;
}

.pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 52px;
}

.pager a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 10px;
    box-shadow: inset 0 0 0 1px var(--line);
    color: var(--muted);
    font-size: 14px;
    transition: box-shadow .15s, color .15s;
}

.pager a:hover {
    box-shadow: inset 0 0 0 1px var(--border-strong);
    color: var(--text);
}

.pager span {
    display: flex;
    flex-direction: column;
    min-width: 0;
    color: var(--text);
    font-weight: 500;
}

.pager small {
    color: var(--subtle);
    font-size: 12px;
    font-weight: 400;
}

.pager .next {
    grid-column: 2;
    justify-content: flex-end;
    text-align: right;
}

.search {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 14vh 16px 16px;
    background: rgba(12, 13, 15, .62);
    backdrop-filter: blur(4px);
}

.search-box {
    width: min(620px, 100%);
    border-radius: 13px;
    background: var(--inset);
    box-shadow: inset 0 0 0 1px var(--border), 0 24px 60px rgba(0, 0, 0, .5);
    overflow: hidden;
    animation: rise .14s ease-out;
}

.search-field {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 54px;
    padding: 0 14px 0 18px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
}

.search-field input {
    flex: 1;
    min-width: 0;
    color: var(--text);
    font-size: 15px;
}

.search-field input::placeholder {
    color: var(--subtle);
}

.results {
    max-height: 52vh;
    padding: 6px;
    overflow-y: auto;
}

.results-empty {
    padding: 26px 14px;
    color: var(--subtle);
    font-size: 14px;
    text-align: center;
}

.result {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
}

.result.selected,
.result:hover {
    background: var(--surface);
}

.result small {
    display: flex;
    gap: 8px;
    color: var(--subtle);
    font-size: 12px;
}

.result small b {
    color: var(--soft);
    font: 500 12px 'Geist Mono', ui-monospace, Consolas, monospace;
}

.result span {
    display: -webkit-box;
    color: var(--soft);
    font-size: 14px;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

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

mark {
    border-radius: 3px;
    background: rgba(255, 255, 255, .14);
    color: var(--text);
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    z-index: 50;
    padding: 8px 14px;
    border-radius: 9px;
    background: var(--text);
    color: var(--bg);
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    transform: translate(-50%, 8px);
    transition: opacity .15s, transform .15s;
    pointer-events: none;
}

.toast.error {
    background: #7f1d1d;
    color: #fecaca;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

@media (max-width: 920px) {
    .top {
        gap: 8px;
        padding: 0 16px 0 8px;
    }

    .icon-btn {
        display: grid;
    }

    .brand {
        width: auto;
    }

    .brand-sep,
    .brand-sub,
    .search-btn span,
    .search-btn kbd {
        display: none;
    }

    .search-btn {
        justify-content: center;
        width: 38px;
        padding: 0;
    }

    .side {
        transform: translateX(-100%);
        transition: transform .2s ease;
    }

    .menu-open .side {
        transform: none;
    }

    .shade {
        position: fixed;
        inset: var(--top) 0 0;
        z-index: 14;
        display: block;
        background: rgba(12, 13, 15, .6);
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s;
    }

    .menu-open .shade {
        opacity: 1;
        pointer-events: auto;
    }

    .main {
        padding: calc(var(--top) + 32px) 16px 48px;
    }

    h1 {
        font-size: 30px;
    }

    .home h1 {
        font-size: 36px;
    }

    .rule {
        grid-template-columns: 42px 1fr;
    }

    .rule-link {
        display: none;
    }

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

    .pager .next {
        grid-column: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}

.load-error {
    padding-top: 40px;
    color: var(--muted);
    text-align: center;
}
