/*
 * gattipage styles.
 *
 * Colour lives in CSS custom properties so `theme.json` can override any of
 * them at runtime (see public/js/theme.js). The values below are the built-in
 * fallbacks and mirror the shipped theme.json, so the page looks right even
 * before the theme request resolves.
 */

:root {
    --primary: #b5e61d;
    --primary-text: #1b2600;

    --bg: #f6f8f3;
    --bg-elevated: #ffffff;
    --bg-sunken: #ecefe6;
    --fg: #1c211a;
    --fg-muted: #5c6656;
    --fg-faint: #8a9484;
    --border: #dde3d5;
    --border-strong: #c3ccb8;
    --link: #3f7d00;
    --add: #1f8a3b;
    --add-bg: #e2f6e6;
    --del: #c0362c;
    --del-bg: #fbe6e3;
    --selection: rgba(181, 230, 29, 0.35);
    --shadow: 0 1px 2px rgba(20, 30, 10, 0.06), 0 8px 24px rgba(20, 30, 10, 0.06);

    --tok-comment: #6b7860;
    --tok-string: #0f766e;
    --tok-number: #b45309;
    --tok-keyword: #7c3aed;
    --tok-function: #1d4ed8;
    --tok-type: #0369a1;

    --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans SC",
        "PingFang SC", sans-serif;
    --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas,
        "Liberation Mono", monospace;

    --radius: 8px;
    --radius-sm: 5px;
    --row-h: 30px;
    --graph-row-h: 30px;
}

[data-theme="dark"] {
    --bg: #141414;
    --bg-elevated: #1c1c1c;
    --bg-sunken: #0f0f0f;
    --fg: #e6e6e6;
    --fg-muted: #9a9a9a;
    --fg-faint: #6b6b6b;
    --border: #2c2c2c;
    --border-strong: #3c3c3c;
    --link: #b5e61d;
    --add: #5fd07a;
    --add-bg: #16301d;
    --del: #ff7a6b;
    --del-bg: #3a1d1a;
    --selection: rgba(181, 230, 29, 0.3);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.35);

    --tok-comment: #6b6b6b;
    --tok-string: #9ece6a;
    --tok-number: #ffc861;
    --tok-keyword: #c084fc;
    --tok-function: #5cc8ff;
    --tok-type: #6ee7b7;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

/* Phone browsers otherwise inflate text in wide blocks on their own. */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--fg);
    background: var(--bg);
    display: flex;
    flex-direction: column;
}

::selection {
    background: var(--selection);
}

a {
    color: var(--link);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

button {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

code,
pre {
    font-family: var(--mono);
    font-size: 12.5px;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 48px;
    padding: 0 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
    flex: 0 0 auto;
    position: relative;
    z-index: 3;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--fg);
    font-weight: 600;
    letter-spacing: 0.01em;
}
.brand:hover {
    text-decoration: none;
}
.brand-mark {
    width: 16px;
    height: 16px;
    border-radius: 5px;
    background: var(--primary);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary-text) 25%, transparent);
}

.crumbs {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    overflow: hidden;
    gap: 2px;
    color: var(--fg-muted);
    min-width: 0;
    white-space: nowrap;
    mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
}
.crumbs a,
.crumbs span {
    color: var(--fg-muted);
    padding: 2px 5px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    text-overflow: ellipsis;
}
.crumbs a:hover {
    background: var(--bg-sunken);
    color: var(--fg);
    text-decoration: none;
}
.crumbs .sep {
    color: var(--fg-faint);
    padding: 0;
}
.crumbs .current {
    color: var(--fg);
    font-weight: 600;
}

.spacer {
    flex: 1 1 auto;
}

.repo-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--fg-muted);
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 2px 10px;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.repo-badge::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary);
}

.btn {
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--fg);
    border-radius: var(--radius-sm);
    padding: 5px 11px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    white-space: nowrap;
}
.btn:hover {
    background: var(--bg-sunken);
    border-color: var(--border-strong);
}
.btn.icon {
    padding: 5px 8px;
}
.btn.tiny {
    padding: 2px 7px;
    font-size: 12px;
}
.btn.primary {
    background: var(--primary);
    border-color: color-mix(in srgb, var(--primary) 70%, var(--fg));
    color: var(--primary-text);
    font-weight: 600;
}
.btn.primary:hover {
    background: color-mix(in srgb, var(--primary) 85%, #fff);
}
.btn.ghost {
    background: transparent;
    border-color: transparent;
}
.btn.ghost:hover {
    background: var(--bg-sunken);
    border-color: var(--border);
}
/* A ghost button acting as a switch (Repos): filled while it is on. */
.btn.ghost.is-on {
    background: var(--primary);
    border-color: color-mix(in srgb, var(--primary) 70%, var(--fg));
    color: var(--primary-text);
    font-weight: 600;
}
.btn.ghost.is-on:hover {
    background: color-mix(in srgb, var(--primary) 85%, #fff);
}
.btn[aria-pressed="true"] {
    background: color-mix(in srgb, var(--primary) 22%, var(--bg-elevated));
    border-color: color-mix(in srgb, var(--primary) 50%, var(--border));
}

/* ---------------------------------------------------------------- layout */

.layout {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}

.sidebar {
    width: 280px;
    flex: 0 0 auto;
    border-right: 1px solid var(--border);
    background: var(--bg-elevated);
    display: flex;
    flex-direction: column;
    min-height: 0;
    transition: width 0.15s ease;
}
.sidebar.collapsed {
    width: 0;
    overflow: hidden;
    border-right-color: transparent;
}

.side-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px 8px 14px;
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
}
.side-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--fg-faint);
}

.filetree {
    overflow: auto;
    padding: 6px 6px 20px;
    flex: 1 1 auto;
    min-height: 0;
}

.content {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    position: relative;
}

/* Each page is a layer filling the content box. A navigation renders the next
 * one underneath the current page (invisible and inert) and then cross-fades
 * them, so the old page never flashes away while the new one loads. */
.view {
    position: absolute;
    inset: 0;
    overflow: auto;
}
.view.is-staging {
    opacity: 0;
    pointer-events: none;
}
.view.is-in {
    animation: view-in 220ms ease 60ms both;
}
.view.is-leaving {
    animation: view-out 190ms ease both;
    pointer-events: none;
}
@keyframes view-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
@keyframes view-out {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Busy indicator, bottom right, shown only when a page takes a moment. */
.busy {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 13px 7px 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-elevated);
    box-shadow: var(--shadow);
    color: var(--fg-muted);
    font-size: 12px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(6px);
    transition:
        opacity 140ms ease,
        transform 140ms ease;
}
.busy.is-on {
    opacity: 1;
    transform: none;
}
.busy-spinner {
    width: 13px;
    height: 13px;
    border: 2px solid color-mix(in srgb, var(--fg-faint) 35%, transparent);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --------------------------------------------------------------- filetree */

.tree-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.tree-list .tree-list {
    margin-left: 14px;
    border-left: 1px solid var(--border);
    padding-left: 2px;
}

/* A directory's children slide open and shut. The height is measured and set by
 * `setOpen()` in tree.js: animating `grid-template-rows: 0fr → 1fr` would be
 * tidier, but browsers that cannot interpolate grid tracks would show no
 * animation at all, and a transition that silently does nothing is worse than a
 * little arithmetic. */
.tree-children {
    max-height: 0;
    overflow: hidden;
    transition: max-height 180ms cubic-bezier(0.22, 0.61, 0.36, 1);
}
.tree-children > .tree-list {
    opacity: 0;
    transition: opacity 140ms ease;
}
.tree-children.is-open > .tree-list {
    opacity: 1;
}

.tree-row {
    display: flex;
    align-items: center;
    gap: 2px;
    border-radius: var(--radius-sm);
}
.tree-row:hover {
    background: var(--bg-sunken);
}
.tree-row.active {
    background: color-mix(in srgb, var(--primary) 25%, transparent);
}

.tree-toggle {
    width: 18px;
    height: 22px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--fg-faint);
    cursor: pointer;
    padding: 0;
    font-size: 10px;
    line-height: 1;
    border-radius: 3px;
}
.tree-toggle:hover {
    color: var(--fg);
    background: var(--border);
}
.tree-toggle.leaf {
    cursor: default;
    visibility: hidden;
}
/* First expansion is still in flight: the chevron makes way for a spinner. */
.tree-toggle.is-loading {
    cursor: default;
}
.tree-toggle.is-loading::after {
    content: "";
    width: 9px;
    height: 9px;
    border: 1.5px solid color-mix(in srgb, var(--fg-faint) 35%, transparent);
    border-top-color: var(--fg-muted);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.tree-label {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 0;
    padding: 3px 6px 3px 0;
    text-align: left;
    cursor: pointer;
    color: var(--fg);
    overflow: hidden;
}
.tree-label:hover {
    text-decoration: none;
}
.tree-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tree-row.is-dir .tree-name {
    font-weight: 500;
}
.tree-icon {
    flex: 0 0 auto;
    width: 14px;
    text-align: center;
    color: var(--fg-faint);
    font-size: 11px;
}
.tree-row.is-dir .tree-icon {
    color: color-mix(in srgb, var(--primary) 60%, var(--fg-muted));
}
.tree-git {
    flex: 0 0 auto;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--primary-text);
    background: var(--primary);
    border-radius: 3px;
    padding: 0 4px;
    border: 0;
}

/* In a listing the repo tag is an indicator: the row itself opens the repo. */
.listing-row .tree-git {
    justify-self: end;
    cursor: default;
}

.tree-loading,
.tree-empty {
    color: var(--fg-faint);
    font-size: 12px;
    padding: 3px 8px;
}

/* ---------------------------------------------------------------- panels */

.panel {
    padding: 18px 22px 60px;
    max-width: 1500px;
}
.panel-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.panel-title {
    font-size: 16px;
    font-weight: 650;
    margin: 0;
    overflow-wrap: anywhere;
}
.panel-sub {
    color: var(--fg-muted);
    font-size: 12.5px;
}
.panel-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
    flex-wrap: wrap;
}

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-bottom: 14px;
    color: var(--fg-muted);
    font-size: 12.5px;
}
.breadcrumbs .sep {
    color: var(--fg-faint);
}
.breadcrumbs .current {
    color: var(--fg);
    font-weight: 600;
}

/* ---------------------------------------------------------------- listing */

.listing {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-elevated);
}
.listing-row {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr) 110px 170px;
    align-items: center;
    gap: 10px;
    padding: 7px 12px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    color: var(--fg);
    width: 100%;
    text-align: left;
    background: none;
    border-left: 0;
    border-right: 0;
    border-top: 0;
}
.listing-row:last-child {
    border-bottom: 0;
}
.listing-row:hover {
    background: var(--bg-sunken);
    text-decoration: none;
}
.listing-row .l-icon,
.l-icon {
    color: var(--fg-faint);
    text-align: center;
}
.listing-row.is-dir .l-icon,
.tree-entry.is-dir .l-icon {
    color: color-mix(in srgb, var(--primary) 60%, var(--fg-muted));
}
.listing-row .l-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.listing-row.is-dir .l-name {
    font-weight: 550;
}
.listing-row .l-size,
.listing-row .l-time {
    color: var(--fg-faint);
    font-size: 12px;
    text-align: right;
    white-space: nowrap;
}
.listing-row .l-time {
    text-align: right;
}
.listing-head {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr) 110px 170px;
    gap: 10px;
    padding: 7px 12px;
    background: var(--bg-sunken);
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--fg-faint);
}
.listing-head span:last-child,
.listing-head span:nth-last-child(2) {
    text-align: right;
}

/* Symlinks that leave the home sandbox are shown but greyed out. */
.listing-row.is-escape .l-name,
.tree-row.is-escape .tree-name {
    color: var(--fg-faint);
}
.listing-row.is-escape,
.tree-row.is-escape {
    cursor: not-allowed;
}



/* -------------------------------------------------------------- code view */

.code-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-elevated);
}
.code-scroll {
    overflow: auto;
    max-height: calc(100vh - 190px);
}
.code {
    display: table;
    width: 100%;
    border-collapse: collapse;
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.65;
}
.code-line {
    display: table-row;
}
.code-line:hover {
    background: color-mix(in srgb, var(--primary) 12%, transparent);
}
.code-line .gutter {
    display: table-cell;
    width: 1%;
    white-space: nowrap;
    text-align: right;
    padding: 0 12px 0 14px;
    color: var(--fg-faint);
    user-select: none;
    background: var(--bg-sunken);
    border-right: 1px solid var(--border);
    vertical-align: top;
    font-variant-numeric: tabular-nums;
}
.code-line .src {
    display: table-cell;
    padding: 0 16px 0 12px;
    white-space: pre;
    vertical-align: top;
}
.code-line.highlight {
    background: color-mix(in srgb, var(--primary) 22%, transparent);
}

.tok-comment {
    color: var(--tok-comment);
    font-style: italic;
}
.tok-string {
    color: var(--tok-string);
}
.tok-number {
    color: var(--tok-number);
}
.tok-keyword {
    color: var(--tok-keyword);
}
.tok-function {
    color: var(--tok-function);
}
.tok-type {
    color: var(--tok-type);
}
.tok-punct {
    color: var(--fg-muted);
}

/* -------------------------------------------------------------- diff view */

.diff-file {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-elevated);
    margin-bottom: 18px;
}
.diff-file-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-sunken);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 2;
}
.diff-file-path {
    font-family: var(--mono);
    font-size: 12.5px;
    overflow-wrap: anywhere;
    flex: 1 1 auto;
}
.diff-file-stat {
    font-family: var(--mono);
    font-size: 11.5px;
    white-space: nowrap;
}
.diff-file-stat .plus {
    color: var(--add);
}
.diff-file-stat .minus {
    color: var(--del);
}

.status-badge {
    flex: 0 0 auto;
    font-family: var(--mono);
    font-size: 10.5px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 4px;
    border: 1px solid var(--border);
    color: var(--fg-muted);
}
.status-added {
    color: var(--add);
    border-color: color-mix(in srgb, var(--add) 45%, var(--border));
}
.status-deleted {
    color: var(--del);
    border-color: color-mix(in srgb, var(--del) 45%, var(--border));
}
.status-renamed,
.status-copied {
    color: var(--tok-function);
    border-color: color-mix(in srgb, var(--tok-function) 45%, var(--border));
}

.diff-body {
    overflow-x: auto;
}
.diff-table {
    border-collapse: collapse;
    width: 100%;
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.6;
}
.diff-table td {
    padding: 0 4px;
    vertical-align: top;
}
.hunk-head {
    background: color-mix(in srgb, var(--primary) 12%, var(--bg-sunken));
    color: var(--fg-muted);
    font-size: 11.5px;
    padding: 2px 10px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    white-space: pre;
    font-family: var(--mono);
}
.diff-num {
    width: 1%;
    min-width: 42px;
    text-align: right;
    padding: 0 8px !important;
    color: var(--fg-faint);
    background: var(--bg-sunken);
    user-select: none;
    border-right: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
}
.diff-text {
    white-space: pre;
    padding-left: 12px !important;
    padding-right: 16px !important;
    color: var(--fg);
}
tr.diff-line-add td,
tr.diff-line-add .diff-text {
    background: var(--add-bg);
}
tr.diff-line-add .diff-text {
    box-shadow: inset 2px 0 0 var(--add);
}
tr.diff-line-del td,
tr.diff-line-del .diff-text {
    background: var(--del-bg);
}
tr.diff-line-del .diff-text {
    box-shadow: inset 2px 0 0 var(--del);
}
tr.diff-line-meta .diff-text {
    color: var(--fg-faint);
    font-style: italic;
}
.diff-empty {
    padding: 14px 16px;
    color: var(--fg-muted);
    font-size: 13px;
}

/* ------------------------------------------------------------ commit view */

.commit-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elevated);
    padding: 14px 16px;
    margin-bottom: 16px;
}
.commit-subject {
    font-size: 17px;
    font-weight: 650;
    margin: 0 0 8px;
    overflow-wrap: anywhere;
}
.commit-body {
    white-space: pre-wrap;
    font-family: var(--mono);
    font-size: 12.5px;
    color: var(--fg-muted);
    margin: 0 0 12px;
    max-height: 260px;
    overflow: auto;
}
.commit-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    font-size: 12.5px;
    color: var(--fg-muted);
}
.commit-meta .who {
    color: var(--fg);
    font-weight: 550;
}
.commit-hash {
    font-family: var(--mono);
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1px 6px;
    font-size: 12px;
    color: var(--fg-muted);
}

.stat-list {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elevated);
    overflow: hidden;
    margin-bottom: 18px;
}
.stat-row {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    padding: 6px 12px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: none;
    cursor: pointer;
    color: var(--fg);
}
.stat-row:last-child {
    border-bottom: 0;
}
.stat-row:hover {
    background: var(--bg-sunken);
}
.stat-path {
    font-family: var(--mono);
    font-size: 12.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.stat-bar {
    display: flex;
    gap: 1px;
    align-items: center;
}
.stat-bar i {
    display: inline-block;
    height: 9px;
    border-radius: 2px;
}
.stat-bar .add {
    background: var(--add);
}
.stat-bar .del {
    background: var(--del);
}
.stat-counts {
    font-family: var(--mono);
    font-size: 11.5px;
    white-space: nowrap;
    min-width: 96px;
    text-align: right;
}
.stat-counts .plus {
    color: var(--add);
}
.stat-counts .minus {
    color: var(--del);
}

/* ------------------------------------------------------------- git graph */

.git-shell {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}
.git-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
    flex: 0 0 auto;
}
.tabs {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.tabs button {
    border: 0;
    background: transparent;
    padding: 5px 12px;
    cursor: pointer;
    color: var(--fg-muted);
}
.tabs button:hover {
    background: var(--bg-sunken);
    color: var(--fg);
}
.tabs button[aria-selected="true"] {
    background: var(--primary);
    color: var(--primary-text);
    font-weight: 600;
}
.git-bar select {
    font-family: inherit;
    font-size: 12.5px;
    color: var(--fg);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    max-width: 260px;
}
.ref-input {
    font-family: var(--mono);
    font-size: 12.5px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--fg);
    width: 170px;
}
.ref-input:focus {
    outline: 2px solid color-mix(in srgb, var(--primary) 55%, transparent);
    outline-offset: 1px;
}

/* --------------------------------------------------------- file icons */

/* An icon is whatever the configuration says: a glyph in the current font, or an
 * image fetched from an icon source. Both have to sit right in a row. */
.icon-img {
    width: 14px;
    height: 14px;
    vertical-align: -2px;
    object-fit: contain;
}

.tree-icon .icon-img {
    vertical-align: -3px;
}

/* ------------------------------------------------------------- clone view */

/* One channel per row: a label, the URL, and a button that copies it. The input
 * takes the room the name does not. */
.clone-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}
.clone-channel {
    flex: 0 0 72px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--fg-faint);
}
.clone-url {
    flex: 1 1 auto;
    min-width: 0;
    font-family: var(--mono);
    font-size: 12.5px;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-sunken);
    color: var(--fg);
}
.clone-url:focus {
    outline: 2px solid color-mix(in srgb, var(--primary) 55%, transparent);
    outline-offset: 1px;
}
.git-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

/* ------------------------------------------------------------ status area */

/* The strip along the bottom of every git view: what is true of the repository
 * rather than of the page. It starts on the left with the language split, which
 * is the bar GitHub shows. */
.status-area {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 30px;
    padding: 5px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--fg-muted);
    font-size: 12px;
    flex: 0 0 auto;
    overflow: hidden;
}
.status-spacer {
    flex: 1 1 auto;
}
.lang-split {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.lang-bar {
    display: flex;
    flex: 0 0 auto;
    width: 180px;
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--bg-sunken);
}
/* A language can be a fraction of a percent: keep its segment visible anyway. */
.lang-seg {
    height: 100%;
    min-width: 3px;
}
.lang-seg.is-other,
.lang-dot.is-other {
    background: var(--fg-faint);
}
.lang-legend {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
}
.lang-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.lang-dot {
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* The spacer is sized to every loaded row; the SVG and the row window are
 * absolutely positioned inside it, so only the visible slice is in the DOM. */
.graph {
    position: relative;
}
.graph-canvas {
    position: absolute;
    left: 0;
    z-index: 0;
    pointer-events: none;
}
.graph-rows {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 1;
}
/* Page-fetch / error notice, floating over the rows. */
.graph-status {
    position: absolute;
    right: 16px;
    bottom: 12px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-elevated);
    box-shadow: var(--shadow);
    color: var(--fg-muted);
    font-size: 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 120ms ease;
}
.graph-status.is-on {
    opacity: 1;
}
.graph-row {
    display: flex;
    align-items: center;
    gap: 8px;
    height: var(--graph-row-h);
    padding-left: var(--graph-w, 140px);
    padding-right: 18px;
    border: 0;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
    background: transparent;
    width: 100%;
    text-align: left;
    cursor: pointer;
    color: var(--fg);
}
.graph-row:hover {
    background: color-mix(in srgb, var(--primary) 10%, transparent);
}
.graph-row .subject {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1 1 auto;
}
.graph-row .author {
    color: var(--fg-faint);
    font-size: 12px;
    white-space: nowrap;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.graph-row .when {
    color: var(--fg-faint);
    font-size: 12px;
    white-space: nowrap;
    width: 90px;
    text-align: right;
}
.graph-row .hash {
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--fg-faint);
    width: 66px;
    text-align: right;
}

.ref-chip {
    flex: 0 0 auto;
    font-size: 10.5px;
    font-family: var(--mono);
    border-radius: 999px;
    padding: 1px 7px;
    border: 1px solid var(--border);
    color: var(--fg-muted);
    background: var(--bg-elevated);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ref-chip.head {
    background: var(--primary);
    border-color: color-mix(in srgb, var(--primary) 60%, var(--fg));
    color: var(--primary-text);
    font-weight: 600;
}
.ref-chip.tag {
    color: var(--tok-number);
    border-color: color-mix(in srgb, var(--tok-number) 45%, var(--border));
}
.ref-chip.remote {
    color: var(--tok-function);
    border-color: color-mix(in srgb, var(--tok-function) 40%, var(--border));
}

/* -------------------------------------------------------------- git tree */

.tree-page {
    padding: 16px 20px 60px;
}
.tree-entries {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-elevated);
}
.tree-entry {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr) 90px 90px 150px;
    gap: 10px;
    align-items: center;
    width: 100%;
    text-align: left;
    padding: 6px 12px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: none;
    cursor: pointer;
    color: var(--fg);
}
.tree-entry:last-child {
    border-bottom: 0;
}
.tree-entry:hover {
    background: var(--bg-sunken);
}
.tree-entry .e-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--mono);
    font-size: 12.5px;
}
.tree-entry.is-dir .e-name {
    font-weight: 600;
}
.tree-entry .e-meta {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--fg-faint);
    text-align: right;
    white-space: nowrap;
}

/* ----------------------------------------------------------------- blame */

.blame-table {
    border-collapse: collapse;
    width: 100%;
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.6;
}
.blame-table td {
    padding: 0 8px;
    vertical-align: top;
    white-space: pre;
}
.blame-table tr:hover td {
    background: color-mix(in srgb, var(--primary) 12%, transparent);
}
.blame-meta {
    border-right: 1px solid var(--border);
    color: var(--fg-faint);
    user-select: none;
    white-space: nowrap;
    min-width: 230px;
}
.blame-meta .b-hash {
    color: var(--fg-muted);
}
.blame-gutter {
    text-align: right;
    color: var(--fg-faint);
    user-select: none;
    width: 1%;
    font-variant-numeric: tabular-nums;
    border-right: 1px solid var(--border);
}
.blame-code {
    padding-left: 12px !important;
    width: 100%;
}
.blame-group-start td {
    border-top: 1px solid var(--border);
}
.blame-color-0 .b-hash {
    color: var(--primary);
}

/* ------------------------------------------------------------- markdown */

.markdown {
    line-height: 1.7;
    max-width: 940px;
    overflow-wrap: anywhere;
}
.markdown > :first-child {
    margin-top: 0;
}
.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4,
.markdown h5,
.markdown h6 {
    line-height: 1.3;
    margin: 1.5em 0 0.6em;
    font-weight: 650;
    scroll-margin-top: 12px;
}
.markdown h1 {
    font-size: 1.75em;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.25em;
}
.markdown h2 {
    font-size: 1.35em;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.2em;
}
.markdown h3 {
    font-size: 1.15em;
}
.markdown h4 {
    font-size: 1.02em;
}
.markdown p {
    margin: 0.85em 0;
}
.markdown ul,
.markdown ol {
    margin: 0.85em 0;
    padding-left: 1.6em;
}
.markdown li {
    margin: 0.25em 0;
}
.markdown li > ul,
.markdown li > ol {
    margin: 0.25em 0;
}
.markdown a {
    color: var(--link);
}
.markdown code {
    font-family: var(--mono);
    font-size: 0.9em;
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.08em 0.35em;
}
.markdown pre {
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    overflow: auto;
    margin: 0.95em 0;
}
.markdown pre code {
    background: none;
    border: 0;
    padding: 0;
    font-size: 12.5px;
    line-height: 1.6;
}
.markdown blockquote {
    margin: 0.95em 0;
    padding: 0.1em 0 0.1em 1em;
    border-left: 3px solid color-mix(in srgb, var(--primary) 60%, var(--border));
    color: var(--fg-muted);
}
.markdown img {
    max-width: 100%;
    height: auto;
}
.markdown table {
    border-collapse: collapse;
    display: block;
    overflow: auto;
    max-width: 100%;
    margin: 0.95em 0;
}
.markdown th,
.markdown td {
    border: 1px solid var(--border);
    padding: 5px 10px;
}
.markdown th {
    background: var(--bg-sunken);
}
.markdown hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 1.6em 0;
}
.markdown .task {
    list-style: none;
    margin-left: -1.25em;
}
.markdown .task .box {
    color: var(--link);
}
.markdown details {
    margin: 0.95em 0;
}
.markdown summary {
    cursor: pointer;
    font-weight: 600;
}

/* ------------------------------------------------------------ misc bits */

.empty-state {
    padding: 60px 20px;
    text-align: center;
    color: var(--fg-muted);
}
.empty-state .big {
    font-size: 34px;
    margin-bottom: 10px;
}

.error-box {
    margin: 20px;
    padding: 14px 16px;
    border: 1px solid color-mix(in srgb, var(--del) 50%, var(--border));
    background: var(--del-bg);
    color: var(--fg);
    border-radius: var(--radius);
    font-family: var(--mono);
    font-size: 12.5px;
    white-space: pre-wrap;
}

.toast {
    position: fixed;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--fg);
    color: var(--bg);
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 12.5px;
    z-index: 20;
    opacity: 0.95;
}

.muted {
    color: var(--fg-muted);
}
.faint {
    color: var(--fg-faint);
}
.mono {
    font-family: var(--mono);
}
.nowrap {
    white-space: nowrap;
}

@media (max-width: 820px) {
    .sidebar {
        width: 220px;
    }
    .listing-row {
        grid-template-columns: 20px minmax(0, 1fr) 90px;
    }
    .listing-row .l-time {
        display: none;
    }
    /* The tree view's mode/size/hash columns are fixed widths that add up to
     * more than a phone is wide, so the name column would get nothing. Drop the
     * hash first and let the other two shrink. */
    .tree-entry {
        grid-template-columns: 18px minmax(0, 1fr) 64px 72px;
        gap: 8px;
    }
    .tree-entry .e-meta:last-child {
        display: none;
    }
    .graph-row .author {
        display: none;
    }
}

/* ---------------------------------------------------------------- mobile */

/* Below this the sidebar is a drawer: it slides in over the page and is put
 * away by the scrim, Escape, or following any link. */
.nav-toggle {
    display: none;
}
.scrim {
    display: none;
}

@media (max-width: 720px) {
    .nav-toggle {
        display: inline-flex;
    }

    .topbar {
        height: 44px;
        gap: 6px;
        padding: 0 8px;
    }
    .brand-name {
        display: none;
    }
    .repo-badge {
        max-width: 120px;
    }

    .layout {
        position: relative;
        overflow: hidden;
    }
    .sidebar {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 12;
        width: min(84vw, 320px);
        transform: translateX(-102%);
        transition: transform 0.2s ease;
        border-right: 1px solid var(--border);
        box-shadow: var(--shadow);
    }
    body.nav-open .sidebar {
        transform: none;
    }
    /* Collapsing has no meaning for a drawer, and its toggle would be hidden
     * under the drawer anyway. */
    .sidebar.collapsed {
        width: min(84vw, 320px);
        overflow: visible;
        border-right-color: var(--border);
    }
    #side-collapse {
        display: none;
    }
    body.nav-open .scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 11;
        background: rgb(0 0 0 / 0.35);
    }

    .panel {
        padding: 12px 12px 48px;
    }
    .git-bar {
        padding: 8px 12px;
        gap: 8px;
    }
    .code-scroll {
        max-height: calc(100dvh - 170px);
    }
    .graph-row {
        padding-right: 12px;
    }
    /* The bar stays, the names of the languages do not: a phone has room for
     * one of them. */
    .lang-legend {
        display: none;
    }
    .lang-bar {
        width: 120px;
    }
}

@media (max-width: 520px) {
    .listing-row {
        grid-template-columns: 20px minmax(0, 1fr);
    }
    .listing-row .l-size {
        display: none;
    }
    /* Nothing but the name fits beside a tree row's icon on a phone. */
    .tree-entry {
        grid-template-columns: 18px minmax(0, 1fr);
    }
    .tree-entry .e-meta {
        display: none;
    }
    /* There is no room for a tag beside the name on a phone, so the name says
     * what it is instead: "Git: somerepo.git". */
    .listing-row .tree-git {
        display: none;
    }
    .listing-row.is-repo .l-name::before {
        content: "Git: ";
        color: var(--fg-faint);
    }
    .repo-badge {
        display: none;
    }
    .graph-row .when {
        display: none;
    }
    .tabs button {
        padding: 5px 9px;
    }
}

/* Fingers need bigger targets than a mouse does. */
@media (pointer: coarse) {
    .btn {
        padding: 7px 13px;
    }
    .btn.icon {
        padding: 7px 10px;
    }
    .listing-row {
        padding: 10px 12px;
    }
    .tree-toggle {
        width: 26px;
        height: 30px;
    }
    .tree-label {
        padding: 6px 6px 6px 0;
    }
}
