/* ============================================================
   OpenKOD Diff Checker — design system

   Two ideas hold this together:

   1. ELEVATION. The page background is deliberately darker than the
      surfaces on it, so a white card genuinely reads as lifted rather
      than as a rectangle drawn on paper. Everything sits on one of a
      few defined layers (--bg → --surface-2 → --surface) and carries
      the shadow that matches its layer. A flat page with hairline
      borders is what makes a tool look like a static document.

   2. SCROLL. The document scrolls normally. The brand header scrolls
      away, and a sticky group — the tools bar plus the diff stats —
      locks to the top of the viewport in its place. The sidebar stays
      put on its own. So a 5,000-line diff keeps its controls in reach
      without the page feeling like a locked-down frame.
   ============================================================ */

:root {
  /* --- layers, light to dark --- */
  --surface: #ffffff;        /* cards, rows, controls */
  --surface-2: #f7f8fa;      /* insets: card headers, gutters */
  --surface-3: #eef0f4;      /* pressed / hovered insets */
  --bg: #e8ebf1;             /* the ground everything floats above */

  --border: #e0e4ec;
  --border-strong: #c9d0dc;

  --text: #16191f;
  --text-soft: #454b57;
  --text-muted: #6b7280;

  --accent: #2f6feb;
  --accent-hover: #245cd0;
  --accent-soft: rgba(47, 111, 235, .10);
  --accent-contrast: #ffffff;

  --danger: #d93a3f;
  --danger-contrast: #ffffff;
  --success: #0e8f6e;
  --success-contrast: #ffffff;

  --added-bg: #e4f8f0;
  --added-strong: #9fe8d0;
  --removed-bg: #fdeaea;
  --removed-strong: #f7b7b4;

  --line-no: #9aa2b1;
  --line-no-bg: #f7f8fa;
  --hover: #f2f4f8;

  --resolved-bg: #e9f0fe;
  --resolved-border: #2f6feb;

  /* --- elevation: each step pairs a tight contact shadow with a
         softer ambient one, which is what stops shadows looking like
         grey smudges --- */
  --shadow-xs: 0 1px 2px rgba(19, 26, 41, .05);
  --shadow-sm: 0 1px 3px rgba(19, 26, 41, .08), 0 1px 2px rgba(19, 26, 41, .04);
  --shadow-md: 0 4px 12px -2px rgba(19, 26, 41, .10), 0 2px 5px -2px rgba(19, 26, 41, .06);
  --shadow-lg: 0 14px 32px -8px rgba(19, 26, 41, .16), 0 5px 12px -6px rgba(19, 26, 41, .10);

  --ring: 0 0 0 3px rgba(47, 111, 235, .26);

  --r-sm: 6px;
  --r-md: 9px;
  --r-lg: 12px;
  --r-pill: 999px;

  --dur: .17s;
  --ease: cubic-bezier(.2, .7, .3, 1);

  --topbar-h: 52px;
  --sidebar-w: 244px;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

[data-theme="dark"] {
  --surface: #161b22;
  --surface-2: #1b212a;
  --surface-3: #232a34;
  --bg: #0b0e13;

  --border: #2b323c;
  --border-strong: #3c4553;

  --text: #e6edf3;
  --text-soft: #c3ccd7;
  --text-muted: #8b949e;

  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --accent-soft: rgba(88, 166, 255, .14);
  --accent-contrast: #0b0e13;

  --danger: #f0666b;
  --danger-contrast: #0b0e13;
  --success: #2dd4a7;
  --success-contrast: #0b0e13;

  --added-bg: #102c1f;
  --added-strong: #1f6f3a;
  --removed-bg: #33131a;
  --removed-strong: #8e2a38;

  --line-no: #6e7681;
  --line-no-bg: #1b212a;
  --hover: #1c2029;

  --resolved-bg: #14213a;
  --resolved-border: #58a6ff;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .30);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .40), 0 1px 2px rgba(0, 0, 0, .24);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, .48), 0 2px 5px -2px rgba(0, 0, 0, .30);
  --shadow-lg: 0 14px 32px -8px rgba(0, 0, 0, .60), 0 5px 12px -6px rgba(0, 0, 0, .40);

  --ring: 0 0 0 3px rgba(88, 166, 255, .32);
}

* { box-sizing: border-box; }

/* Several elements here are laid out with flex/grid AND toggled via the
   `hidden` attribute. A class setting `display` outranks the UA's
   `[hidden] { display: none }`, so hidden elements would still render —
   this keeps the attribute authoritative. */
[hidden] { display: none !important; }

/* The document scrolls normally. Nothing between <body> and .tools-sticky
   may set `overflow` — an overflow value other than `visible` creates a
   scroll container, and a sticky element can only stick within its nearest
   scrolling ancestor, so it would be trapped inside that box instead of
   locking to the viewport. */
html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body { display: flex; flex-direction: column; }

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--r-sm);
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ---------------- Top bar ---------------- */
/* Sits at the top of the document and scrolls away with the page — the
   sticky tools bar takes over the top of the viewport in its place. */
.topbar {
  flex: none;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
  font-size: 14.5px;
  letter-spacing: -.01em;
  color: var(--text);
}
.brand-mark { color: var(--text); flex: none; }
.brand-name { white-space: nowrap; }
/* The descriptor sits back so "OpenKOD" carries the brand. */
.brand-thin { font-weight: 450; color: var(--text-muted); }

/* Tells a first-time visitor what this is and why it's safe, in the one
   place they look first. Hidden on narrow screens where it would crowd. */
.brand-tagline {
  font-size: 12px;
  font-weight: 450;
  color: var(--text-muted);
  padding-left: 13px;
  margin-left: 3px;
  border-left: 1px solid var(--border);
  white-space: nowrap;
}
@media (max-width: 1100px) { .brand-tagline { display: none; } }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

/* ---------------- Buttons ---------------- */
.ghost-btn, .ghost-link {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-soft);
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: background var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              color var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}
.ghost-btn:hover, .ghost-link:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-strong);
}
.ghost-btn:active { transform: translateY(1px); }

.pill-btn {
  border: none;
  border-radius: var(--r-sm);
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.share-btn { background: var(--success); color: var(--success-contrast); }
.share-btn:hover { filter: brightness(1.06); }
.share-btn:active { transform: translateY(1px); }

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-soft);
  box-shadow: var(--shadow-xs);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }

.only-mobile { display: none; }

/* ---------------- Shell: sidebar + main ---------------- */
.app-shell {
  flex: 1;
  display: flex;
  /* flex-start, not the default stretch: a stretched sidebar would already
     span the full shell height and have nowhere to travel, so `sticky`
     would do nothing. Capped at 100vh, it can stay put while the page
     scrolls past it. */
  align-items: flex-start;
  width: 100%;
}

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  padding: 16px 14px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sidebar-section { display: flex; flex-direction: column; gap: 8px; }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--text-soft);
  cursor: pointer;
  padding: 4px 6px;
  margin: 0 -6px;
  border-radius: var(--r-sm);
  user-select: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.toggle-row:hover { background: var(--surface-2); color: var(--text); }

.toggle-row input[type="checkbox"] {
  appearance: none;
  width: 32px;
  height: 18px;
  border-radius: var(--r-pill);
  background: var(--border-strong);
  position: relative;
  cursor: pointer;
  flex: none;
  transition: background var(--dur) var(--ease);
}
.toggle-row input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease);
}
.toggle-row input[type="checkbox"]:checked { background: var(--accent); }
.toggle-row input[type="checkbox"]:checked::after { transform: translateX(14px); }

.sidebar-label {
  font-size: 10.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}

.sidebar-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.45;
}

.segmented {
  display: flex;
  gap: 3px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.segmented-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 550;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: var(--r-sm);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
}
.segmented-btn:hover:not(.active) { color: var(--text); background: var(--surface-3); }
.segmented-btn.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.lang-select, .full-width { width: 100%; }
.lang-select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 7px 8px;
  font-size: 12px;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease);
}
.lang-select:hover { border-color: var(--border-strong); }

.sidebar-accordion {
  background: transparent;
  border: none;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  padding: 0;
  cursor: pointer;
  transition: color var(--dur) var(--ease);
}
.sidebar-accordion:hover { color: var(--accent); }

.ignore-patterns { display: flex; flex-direction: column; gap: 5px; margin-top: 7px; }
.ignore-patterns label { font-size: 11px; color: var(--text-muted); line-height: 1.45; }
.ignore-patterns textarea {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 7px 8px;
  resize: vertical;
  min-height: 52px;
  background: var(--surface-2);
  color: var(--text);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.ignore-patterns textarea:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: var(--ring);
}

/* Footer lives in the sidebar — the page bottom is a long way down. */
.site-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--text-muted);
}
.site-footer p { margin: 0 0 6px; }
.site-footer p:last-child { margin-bottom: 0; }
.footer-links a {
  color: var(--text-soft);
  text-decoration: none;
  border-bottom: 1px solid var(--border-strong);
}
.footer-links a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.footer-links span { margin: 0 5px; opacity: .5; }
.footer-legal { opacity: .8; }

/* ---------------- Shortcuts dialog ---------------- */
.shortcuts-dialog {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  padding: 18px 20px 20px;
  width: min(380px, calc(100vw - 32px));
}
.shortcuts-dialog::backdrop { background: rgba(11, 14, 19, .42); }
.shortcuts-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.shortcuts-head h2 { font-size: 15px; margin: 0; letter-spacing: -.01em; }
.shortcuts-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 9px 14px;
  margin: 0;
  align-items: center;
}
.shortcuts-list dt { display: flex; gap: 4px; }
.shortcuts-list dd { margin: 0; font-size: 12.5px; color: var(--text-soft); }
.shortcuts-list kbd, .compare-hint kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--text-soft);
  white-space: nowrap;
}
.shortcuts-note {
  margin: 16px 0 0;
  padding-top: 13px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
}

/* ---------------- Legal pages (privacy, terms) ---------------- */
.legal-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 34px 20px 64px;
}
.legal-page h1 {
  font-size: 24px;
  letter-spacing: -.02em;
  margin: 0 0 6px;
}
.legal-updated {
  color: var(--text-muted);
  font-size: 12.5px;
  margin: 0 0 26px;
}
.legal-page h2 {
  font-size: 15px;
  margin: 30px 0 8px;
  letter-spacing: -.01em;
}
.legal-page p, .legal-page li {
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-soft);
}
.legal-page ul { padding-left: 20px; }
.legal-page li { margin-bottom: 5px; }
.legal-page a { color: var(--accent); }
.legal-note {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  padding: 12px 15px;
  box-shadow: var(--shadow-xs);
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 22px;
}
.back-link:hover { color: var(--accent); }

/* ---------------- Main column ---------------- */
main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg);
}

/* --- composer: the input area, collapsible --- */
.composer {
  flex: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.composer-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-muted);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.composer-toggle:hover { background: var(--surface-2); color: var(--text); }
.composer-toggle .chev {
  font-size: 10px;
  transition: transform var(--dur) var(--ease);
}
.composer.collapsed .composer-toggle .chev { transform: rotate(-90deg); }
.composer-summary {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.composer-body {
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 0 14px 14px;
  border-top: 1px solid var(--border);
}
.composer.collapsed .composer-body { display: none; }

.input-pane {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 10px;
  padding-top: 12px;
}

.swap-btn { align-self: center; }

.editor-col {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.editor-col:focus-within {
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.editor-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 11px;
  font-size: 10.5px;
  font-weight: 650;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: .06em;
}

textarea {
  border: none;
  outline: none;
  resize: vertical;
  min-height: 150px;
  padding: 11px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  background: var(--surface);
  color: var(--text);
}

.text-btn {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 550;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  transition: background var(--dur) var(--ease);
}
.text-btn:hover { background: var(--accent-soft); }

.compare-row { display: flex; align-items: center; gap: 11px; }

.primary-btn {
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  padding: 9px 22px;
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
}
.primary-btn:hover { background: var(--accent-hover); box-shadow: var(--shadow-md); }
.primary-btn:active { transform: translateY(1px); box-shadow: var(--shadow-xs); }

.compare-hint { font-size: 11.5px; color: var(--text-muted); }
.compare-hint kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-soft);
}

.empty-state {
  min-height: 260px;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 30px;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  background: var(--surface);
}
/* The inner wrapper matters: text placed directly in a flex/grid container
   gets blockified, which would drop "Compare" onto its own line. */
.empty-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 380px;
  text-align: center;
  color: var(--text-soft);
  font-size: 13.5px;
  line-height: 1.55;
}
.empty-inner svg { color: var(--border-strong); }
.empty-state strong { color: var(--text); font-weight: 650; }
.empty-sub { font-size: 12px; color: var(--text-muted); }

/* ---------------- Workspace ---------------- */
/* The card holding the sticky tools group and the diff. It must NOT clip
   its overflow — `overflow: hidden` here would make it the sticky group's
   scroll container and kill the sticking. Rounded corners are applied to
   the first and last children instead. */
.workspace {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

/* Zero-height marker just above the sticky group; app.js watches it to
   tell whether the bar is currently stuck. */
.sticky-sentinel { height: 0; }

/* Tools bar + stats travel together and lock to the top of the viewport,
   taking over from the brand header as it scrolls away. */
.tools-sticky {
  position: sticky;
  top: 0;
  z-index: 40;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: var(--surface);
  overflow: hidden;               /* clips its own children to the radius */
}
/* Once it has left its resting place, lift it above the content it covers. */
.tools-sticky::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.tools-sticky.is-stuck::after { opacity: 1; }
.tools-sticky.is-stuck { border-radius: 0; }

.tools-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.doc-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tools-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
}

/* ---------------- Change navigator ---------------- */
.change-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 14px;
  padding: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-btn:hover:not(:disabled) { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-xs); }
.nav-btn:disabled { opacity: .35; cursor: default; }
.change-count {
  font-size: 11.5px;
  font-weight: 550;
  color: var(--text-soft);
  padding: 0 5px;
  min-width: 84px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
@media (max-width: 620px) { .change-count { min-width: 0; } }

/* Brief flash on the block you just jumped to, so it's obvious where you
   landed rather than leaving you to re-find your place. */
@keyframes change-land {
  from { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
  to   { background: transparent; box-shadow: inset 3px 0 0 transparent; }
}
.sbs-row.just-landed, .merge-spotlight.just-landed {
  animation: change-land 1.1s var(--ease);
}

/* ---------------- Result pane ---------------- */
.result-pane {
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  overflow: hidden;               /* safe: it is a sibling of the sticky
                                     group, not an ancestor of it */
  background: var(--surface);
}

.stats-header {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12.5px;
}
.stats-side { display: flex; align-items: center; gap: 8px; padding: 10px 14px; }
.stats-removed { border-right: 1px solid var(--border); }
.stats-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dot-removed { background: var(--danger); box-shadow: 0 0 0 3px rgba(217, 58, 63, .14); }
.dot-added { background: var(--success); box-shadow: 0 0 0 3px rgba(14, 143, 110, .14); }
.stats-removed #removalsCount { color: var(--danger); font-weight: 650; }
.stats-added #additionsCount { color: var(--success); font-weight: 650; }
.stats-linecount {
  color: var(--text-muted);
  margin-left: auto;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

/* Grows with its content — the page scrolls it, not an inner scrollbar.
   Horizontal overflow is still its own, for long unwrapped lines. */
.diff-view {
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
}

body.no-line-wrap .code { white-space: pre; }

/* --- side by side --- */
.side-by-side-view { display: block; }
.sbs-row {
  display: grid;
  grid-template-columns: 52px 1fr 52px 1fr;
  transition: background var(--dur) var(--ease);
}
.sbs-row:hover .code { background: var(--hover); }
.sbs-row.mergeable { cursor: pointer; }
.sbs-row.mergeable:hover { box-shadow: inset 3px 0 0 var(--accent); }

.line-no {
  text-align: right;
  padding: 1px 9px;
  color: var(--line-no);
  background: var(--line-no-bg);
  user-select: none;
  border-right: 1px solid var(--border);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
}

.code {
  padding: 1px 11px;
  white-space: pre-wrap;
  word-break: break-word;
  border-right: 1px solid var(--border);
}

.sbs-row.type-added .code.right,
.sbs-row.type-added .line-no.right { background: var(--added-bg); }
.sbs-row.type-removed .code.left,
.sbs-row.type-removed .line-no.left { background: var(--removed-bg); }
.sbs-row.type-modified .code.left,
.sbs-row.type-modified .line-no.left { background: var(--removed-bg); }
.sbs-row.type-modified .code.right,
.sbs-row.type-modified .line-no.right { background: var(--added-bg); }

.code.left .word-mark { background: var(--removed-strong); border-radius: 3px; padding: 0 1px; }
.code.right .word-mark { background: var(--added-strong); border-radius: 3px; padding: 0 1px; }
.inline-row.type-removed .word-mark { background: var(--removed-strong); border-radius: 3px; padding: 0 1px; }
.inline-row.type-added .word-mark { background: var(--added-strong); border-radius: 3px; padding: 0 1px; }

.collapse-row {
  grid-column: 1 / -1;
  padding: 6px 12px;
  color: var(--text-muted);
  background: var(--surface-2);
  cursor: pointer;
  font-size: 11.5px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  text-align: center;
  letter-spacing: .02em;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.collapse-row:hover { color: var(--accent); background: var(--accent-soft); }

/* --- inline view --- */
.inline-row { display: grid; grid-template-columns: 52px 52px 1fr; }
.inline-row .code { border-right: none; }
.inline-row.type-added { background: var(--added-bg); }
.inline-row.type-removed { background: var(--removed-bg); }
.inline-row .marker { width: 100%; text-align: center; color: var(--text-muted); user-select: none; }
.inline-row.type-added .marker { color: var(--success); }
.inline-row.type-removed .marker { color: var(--danger); }

/* --- syntax highlighting token colors --- */
.tok-keyword { color: #cf222e; font-weight: 600; }
.tok-string { color: #0a7d4c; }
.tok-comment { color: var(--text-muted); font-style: italic; }
.tok-number { color: #953800; }
.tok-function { color: #6639ba; }

[data-theme="dark"] .tok-keyword { color: #ff7b72; }
[data-theme="dark"] .tok-string { color: #7ee787; }
[data-theme="dark"] .tok-comment { color: #8b949e; }
[data-theme="dark"] .tok-number { color: #ffa657; }
[data-theme="dark"] .tok-function { color: #d2a8ff; }

/* --- merge spotlight card (a clicked-open change, inline in Split view) --- */
.merge-spotlight {
  display: grid;
  grid-template-columns: 52px 1fr 52px 1fr;
  border: 1.5px solid var(--accent);
  border-radius: var(--r-lg);
  margin: 12px 14px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  scroll-margin: 60px;
  animation: spotlight-in .19s var(--ease);
}
@keyframes spotlight-in {
  from { opacity: 0; transform: translateY(-4px) scale(.985); }
  to   { opacity: 1; transform: none; }
}
.merge-spotlight .code.placeholder {
  background: repeating-linear-gradient(135deg, var(--surface-2) 0 9px, var(--surface) 9px 18px);
}
.merge-spotlight .code.hl-removed { background: var(--removed-bg); }
.merge-spotlight .code.hl-added { background: var(--added-bg); }

.merge-spotlight-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.spotlight-btn {
  padding: 9px 18px;
  border-radius: var(--r-pill);
  font-weight: 650;
  font-size: 12.5px;
  border: none;
  cursor: pointer;
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              filter var(--dur) var(--ease);
}
.spotlight-btn.danger { background: var(--danger); }
.spotlight-btn.success { background: var(--success); }
.spotlight-btn:hover { filter: brightness(1.07); box-shadow: var(--shadow-md); }
.spotlight-btn:active { transform: translateY(1px); box-shadow: var(--shadow-xs); }
.spotlight-btn .chevron { font-size: 16px; line-height: 1; }
.spotlight-btn.undo {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--text-muted);
  font-weight: 400;
  font-size: 15px;
  justify-content: center;
}
.spotlight-btn.undo:hover {
  color: var(--text);
  border-color: var(--accent);
  filter: none;
}

/* --- resolved row: once a merge decision is made the row stays in the
   normal two-column layout — both sides mirror the resolved text, like an
   "equal" row — but drops the red/green diff colors, which would suggest
   it's still an open change. It gets its own treatment instead: a soft
   accent tint and a solid accent bar, so merged lines are obvious while
   scrolling. The arrow in the middle shows which side the result came
   from (hover for a label); undo sends it back to the diff view. --- */
.sbs-row.type-resolved {
  position: relative;
  cursor: default;
  background: var(--resolved-bg);
  box-shadow: inset 3px 0 0 var(--resolved-border);
}
.sbs-row.type-resolved .line-no { background: transparent; }
.sbs-row.type-resolved:hover .code { background: none; }
.sbs-row.type-resolved .code {
  font-family: var(--mono);
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.sbs-row.type-resolved .code.right { padding-right: 32px; }
.sbs-row.type-resolved.empty .code { color: var(--text-muted); font-style: italic; }

.merge-direction {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--resolved-border);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 0 0 3px var(--resolved-bg), var(--shadow-sm);
  z-index: 2;
}
.merge-direction::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 145%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--surface);
  padding: 5px 10px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 500;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  box-shadow: var(--shadow-md);
  transition: opacity .12s var(--ease);
  z-index: 5;
}
.merge-direction:hover::after { opacity: 1; }

.undo-inline {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--resolved-border);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  padding: 0;
  color: var(--resolved-border);
  font-size: 12px;
  cursor: pointer;
  z-index: 2;
  box-shadow: var(--shadow-xs);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.undo-inline:hover { background: var(--resolved-border); color: #fff; }

/* ---------------- Responsive ---------------- */
@media (max-width: 860px) {
  .only-desktop { display: none; }
  .only-mobile { display: inline-flex; align-items: center; justify-content: center; }
  .app-shell { position: relative; }
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform .2s var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  main { padding: 10px; }
  .input-pane { grid-template-columns: 1fr; }
  .swap-btn { justify-self: center; }
  .sbs-row, .merge-spotlight { grid-template-columns: 38px 1fr 38px 1fr; }
  .inline-row { grid-template-columns: 38px 38px 1fr; }
  .stats-header { grid-template-columns: 1fr; }
  .stats-removed { border-right: none; border-bottom: 1px solid var(--border); }
}
