/* Browser interface contract: docs/specs/2026-10-16-browser-interface.md */

/* Tokens */

:root {
  color-scheme: light dark;
  --font-sans: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 6px;
  --radius-large: 8px;
  --control: 32px;
  --row: 22px; /* diff-view.js and browse.js position rows in 22px steps */
  --sidebar: 248px;
  --content-width: 1280px;

  --bg: #ffffff;
  --bg-subtle: #f6f8fa;
  --bg-muted: #eceff3;
  --border: #d0d7de;
  --border-muted: #e4e8ec;
  --text: #1f2328;
  --text-muted: #57606a;
  --accent: #1a5fd0;
  --accent-subtle: #e8f0fd;
  --primary: #1a5fd0;
  --primary-hover: #154fae;
  --primary-text: #ffffff;
  --success: #17733a;
  --success-subtle: #e2f5e7;
  --warning: #7a5000;
  --warning-subtle: #fff6d9;
  --warning-border: #e2c46b;
  --danger: #c0272f;
  --danger-subtle: #fdeceb;
  --danger-border: #eeb4b7;
  --diff-add: #e7f7eb;
  --diff-add-gutter: #cdeed6;
  --diff-del: #fdeceb;
  --diff-del-gutter: #f8d5d3;
  --line-highlight: rgb(255 200 40 / 24%);
  --shadow: 0 1px 2px rgb(31 35 40 / 6%), 0 8px 24px rgb(31 35 40 / 14%);
  --backdrop: rgb(31 35 40 / 45%);
  --code-comment: #6a737d;
  --code-keyword: #cf222e;
  --code-string: #0a3069;
  --code-number: #0550ae;
  --code-title: #6639ba;
  --code-type: #953800;
  --code-attr: #0550ae;
  --code-meta: #57606a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1217;
    --bg-subtle: #161a21;
    --bg-muted: #1f242d;
    --border: #2f3641;
    --border-muted: #252b34;
    --text: #e4e8ee;
    --text-muted: #9aa4b1;
    --accent: #72a7ff;
    --accent-subtle: #182841;
    --primary: #72a7ff;
    --primary-hover: #94bcff;
    --primary-text: #0b1526;
    --success: #5cc47c;
    --success-subtle: #132d1d;
    --warning: #e2b84a;
    --warning-subtle: #2b2312;
    --warning-border: #5e4b1d;
    --danger: #f2756d;
    --danger-subtle: #321a1c;
    --danger-border: #6e3034;
    --diff-add: #142a1c;
    --diff-add-gutter: #1b3b26;
    --diff-del: #2e181a;
    --diff-del-gutter: #462224;
    --line-highlight: rgb(227 179 65 / 20%);
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px rgb(0 0 0 / 50%);
    --backdrop: rgb(0 0 0 / 60%);
    --code-comment: #8b949e;
    --code-keyword: #ff7b72;
    --code-string: #a5d6ff;
    --code-number: #79c0ff;
    --code-title: #d2a8ff;
    --code-type: #ffa657;
    --code-attr: #79c0ff;
    --code-meta: #8b949e;
  }
}

/* Base */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  font: 14px/1.5 var(--font-sans);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
h4 { font-size: 13px; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, kbd { font-family: var(--font-mono); }
pre { margin: 0; }
img, svg { flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.icon { width: 16px; height: 16px; color: var(--text-muted); }

/* Controls */

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--control);
  max-width: 100%;
  padding: 5px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  overflow-wrap: anywhere;
}
button:hover:not(:disabled) { background: var(--bg-subtle); }
button:active:not(:disabled) { background: var(--bg-muted); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

:is(button.primary, .panel-form > button[type=submit]:not(.danger), dialog form button[type=submit], .releases form button[type=submit]) {
  color: var(--primary-text);
  background: var(--primary);
  border-color: var(--primary);
}
:is(button.primary, .panel-form > button[type=submit]:not(.danger), dialog form button[type=submit], .releases form button[type=submit]):hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
button.danger { color: var(--danger); border-color: var(--danger-border); background: var(--bg); }
button.danger:hover:not(:disabled) { background: var(--danger-subtle); border-color: var(--danger); }
button.quiet { color: var(--text-muted); background: transparent; border-color: transparent; }
button.quiet:hover:not(:disabled) { color: var(--text); background: var(--bg-muted); }
.text-button {
  min-height: 0;
  padding: 0;
  justify-content: flex-start;
  text-align: left;
  font-size: inherit;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: 0;
  border-radius: 2px;
}
.text-button:hover:not(:disabled) { background: none; text-decoration: underline; }
.back-button { justify-self: start; }

label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; }
label:has(> input:is([type=checkbox], [type=radio])), label.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
}
label:has(> input:is([type=checkbox], [type=radio])) > input { order: -1; }

input, select, textarea {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
input:not([type=checkbox], [type=radio], [type=file]), select {
  width: 100%;
  min-width: 0;
  height: var(--control);
  padding: 0 10px;
}
textarea { display: block; width: 100%; min-height: 96px; padding: 8px 10px; line-height: 1.5; resize: vertical; }
select {
  appearance: none;
  padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
:is(input, select, textarea):hover:not(:disabled, [readonly]) { border-color: var(--text-muted); }
:is(input, select, textarea):focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
:is(input, select, textarea):disabled { color: var(--text-muted); background-color: var(--bg-subtle); cursor: not-allowed; }
input[readonly] { background-color: var(--bg-subtle); }
::placeholder { color: var(--text-muted); opacity: 0.75; }
input[type=number] { font-variant-numeric: tabular-nums; }
input[type=checkbox] {
  appearance: none;
  display: inline-grid;
  place-content: center;
  width: 16px;
  height: 16px;
  margin: 0;
  flex: none;
  border-radius: 4px;
  cursor: pointer;
}
input[type=checkbox]::before {
  content: "";
  width: 10px;
  height: 10px;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0, 43% 62%);
  background: var(--primary-text);
  transform: scale(0);
  transition: transform 80ms ease-out;
}
input[type=checkbox]:checked { background-color: var(--primary); border-color: var(--primary); }
input[type=checkbox]:checked::before { transform: scale(1); }
input[type=checkbox]:focus-visible { outline-offset: 2px; }
input[type=file] { max-width: 100%; font-size: 13px; border: 0; background: none; }
input[type=file]::file-selector-button {
  margin-right: 10px;
  min-height: var(--control);
  padding: 5px 12px;
  font: inherit;
  font-weight: 500;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.badge:is([data-state=open], [data-state=queued], [data-state=running], [data-state=pending], [data-state=cancelling], [data-state=featured]) { color: var(--accent); background: var(--accent-subtle); border-color: transparent; }
.badge:is([data-state=success], [data-state=merged], [data-state=ready], [data-state=done], [data-state=active]) { color: var(--success); background: var(--success-subtle); border-color: transparent; }
.badge:is([data-state=failure], [data-state=error], [data-state=timed_out], [data-state=deleting], [data-state=deleted]) { color: var(--danger); background: var(--danger-subtle); border-color: transparent; }
.badge:is([data-state=archived], [data-state=draft], [data-state=stale], [data-state=importing], [data-state=restoring]) { color: var(--warning); background: var(--warning-subtle); border-color: transparent; }
.badge[data-state=empty] { color: var(--text-muted); background: var(--bg-muted); border-color: transparent; }

.topic {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-subtle);
  border-radius: var(--radius);
}

/* Messages */

.notice { padding: 24px 16px; color: var(--text-muted); overflow-wrap: anywhere; }
.notice pre { margin-top: 12px; padding: 12px 16px; overflow: auto; font-size: 12px; color: var(--text); background: var(--bg-subtle); border-radius: var(--radius); }
.hint { font-size: 12px; color: var(--text-muted); overflow-wrap: anywhere; }
.warning {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text);
  background: var(--warning-subtle);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius);
  overflow-wrap: anywhere;
}
.warning:empty { display: none; }
.read-error { display: grid; gap: 12px; justify-items: start; padding: 16px; }
.read-error > .warning { justify-self: stretch; }
.oid { font: 12px/1.6 var(--font-mono); color: var(--text-muted); overflow-wrap: anywhere; }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: 14px; }
.source {
  padding: 12px 16px;
  font: 12px/1.6 var(--font-mono);
  tab-size: 4;
  overflow: auto;
  background: var(--bg-subtle);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
}
.merge-instructions { white-space: pre-wrap; overflow-wrap: anywhere; }
.action-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

#message {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  width: max-content;
  max-width: min(640px, calc(100% - 32px));
  padding: 10px 16px;
  font-size: 13px;
  color: var(--bg);
  background: var(--text);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  overflow-wrap: anywhere;
}
#message button { color: inherit; background: transparent; border-color: currentColor; }
#message button:hover:not(:disabled) { background: rgb(127 127 127 / 20%); }

/* Application frame */

aside {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 12px;
  overflow-y: auto;
  background: var(--bg-subtle);
  border-right: 1px solid var(--border-muted);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px; font-size: 15px; font-weight: 650; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { width: 24px; height: 24px; }
.sidebar-heading {
  display: flex;
  justify-content: space-between;
  margin: 18px 8px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
#repo-count { font-variant-numeric: tabular-nums; }
#repositories { display: flex; flex-direction: column; gap: 2px; }
#repositories button {
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  padding: 4px 8px;
  font-weight: 400;
  text-align: left;
  color: var(--text);
  background: transparent;
  border: 0;
}
#repositories button:hover:not(:disabled) { background: var(--bg-muted); }
#repositories button.active { font-weight: 600; color: var(--accent); background: var(--accent-subtle); }
#repositories button.active .icon { color: var(--accent); }
#repositories .repo-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { min-width: 0; min-height: 100vh; display: flex; flex-direction: column; }
main > header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 8px 32px;
  background: var(--bg);
  border-bottom: 1px solid var(--border-muted);
}
.location { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; }
.location a { color: var(--text-muted); }
#header-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
#header-name:not(:empty)::before { content: "/"; margin-right: 8px; font-weight: 400; color: var(--border); }
.header-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
main > section { width: 100%; max-width: var(--content-width); margin: 0 auto; padding: 28px 32px 48px; }
.site-footer { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px; margin-top: auto; padding: 16px 32px; font-size: 12px; border-top: 1px solid var(--border-muted); }
.site-footer a { color: var(--text-muted); }

/* Home */

.page-heading { display: flex; align-items: baseline; gap: 10px; margin-bottom: 16px; }
.page-heading h1 { font-size: 20px; }
.repo-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.repo-list > .notice, .repo-list > .warning { grid-column: 1 / -1; }
.repo-list > .notice { padding: 32px 0; }
.repo-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-large);
}
.repo-card h2 { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 15px; }
.repo-card h2 a { overflow-wrap: anywhere; }
.repo-card > p { font-size: 13px; color: var(--text-muted); overflow-wrap: anywhere; }
.topics { display: flex; flex-wrap: wrap; gap: 6px; }
.card-links { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: auto; padding-top: 4px; font-size: 13px; }
.card-links span { color: var(--text-muted); }

/* Repository */

.repo-heading { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px 32px; }
.repo-identity { flex: 1 1 360px; min-width: 0; display: grid; gap: 6px; }
#repo-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
#description { color: var(--text-muted); overflow-wrap: anywhere; }
#description:empty, #object-stats:empty { display: none; }
.clone-box { flex: 0 1 400px; min-width: 0; display: grid; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.clone-field { display: flex; min-width: 0; }
.clone-field input { flex: 1; font: 12px var(--font-mono); border-radius: var(--radius) 0 0 var(--radius); }
.clone-field button { flex: none; margin-left: -1px; border-radius: 0 var(--radius) var(--radius) 0; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-top: 20px;
  border-bottom: 1px solid var(--border-muted);
}
.toolbar[inert] { opacity: 0.6; }
.tabs { display: flex; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: none;
  min-height: 42px;
  padding: 0 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
}
.tabs button:hover:not(:disabled) { color: var(--text); background: none; border-bottom-color: var(--border); }
.tabs button.selected { font-weight: 600; color: var(--text); border-bottom-color: var(--accent); }
.tabs button:focus-visible { outline-offset: -2px; }
.branch-label { display: flex; align-items: center; gap: 6px; flex: none; padding: 5px 0; color: var(--text-muted); }
.branch-label select { width: auto; max-width: 220px; font-size: 13px; }

.summary {
  display: flex;
  align-items: center;
  gap: 8px 12px;
  min-width: 0;
  margin-top: 16px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--radius-large) var(--radius-large) 0 0;
}
.summary strong { flex: 0 1 auto; min-width: 0; color: var(--text); overflow-wrap: anywhere; }
.summary-message { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.summary > a { flex: none; }
.summary code { font-size: 12px; }

#content { min-width: 0; margin-top: 16px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-large); overflow: hidden; }
.summary:not([hidden]) + #content { margin-top: 0; border-radius: 0 0 var(--radius-large) var(--radius-large); }
#content > :is(p, h2, h3, pre):not(.notice, .read-context) { margin: 16px; }
#content > :is(button, a) { margin: 16px 0 16px 16px; }
#content > .back-button { margin: 12px 16px 0; }

.list-footer { padding: 12px 16px; border-top: 1px solid var(--border-muted); }

/* Panels and rows */

.panel, .panel-form {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
  margin: 0;
  padding: 20px;
  border-bottom: 1px solid var(--border-muted);
}
:is(.panel, .panel-form) > :is(button, a, input[type=file]) { justify-self: start; }
:is(.panel, .panel-form) > h2 { font-size: 15px; }
:is(.panel, .panel-form) > p:not(.warning, .hint) { color: var(--text-muted); font-size: 13px; overflow-wrap: anywhere; }
.panel-form { max-width: 100%; }
.panel-form > label, .panel-form > .warning, .panel-form > p { max-width: 640px; }
.panel > .panel-form { padding: 0; border: 0; }
#content > :is(.panel, .panel-form, .panel-heading, .item-row):not(.danger-zone):last-child,
#content > :last-child > :is(.panel, .panel-form, .item-row):last-child { border-bottom: 0; }
.panel:empty { display: none; }
.panel-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-muted);
}
.panel-heading h2 { margin-right: auto; font-size: 16px; }
.panel-heading > .hint { flex: 1 1 320px; margin: 0; font-size: 12px; color: var(--text-muted); }
.panel-heading label { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--text-muted); }
.panel-heading select { width: auto; }
.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  min-width: 0;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-muted);
}
.item-row > div { display: grid; gap: 4px; min-width: 0; }
.item-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.item-row p, .item-row small { font-size: 12px; color: var(--text-muted); overflow-wrap: anywhere; }
.panel > .item-row { padding: 12px 0; border-top: 1px solid var(--border-muted); border-bottom: 0; }
.item-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.danger-zone { margin: 20px; border: 1px solid var(--danger-border); border-radius: var(--radius-large); }
.danger-zone > h2 { color: var(--danger); }
.secret-panel { margin: 0 0 16px; background: var(--accent-subtle); border: 1px solid var(--accent); border-radius: var(--radius-large); }
.discussion { display: grid; gap: 4px; padding: 12px 0; border-top: 1px solid var(--border-muted); }
.discussion small { font-size: 12px; color: var(--text-muted); overflow-wrap: anywhere; }
.discussion.stale { opacity: 0.7; }
.audit-row { padding: 6px 0; font: 12px/1.6 var(--font-mono); border-top: 1px solid var(--border-muted); overflow-wrap: anywhere; }
.checks { display: grid; gap: 6px; }
.check-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13px; overflow-wrap: anywhere; }
.check-row::before { content: ""; flex: none; width: 8px; height: 8px; background: var(--text-muted); border-radius: 50%; }
.check-row[data-state=success]::before { background: var(--success); }
.check-row:is([data-state=failure], [data-state=error])::before { background: var(--danger); }
.check-row[data-state=pending]::before { background: var(--accent); }

/* Source browsing */

.read-context { padding: 10px 16px; font: 12px/1.6 var(--font-mono); color: var(--text-muted); border-bottom: 1px solid var(--border-muted); overflow-wrap: anywhere; }
.path-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 10px 16px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-muted);
}
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; min-width: 0; font-size: 14px; }
.crumbs > span { color: var(--text-muted); }
.crumbs button { min-height: 0; padding: 0; font-size: inherit; font-weight: 500; color: var(--accent); background: none; border: 0; text-align: left; }
.crumbs button:hover:not(:disabled) { background: none; text-decoration: underline; }
.crumbs button:last-child { font-weight: 600; color: var(--text); }
.source-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 13px; }
.source-tools a { font-family: var(--font-mono); font-size: 12px; margin-right: 4px; }
.source-tools button { min-height: 28px; padding: 3px 10px; font-size: 12px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border-muted); }
.inline-form input:not([type=number]) { flex: 1 1 220px; width: auto; }
.inline-form input[type=number] { flex: 0 0 8em; width: 8em; }
.form-hint { padding: 10px 16px; font-size: 12px; color: var(--text-muted); border-bottom: 1px solid var(--border-muted); }

table { width: 100%; border-collapse: collapse; }
.tree td { padding: 7px 16px; font-size: 14px; border-top: 1px solid var(--border-muted); }
.tree tr:first-child td { border-top: 0; }
.tree tr:hover td { background: var(--bg-subtle); }
.tree td:last-child { width: 1%; text-align: right; white-space: nowrap; font: 12px var(--font-mono); color: var(--text-muted); }
.entry { display: flex; align-items: center; gap: 10px; min-width: 0; }
.entry .icon-folder, .entry .icon-submodule { color: var(--accent); }
.entry button { min-height: 0; padding: 0; font-size: inherit; font-weight: 400; color: var(--text); background: none; border: 0; text-align: left; }
.entry button:hover:not(:disabled) { color: var(--accent); background: none; text-decoration: underline; }

.readme { border-top: 1px solid var(--border-muted); }
.readme-title { display: flex; align-items: center; gap: 8px; padding: 10px 16px; font-size: 13px; background: var(--bg-subtle); border-bottom: 1px solid var(--border-muted); }

.source-view { min-width: 0; }
.source-view .inline-form .hint { flex: 1 1 200px; }
.code-scroll { max-height: 70vh; overflow: auto; font: 12px/var(--row) var(--font-mono); }
.code-scroll:focus-visible { outline-offset: -2px; }
.code-lines { position: relative; display: flex; width: max-content; min-width: 100%; }
.line-numbers {
  position: sticky;
  left: 0;
  z-index: 1;
  flex: none;
  padding: 8px 12px 8px 16px;
  font: inherit;
  text-align: right;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border-right: 1px solid var(--border-muted);
  cursor: pointer;
  user-select: none;
  white-space: pre;
}
.code-lines .source { flex: 1 0 auto; padding: 8px 16px; font: inherit; white-space: pre; background: none; border: 0; border-radius: 0; overflow: visible; }
.code-lines .source code { font: inherit; }
/* browse.js positions this 8px padding + 22px rows */
.line-highlight { position: absolute; left: 0; right: 0; z-index: 2; height: var(--row); background: var(--line-highlight); pointer-events: none; }

.commit-header { display: grid; gap: 10px; padding: 20px; border-bottom: 1px solid var(--border-muted); }
.commit-header h2 { font-size: 18px; }
.commit-meta { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 20px; margin: 0; font-size: 13px; }
.commit-meta dt { color: var(--text-muted); }
.commit-meta dd { margin: 0; font: 12px var(--font-mono); overflow-wrap: anywhere; }
.commit-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.commit-actions:last-child { border-bottom: 0; }

.search-results { display: grid; }
.search-results > button { justify-content: flex-start; min-height: 36px; padding: 6px 16px; font-family: var(--font-mono); font-size: 12px; font-weight: 400; text-align: left; color: var(--accent); background: none; border: 0; border-bottom: 1px solid var(--border-muted); border-radius: 0; }
.search-results > button:hover:not(:disabled) { background: var(--bg-subtle); text-decoration: underline; }
.search-results > p { padding: 12px 16px; }
.content-match { display: grid; gap: 4px; min-width: 0; padding: 8px 16px; border-bottom: 1px solid var(--border-muted); }
.content-match > button { justify-content: flex-start; padding: 0; color: var(--accent); background: none; border: 0; font-family: var(--font-mono); font-size: 12px; }
.content-match > code { overflow-wrap: anywhere; white-space: pre-wrap; color: var(--text-muted); }
.commit-search-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border-muted); }
.commit-search-form .field { display: contents; }
.commit-search-form input { min-width: 0; }
.list-tools { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border-muted); }
.blame-table { width: 100%; table-layout: fixed; }
.blame-table th, .blame-table td { padding: 6px 10px; vertical-align: top; text-align: left; }
.blame-table th:nth-child(1), .blame-table td:nth-child(1) { width: 5em; text-align: right; color: var(--text-muted); }
.blame-table th:nth-child(2), .blame-table td:nth-child(2) { width: 10em; }
.blame-table td:nth-child(3) { overflow-wrap: anywhere; }
.blame-table code { white-space: pre-wrap; }

.history-row { display: flex; align-items: center; gap: 8px 12px; padding: 12px 16px; border-top: 1px solid var(--border-muted); }
.history-row:first-child { border-top: 0; }
.history-row > div { flex: 1; min-width: 0; display: grid; gap: 2px; }
.history-row strong { font-weight: 600; overflow-wrap: anywhere; }
.history-row small { font-size: 12px; color: var(--text-muted); }
.history-row button { min-height: 28px; padding: 3px 10px; font-size: 12px; }
.history-row .oid-button { font-family: var(--font-mono); }

/* Compare and diff */

.compare-layout { display: grid; grid-template-columns: minmax(200px, 280px) minmax(0, 1fr); min-height: 420px; border-top: 1px solid var(--border-muted); }
.changed-files { display: flex; flex-direction: column; gap: 2px; max-height: 70vh; padding: 8px; overflow: auto; background: var(--bg-subtle); border-right: 1px solid var(--border-muted); }
.changed-files > .diff-title { padding: 4px 8px 8px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.changed-files button {
  display: block;
  flex: none;
  width: 100%;
  min-height: 30px;
  padding: 5px 8px;
  font: 12px/1.6 var(--font-mono);
  text-align: left;
  overflow-wrap: anywhere;
  color: var(--text);
  background: none;
  border: 0;
}
.changed-files button:hover:not(:disabled) { background: var(--bg-muted); }
.changed-files button.active { color: var(--accent); background: var(--accent-subtle); }
.change-mark { display: inline-block; width: 1.4em; font-weight: 700; }
.change-mark[data-change=added] { color: var(--success); }
.change-mark[data-change=deleted] { color: var(--danger); }
.change-mark[data-change=modified] { color: var(--warning); }
.diff-pane { min-width: 0; }
.diff-pane > .notice { padding: 32px 16px; }
.diff-pane > .diff-title { padding: 10px 16px; font: 600 13px/1.5 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg-subtle); border-bottom: 1px solid var(--border-muted); }
.diff-pane .warning { margin: 16px; }
.diff-pane > div > .source { margin: 0 16px 16px; }
.diff-pane > div > .notice { padding: 16px; }
.diff-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 12px 16px; }
.diff-summary { flex-basis: 100%; font-size: 12px; color: var(--text-muted); overflow-wrap: anywhere; }
.diff-tools .inline-form { padding: 0; border: 0; margin-left: auto; }
.diff-download { font-size: 13px; font-weight: 500; }
.diff-download:focus-visible { outline-offset: 2px; }
.diff-scroll { position: relative; height: 60vh; overflow: auto; font: 12px/var(--row) var(--font-mono); border-top: 1px solid var(--border-muted); }
.diff-scroll:focus-visible { outline-offset: -2px; }
.diff-columns { position: sticky; top: 0; z-index: 1; display: flex; height: var(--row); font-size: 11px; color: var(--text-muted); background: var(--bg-subtle); }
.diff-columns span { width: 56px; min-width: 56px; padding-right: 12px; text-align: right; }
.diff-columns span:last-child { width: auto; padding-left: 12px; text-align: left; }
.diff-inner { position: relative; min-width: 100%; }
.diff-rows { position: absolute; left: 0; right: 0; }
.diff-line { display: flex; height: var(--row); min-width: max-content; white-space: pre; }
.diff-line span { width: 56px; min-width: 56px; padding-right: 12px; text-align: right; color: var(--text-muted); user-select: none; }
.diff-line code { padding: 0 12px; font: inherit; }
.diff-line.add { background: var(--diff-add); }
.diff-line.add span { background: var(--diff-add-gutter); }
.diff-line.del { background: var(--diff-del); }
.diff-line.del span { background: var(--diff-del-gutter); }

/* Markdown */

.wiki { display: grid; min-width: 0; gap: 16px; padding: 20px; }
.wiki-heading, .wiki-editor, .wiki-result { display: grid; min-width: 0; gap: 12px; }
.wiki-heading h2, .wiki > h2, .wiki-result h2 { font-size: 20px; }
.wiki-revision { font: 12px/1.7 var(--font-mono); color: var(--text-muted); overflow-wrap: anywhere; }
.wiki-tools { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; font-size: 13px; }
.wiki-directory { display: grid; min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); }
.wiki-directory > a { padding: 12px; overflow-wrap: anywhere; border-bottom: 1px solid var(--border-muted); }
.wiki-directory > a:last-child { border-bottom: 0; }
.wiki .markdown { min-width: 0; padding: 16px 0; border-top: 1px solid var(--border-muted); }
.wiki-editor > label { display: grid; min-width: 0; gap: 6px; font-size: 13px; }
.wiki-editor :is(input, select, textarea) { min-width: 0; width: 100%; }
.wiki-editor textarea { resize: vertical; min-height: 240px; font: 13px/1.6 var(--font-mono); }
.wiki-editor input[type=checkbox] { width: auto; justify-self: start; }
.wiki-history-row { display: flex; flex-wrap: wrap; min-width: 0; gap: 8px 16px; padding: 16px 0; border-bottom: 1px solid var(--border-muted); overflow-wrap: anywhere; }
.wiki-history-row strong { flex-basis: 100%; white-space: pre-wrap; }
.wiki-history-row span { flex: 1 1 200px; font-size: 13px; }
.wiki [data-wiki-anchor] { scroll-margin-top: 80px; }

.markdown { padding: 24px 32px; font-size: 15px; line-height: 1.65; overflow-wrap: anywhere; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown :is(p, ul, ol, pre, blockquote, table, dl) { margin: 0 0 16px; }
.markdown :is(h1, h2, h3, h4, h5, h6) { margin: 28px 0 12px; line-height: 1.3; }
.markdown h1 { padding-bottom: 8px; font-size: 26px; border-bottom: 1px solid var(--border-muted); }
.markdown h2 { padding-bottom: 6px; font-size: 21px; border-bottom: 1px solid var(--border-muted); }
.markdown h3 { font-size: 17px; }
.markdown :is(h4, h5, h6) { font-size: 15px; }
.markdown :is(ul, ol) { padding-left: 24px; }
.markdown li + li { margin-top: 4px; }
.markdown a { text-decoration: underline; text-underline-offset: 2px; }
.markdown code { padding: 0.15em 0.4em; font-size: 85%; background: var(--bg-muted); border-radius: 4px; }
.markdown pre { padding: 14px 16px; overflow: auto; font-size: 13px; line-height: 1.5; background: var(--bg-subtle); border-radius: var(--radius); }
.markdown pre code { padding: 0; font-size: inherit; background: none; }
.markdown blockquote { padding: 0 16px; color: var(--text-muted); border-left: 3px solid var(--border); }
.markdown table { display: block; width: max-content; max-width: 100%; overflow: auto; }
.markdown :is(th, td) { padding: 6px 12px; font-size: 14px; text-align: left; border: 1px solid var(--border); }
.markdown th { background: var(--bg-subtle); }
.markdown img { display: block; max-width: 100%; height: auto; }
.markdown hr { margin: 24px 0; border: 0; border-top: 1px solid var(--border); }

/* Syntax highlighting */

.hljs-comment, .hljs-quote { color: var(--code-comment); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-doctag { color: var(--code-keyword); }
.hljs-string, .hljs-regexp, .hljs-addition { color: var(--code-string); }
.hljs-number, .hljs-symbol, .hljs-variable.constant_ { color: var(--code-number); }
.hljs-title, .hljs-title.function_, .hljs-section { color: var(--code-title); }
.hljs-type, .hljs-built_in, .hljs-title.class_ { color: var(--code-type); }
.hljs-attribute, .hljs-attr, .hljs-property, .hljs-name { color: var(--code-attr); }
.hljs-meta, .hljs-subst { color: var(--code-meta); }

/* Pull requests, releases, Actions and maintenance */

.compile-state { font-size: 13px; overflow-wrap: anywhere; }
.compile-state[data-state=success] { color: var(--success); }
.compile-state:is([data-state=failure], [data-state=error]) { color: var(--danger); }
.compile-state[data-state=pending] { color: var(--accent); }

.releases { display: grid; gap: 16px; min-width: 0; padding: 20px; }
.releases :is(code, p, h2, h3) { overflow-wrap: anywhere; }
.releases .section-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.releases .section-heading h2 { margin-right: auto; font-size: 18px; }
.releases form { display: grid; gap: 14px; max-width: 680px; }
.releases form > h2 { font-size: 18px; }
.release-list { display: grid; border: 1px solid var(--border); border-radius: var(--radius-large); }
.release-list > .hint, .release-list > p { padding: 16px; }
.release-card { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 12px 16px; border-top: 1px solid var(--border-muted); }
.release-card:first-child { border-top: 0; }
.release-card > .release-title { min-height: 0; padding: 0; font-size: 15px; font-weight: 600; color: var(--accent); background: none; border: 0; text-align: left; }
.release-card > .release-title:hover:not(:disabled) { background: none; text-decoration: underline; }
.release-card > code { font-size: 12px; color: var(--text-muted); }
.release-card > p { flex-basis: 100%; font-size: 12px; color: var(--text-muted); }
.release-more { justify-self: start; }
.release-identity { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13px; }
.release-identity code { font-size: 12px; }
.release-identity > strong { flex-basis: 100%; color: var(--warning); font-size: 12px; }
.releases .markdown { padding: 0; }
.assets { display: grid; gap: 12px; padding-top: 16px; border-top: 1px solid var(--border-muted); }
.asset-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 10px 0; font-size: 13px; border-top: 1px solid var(--border-muted); }
.asset-row:first-of-type { border-top: 0; }
.asset-row strong { overflow-wrap: anywhere; }
.asset-row code { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); overflow-wrap: anywhere; }
.asset-row p { flex-basis: 100%; font-size: 12px; color: var(--text-muted); }
.artifact-picker { display: grid; gap: 8px; min-width: 0; padding-top: 16px; border-top: 1px solid var(--border-muted); }
.artifact-picker > button { justify-self: start; }
.artifact-picker p { font-size: 12px; color: var(--text-muted); overflow-wrap: anywhere; }

.actions-panel { display: grid; min-width: 0; }
.actions-panel > .hint { padding: 12px 20px 0; }
.actions-panel > .hint:empty { padding: 0; }
.actions-panel > .warning { margin: 16px 20px 0; }
.actions-run { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 12px 0; border-top: 1px solid var(--border-muted); min-width: 0; }
.actions-run > p { flex-basis: 100%; font-size: 12px; }
.actions-run > .oid { flex: 1 1 260px; }
.actions-detail section, .actions-artifacts { display: grid; gap: 6px; padding-top: 12px; border-top: 1px solid var(--border-muted); }
.actions-detail section p, .actions-artifact p { font-size: 13px; overflow-wrap: anywhere; }
.actions-artifact { display: grid; gap: 6px; padding: 12px 0; border-top: 1px solid var(--border-muted); overflow-wrap: anywhere; }
.actions-artifact > button { justify-self: start; }
.actions-log, .actions-workflow {
  max-height: 480px;
  padding: 12px 16px;
  overflow: auto;
  font: 12px/1.6 var(--font-mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--bg-subtle);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
}
details > summary { cursor: pointer; font-size: 13px; font-weight: 500; }
details[open] > summary { margin-bottom: 8px; }

.maintenance { display: grid; min-width: 0; }
.maintenance > .hint { padding: 12px 20px 0; }
.maintenance > .hint:empty { padding: 0; }
.metrics { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 24px; margin: 0; font-size: 13px; }
.metrics dt { color: var(--text-muted); }
.metrics dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.job-row { display: grid; gap: 4px; padding: 12px 0; border-top: 1px solid var(--border-muted); }
.job-row > button { justify-self: start; margin-top: 4px; }
.job-row p { font-size: 13px; color: var(--text-muted); }
.confirm-form { display: grid; gap: 10px; padding: 12px 0; }
.confirm-form > button { justify-self: start; }

/* Dialogs */

dialog {
  width: min(480px, calc(100% - 32px));
  max-height: calc(100vh - 64px);
  padding: 24px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: var(--backdrop); }
dialog form { display: grid; gap: 16px; }
dialog h2 { font-size: 18px; }
dialog form > p { font-size: 13px; color: var(--text-muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.wide-dialog { width: min(820px, calc(100% - 32px)); overflow: auto; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.wide-dialog :is(.panel, .panel-form) { padding: 16px 0; }
.wide-dialog .secret-panel { padding: 16px; }

/* Public project pages */

body.public-page { display: block; }
.public-page main > section { max-width: 960px; }
.public-page .header-actions { align-items: center; gap: 8px 20px; font-size: 14px; }
.public-page .page-heading { align-items: center; margin-bottom: 8px; }
.public-page section > p { margin-bottom: 20px; color: var(--text-muted); }
.public-page section > .topics { margin-bottom: 16px; }
.public-page section > .card-links { margin-bottom: 24px; font-size: 14px; }

/* Narrow screens */

@media (max-width: 1024px) {
  :root { --sidebar: 208px; }
  main > header { padding: 8px 20px; }
  main > section { padding: 24px 20px 40px; }
}

@media (max-width: 760px) {
  body { display: block; }
  aside {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--border-muted);
  }
  .brand { padding: 4px; }
  aside .brand-name, .sidebar-heading { display: none; }
  #repositories { flex: 1; flex-direction: row; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  #repositories::-webkit-scrollbar { display: none; }
  #repositories button { flex: none; width: auto; max-width: 180px; }
  main > header { position: static; min-height: 48px; padding: 8px 16px; flex-wrap: wrap; }
  main > section { padding: 20px 16px 32px; }
  .repo-heading { gap: 16px; }
  .clone-box { flex-basis: 100%; }
  .toolbar { flex-wrap: wrap; gap: 0; }
  .tabs { flex-basis: 100%; }
  .branch-label { padding: 8px 0; }
  .summary { flex-wrap: wrap; }
  .summary-message { flex-basis: 100%; order: 1; }
  .compare-layout { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .changed-files { max-height: 180px; border-right: 0; border-bottom: 1px solid var(--border-muted); }
  .diff-scroll { height: 55vh; }
  .markdown { padding: 16px; font-size: 14px; }
  .panel, .panel-form, .commit-header { padding: 16px; gap: 12px; }
  .panel-heading, .item-row { padding: 12px 16px; }
  .item-row { flex-wrap: wrap; }
  .history-row { flex-wrap: wrap; }
  .history-row > div { flex-basis: 100%; }
  .commit-search-form { grid-template-columns: 1fr; }
  .blame-table th:nth-child(2), .blame-table td:nth-child(2) { width: 7em; }
  .commit-meta { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .commit-meta dd + dt { margin-top: 8px; }
  .commit-actions { gap: 6px; }
  .metrics { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .metrics dd + dt { margin-top: 8px; }
  .danger-zone { margin: 16px; }
  .releases { padding: 16px; }
  .wiki { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

@media (forced-colors: active) {
  button, input, select, textarea, .badge, .topic { border: 1px solid ButtonText; }
  .tabs button.selected, #repositories button.active, .changed-files button.active { outline: 2px solid Highlight; outline-offset: -2px; }
  input[type=checkbox]::before { background: CanvasText; }
}
