/* ===================================================================
   DeltaDraw v2 — Design System
   Clean, modern, precise. Light + dark themes. Soft corners.
   =================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&family=IBM+Plex+Sans:wght@400;500;600&family=Instrument+Serif&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Theme: Light (default) ───────────────────────────────────────── */
:root {
  --bg-page:    oklch(98.5% 0.004 250);
  --bg-surface: oklch(100% 0 0);
  --bg-sunk:    oklch(96.5% 0.005 250);
  --bg-raised:  oklch(99.5% 0.002 250);
  --bg-hover:   oklch(95% 0.006 250);
  --bg-active:  oklch(92% 0.008 250);

  --line-soft:   oklch(92% 0.005 250);
  --line:        oklch(88% 0.006 250);
  --line-strong: oklch(78% 0.008 250);
  --hairline:    oklch(70% 0.01 250 / 0.32);

  --ink:    oklch(20% 0.018 255);
  --ink-2:  oklch(38% 0.014 255);
  --ink-3:  oklch(55% 0.012 255);
  --ink-4:  oklch(70% 0.01 255);

  --primary:        oklch(48% 0.16 268);
  --primary-2:      oklch(58% 0.16 268);
  --primary-3:      oklch(70% 0.12 268);
  --primary-tint:   oklch(95% 0.03 268);
  --primary-tint-2: oklch(90% 0.05 268);

  --removed:        oklch(52% 0.13 28);
  --removed-2:      oklch(62% 0.14 28);
  --removed-tint:   oklch(95% 0.025 28);

  --added:          oklch(50% 0.10 155);
  --added-2:        oklch(60% 0.12 155);
  --added-tint:     oklch(94% 0.025 155);

  --warning:        oklch(62% 0.13 70);
  --warning-2:      oklch(72% 0.14 70);
  --warning-tint:   oklch(95% 0.04 70);

  --gdt:            oklch(52% 0.15 305);
  --gdt-2:          oklch(64% 0.15 305);
  --gdt-tint:       oklch(95% 0.03 305);

  --info:           oklch(55% 0.10 230);
  --info-tint:      oklch(95% 0.025 230);

  --paper:        oklch(98% 0.003 80);
  --paper-grid:   oklch(82% 0.005 250 / 0.55);

  --sans: "Geist", -apple-system, system-ui, sans-serif;
  --mono: "IBM Plex Sans", -apple-system, system-ui, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;

  --t-display: 56px;
  --t-h1: 32px;
  --t-h2: 22px;
  --t-h3: 16px;
  --t-body: 14px;
  --t-small: 12.5px;
  --t-mono: 11.5px;
  --t-eyebrow: 10.5px;

  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-7: 32px; --s-8: 48px;
  --s-9: 64px; --s-10: 96px;

  --r-1: 3px;
  --r-2: 5px;
  --r-3: 7px;
  --r-4: 10px;
  --r-5: 14px;
  --r-pill: 999px;

  --shadow-sm: 0 1px 2px oklch(40% 0.02 250 / 0.06), 0 0 0 1px oklch(40% 0.02 250 / 0.04);
  --shadow:    0 2px 6px oklch(40% 0.02 250 / 0.08), 0 0 0 1px oklch(40% 0.02 250 / 0.05);
  --shadow-lg: 0 8px 24px oklch(40% 0.02 250 / 0.12), 0 0 0 1px oklch(40% 0.02 250 / 0.06);
  --shadow-pop:0 18px 48px oklch(20% 0.02 250 / 0.18), 0 0 0 1px oklch(40% 0.02 250 / 0.08);

  --ease-out: cubic-bezier(.2,.9,.3,1);
  --t-fast: 120ms;
  --t-base: 180ms;
  --t-slow: 320ms;

  /* Legacy aliases for app.js inline references */
  --bg-primary: oklch(98.5% 0.004 250);
  --bg-secondary: oklch(100% 0 0);
  --bg-tertiary: oklch(96.5% 0.005 250);
  --border-color: oklch(88% 0.006 250);
  --text-primary: oklch(20% 0.018 255);
  --text-secondary: oklch(55% 0.012 255);
  --accent-blue: oklch(48% 0.16 268);
  --accent-red: oklch(52% 0.13 28);
  --accent-green: oklch(50% 0.10 155);
  --accent-amber: oklch(62% 0.13 70);
  --accent-purple: oklch(52% 0.15 305);
}

/* ── Theme: Dark ──────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg-page:    oklch(15% 0.012 255);
  --bg-surface: oklch(18% 0.014 255);
  --bg-sunk:    oklch(13% 0.012 255);
  --bg-raised:  oklch(21% 0.015 255);
  --bg-hover:   oklch(24% 0.016 255);
  --bg-active:  oklch(28% 0.018 255);

  --line-soft:   oklch(24% 0.014 255);
  --line:        oklch(30% 0.016 255);
  --line-strong: oklch(40% 0.018 255);
  --hairline:    oklch(70% 0.01 255 / 0.28);

  --ink:    oklch(96% 0.008 255);
  --ink-2:  oklch(78% 0.012 255);
  --ink-3:  oklch(60% 0.012 255);
  --ink-4:  oklch(45% 0.012 255);

  --primary:        oklch(70% 0.16 268);
  --primary-2:      oklch(78% 0.14 268);
  --primary-3:      oklch(58% 0.16 268);
  --primary-tint:   oklch(28% 0.06 268);
  --primary-tint-2: oklch(34% 0.08 268);

  --removed:        oklch(68% 0.16 28);
  --removed-2:      oklch(78% 0.14 28);
  --removed-tint:   oklch(28% 0.05 28);

  --added:          oklch(72% 0.14 155);
  --added-2:        oklch(80% 0.13 155);
  --added-tint:     oklch(26% 0.04 155);

  --warning:        oklch(78% 0.15 70);
  --warning-2:      oklch(86% 0.13 70);
  --warning-tint:   oklch(28% 0.05 70);

  --gdt:            oklch(72% 0.16 305);
  --gdt-2:          oklch(80% 0.14 305);
  --gdt-tint:       oklch(28% 0.06 305);

  --info:           oklch(72% 0.12 230);
  --info-tint:      oklch(28% 0.05 230);

  --paper:        oklch(94% 0.004 80);
  --paper-grid:   oklch(70% 0.005 250 / 0.5);

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.35), 0 0 0 1px rgb(255 255 255 / 0.04);
  --shadow:    0 2px 8px rgb(0 0 0 / 0.4), 0 0 0 1px rgb(255 255 255 / 0.05);
  --shadow-lg: 0 12px 32px rgb(0 0 0 / 0.5), 0 0 0 1px rgb(255 255 255 / 0.06);
  --shadow-pop:0 22px 60px rgb(0 0 0 / 0.6), 0 0 0 1px rgb(255 255 255 / 0.08);
}

html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--sans);
  font-size: var(--t-body);
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg-page);
  font-feature-settings: "ss01", "cv11", "tnum";
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background var(--t-base) var(--ease-out), color var(--t-base) var(--ease-out);
}
button { font: inherit; color: inherit; }
input, textarea, select { font: inherit; }
img, svg { display: block; }

.mono { font-family: var(--mono); font-feature-settings: "ss01", "tnum"; }
.serif { font-family: var(--serif); }
.eyebrow {
  font-family: var(--mono);
  font-size: var(--t-eyebrow);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
}

/* ── App frame ────────────────────────────────────────────────────── */
.app-frame { display: flex; flex-direction: column; height: 100vh; background: var(--bg-page); overflow: hidden; }

.titlebar {
  height: 50px;
  display: flex; align-items: center;
  padding: 0 var(--s-4);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--line);
  gap: var(--s-4);
  flex-shrink: 0;
}
.lights { display: flex; gap: 6px; }
.lights span {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--line-strong);
  opacity: .8;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 500; letter-spacing: -0.005em; font-size: 14px;
}
.brand-mark {
  width: 24px; height: 24px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--primary), var(--primary-3));
  display: inline-flex; align-items: center; justify-content: center;
  color: white;
  box-shadow: var(--shadow-sm);
}
.brand-mark svg { width: 13px; height: 13px; }
.brand .ver {
  font-family: var(--mono); font-size: 10px;
  padding: 2px 7px; border-radius: var(--r-pill);
  background: var(--bg-sunk); color: var(--ink-3);
  letter-spacing: 0.04em;
}
.crumbs {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-4);
}
.crumbs .crumb.active { color: var(--ink); }
.crumbs .sep { color: var(--line-strong); }
.titlebar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* AI status pill */
.ai-status, .status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--bg-sunk);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-2);
  text-transform: uppercase;
}
.ai-status::before, .status-pill .dot {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-4);
}
.ai-status.active::before, .status-pill.live .dot {
  background: var(--added);
  box-shadow: 0 0 0 3px var(--added-tint);
  animation: live-pulse 1.6s ease-in-out infinite;
}
.ai-status.inactive::before { background: var(--ink-4); }
@keyframes live-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--added-tint); }
  50%      { box-shadow: 0 0 0 4px transparent; }
}

.version-text {
  font-family: var(--mono); font-size: 10px;
  color: var(--ink-4); letter-spacing: 0.04em;
}

.theme-toggle {
  display: inline-flex;
  background: var(--bg-sunk);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-pill);
  padding: 3px;
  gap: 2px;
}
.theme-toggle button {
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: transparent;
  border: none;
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-out);
}
.theme-toggle button.on {
  background: var(--bg-surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* ── Sign-off footer ──────────────────────────────────────────────── */
.signoff {
  display: flex; align-items: center;
  padding: 0 var(--s-4);
  height: 36px;
  background: var(--bg-surface);
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
  flex-shrink: 0;
  gap: var(--s-5);
}
.signoff .seg-item { display: inline-flex; align-items: center; gap: 6px; }
.signoff .seg-item strong {
  color: var(--ink-3);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 10px;
}
.signoff .seg-item .v { color: var(--ink); font-weight: 500; }
.signoff .seg-item .v.added { color: var(--added); }
.signoff .seg-item .v.warning { color: var(--warning); }
.signoff .seg-item .v.removed { color: var(--removed); }
.signoff .seg-item + .seg-item::before {
  content: ""; width: 1px; height: 14px; background: var(--line);
  margin-right: var(--s-3);
}
.signoff .right { margin-left: auto; }
.signoff .route-pill {
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--primary-tint);
  color: var(--primary);
  font-weight: 500;
}

/* Section markers "01 / 02" */
.section-num {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--ink-3);
}
.section-num strong { color: var(--ink); font-weight: 500; }
.section-num .sep { color: var(--line-strong); margin: 0 6px; }

/* ── Screens ──────────────────────────────────────────────────────── */
.screen { display: none; flex: 1; min-height: 0; flex-direction: column; position: relative; }
.screen.active { display: flex; }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn, .btn-primary, .btn-secondary, .btn-download, .redline-btn, .toolbar-toggle, .nav-btn, .zoom-btn {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: 8px 14px;
  border-radius: var(--r-3);
  border: 1px solid var(--line);
  background: var(--bg-surface);
  color: var(--ink);
  font-size: var(--t-body);
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-out);
  white-space: nowrap;
  font-family: inherit;
}
.btn:hover, .btn-secondary:hover, .toolbar-toggle:hover, .nav-btn:hover, .zoom-btn:hover, .redline-btn:hover {
  background: var(--bg-hover); border-color: var(--line-strong);
}
.btn:active, .btn-primary:active { transform: translateY(0.5px); }
.btn:disabled, .btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn .kbd, .btn-primary .kbd {
  font-family: var(--mono); font-size: 10px;
  padding: 1px 5px;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink-3);
}

.btn-primary, .btn-download {
  background: var(--primary);
  color: white;
  border-color: transparent;
  box-shadow: 0 1px 2px oklch(40% 0.1 268 / 0.2), inset 0 1px 0 oklch(100% 0 0 / 0.12);
}
.btn-primary:hover:not(:disabled), .btn-download:hover { background: var(--primary-2); border-color: transparent; filter: none; }
.btn-primary .kbd { background: oklch(100% 0 0 / 0.18); border-color: transparent; color: oklch(100% 0 0 / 0.85); }

.btn-ghost {
  background: transparent; border-color: transparent; color: var(--ink-2);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--ink); }

.btn-danger { background: var(--removed-tint); color: var(--removed-2); border-color: transparent; }
.btn-danger:hover { background: var(--removed); color: white; }

.btn-sm { padding: 5px 10px; font-size: var(--t-small); border-radius: var(--r-2); }

.btn-export {
  background: var(--bg-surface) !important;
  color: var(--ink) !important;
  border: 1px solid var(--line) !important;
  box-shadow: none !important;
}
.btn-export:hover { background: var(--bg-hover) !important; border-color: var(--line-strong) !important; }

.toolbar-toggle, .redline-btn {
  padding: 5px 10px; font-size: var(--t-small);
  border-radius: var(--r-2);
}
.redline-btn.active {
  background: var(--removed-tint); color: var(--removed); border-color: transparent;
}
.toolbar-toggle.active {
  background: var(--primary-tint); color: var(--primary); border-color: transparent;
}

.toolbar-toggle.fb-toolbar-btn { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 30%, var(--line)); }
.toolbar-toggle.fb-toolbar-btn:hover { background: var(--warning-tint); }
.toolbar-toggle.fb-toolbar-copy { color: var(--added); border-color: color-mix(in srgb, var(--added) 30%, var(--line)); position: relative; }
.toolbar-toggle.fb-toolbar-copy:hover { background: var(--added-tint); }
.fb-copy-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; padding: 0 6px; margin-left: 2px;
  background: var(--primary); color: white;
  border-radius: var(--r-pill); font-size: 10px; font-weight: 600; line-height: 16px;
  font-family: var(--mono);
}

/* Floating sidebar toggle — Xcode-style rounded button at top-right */
.sidebar-toggle-btn.floating {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 25;
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  color: var(--ink-2);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--t-fast) var(--ease-out);
}
.sidebar-toggle-btn.floating:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: var(--bg-raised);
  box-shadow: var(--shadow);
}
.sidebar-toggle-btn.floating[aria-pressed="true"] {
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 30%, var(--line));
  background: var(--primary-tint);
}

/* Page nav + zoom (compact icon variants) */
.nav-btn, .zoom-btn {
  width: 28px; height: 28px;
  padding: 0; justify-content: center;
  border-radius: var(--r-2);
  font-family: var(--mono); font-size: 12px;
  color: var(--ink-2);
}
.nav-btn:hover, .zoom-btn:hover { color: var(--ink); }

.page-indicator {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-family: var(--mono);
  font-size: var(--t-small);
  color: var(--ink-2);
  letter-spacing: 0.04em;
  padding: 0 6px; min-width: 60px; justify-content: center;
}
.page-indicator strong { color: var(--ink); font-weight: 500; }
.page-indicator .tot { color: var(--ink-4); margin-left: 4px; }

/* ── Badges ───────────────────────────────────────────────────────── */
.badge, .type-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--bg-sunk);
  color: var(--ink-2);
  border: 1px solid var(--line-soft);
}
.badge .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.removed, .type-badge.dimension { background: var(--removed-tint); color: var(--removed); border-color: transparent; }
.badge.added, .type-badge.added { background: var(--added-tint); color: var(--added); border-color: transparent; }
.badge.warning, .type-badge.geometry, .type-badge.modified, .type-badge.removed { background: var(--warning-tint); color: var(--warning); border-color: transparent; }
.badge.gdt, .type-badge.gdt { background: var(--gdt-tint); color: var(--gdt); border-color: transparent; }
.badge.info, .type-badge.text { background: var(--info-tint); color: var(--info); border-color: transparent; }
.badge.primary { background: var(--primary-tint); color: var(--primary); border-color: transparent; }
.type-badge.warning-badge, .warning-badge { background: var(--warning-tint); color: var(--warning); border-color: transparent; }

/* Stamp badge */
.stamp {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono);
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.18em; text-transform: uppercase;
  padding: 4px 10px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  color: var(--added);
  transform: rotate(-3deg);
  position: relative;
  background: oklch(98% 0 0 / 0.6);
}
.stamp::before {
  content: ""; position: absolute; inset: -3px;
  border: 1px dashed currentColor; opacity: 0.35;
  border-radius: 4px; pointer-events: none;
}
.stamp.flag { color: var(--warning); }

/* ── Filter chips ─────────────────────────────────────────────────── */
.fchip, .chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--bg-surface);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-out);
}
.fchip:hover, .chip:hover { background: var(--bg-hover); color: var(--ink); }
.fchip .sw, .chip .sw { width: 7px; height: 7px; border-radius: 2px; background: var(--ink-3); }
.fchip .ct, .chip .ct { color: var(--ink-3); font-weight: 500; }
.fchip.dimension .sw { background: var(--removed); }
.fchip.text .sw { background: var(--info); }
.fchip.geometry .sw, .fchip.modified .sw, .fchip.added .sw, .fchip.removed .sw { background: var(--warning); }
.fchip.gdt .sw { background: var(--gdt); }
.fchip.on { background: var(--bg-active); color: var(--ink); border-color: var(--line-strong); }
.fchip.off { opacity: 0.5; }

/* ── Inputs ───────────────────────────────────────────────────────── */
.input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  color: var(--ink);
  font-size: var(--t-body);
  transition: all var(--t-fast) var(--ease-out);
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint); }
.input::placeholder { color: var(--ink-4); }
textarea.input { resize: vertical; min-height: 70px; }

/* ── Upload screen ────────────────────────────────────────────────── */
#screen-upload.active { align-items: center; justify-content: center; padding: var(--s-7); }
.upload-shell { width: 100%; max-width: 760px; }
.upload-shell .meta { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); }
.upload-shell h1 {
  font-size: var(--t-h1); font-weight: 400;
  letter-spacing: -0.025em; line-height: 1.25;
  margin-bottom: var(--s-3);
  color: var(--ink);
}
.upload-shell h1 em {
  font-family: var(--serif); font-style: italic;
  color: var(--primary); font-weight: 400;
  line-height: 1; display: inline-block; vertical-align: baseline;
}
.upload-shell .lead {
  color: var(--ink-2); font-size: 15px; line-height: 1.55;
  max-width: 540px; margin-bottom: var(--s-6);
}
.file-slots {
  display: grid;
  grid-template-columns: 1fr 24px 1fr;
  gap: 0; align-items: stretch;
}
.file-slot { display: flex; }
.slot-arrow {
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-4);
  font-family: var(--mono); font-size: 14px;
}
.upload-actions {
  margin-top: var(--s-5);
  padding-top: var(--s-5);
  border-top: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between;
}
.upload-meta {
  display: flex; align-items: center; gap: var(--s-3);
  font-family: var(--mono);
  font-size: 11px; color: var(--ink-3);
  letter-spacing: 0.06em; text-transform: uppercase;
}
.upload-meta .sep { color: var(--line-strong); }

/* Drop zone */
.drop-zone {
  position: relative; flex: 1;
  background: var(--bg-surface);
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-4);
  padding: var(--s-6);
  min-height: 220px;
  display: flex; flex-direction: column;
  cursor: pointer;
  transition: all var(--t-base) var(--ease-out);
  overflow: hidden;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-tint);
}
.drop-zone.has-file {
  border-style: solid;
  border-color: var(--added);
  background: var(--added-tint);
}
.slot-label {
  display: flex; align-items: center; gap: var(--s-2);
  margin-bottom: var(--s-4);
}
.slot-idx {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px;
  background: var(--bg-sunk);
  font-family: var(--mono);
  font-size: 10.5px; font-weight: 600;
  color: var(--ink-2);
  letter-spacing: 0.06em;
}
.drop-zone.has-file .slot-idx { background: var(--added); color: white; }
.slot-tag {
  font-family: var(--mono);
  font-size: var(--t-eyebrow);
  letter-spacing: 0.14em;
  color: var(--ink-3);
  text-transform: uppercase;
}
.drop-icon { color: var(--ink-4); margin-bottom: var(--s-3); }
.drop-icon svg { width: 32px; height: 32px; }
.drop-zone h3 { font-size: var(--t-h3); font-weight: 500; margin-bottom: 4px; letter-spacing: -0.01em; color: var(--ink); }
.drop-zone .hint, .drop-zone p {
  color: var(--ink-3); font-size: var(--t-small);
  margin-bottom: auto;
}
.file-input { display: none; }
.file-name {
  margin-top: var(--s-4);
  padding: 8px 10px;
  background: var(--bg-surface);
  border-radius: var(--r-2);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--added);
  display: none;
  border: 1px solid color-mix(in srgb, oklch(60% 0.10 155) 30%, transparent);
}
.drop-zone.has-file .file-name { display: block; }

/* ── Processing screen ────────────────────────────────────────────── */
#screen-processing.active { align-items: center; justify-content: center; padding: var(--s-7); }
.proc-shell { width: 100%; max-width: 480px; text-align: left; }
.proc-shell .meta { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); }
.proc-shell h2 {
  font-size: 26px; font-weight: 400; letter-spacing: -0.02em;
  margin-bottom: var(--s-6); color: var(--ink);
}
.proc-shell h2 em {
  font-family: var(--serif); font-style: italic;
  color: var(--primary); font-weight: 400;
}
.progress-rail {
  position: relative;
  height: 6px;
  background: var(--line-soft);
  border-radius: var(--r-pill);
  overflow: hidden;
  margin-bottom: 6px;
}
.progress-rail .fill, .progress-bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--primary);
  border-radius: var(--r-pill);
  transition: width var(--t-slow) var(--ease-out);
  width: 0%;
  height: 100%;
}
.progress-rail.scan::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 30%;
  background: linear-gradient(90deg, transparent, var(--primary) 50%, transparent);
  animation: scan 1.6s var(--ease-out) infinite;
}
@keyframes scan { 0% { transform: translateX(-30%); } 100% { transform: translateX(380%); } }
.proc-meta {
  font-family: var(--mono); font-size: 11px; color: var(--ink-3);
  display: flex; justify-content: space-between;
  margin-bottom: var(--s-5);
}
.proc-stage, .proc-timer {
  font-family: var(--mono); font-size: 12px; color: var(--ink-2);
  margin-bottom: 4px;
}
.proc-timer { color: var(--ink-3); }
.proc-stages {
  display: flex; flex-direction: column; gap: 10px;
  margin-top: var(--s-5);
}
.proc-stage-row {
  display: flex; align-items: center; gap: var(--s-3);
  font-family: var(--mono); font-size: 12px;
  color: var(--ink-3);
  transition: color var(--t-base) var(--ease-out);
}
.proc-stage-row .stage-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--line);
  flex-shrink: 0;
}
.proc-stage-row.done { color: var(--ink-2); }
.proc-stage-row.done .stage-dot { background: var(--added); }
.proc-stage-row.active { color: var(--ink); font-weight: 500; }
.proc-stage-row.active .stage-dot {
  background: var(--primary);
  animation: stage-pulse 1.4s ease-in-out infinite;
}
@keyframes stage-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--primary-tint-2); }
  50%      { box-shadow: 0 0 0 5px transparent; }
}
.proc-stage-row .stage-time { margin-left: auto; color: var(--ink-4); font-size: 10.5px; }

/* ── Skeleton overlay ─────────────────────────────────────────────── */
.skeleton-loading .panel-scroll, .skeleton-loading .overlay-panel {
  filter: blur(3px) brightness(.96);
  pointer-events: none;
  transition: filter .5s ease;
}
.skeleton-loading .redline-sidebar { display: none !important; }
.skeleton-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 100;
  background: color-mix(in srgb, var(--bg-page) 75%, transparent);
  backdrop-filter: blur(2px);
}
.skeleton-card {
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--r-4);
  padding: 24px 32px;
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; width: 380px;
  box-shadow: var(--shadow-lg);
}
.skeleton-brand {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em;
  color: var(--ink-3); text-transform: uppercase;
}
.skeleton-brand-delta { color: var(--ink-3); }
.skeleton-brand-draw { color: var(--primary); font-weight: 500; }
.skeleton-spinner {
  width: 28px; height: 28px;
  border: 2px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: skeleton-spin 0.9s linear infinite;
}
@keyframes skeleton-spin { to { transform: rotate(360deg); } }
.skeleton-stage {
  font-family: var(--sans); font-size: 13px; color: var(--ink);
  text-align: center; height: 1.3em; line-height: 1.3em; font-weight: 500;
}
.skeleton-substage {
  font-size: 11.5px; color: var(--ink-3);
  text-align: center; height: 1.2em; line-height: 1.2em;
}
.skeleton-timer {
  font-family: var(--mono); font-size: 10.5px; color: var(--ink-4);
  letter-spacing: 0.04em;
}
.skeleton-progress {
  width: 100%; height: 4px;
  background: var(--line-soft);
  border-radius: var(--r-pill); overflow: hidden;
}
.skeleton-progress-fill {
  height: 100%; width: 0%;
  background: var(--primary);
  transition: width 1.5s ease;
}

/* ── Toolbar ──────────────────────────────────────────────────────── */
.toolbar {
  display: flex; align-items: center;
  padding: 10px var(--s-4);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--line);
  gap: var(--s-3);
  flex-shrink: 0;
  min-height: 56px;
  flex-wrap: wrap;
}
.toolbar-left, .toolbar-center, .toolbar-right {
  display: flex; align-items: center; gap: var(--s-2);
}
.toolbar-divider, .tdiv { width: 1px; height: 22px; background: var(--line); margin: 0 var(--s-2); }

/* Segmented mode tabs */
.mode-tabs {
  display: inline-flex;
  background: var(--bg-sunk);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-3);
  padding: 3px;
  gap: 2px;
}
.tab-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border-radius: var(--r-2);
  background: transparent;
  border: none;
  color: var(--ink-3);
  font-size: var(--t-small);
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--t-fast) var(--ease-out);
}
.tab-btn:hover:not(.active) { color: var(--ink); }
.tab-btn.active {
  background: var(--bg-surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.tab-btn .g { display: flex; }
.tab-btn svg { width: 13px; height: 13px; }

.zoom-controls {
  display: inline-flex; gap: 2px;
  background: var(--bg-sunk);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-3);
  padding: 3px;
}
.zoom-controls .zoom-btn {
  width: 26px; height: 26px;
  border: none; border-radius: var(--r-2);
  background: transparent;
  color: var(--ink-3);
}
.zoom-controls .zoom-btn:hover { background: var(--bg-surface); color: var(--ink); }

/* ── Filter bar + sparkline ───────────────────────────────────────── */
.filterbar {
  display: flex; align-items: center; gap: var(--s-2);
  padding: 8px var(--s-4);
  background: var(--bg-sunk);
  border-bottom: 1px solid var(--line-soft);
  min-height: 38px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.filterbar .flbl, .filter-label {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-3); margin-right: 4px;
}
.spark, .spark-row {
  display: flex; align-items: center; gap: var(--s-2);
  margin-left: auto;
  font-family: var(--mono); font-size: 11px; color: var(--ink-3);
}
.spark-dots {
  display: flex; gap: 2px;
  max-width: 280px; flex-wrap: nowrap; overflow: hidden;
}
.spark-dot {
  width: 6px; height: 14px; border-radius: 2px;
  background: var(--line);
  cursor: pointer; flex-shrink: 0;
  transition: transform var(--t-fast) var(--ease-out);
}
.spark-dot:hover { transform: scaleY(1.2); }
/* Saturation tied to urgency — loud for "needs attention", quiet for "settled" */
.spark-dot.unactioned       { background: var(--removed); }
.spark-dot.change-required  { background: var(--warning); }
.spark-dot.approved         { background: color-mix(in oklch, var(--added) 45%, var(--bg-surface)); }
.spark-dot.dismissed        { background: var(--line-strong); opacity: 0.6; }
.spark-dot.selected {
  outline: 1.5px solid var(--primary);
  outline-offset: 1px;
  filter: saturate(1.4);
}

/* ── Results body ─────────────────────────────────────────────────── */
.results-body { flex: 1; overflow: hidden; position: relative; display: flex; min-height: 0; }
.results-main { flex: 1; overflow: hidden; position: relative; display: flex; min-width: 0; }

@keyframes wipe-in { 0% { clip-path: inset(0 0 100% 0); } 100% { clip-path: inset(0 0 0 0); } }
.view-container {
  flex: 1; display: flex; flex-direction: column;
  position: relative; overflow: hidden; min-width: 0;
  animation: wipe-in .2s var(--ease-out);
}
#view-side-by-side { flex-direction: row; padding: var(--s-4); gap: var(--s-3); background: var(--bg-page); }

/* Panel chrome */
.panel {
  flex: 1; display: flex; flex-direction: column;
  position: relative; overflow: hidden; min-width: 0;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--r-4);
}
.panel-label {
  padding: 8px var(--s-3);
  background: var(--bg-sunk);
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--mono); font-size: 10.5px;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-3);
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}
.panel-old .panel-label { color: var(--removed); }
.panel-new .panel-label { color: var(--added); }
.panel-label .rev-tag {
  font-family: var(--mono); font-size: 10px;
  padding: 1px 6px; border-radius: 3px;
  background: var(--bg-surface); color: var(--ink-2);
  letter-spacing: 0.04em;
}

.panel-scroll {
  flex: 1; overflow: auto; position: relative;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--paper-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--paper-grid) 1px, transparent 1px);
  background-size: 24px 24px;
  padding: var(--s-4);
  display: flex; justify-content: center; align-items: flex-start;
}
/* Crop marks */
.panel-scroll::before, .panel-scroll::after {
  content: ""; position: absolute;
  width: 12px; height: 12px;
  border: 0 solid var(--ink-4); opacity: 0.5;
  pointer-events: none;
}
.panel-scroll::before { top: 6px; left: 6px; border-top-width: 1px; border-left-width: 1px; }
.panel-scroll::after  { bottom: 6px; right: 6px; border-bottom-width: 1px; border-right-width: 1px; }

.image-wrapper {
  position: relative;
  background: white;
  box-shadow: var(--shadow);
  border-radius: var(--r-2);
}
.image-wrapper img {
  display: block; max-width: 100%; height: auto;
  border-radius: var(--r-2);
}
.overlay-layer { position: absolute; inset: 0; pointer-events: none; }
.overlay-layer > * { pointer-events: auto; }

/* Overlay mode */
.overlay-controls {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 10px var(--s-4);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--line-soft);
  flex-shrink: 0;
}
.overlay-label {
  font-family: var(--mono); font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--ink-3);
}
.overlay-controls input[type=range] { flex: 1; accent-color: var(--primary); }
.overlay-stack { position: relative; }
.overlay-img { transition: opacity .15s ease; }
.overlay-img-old { position: relative; }
.overlay-img-new { position: absolute; top: 0; left: 0; }

/* ── Sidebar ──────────────────────────────────────────────────────── */
.redline-sidebar {
  width: 340px;
  background: var(--bg-surface);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}
.redline-sidebar h3 {
  padding: var(--s-4);
  border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: var(--s-2);
  font-size: var(--t-h3);
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--ink);
}
.redline-sidebar h3 .count {
  margin-left: auto;
  background: var(--primary-tint); color: var(--primary);
  padding: 2px 8px; border-radius: var(--r-pill);
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.04em;
}
.change-list {
  flex: 1; overflow-y: auto;
  padding: var(--s-3);
  display: flex; flex-direction: column; gap: 6px;
}
.no-changes {
  padding: var(--s-5);
  font-family: var(--mono); font-size: 11px; color: var(--ink-3);
  text-align: center; text-transform: uppercase; letter-spacing: 0.08em;
}

.change-section { margin-top: var(--s-2); }
.change-section:first-child { margin-top: 0; }
.change-section.collapsed .change-card { display: none; }
.section-header {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 4px;
  font-family: var(--mono); font-size: 10.5px;
  letter-spacing: 0.14em; text-transform: uppercase;
  cursor: pointer; user-select: none;
  background: transparent !important;
  border-radius: 0; margin-bottom: 4px;
}
.section-header::before {
  content: ""; width: 6px; height: 6px; border-radius: 2px;
  background: currentColor; opacity: 0.85;
}
.section-unactioned { color: var(--removed); }
.section-change-required { color: var(--warning); }
.section-approved { color: var(--added); }
.section-dismissed { color: var(--ink-4); }

/* Change card */
.change-card {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 4px var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease-out);
  position: relative;
  align-items: start;
}
.change-card:hover { border-color: var(--line-strong); background: var(--bg-raised); }
.change-card.selected {
  border-color: var(--primary);
  background: var(--primary-tint);
  box-shadow: inset 2px 0 0 var(--primary);
}
.change-card[data-status="approved"] .change-card-num { color: var(--added); }
.change-card[data-status="change-required"] .change-card-num { color: var(--warning); }

/* Type badge inside a per-change context reflects STATUS color, not type color.
   The badge text still says DIMENSION/TEXT/etc — only the chip color changes. */
.change-card .type-badge,
.annotation-popup .type-badge {
  background: var(--removed-tint);
  color: var(--removed);
}
.change-card[data-status="approved"] .type-badge,
.annotation-popup[data-status="approved"] .type-badge {
  background: var(--added-tint);
  color: var(--added);
}
.change-card[data-status="change-required"] .type-badge,
.annotation-popup[data-status="change-required"] .type-badge {
  background: var(--warning-tint);
  color: var(--warning);
}
.change-card[data-status="dismissed"] .type-badge,
.annotation-popup[data-status="dismissed"] .type-badge {
  background: var(--bg-sunk);
  color: var(--ink-3);
}
.change-card-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  line-height: 20px;
  letter-spacing: 0.04em;
}
.change-card-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.change-card-header {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.change-card-zone {
  font-family: var(--mono); font-size: 10.5px;
  color: var(--ink-3); letter-spacing: 0.06em;
  text-transform: uppercase; margin-left: auto;
}
.change-card-values, .cc-vals {
  font-family: var(--mono);
  font-size: 12.5px; line-height: 1.4;
}
.change-card-values .old-val, .cc-vals .old-val, .old-val,
.popup-values .old-val {
  color: var(--removed);
  text-decoration: line-through;
  text-decoration-color: oklch(60% 0.13 28 / 0.55);
  text-decoration-thickness: 1.5px;
  margin-right: 6px;
}
.change-card-values .new-val, .cc-vals .new-val, .new-val,
.popup-values .new-val {
  color: var(--added); font-weight: 500;
}
.change-card-values .change-desc, .change-desc {
  color: var(--ink-2); font-size: var(--t-small); font-family: var(--sans);
}
.card-comment-preview {
  font-size: 11.5px; color: var(--ink-2); font-style: italic;
  padding-left: 8px; border-left: 2px solid var(--line);
  margin-top: 4px;
}
.redline-card-reported {
  display: inline-block; margin-left: 4px;
  font-family: var(--mono); font-size: 9.5px;
  color: var(--warning);
  background: var(--warning-tint);
  border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent);
  border-radius: var(--r-pill);
  padding: 1px 6px;
  letter-spacing: 0.04em; text-transform: uppercase;
}

@keyframes approve-trace {
  0% { box-shadow: inset 0 0 0 1px transparent; }
  40% { box-shadow: inset 0 0 0 1px var(--added); }
  100% { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--added) 18%, transparent); }
}
.change-card.approve-flash { animation: approve-trace .4s ease-out; }

/* ── Detail bar ───────────────────────────────────────────────────── */
.detail-bar {
  padding: 8px var(--s-4);
  background: var(--bg-surface);
  border-top: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-2);
  display: flex; align-items: center; gap: var(--s-3);
  min-height: 36px;
  flex-shrink: 0;
}
.detail-bar .detail-type {
  color: var(--ink-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 10.5px;
  font-weight: 500;
}
.detail-bar .detail-highlight { color: var(--warning); font-weight: 500; }

/* ── Annotation overlays + markers ─────────────────────────────────── */
.redline-overlay, .change-overlay {
  position: absolute;
  border: 1px solid oklch(64% 0.13 28);
  background: color-mix(in srgb, oklch(64% 0.13 28) 7%, transparent);
  border-radius: var(--r-2);
  pointer-events: auto; cursor: pointer;
  transition: background var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
}
.redline-overlay:hover, .change-overlay:hover {
  background: color-mix(in srgb, oklch(64% 0.13 28) 12%, transparent);
}
.redline-overlay.status-approved, .change-overlay.status-approved {
  border-color: oklch(60% 0.11 155);
  background: color-mix(in srgb, oklch(60% 0.11 155) 7%, transparent);
}
.redline-overlay.status-approved:hover, .change-overlay.status-approved:hover {
  background: color-mix(in srgb, oklch(60% 0.11 155) 12%, transparent);
}
.redline-overlay.status-change-required, .change-overlay.status-change-required {
  border-color: oklch(76% 0.13 75);
  background: color-mix(in srgb, oklch(76% 0.13 75) 9%, transparent);
}
.redline-overlay.status-change-required:hover, .change-overlay.status-change-required:hover {
  background: color-mix(in srgb, oklch(76% 0.13 75) 14%, transparent);
}
.redline-overlay.status-dismissed, .change-overlay.status-dismissed {
  border-color: var(--ink-4);
  background: color-mix(in srgb, var(--ink-4) 7%, transparent);
  opacity: .55;
}
.redline-overlay.selected, .change-overlay.selected {
  border-width: 1px !important;
  box-shadow:
    0 0 0 1px var(--bg-surface),
    0 0 0 2.5px var(--primary);
  outline: none !important;
  z-index: 10;
}

/* Phantom / placeholder highlight — used on the side that doesn't actually
   carry the change (fallback to the other side's bbox). Communicates "this
   is approximately where the change is" without competing with the real one. */
.redline-overlay.phantom, .change-overlay.phantom {
  border-style: dashed;
  border-width: 1px;
  background: transparent;
  opacity: 0.6;
}
.redline-overlay.phantom:hover, .change-overlay.phantom:hover {
  opacity: 0.85;
  background: color-mix(in srgb, currentColor 5%, transparent);
}

@keyframes marker-pulse {
  0%, 100% {
    box-shadow: 0 0 0 1.5px var(--bg-surface), 0 0 0 3.5px var(--primary),
                0 1px 2px oklch(20% 0.02 250 / 0.10),
                0 2px 6px oklch(20% 0.02 250 / 0.12),
                0 0 0 4px var(--primary-tint-2);
  }
  50% {
    box-shadow: 0 0 0 1.5px var(--bg-surface), 0 0 0 3.5px var(--primary),
                0 1px 2px oklch(20% 0.02 250 / 0.10),
                0 2px 6px oklch(20% 0.02 250 / 0.12),
                0 0 0 10px transparent;
  }
}
.annotation-marker {
  position: absolute;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--mono);
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.01em;
  color: white;
  background: var(--ink);
  border: 1.5px solid var(--bg-surface);
  box-shadow:
    0 0 0 1px oklch(20% 0.02 250 / 0.06),
    0 1px 2px oklch(20% 0.02 250 / 0.10),
    0 2px 6px oklch(20% 0.02 250 / 0.12);
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
  z-index: 5;
}
.annotation-marker:hover {
  transform: scale(1.08);
  box-shadow:
    0 0 0 1px oklch(20% 0.02 250 / 0.08),
    0 2px 4px oklch(20% 0.02 250 / 0.14),
    0 4px 10px oklch(20% 0.02 250 / 0.16);
}
/* Softer, less saturated fills for a friendlier feel */
.annotation-marker.unactioned { background: oklch(64% 0.13 28); }
.annotation-marker.approved { background: oklch(60% 0.11 155); }
.annotation-marker.change-required { background: oklch(76% 0.13 75); color: oklch(28% 0.06 70); }
.annotation-marker.dismissed { background: var(--ink-4); opacity: 0.55; }
.annotation-marker.warning-marker { background: oklch(76% 0.13 75); color: oklch(28% 0.06 70); }

.annotation-marker.selected {
  box-shadow:
    0 0 0 1.5px var(--bg-surface),
    0 0 0 3.5px var(--primary),
    0 1px 2px oklch(20% 0.02 250 / 0.10),
    0 2px 6px oklch(20% 0.02 250 / 0.12);
  z-index: 6;
  animation: marker-pulse 1.4s ease-in-out infinite;
  filter: saturate(0.55) brightness(1.08);
  color: var(--ink-2);
}

/* Leader arrow connecting marker to rect — clean, modern, low-weight */
.annotation-arrow {
  pointer-events: none;
  overflow: visible;
  z-index: 4;
}
.annotation-arrow line, .annotation-arrow path {
  fill: none;
  stroke: oklch(64% 0.13 28);
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 3 3;
  opacity: 0.7;
}
.annotation-arrow.status-approved line, .annotation-arrow.status-approved path { stroke: oklch(60% 0.11 155); }
.annotation-arrow.status-change-required line, .annotation-arrow.status-change-required path { stroke: oklch(76% 0.13 75); }
.annotation-arrow.status-gdt line, .annotation-arrow.status-gdt path { stroke: oklch(62% 0.14 305); }
.annotation-arrow .leader-dot {
  fill: oklch(64% 0.13 28);
  stroke: var(--bg-surface);
  stroke-width: 1;
  opacity: 0.9;
  stroke-dasharray: none;
}
.annotation-arrow.status-approved .leader-dot { fill: oklch(60% 0.11 155); }
.annotation-arrow.status-change-required .leader-dot { fill: oklch(76% 0.13 75); }
.annotation-arrow.status-gdt .leader-dot { fill: oklch(62% 0.14 305); }
.annotation-marker.hidden, .annotation-arrow.hidden { display: none !important; }

/* Obstructed marker: another annotation is being focused and this number is
   covering part of it. Only the number fades — the underlying highlight stays. */
.annotation-marker.obstructed {
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease-out;
}

.note-link-marker {
  position: absolute;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--primary); color: white;
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; border: 1.5px solid var(--bg-surface);
  box-shadow: 0 1px 3px oklch(20% 0.02 250 / 0.3);
  z-index: 4; pointer-events: auto;
  transition: transform var(--t-fast) var(--ease-out);
}
.note-link-marker:hover {
  transform: scale(1.2);
  box-shadow: 0 0 0 3px var(--primary-tint);
}

@keyframes pulse-note-ref {
  0%, 100% { box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 60%, transparent), 0 0 8px 3px var(--primary-tint); }
  50% { box-shadow: 0 0 0 4px var(--primary), 0 0 14px 5px color-mix(in srgb, var(--primary) 30%, transparent); }
}
.note-ref-highlight {
  position: absolute;
  background: var(--primary-tint);
  border: 2px solid var(--primary);
  border-radius: var(--r-1);
  animation: pulse-note-ref 1s ease-in-out infinite;
  pointer-events: none; z-index: 20;
}

/* ── Annotation popover ───────────────────────────────────────────── */
.annotation-popup {
  position: absolute;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--r-4);
  box-shadow: var(--shadow-pop);
  padding: var(--s-4);
  width: 300px;
  z-index: 100;
  font-size: var(--t-body);
  color: var(--ink);
  pointer-events: auto;
  animation: pop-in var(--t-fast) var(--ease-out);
}
@keyframes pop-in {
  from { opacity: 0; transform: translateY(4px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.popup-drag-handle {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 10px;
  margin: -4px 0 4px;
  cursor: grab;
  color: var(--ink-4);
  border-radius: var(--r-1);
  transition: color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out);
}
.popup-drag-handle:hover { color: var(--ink-3); background: var(--bg-hover); }
.popup-drag-handle::before {
  content: ""; width: 32px; height: 3px;
  background: currentColor; border-radius: var(--r-pill);
  opacity: 0.5;
}
.annotation-popup.dragging { cursor: grabbing; user-select: none; }
.annotation-popup.dragging .popup-drag-handle { cursor: grabbing; color: var(--primary); }
.annotation-popup.dragging .popup-drag-handle::before { opacity: 0.9; }
body.popup-dragging { cursor: grabbing; }
body.popup-dragging * { cursor: grabbing !important; }

.popup-header {
  display: flex; align-items: center; gap: 6px;
  padding-bottom: var(--s-3);
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: var(--s-3);
}
.popup-zone {
  font-family: var(--mono); font-size: 10.5px;
  color: var(--ink-3); letter-spacing: 0.06em;
  text-transform: uppercase;
}
.popup-warning-badge {
  font-family: var(--mono); font-size: 10.5px;
  color: var(--warning); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.popup-close {
  margin-left: auto;
  width: 22px; height: 22px;
  border-radius: var(--r-2);
  border: none;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1;
}
.popup-close:hover { background: var(--bg-hover); color: var(--ink); }

.popup-values {
  font-family: var(--mono);
  font-size: 12.5px;
  margin-bottom: var(--s-3);
  line-height: 1.45;
}
.popup-desc { color: var(--ink-2); font-size: 12px; font-family: var(--sans); }

.popup-comment {
  width: 100%; min-height: 60px;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  color: var(--ink);
  font-size: var(--t-body); padding: 9px 12px;
  font-family: var(--sans);
  resize: vertical; margin-bottom: var(--s-3);
  transition: all var(--t-fast) var(--ease-out);
}
.popup-comment:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}
.popup-comment::placeholder { color: var(--ink-4); }
.popup-comment-locked {
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: var(--r-2); padding: 8px 10px;
  font-size: 12px; color: var(--ink);
  margin-bottom: 6px;
  white-space: pre-wrap; word-break: break-word;
  font-family: var(--sans);
}

.popup-approve-section {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
}
.popup-approve-section button {
  padding: 5px 10px; font-size: var(--t-small);
  border-radius: var(--r-2); border: none; cursor: pointer;
  font-family: inherit; font-weight: 500;
  display: inline-flex; align-items: center; gap: 5px;
  transition: all var(--t-fast) var(--ease-out);
}
.popup-approve-btn { background: var(--primary); color: white; }
.popup-approve-btn:hover { background: var(--primary-2); }
.popup-change-req-btn { background: var(--warning-tint); color: var(--warning); }
.popup-change-req-btn:hover { background: var(--warning); color: white; }
.popup-dismiss-btn {
  background: transparent; color: var(--ink-2);
  border: 1px solid var(--line) !important;
}
.popup-dismiss-btn:hover { background: var(--bg-hover); color: var(--ink); }
.popup-submit-btn { background: var(--primary); color: white; margin-bottom: var(--s-2); }
.popup-edit-btn {
  background: transparent; color: var(--ink-2);
  border: 1px solid var(--line);
  padding: 4px 10px; border-radius: var(--r-2);
  font-size: 11.5px; font-weight: 500; cursor: pointer;
  margin-bottom: var(--s-2); font-family: inherit;
}
.popup-unapprove-btn {
  background: transparent; color: var(--ink-3);
  border: 1px solid var(--line);
  padding: 4px 8px; border-radius: var(--r-2);
  font-size: 11px; cursor: pointer; font-family: inherit;
}
.popup-approved-badge { color: var(--added); font-weight: 500; font-size: 12px; }
.popup-change-req-badge { color: var(--warning); font-weight: 500; font-size: 12px; }
.popup-approved-date { color: var(--ink-4); font-family: var(--mono); font-size: 10.5px; }

/* ── Modal ────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: oklch(15% 0.02 255 / 0.55);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fade-in var(--t-base) var(--ease-out);
}
.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--r-5);
  padding: var(--s-7);
  width: 440px;
  max-width: calc(100vw - 32px);
  text-align: center;
  box-shadow: var(--shadow-pop);
  animation: pop-in var(--t-base) var(--ease-out);
}
.modal-card h3 {
  font-size: var(--t-h2); font-weight: 500;
  letter-spacing: -0.015em; margin-bottom: var(--s-2);
  color: var(--ink);
}
.modal-card p { color: var(--ink-2); font-size: var(--t-body); margin-bottom: var(--s-5); line-height: 1.55; }
.modal-buttons { display: flex; gap: var(--s-2); justify-content: center; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ── Login overlay ────────────────────────────────────────────────── */
.login-overlay {
  position: fixed; inset: 0;
  background: var(--bg-page);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000;
}
.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--r-5);
  padding: var(--s-8) var(--s-7);
  width: 380px;
  max-width: calc(100vw - 32px);
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.login-card h2 {
  font-size: 24px; font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--ink); margin-bottom: 6px;
}
.login-card h2 em {
  font-family: var(--serif); font-style: italic; color: var(--primary);
}
.login-card p {
  color: var(--ink-3); font-size: 12px;
  margin-bottom: var(--s-5);
  font-family: var(--mono);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.login-card input[type="password"] {
  width: 100%; padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  color: var(--ink); font-size: var(--t-body);
  margin-bottom: var(--s-3);
  font-family: var(--sans);
  transition: all var(--t-fast) var(--ease-out);
}
.login-card input[type="password"]:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}
.login-card .btn-primary { width: 100%; justify-content: center; }
.login-error {
  color: var(--removed); font-size: 11.5px;
  font-family: var(--mono); letter-spacing: 0.04em;
  min-height: 1.2em; margin-top: 8px;
}

/* ── Scrollbars ───────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 5px; border: 2px solid var(--bg-page); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }

/* ── Feedback widget ──────────────────────────────────────────────── */
.fb-section {
  margin-top: var(--s-3); padding-top: var(--s-3);
  border-top: 1px solid var(--line-soft);
}
.fb-header { display: flex; justify-content: flex-start; }
.fb-report-btn {
  background: var(--warning-tint);
  color: var(--warning);
  border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent);
  padding: 4px 10px; border-radius: var(--r-2);
  font-size: 11.5px; cursor: pointer;
  font-family: inherit; font-weight: 500;
}
.fb-report-btn:hover { background: color-mix(in srgb, var(--warning) 22%, transparent); }
.fb-form { margin-top: var(--s-3); display: flex; flex-direction: column; gap: 6px; }
.fb-label {
  font-family: var(--mono); font-size: 10px;
  color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.fb-select, .fb-textarea {
  width: 100%; box-sizing: border-box;
  background: var(--bg-surface);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 6px 8px; border-radius: var(--r-2);
  font-family: var(--sans); font-size: 12px;
}
.fb-textarea { min-height: 60px; resize: vertical; }
.fb-paste-zone {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-3);
  padding: 12px; text-align: center;
  color: var(--ink-3); font-size: 11.5px;
  background: var(--bg-sunk); cursor: pointer;
}
.fb-paste-zone.attached { border-style: solid; border-color: color-mix(in srgb, var(--added) 40%, transparent); padding: 8px; text-align: left; }
.fb-paste-thumb { min-height: 24px; }
.fb-thumb-img { max-width: 100%; max-height: 90px; border-radius: var(--r-2); display: block; }
.fb-paste-hint { font-size: 10px; color: var(--ink-3); margin-top: 4px; font-family: var(--mono); }
.fb-paste-hint .kbd {
  background: var(--bg-surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0 4px; font-family: var(--mono); font-size: 10px;
}
.fb-btn-row { display: flex; gap: 6px; justify-content: flex-end; margin-top: 4px; }
.fb-cancel-btn, .fb-submit-btn {
  padding: 5px 10px; border-radius: var(--r-2);
  font-size: 11.5px; cursor: pointer;
  border: 1px solid var(--line); font-family: inherit;
}
.fb-cancel-btn { background: transparent; color: var(--ink-2); }
.fb-submit-btn {
  background: var(--primary); color: white; font-weight: 500;
  border-color: transparent;
}
.fb-submit-btn:disabled { opacity: 0.6; cursor: wait; }
.fb-err { color: var(--removed); font-size: 11px; font-family: var(--mono); }

/* Run-level feedback floating panel */
.fb-runlevel-panel {
  position: fixed; top: 80px; right: 24px; width: 380px;
  background: var(--bg-surface);
  border: 1px solid color-mix(in srgb, var(--warning) 30%, var(--line));
  border-radius: var(--r-4);
  z-index: 200; box-shadow: var(--shadow-pop);
}
.fb-runlevel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px var(--s-3);
  background: var(--warning-tint);
  border-bottom: 1px solid color-mix(in srgb, var(--warning) 30%, transparent);
  color: var(--warning); font-weight: 500; font-size: 12px;
  font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.06em;
  border-radius: var(--r-4) var(--r-4) 0 0;
}
.fb-runlevel-close {
  background: transparent; border: none;
  color: var(--warning); font-size: 16px; cursor: pointer;
  padding: 0 4px; line-height: 1;
}
.fb-runlevel-body { padding: var(--s-3); }

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .toolbar { flex-wrap: wrap; gap: 8px; }
  .redline-sidebar { width: 280px; }
  .filterbar { flex-wrap: wrap; }
  .spark { margin-left: 0; }
}
@media (max-width: 1024px) {
  .file-slots { grid-template-columns: 1fr; gap: 12px; }
  .slot-arrow { display: none; }
  .toolbar { padding: 8px 12px; }
  .redline-sidebar { width: 240px; }
}
