/* Forge. One stylesheet, no framework.
   Colours are tokens written as light-dark(light, dark). The page follows the system setting
   unless the visitor picked a theme, which theme.js stores as <html data-theme="light|dark">. */

:root {
    color-scheme: light dark;

    --bg: light-dark(#ffffff, #0f1318);
    --surface: light-dark(#f6f7f9, #161b22);
    --surface-2: light-dark(#eceff3, #1f2630);
    --border: light-dark(#d8dce3, #2b3440);
    --border-strong: light-dark(#b4bcc8, #445061);
    --text: light-dark(#171b22, #e3e8ee);
    --muted: light-dark(#5b6472, #95a1b0);
    --link: light-dark(#0b5fca, #74b0ff);
    --accent: light-dark(#c2410c, #fb923c);
    --accent-soft: light-dark(#fff1e8, #2e1d10);
    --primary: light-dark(#c2410c, #c9480f);
    --primary-hover: light-dark(#a3360a, #dd5514);
    --primary-text: #ffffff;
    --danger: light-dark(#b3261e, #ff7b72);
    --add-bg: light-dark(#e3f6e8, #14321f);
    --add-text: light-dark(#136c32, #7ee2a0);
    --add-strong: light-dark(#abe7b9, #1f6b3a);
    --del-bg: light-dark(#fde8e6, #3d1a1a);
    --del-text: light-dark(#a4231c, #ffa198);
    --del-strong: light-dark(#f8b8b3, #7d2a2a);
    --hunk-bg: light-dark(#eaf1fb, #1b2a40);
    --warn-bg: light-dark(#fff4d6, #3a3012);
    --warn-text: light-dark(#6b4e00, #f2d27a);
    --target-bg: light-dark(#fff3bf, #4a3f10);
    --merged-bg: light-dark(#ebe2fb, #2e2350);
    --merged-text: light-dark(#5b2fa6, #c9b2ff);
    --shadow: 0 8px 28px light-dark(rgba(23, 27, 34, 0.14), rgba(0, 0, 0, 0.5));
    --shadow-small: 0 1px 2px light-dark(rgba(23, 27, 34, 0.06), rgba(0, 0, 0, 0.3));
    --focus: light-dark(#0b5fca, #74b0ff);

    --radius: 8px;
    --radius-small: 6px;
    --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, "Liberation Mono", monospace;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

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

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

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.5;
}

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

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

h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 0.5rem; letter-spacing: -0.01em; text-wrap: balance; }
h2 { font-size: 1.15rem; line-height: 1.3; margin: 0 0 0.75rem; }
h3 { font-size: 1rem; margin: 1.5rem 0 0.5rem; }

code, pre, kbd { font-family: var(--mono); font-size: 0.87rem; }
code { background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }
pre code { background: none; padding: 0; }
kbd {
    display: inline-block;
    min-width: 1.5em;
    padding: 0 5px;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 4px;
    background: var(--bg);
    color: var(--muted);
    font-size: 0.75rem;
    line-height: 1.5;
    text-align: center;
}

svg.icon {
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: -0.15em;
}
svg.icon.logo-mark { fill: var(--accent); stroke: none; }

html:not(.js) .js-only { display: none !important; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 20px; }
main.wrap { flex: 1; padding-top: 24px; padding-bottom: 56px; }
.narrow {
    max-width: 440px;
    margin: 40px auto;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-small);
}
.auth-logo { margin-bottom: 12px; }

.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; padding: 6px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-small); }
.skip-link:focus { left: 8px; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.right { text-align: right; }
.break { overflow-wrap: anywhere; }
.danger-text { color: var(--danger); }
.added { color: var(--add-text); }
.deleted { color: var(--del-text); }
.sep { color: var(--muted); margin: 0 0.25rem; }

/* Top bar */
.topbar { border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar-inner { display: flex; align-items: center; gap: 16px; min-height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; letter-spacing: -0.01em; color: var(--text); }
.brand:hover { text-decoration: none; }
.topnav { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.inline-form { display: inline; margin: 0; }
.link-button { background: none; border: 0; padding: 0; color: var(--link); font: inherit; cursor: pointer; }
.link-button:hover { text-decoration: underline; }

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid transparent;
    border-radius: var(--radius-small);
    background: none;
    color: var(--muted);
    cursor: pointer;
}
.icon-button:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.theme-icon { display: none; }
:root:not([data-theme]) .theme-icon-auto,
:root[data-theme="light"] .theme-icon-light,
:root[data-theme="dark"] .theme-icon-dark { display: inline; }

/* Search box: an icon, the field, and an optional key hint, drawn as one control. */
.search {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    max-width: 380px;
    margin: 0;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    background: var(--bg);
    color: var(--muted);
}
.search:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.search input[type="search"] {
    flex: 1;
    min-width: 0;
    padding: 6px 0;
    border: 0;
    outline: 0;
    background: none;
    color: var(--text);
    font: inherit;
}

/* Dropdown menus are <details>; app.js closes them on outside click and Escape. */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-button { display: inline-flex; align-items: center; gap: 4px; padding: 3px 6px 3px 3px; border-radius: 999px; color: var(--muted); }
.menu-button:hover { background: var(--surface-2); }
.menu-panel {
    position: absolute;
    z-index: 30;
    top: calc(100% + 6px);
    left: 0;
    min-width: 220px;
    padding: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.menu-panel.menu-right { left: auto; right: 0; }
.menu-header { margin: 0 0 6px; padding: 6px 10px 8px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 0.85rem; }
.menu-header strong { color: var(--text); }
.menu-form { margin: 6px 0 0; padding-top: 6px; border-top: 1px solid var(--border); }
.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 6px 10px;
    border: 0;
    border-radius: var(--radius-small);
    background: none;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); text-decoration: none; }
.menu-item svg.icon { color: var(--muted); }

/* Avatars */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    border-radius: 50%;
    color: #ffffff;
    font-weight: 700;
    line-height: 1;
    user-select: none;
}
.avatar-sm { width: 20px; height: 20px; font-size: 0.7rem; }
.avatar-md { width: 28px; height: 28px; font-size: 0.85rem; }
.avatar-lg { width: 72px; height: 72px; font-size: 2rem; }
.avatar-c0 { background: #c2410c; }
.avatar-c1 { background: #0f766e; }
.avatar-c2 { background: #1d4ed8; }
.avatar-c3 { background: #7c3aed; }
.avatar-c4 { background: #be185d; }
.avatar-c5 { background: #4d7c0f; }
.avatar-c6 { background: #a16207; }
.avatar-c7 { background: #475569; }

/* Footer */
.footer { border-top: 1px solid var(--border); font-size: 0.85rem; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 12px 24px; flex-wrap: wrap; padding-top: 16px; padding-bottom: 20px; }
.footer-brand { display: inline-flex; align-items: center; gap: 6px; }
.language-form { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 0; }
.language-label { display: inline-flex; align-items: center; gap: 5px; }

/* Buttons and forms */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 500;
    line-height: 1.4;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: var(--shadow-small);
}
.button:hover { text-decoration: none; border-color: var(--border-strong); background: var(--surface-2); }
.button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 55%, var(--border)); background: transparent; }
.button.danger:hover { background: var(--del-bg); border-color: var(--danger); }
.button.small { padding: 2px 8px; font-size: 0.85rem; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 4px; font-weight: 600; }
.form label.choice { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.form small { font-weight: 400; }
.form button { justify-self: start; }
input[type="text"], input[type="password"], input[type="url"], input:not([type]), select, textarea {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    background: var(--bg);
    color: var(--text);
    font: inherit;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="url"]:focus, input:not([type]):focus, select:focus, textarea:focus {
    outline: 0;
    border-color: var(--focus);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent);
}
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }
textarea { resize: vertical; }
textarea.code-input { font-family: var(--mono); font-size: 0.85rem; white-space: pre; overflow-x: auto; tab-size: 4; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-small); padding: 8px 12px; margin: 0; display: grid; gap: 6px; }
legend { font-weight: 600; padding: 0 4px; }

.card { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 16px 0; }
.card.empty, .empty { text-align: center; color: var(--muted); padding: 32px 16px; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 60%, var(--border)); }
details.card > summary { cursor: pointer; }
details.card[open] > summary { margin-bottom: 12px; }

.empty-state { padding: 56px 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius); text-align: center; color: var(--muted); }
.empty-state h2 { margin: 12px 0 4px; color: var(--text); font-size: 1.05rem; }
.empty-state p { margin: 4px 0 0; }

.alert { padding: 10px 14px; border-radius: var(--radius-small); margin: 12px 0; border: 1px solid var(--border); }
.alert.error { background: var(--del-bg); color: var(--del-text); border-color: transparent; }
.alert.success { background: var(--add-bg); color: var(--add-text); border-color: transparent; }
.alert.warning { background: var(--warn-bg); color: var(--warn-text); border-color: transparent; }
.alert p { margin: 0 0 8px; }
.alert p:last-child { margin-bottom: 0; }
.alert ul { margin: 4px 0 0; padding-left: 20px; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.6;
    color: var(--muted);
    vertical-align: middle;
    white-space: nowrap;
}
.badge-added { background: var(--add-bg); color: var(--add-text); border-color: transparent; }
.badge-deleted { background: var(--del-bg); color: var(--del-text); border-color: transparent; }
.badge-merged { background: var(--merged-bg); color: var(--merged-text); border-color: transparent; }
.counter { min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 0.75rem; font-weight: 600; line-height: 1.6; text-align: center; }

/* Tables */
.table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.table th.right, .table td.right { text-align: right; }
.table tbody tr:hover { background: var(--surface); }
.table td.actions { white-space: nowrap; }
.table td.actions .button { margin-left: 4px; }
.table.tree { border: 1px solid var(--border); border-radius: var(--radius); border-collapse: separate; border-spacing: 0; }
.table.tree tr:last-child td { border-bottom: 0; }
.table.tree td { vertical-align: middle; }
.table.tree td.icon { width: 28px; padding-right: 0; color: var(--muted); }
.table.tree .name { overflow-wrap: anywhere; }

/* Home and profile */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.page-head h1, .page-head h2 { margin-bottom: 0; }
.page-sub { margin: 2px 0 0; }
.profile { display: flex; align-items: center; gap: 20px; margin-bottom: 28px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.profile h1 { margin-bottom: 2px; }
.profile p { margin: 0; }
.filter-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.filter-search { max-width: 420px; min-width: 200px; }
.repo-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); }
.repo-row { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.repo-row:last-child { border-bottom: 0; }
.repo-row:hover { background: var(--surface); }
.repo-row:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.repo-row:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.repo-icon { display: inline-flex; padding-top: 3px; color: var(--muted); }
.repo-main { flex: 1; min-width: 0; }
.repo-link { font-size: 1.05rem; overflow-wrap: anywhere; }
.repo-row-description { margin: 2px 0 0; }
.repo-meta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-top: 3px; white-space: nowrap; }
.meta-item { display: inline-flex; align-items: center; gap: 5px; }

/* Repository header */
.repo-head { margin-bottom: 16px; }
.repo-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 1.3rem; font-weight: 400; }
.repo-title > svg.icon { color: var(--muted); }
.repo-title .sep { margin: 0; }
.repo-name { font-weight: 700; }
.repo-description { margin: 0 0 8px; }
.repo-bar { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; color: var(--text); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab svg.icon { color: var(--muted); }
.tab:hover { text-decoration: none; border-bottom-color: var(--border-strong); }
.tab.active { border-bottom-color: var(--accent); font-weight: 600; }
.tab.active svg.icon { color: var(--text); }
.subtabs { display: flex; gap: 4px; margin: 12px 0; }
.subtabs a { padding: 4px 12px; border-radius: 999px; color: var(--muted); }
.subtabs a:hover { background: var(--surface); text-decoration: none; color: var(--text); }
.subtabs .active { background: var(--surface-2); font-weight: 600; color: var(--text); }

.clone-menu { margin-bottom: 6px; }
.clone-panel { width: min(380px, calc(100vw - 28px)); padding: 12px; }
.clone-title { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; font-weight: 600; }
.clone-hint { margin: 8px 0 0; }
.clone-box { display: flex; gap: 6px; min-width: 0; }
.clone-url { flex: 1; min-width: 0; font-family: var(--mono); font-size: 0.82rem; }
.copied, .copied svg.icon { color: var(--add-text); }

/* Repository home: files on the left, facts about the repository on the right. */
.repo-layout.with-side { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 32px; align-items: start; }
.repo-content { min-width: 0; }
.repo-side { margin-top: 12px; }
.side-section { padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.side-section:last-child { border-bottom: 0; }
.side-section h2 { font-size: 1rem; }
.side-section p { margin: 0 0 12px; overflow-wrap: anywhere; }
.side-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.side-list li { display: flex; align-items: center; gap: 8px; }
.side-list svg.icon { color: var(--muted); }
.side-list a { color: var(--text); }
.side-list a:hover { color: var(--link); }

.lang-bar { display: block; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.lang-bar rect { fill: var(--lang); }
.lang-legend { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.85rem; }
.lang-legend li { display: inline-flex; align-items: center; gap: 6px; }
.lang-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--lang); }
.lang-csharp { --lang: #178600; }
.lang-javascript { --lang: #d4b830; }
.lang-typescript { --lang: #3178c6; }
.lang-html { --lang: #e34c26; }
.lang-css { --lang: #7e57c2; }
.lang-python { --lang: #3572a5; }
.lang-go { --lang: #00add8; }
.lang-rust { --lang: #dea584; }
.lang-java { --lang: #b07219; }
.lang-kotlin { --lang: #a97bff; }
.lang-swift { --lang: #f05138; }
.lang-c { --lang: #6e7681; }
.lang-cpp { --lang: #f34b7d; }
.lang-ruby { --lang: #a51d2d; }
.lang-php { --lang: #6e7bb8; }
.lang-lua { --lang: #3b4fc4; }
.lang-shell { --lang: #5fb233; }
.lang-powershell { --lang: #2b5797; }
.lang-sql { --lang: #e38c00; }
.lang-vb { --lang: #945db7; }
.lang-other { --lang: #8b949e; }

/* Toolbar: ref switcher, breadcrumbs */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
.toolbar-end { margin-left: auto; }
.breadcrumbs { overflow-wrap: anywhere; }

.ref-switcher { position: relative; }
.ref-switcher summary { list-style: none; }
.ref-switcher summary::-webkit-details-marker { display: none; }
.ref-menu {
    position: absolute;
    z-index: 10;
    top: calc(100% + 4px);
    left: 0;
    min-width: 240px;
    max-height: 360px;
    overflow-y: auto;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    box-shadow: var(--shadow);
}
.ref-menu-title { margin: 6px 8px 2px; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.ref-item { display: block; padding: 4px 8px; border-radius: 4px; color: var(--text); overflow-wrap: anywhere; }
.ref-item:hover { background: var(--surface-2); text-decoration: none; }
.ref-item.active { font-weight: 700; }

/* The file list: the newest commit as its header, then one row per entry. */
.file-box { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.file-box .table.tree { margin: 0; border: 0; border-radius: 0; }
.latest-commit {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.latest-subject { display: flex; align-items: center; gap: 8px; min-width: 0; }
.latest-subject strong { white-space: nowrap; }
.latest-message { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.latest-meta { white-space: nowrap; }
.icon-folder { color: var(--link); fill: color-mix(in srgb, var(--link) 22%, transparent); }
.table.tree .tree-commit { width: 45%; max-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table.tree .tree-age { white-space: nowrap; }
.readme-name { display: flex; align-items: center; gap: 8px; margin: -16px -16px 16px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface); border-radius: var(--radius) var(--radius) 0 0; font-weight: 600; }
.sha { font-family: var(--mono); font-size: 0.85rem; }

/* Search inside a repository */
.repo-search { flex: 0 1 300px; min-width: 180px; }
form.toolbar .repo-search { flex: 1 1 300px; max-width: 520px; }
.result-heading { display: flex; align-items: center; gap: 8px; margin-top: 24px; }
.result-heading svg.icon { color: var(--muted); }
.result-files { list-style: none; margin: 8px 0; padding: 4px 0; border: 1px solid var(--border); border-radius: var(--radius); }
.result-files li { display: flex; align-items: center; gap: 8px; padding: 4px 12px; overflow-wrap: anywhere; }
.result-files svg.icon { color: var(--muted); }
.result-file { margin: 12px 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.result-file-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border); font-family: var(--mono); font-size: 0.87rem; overflow-wrap: anywhere; }
.result-file-head svg.icon { color: var(--muted); }
.result-lines { display: block; overflow-x: auto; border-collapse: collapse; font-family: var(--mono); font-size: 0.85rem; padding: 4px 0; }
.result-lines td { padding: 1px 10px; vertical-align: top; }
.result-lines .ln { min-width: 52px; text-align: right; user-select: none; white-space: nowrap; }
.result-lines .ln a { color: var(--muted); }
.result-code { white-space: pre; tab-size: 4; }
mark { background: var(--target-bg); color: inherit; border-radius: 2px; }

/* README and markdown */
.markdown { overflow-wrap: anywhere; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown img { max-width: 100%; }
.markdown pre, .snippet, .plain, .commit-body {
    background: var(--surface);
    border-radius: var(--radius-small);
    padding: 12px;
    overflow-x: auto;
}
.plain, .commit-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.markdown table { border-collapse: collapse; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 4px 10px; }
.markdown blockquote { margin: 0; padding-left: 12px; border-left: 3px solid var(--border); color: var(--muted); }
.markdown h1, .markdown h2 { border-bottom: 1px solid var(--border); padding-bottom: 4px; margin-top: 1.2em; }

/* File view */
.file-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: var(--radius) var(--radius) 0 0;
    background: var(--surface);
}
.file-info { display: flex; align-items: center; gap: 8px; min-width: 0; }
.file-info svg.icon { color: var(--muted); }
.file-name { overflow-wrap: anywhere; }
.file-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.file-actions .segmented { font-size: 0.85rem; margin-right: 6px; }
.file-actions .segmented a { padding: 2px 10px; }
.file-head + .card, .file-head + .code-view { margin-top: 0; border-radius: 0 0 var(--radius) var(--radius); }
.file-preview { padding: 24px 32px; }
.code-view { position: relative; display: flex; border: 1px solid var(--border); overflow-x: auto; }
.code-view pre { position: relative; margin: 0; padding: 10px 0; line-height: 1.45; }
.line-numbers { text-align: right; user-select: none; border-right: 1px solid var(--border); flex: none; }
.line-numbers a { display: block; padding: 0 10px; color: var(--muted); }
.line-numbers a:hover { color: var(--text); text-decoration: none; }
html:not(.js) .line-numbers a:target, .line-numbers a.selected { background: var(--target-bg); color: var(--text); font-weight: 700; }
.line-highlight { position: absolute; left: 0; background: var(--target-bg); pointer-events: none; }
.button-group { display: inline-flex; }
.button-group .button { border-radius: 0; }
.button-group .button + .button { margin-left: -1px; }
.button-group .button:first-child { border-radius: var(--radius-small) 0 0 var(--radius-small); }
.button-group .button:last-child { border-radius: 0 var(--radius-small) var(--radius-small) 0; }
.icon-button.inline { width: 24px; height: 24px; vertical-align: middle; }
.code-view .code { padding-left: 12px; padding-right: 12px; flex: 1; tab-size: 4; }
.code-view .code code.hljs { padding: 0; background: none; overflow: visible; }
.image-view { text-align: center; }
.image-view img { max-width: 100%; }

/* Commits */
.commit-list { list-style: none; margin: 12px 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); }
.commit-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.commit-row:last-child { border-bottom: 0; }
.commit-row:hover { background: var(--surface); }
.commit-main { min-width: 0; }
.commit-day { display: flex; align-items: center; gap: 8px; margin: 20px 0 0; color: var(--muted); font-size: 0.9rem; font-weight: 600; }
.commit-day + .commit-list { margin-top: 8px; }
.commit-byline { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.commit-byline .sep { margin: 0; }
.commit-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.meta dd .avatar { vertical-align: -4px; }
.commit-subject { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.pager { display: flex; gap: 8px; justify-content: center; margin: 16px 0; }
.commit-title { overflow-wrap: anywhere; }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 12px 0; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; overflow-wrap: anywhere; }
.meta .sha { margin-right: 8px; }
.stat-list { list-style: none; margin: 8px 0 16px; padding: 0; }
.stat-list li { display: flex; gap: 12px; padding: 2px 0; overflow-wrap: anywhere; }
.stat-counts { flex: none; min-width: 90px; font-family: var(--mono); font-size: 0.85rem; }
.comment { margin: 8px 0; }
.comment p:first-child { margin-top: 0; }

/* Diff */
.diff-file { border: 1px solid var(--border); border-radius: var(--radius); margin: 16px 0; overflow: hidden; }
.diff-file-head { display: flex; gap: 10px; align-items: center; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
.diff-path { font-family: var(--mono); font-size: 0.87rem; overflow-wrap: anywhere; flex: 1; }
.diff-counts { font-family: var(--mono); font-size: 0.85rem; white-space: nowrap; }
.diff-note { margin: 0; padding: 12px; }
.diff { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 0.85rem; display: block; overflow-x: auto; }
.diff td { padding: 0 8px; vertical-align: top; }
.diff .ln { width: 1%; min-width: 44px; text-align: right; color: var(--muted); user-select: none; white-space: nowrap; }
.diff .diff-code { white-space: pre; width: 100%; }
.diff .marker { display: inline-block; width: 1.2em; user-select: none; }
.diff tr.add { background: var(--add-bg); }
.diff tr.del { background: var(--del-bg); }
.diff tr.hunk { background: var(--hunk-bg); color: var(--muted); }
.diff tr.meta { color: var(--muted); font-style: italic; }

/* Diff: options, file index, collapsible files, side-by-side layout, within-line changes */
.diff-options { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin: 8px 0 12px; font-size: 0.9rem; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-small); overflow: hidden; }
.segmented a { padding: 4px 12px; color: var(--text); }
.segmented a + a { border-left: 1px solid var(--border); }
.segmented a.active { background: var(--surface-2); font-weight: 600; }
.segmented a:hover { text-decoration: none; background: var(--surface); }
.diff-index { list-style: none; margin: 8px 0 16px; padding: 0; }
.diff-index li { display: flex; gap: 12px; padding: 2px 0; overflow-wrap: anywhere; }
details.diff-file > summary { cursor: pointer; list-style-position: inside; }
details.diff-file:not([open]) > summary { border-bottom: 0; }
.diff.split .diff-code { width: 50%; }
.diff.split td.add { background: var(--add-bg); }
.diff.split td.del { background: var(--del-bg); }
.diff.split td.blank { background: var(--surface); }
.diff.split td.ln + td.diff-code { border-right: 1px solid var(--border); }
.diff .chg { border-radius: 2px; }
.diff tr.add .chg, .diff td.add .chg { background: var(--add-strong); }
.diff tr.del .chg, .diff td.del .chg { background: var(--del-strong); }
.diff .line .hljs, .diff .line { background: none; }

/* Compare, conflicts and ref management */
.compare-form label { display: flex; align-items: center; gap: 6px; }
.compare-form select { width: auto; max-width: 260px; }
fieldset.conflict { margin-bottom: 12px; }
.apply-form { margin: 12px 0 0; }
.apply-form label { display: flex; align-items: center; gap: 6px; }
.apply-form select { width: auto; max-width: 260px; }

/* Pull requests */
.pull-icon { display: inline-flex; flex: none; }
.pull-open { color: var(--add-text); }
.pull-merged { color: var(--merged-text); }
.pull-closed { color: var(--del-text); }
.pull-main { flex: 1; }
.pull-title { font-size: 1.4rem; margin-bottom: 8px; }
.pull-summary { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 16px; }
.commit-byline { flex-wrap: wrap; }
.comment-head { margin: 0 0 8px; }
.cell-icon { color: var(--muted); margin-right: 4px; }

/* Activity: stat tiles, the weekly chart, contributors */
.activity-scope { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 0 0 16px; }
.stat-tile { padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); }
.stat-tile dt { color: var(--muted); font-size: 0.85rem; }
.stat-tile dd { margin: 4px 0 0; font-size: 1.7rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.stat-tile dd.stat-date { font-size: 1.25rem; line-height: 1.65; }
.chart-sub { margin: -8px 0 12px; }
.chart-scroll { overflow-x: auto; }
.week-chart { display: block; width: 100%; min-width: 620px; height: auto; }
.chart-grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 2 3; }
.chart-axis { stroke: var(--border-strong); stroke-width: 1; }
.chart-label { fill: var(--muted); font-size: 10px; font-family: var(--sans); }
.week-hit { fill: transparent; }
.week-bar { fill: var(--accent); }
.week:hover .week-hit { fill: var(--surface-2); }
.section-title { display: flex; align-items: center; gap: 8px; margin-top: 28px; }
.contributor-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); }
.contributor { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.contributor:last-child { border-bottom: 0; }
.contributor-main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.contributor-share { width: 180px; flex: none; text-align: right; }
.share-bar { display: block; margin-top: 4px; border-radius: 999px; background: var(--surface-2); }
.share-bar rect { fill: var(--accent); }

/* Dialogs */
.dialog { width: min(420px, calc(100vw - 32px)); padding: 20px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--text); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.shortcut-list { display: grid; grid-template-columns: max-content 1fr; gap: 10px 16px; margin: 0 0 20px; align-items: center; }
.shortcut-list dd { margin: 0; }
.footer-link { margin-left: 12px; }

/* Status pages */
.status-action { margin-top: 24px; }
.status-page { text-align: center; padding: 72px 0; }
.status-code { font-size: 4rem; font-weight: 800; line-height: 1; letter-spacing: -0.03em; margin: 0 0 12px; color: var(--accent); }

@media (max-width: 900px) {
    .repo-layout.with-side { grid-template-columns: minmax(0, 1fr); gap: 8px; }
}

@media (max-width: 720px) {
    .wrap { padding: 0 14px; }
    .table.tree .tree-commit, .latest-message { display: none; }
    .file-head { flex-wrap: wrap; }
    .file-preview { padding: 16px; }
    .file-box .table.tree { display: table; }
    .repo-row { flex-wrap: wrap; }
    .repo-meta { width: 100%; padding-left: 30px; }
    .commit-row { flex-direction: column; align-items: flex-start; gap: 4px; }
    .clone-url { width: 100%; }
    .clone-box { width: 100%; }
    .table { display: block; overflow-x: auto; }
    .search kbd { display: none; }
    .narrow { margin: 16px auto; padding: 20px; }
    .profile { gap: 14px; }
}

@media (prefers-reduced-motion: no-preference) {
    .button, .icon-button, .menu-item, .tab { transition: background-color 0.12s, border-color 0.12s, color 0.12s; }
}
