/* git.css — Apple/Finder-flavoured Git Browser overlay.
   Ported from the KKTerm redesign mockup and scoped to `.git-browser`. Shared
   chrome reads app color-scheme tokens from `src/styles/colorSchemes.css`; only
   git-specific lane/diff tints are defined locally, switched by data-git-theme
   (resolved from the surface luminance, not a hard-coded scheme name). */

.git-browser {
  /* chrome tokens mapped onto app color-scheme variables */
  --git-bg: var(--surface);
  --git-chrome: var(--surface-muted);
  --git-chrome-2: var(--app-bg);
  --git-sidebar: var(--app-bg);
  --git-muted: var(--surface-muted);
  --git-hover: var(--hover);
  --git-press: var(--press);
  --git-text: var(--text);
  --git-text-2: var(--text-muted);
  --git-text-3: var(--text-faint);
  --git-hairline: var(--hairline);
  --git-border: var(--border);
  --git-accent: var(--accent);
  --git-accent-press: var(--accent-press);
  --git-sel: var(--sel);
  --git-sel-text: #ffffff;
  --git-sel-soft: var(--sel-soft);
  --git-green: var(--green);
  --git-amber: var(--amber);
  --git-red: var(--red);
  --git-ring: var(--ring);
  --git-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Menlo", "Consolas", monospace;
  --git-row-h: 30px;
  --git-row-font: 12.5px;

  /* diff + status tints derived from the semantic tokens (light defaults) */
  --git-add-bg: color-mix(in srgb, var(--green) 16%, var(--surface));
  --git-add-text: color-mix(in srgb, var(--green) 70%, var(--text));
  --git-del-bg: color-mix(in srgb, var(--red) 14%, var(--surface));
  --git-del-text: color-mix(in srgb, var(--red) 72%, var(--text));
  --git-diff-add: color-mix(in srgb, var(--green) 12%, var(--surface));
  --git-diff-add-gutter: color-mix(in srgb, var(--green) 26%, var(--surface));
  --git-diff-del: color-mix(in srgb, var(--red) 11%, var(--surface));
  --git-diff-del-gutter: color-mix(in srgb, var(--red) 24%, var(--surface));

  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1472px, 94vw);
  height: min(880px, 92vh);
  max-width: 98vw;
  max-height: 96vh;
  background: var(--git-bg);
  border: 1px solid var(--git-border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.16);
  color: var(--git-text);
  font-family: -apple-system, "SF Pro Text", "Inter", "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: var(--git-row-font);
  line-height: 1.4;
}
.git-browser * { box-sizing: border-box; }

/* The overlay backdrop centers the panel above all workspace chrome. */
.git-overlay-backdrop {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── titlebar ───────────────────────────────────────────────────────────── */
.git-titlebar {
  display: flex; align-items: center; gap: 12px;
  height: 44px; padding: 0 10px 0 14px;
  background: var(--git-chrome);
  border-bottom: 1px solid var(--git-hairline);
  flex: 0 0 auto;
}
.git-title-id { display: flex; align-items: center; gap: 9px; font-weight: 640; font-size: 13px; letter-spacing: -0.01em; }
.git-title-id .repo-glyph { display: inline-flex; color: var(--git-accent); }
.git-branch-pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 21px; padding: 0 9px 0 7px; border-radius: 999px;
  background: var(--git-muted); color: var(--git-text-2);
  font-size: 11px; font-weight: 600;
}
.git-branch-pill .gl { display: inline-flex; color: var(--git-text-2); }
.git-titlebar-spacer { flex: 1 1 auto; }
.git-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 7px;
  background: transparent; border: 0; color: var(--git-text-2); cursor: pointer;
}
.git-icon-btn:hover { background: var(--git-hover); color: var(--git-text); }
.git-icon-btn.is-active {
  background: color-mix(in srgb, var(--git-accent) 18%, transparent);
  color: var(--git-accent);
}

/* ── toolbar ────────────────────────────────────────────────────────────── */
.git-toolbar {
  display: flex; align-items: center; gap: 8px;
  height: 48px; padding: 0 12px;
  background: var(--git-chrome);
  border-bottom: 1px solid var(--git-hairline);
  flex: 0 0 auto;
}
.git-tb-spacer { flex: 1 1 auto; }
.git-tb-group { display: inline-flex; align-items: center; gap: 4px; }
.git-tb-sep { width: 1px; height: 24px; background: var(--git-hairline); margin: 0 4px; }
.git-toolbar .act {
  position: relative;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; min-width: 50px; height: 38px; padding: 0 8px; border-radius: 8px;
  border: 0; background: transparent; color: var(--git-text-2); cursor: pointer;
}
.git-toolbar .act .gl { display: inline-flex; }
.git-toolbar .act .lbl { font-size: 10.5px; font-weight: 600; }
.git-toolbar .act .cnt {
  position: absolute; top: 2px; right: 4px;
  min-width: 15px; height: 15px; padding: 0 4px; border-radius: 999px;
  background: var(--git-accent); color: #fff; font-size: 9.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.git-toolbar .act:hover:not(:disabled) { background: var(--git-hover); color: var(--git-text); }
.git-toolbar .act:disabled { opacity: 0.45; cursor: default; }

.git-segmented {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 2px; border-radius: 8px; background: var(--git-chrome-2);
  box-shadow: inset 0 0 0 0.5px var(--git-border);
}
.git-segmented button {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  height: 26px; padding: 0 11px; border: 0; border-radius: 6px;
  background: transparent; color: var(--git-text-2); cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 600;
}
.git-segmented button:hover { color: var(--git-text); }
.git-segmented button.active {
  background: var(--git-bg); color: var(--git-text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18), 0 0 0 0.5px rgba(0, 0, 0, 0.05);
}
.git-search {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px; min-width: 170px;
  border-radius: 8px; background: var(--git-muted);
  color: var(--git-text-3); box-shadow: inset 0 0 0 0.5px var(--git-border);
}
.git-search input { border: 0; background: transparent; outline: none; color: var(--git-text); font: inherit; width: 100%; }
.git-search input::placeholder { color: var(--git-text-3); }

.git-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 12px; border-radius: 8px;
  font-size: 12.5px; font-weight: 590; cursor: pointer;
  border: 0.5px solid var(--git-border); background: var(--git-bg); color: var(--git-text);
}
.git-btn:hover:not(:disabled) { background: var(--git-hover); }
.git-btn:disabled { color: var(--git-text-3); cursor: default; opacity: 0.5; }
.git-btn.primary { background: var(--git-accent); color: #fff; border-color: transparent; }
.git-btn.primary:hover:not(:disabled) { background: var(--git-accent-press); }
.git-btn.primary:disabled { background: var(--git-muted); color: var(--git-text-3); }

/* ── body grid ──────────────────────────────────────────────────────────── */
.git-body { display: flex; flex: 1 1 0; min-height: 0; }

/* ── resize: window grip/edges + inline pane splitters ──────────────────── */
/* Window edge + corner grips, anchored to the overlay (position: relative). */
.git-resize-edge-e { position: absolute; top: 0; right: 0; width: 6px; height: 100%; cursor: ew-resize; z-index: 6; }
.git-resize-edge-s { position: absolute; left: 0; bottom: 0; width: 100%; height: 6px; cursor: ns-resize; z-index: 6; }
.git-resize-corner {
  position: absolute; right: 0; bottom: 0; width: 16px; height: 16px;
  cursor: nwse-resize; z-index: 7;
  background:
    linear-gradient(135deg, transparent 0 50%, var(--git-text-3) 50% 60%, transparent 60% 72%, var(--git-text-3) 72% 82%, transparent 82%);
  opacity: 0.5;
}
.git-resize-corner:hover { opacity: 0.9; }

/* Vertical splitter between two inline panes. A thin hit-area straddling the
   existing 1px pane border; a center rule lights up on hover/drag. */
.git-pane-resizer {
  flex: 0 0 auto; width: 7px; margin: 0 -3.5px; z-index: 5;
  cursor: ew-resize; align-self: stretch;
  background: transparent; position: relative;
}
.git-pane-resizer::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%;
  width: 1px; transform: translateX(-0.5px); background: transparent;
}
.git-pane-resizer:hover::after { background: var(--git-accent); }

/* sidebar */
.git-sidebar {
  flex: 0 0 232px; min-width: 232px;
  background: var(--git-sidebar); border-right: 1px solid var(--git-hairline);
  display: flex; flex-direction: column; overflow-y: auto;
  padding: 8px 8px 14px;
}
.git-sb-group { padding: 12px 8px 3px 10px; display: flex; align-items: center; gap: 6px; }
.git-sb-group .t { font-size: 11px; font-weight: 700; color: var(--git-text-3); letter-spacing: 0.03em; text-transform: uppercase; flex: 1 1 auto; }
.git-sb-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  height: 30px; padding: 0 9px; border: 0; border-radius: 7px;
  background: transparent; color: var(--git-text); font: inherit; font-size: 13px;
  font-weight: 500; cursor: pointer; text-align: left;
}
.git-sb-item.git-sb-sub { padding-left: 28px; }
.git-sb-item.git-sb-more .nm { color: var(--git-text-3); font-size: 12px; }
.git-sb-item .gl { display: inline-flex; flex: 0 0 auto; }
.git-sb-item .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; }
.git-sb-item:hover { background: var(--git-hover); }
.git-sb-item.sel { background: var(--git-sel-soft); }
.git-sb-item.active { background: var(--git-accent); color: #fff; }
.git-sb-item.active.sel { box-shadow: inset 0 0 0 1.5px var(--git-sel); }
.git-sb-item.active .gl { color: rgba(255, 255, 255, 0.95) !important; }
.git-sb-item .git-sb-tag {
  flex: 0 0 auto; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  height: 16px; padding: 0 6px; border-radius: 5px; font-size: 10px; font-weight: 700;
  background: var(--git-muted); color: var(--git-text-3);
  display: inline-flex; align-items: center;
}
.git-sb-item.active .git-sb-tag { background: rgba(255, 255, 255, 0.22); color: #fff; }
.git-sb-group .git-sb-add {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border: 0; border-radius: 5px; background: transparent;
  color: var(--git-text-3); cursor: pointer;
}
.git-sb-group .git-sb-add:hover { background: var(--git-hover); color: var(--git-text); }
.git-sb-item .ab { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.git-sb-item .ab .up { color: var(--git-green); }
.git-sb-item .ab .down { color: var(--git-amber); }
.git-sb-remote-head { cursor: default; }
.git-sb-stash { cursor: default; }
.git-stash-actions { display: none; align-items: center; gap: 2px; flex: 0 0 auto; }
.git-sb-stash:hover .git-stash-actions { display: inline-flex; }
.git-stash-actions button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border: 0; border-radius: 5px; background: transparent;
  color: var(--git-text-2); cursor: pointer;
}
.git-stash-actions button:hover { background: var(--git-hover); color: var(--git-text); }

/* ── commit graph ───────────────────────────────────────────────────────── */
.git-graph-wrap { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; background: var(--git-bg); }
.git-graph-colhead {
  display: flex; align-items: center; height: 28px; padding: 0 14px;
  border-bottom: 1px solid var(--git-hairline); color: var(--git-text-3);
  font-size: 11px; font-weight: 600; flex: 0 0 auto; user-select: none;
}
.git-graph-colhead .c-msg { flex: 1 1 auto; }
.git-graph-colhead .c-author { width: var(--git-col-author, 150px); flex: 0 0 auto; position: relative; }
.git-graph-colhead .c-sha { width: var(--git-col-sha, 78px); flex: 0 0 auto; position: relative; }
.git-graph-colhead .c-date { width: var(--git-col-date, 96px); flex: 0 0 auto; text-align: right; position: relative; }
.git-col-resizer {
  position: absolute; left: -4px; top: 0; bottom: 0; width: 8px;
  cursor: ew-resize; z-index: 4;
}
.git-col-resizer::after {
  content: ""; position: absolute; left: 3px; top: 5px; bottom: 5px; width: 1px;
  background: var(--git-hairline);
}
.git-col-resizer:hover::after { background: var(--git-accent, var(--git-text-3)); }

.git-graph-scroll { position: relative; flex: 1 1 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.git-graph-canvas { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 1; }
.git-commit-rows { position: relative; z-index: 2; }
.git-commit-row {
  display: flex; align-items: center; height: var(--git-row-h);
  padding: 0 14px 0 0; cursor: default; user-select: none;
}
.git-commit-row:hover { background: var(--git-hover); }
.git-commit-row.sel { background: var(--git-sel); color: var(--git-sel-text); }
.git-commit-row.sel .c-sha, .git-commit-row.sel .c-date, .git-commit-row.sel .c-author .nm { color: rgba(255, 255, 255, 0.86); }
.git-commit-row .git-refs { display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto; margin-right: 9px; }
.git-ref {
  display: inline-flex; align-items: center; gap: 4px; height: 19px;
  padding: 0 7px 0 6px; border-radius: 5px; font-size: 11px; font-weight: 650;
  white-space: nowrap; flex: 0 0 auto;
}
.git-ref .gl { display: inline-flex; }
.git-ref.head { color: #fff; }
.git-ref.branch { background: var(--git-muted); color: var(--git-text); }
.git-ref.remote { background: transparent; box-shadow: inset 0 0 0 1px var(--git-border); color: var(--git-text-2); }
.git-ref.tag { background: color-mix(in srgb, var(--git-amber) 18%, var(--git-bg)); color: color-mix(in srgb, var(--git-amber) 70%, var(--git-text)); }
.git-commit-row .c-msg { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; font-size: var(--git-row-font); }
.git-commit-row .c-author { width: var(--git-col-author, 150px); flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.git-commit-row .c-author .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--git-text-2); font-size: 12px; font-weight: 500; }
.git-commit-row .c-sha { width: var(--git-col-sha, 78px); flex: 0 0 auto; font-family: var(--git-mono); font-size: 11.5px; color: var(--git-text-3); }
.git-commit-row .c-date { width: var(--git-col-date, 96px); flex: 0 0 auto; text-align: right; color: var(--git-text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.git-commit-row.wt .c-msg { color: var(--git-text-2); font-style: italic; }
.git-wt-badge {
  display: inline-flex; align-items: center; gap: 5px; height: 19px; padding: 0 8px;
  border-radius: 5px; background: var(--git-muted); color: var(--git-text-2);
  font-size: 11px; font-weight: 650; margin-right: 9px;
  box-shadow: inset 0 0 0 1px var(--git-border);
  flex: 0 0 auto; white-space: nowrap;
}
.git-avatar {
  width: 20px; height: 20px; border-radius: 50%; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 9.5px; font-weight: 700;
}
.git-avatar.lg { width: 34px; height: 34px; font-size: 13px; }

/* ── detail panel ───────────────────────────────────────────────────────── */
.git-detail {
  flex: 0 0 430px; width: 430px; min-width: 0;
  border-left: 1px solid var(--git-hairline); background: var(--git-bg);
  display: flex; flex-direction: column; overflow: hidden;
}
.git-detail-head {
  padding: 16px 18px 14px; border-bottom: 1px solid var(--git-hairline);
  flex: 0 0 auto; display: flex; flex-direction: column; max-height: 40%; min-height: 0;
}
.git-detail-head .msg { flex: 0 0 auto; font-size: 15px; font-weight: 650; line-height: 1.34; letter-spacing: -0.01em; }
.git-detail-head .body-msg { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin-top: 7px; font-size: 12.5px; color: var(--git-text-2); line-height: 1.5; white-space: pre-wrap; }
.git-detail-meta { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; margin-top: 13px; }
.git-detail-meta .who { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.git-detail-meta .who .n { font-size: 12.5px; font-weight: 600; }
.git-detail-meta .who .e { font-size: 11.5px; color: var(--git-text-3); }
.git-detail-meta .when { margin-left: auto; text-align: right; font-size: 11.5px; color: var(--git-text-3); }
.git-sha-row { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.git-sha-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 6px 0 9px;
  border-radius: 6px; background: var(--git-muted); box-shadow: inset 0 0 0 0.5px var(--git-border);
  font-family: var(--git-mono); font-size: 11.5px; color: var(--git-text);
}
.git-sha-chip .k { font-family: inherit; font-size: 10.5px; font-weight: 700; color: var(--git-text-3); letter-spacing: 0.03em; }
.git-sha-chip .copy { display: inline-flex; color: var(--git-text-3); cursor: pointer; padding: 2px; border-radius: 4px; border: 0; background: transparent; }
.git-sha-chip .copy:hover { color: var(--git-text); background: var(--git-hover); }

.git-files-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 18px 8px;
  font-size: 11px; font-weight: 700; color: var(--git-text-3); letter-spacing: 0.03em; text-transform: uppercase;
  flex: 0 0 auto;
}
.git-files-head .stat { margin-left: auto; display: inline-flex; gap: 8px; font-size: 11px; letter-spacing: 0; text-transform: none; }
.git-files-head .stat .add { color: var(--git-green); }
.git-files-head .stat .del { color: var(--git-red); }
.git-files-list { flex: 1 1 0; min-height: 0; overflow-y: auto; padding: 0 8px 8px; }
.git-file-row {
  display: flex; align-items: center; gap: 9px; height: 30px; padding: 0 8px 0 10px;
  border-radius: 7px; cursor: default; font-size: 12.5px;
}
.git-file-row:hover { background: var(--git-hover); }
.git-file-row.sel { background: var(--git-sel-soft); }
.git-st {
  width: 17px; height: 17px; border-radius: 4px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800;
}
.git-st.M { background: color-mix(in srgb, var(--git-amber) 20%, var(--git-bg)); color: color-mix(in srgb, var(--git-amber) 80%, var(--git-text)); }
.git-st.A { background: var(--git-add-bg); color: var(--git-add-text); }
.git-st.D { background: var(--git-del-bg); color: var(--git-del-text); }
.git-st.R { background: color-mix(in srgb, var(--git-accent) 18%, var(--git-bg)); color: var(--git-accent); }
.git-file-row .path { flex: 1 1 auto; min-width: 0; display: flex; align-items: baseline; gap: 7px; overflow: hidden; }
.git-file-row .path .dir { color: var(--git-text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; font-size: 11.5px; }
.git-file-row .path .name { color: var(--git-text); font-weight: 550; white-space: nowrap; flex: 0 0 auto; max-width: 62%; overflow: hidden; text-overflow: ellipsis; }
.git-file-row .churn { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; font-family: var(--git-mono); font-size: 10.5px; }
.git-file-row .churn .a { color: var(--git-green); }
.git-file-row .churn .d { color: var(--git-red); }

/* ── diff viewer ────────────────────────────────────────────────────────── */
.git-diff { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; background: var(--git-bg); overflow: hidden; }
.git-diff-head {
  display: flex; align-items: center; gap: 9px; height: 36px; padding: 0 14px;
  border-bottom: 1px solid var(--git-hairline); flex: 0 0 auto;
  font-family: var(--git-mono); font-size: 12px; color: var(--git-text-2);
}
.git-diff-head .nm { color: var(--git-text); font-weight: 600; }
.git-diff-head .dir { color: var(--git-text-3); }
.git-diff-head .churn { margin-left: auto; display: inline-flex; gap: 8px; }
.git-diff-head .churn .a { color: var(--git-green); }
.git-diff-head .churn .d { color: var(--git-red); }
.git-diff-body { flex: 1 1 0; min-height: 0; overflow: auto; font-family: var(--git-mono); font-size: 12px; line-height: 1.55; }
.git-diff-loading { padding: 14px; color: var(--git-text-3); font-family: -apple-system, sans-serif; font-size: 12.5px; }
.git-dl { display: flex; min-width: max-content; }
.git-dl .gut { flex: 0 0 auto; width: 46px; padding: 0 8px 0 0; text-align: right; color: var(--git-text-3); user-select: none; font-variant-numeric: tabular-nums; }
.git-dl .code { flex: 1 1 auto; padding: 0 14px 0 8px; white-space: pre; color: var(--git-text); }
.git-dl.hunk { background: color-mix(in srgb, var(--git-accent) 8%, var(--git-bg)); }
.git-dl.hunk .gut { color: color-mix(in srgb, var(--git-accent) 60%, var(--git-text-3)); }
.git-dl.hunk .code { color: color-mix(in srgb, var(--git-accent) 80%, var(--git-text)); }
.git-dl.add { background: var(--git-diff-add); }
.git-dl.add .gut { background: var(--git-diff-add-gutter); color: var(--git-add-text); }
.git-dl.add .code { color: var(--git-add-text); }
.git-dl.del { background: var(--git-diff-del); }
.git-dl.del .gut { background: var(--git-diff-del-gutter); color: var(--git-del-text); }
.git-dl.del .code { color: var(--git-del-text); }

/* ── advanced side-by-side diff ─────────────────────────────────────────── */
.git-adv-backdrop {
  --git-bg: var(--surface);
  --git-chrome: var(--surface-muted);
  --git-chrome-2: var(--app-bg);
  --git-muted: var(--surface-muted);
  --git-text: var(--text);
  --git-text-2: var(--text-muted);
  --git-text-3: var(--text-faint);
  --git-hairline: var(--hairline);
  --git-border: var(--border);
  --git-accent: var(--accent);
  --git-green: var(--green);
  --git-amber: var(--amber);
  --git-red: var(--red);
  --git-add-text: color-mix(in srgb, var(--green) 70%, var(--text));
  --git-del-text: color-mix(in srgb, var(--red) 72%, var(--text));
  --git-diff-add: color-mix(in srgb, var(--green) 12%, var(--surface));
  --git-diff-add-gutter: color-mix(in srgb, var(--green) 26%, var(--surface));
  --git-diff-del: color-mix(in srgb, var(--red) 11%, var(--surface));
  --git-diff-del-gutter: color-mix(in srgb, var(--red) 24%, var(--surface));
  --git-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Menlo", "Consolas", monospace;

  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.34);
}
.git-adv {
  width: min(1848px, 96vw);
  height: min(1064px, 92vh);
  min-width: 640px;
  min-height: 420px;
  max-width: 96vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* User-resizable from the bottom-right corner. */
  resize: both;
  border-radius: 10px;
  border: 1px solid var(--git-border);
  background: var(--git-bg);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.34), 0 8px 24px rgba(0, 0, 0, 0.18);
}
.git-adv-head {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 10px 0 14px;
  border-bottom: 1px solid var(--git-hairline);
  background: var(--git-chrome);
  flex: 0 0 auto;
}
.git-adv-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
  font-family: var(--git-mono);
  font-size: 12px;
}
.git-adv-title .name {
  color: var(--git-text);
  font-weight: 700;
  white-space: nowrap;
}
.git-adv-title .dir {
  color: var(--git-text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.git-adv-search {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 240px;
  height: 28px;
  padding: 0 8px;
  border-radius: 8px;
  background: var(--git-muted);
  color: var(--git-text-3);
  box-shadow: inset 0 0 0 0.5px var(--git-border);
}
.git-adv-search input {
  min-width: 0;
  flex: 1 1 auto;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--git-text);
  font: inherit;
}
.git-adv-search .count {
  min-width: 22px;
  text-align: right;
  font-family: var(--git-mono);
  font-size: 11px;
  color: var(--git-text-3);
}
.diff-sbs {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.diff-sbs-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 10px 0 14px;
  border-bottom: 1px solid var(--git-hairline);
  background: var(--git-chrome);
  flex: 0 0 auto;
}
.diff-sbs-toolbar-spacer {
  flex: 1 1 auto;
}
.git-adv-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  height: 28px;
  border-bottom: 1px solid var(--git-hairline);
  background: var(--git-chrome-2);
  color: var(--git-text-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.git-adv-cols > div {
  display: flex;
  align-items: center;
  padding: 0 12px;
}
.git-adv-cols > div + div {
  border-left: 1px solid var(--git-hairline);
}
.git-adv-body {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  font-family: var(--git-mono);
  font-size: 12px;
  line-height: 1.55;
}
.git-adv-content {
  min-width: max-content;
}
.git-adv-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-width: 980px;
}
.git-adv-row.active {
  outline: 1px solid var(--git-accent);
  outline-offset: -1px;
}
.git-adv-hunk {
  display: block;
  padding: 4px 12px;
  color: color-mix(in srgb, var(--git-accent) 78%, var(--git-text));
  background: color-mix(in srgb, var(--git-accent) 8%, var(--git-bg));
  font-weight: 600;
}
/* "X filtered lines" fold standing in for rows hidden by the diff/same filter;
   click to expand the run. Spans the full width like a hunk header. */
.git-adv-row.git-adv-fold {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  padding: 3px 12px;
  border: 0;
  border-top: 1px solid var(--git-hairline);
  border-bottom: 1px solid var(--git-hairline);
  background: color-mix(in srgb, var(--git-muted) 55%, var(--git-bg));
  color: var(--git-text-3);
  font-size: 11px;
  letter-spacing: 0.02em;
  cursor: pointer;
  /* Pin the row to the viewport width so its centered label stays visible even
     when a wide, un-wrapped diff is scrolled horizontally. */
  position: sticky;
  left: 0;
  width: 100%;
}
.git-adv-row.git-adv-fold:hover {
  color: var(--git-text);
  background: color-mix(in srgb, var(--git-accent) 12%, var(--git-bg));
}
.git-adv-fold-icon {
  flex: 0 0 auto;
  opacity: 0.8;
}
/* The header above an expanded run reads as the inverse of a collapsed fold —
   a faint accent tint so it's clearly the "collapse again" control. */
.git-adv-row.git-adv-fold-open {
  background: color-mix(in srgb, var(--git-accent) 9%, var(--git-bg));
  color: color-mix(in srgb, var(--git-accent) 60%, var(--git-text));
}
.git-adv-row.git-adv-fold-open:hover {
  background: color-mix(in srgb, var(--git-accent) 16%, var(--git-bg));
}
.git-adv-cell {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  min-width: 0;
}
.git-adv-cell + .git-adv-cell {
  border-left: 1px solid var(--git-hairline);
}
.git-adv-cell .no {
  padding: 0 8px 0 0;
  text-align: right;
  color: var(--git-text-3);
  background: color-mix(in srgb, var(--git-chrome) 74%, var(--git-bg));
  user-select: none;
  font-variant-numeric: tabular-nums;
}
.git-adv-cell .txt {
  padding: 0 12px 0 8px;
  white-space: pre;
  overflow: hidden;
  text-overflow: clip;
}
.git-adv-cell.add {
  background: var(--git-diff-add);
  color: var(--git-add-text);
}
.git-adv-cell.add .no {
  background: var(--git-diff-add-gutter);
  color: var(--git-add-text);
}
.git-adv-cell.del {
  background: var(--git-diff-del);
  color: var(--git-del-text);
}
.git-adv-cell.del .no {
  background: var(--git-diff-del-gutter);
  color: var(--git-del-text);
}
.git-adv-cell.blank {
  background: color-mix(in srgb, var(--git-muted) 50%, var(--git-bg));
}

/* Beyond Compare-style intra-line diff. A modification pair (both sides changed)
   keeps the line clean — only a faint neutral wash plus a muted line-number
   gutter — instead of a full red/green fill, so the per-character highlights
   stand out. Only the differing character runs get a clear red block with red
   text; unchanged runs stay normal-colored. Pure add/del lines (one side only,
   no char segments) keep their solid green/red fill above. */
.git-adv-row.mod-pair .git-adv-cell.del,
.git-adv-row.mod-pair .git-adv-cell.add {
  background: color-mix(in srgb, var(--git-amber) 7%, transparent);
  color: var(--git-text);
}
.git-adv-row.mod-pair .git-adv-cell.del .no,
.git-adv-row.mod-pair .git-adv-cell.add .no {
  background: color-mix(in srgb, var(--git-amber) 16%, var(--git-chrome));
  color: var(--git-text-3);
}
.git-adv-cell .txt .seg-diff {
  background: color-mix(in srgb, var(--git-red) 26%, transparent);
  color: var(--git-del-text);
  border-radius: 2px;
}
.git-adv-cell.search-hit .txt {
  background: color-mix(in srgb, var(--git-amber) 26%, transparent);
}
/* Word-wrap mode: let long lines wrap instead of forcing horizontal scroll. */
.diff-sbs.wrap .git-adv-content {
  min-width: 0;
}
.diff-sbs.wrap .git-adv-row {
  min-width: 0;
}
.diff-sbs.wrap .git-adv-cell .txt {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: visible;
  text-overflow: clip;
}
.git-adv-mode {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 28px;
  padding: 2px;
  border-radius: 8px;
  background: var(--git-muted);
  box-shadow: inset 0 0 0 0.5px var(--git-border);
}
.git-adv-mode button {
  height: 24px;
  padding: 0 11px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--git-text-2);
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
.git-adv-mode button:hover { color: var(--git-text); }
.git-adv-mode button.active {
  background: var(--git-bg);
  color: var(--git-text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}
.git-adv-main {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
}
.git-adv-map {
  position: relative;
  flex: 0 0 auto;
  width: 18px;
  border-right: 1px solid var(--git-hairline);
  background: var(--git-chrome-2);
  overflow: hidden;
  touch-action: none;
}
.git-adv-map.scrollable { cursor: pointer; }
.git-adv-map.scrollable:active { cursor: grabbing; }
.git-adv-map-window {
  position: absolute;
  left: 0;
  right: 0;
  min-height: 8px;
  background: color-mix(in srgb, var(--git-accent) 16%, transparent);
  border-top: 1px solid color-mix(in srgb, var(--git-accent) 45%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--git-accent) 45%, transparent);
  pointer-events: none;
}
.git-adv-map-marker {
  position: absolute;
  left: 2px;
  right: 2px;
  height: 3px;
  margin-top: -1.5px;
  padding: 0;
  border: 0;
  border-radius: 1px;
  cursor: pointer;
}
.git-adv-map-marker:hover {
  height: 5px;
  margin-top: -2.5px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--git-text) 40%, transparent);
}
.git-adv-map-marker.add { background: var(--git-green); }
.git-adv-map-marker.del { background: var(--git-red); }
.git-adv-map-marker.mod { background: var(--git-amber); }
.git-browser[data-git-theme="dark"] ~ .git-adv-backdrop {
  --git-add-text: color-mix(in srgb, var(--green) 78%, #ffffff);
  --git-del-text: color-mix(in srgb, var(--red) 80%, #ffffff);
  --git-diff-add: color-mix(in srgb, var(--green) 18%, var(--surface));
  --git-diff-add-gutter: color-mix(in srgb, var(--green) 34%, var(--surface));
  --git-diff-del: color-mix(in srgb, var(--red) 18%, var(--surface));
  --git-diff-del-gutter: color-mix(in srgb, var(--red) 36%, var(--surface));
}

/* ── working tree pane ──────────────────────────────────────────────────── */
.git-wt-pane { flex: 0 0 380px; width: 380px; border-right: 1px solid var(--git-hairline); display: flex; flex-direction: column; background: var(--git-bg); overflow: hidden; }
.git-wt-section-head {
  display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px 0 14px;
  background: var(--git-chrome); border-bottom: 1px solid var(--git-hairline); border-top: 1px solid var(--git-hairline);
  flex: 0 0 auto; cursor: default;
}
.git-wt-section-head:first-child { border-top: 0; }
.git-wt-section-head .t { font-size: 11px; font-weight: 700; color: var(--git-text-2); letter-spacing: 0.03em; text-transform: uppercase; flex: 1 1 auto; }
.git-wt-section-head .cnt { font-size: 11px; font-weight: 700; color: var(--git-text-3); font-variant-numeric: tabular-nums; }
.git-wt-section-head .mini { display: inline-flex; align-items: center; justify-content: center; height: 20px; padding: 0 8px; border-radius: 6px; border: 0.5px solid var(--git-border); background: var(--git-bg); color: var(--git-text-2); font-size: 11px; font-weight: 600; cursor: pointer; }
.git-wt-section-head .mini:hover:not(:disabled) { background: var(--git-hover); color: var(--git-text); }
.git-wt-section-head .mini:disabled { opacity: 0.4; cursor: default; }
.git-wt-list { overflow-y: auto; padding: 5px 8px; flex: 0 1 auto; }
.git-wt-list.staged { background: color-mix(in srgb, var(--git-green) 5%, var(--git-bg)); }
.git-wt-empty { padding: 10px 12px; color: var(--git-text-3); font-size: 12px; }
.git-wt-row { display: flex; align-items: center; gap: 9px; height: 30px; padding: 0 8px; border-radius: 7px; cursor: default; font-size: 12.5px; }
.git-wt-row:hover { background: var(--git-hover); }
.git-wt-row.sel { background: var(--git-sel-soft); }
.git-wt-row .path { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.git-wt-row .path .dir2 { color: var(--git-text-3); }
.git-wt-row .churn { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; font-family: var(--git-mono); font-size: 10.5px; }
.git-wt-row .churn .a { color: var(--git-green); }
.git-wt-row .churn .d { color: var(--git-red); }
.git-wt-row-actions { display: none; flex: 0 0 auto; align-items: center; }
.git-wt-row:hover .git-wt-row-actions { display: inline-flex; }
.git-wt-row-actions button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border: 0; border-radius: 5px; background: transparent;
  color: var(--git-text-3); cursor: pointer;
}
.git-wt-row-actions button:hover { background: var(--git-hover); color: var(--git-red); }
.git-chk {
  width: 16px; height: 16px; border-radius: 4px; flex: 0 0 auto; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--git-border); color: #fff; background: var(--git-bg);
}
.git-chk.on { background: var(--git-accent); border-color: var(--git-accent); }
.git-wt-commit-box { flex: 0 0 auto; border-top: 1px solid var(--git-hairline); padding: 12px 14px 14px; background: var(--git-chrome); }
.git-wt-commit-box textarea {
  width: 100%; min-height: 64px; resize: none; border-radius: 9px; padding: 9px 11px;
  border: 0.5px solid var(--git-border); background: var(--git-bg); color: var(--git-text); font: inherit; font-size: 13px; outline: none;
}
.git-wt-commit-box textarea:focus { border-color: var(--git-accent); box-shadow: var(--git-ring); }
.git-wt-commit-box .row2 { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.git-amend { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--git-text-2); cursor: pointer; }
.git-amend .git-chk { width: 15px; height: 15px; }

/* ── empty / loading / gate ─────────────────────────────────────────────── */
.git-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 8px; color: var(--git-text-3); font-size: 13px; padding: 24px; text-align: center; }
.git-empty .gl { color: var(--git-text-3); opacity: 0.7; }
.git-loading { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--git-text-2); font-size: 13px; }
.git-load-error .detail { font-family: var(--git-mono); font-size: 11.5px; color: var(--git-red); max-width: 70%; text-align: center; }
.git-gate { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 32px; text-align: center; }
.git-gate .glyph { color: var(--git-accent); }
.git-gate h3 { margin: 0; font-size: 16px; font-weight: 650; }
.git-gate p { margin: 0; max-width: 380px; color: var(--git-text-2); font-size: 13px; line-height: 1.5; }
.git-gate-error { color: var(--git-red); font-family: var(--git-mono); font-size: 11.5px; }

/* ── context menu ───────────────────────────────────────────────────────── */
.git-ctx-backdrop { position: fixed; inset: 0; z-index: 50; }
.git-ctx-menu {
  position: fixed; z-index: 51; min-width: 200px; padding: 5px;
  background: color-mix(in srgb, var(--git-bg) 92%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border: 0.5px solid var(--git-border); border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28), 0 2px 8px rgba(0, 0, 0, 0.16);
}
.git-ctx-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 28px; padding: 0 10px;
  border: 0; border-radius: 6px; background: transparent; color: var(--git-text); font: inherit; font-size: 13px; cursor: default; text-align: left;
}
.git-ctx-menu button .gl { color: var(--git-text-2); display: inline-flex; }
.git-ctx-menu button:hover { background: var(--git-accent); color: #fff; }
.git-ctx-menu button:hover .gl { color: #fff; }
.git-ctx-menu button.danger:hover { background: var(--git-red); }
.git-ctx-menu .sep { height: 1px; margin: 5px 8px; background: var(--git-hairline); }

/* dark-theme diff tints: blend toward the dark surface for legible contrast */
.git-browser[data-git-theme="dark"] {
  --git-add-bg: color-mix(in srgb, var(--green) 26%, var(--surface));
  --git-add-text: color-mix(in srgb, var(--green) 78%, #ffffff);
  --git-del-bg: color-mix(in srgb, var(--red) 26%, var(--surface));
  --git-del-text: color-mix(in srgb, var(--red) 80%, #ffffff);
  --git-diff-add: color-mix(in srgb, var(--green) 18%, var(--surface));
  --git-diff-add-gutter: color-mix(in srgb, var(--green) 34%, var(--surface));
  --git-diff-del: color-mix(in srgb, var(--red) 18%, var(--surface));
  --git-diff-del-gutter: color-mix(in srgb, var(--red) 36%, var(--surface));
}
