:root {
  --bg: #0d1117;
  --bg-elev: #161b22;
  --bg-elev-2: #1c2230;
  --border: #30363d;
  --border-soft: #21262d;
  --fg: #e6edf3;
  /* Muted/faint greys are tuned to clear WCAG AA (4.5:1) on the dark surfaces. */
  --fg-muted: #9aa4b2;
  --fg-faint: #868f9b;
  --accent: #2f81f7;
  /* Darker accent for solid fills under white text (e.g. primary button):
     clears WCAG AA (4.5:1) where the lighter --accent (3.7:1) would not. */
  --accent-strong: #1f6feb;
  --accent-soft: rgba(47, 129, 247, 0.15);
  --danger: #f85149;
  --success: #3fb950;
  --selection: #1f6feb44;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --topbar-h: 56px;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--fg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
/* Inline links inside running text need a non-color cue (underline) at rest. */
p a {
  text-decoration: underline;
}

.muted {
  color: var(--fg-muted);
}

kbd {
  font-family: var(--mono);
  font-size: 0.78em;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
}

/* ---------- Topbar ---------- */
.topbar {
  min-height: var(--topbar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1rem;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 0 0 auto;
}
.brand-glyph {
  font-size: 1.4rem;
  color: var(--accent);
  line-height: 1;
}
.brand-text h1 {
  font-size: 1.05rem;
  margin: 0;
  letter-spacing: 0.02em;
}
.brand-text .tagline {
  margin: 0;
  font-size: 0.72rem;
  color: var(--fg-faint);
}

.repo-bar {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-width: 0;
}
.repo-id {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.repo-name {
  font-weight: 600;
  font-family: var(--mono);
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.repo-meta {
  font-size: 0.72rem;
  color: var(--fg-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.repo-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 0 0 auto;
}

.branch-picker {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 0.5rem;
  height: 34px;
}
.branch-glyph {
  color: var(--fg-muted);
}
.branch-picker select {
  background: transparent;
  color: var(--fg);
  border: none;
  font-size: 0.85rem;
  max-width: 220px;
  padding: 0.3rem 0.2rem;
  outline: none;
}
.branch-picker select option {
  background: var(--bg-elev);
  color: var(--fg);
}

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--fg);
  font: inherit;
  font-size: 0.85rem;
  padding: 0 0.85rem;
  height: 34px;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:hover {
  background: #262d3a;
  border-color: #3d4655;
}
.btn:active {
  transform: translateY(1px);
}
.btn.primary {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #fff;
  font-weight: 600;
}
.btn.primary:hover {
  background: #1a6ae0;
  border-color: #1a6ae0;
}
.btn.ghost {
  background: transparent;
}
.btn[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #cbe0ff;
}
.btn:disabled {
  opacity: 0.55;
  cursor: progress;
}

/* ---------- Layout ---------- */
.content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

/* ---------- Start view ---------- */
.start-view {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 2.5rem 1.25rem 4rem;
  overflow-y: auto;
}
.clone-card {
  width: 100%;
  max-width: 560px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem;
}
.clone-card h2 {
  margin: 0 0 0.35rem;
}
.clone-card > .muted {
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
}
.field > span {
  font-size: 0.82rem;
  color: var(--fg-muted);
}
.field input,
.palette-input,
.tree-filter {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: var(--radius);
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-size: 0.9rem;
  outline: none;
  width: 100%;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-row {
  display: flex;
  gap: 0.75rem;
}
.field-row .field {
  flex: 1 1 auto;
}
.field-narrow {
  flex: 0 0 90px;
}
.field small {
  font-size: 0.72rem;
  line-height: 1.4;
}

.advanced {
  margin: 0.25rem 0 1rem;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
}
.advanced summary {
  cursor: pointer;
  font-size: 0.84rem;
  color: var(--fg-muted);
}
.advanced[open] summary {
  margin-bottom: 0.75rem;
}
.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  margin-bottom: 0.9rem;
  cursor: pointer;
}
.checkbox input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.form-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* ---------- Preset repositories ---------- */
.presets {
  margin-top: 1.1rem;
}
.presets-label {
  font-size: 0.82rem;
  margin: 0 0 0.5rem;
}
.preset-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.preset {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  text-align: left;
  font: inherit;
}
.preset:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.preset:disabled {
  opacity: 0.55;
  cursor: progress;
}
.preset .p-name {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--fg);
}
.preset .p-note {
  font-size: 0.7rem;
  color: var(--fg-faint);
}
.error {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 0.9rem 0 0;
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.35);
  border-radius: var(--radius);
  padding: 0.55rem 0.7rem;
}

.progress {
  margin-top: 1.1rem;
}
.progress-track {
  height: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.2s ease;
}
.progress-label {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: var(--fg-muted);
  font-family: var(--mono);
}

/* ---------- Recent repos ---------- */
.recent {
  width: 100%;
  max-width: 560px;
}
.recent-head h3 {
  margin: 0 0 0.15rem;
}
.recent-head .muted {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
}
.storage-usage {
  font-size: 0.78rem !important;
  color: var(--fg-faint) !important;
}
.recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.recent-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
}
.recent-item .ri-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.recent-item .ri-main {
  min-width: 0;
  cursor: pointer;
  flex: 1 1 auto;
}
.recent-item .ri-name {
  font-family: var(--mono);
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recent-item .ri-meta {
  font-size: 0.74rem;
  color: var(--fg-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recent-item .ri-proxy-meta {
  font-size: 0.72rem;
  color: var(--fg-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recent-item .ri-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.recent-item .ri-action {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.72rem;
  line-height: 1;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
}
.recent-item .ri-action:hover {
  color: var(--fg);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.recent-item .ri-action[aria-expanded='true'] {
  color: #cbe0ff;
  border-color: var(--accent);
  background: var(--accent-soft);
}
.recent-item .ri-remove {
  flex: 0 0 auto;
  background: transparent;
  border: none;
  color: var(--fg-faint);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
}
.recent-item .ri-remove:hover {
  color: var(--danger);
  background: rgba(248, 81, 73, 0.1);
}
.recent-item .ri-proxy-edit {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  border-top: 1px solid var(--border-soft);
  padding-top: 0.5rem;
}
.recent-item .ri-proxy-input {
  flex: 1 1 12rem;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: var(--radius);
  padding: 0.4rem 0.6rem;
  font: inherit;
  font-size: 0.82rem;
  outline: none;
}
.recent-item .ri-proxy-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- Browser view ---------- */
.browser-view {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  position: relative;
}
.sidebar {
  flex: 0 0 290px;
  max-width: 60vw;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg-elev);
  min-height: 0;
}
.sidebar-head {
  padding: 0.6rem;
  border-bottom: 1px solid var(--border-soft);
}
.tree-filter {
  font-size: 0.82rem;
  padding: 0.4rem 0.55rem;
}
.tree-scroll {
  flex: 1 1 auto;
  overflow: auto;
  padding: 0.4rem 0.3rem 1rem;
}
.tree,
.flat-results {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 0.84rem;
  text-align: left;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.tree-row:hover {
  background: var(--bg-elev-2);
}
.tree-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.tree-row.active {
  background: var(--accent-soft);
  color: #cbe0ff;
}
.tree-row .twisty {
  flex: 0 0 12px;
  color: var(--fg-faint);
  font-size: 0.7rem;
  transition: transform 0.12s ease;
  text-align: center;
}
.tree-row.open .twisty {
  transform: rotate(90deg);
}
.tree-row .node-icon {
  flex: 0 0 auto;
  opacity: 0.85;
}
.tree-row .node-name {
  overflow: hidden;
  text-overflow: ellipsis;
}
.flat-row {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
}
.flat-row:hover,
.flat-row.active {
  background: var(--bg-elev-2);
}
.flat-row .fr-name {
  font-size: 0.84rem;
}
.flat-row .fr-path {
  font-size: 0.72rem;
  color: var(--fg-faint);
}
.match {
  /* Brighter than --accent so the highlight clears WCAG AA even on the
     accent-tinted background of an active/selected row. */
  color: #58a6ff;
  font-weight: 700;
}
.empty {
  color: var(--fg-faint);
  font-size: 0.85rem;
  padding: 0.5rem;
}

/* ---------- Viewer ---------- */
.viewer {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}
.viewer-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
.file-path {
  font-family: var(--mono);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 3rem;
}
.file-path .dir {
  color: var(--fg-faint);
}
.viewer-head-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 0 0 auto;
}
.file-info {
  font-size: 0.74rem;
  color: var(--fg-faint);
  white-space: nowrap;
  flex: 0 0 auto;
}
.btn.small {
  height: 26px;
  padding: 0 0.6rem;
  font-size: 0.76rem;
}
.viewer-body {
  flex: 1 1 auto;
  overflow: auto;
  min-height: 0;
}
.placeholder {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-align: center;
  padding: 2rem;
}
.placeholder-title {
  font-size: 1rem;
  margin: 0;
}

/* code rendering */
.code-view {
  display: flex;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.55;
  min-height: 100%;
  position: relative;
}
/* Linked-line highlight: an absolute band behind the (positioned) code text.
   The sticky gutter, later in source order, paints over it in its own column. */
.line-highlight {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 0;
  pointer-events: none;
  background: rgba(187, 128, 9, 0.18);
}
.gutter {
  flex: 0 0 auto;
  text-align: right;
  padding: 0.6rem 0.6rem 0.6rem 0.9rem;
  color: var(--fg-faint);
  background: var(--bg);
  border-right: 1px solid var(--border-soft);
  user-select: none;
  white-space: pre;
  position: sticky;
  left: 0;
  z-index: 1;
  cursor: pointer;
}
.code {
  padding: 0.6rem 1rem;
  white-space: pre;
  tab-size: 2;
  flex: 1 1 auto;
  color: var(--fg);
  position: relative;
  z-index: 1;
}
/* Syntax-highlight token colors (all tuned to clear WCAG AA on --bg). */
.tok-comment { color: #9aa4b2; font-style: italic; }
.tok-string { color: #a5d6ff; }
.tok-keyword { color: #ff7b72; }
.tok-number,
.tok-literal,
.tok-property,
.tok-heading { color: #79c0ff; }
.tok-heading { font-weight: 600; }
.tok-function { color: #d2a8ff; }
.tok-type,
.tok-variable { color: #ffa657; }
.tok-tag { color: #7ee787; }
.tok-attr { color: #d2a8ff; }
.tok-meta { color: #ff7b72; }
.tok-link { color: #a5d6ff; text-decoration: underline; }
.tok-strong { font-weight: 700; }
.tok-em { font-style: italic; }
.notice {
  padding: 2rem;
  text-align: center;
  color: var(--fg-muted);
}
.notice .btn {
  margin-top: 1rem;
}
.notice .lfs-oid {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--fg-faint);
  word-break: break-all;
}
.notice .symlink-target {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--fg);
  word-break: break-all;
}
.notice .symlink-target .sym-arrow {
  color: var(--fg-faint);
}
.notice .symlink-target .sym-link {
  font: inherit;
  color: var(--accent-strong);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  text-decoration: underline;
  word-break: break-all;
}
.notice .symlink-target .sym-link:hover,
.notice .symlink-target .sym-link:focus-visible {
  text-decoration: none;
}
.notice .submodule-url {
  font-family: var(--mono);
  font-size: 0.82rem;
  word-break: break-all;
}
.notice .submodule-oid {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--fg-faint);
  word-break: break-all;
}
/* External-link affordance on the viewer's "Open on host" link. */
.btn.external::after {
  content: ' \2197'; /* ↗ — decorative; the accessible name covers the action */
}

/* Loading skeleton (shown while a file's bytes are fetched). */
.skeleton {
  padding: 0.8rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.skeleton-line {
  height: 0.72rem;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    var(--bg-elev) 25%,
    var(--bg-elev-2) 37%,
    var(--bg-elev) 63%
  );
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
}
@keyframes skeleton-shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: 0 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton-line {
    animation: none;
  }
}

.image-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  min-height: 100%;
}
.image-view img {
  max-width: 100%;
  max-height: 70vh;
  background: repeating-conic-gradient(#2a2a2a 0% 25%, #333 0% 50%) 50% / 20px 20px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* ---------- Markdown preview ---------- */
.md-doc {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.md-toolbar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  gap: 0.3rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
}
.md-toggle {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--fg-muted);
  font: inherit;
  font-size: 0.76rem;
  padding: 0.15rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
}
.md-toggle:hover {
  border-color: var(--accent);
  color: #cbe0ff;
}
.md-toggle.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #cbe0ff;
}
.md-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.md-content {
  flex: 1 1 auto;
}
.md-raw {
  margin: 0;
  padding: 0.8rem 1rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--fg);
}

.markdown-body {
  padding: 1.25rem 1.5rem 2.5rem;
  max-width: 54rem;
  line-height: 1.6;
  font-size: 0.92rem;
  color: var(--fg);
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin: 1.4em 0 0.6em;
  line-height: 1.25;
}
.markdown-body h1 {
  font-size: 1.7rem;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
}
.markdown-body h2 {
  font-size: 1.35rem;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border-soft);
}
.markdown-body h3 {
  font-size: 1.15rem;
}
.markdown-body > :first-child {
  margin-top: 0;
}
.markdown-body p {
  margin: 0 0 1em;
}
.markdown-body a {
  color: var(--accent);
  text-decoration: underline;
}
.markdown-body ul,
.markdown-body ol {
  margin: 0 0 1em;
  padding-left: 1.6em;
}
.markdown-body li {
  margin: 0.2em 0;
}
.markdown-body blockquote {
  margin: 0 0 1em;
  padding: 0.1em 1em;
  color: var(--fg-muted);
  border-left: 3px solid var(--border);
}
.markdown-body blockquote > :last-child {
  margin-bottom: 0;
}
.markdown-body code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--bg-elev-2);
  border-radius: 4px;
  padding: 0.15em 0.4em;
}
.markdown-body pre {
  margin: 0 0 1em;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}
.markdown-body pre code {
  background: none;
  padding: 0;
  font-size: 0.82rem;
}
.markdown-body hr {
  height: 1px;
  border: 0;
  margin: 1.5em 0;
  background: var(--border);
}
.markdown-body img {
  max-width: 100%;
}
.markdown-body table {
  border-collapse: collapse;
  margin: 0 0 1em;
  display: block;
  overflow-x: auto;
}
.markdown-body th,
.markdown-body td {
  border: 1px solid var(--border);
  padding: 0.4em 0.7em;
}
.markdown-body th {
  background: var(--bg-elev);
}

/* ---------- History panel ---------- */
.history-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 90vw;
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 28px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  z-index: 10;
}
.history-head {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-soft);
}
.history-head-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.history-head h3 {
  margin: 0;
  font-size: 0.95rem;
}
.history-compare {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.55rem;
  font-size: 0.74rem;
}
.history-compare select {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.2rem 0.4rem;
  font: inherit;
  font-size: 0.76rem;
}
.commit-list {
  list-style: none;
  margin: 0;
  padding: 0.5rem;
  overflow-y: auto;
}
.commit-item {
  padding: 0.6rem 0.7rem;
  border-radius: 6px;
}
.commit-item:hover {
  background: var(--bg-elev-2);
}
.commit-msg {
  font-size: 0.85rem;
  margin: 0 0 0.3rem;
}
.commit-meta {
  font-size: 0.73rem;
  color: var(--fg-faint);
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.commit-oid {
  font-family: var(--mono);
  color: var(--accent);
}
.commit-actions {
  margin-top: 0.4rem;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.commit-action {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--fg-muted);
  font: inherit;
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  cursor: pointer;
}
.commit-action:hover {
  border-color: var(--accent);
  color: #cbe0ff;
  background: var(--accent-soft);
}

/* ---------- Diff view ---------- */
.diff-list {
  display: flex;
  flex-direction: column;
}
.diff-file {
  border-bottom: 1px solid var(--border-soft);
}
.diff-file-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  text-align: left;
  appearance: none;
  border: 0;
  background: var(--bg-elev);
  color: var(--fg);
  font: inherit;
  padding: 0.5rem 1rem;
  cursor: pointer;
}
.diff-file-head:hover {
  background: var(--bg-elev-2);
}
.diff-file-head::before {
  content: '\25B8'; /* ▸ */
  color: var(--fg-faint);
  transition: transform 0.12s ease;
}
.diff-file-head.open::before {
  transform: rotate(90deg);
}
.diff-file-path {
  font-family: var(--mono);
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.diff-badge {
  flex: 0 0 auto;
  width: 1.2rem;
  height: 1.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: #07120a;
}
.diff-badge.added {
  background: #3fb950;
}
.diff-badge.removed {
  background: #f85149;
  color: #1a0606;
}
.diff-badge.modified {
  background: #d29922;
}
.diff-file-body {
  background: var(--bg);
}
.diff-rows {
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
  overflow-x: auto;
}
.diff-row {
  display: flex;
  white-space: pre;
}
.diff-row.add {
  background: rgba(63, 185, 80, 0.14);
}
.diff-row.del {
  background: rgba(248, 81, 73, 0.14);
}
.diff-ln {
  flex: 0 0 auto;
  width: 3rem;
  padding: 0 0.5rem;
  text-align: right;
  color: var(--fg-faint);
  user-select: none;
  border-right: 1px solid var(--border-soft);
}
.diff-text {
  padding: 0 0.75rem;
  flex: 1 1 auto;
}
.diff-row.add .diff-text {
  color: #aff0bd;
}
.diff-row.del .diff-text {
  color: #ffb3ae;
}

/* ---------- Blame view ---------- */
.blame-view {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.blame-toolbar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border-soft);
}
.blame-rows {
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.6;
  overflow-x: auto;
}
.blame-row {
  display: flex;
  align-items: stretch;
  white-space: pre;
}
.blame-row:hover {
  background: var(--bg-elev);
}
/* Fixed-width chip column; only the first line of a commit run fills it. */
.blame-commit-cell {
  flex: 0 0 auto;
  width: 6rem;
  padding: 0 0.4rem;
  border-right: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
}
.blame-commit {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--accent);
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.blame-commit:hover:not(:disabled) {
  text-decoration: underline;
}
.blame-commit:disabled {
  color: var(--fg-faint);
  cursor: default;
}
.blame-ln {
  flex: 0 0 auto;
  width: 3rem;
  padding: 0 0.5rem;
  text-align: right;
  color: var(--fg-faint);
  user-select: none;
  border-right: 1px solid var(--border-soft);
}
.blame-code {
  padding: 0 0.75rem;
  flex: 1 1 auto;
  color: var(--fg);
}

/* ---------- Command palette ---------- */
.palette-overlay {
  position: fixed;
  inset: 0;
  background: rgba(1, 4, 9, 0.6);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  z-index: 50;
}
.palette {
  width: min(620px, 92vw);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.palette-input {
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  font-size: 1rem;
  padding: 0.9rem 1rem;
}
.palette-input:focus {
  outline: none;
}
.palette-results {
  list-style: none;
  margin: 0;
  padding: 0.4rem;
  max-height: 50vh;
  overflow-y: auto;
}
.palette-row {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
}
.palette-row.active {
  background: var(--accent-soft);
}
.palette-row .pr-name {
  font-size: 0.9rem;
}
.palette-row .pr-path {
  font-size: 0.74rem;
  color: var(--fg-faint);
}
/* The active row's accent tint lifts the background; use the brighter muted
   grey there so the path keeps a >=4.5:1 ratio. */
.palette-row.active .pr-path {
  color: var(--fg-muted);
}
.palette-empty {
  padding: 1rem;
  color: var(--fg-faint);
  text-align: center;
  font-size: 0.88rem;
}

/* ---------- Content search (grep) ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.search-overlay {
  margin: 10vh auto auto;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  max-width: 94vw;
  overscroll-behavior: contain;
}
.search-overlay::backdrop {
  background: rgba(1, 4, 9, 0.6);
  overflow: hidden;
  overscroll-behavior: contain;
}
.search-panel {
  width: min(720px, 94vw);
  max-height: 74vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.search-head {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
}
.search-input {
  flex: 1 1 auto;
  border: none;
  border-radius: 0;
  font-size: 1rem;
  padding: 0.9rem 1rem;
  background: transparent;
  color: var(--fg);
}
.search-input:focus {
  outline: none;
}
.search-opts {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0 0.6rem;
}
.search-opt {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--fg-muted);
  padding: 0.25rem 0.45rem;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
}
.search-opt:hover {
  background: var(--bg);
}
.search-status {
  padding: 0.45rem 1rem;
  margin: 0;
  font-size: 0.8rem;
  color: var(--fg-muted);
  border-bottom: 1px solid var(--border-soft);
  min-height: 1.2rem;
}
.search-status.error {
  color: var(--danger);
}
.search-results {
  overflow-y: auto;
  padding: 0.3rem;
}
.cs-file {
  margin-bottom: 0.35rem;
}
.cs-file-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  padding: 0.35rem 0.55rem;
  background: var(--bg);
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.cs-file-path {
  font-size: 0.82rem;
  color: var(--fg);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cs-file-count {
  flex: 0 0 auto;
  font-size: 0.72rem;
  color: var(--fg-faint);
}
.cs-line {
  display: flex;
  gap: 0.6rem;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  border-radius: 6px;
  padding: 0.2rem 0.55rem;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.78rem;
}
.cs-line:hover,
.cs-line.active {
  background: var(--accent-soft);
}
.cs-line-no {
  flex: 0 0 auto;
  width: 3ch;
  text-align: right;
  color: var(--fg-faint);
}
.cs-line-text {
  flex: 1 1 auto;
  min-width: 0;
  white-space: pre;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--fg-muted);
}
.cs-hit {
  background: rgba(187, 128, 9, 0.4);
  color: var(--fg);
  border-radius: 2px;
}
.search-empty {
  padding: 1.2rem;
  text-align: center;
  color: var(--fg-faint);
  font-size: 0.88rem;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 0.6rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  z-index: 60;
  max-width: 90vw;
}
.toast.error {
  border-color: rgba(248, 81, 73, 0.5);
  color: #ffb4ae;
}
.toast.success {
  border-color: rgba(63, 185, 80, 0.5);
}

[hidden] {
  display: none !important;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .brand-text .tagline {
    display: none;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    height: auto;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
  }
  /* Once a repo is open the repo bar carries the identity, so reclaim the
     vertical space the "git" brand would otherwise use. */
  .repo-open .topbar .brand {
    display: none;
  }

  .repo-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  .repo-meta {
    display: none;
  }

  /* Keep the controls on a single, horizontally scrollable row instead of
     wrapping into a tall, cramped block. */
  .repo-actions {
    gap: 0.4rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .repo-actions::-webkit-scrollbar {
    display: none;
  }
  .repo-actions > * {
    flex: 0 0 auto;
  }
  .repo-actions .btn {
    height: 38px;
  }
  .branch-picker {
    height: 38px;
  }
  .branch-picker select {
    max-width: 38vw;
  }

  /* The viewer header gains several actions; let them scroll horizontally
     instead of squeezing the file path or wrapping into a tall block. */
  .viewer-head-actions {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .viewer-head-actions::-webkit-scrollbar {
    display: none;
  }
  .viewer-head-actions > * {
    flex: 0 0 auto;
  }

  .browser-view {
    flex-direction: column;
  }
  .sidebar {
    flex: 0 0 auto;
    max-width: none;
    width: 100%;
    max-height: 42vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .history-panel {
    width: 100%;
    max-width: none;
  }
  .btn {
    font-size: 0.8rem;
    padding: 0 0.7rem;
  }
}
