:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  color-scheme: light dark;
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #fafafa;
  color: #1a1a1a;
  /* The panel window is a fixed size (resizable: false) and panel-body
   * owns its own vertical scroll — nothing should ever scroll at the
   * document level. A chip dropdown that mis-anchors past the panel
   * edge must clip, not spawn a scrollbar. Hard guard against both axes. */
  overflow: hidden;
}

@media (prefers-color-scheme: dark) {
  html,
  body,
  #root {
    background: #1a1a1a;
    color: #ededed;
  }
}

.panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  /* visible so chip dropdowns can overlay the body. The webview itself
     still clips to the OS window — that's fine, our panel is sized to
     contain dropdowns within it. */
  overflow: visible;
}

/* ----- header (title + chips on one row) ----- */

.panel-header {
  display: flex;
  align-items: stretch;
  gap: calc(8px * var(--ui-scale, 1));
  padding: calc(6px * var(--ui-scale, 1)) calc(12px * var(--ui-scale, 1));
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  min-height: calc(36px * var(--ui-scale, 1));
}

@media (prefers-color-scheme: dark) {
  .panel-header {
    border-bottom-color: rgba(255, 255, 255, 0.08);
  }
}

.panel-header-icon {
  width: calc(18px * var(--ui-scale, 1));
  height: calc(18px * var(--ui-scale, 1));
  flex-shrink: 0;
  border-radius: 4px;
  align-self: center;
  user-select: none;
  -webkit-user-select: none;
}

.header-chips {
  display: flex;
  align-items: center;
  gap: calc(4px * var(--ui-scale, 1));
  flex-shrink: 0;
}

/* Upstream ahead/behind badge in single-repo mode. Read-only — sits next
 * to the BranchChip and shows how far the local branch has drifted from
 * its origin/<branch> tracking ref. Tooltip explains the local-only,
 * no-fetch caveat. Deliberately not a button: it's an info badge. */
.upstream-badge {
  display: inline-flex;
  align-items: center;
  gap: calc(3px * var(--ui-scale, 1));
  padding: 0 calc(6px * var(--ui-scale, 1));
  height: calc(20px * var(--ui-scale, 1));
  border-radius: 10px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: calc(10px * var(--ui-scale, 1));
  font-weight: 600;
  cursor: help;
  user-select: none;
  white-space: nowrap;
}
.upstream-badge-synced {
  /* glyph-only when in sync — minimum footprint */
  padding: 0 calc(5px * var(--ui-scale, 1));
  background: rgba(60, 160, 100, 0.12);
  color: rgba(40, 130, 80, 0.95);
}
.upstream-badge-diverged {
  background: rgba(220, 140, 40, 0.14);
  color: rgba(200, 120, 30, 0.95);
}
.upstream-badge-check {
  font-weight: 700;
}
.upstream-badge-ref {
  font-weight: 500;
  opacity: 0.85;
}
.upstream-badge-ahead,
.upstream-badge-behind {
  font-variant-numeric: tabular-nums;
}
.upstream-badge-ahead + .upstream-badge-behind {
  margin-left: 2px;
}

@media (prefers-color-scheme: dark) {
  .upstream-badge-synced {
    background: rgba(80, 200, 130, 0.16);
    color: rgba(120, 220, 160, 0.95);
  }
  .upstream-badge-diverged {
    background: rgba(255, 180, 80, 0.18);
    color: rgba(255, 200, 120, 0.95);
  }
}

.panel-drag-handle {
  flex: 1;
  cursor: grab;
  align-self: stretch;
}

.panel-drag-handle:active {
  cursor: grabbing;
}

.panel-status {
  font-size: calc(11px * var(--ui-scale, 1));
  opacity: 0.6;
  flex-shrink: 0;
}

.panel-close {
  flex-shrink: 0;
  width: calc(22px * var(--ui-scale, 1));
  height: calc(22px * var(--ui-scale, 1));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  font-size: calc(11px * var(--ui-scale, 1));
  cursor: pointer;
  border-radius: 4px;
  opacity: 0.55;
  align-self: center;
}

.panel-pin {
  flex-shrink: 0;
  width: calc(22px * var(--ui-scale, 1));
  height: calc(22px * var(--ui-scale, 1));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  font-size: calc(12px * var(--ui-scale, 1));
  cursor: pointer;
  border-radius: 4px;
  opacity: 0.4;
  align-self: center;
}

.panel-pin:hover {
  background: rgba(0, 0, 0, 0.08);
  opacity: 0.7;
}

.panel-pin.pinned {
  opacity: 1;
  color: rgb(80, 130, 240);
}

@media (prefers-color-scheme: dark) {
  .panel-pin:hover {
    background: rgba(255, 255, 255, 0.10);
  }
  .panel-pin.pinned {
    color: rgb(140, 180, 255);
  }
}

.panel-close:hover {
  background: rgba(0, 0, 0, 0.08);
  opacity: 1;
}

@media (prefers-color-scheme: dark) {
  .panel-close:hover {
    background: rgba(255, 255, 255, 0.10);
  }
}

/* ----- chips (live inside .header-chips now) ----- */

.chip-wrap {
  position: relative;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: calc(4px * var(--ui-scale, 1));
  padding: calc(3px * var(--ui-scale, 1)) calc(9px * var(--ui-scale, 1));
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 12px;
  background: #fff;
  color: inherit;
  font: inherit;
  font-size: calc(11px * var(--ui-scale, 1));
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  /* Cap individual chip width so a long branch / repo name can't push
   * the ✕ off the header. Full text stays available via the chip's
   * title attribute. Scales with UI so wider text at high scale still
   * fits proportionally. */
  max-width: calc(160px * var(--ui-scale, 1));
  min-width: 0;
}

.chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.chip:hover {
  background: #f4f4f6;
}

.chip.open {
  background: rgba(80, 130, 240, 0.16);
  border-color: rgba(80, 130, 240, 0.55);
}

.chip.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (prefers-color-scheme: dark) {
  .chip {
    background: #2a2a2c;
    border-color: rgba(255, 255, 255, 0.14);
  }
  .chip:hover {
    background: #34343a;
  }
  .chip.open {
    background: rgba(140, 180, 255, 0.2);
    border-color: rgba(140, 180, 255, 0.55);
  }
}

.chip-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}

.chip-clear {
  display: inline-flex;
  width: calc(14px * var(--ui-scale, 1));
  height: calc(14px * var(--ui-scale, 1));
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  font-size: calc(10px * var(--ui-scale, 1));
  opacity: 0.7;
}

.chip-clear:hover {
  background: rgba(0, 0, 0, 0.15);
  opacity: 1;
}

.chip-caret {
  font-size: calc(9px * var(--ui-scale, 1));
  opacity: 0.55;
  flex-shrink: 0;
}

.chip-dropdown {
  position: absolute;
  top: calc(100% + calc(4px * var(--ui-scale, 1)));
  z-index: 50;
  width: calc(280px * var(--ui-scale, 1));
  max-height: calc(320px * var(--ui-scale, 1));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
}

.chip-dropdown-left {
  left: 0;
}

.chip-dropdown-right {
  right: 0;
}

@media (prefers-color-scheme: dark) {
  .chip-dropdown {
    background: #2a2a2c;
    border-color: rgba(255, 255, 255, 0.16);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  }
}

.chip-search {
  padding: calc(6px * var(--ui-scale, 1));
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
  .chip-search {
    border-bottom-color: rgba(255, 255, 255, 0.06);
  }
}

.chip-search input {
  width: 100%;
  padding: calc(4px * var(--ui-scale, 1)) calc(8px * var(--ui-scale, 1));
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: calc(12px * var(--ui-scale, 1));
  outline: none;
}

.chip-search input:focus {
  border-color: rgba(80, 130, 240, 0.6);
}

.chip-list {
  max-height: calc(320px * var(--ui-scale, 1));
  overflow-y: auto;
  overflow-x: hidden;
}

/* Virtualised chip dropdown: the height is set inline to the computed
 * viewport, and flex:none stops the flex column from shrinking it. */
.chip-vlist {
  flex: none;
}

/* Full-height spacer track — its height is the sum of every row, so the
 * native scrollbar reflects the true list length. */
.chip-vtrack {
  position: relative;
  width: 100%;
}

/* One virtual row, absolutely placed at its prefix-sum offset. The JS
   virtualizer sets `height` inline from `chipRowH(scale, base)` so the
   row box is an integer. Children scale via calc(... * var(--ui-scale))
   independently. `overflow: hidden` keeps a future
   larger-than-expected child (longer localized label, larger font
   metric, extra badge) from leaking visually into the next virtual
   row — the row geometry stays whatever chipRowH said it is. */
.chip-vrow {
  position: absolute;
  left: 0;
  right: 0;
  overflow: hidden;
}

.chip-section {
  padding: calc(6px * var(--ui-scale, 1)) calc(10px * var(--ui-scale, 1)) calc(2px * var(--ui-scale, 1));
  font-size: calc(10px * var(--ui-scale, 1));
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.55;
}

/* "All repos" is a section header that also resets the filter — styled
 * to read as interactive (hover, active), unlike the plain Pinned label. */
.chip-section-all {
  display: block;
  width: 100%;
  padding: calc(6px * var(--ui-scale, 1)) calc(10px * var(--ui-scale, 1)) calc(4px * var(--ui-scale, 1));
  border: none;
  background: transparent;
  font: inherit;
  font-size: calc(10px * var(--ui-scale, 1));
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
  color: inherit;
  opacity: 0.7;
  cursor: pointer;
}

.chip-section-all:hover {
  opacity: 0.95;
  background: rgba(0, 0, 0, 0.05);
}

.chip-section-all.active {
  opacity: 1;
  color: rgb(80, 130, 240);
}

@media (prefers-color-scheme: dark) {
  .chip-section-all:hover {
    background: rgba(255, 255, 255, 0.06);
  }
}

.chip-item-row {
  display: flex;
  align-items: center;
  gap: calc(5px * var(--ui-scale, 1));
  padding-right: calc(6px * var(--ui-scale, 1));
  padding-left: calc(6px * var(--ui-scale, 1));
  min-width: 0;
  max-width: 100%;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

/* Checked into the multi-repo filter — kept subtle: the filled checkbox is
   the primary signal. Declared before `.active` so that an active row
   which is ALSO checked still reads as active (equal specificity). */
.chip-item-row.selected {
  background: rgba(80, 130, 240, 0.07);
}

/* Single-repo mode: the repo you've drilled into. A left accent bar plus a
   firmer fill set it clearly apart from a merely checked row — the two
   were near-identical blue tints before. */
.chip-item-row.active {
  background: rgba(80, 130, 240, 0.16);
  box-shadow: inset 3px 0 0 #5082f0;
}

@media (prefers-color-scheme: dark) {
  .chip-item-row.selected {
    background: rgba(80, 130, 240, 0.13);
  }
  .chip-item-row.active {
    background: rgba(80, 130, 240, 0.28);
  }
}

/* Custom checkbox for the multi-repo filter. Rendered as a
 * <button role="checkbox"> so it's focusable and keyboard-operable. */
.chip-checkbox {
  width: calc(20px * var(--ui-scale, 1));
  height: calc(20px * var(--ui-scale, 1));
  box-sizing: border-box;
  flex-shrink: 0;
  padding: 0;
  cursor: pointer;
  border: 2px solid rgba(128, 128, 128, 0.35);
  border-radius: 5px;
  transition: border-color 0.15s ease, background 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.6);
}

@media (prefers-color-scheme: dark) {
  .chip-checkbox {
    border-color: rgba(255, 255, 255, 0.28);
    background: rgba(0, 0, 0, 0.4);
  }
}

.chip-checkbox:not(.readonly):hover {
  border-color: rgba(80, 130, 240, 0.6);
}

.chip-checkbox.checked {
  background: linear-gradient(135deg, #5082f0, #4a7ae8);
  border-color: #5082f0;
}

.chip-checkbox.checked:not(.readonly):hover {
  background: linear-gradient(135deg, #5a8cf5, #5489f0);
}

/* Single-repo mode: the multi-select filter is dormant, so the checkbox
 * is shown disabled rather than removed — layout stays put and the
 * feature stays discoverable. */
.chip-checkbox.readonly {
  cursor: not-allowed;
  opacity: 0.4;
}

.chip-checkbox-icon {
  color: white;
  font-size: calc(13px * var(--ui-scale, 1));
  font-weight: 700;
  line-height: 1;
  animation: checkmark 0.15s ease-out;
}

@keyframes checkmark {
  from {
    transform: scale(0);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.chip-item {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: calc(1px * var(--ui-scale, 1));
  padding: calc(5px * var(--ui-scale, 1)) calc(10px * var(--ui-scale, 1));
  background: transparent;
  border: none;
  color: inherit;
  font: inherit;
  font-size: calc(12px * var(--ui-scale, 1));
  text-align: left;
  cursor: pointer;
}

/* In a repo row the checkbox + row gap already provide the left inset;
 * the item's own padding (sized for the pre-checkbox layout) would
 * double up. Trim it so the checkbox sits evenly after the row edge. */
.chip-item-row .chip-item {
  padding-left: calc(2px * var(--ui-scale, 1));
  padding-right: calc(6px * var(--ui-scale, 1));
}

.chip-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
  .chip-item:hover {
    background: rgba(255, 255, 255, 0.06);
  }
}

.chip-item.active {
  background: rgba(80, 130, 240, 0.18);
}

.chip-item.checked {
  font-weight: 600;
}

.chip-item-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.chip-item-path {
  font-size: calc(10px * var(--ui-scale, 1));
  opacity: 0.55;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.chip-item-count {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-size: calc(10px * var(--ui-scale, 1));
  opacity: 0.6;
}

/* RepoChip item title row — repo name + commit-count facet on one line,
   the path renders on the line below. */
.chip-item-titleline {
  display: flex;
  align-items: baseline;
  gap: calc(6px * var(--ui-scale, 1));
  width: 100%;
  min-width: 0;
}
.chip-item-titleline .chip-item-name {
  flex: 1;
  min-width: 0;
}

.chip-check {
  display: inline-block;
  width: calc(12px * var(--ui-scale, 1));
  font-size: calc(11px * var(--ui-scale, 1));
  color: rgba(80, 130, 240, 0.95);
}

.chip-item-head {
  font-size: calc(10px * var(--ui-scale, 1));
  opacity: 0.6;
  margin-left: calc(4px * var(--ui-scale, 1));
}

/* Section header inside BranchChip dropdown (Local / Remote tracking).
 * Sticky enough to read at a glance, quiet enough not to look clickable. */
.chip-section-header {
  padding: calc(8px * var(--ui-scale, 1)) calc(10px * var(--ui-scale, 1)) calc(4px * var(--ui-scale, 1));
  font-size: calc(10px * var(--ui-scale, 1));
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.45;
  user-select: none;
  cursor: default;
}

.chip-empty {
  padding: calc(10px * var(--ui-scale, 1));
  text-align: center;
  font-size: calc(11px * var(--ui-scale, 1));
  opacity: 0.55;
}

.chip-pin {
  padding: calc(2px * var(--ui-scale, 1)) calc(6px * var(--ui-scale, 1));
  border: none;
  background: transparent;
  color: rgba(0, 0, 0, 0.18);
  font-size: calc(13px * var(--ui-scale, 1));
  cursor: pointer;
  border-radius: 4px;
}

.chip-pin:hover {
  background: rgba(0, 0, 0, 0.08);
}

.chip-pin.pinned {
  color: rgba(240, 180, 60, 0.95);
}

@media (prefers-color-scheme: dark) {
  .chip-pin {
    color: rgba(255, 255, 255, 0.22);
  }
  .chip-pin:hover {
    background: rgba(255, 255, 255, 0.08);
  }
  .chip-pin.pinned {
    color: rgba(255, 200, 90, 0.95);
  }
}

/* "Missing" repo row: greyed text + small tag, plus a ✕ hide button
 * in place of the pin star. Drag/drop a new path onto the panel to
 * relink, or hide to suppress auto-rediscovery. */
.chip-item-row.missing .chip-item-name,
.chip-item-row.missing .chip-item-path {
  opacity: 0.45;
}
.chip-item-missing-tag {
  font-size: calc(10px * var(--ui-scale, 1));
  font-weight: 400;
  opacity: 0.8;
  color: rgba(180, 50, 50, 0.95);
}
.chip-hide {
  width: calc(26px * var(--ui-scale, 1));
  background: transparent;
  border: none;
  font-size: calc(12px * var(--ui-scale, 1));
  color: rgba(0, 0, 0, 0.45);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}
.chip-hide:hover {
  background: rgba(220, 80, 80, 0.12);
  color: rgba(200, 50, 50, 0.95);
}
@media (prefers-color-scheme: dark) {
  .chip-item-missing-tag {
    color: rgba(255, 140, 140, 0.95);
  }
  .chip-hide {
    color: rgba(255, 255, 255, 0.4);
  }
  .chip-hide:hover {
    background: rgba(255, 120, 120, 0.16);
    color: rgba(255, 160, 160, 0.95);
  }
}

/* AuthorsChip puts the count item differently — override path style */
.chip-item:not(.chip-item-row .chip-item) {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

/* ----- body ----- */

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* Fresh-PC first-paint: no cache, no IDE recents, no git config hints
 * — instead of leaving the user staring at a blank "Scanning…" we
 * promote the explicit-add flow to primary UI. Big drop target plus
 * a paste hint; the same flow lives as a tiny footer hint once at
 * least one repo is known. */
.empty-drop {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px 24px;
  text-align: center;
  border: 2px dashed rgba(0, 0, 0, 0.15);
  border-radius: 12px;
  margin: 24px;
  color: rgba(0, 0, 0, 0.6);
}
.empty-drop-icon {
  font-size: 36px;
  opacity: 0.75;
}
.empty-drop-title {
  font-size: 14px;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.8);
}
.empty-drop-sub {
  font-size: 11px;
  opacity: 0.65;
}
.empty-drop-status {
  margin-top: 12px;
  font-size: 11px;
  opacity: 0.6;
  font-style: italic;
}
.empty-drop-error {
  margin-top: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(220, 80, 80, 0.12);
  color: rgba(180, 50, 50, 0.95);
  font-size: 11px;
  max-width: 90%;
}

@media (prefers-color-scheme: dark) {
  .empty-drop {
    border-color: rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.55);
  }
  .empty-drop-title {
    color: rgba(255, 255, 255, 0.85);
  }
  .empty-drop-error {
    background: rgba(255, 120, 120, 0.16);
    color: rgba(255, 160, 160, 0.95);
  }
}

/* Persistent (subtle) footer hint when at least one repo is known.
 * Reminds users they can drag/paste without taking real estate from
 * the timeline. */
.panel-footer-hint {
  flex-shrink: 0;
  padding: 4px 12px 6px;
  font-size: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.panel-footer-hint-text {
  opacity: 0.4;
  cursor: default;
}
.panel-footer-hint-error {
  color: rgba(180, 50, 50, 0.95);
}

/* "+ Add repo" button — footer (compact) and empty-state (larger). The
 * native folder picker it opens is the primary repo-add path; drop /
 * paste stay as secondary affordances. */
.add-repo-btn {
  flex-shrink: 0;
  padding: 3px 10px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  opacity: 0.75;
  transition: opacity 0.12s ease, background 0.12s ease;
}
.add-repo-btn:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.06);
}
.empty-drop-btn {
  margin-top: 10px;
  padding: 6px 14px;
  font-size: 12px;
}

@media (prefers-color-scheme: dark) {
  .panel-footer-hint {
    border-top-color: rgba(255, 255, 255, 0.08);
  }
  .panel-footer-hint-error {
    color: rgba(255, 160, 160, 0.95);
  }
  .add-repo-btn {
    border-color: rgba(255, 255, 255, 0.18);
  }
  .add-repo-btn:hover {
    background: rgba(255, 255, 255, 0.10);
  }
}

.panel-empty {
  font-size: 12px;
  opacity: 0.55;
  text-align: center;
  margin-top: 40%;
}

/* Filter-aware empty state: name the filter that's hiding the commits and
   offer the one-click way out. Lives inside .panel-empty (a div variant). */
.panel-empty-line {
  margin: 0 0 8px;
}

.panel-empty-actions {
  margin: 0;
  display: flex;
  gap: 8px;
  justify-content: center;
}

.panel-empty-action {
  padding: 3px 10px;
  border: 1px solid rgba(128, 128, 128, 0.4);
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font-size: 11px;
  cursor: pointer;
}

.panel-empty-action:hover {
  border-color: #5b5df0;
  color: #5b5df0;
}

/* ----- timeline ----- */

.timeline {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* All-repos windowed timeline — `.timeline-scroll` is the scroll viewport
   (fills the panel body below the header, scrolls internally), and
   `.timeline-windowed-list` is the spacer-padded inner list: only the rows
   in view are mounted, top/bottom padding stands in for the rest. */
.timeline-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.timeline-windowed-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline-loading-more {
  padding: 6px 12px;
  font-size: 11px;
  text-align: center;
  opacity: 0.45;
}

/* "N new commits" pill — floats at the top of the timeline viewport when
   the scanner reports commits beyond the pinned snapshot and the reader is
   scrolled away from the top. The anchor is a zero-height sticky element so
   the pill overlays without disturbing the virtualization math. */
.timeline-new-pill-anchor {
  position: sticky;
  top: 0;
  height: 0;
  z-index: 5;
}

.timeline-new-pill {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 12px;
  border: none;
  border-radius: 11px;
  background: #5b5df0;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
}

.timeline-new-pill:hover {
  background: #6f71f3;
}

/* Copy-as-AI-context toast — confirms the 'c' shortcut even when no row is
   expanded (the keyboard path used to copy in total silence; worse, a
   failure left the previous clipboard in place with no hint). Same sticky
   zero-height anchor trick as the new-commits pill, parked just below the
   pill slot so the two never overlap. */
.timeline-copy-toast-anchor {
  position: sticky;
  top: 0;
  height: 0;
  z-index: 6;
}

.timeline-copy-toast {
  position: absolute;
  top: 34px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 12px;
  border-radius: 11px;
  background: rgba(40, 44, 52, 0.92);
  color: #d6f5dd;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

.timeline-copy-toast.error {
  color: #ffc7c7;
}

@media (prefers-color-scheme: light) {
  .timeline-copy-toast {
    background: rgba(255, 255, 255, 0.95);
    color: #1d7a3a;
    border: 1px solid rgba(0, 0, 0, 0.12);
  }
  .timeline-copy-toast.error {
    color: #b3261e;
  }
}

/* All-repos mode: marker · time · repo · summary · author */
.timeline-all .timeline-row {
  display: grid;
  grid-template-columns: 28px 36px minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  padding: calc(6px * var(--ui-scale, 1)) 12px;
  font-size: calc(12px * var(--ui-scale, 1));
  line-height: 1.5;
  cursor: default;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  /* Fixed height — the windowed timeline's virtualization math relies on
     every all-repos row being exactly this tall. --timeline-row-h is set
     from JS (lib/settings) to the exact integer that geometry uses. */
  height: var(--timeline-row-h, 31px);
  box-sizing: border-box;
}

/* Placeholder for an all-repos row whose commit is not loaded yet — a
   random-access jump-load in flight. Light pulsing skeleton bar; inert. */
.timeline-row-blank {
  pointer-events: none;
}
.timeline-skeleton {
  grid-column: 2 / 5;
  align-self: center;
  height: 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.07);
  animation: skeleton-pulse 1.4s ease-in-out infinite;
}
@keyframes skeleton-pulse {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 0.9;
  }
}
@media (prefers-color-scheme: dark) {
  .timeline-skeleton {
    background: rgba(255, 255, 255, 0.08);
  }
}

/* Single-repo mode: lane area (SVG DAG) · time · summary · author.
   Repo column dropped because every row is the same repo. */
.timeline-single {
  position: relative;
  animation: lane-slidein 150ms ease-out;
}

.timeline-single .timeline-row {
  display: grid;
  grid-template-columns: 80px 36px minmax(0, 3fr) minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  padding: calc(6px * var(--ui-scale, 1)) 12px;
  font-size: calc(12px * var(--ui-scale, 1));
  line-height: 1.5;
  cursor: default;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  height: var(--timeline-row-h, 31px);
  box-sizing: border-box;
}

.timeline-lane-spacer {
  /* placeholder so the grid keeps the lane column free for the absolute SVG */
}

/* Single-repo lane SVG. Windowed: `top` is set inline to the visible
   band's content-Y; only band-intersecting nodes/edges are emitted. */
.lane-graph {
  position: absolute;
  left: 12px; /* matches timeline-row padding-left */
  pointer-events: none;
  display: block;
}

@keyframes lane-slidein {
  from {
    opacity: 0.4;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (prefers-color-scheme: dark) {
  .timeline-row {
    border-bottom-color: rgba(255, 255, 255, 0.04);
  }
}

.timeline-row:hover {
  background: rgba(0, 0, 0, 0.04);
}

@media (prefers-color-scheme: dark) {
  .timeline-row:hover {
    background: rgba(255, 255, 255, 0.05);
  }
}

.timeline-row.selected {
  background: rgba(80, 130, 240, 0.18);
}

.timeline-marker {
  text-align: center;
  font-size: calc(11px * var(--ui-scale, 1));
  line-height: 1;
  opacity: 0.55;
  transition: color 200ms, opacity 200ms;
}

.timeline-marker.fresh {
  color: #5b5df0;
  opacity: 1;
  font-size: calc(13px * var(--ui-scale, 1));
  text-shadow: 0 0 6px rgba(91, 93, 240, 0.35);
}

.marker-merge {
  color: #8a7ce0;
  opacity: 0.95;
}

.marker-tag {
  color: #d99a2b;
  opacity: 0.95;
}

.timeline-marker.fresh.marker-merge,
.timeline-marker.fresh.marker-tag {
  text-shadow: 0 0 6px rgba(91, 93, 240, 0.45);
}

.timeline-time {
  font-variant-numeric: tabular-nums;
  opacity: 0.55;
  text-align: right;
}

.timeline-repo {
  opacity: 0.7;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Per-repo identity dot — the pre-attentive cue that lets the eye chunk
   the interleaved all-repos timeline by repo instead of reading each name.
   Low-key on purpose: the summary column must keep dominating. */
.timeline-repo-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: baseline;
  opacity: 0.85;
  flex-shrink: 0;
}

.timeline-repo-clickable {
  cursor: pointer;
}

.timeline-repo-clickable:hover {
  text-decoration: underline;
  opacity: 1;
}

.timeline-summary {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-branch {
  display: inline-block;
  margin-right: 6px;
  padding: 0 5px;
  border-radius: 3px;
  font-size: calc(10px * var(--ui-scale, 1));
  font-weight: 600;
  background: rgba(80, 130, 240, 0.14);
  color: rgba(80, 130, 240, 0.95);
  vertical-align: 1px;
}

@media (prefers-color-scheme: dark) {
  .timeline-branch {
    background: rgba(140, 180, 255, 0.16);
    color: rgba(160, 190, 255, 0.95);
  }
}

/* Remote-tracking ref badge — appears after the commit summary when an
 * origin/<branch> tip points at this commit. Deliberately quieter than
 * the local branch label: thinner weight, monospace, neutral grey so it
 * doesn't compete with local identity in the timeline. */
.timeline-remote-tip {
  display: inline-block;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: calc(10px * var(--ui-scale, 1));
  font-weight: 500;
  background: rgba(0, 0, 0, 0.05);
  color: rgba(0, 0, 0, 0.55);
  vertical-align: 1px;
  white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
  .timeline-remote-tip {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.5);
  }
}

.timeline-author {
  opacity: 0.5;
  font-size: calc(11px * var(--ui-scale, 1));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-row.expanded {
  background: rgba(80, 130, 240, 0.10);
}

/* ----- inline expansion (commit detail + changed files) ----- */

.timeline-expansion {
  list-style: none;
  padding: calc(8px * var(--ui-scale, 1)) calc(12px * var(--ui-scale, 1)) calc(10px * var(--ui-scale, 1)) calc(50px * var(--ui-scale, 1));
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(0, 0, 0, 0.025);
  overflow: hidden;
  animation: expand-in 160ms ease-out;
}

@media (prefers-color-scheme: dark) {
  .timeline-expansion {
    border-bottom-color: rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.025);
  }
}

@keyframes expand-in {
  from {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
  }
  to {
    max-height: calc(600px * var(--ui-scale, 1));
    opacity: 1;
  }
}

/* commit detail block above the file list */

.commit-detail {
  padding: calc(2px * var(--ui-scale, 1)) 0 calc(8px * var(--ui-scale, 1));
  border-bottom: 1px dashed rgba(0, 0, 0, 0.07);
  margin-bottom: calc(6px * var(--ui-scale, 1));
}

@media (prefers-color-scheme: dark) {
  .commit-detail {
    border-bottom-color: rgba(255, 255, 255, 0.07);
  }
}

.commit-detail-summary {
  font-size: calc(12px * var(--ui-scale, 1));
  font-weight: 600;
  margin-bottom: calc(2px * var(--ui-scale, 1));
}

.commit-detail-body {
  font-size: calc(11px * var(--ui-scale, 1));
  margin: calc(4px * var(--ui-scale, 1)) 0 calc(6px * var(--ui-scale, 1));
  padding: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, monospace;
  opacity: 0.85;
  max-height: calc(180px * var(--ui-scale, 1));
  overflow-y: auto;
}

.commit-detail-meta {
  font-size: calc(10px * var(--ui-scale, 1));
  opacity: 0.6;
  display: flex;
  gap: calc(8px * var(--ui-scale, 1));
  align-items: baseline;
}

.commit-detail-hash {
  font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, monospace;
  background: rgba(0, 0, 0, 0.08);
  padding: 0 calc(5px * var(--ui-scale, 1));
  border-radius: 3px;
  font-size: calc(10px * var(--ui-scale, 1));
}

@media (prefers-color-scheme: dark) {
  .commit-detail-hash {
    background: rgba(255, 255, 255, 0.10);
  }
}

.commit-detail-email {
  opacity: 0.7;
}

.commit-actions {
  display: flex;
  gap: calc(8px * var(--ui-scale, 1));
  margin: calc(4px * var(--ui-scale, 1)) 0 calc(8px * var(--ui-scale, 1));
}

.commit-copy-btn {
  padding: calc(3px * var(--ui-scale, 1)) calc(10px * var(--ui-scale, 1));
  border: 1px solid rgba(80, 130, 240, 0.4);
  border-radius: 4px;
  background: rgba(80, 130, 240, 0.10);
  color: inherit;
  font: inherit;
  font-size: calc(11px * var(--ui-scale, 1));
  cursor: pointer;
  transition: background 100ms;
}

.commit-copy-btn:hover {
  background: rgba(80, 130, 240, 0.20);
}

@media (prefers-color-scheme: dark) {
  .commit-copy-btn {
    border-color: rgba(140, 180, 255, 0.45);
    background: rgba(140, 180, 255, 0.14);
  }
  .commit-copy-btn:hover {
    background: rgba(140, 180, 255, 0.24);
  }
}

.changed-files {
  display: flex;
  flex-direction: column;
  gap: calc(2px * var(--ui-scale, 1));
}

.changed-files-empty {
  padding: calc(4px * var(--ui-scale, 1)) 0;
  font-size: calc(11px * var(--ui-scale, 1));
  opacity: 0.55;
}

.changed-file {
  display: grid;
  grid-template-columns: calc(38px * var(--ui-scale, 1)) minmax(0, 1fr) auto;
  gap: calc(8px * var(--ui-scale, 1));
  align-items: center;
  padding: calc(3px * var(--ui-scale, 1)) calc(6px * var(--ui-scale, 1));
  border-radius: 4px;
  font-size: calc(11px * var(--ui-scale, 1));
}

.changed-file-clickable {
  cursor: pointer;
}

.changed-file-clickable:hover {
  background: rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
  .changed-file-clickable:hover {
    background: rgba(255, 255, 255, 0.05);
  }
}

.changed-file-badge {
  display: inline-block;
  text-align: center;
  font-size: calc(9px * var(--ui-scale, 1));
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: calc(1px * var(--ui-scale, 1)) calc(4px * var(--ui-scale, 1));
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.08);
  color: rgba(0, 0, 0, 0.75);
}

@media (prefers-color-scheme: dark) {
  .changed-file-badge {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.85);
  }
}

.badge-new {
  background: rgba(80, 200, 120, 0.20);
  color: rgba(45, 150, 80, 1);
}
.badge-mod {
  background: rgba(80, 130, 240, 0.16);
  color: rgba(60, 110, 220, 1);
}
.badge-ren {
  background: rgba(200, 140, 60, 0.18);
  color: rgba(170, 110, 30, 1);
}
.badge-del {
  background: rgba(220, 80, 80, 0.18);
  color: rgba(190, 50, 50, 1);
}
.badge-cp {
  background: rgba(140, 100, 200, 0.16);
  color: rgba(110, 70, 170, 1);
}
.badge-type {
  background: rgba(140, 140, 140, 0.16);
  color: rgba(100, 100, 100, 1);
}

@media (prefers-color-scheme: dark) {
  .badge-new { color: rgba(120, 220, 150, 1); }
  .badge-mod { color: rgba(140, 180, 255, 1); }
  .badge-ren { color: rgba(230, 175, 100, 1); }
  .badge-del { color: rgba(255, 130, 130, 1); }
  .badge-cp  { color: rgba(190, 150, 240, 1); }
  .badge-type { color: rgba(190, 190, 190, 1); }
}

.changed-file-path {
  display: flex;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, monospace;
}

.changed-file-dir {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.5;
  font-weight: 400;
}

.changed-file-name {
  flex: 0 0 auto;
  font-weight: 600;
}

.changed-file-old {
  opacity: 0.55;
  margin-right: calc(4px * var(--ui-scale, 1));
}

.changed-file-bin {
  font-size: calc(9px * var(--ui-scale, 1));
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: calc(1px * var(--ui-scale, 1)) calc(4px * var(--ui-scale, 1));
  margin-left: calc(6px * var(--ui-scale, 1));
  border-radius: 3px;
  background: rgba(140, 140, 140, 0.18);
  color: rgba(110, 110, 110, 1);
  flex-shrink: 0;
}

@media (prefers-color-scheme: dark) {
  .changed-file-bin {
    background: rgba(180, 180, 180, 0.18);
    color: rgba(190, 190, 190, 1);
  }
}

.changed-file-size {
  font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, monospace;
  font-size: calc(10px * var(--ui-scale, 1));
  opacity: 0.7;
}

/* ============================================================
   Context menu
   ============================================================ */

.context-menu {
  position: fixed;
  z-index: 1000;
  min-width: 200px;
  padding: 4px 0;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  user-select: none;
  font-size: 12px;
}

@media (prefers-color-scheme: dark) {
  .context-menu {
    background: #2a2a2c;
    border-color: rgba(255, 255, 255, 0.16);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  }
}

.context-menu-item {
  display: block;
  width: 100%;
  padding: 5px 12px;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.context-menu-item:hover:not(.disabled) {
  background: rgba(80, 130, 240, 0.18);
}

.context-menu-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@media (prefers-color-scheme: dark) {
  .context-menu-item:hover:not(.disabled) {
    background: rgba(140, 180, 255, 0.22);
  }
}

.context-menu-divider {
  height: 1px;
  background: rgba(0, 0, 0, 0.08);
  margin: 4px 0;
}

@media (prefers-color-scheme: dark) {
  .context-menu-divider {
    background: rgba(255, 255, 255, 0.10);
  }
}

.changed-file-stat {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, monospace;
  display: inline-flex;
  gap: 8px;
}

.changed-file-plus {
  color: rgba(60, 160, 90, 1);
}
.changed-file-minus {
  color: rgba(200, 80, 80, 1);
}

@media (prefers-color-scheme: dark) {
  .changed-file-plus {
    color: rgba(120, 220, 150, 1);
  }
  .changed-file-minus {
    color: rgba(255, 130, 130, 1);
  }
}

/* ============================================================
   Diff window
   ============================================================ */

.diff-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.diff-loading {
  padding: 24px;
  text-align: center;
  font-size: 13px;
  opacity: 0.6;
}

.diff-header {
  padding: 8px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.diff-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

@media (prefers-color-scheme: dark) {
  .diff-header {
    border-bottom-color: rgba(255, 255, 255, 0.08);
  }
}

.diff-header-summary {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.diff-header-meta {
  font-size: 11px;
  opacity: 0.7;
  display: flex;
  gap: 8px;
  align-items: center;
}

.diff-header-hash {
  font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, monospace;
  background: rgba(0, 0, 0, 0.08);
  padding: 0 5px;
  border-radius: 3px;
  font-size: 11px;
}

@media (prefers-color-scheme: dark) {
  .diff-header-hash {
    background: rgba(255, 255, 255, 0.10);
  }
}

/* Context-line toggle: a small segmented control in the diff header.
   Switches the side-by-side view between ±3 / ±25 / whole-file. */
.diff-context-toggle {
  display: flex;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 6px;
  overflow: hidden;
}

.diff-context-btn {
  font: inherit;
  font-size: 11px;
  line-height: 1;
  padding: 4px 9px;
  border: none;
  border-left: 1px solid rgba(0, 0, 0, 0.12);
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: 0.7;
}

.diff-context-btn:first-child {
  border-left: none;
}

.diff-context-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  opacity: 1;
}

.diff-context-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  background: transparent;
}

.diff-context-btn.active {
  background: rgba(80, 130, 240, 0.9);
  color: #fff;
  opacity: 1;
}

@media (prefers-color-scheme: dark) {
  .diff-context-toggle {
    border-color: rgba(255, 255, 255, 0.14);
  }
  .diff-context-btn {
    border-left-color: rgba(255, 255, 255, 0.14);
  }
  .diff-context-btn:hover {
    background: rgba(255, 255, 255, 0.08);
  }
  .diff-context-btn.active {
    background: rgba(120, 160, 255, 0.9);
    color: #0b0b0b;
  }
}

.diff-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.diff-sidebar {
  width: 240px;
  flex-shrink: 0;
  border-right: 1px solid rgba(0, 0, 0, 0.08);
  overflow-y: auto;
  padding: 6px 0;
}

@media (prefers-color-scheme: dark) {
  .diff-sidebar {
    border-right-color: rgba(255, 255, 255, 0.08);
  }
}

.diff-sidebar-empty {
  padding: 16px;
  font-size: 12px;
  opacity: 0.6;
}

.diff-file {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: inherit;
  font: inherit;
  padding: 5px 12px;
  cursor: pointer;
}

.diff-file:hover {
  background: rgba(0, 0, 0, 0.04);
}

.diff-file.active {
  background: rgba(80, 130, 240, 0.18);
}

@media (prefers-color-scheme: dark) {
  .diff-file:hover {
    background: rgba(255, 255, 255, 0.05);
  }
  .diff-file.active {
    background: rgba(140, 180, 255, 0.20);
  }
}

.diff-file-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.diff-file-name {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, monospace;
}

.diff-file-dir {
  font-size: 10px;
  opacity: 0.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, monospace;
  margin-top: 1px;
}

.diff-file-stat {
  font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, monospace;
  font-size: 10px;
  flex-shrink: 0;
  display: inline-flex;
  gap: 6px;
}

.diff-main {
  flex: 1;
  overflow: auto;
  min-width: 0;
}

/* side-by-side diff — two columns, each with its own horizontal scroll,
   kept in sync via JS so dragging one column scrolls the other. */

.sbs {
  font-family: var(--diff-font-family, ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, monospace);
  font-size: calc(12px * var(--ui-scale, 1));
  line-height: 1.45;
  height: 100%;
  display: flex;
}

.sbs-empty {
  padding: 24px;
  text-align: center;
  opacity: 0.6;
}

.sbs-cols {
  flex: 1;
  display: grid;
  /* Inline style overrides the columns with the persisted split; this is
     the fallback and defines the resizer's fixed middle track width. */
  grid-template-columns: 1fr 8px 1fr;
  min-width: 0;
  height: 100%;
}

.sbs-col {
  overflow-x: auto;
  overflow-y: visible;
  min-width: 0;
  border-right: 1px solid rgba(0, 0, 0, 0.06);
}

.sbs-col:last-child {
  border-right: none;
}

@media (prefers-color-scheme: dark) {
  .sbs-col {
    border-right-color: rgba(255, 255, 255, 0.06);
  }
}

/* Draggable divider between the old/new columns. The grid gives it a fixed
   8px track; pointer drag rewrites the inline grid-template-columns. */
.sbs-resizer {
  cursor: col-resize;
  background: rgba(0, 0, 0, 0.06);
  touch-action: none;
  transition: background 0.12s;
}

.sbs-resizer:hover,
.sbs-resizer:active {
  background: rgba(80, 130, 240, 0.55);
}

@media (prefers-color-scheme: dark) {
  .sbs-resizer {
    background: rgba(255, 255, 255, 0.08);
  }
  .sbs-resizer:hover,
  .sbs-resizer:active {
    background: rgba(140, 180, 255, 0.6);
  }
}

/* Sized to the widest line so every row's tint spans the full scroll
   width — short rows would otherwise show untinted gaps when scrolled. */
.sbs-col-inner {
  width: max-content;
  min-width: 100%;
}

.sbs-hunk-header {
  background: rgba(80, 130, 240, 0.06);
  width: 100%;
  padding: 4px 10px;
  opacity: 0.7;
  font-size: calc(11px * var(--ui-scale, 1));
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  white-space: nowrap;
}

.sbs-hunk-header-blank {
  background: rgba(80, 130, 240, 0.03);
  color: transparent;
}

@media (prefers-color-scheme: dark) {
  .sbs-hunk-header {
    background: rgba(140, 180, 255, 0.08);
    border-top-color: rgba(255, 255, 255, 0.06);
    border-bottom-color: rgba(255, 255, 255, 0.06);
  }
  .sbs-hunk-header-blank {
    background: rgba(140, 180, 255, 0.04);
  }
}

.sbs-line {
  display: grid;
  grid-template-columns: calc(44px * var(--ui-scale, 1)) calc(16px * var(--ui-scale, 1)) max-content;
  width: 100%;
  align-items: baseline;
  padding: 0 6px;
  min-height: calc(18px * var(--ui-scale, 1));
  white-space: pre;
}

.sbs-line.delete {
  background: rgba(220, 80, 80, 0.10);
}

.sbs-line.add {
  background: rgba(80, 200, 120, 0.10);
}

.sbs-line.context {
  background: transparent;
}

.sbs-line.blank {
  background: rgba(0, 0, 0, 0.025);
}

@media (prefers-color-scheme: dark) {
  .sbs-line.delete {
    background: rgba(220, 80, 80, 0.18);
  }
  .sbs-line.add {
    background: rgba(80, 200, 120, 0.16);
  }
  .sbs-line.blank {
    background: rgba(255, 255, 255, 0.03);
  }
}

/* Gutter cells (line number + +/- sign) are sticky-left so they stay
   visible during the diff window's horizontal scroll. They MUST have
   an opaque background or the scrolled body text bleeds through them
   visually — `background: inherit` from .sbs-line was inheriting the
   row's semi-transparent tint (rgba 0.10~0.18) which is exactly the
   wrong choice for a sticky overlay. Following the same pattern as
   GitHub / GitLab / VS Code's monaco diff: per-row-type SOLID colour
   pre-blended against the body bg (#fafafa light / #1a1a1a dark) so
   the gutter looks identical to the row tint at column-resting state
   AND obscures content underneath when the row scrolls horizontally.
   The sign cell carries a thin right border so the gutter/content
   boundary stays visible during scroll. */
.sbs-num {
  text-align: right;
  opacity: 0.45;
  user-select: none;
  font-size: calc(10px * var(--ui-scale, 1));
  padding-right: 6px;
  position: sticky;
  left: 0;
  background: #fafafa;
  z-index: 1;
}

.sbs-sign {
  text-align: center;
  opacity: 0.55;
  user-select: none;
  font-weight: 700;
  position: sticky;
  left: calc(44px * var(--ui-scale, 1));
  background: #fafafa;
  border-right: 1px solid rgba(0, 0, 0, 0.06);
  z-index: 1;
}

/* Solid pre-blended row colours for the sticky gutter. Each value
   equals the corresponding .sbs-line.<type> rgba tint flattened onto
   the body bg so at column-resting state the gutter is visually
   indistinguishable from the row, but during horizontal scroll it
   actually paints opaquely instead of letting text through. */
.sbs-line.delete .sbs-num,
.sbs-line.delete .sbs-sign {
  background: rgb(247, 233, 233);
}

.sbs-line.add .sbs-num,
.sbs-line.add .sbs-sign {
  background: rgb(233, 245, 237);
}

.sbs-line.blank .sbs-num,
.sbs-line.blank .sbs-sign {
  background: rgb(246, 246, 246);
}

.sbs-line.delete .sbs-sign {
  color: rgba(190, 50, 50, 1);
}

.sbs-line.add .sbs-sign {
  color: rgba(45, 150, 80, 1);
}

@media (prefers-color-scheme: dark) {
  .sbs-num,
  .sbs-sign {
    background: #1a1a1a;
  }
  .sbs-sign {
    border-right-color: rgba(255, 255, 255, 0.06);
  }
  .sbs-line.delete .sbs-num,
  .sbs-line.delete .sbs-sign {
    background: rgb(61, 36, 36);
  }
  .sbs-line.add .sbs-num,
  .sbs-line.add .sbs-sign {
    background: rgb(35, 54, 41);
  }
  .sbs-line.blank .sbs-num,
  .sbs-line.blank .sbs-sign {
    background: rgb(33, 33, 33);
  }
  .sbs-line.delete .sbs-sign { color: rgba(255, 130, 130, 1); }
  .sbs-line.add .sbs-sign { color: rgba(120, 220, 150, 1); }
}

.sbs-text {
  white-space: pre;
}

/* Shiki output: inherit our row backgrounds + lift overall opacity slightly
   so highlighted tokens stay readable on the delete/add row tints. */
.sbs-text-shiki {
  white-space: pre;
}

.sbs-text-shiki .line {
  background: transparent !important;
}

.sbs-line.delete .sbs-text-shiki span,
.sbs-line.add .sbs-text-shiki span {
  background: transparent !important;
}

/* binary / image diff */

.binary-info {
  padding: 60px 40px;
  text-align: center;
}

.binary-info-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.binary-info-meta {
  font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, monospace;
  opacity: 0.75;
  margin-bottom: 16px;
}

.binary-info-hint {
  font-size: 12px;
  opacity: 0.55;
}

.image-diff {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px;
  height: 100%;
  box-sizing: border-box;
}

.image-diff-side {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.image-diff-label {
  font-size: 11px;
  opacity: 0.7;
  margin-bottom: 6px;
  font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, monospace;
}

.image-diff-frame {
  flex: 1;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-image: linear-gradient(45deg, rgba(0,0,0,0.04) 25%, transparent 25%, transparent 75%, rgba(0,0,0,0.04) 75%),
                    linear-gradient(45deg, rgba(0,0,0,0.04) 25%, transparent 25%, transparent 75%, rgba(0,0,0,0.04) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
  overflow: auto;
  min-height: 0;
}

@media (prefers-color-scheme: dark) {
  .image-diff-frame {
    border-color: rgba(255, 255, 255, 0.14);
    background-image: linear-gradient(45deg, rgba(255,255,255,0.04) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.04) 75%),
                      linear-gradient(45deg, rgba(255,255,255,0.04) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.04) 75%);
  }
}

.image-diff-frame img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.image-diff-empty {
  font-size: 12px;
  opacity: 0.55;
  padding: 16px;
}

.image-diff-loading,
.image-diff-error {
  padding: 24px;
  text-align: center;
  opacity: 0.6;
}

.diff-file-binsize {
  font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, monospace;
  font-size: 10px;
  opacity: 0.7;
}

/* ============================================================
   Self-update modal (panel overlay)
   ============================================================ */

.update-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.34);
  -webkit-backdrop-filter: blur(1.5px);
  backdrop-filter: blur(1.5px);
}

.update-modal {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 380px;
  max-height: 100%;
  padding: 16px;
  background: #fff;
  color: #1a1a1a;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

.update-modal-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.update-modal-title {
  font-size: 14px;
  font-weight: 600;
}

.update-modal-version {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: rgb(60, 110, 220);
}

.update-modal-changelog {
  max-height: 320px;
  overflow-y: auto;
  padding: 10px;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  background: #f4f4f6;
  border-radius: 6px;
}

.update-modal-changelog code {
  font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, monospace;
  font-size: 11px;
  padding: 1px 4px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 3px;
}

.update-modal-error {
  font-size: 11px;
  color: rgba(190, 50, 50, 1);
  padding: 6px 8px;
  background: rgba(220, 80, 80, 0.12);
  border-radius: 5px;
}

.update-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.update-btn {
  font: inherit;
  font-size: 12px;
  padding: 6px 12px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 6px;
  background: #fff;
  color: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.update-btn:hover:not(:disabled) {
  background: #f4f4f6;
}

.update-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.update-btn-primary {
  background: rgb(80, 130, 240);
  border-color: rgb(80, 130, 240);
  color: #fff;
  font-weight: 600;
}

.update-btn-primary:hover:not(:disabled) {
  background: rgb(64, 112, 224);
}

.update-btn-quiet {
  border-color: transparent;
  color: rgba(0, 0, 0, 0.55);
}

.update-btn-quiet:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
  .update-modal {
    background: #2a2a2c;
    color: #ededed;
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  }
  .update-modal-version {
    color: rgba(140, 180, 255, 1);
  }
  .update-modal-changelog {
    background: #202022;
  }
  .update-modal-changelog code {
    background: rgba(255, 255, 255, 0.1);
  }
  .update-modal-error {
    color: rgba(255, 130, 130, 1);
    background: rgba(220, 80, 80, 0.16);
  }
  .update-btn {
    background: #34343a;
    border-color: rgba(255, 255, 255, 0.16);
  }
  .update-btn:hover:not(:disabled) {
    background: #3e3e44;
  }
  .update-btn-primary {
    background: rgb(96, 142, 245);
    border-color: rgb(96, 142, 245);
    color: #fff;
  }
  .update-btn-primary:hover:not(:disabled) {
    background: rgb(112, 156, 250);
  }
  .update-btn-quiet {
    border-color: transparent;
    color: rgba(255, 255, 255, 0.55);
  }
  .update-btn-quiet:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.07);
  }
}

/* ============================================================
   Settings window
   ============================================================ */

.settings {
  height: 100%;
  overflow-y: auto;
  padding: 20px 24px 28px;
}

.settings-title {
  margin: 0 0 16px;
  font-size: 17px;
  font-weight: 600;
}

.settings-section + .settings-section {
  margin-top: 22px;
}

.settings-section-title {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.55;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-label {
  flex: 0 0 64px;
  font-size: 13px;
}

.settings-slider {
  flex: 1;
  min-width: 0;
}

.settings-value {
  flex: 0 0 44px;
  text-align: right;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}

.settings-hint {
  margin: 8px 0 0;
  font-size: 11px;
  opacity: 0.5;
}

.settings-hint + .settings-row {
  margin-top: 14px;
}

.settings-input {
  flex: 1;
  min-width: 0;
  padding: 4px 8px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 12px;
  outline: none;
}

.settings-input:focus {
  border-color: rgba(80, 130, 240, 0.6);
}

@media (prefers-color-scheme: dark) {
  .settings-input {
    border-color: rgba(255, 255, 255, 0.18);
  }
}

.settings-hotkey {
  flex: 1;
  min-width: 0;
  padding: 4px 8px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}

.settings-hotkey:hover:not(.recording) {
  background: rgba(0, 0, 0, 0.04);
}

.settings-hotkey.recording {
  border-color: rgba(80, 130, 240, 0.7);
  background: rgba(80, 130, 240, 0.10);
  cursor: default;
}

@media (prefers-color-scheme: dark) {
  .settings-hotkey {
    border-color: rgba(255, 255, 255, 0.18);
  }
  .settings-hotkey:hover:not(.recording) {
    background: rgba(255, 255, 255, 0.05);
  }
  .settings-hotkey.recording {
    border-color: rgba(140, 180, 255, 0.7);
    background: rgba(140, 180, 255, 0.14);
  }
}

.settings-error {
  margin: 6px 0 0;
  font-size: 11px;
  color: rgba(190, 50, 50, 1);
}

@media (prefers-color-scheme: dark) {
  .settings-error {
    color: rgba(255, 130, 130, 1);
  }
}

/* Update-check radio group — stacks vertically with a short hint per
   option so the trade-offs (auto vs manual vs off) are visible inline
   without a tooltip. */
.settings-radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-radio {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: center;
  cursor: pointer;
  padding: 4px 2px;
  border-radius: 4px;
}

.settings-radio:hover {
  background: rgba(0, 0, 0, 0.03);
}

.settings-radio input {
  grid-row: 1 / span 2;
  margin: 0;
  cursor: pointer;
}

.settings-radio-label {
  font-size: 13px;
}

.settings-radio-hint {
  grid-column: 2;
  font-size: 11px;
  opacity: 0.55;
}

@media (prefers-color-scheme: dark) {
  .settings-radio:hover {
    background: rgba(255, 255, 255, 0.04);
  }
}

/* Footer with the "Open settings.json" escape hatch — visually
   de-emphasised so non-power-users aren't drawn to it, but still
   reachable for the rare hand-edit case (clearing a corrupted
   branch_selections entry, debugging panel_position, etc.). */
.settings-footer {
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-link {
  align-self: flex-start;
  background: none;
  border: none;
  padding: 0;
  color: rgba(80, 130, 240, 0.95);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(80, 130, 240, 0.4);
}

.settings-link:hover {
  text-decoration-color: rgba(80, 130, 240, 0.9);
}

.settings-footer-hint {
  font-size: 11px;
  opacity: 0.5;
}

@media (prefers-color-scheme: dark) {
  .settings-footer {
    border-top-color: rgba(255, 255, 255, 0.08);
  }
  .settings-link {
    color: rgba(140, 180, 255, 0.95);
    text-decoration-color: rgba(140, 180, 255, 0.4);
  }
  .settings-link:hover {
    text-decoration-color: rgba(140, 180, 255, 0.9);
  }
}
