:root {
    color-scheme: dark;

    --bg: #0d0f12;
    --surface: #13161b;
    --surface2: #191d25;
    --hover: #1b2029;
    --code-bg: #0b0d10;
    --footer-bg: #0a0c0f;

    --border: #2a3040;
    --border2: #3a4256;

    --white: #ffffff;
    --text: #d5dce8;
    --muted: #98a4ba;
    --subtle: #7d8aa3;
    --accent: #3fa9dd;
    --accent-hover: #8cc9ec;
    --accent-solid: #1A8ABD;
    --gold: #e8b84b;
    --green: #5cc99b;
    --red: #f08080;

    --focus: #ffd166;

    --nav-h: 3rem;
    --subnav-h: 2.75rem;
    --footer-h: 2.75rem;
    --content-w: 67.5rem;
    --radius: 0.375rem;

    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans",
    "Liberation Sans", "DejaVu Sans", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, "DejaVu Sans Mono",
    "Liberation Mono", monospace;
    --font-serif: ui-serif, "Noto Serif", "DejaVu Serif", "Liberation Serif",
    "Times New Roman", serif;
}


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

body, h1, h2, h3, p, ul, ol, figure, pre {
    margin: 0;
}

ul[class], ol[class] {
    padding: 0;
    list-style: none;
}

html {
    font-size: 100%;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

img, svg {
    max-width: 100%;
    height: auto;
}

a {
    color: var(--accent);
}

a:hover {
    color: var(--accent-hover);
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
}


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

:focus:not(:focus-visible) {
    outline: none;
}

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

.skip-link {
    position: absolute;
    left: 0.75rem;
    top: -4rem;
    z-index: 1000;
    background: var(--focus);
    color: #000;
    padding: 0.6rem 1rem;
    border-radius: var(--radius);
    font-weight: 600;
    text-decoration: none;
}

.skip-link:focus {
    top: 0.75rem;
}


nav.topnav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    min-height: var(--nav-h);
    padding: 0.35rem clamp(0.75rem, 3vw, 1.5rem);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

.logo {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--white);
    text-decoration: none;
    letter-spacing: -0.01em;
    flex-shrink: 0;
}

.logo:hover {
    color: var(--white);
}

.logo em {
    color: var(--accent);
    font-style: italic;
}

.branch-wrap {
    position: relative;
    flex-shrink: 0;
}

.branch-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.25rem;
    background: var(--surface2);
    border: 1px solid var(--border2);
    color: var(--text);
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: border-color 0.15s, background-color 0.15s;
}

.branch-btn:hover {
    border-color: var(--accent);
    background: var(--hover);
}

.branch-btn .arrow {
    color: var(--muted);
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.branch-wrap.open .branch-btn .arrow {
    transform: rotate(180deg);
}

.branch-icon {
    color: var(--green);
}

.branch-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 0.375rem);
    left: 0;
    min-width: 13.75rem;
    max-width: calc(100vw - 1.5rem);
    max-height: 70vh;
    overflow-y: auto;
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 200;
}

.branch-wrap.open .branch-dropdown {
    display: block;
}

.branch-dropdown-header {
    padding: 0.5rem 0.9rem;
    font-size: 0.75rem;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
}

.branch-dropdown a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 2.75rem;
    padding: 0.5rem 0.9rem;
    font-size: 0.875rem;
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid var(--border);
    transition: background-color 0.1s;
}

.branch-dropdown a:last-child {
    border-bottom: none;
}

.branch-dropdown a:hover {
    background: var(--hover);
    color: var(--accent-hover);
}

.branch-dropdown a.active {
    color: var(--white);
    font-weight: 600;
}

.branch-dropdown a .bi {
    color: var(--muted);
    font-size: 0.8rem;
    width: 1rem;
    text-align: center;
}

.branch-dropdown a.active .bi {
    color: var(--white);
}

/* ── Breadcrumb ── */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.4rem;
    font-size: 0.8125rem;
    color: var(--muted);
    flex: 1 1 12rem;
    min-width: 0;
}

.breadcrumb a {
    color: var(--accent);
    text-decoration: none;
    overflow-wrap: anywhere;
}

.breadcrumb a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.breadcrumb .sep {
    color: var(--subtle);
}

/* ── Sub-nav ── */
nav.subnav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    min-height: var(--subnav-h);
    padding: 0 clamp(0.75rem, 3vw, 1.5rem);
    flex-shrink: 0;
    overflow-x: auto;
    scrollbar-width: thin;
}

.subnav a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: var(--subnav-h);
    padding: 0 1rem;
    font-size: 0.875rem;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}

.subnav a:hover {
    color: var(--text);
}

.subnav a.active {
    color: var(--accent);
    border-bottom-color: var(--accent-solid);
}

.subnav .icon {
    font-size: 0.9em;
}

main {
    flex: 1;
    width: 100%;
    max-width: var(--content-w);
    margin: clamp(1rem, 4vw, 2rem) auto;
    padding: 0 clamp(0.75rem, 3vw, 1.5rem) 3rem;
}

footer.git-footer {
    background: var(--footer-bg);
    border-top: 1px solid var(--border);
    min-height: var(--footer-h);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    padding: 0.4rem clamp(0.75rem, 3vw, 1.5rem);
    flex-shrink: 0;
}

.git-footer .footer-label {
    font-size: 0.75rem;
    color: var(--muted);
    flex-shrink: 0;
}

.git-footer .footer-cmd {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    color: var(--green);
    flex: 1 1 12rem;
    min-width: 0;
    overflow-x: auto;
    white-space: nowrap;
}

.git-footer .footer-cmd .git-kw {
    color: var(--accent);
}

.git-footer .copy-btn {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    min-height: 2rem;
    background: var(--surface2);
    border: 1px solid var(--border2);
    color: var(--text);
    padding: 0.2rem 0.75rem;
    border-radius: 0.25rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.15s, color 0.15s;
}

.git-footer .copy-btn:hover {
    border-color: var(--accent);
}

.git-footer .copy-btn.copied {
    border-color: var(--green);
    color: var(--green);
}


.page-title {
    font-family: var(--font-serif);
    font-size: clamp(1.375rem, 1.1rem + 1.2vw, 1.75rem);
    font-weight: 400;
    line-height: 1.25;
    color: var(--text);
    margin-bottom: 0.25rem;
    overflow-wrap: anywhere;
}

.page-title em {
    color: var(--white);
    font-style: italic;
}

.page-sub {
    font-size: 0.875rem;
    color: var(--muted);
    margin-bottom: 1.5rem;
}

.repo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 17.5rem), 1fr));
    gap: 1rem;
}

.repo-card {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.1rem 1.2rem;
    text-decoration: none;
    transition: border-color 0.15s, background-color 0.15s;
}

.repo-card:hover {
    border-color: var(--accent);
    background: var(--hover);
}

.repo-card-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent);
    overflow-wrap: anywhere;
}

.repo-card-desc {
    font-size: 0.875rem;
    color: var(--muted);
}

.repo-card-meta {
    font-size: 0.8125rem;
    color: var(--muted);
    margin-top: auto;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border);
}

.data-table thead tr {
    background: var(--surface2);
    border-bottom: 1px solid var(--border2);
}

.data-table th {
    padding: 0.6rem 1rem;
    text-align: left;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--muted);
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background-color 0.1s;
}

.data-table tbody tr:last-child {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: var(--hover);
}

.data-table td {
    padding: 0.55rem 1rem;
    font-size: 0.9rem;
    vertical-align: middle;
}

.file-icon {
    margin-right: 0.45rem;
}

.file-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    overflow-wrap: anywhere;
}

.file-link:hover {
    text-decoration: underline;
    color: var(--accent-hover);
}

.muted-text {
    color: var(--muted);
    font-size: 0.8125rem;
}

.ref-row td:first-child {
    width: 2rem;
    text-align: center;
}

.ref-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 0.15rem 0.5rem;
    border-radius: 0.25rem;
}

.ref-branch {
    background: #0e2040;
    color: #7ec3ee;
    border: 1px solid #1e3a6e;
}

.ref-tag {
    background: #2a1a00;
    color: var(--gold);
    border: 1px solid #5a3a00;
}

.ref-name {
    color: var(--text);
    font-weight: 500;
    overflow-wrap: anywhere;
}

.ref-hash,
.log-hash {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--gold);
    background: #1a1f2a;
    border: 1px solid var(--border2);
    padding: 0.15rem 0.5rem;
    border-radius: 0.25rem;
}

.log-list, .version-list {
    display: flex;
    flex-direction: column;
}

.log-item, .version-item {
    display: flex;
    align-items: center;
    gap: 0.5rem 0.9rem;
    padding: 0.6rem 1rem;
    border: 1px solid var(--border);
    border-bottom: none;
    background: var(--surface);
    transition: background-color 0.1s;
}

.log-item:first-child, .version-item:first-child {
    border-radius: var(--radius) var(--radius) 0 0;
}

.log-item:last-child, .version-item:last-child {
    border-radius: 0 0 var(--radius) var(--radius);
    border-bottom: 1px solid var(--border);
}

.log-item:only-child, .version-item:only-child {
    border-radius: var(--radius);
    border-bottom: 1px solid var(--border);
}

.log-item:hover, .version-item:hover {
    background: var(--hover);
}

.log-hash {
    text-decoration: none;
    flex-shrink: 0;
    letter-spacing: 0.04em;
}

.log-hash:hover {
    background: #1e2840;
    color: #f5cc6e;
}

.log-msg {
    flex: 1;
    min-width: 0;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.log-author {
    font-size: 0.8125rem;
    color: var(--muted);
    flex-shrink: 0;
    max-width: 10rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.log-date {
    font-size: 0.8125rem;
    color: var(--muted);
    flex-shrink: 0;
}

/* ── Code view ── */
.code-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.8rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 0.65rem 1.2rem;
    font-size: 0.875rem;
    color: var(--muted);
}

.code-meta strong {
    color: var(--text);
    overflow-wrap: anywhere;
}

.raw-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 2rem;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    background: var(--surface);
    border: 1px solid var(--border2);
    color: var(--text);
    padding: 0.2rem 0.75rem;
    border-radius: 0.25rem;
    text-decoration: none;
    white-space: nowrap;
    transition: border-color 0.15s, color 0.15s;
}

.raw-btn:hover {
    border-color: var(--accent);
    color: var(--accent-hover);
}

.raw-btn.dl {
    border-color: #2f5a3f;
    color: var(--green);
    background: #0e1a0a;
}

.raw-btn.dl:hover {
    border-color: var(--green);
    color: #8ae6bc;
}

.code-wrap {
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    overflow: auto;
    background: var(--code-bg);
}

.code-wrap:focus-visible {
    outline-offset: -2px;
}

.chroma, .chroma-wrap .chroma, .chroma-wrap pre.chroma {
    background: transparent !important; /* Chroma inlines its own background */
}

.chroma-wrap .chroma, .chroma-wrap pre.chroma {
    margin: 0;
    padding: 0;
}

.chroma-wrap table.lntable {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.65;
    tab-size: 4;
}

.chroma-wrap table.lntable td {
    padding: 0;
    vertical-align: top;
}

.chroma-wrap .lntd:first-child {
    user-select: none;
    text-align: right;
    min-width: 3.2rem;
    border-right: 1px solid var(--border);
    background: #0d0f13;
}

.chroma-wrap .lntd:first-child pre {
    padding: 0 0.8rem;
    color: var(--subtle) !important;
    background: transparent !important;
}

.chroma-wrap .lntd:last-child {
    width: 100%;
}

.chroma-wrap .lntd:last-child pre {
    padding: 0.02rem 1rem;
    white-space: pre;
}

.chroma-wrap table.lntable tr:hover .lntd:first-child pre {
    color: var(--text) !important;
}

.chroma-wrap table.lntable tr:hover .lntd:last-child {
    background: #111520;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 2.25rem;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
    transition: color 0.15s;
}

.back-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.empty {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--muted);
    font-size: 0.95rem;
    border: 1px dashed var(--border2);
    border-radius: var(--radius);
}


@media (max-width: 40em) {
    .data-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table th, .data-table td {
        padding: 0.55rem 0.75rem;
        white-space: nowrap;
    }

    .log-item, .version-item {
        flex-wrap: wrap;
    }

    .log-msg {
        order: 3;
        flex-basis: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .log-author {
        max-width: 100%;
    }

    .code-meta {
        padding: 0.6rem 0.9rem;
    }

    .repo-card {
        padding: 1rem;
    }
}

@media (max-width: 26em) {
    .git-footer .footer-cmd {
        flex-basis: 100%;
    }

    .branch-wrap {
        flex: 1 1 100%;
    }

    .branch-btn {
        width: 100%;
        justify-content: space-between;
    }
}

@media (min-width: 90em) {
    :root {
        --content-w: 75rem;
    }
}


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

@media (prefers-contrast: more) {
    :root {
        --border: #5a647a;
        --border2: #7d8aa3;
        --muted: #c2cbdb;
        --subtle: #aab4c8;
    }
}

@media (forced-colors: active) {
    .branch-btn, .raw-btn, .copy-btn, .repo-card, .ref-badge {
        border: 1px solid ButtonText;
    }

    .subnav a.active {
        border-bottom-color: Highlight;
    }

    .skip-link {
        border: 2px solid ButtonText;
    }
}

@media print {
    :root {
        --bg: #fff;
        --surface: #fff;
        --surface2: #fff;
        --code-bg: #fff;
        --text: #000;
        --muted: #333;
        --white: #000;
        --accent: #000;
        --border: #999;
        --border2: #999;
    }

    nav.topnav, nav.subnav, footer.git-footer, .raw-btn, .back-link {
        display: none;
    }

    body {
        display: block;
    }

    main {
        max-width: none;
        margin: 0;
        padding: 0;
    }

    .code-wrap {
        overflow: visible;
    }

    .chroma-wrap .lntd:last-child pre {
        white-space: pre-wrap;
    }
}