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

:root {
    --bg:       #0d0f12;
    --surface:  #13161b;
    --surface2: #191d25;
    --border:   #1f2530;
    --border2:  #2a3040;
    --accent:   #1A8ABD;
    --gold:     #e8b84b;
    --white:    #ffffff;
    --text:     #cdd5e0;
    --muted:    #6b7a94;
    --green:    #4caf88;
    --red:      #e05c5c;
    --nav-h:    48px;
    --subnav-h: 40px;
    --footer-h: 44px;
    --font-mono: ui-monospace, "Cascadia Code", "Fira Code", "Consolas", monospace;
    --font-serif: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
}

html { font-size: 15px; }

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

/* ── Top nav ── */
nav.topnav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    height: var(--nav-h);
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
    gap: 1rem;
}

.logo {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--white);
    text-decoration: none;
    letter-spacing: -0.01em;
    flex-shrink: 0;
}
.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;
    background: var(--surface2); border: 1px solid var(--border2);
    color: var(--text); padding: 0.3rem 0.75rem; border-radius: 5px;
    font-family: var(--font-mono); font-size: 0.8rem;
    cursor: pointer; user-select: none;
    transition: border-color 0.15s, background 0.15s; white-space: nowrap;
}
.branch-btn:hover { border-color: var(--accent); background: #1a1f28; }
.branch-btn .arrow { color: var(--muted); font-size: 0.65rem; 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% + 6px); left: 0;
    min-width: 220px; background: var(--surface2); border: 1px solid var(--border2);
    border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,0.5); z-index: 200; overflow: hidden;
}
.branch-wrap.open .branch-dropdown { display: block; }
.branch-dropdown-header {
    padding: 0.5rem 0.9rem; font-size: 0.68rem;
    text-transform: uppercase; letter-spacing: 0.1em;
    color: var(--muted); border-bottom: 1px solid var(--border);
}
.branch-dropdown a {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.5rem 0.9rem; font-size: 0.82rem; color: var(--text);
    text-decoration: none; transition: background 0.1s;
    border-bottom: 1px solid var(--border);
}
.branch-dropdown a:last-child { border-bottom: none; }
.branch-dropdown a:hover { background: #1e2530; color: var(--accent); }
.branch-dropdown a.active { color: var(--white); }
.branch-dropdown a .bi { color: var(--muted); font-size: 0.75rem; width: 1rem; text-align: center; }
.branch-dropdown a.active .bi { color: var(--white); }

.breadcrumb {
    display: flex; align-items: center; gap: 0.35rem;
    font-size: 0.78rem; color: var(--muted); overflow: hidden; flex: 1;
}
.breadcrumb a { color: var(--accent); text-decoration: none; white-space: nowrap; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: var(--border2); }

/* ── Sub-nav ── */
nav.subnav {
    background: var(--surface); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; height: var(--subnav-h);
    padding: 0 1.5rem; flex-shrink: 0;
}
.subnav a {
    display: inline-flex; align-items: center; gap: 0.4rem;
    height: var(--subnav-h); padding: 0 1rem; font-size: 0.82rem;
    color: var(--muted); text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s; white-space: nowrap;
}
.subnav a:hover { color: var(--text); }
.subnav a.active { color: var(--accent); border-bottom-color: var(--accent); }
.subnav .icon { font-size: 0.9em; }

/* ── Main ── */
main { max-width: 1080px; width: 100%; margin: 2rem auto; padding: 0 1.5rem 3rem; flex: 1; }

/* ── Footer git bar ── */
footer.git-footer {
    background: #0a0c0f; border-top: 1px solid var(--border);
    height: var(--footer-h); display: flex; align-items: center;
    padding: 0 1.5rem; gap: 0.75rem; flex-shrink: 0;
}
.git-footer .footer-label {
    font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em;
    color: var(--muted); flex-shrink: 0;
}
.git-footer .footer-cmd {
    font-family: var(--font-mono); font-size: 0.8rem; color: var(--green);
    flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.git-footer .footer-cmd .git-kw { color: var(--accent); }
.git-footer .copy-btn {
    font-family: var(--font-mono); font-size: 0.72rem;
    background: var(--surface2); border: 1px solid var(--border2);
    color: var(--muted); padding: 0.2rem 0.6rem; border-radius: 4px;
    cursor: pointer; transition: border-color 0.15s, color 0.15s; flex-shrink: 0;
}
.git-footer .copy-btn:hover { border-color: var(--accent); color: var(--text); }
.git-footer .copy-btn.copied { border-color: var(--green); color: var(--green); }

/* ── Page heading ── */
.page-title {
    font-family: var(--font-serif); font-size: 1.5rem; font-weight: normal;
    color: var(--text); margin-bottom: 0.2rem;
}
.page-title em { color: var(--white); font-style: italic; }
.page-sub { font-size: 0.77rem; color: var(--muted); margin-bottom: 1.6rem; }

/* ── Repo index cards ── */
.repo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}
.repo-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.1rem 1.2rem;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    transition: border-color 0.15s, background 0.15s;
}
.repo-card:hover { border-color: var(--accent); background: #161a22; }
.repo-card-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.repo-card-desc { font-size: 0.78rem; color: var(--muted); }
.repo-card-meta { font-size: 0.72rem; 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;
    border: 1px solid var(--border); border-radius: 6px; overflow: hidden;
}
.data-table thead tr { background: var(--surface2); border-bottom: 1px solid var(--border2); }
.data-table th {
    padding: 0.55rem 1rem; text-align: left; font-size: 0.7rem;
    text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 500;
}
.data-table tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: #161a22; }
.data-table td { padding: 0.5rem 1rem; font-size: 0.83rem; vertical-align: middle; }

.file-icon { margin-right: 0.45rem; }
.file-link { color: var(--accent); text-decoration: none; font-weight: 500; }
.file-link:hover { text-decoration: underline; color: #7eb5ff; }
.muted-text { color: var(--muted); font-size: 0.78rem; }

/* ── Ref badges ── */
.ref-row td:first-child { width: 2rem; text-align: center; }
.ref-badge {
    display: inline-block; font-size: 0.68rem; padding: 0.15rem 0.5rem;
    border-radius: 3px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
}
.ref-branch { background: #0e2040; color: var(--accent); border: 1px solid #1e3a6e; }
.ref-tag    { background: #2a1a00; color: var(--gold);   border: 1px solid #5a3a00; }
.ref-name   { color: var(--text); font-weight: 500; }
.ref-hash {
    font-size: 0.75rem; color: var(--gold); background: #1a1f2a;
    border: 1px solid var(--border2); padding: 0.15rem 0.5rem;
    border-radius: 4px; font-family: var(--font-mono);
}

/* ── Log / version lists ── */
.log-list, .version-list { display: flex; flex-direction: column; }
.log-item, .version-item {
    display: flex; align-items: center; gap: 0.9rem;
    padding: 0.6rem 1rem;
    border: 1px solid var(--border); border-bottom: none;
    background: var(--surface); transition: background 0.1s;
}
.log-item:first-child, .version-item:first-child { border-radius: 6px 6px 0 0; }
.log-item:last-child,  .version-item:last-child  { border-radius: 0 0 6px 6px; border-bottom: 1px solid var(--border); }
.log-item:only-child,  .version-item:only-child  { border-radius: 6px; border-bottom: 1px solid var(--border); }
.log-item:hover, .version-item:hover { background: #161a22; }

.log-hash {
    font-size: 0.75rem; color: var(--gold); background: #1a1f2a;
    border: 1px solid var(--border2); padding: 0.15rem 0.5rem;
    border-radius: 4px; font-family: var(--font-mono);
    text-decoration: none; flex-shrink: 0; letter-spacing: 0.04em;
}
.log-hash:hover { background: #1e2840; color: #f5cc6e; }
.log-msg    { flex: 1; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-author { font-size: 0.75rem; color: var(--muted); flex-shrink: 0; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-date   { font-size: 0.75rem; color: var(--muted); flex-shrink: 0; }

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

.raw-btn {
    display: inline-flex; align-items: center; gap: 0.35rem;
    font-family: var(--font-mono); font-size: 0.75rem;
    background: var(--surface); border: 1px solid var(--border2);
    color: var(--muted); padding: 0.2rem 0.65rem; border-radius: 4px;
    text-decoration: none; transition: border-color 0.15s, color 0.15s; white-space: nowrap;
}
.raw-btn:hover { border-color: var(--accent); color: var(--accent); }
.raw-btn.dl { border-color: #2a3a1a; color: var(--green); background: #0e1a0a; }
.raw-btn.dl:hover { border-color: var(--green); color: #6ee0a8; }

/* ── Chroma code block ── */
.code-wrap {
    border: 1px solid var(--border); border-radius: 0 0 6px 6px;
    overflow: auto; background: #0b0d10;
}
.chroma-wrap .chroma { background: transparent !important; margin: 0; }
.chroma-wrap pre.chroma { margin: 0; padding: 0; background: transparent !important; }
.chroma-wrap table.lntable {
    width: 100%; border-collapse: collapse;
    font-family: var(--font-mono); font-size: 0.81rem; line-height: 1.65;
}
.chroma-wrap table.lntable td { padding: 0; vertical-align: top; }
.chroma-wrap .lntd:first-child {
    user-select: none; text-align: right;
    border-right: 1px solid var(--border); background: #0d0f13;
    min-width: 3.2rem; padding: 0;
}
.chroma-wrap .lntd:first-child pre { padding: 0 0.8rem; color: #3a4455 !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(--muted) !important; }
.chroma-wrap table.lntable tr:hover .lntd:last-child { background: #111520; }
.chroma { background: transparent !important; }

/* ── Back link ── */
.back-link {
    display: inline-flex; align-items: center; gap: 0.4rem;
    color: var(--muted); text-decoration: none; font-size: 0.79rem;
    margin-bottom: 1.4rem; transition: color 0.15s;
}
.back-link:hover { color: var(--accent); }

/* ── Empty / error ── */
.empty {
    text-align: center; padding: 3rem; color: var(--muted);
    font-size: 0.88rem; border: 1px dashed var(--border); border-radius: 6px;
}