:root {
    color-scheme: light;
    --bg: #f6f8fa;
    --surface: #ffffff;
    --surface2: #eef1f5;
    --hover: #e9eef5;
    --code-bg: #ffffff;
    --footer-bg: #eef1f5;

    --border: #d0d7e2;
    --border2: #b4bfcf;


    --strong: #0b1220;
    --text: #1f2733;
    --muted: #4f5d73;
    --subtle: #5b697f;

    --accent: #0b6e99;
    --accent-hover: #064a69;
    --accent-solid: #1A8ABD;
    --gold: #7a4f00;
    --green: #1d7a52;
    --red: #b3261e;

    --focus: #b45309;

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

/* Targeted reset instead of * { margin:0; padding:0 } */
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(--strong);
    color: #fff;
    padding: 0.6rem 1rem;
    border-radius: var(--radius);
    font-weight: 600;
    text-decoration: none;
}

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


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(--strong);
    text-decoration: none;
    letter-spacing: -0.01em;
    flex-shrink: 0;
}

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

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

/* ── Branch picker ── */
.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-solid);
    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(--surface);
    border: 1px solid var(--border2);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(16, 24, 40, 0.15);
    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);
    background: var(--surface2);
    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(--strong);
    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(--strong);
}

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

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(--strong);
}

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

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

/* ── Main ── */
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 bar ── */
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(--surface);
    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-solid);
}

.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(--strong);
    font-style: italic;
}

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

/* ── Repo index cards ── */
.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-solid);
    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);
}

/* ── Generic table ── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    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: #e1f0fa;
    color: #0b5a80;
    border: 1px solid #9fcbe5;
}

.ref-tag {
    background: #fff4d6;
    color: var(--gold);
    border: 1px solid #e0b84d;
}

.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: #fbf3e0;
    border: 1px solid #e0cfa0;
    padding: 0.15rem 0.5rem;
    border-radius: 0.25rem;
}

/* ── Log / version lists ── */
.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: #f5e6bd;
    color: #5c3b00;
}

.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-solid);
    color: var(--accent-hover);
}

.raw-btn.dl {
    border-color: #7fbf9f;
    color: #17613f;
    background: #e6f5ed;
}

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

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

/* ── Back link ── */
.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 / error ── */
.empty {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--muted);
    font-size: 0.95rem;
    border: 1px dashed var(--border2);
    border-radius: var(--radius);
}


/* 6. Responsive
   ========================================================================== */

/* Small tablets and phones */
@media (max-width: 40em) {
    /* Let wide tables scroll sideways instead of breaking the page */
    .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;
    }

    /* Commit rows: hash + meta on the first line, message wraps below */
    .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;
    }
}

/* Very small phones: stack the footer controls */
@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;
    }
}

/* Large screens: slightly more breathing room */
@media (min-width: 90em) {
    :root {
        --content-w: 75rem;
    }
}


/* 7. User preferences
   ========================================================================== */

/* Reduced motion: remove non-essential animation */
@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;
    }
}

/* Increased contrast */
@media (prefers-contrast: more) {
    :root {
        --border: #6b778c;
        --border2: #4f5d73;
        --muted: #2f3b50;
        --subtle: #3d4a60;
        --accent: #064a69;
    }
}

/* Windows High Contrast / forced colours: rely on system colours */
@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;
    }
}

/* Print: hide interactive chrome, keep code readable */
@media print {
    nav.topnav, nav.subnav, footer.git-footer, .raw-btn, .back-link {
        display: none;
    }

    body {
        display: block;
        background: #fff;
    }

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

    .code-wrap {
        overflow: visible;
    }

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