/* ════════════════════════════════════════════════════════════════════════
   SPEED FILE MANAGER · Documents view (native port into Altitude)

   This stylesheet is loaded once at app boot. The view itself is hidden
   by default (display:none) — showStage('docs') sets display:flex, which
   is the only thing that activates the styling.

   All selectors below are scoped under #docs-view-root so the document viewer
   styles cannot leak into Altitude's pipe/sum/admin views. Likewise,
   Altitude styles do not leak in — the document viewer CSS variables
   (--bg, --surface, --text, etc.) are scoped to #docs-view-root and
   override anything inherited.

   Theme is driven by Altitude's own html[data-theme="..."] attribute,
   so toggling Altitude's theme automatically retheme the docs view too.
   ════════════════════════════════════════════════════════════════════════ */

/* ──── OVERLAY POSITIONING ────
   When showStage('docs') runs, body gets the .docs-fullwidth class and
   the root container's display flips to flex. The container is a
   fixed-position full-viewport overlay above all Altitude chrome. */
#docs-view-root {
  display: none;             /* shown by JS via .docs-fullwidth on body */
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  /* Reset host page inheritance — we set our own font/color/bg via the
     namespaced :root rules below. */
  font-family: 'Inter Variable', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;          /* document viewer expects no scroll on its container */
}
body.docs-fullwidth #docs-view-root {
  display: grid;             /* document viewer .app uses display:grid layout */
}
body.docs-fullwidth {
  /* Hide Altitude's chrome behind the overlay — strictly belt-and-braces
     since z-index 9999 already covers everything. Also prevents background
     scroll while the docs view is active. */
  overflow: hidden;
}

/* ════════════════════════════════════════════════════════════════════════
   Speed File Manager (Documents view) — namespaced CSS
   Auto-generated. All selectors scoped under #docs-view-root so the
   document viewer styles cannot leak into the rest of Altitude.
   ════════════════════════════════════════════════════════════════════════ */

#docs-view-root {
  /* ════════════════════════════════════════════════════════════════════
     Carbon dark theme (v8.6.46). Documents view surfaces aligned to
     the rest of the app. Tag colors (red/blue/green/yellow/etc) are
     CATEGORICAL and intentionally identical across themes — they
     identify document type, not visual style. Only the chrome
     (sidebars, surfaces, text) is themed.
     ════════════════════════════════════════════════════════════════════ */
  /* SIGNAL (soft cool blue, restrained for Carbon) */
  --signal: #9ec4ff;
  --signal-hover: #c0d8ff;
  --signal-dim: #6f99d4;
  --signal-pale: rgba(158, 196, 255, 0.10);
  --signal-tint: rgba(158, 196, 255, 0.18);
  --signal-ink: #c6dcff;
  --amber: #66d8ff;

  /* STATUS */
  --success: #5ddd9f;
  --warning: #ffcf40;
  --danger: #ff7a7a;
  --info: #9ec4ff;

  /* TAG COLORS — identical in both themes (categorical, not visual style) */
  --tag-red: #DC2626;
  --tag-maroon: #7F1D1D;
  --tag-blue: #2563EB;
  --tag-green: #16A34A;
  --tag-yellow: #EAB308;
  --tag-purple: #7C3AED;
  --tag-orange: #EA580C;
  --tag-pink: #F472B6;
  --tag-black: #6B7280;
  --tag-teal: #0D9488;       /* Quotes & Indications (manual) */
  --tag-magenta: #DB2777;    /* Cancellations (manual) */
  --tag-coral: #FB7185;      /* Subjectivity (manual) */

  /* RGB variants for rgba() — used for glow + gradient tints */
  --tag-red-rgb: 220, 38, 38;
  --tag-maroon-rgb: 127, 29, 29;
  --tag-blue-rgb: 37, 99, 235;
  --tag-green-rgb: 22, 163, 74;
  --tag-yellow-rgb: 234, 179, 8;
  --tag-purple-rgb: 124, 58, 237;
  --tag-orange-rgb: 234, 88, 12;
  --tag-pink-rgb: 244, 114, 182;
  --tag-black-rgb: 107, 114, 128;
  --tag-teal-rgb: 13, 148, 136;
  --tag-magenta-rgb: 219, 39, 119;
  --tag-coral-rgb: 251, 113, 133;

  /* SURFACES — Carbon (true neutral, no blue) */
  --bg: #0a0a0c;
  --surface: #141417;
  --surface-alt: #1a1a1e;
  --surface-raised: #202024;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.13);

  /* TYPE */
  --text: #fafafa;
  --text-secondary: #a0a0a8;
  --text-tertiary: #62646c;

  /* CHROME — deeper background for sidebars to create elevation hierarchy */
  --sidebar-bg: #07070a;
  --sidebar-text: #888890;
  --topbar-bg: rgba(20, 20, 23, 0.85);
  --backdrop-bg: rgba(10, 10, 12, 0.82);

  /* FONTS */
  --font-display: 'Inter Variable', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-sans: 'Inter Variable', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Geist Mono', 'SF Mono', Menlo, monospace;

  /* GEOMETRY */
  --radius: 6px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.42);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.36), 0 1px 3px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.52);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.72);

  --topbar-h: 52px;
  --docs-panel-w: 300px;
  --tags-panel-w: 280px;
}

html[data-theme="light"] #docs-view-root {
  /* Carbon-era v8.6.46: signal must be redefined here so it doesn't
     inherit the soft blue from the Carbon dark base. */
  --signal: #0570DE;
  --signal-hover: #3B82F6;
  --signal-dim: #0469C5;
  --signal-ink: #0469C5;
  --signal-pale: rgba(5, 112, 222, 0.22);
  --signal-tint: rgba(5, 112, 222, 0.35);
  --amber: #00D4FF;
  --success: #2E8F48;
  --warning: #B8700E;
  --danger: #C13737;
  --info: #2563EB;
  /* Tag colors intentionally NOT overridden here — they stay the same across themes
     so tagged docs keep the same visual identity when the user toggles modes. */
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-alt: #EBF0F5;
  --surface-raised: #DDE5EE;
  --border: #E3E8EE;
  --border-strong: #C0CCDA;
  --text: #0A2540;
  --text-secondary: #708099;
  --text-tertiary: #697386;
  --sidebar-bg: #FFFFFF;
  --sidebar-text: #708099;
  --topbar-bg: rgba(255, 255, 255, 0.85);
  --backdrop-bg: rgba(255, 255, 255, 0.72);
  --shadow-sm: 0 1px 2px rgba(10, 37, 64, 0.04);
  --shadow: 0 2px 8px rgba(10, 37, 64, 0.06), 0 1px 3px rgba(10, 37, 64, 0.08);
  --shadow-lg: 0 8px 24px rgba(10, 37, 64, 0.10);
  --shadow-xl: 0 20px 60px rgba(10, 37, 64, 0.18);
}

#docs-view-root * { box-sizing: border-box; margin: 0; padding: 0; }

#docs-view-root, #docs-view-root {
  height: 100%;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#docs-view-root button { font-family: inherit; }

#docs-view-root input, #docs-view-root textarea { font-family: inherit; }

#docs-view-root .svg-sm { width: 13px; height: 13px; }

#docs-view-root .svg-xs { width: 11px; height: 11px; }

#docs-view-root *, #docs-view-root *::before, #docs-view-root *::after {
  transition-property: background-color, border-color, color, fill, stroke, box-shadow, opacity;
  transition-duration: 160ms;
  transition-timing-function: ease;
}

html.no-transitions #docs-view-root *, html.no-transitions #docs-view-root *::before, html.no-transitions #docs-view-root *::after {
  transition-duration: 0ms !important;
}

#docs-view-root ::-webkit-scrollbar { width: 10px; height: 10px; }

#docs-view-root ::-webkit-scrollbar-track { background: transparent; }

#docs-view-root ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; border: 2px solid var(--bg); }

#docs-view-root ::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

#docs-view-root .app {
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr;
  height: 100vh;
}

#docs-view-root .topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 50;
}

#docs-view-root .topbar-left, #docs-view-root .topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

#docs-view-root .topbar-center { flex: 1; display: flex; justify-content: center; align-items: center; gap: 10px; min-width: 0; }

#docs-view-root .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); cursor: pointer; }

#docs-view-root .brand-mark {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: var(--signal);
  color: #0A2540;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

#docs-view-root .brand-text { display: flex; flex-direction: column; line-height: 1; }

#docs-view-root .brand-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  font-style: italic;
  letter-spacing: -0.01em;
  color: var(--text);
}

#docs-view-root .brand-sub {
  font-size: 9.5px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-top: 2px;
}

#docs-view-root .tools-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 10px;
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  flex-shrink: 0;
  height: 32px;
}

#docs-view-root .tools-btn:hover {
  background: var(--surface-raised);
  border-color: var(--border-strong);
  box-shadow: 0 0 0 1px var(--border-strong);
}

#docs-view-root .tools-btn.open {
  background: var(--surface-raised);
  border-color: var(--signal);
  box-shadow: 0 0 0 1px var(--signal-tint);
}

#docs-view-root .tools-btn-icon {
  width: 14px; height: 14px;
  color: var(--signal);
  flex-shrink: 0;
}

#docs-view-root .tools-btn-label { line-height: 1; }

#docs-view-root .tools-btn-chevron {
  width: 10px; height: 10px;
  opacity: 0.55;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

#docs-view-root .tools-btn.open .tools-btn-chevron { transform: rotate(180deg); }

#docs-view-root .tools-btn-active {
  display: none;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  box-shadow: 0 0 8px 0 currentColor;
}

#docs-view-root .tools-btn.tool-active .tools-btn-active { display: inline-block; }

#docs-view-root .topbar-category {
  margin-left: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  opacity: 0.7;
  white-space: nowrap;
  flex-shrink: 0;
}

#docs-view-root .topbar-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  max-width: 340px;
  min-width: 160px;
  height: 32px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

#docs-view-root .topbar-search:focus-within {
  border-color: var(--signal);
  box-shadow: 0 0 0 1px var(--signal-tint);
  background: var(--surface);
}

#docs-view-root .topbar-search .search-icon {
  width: 13px; height: 13px;
  margin-left: 10px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

#docs-view-root .topbar-search .search-input {
  flex: 1;
  height: 100%;
  background: transparent;
  border: none;
  padding: 0 8px;
  color: var(--text);
  font-size: 12.5px;
  outline: none;
  min-width: 0;
}

#docs-view-root .topbar-search .search-input::placeholder {
  color: var(--text-tertiary);
  opacity: 0.7;
}

#docs-view-root .topbar-search .search-clear {
  position: static;
  transform: none;
  width: 20px; height: 20px;
  margin-right: 6px;
  margin-left: 2px;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  flex-shrink: 0;
}

#docs-view-root .topbar-search .search-clear:hover {
  background: var(--border);
  color: var(--text);
}

#docs-view-root .topbar-search .search-clear.visible { display: flex; }

#docs-view-root .topbar-search .search-clear svg { width: 11px; height: 11px; }

#docs-view-root .topbar-search .search-counter {
  display: none;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--signal);
  padding: 2px 7px;
  margin-right: 2px;
  border-radius: 3px;
  background: var(--signal-tint);
  letter-spacing: 0.02em;
  flex-shrink: 0;
  white-space: nowrap;
}

#docs-view-root .topbar-search .search-counter.visible { display: inline-block; }

#docs-view-root .topbar-search .search-counter.no-match {
  color: #F87171;
  background: rgba(248, 113, 113, 0.12);
}

#docs-view-root .topbar-search .search-nav-btn {
  width: 22px; height: 22px;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  flex-shrink: 0;
  margin-right: 1px;
  transition: background 0.12s ease, color 0.12s ease;
}

#docs-view-root .topbar-search .search-nav-btn svg { width: 11px; height: 11px; }

#docs-view-root .topbar-search .search-nav-btn:hover:not(:disabled) {
  background: var(--border);
  color: var(--text);
}

#docs-view-root .topbar-search .search-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

#docs-view-root .topbar-search.has-results .search-nav-btn { display: flex; }

#docs-view-root mark.search-hl {
  background: #FDE047;
  color: #713F12;
  padding: 0 1px;
  border-radius: 2px;
  font-weight: 600;
  box-shadow: 0 0 0 1px rgba(234, 179, 8, 0.4);
}

html[data-theme="light"] #docs-view-root mark.search-hl {
  background: #FEF08A;
  color: #713F12;
}

#docs-view-root .doc-search-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #EAB308;
  color: #1A1203;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 3px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  z-index: 4;
  box-shadow: 0 2px 8px rgba(234, 179, 8, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.15);
  pointer-events: none;
}

#docs-view-root .doc-item.has-search-match {
  box-shadow: 0 0 0 1px rgba(234, 179, 8, 0.45), 0 0 14px -2px rgba(234, 179, 8, 0.35);
}

#docs-view-root .doc-item.search-focused {
  border-color: #EAB308 !important;
  box-shadow: 0 0 0 2px #EAB308, 0 0 24px 0 rgba(234, 179, 8, 0.7) !important;
  animation: search-pulse 1.2s ease-in-out;
}

@keyframes search-pulse {
  0%   { box-shadow: 0 0 0 2px #EAB308, 0 0 0 0 rgba(234, 179, 8, 0.9); }
  50%  { box-shadow: 0 0 0 2px #EAB308, 0 0 30px 4px rgba(234, 179, 8, 0.7); }
  100% { box-shadow: 0 0 0 2px #EAB308, 0 0 24px 0 rgba(234, 179, 8, 0.5); }
}

#docs-view-root .topbar-utils {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

#docs-view-root .topbar-utils .view-toggle {
  display: flex;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  height: 32px;
}

#docs-view-root .topbar-utils .view-toggle button {
  width: 28px; height: 100%;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.12s ease, color 0.12s ease;
}

#docs-view-root .topbar-utils .view-toggle button:hover {
  background: var(--surface-raised);
  color: var(--text-secondary);
}

#docs-view-root .topbar-utils .view-toggle button.active {
  background: var(--signal);
  color: var(--bg);
}

#docs-view-root .topbar-utils .view-toggle button svg { width: 13px; height: 13px; }

#docs-view-root .topbar-utils .sort-wrap {
  position: relative;
}

#docs-view-root .topbar-utils .sort-btn {
  width: 32px; height: 32px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

#docs-view-root .topbar-utils .sort-btn:hover {
  background: var(--surface-raised);
  color: var(--text);
  border-color: var(--border-strong);
}

#docs-view-root .topbar-utils .sort-btn svg { width: 13px; height: 13px; }

#docs-view-root .topbar-utils .sort-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  min-width: 150px;
  padding: 4px;
  z-index: 200;
  display: none;
}

#docs-view-root .topbar-utils .sort-menu.visible { display: block; }

#docs-view-root .topbar-utils .sort-option {
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
  font-family: var(--font-body);
}

#docs-view-root .topbar-utils .sort-option:hover {
  background: var(--surface-alt);
  color: var(--text);
}

#docs-view-root .topbar-utils .sort-option.active {
  background: var(--signal-tint);
  color: var(--signal);
  font-weight: 600;
}

#docs-view-root .topbar-utils .btn-icon {
  width: 32px; height: 32px;
}

@media (max-width: 1200px) {
  #docs-view-root .topbar-category { display: none; }
}

@media (max-width: 1000px) {
  #docs-view-root .topbar-utils .view-toggle { display: none; }
}

#docs-view-root .btn {
  padding: 7px 14px;
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#docs-view-root .btn:hover { background: var(--surface-raised); border-color: var(--border-strong); }

#docs-view-root .btn-primary { background: var(--signal); color: #0A2540; border-color: var(--signal); font-weight: 600; }

#docs-view-root .btn-primary:hover { background: var(--signal-hover); border-color: var(--signal-hover); }

html[data-theme="light"] #docs-view-root .btn-primary { color: #0A2540; }

#docs-view-root .btn-icon {
  width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
}

#docs-view-root .btn-icon:hover { background: var(--surface-alt); color: var(--text); border-color: var(--border); }

#docs-view-root .btn-icon svg { width: 16px; height: 16px; }

#docs-view-root .workspace {
  display: grid;
  grid-template-columns: var(--docs-panel-w) 4px 1fr 4px var(--tags-panel-w);
  overflow: hidden;
  background: var(--bg);
}

#docs-view-root .resizer {
  background: transparent;
  cursor: col-resize;
  position: relative;
  z-index: 5;
}

#docs-view-root .resizer::after {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 2px; height: 40px;
  background: var(--border);
  border-radius: 1px;
  transition: background 0.15s, height 0.15s;
}

#docs-view-root .resizer:hover::after, #docs-view-root .resizer.active::after {
  background: var(--signal);
  height: 60px;
}

#docs-view-root .docs-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  overflow: hidden;
  min-width: 0;
}

#docs-view-root .docs-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

#docs-view-root .docs-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

#docs-view-root .docs-header-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  font-weight: 700;
}

#docs-view-root .docs-count-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--signal-ink);
  background: var(--signal-pale);
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--signal-tint);
  font-weight: 600;
}

#docs-view-root .docs-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

#docs-view-root .docs-actions .btn-icon { width: 28px; height: 28px; }

#docs-view-root .view-toggle {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
  gap: 2px;
}

#docs-view-root .view-toggle button {
  width: 26px; height: 24px;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
}

#docs-view-root .view-toggle button.active { background: var(--signal); color: #0A2540; }

#docs-view-root .view-toggle button svg { width: 13px; height: 13px; }

#docs-view-root .search-sort {
  display: flex;
  gap: 6px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}

#docs-view-root .search-wrap { flex: 1; position: relative; }

#docs-view-root .search-wrap svg.search-icon {
  position: absolute;
  left: 9px; top: 50%;
  transform: translateY(-50%);
  width: 13px; height: 13px;
  color: var(--text-tertiary);
  pointer-events: none;
}

#docs-view-root .search-input {
  width: 100%;
  padding: 6px 28px 6px 28px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  outline: none;
}

#docs-view-root .search-input:focus { border-color: var(--signal); box-shadow: 0 0 0 3px var(--signal-pale); }

#docs-view-root .search-input::placeholder { color: var(--text-tertiary); }

#docs-view-root .search-clear {
  position: absolute;
  right: 4px; top: 50%;
  transform: translateY(-50%);
  width: 22px; height: 22px;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: 4px;
  display: none;
  align-items: center; justify-content: center;
}

#docs-view-root .search-clear.visible { display: inline-flex; }

#docs-view-root .search-clear:hover { background: var(--surface-alt); color: var(--text); }

#docs-view-root .search-clear svg { width: 11px; height: 11px; }

#docs-view-root .sort-wrap { position: relative; }

#docs-view-root .sort-btn {
  width: 32px; height: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

#docs-view-root .sort-btn:hover { color: var(--text); border-color: var(--border-strong); }

#docs-view-root .sort-btn svg { width: 13px; height: 13px; }

#docs-view-root .sort-menu {
  position: absolute;
  top: calc(100% + 4px); right: 0;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  z-index: 100;
  display: none;
}

#docs-view-root .sort-menu.visible { display: block; }

#docs-view-root .sort-option {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 6px 10px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
  text-align: left;
}

#docs-view-root .sort-option:hover { background: var(--surface-alt); }

#docs-view-root .sort-option.active { color: var(--signal-ink); background: var(--signal-pale); }

#docs-view-root .bulk-bar {
  background: var(--signal);
  color: #0A2540;
  padding: 7px 12px;
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
}

#docs-view-root .bulk-bar.visible { display: flex; }

#docs-view-root .bulk-count { flex-shrink: 0; }

#docs-view-root .bulk-actions { display: flex; gap: 3px; margin-left: auto; }

#docs-view-root .bulk-btn {
  width: 26px; height: 26px;
  background: rgba(10, 37, 64, 0.12);
  border: none;
  color: #0A2540;
  border-radius: 4px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

#docs-view-root .bulk-btn:hover { background: rgba(10, 37, 64, 0.22); }

#docs-view-root .bulk-btn.danger:hover { background: var(--danger); color: white; }

#docs-view-root .bulk-btn svg { width: 12px; height: 12px; }

#docs-view-root .mini-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
}

#docs-view-root .mini-dot.red { background: var(--tag-red); }

#docs-view-root .mini-dot.maroon { background: var(--tag-maroon); }

#docs-view-root .mini-dot.blue { background: var(--tag-blue); }

#docs-view-root .mini-dot.green { background: var(--tag-green); }

#docs-view-root .mini-dot.yellow { background: var(--tag-yellow); }

#docs-view-root .mini-dot.purple { background: var(--tag-purple); }

#docs-view-root .mini-dot.orange { background: var(--tag-orange); }

#docs-view-root .mini-dot.pink { background: var(--tag-pink); }

#docs-view-root .mini-dot.black { background: var(--tag-black); border: 1px solid var(--border-strong); }

#docs-view-root .mini-dot.teal { background: var(--tag-teal); }

#docs-view-root .mini-dot.magenta { background: var(--tag-magenta); }

#docs-view-root .mini-dot.coral { background: var(--tag-coral); }

#docs-view-root .docs-list {
  overflow-y: auto;
  padding: 8px;
  /* v8.7.01: JS owns page-card navigation. Disable browser anchoring and
     smooth-scroll behavior inside the viewer so tagged-page clicks land with
     the selected card aligned to the top instead of settling between pages. */
  overflow-anchor: none;
  scroll-padding-top: 0;
  scroll-behavior: auto;
}

#docs-view-root .docs-empty {
  /* v8.6.48: dressed as a compact spotlight card. Same recipe as the
     .verdict-card / .spotlight-card system in app.css — diagonal
     pale-signal gradient, tinted border, italic display title — just
     tuned for the narrow sidebar (~280px) instead of full width. */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
  margin: 10px;
  text-align: center;
  color: var(--text-tertiary);
  background: linear-gradient(135deg, var(--signal-pale) 0%, var(--surface-alt) 80%);
  border: 1px solid var(--signal-tint);
  border-radius: var(--radius);
}

#docs-view-root .docs-empty svg {
  width: 36px; height: 36px;
  color: var(--signal-dim);
  opacity: 0.7;
  margin-bottom: 12px;
}

#docs-view-root .docs-empty-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-style: italic;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--signal-ink);
  margin-bottom: 5px;
}

#docs-view-root .docs-empty-sub {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

#docs-view-root .doc-item {
  display: block;
  position: relative;
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
  scroll-margin-top: 0;
  overflow-anchor: none;
}

#docs-view-root .doc-item:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

#docs-view-root .doc-item.selected {
  border-color: var(--signal);
  box-shadow: 0 0 0 2px var(--signal-tint);
}

#docs-view-root .doc-item.has-color { border-left-width: 3px; }

#docs-view-root .doc-color-bar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: transparent;
  z-index: 2;
  box-shadow: 0 0 8px 0 currentColor;
}

#docs-view-root .doc-item.has-color.tag-red { color: var(--tag-red);    }

#docs-view-root .doc-item.has-color.tag-maroon { color: var(--tag-maroon); }

#docs-view-root .doc-item.has-color.tag-blue { color: var(--tag-blue);   }

#docs-view-root .doc-item.has-color.tag-green { color: var(--tag-green);  }

#docs-view-root .doc-item.has-color.tag-yellow { color: var(--tag-yellow); }

#docs-view-root .doc-item.has-color.tag-purple { color: var(--tag-purple); }

#docs-view-root .doc-item.has-color.tag-orange { color: var(--tag-orange); }

#docs-view-root .doc-item.has-color.tag-pink { color: var(--tag-pink);   }

#docs-view-root .doc-item.has-color.tag-black { color: var(--tag-black);  }

#docs-view-root .doc-item.has-color.tag-teal { color: var(--tag-teal);    }

#docs-view-root .doc-item.has-color.tag-magenta { color: var(--tag-magenta); }

#docs-view-root .doc-item.has-color.tag-coral { color: var(--tag-coral);  }

#docs-view-root .doc-item.has-color .doc-color-bar { background: currentColor; }

#docs-view-root .doc-item.has-color .doc-name, #docs-view-root .doc-item.has-color .doc-date { color: var(--text); }

#docs-view-root .doc-item.has-color:hover {
  box-shadow: 0 0 12px -2px currentColor;
}

#docs-view-root .doc-thumb {
  aspect-ratio: 8.5 / 11;
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  position: relative;
  border-bottom: 1px solid var(--border);
}

#docs-view-root .doc-thumb img {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;
  object-fit: contain;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  background: white;
  border-radius: 2px;
}

#docs-view-root .doc-thumb-content {
  width: 100%; height: 100%;
  background: white;
  color: #333;
  padding: 10px;
  font-size: 9px;
  line-height: 1.3;
  overflow: hidden;
  text-align: left;
  border-radius: 2px;
}

#docs-view-root .doc-thumb-native {
  --nc: 22, 163, 74;  /* default green (excel) */
  --nc-hex: #16A34A;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 18px 14px;
  background: linear-gradient(160deg, rgba(var(--nc), 0.08) 0%, rgba(var(--nc), 0.02) 55%, var(--surface) 100%), var(--surface);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
  transition: background 0.15s ease;
}

#docs-view-root .doc-thumb-native-excel { --nc: 22, 163, 74;   --nc-hex: #16A34A; }

#docs-view-root .doc-thumb-native-csv { --nc: 22, 163, 74;   --nc-hex: #16A34A; }

#docs-view-root .doc-thumb-native-email { --nc: 14, 165, 233;  --nc-hex: #0EA5E9; }

#docs-view-root .doc-thumb-native-powerpoint { --nc: 234, 88, 12;   --nc-hex: #EA580C; }

#docs-view-root .doc-thumb-native-archive { --nc: 161, 98, 7;    --nc-hex: #A16207; }

#docs-view-root .doc-thumb-native-native { --nc: 100, 116, 139; --nc-hex: #64748B; }

#docs-view-root .doc-thumb-native::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--nc-hex);
  opacity: 0.9;
}

#docs-view-root .doc-item:hover .doc-thumb-native {
  background: linear-gradient(160deg, rgba(var(--nc), 0.14) 0%, rgba(var(--nc), 0.04) 55%, var(--surface) 100%), var(--surface);
}

#docs-view-root .native-card-icon {
  width: 64px; height: 64px;
  color: var(--nc-hex);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 4px 12px rgba(var(--nc), 0.35));
}

#docs-view-root .native-card-icon svg { width: 100%; height: 100%; }

#docs-view-root .native-card-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  max-width: 100%;
}

#docs-view-root .native-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
  word-break: break-word;
  max-width: 100%;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

#docs-view-root .native-card-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
}

#docs-view-root .native-card-action {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 5px 10px;
  background: rgba(var(--nc), 0.12);
  border: 1px solid rgba(var(--nc), 0.35);
  border-radius: 4px;
  color: var(--nc-hex);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background 0.15s ease, border-color 0.15s ease;
}

#docs-view-root .doc-item:hover .native-card-action {
  background: rgba(var(--nc), 0.2);
  border-color: rgba(var(--nc), 0.55);
}

#docs-view-root .native-card-action svg { width: 11px; height: 11px; }

#docs-view-root .eml-header {
  padding: 14px 18px;
  margin-bottom: 14px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-left: 3px solid #0EA5E9;
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 12px;
  color: #1E293B;
}

#docs-view-root .eml-header-row {
  display: flex;
  gap: 8px;
  padding: 2px 0;
}

#docs-view-root .eml-header-key {
  font-weight: 700;
  min-width: 70px;
  color: #475569;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.05em;
  padding-top: 2px;
}

#docs-view-root .eml-header-val {
  color: #0F172A;
  flex: 1;
  word-break: break-word;
}

#docs-view-root .doc-thumb-powerpoint .ppt-slide {
  padding: 40px 60px;
  background: #FFFFFF;
}

#docs-view-root .doc-thumb-powerpoint .ppt-slide-title {
  font-size: 34px;
  font-weight: 700;
  color: #0F172A;
  margin-bottom: 24px;
  border-bottom: 4px solid #EA580C;
  padding-bottom: 12px;
  display: inline-block;
}

#docs-view-root .doc-thumb-powerpoint .ppt-slide-body {
  font-size: 20px;
  color: #334155;
  margin-bottom: 12px;
  line-height: 1.5;
}

#docs-view-root .doc-thumb-text pre {
  font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #334155;
  margin: 0;
}

#docs-view-root .docs-list[data-view="list"] .doc-thumb-native {
  padding: 6px;
  gap: 0;
}

#docs-view-root .docs-list[data-view="list"] .native-card-icon { width: 30px; height: 30px; }

#docs-view-root .docs-list[data-view="list"] .native-card-body, #docs-view-root .docs-list[data-view="list"] .native-card-action { display: none; }

#docs-view-root .doc-thumb-word {
  width: 100%; height: 100%;
  background: white;
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

#docs-view-root .doc-thumb-word-page {
  width: 816px;
  min-height: 1056px;
  padding: 72px;
  background: white;
  color: #1a1a1a;
  font-family: Calibri, 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  box-sizing: border-box;
  transform-origin: top left;
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  /* Initial scale - overridden by JS based on actual thumb width */
  transform: scale(0.343);
}

#docs-view-root .doc-thumb-word-page h1 { font-size: 28px; font-weight: 600; margin: 0 0 14px 0; color: #0A2540; }

#docs-view-root .doc-thumb-word-page h2 { font-size: 22px; font-weight: 600; margin: 20px 0 10px 0; color: #0A2540; }

#docs-view-root .doc-thumb-word-page h3 { font-size: 18px; font-weight: 600; margin: 16px 0 8px 0; color: #0A2540; }

#docs-view-root .doc-thumb-word-page h4 { font-size: 15px; font-weight: 600; margin: 14px 0 6px 0; }

#docs-view-root .doc-thumb-word-page p { margin: 0 0 10px 0; }

#docs-view-root .doc-thumb-word-page ul, #docs-view-root .doc-thumb-word-page ol { margin: 0 0 10px 20px; padding: 0; }

#docs-view-root .doc-thumb-word-page li { margin: 0 0 4px 0; }

#docs-view-root .doc-thumb-word-page table { border-collapse: collapse; margin: 10px 0; width: 100%; }

#docs-view-root .doc-thumb-word-page td, #docs-view-root .doc-thumb-word-page th { border: 1px solid #ccc; padding: 6px 10px; font-size: 13px; }

#docs-view-root .doc-thumb-word-page th { background: #f5f5f5; font-weight: 600; }

#docs-view-root .doc-thumb-word-page img { max-width: 100%; height: auto; }

#docs-view-root .doc-thumb-word-page strong { font-weight: 600; }

#docs-view-root .doc-thumb-word-page em { font-style: italic; }

#docs-view-root .doc-badge {
  position: absolute;
  top: 8px; right: 8px;
  padding: 2px 6px;
  background: rgba(10, 37, 64, 0.75);
  color: white;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-radius: 3px;
  z-index: 3;
}

#docs-view-root .doc-page-badge {
  position: absolute;
  bottom: 8px; left: 8px;
  padding: 2px 6px;
  background: rgba(10, 37, 64, 0.75);
  color: white;
  font-family: var(--font-mono);
  font-size: 9px;
  border-radius: 3px;
  z-index: 3;
}

#docs-view-root .anno-indicator {
  position: absolute;
  top: 8px; left: 8px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--signal);
  color: #0A2540;
  display: flex; align-items: center; justify-content: center;
  z-index: 4;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

#docs-view-root .anno-indicator svg { width: 11px; height: 11px; }

#docs-view-root .doc-info { padding: 8px 10px 10px; }

#docs-view-root .doc-name {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
  cursor: text;
  padding: 1px 3px;
  border-radius: 3px;
  border: 1px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
}

#docs-view-root .doc-name:hover {
  background: var(--surface-alt);
  border-color: var(--border);
}

#docs-view-root .doc-name-input {
  width: 100%;
  padding: 2px 4px;
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--signal);
  border-radius: 3px;
  font-size: 12px;
  outline: none;
}

#docs-view-root .doc-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

#docs-view-root .doc-date {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-tertiary);
}

#docs-view-root .doc-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.12s ease;
}

#docs-view-root .doc-item:hover .doc-actions { opacity: 1; }

#docs-view-root .doc-mini-btn {
  width: 22px; height: 22px;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#docs-view-root .doc-mini-btn:hover { background: var(--surface-alt); color: var(--text); }

#docs-view-root .doc-mini-btn.active { color: var(--signal-ink); background: var(--signal-pale); }

#docs-view-root .doc-mini-btn svg { width: 11px; height: 11px; }

#docs-view-root .docs-list[data-view="list"] .doc-item {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  aspect-ratio: auto;
}

#docs-view-root .docs-list[data-view="list"] .doc-thumb {
  width: 48px; height: 60px;
  padding: 3px;
  border-bottom: none;
  border-radius: 3px;
  aspect-ratio: 8.5 / 11;
}

#docs-view-root .docs-list[data-view="list"] .doc-thumb img { box-shadow: none; }

#docs-view-root .docs-list[data-view="list"] .doc-thumb .doc-badge, #docs-view-root .docs-list[data-view="list"] .doc-thumb .doc-page-badge, #docs-view-root .docs-list[data-view="list"] .doc-thumb .anno-indicator { display: none; }

#docs-view-root .docs-list[data-view="list"] .doc-info { padding: 0; }

#docs-view-root .docs-list[data-view="list"] .doc-actions { opacity: 1; }

#docs-view-root .categories-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
  min-width: 0;
}

#docs-view-root .cat-header {
  padding: 20px 24px 14px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

#docs-view-root .cat-header-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;
  font-style: italic;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1;
}

#docs-view-root .cat-header-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}

#docs-view-root .cat-stats {
  display: flex;
  align-items: center;
  gap: 12px;
}

#docs-view-root .cat-stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}

#docs-view-root .cat-stat-pill b {
  color: var(--text);
  font-weight: 600;
}

#docs-view-root .cat-grid {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  align-content: start;
}

#docs-view-root .cat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  gap: 12px;
  align-items: center;
  position: relative;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

#docs-view-root .cat-card:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

#docs-view-root .cat-card.active {
  border-color: var(--signal);
  border-left-color: var(--signal);
  box-shadow: 0 0 0 1px var(--signal-tint);
  background: linear-gradient(135deg, var(--signal-pale) 0%, var(--surface) 60%);
}

/* v8.7.52: Card depth promoted to rest state.
   v8.7.50 was too subtle at rest — Justin wanted the depth that was
   previously shown only on :hover to be the default. Old hover shadow is
   now the rest shadow; a deeper hover is designed on top so the cards
   still respond to mouse-over (existing translateY(-1px) lift stays).
   Scoped to light mode; dark mode keeps the Carbon flat aesthetic
   established in v8.6.48. Specificity (0,1,2,1) beats the base
   #docs-view-root .cat-card rule so order within this file doesn't
   matter. */
html[data-theme="light"] #docs-view-root .cat-card {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(10, 37, 64, 0.025) 100%),
        var(--surface);
    box-shadow:
        0 1px 3px rgba(10, 37, 64, 0.08),
        0 8px 20px rgba(10, 37, 64, 0.09);
}

html[data-theme="light"] #docs-view-root .cat-card:hover {
    /* Existing translateY(-1px) lift on the base rule stays; shadow
       deepens further so hover still feels like a clear response. */
    box-shadow:
        0 2px 4px rgba(10, 37, 64, 0.09),
        0 12px 28px rgba(10, 37, 64, 0.11);
}

html[data-theme="light"] #docs-view-root .cat-card.active {
    /* Preserve the signal-pale diagonal gradient + signal-tint ring,
       stack the depth shadow underneath so the active card also looks
       raised. Matches the new rest-state depth so all cards float
       consistently; signal ring is the only distinguishing cue. */
    background: linear-gradient(135deg, var(--signal-pale) 0%, var(--surface) 60%);
    box-shadow:
        0 0 0 1px var(--signal-tint),
        0 1px 3px rgba(10, 37, 64, 0.08),
        0 8px 20px rgba(10, 37, 64, 0.10);
}

html[data-theme="light"] #docs-view-root .cat-card.active:hover {
    /* Active+hover needs explicit definition because .cat-card.active
       and .cat-card:hover have identical specificity, so without this
       the active rule would win source-order over hover and hover
       would visually do nothing for the selected card. */
    box-shadow:
        0 0 0 1px var(--signal-tint),
        0 2px 4px rgba(10, 37, 64, 0.09),
        0 12px 28px rgba(10, 37, 64, 0.12);
}

#docs-view-root .cat-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--surface-alt);
}

#docs-view-root .cat-icon svg { width: 16px; height: 16px; }

#docs-view-root .cat-card[data-cat="all"]              .cat-icon { background: var(--signal-pale); color: var(--signal-ink); }

/* Pipeline-routed categories — auto-classified by the Altitude pipeline */
#docs-view-root .cat-card[data-cat="loss-history"]     .cat-icon { background: rgba(220, 38, 38, 0.12);  color: var(--tag-red); }

#docs-view-root .cat-card[data-cat="applications"]     .cat-icon { background: rgba(22, 163, 74, 0.12);  color: var(--tag-green); }

#docs-view-root .cat-card[data-cat="underlying"]       .cat-icon { background: rgba(234, 179, 8, 0.12);  color: var(--tag-yellow); }

#docs-view-root .cat-card[data-cat="project"]          .cat-icon { background: rgba(124, 58, 237, 0.12); color: var(--tag-purple); }

#docs-view-root .cat-card[data-cat="correspondence"]   .cat-icon { background: rgba(244, 114, 182, 0.12); color: var(--tag-pink); }

#docs-view-root .cat-card[data-cat="compliance"]       .cat-icon { background: rgba(234, 88, 12, 0.12);  color: var(--tag-orange); }

#docs-view-root .cat-card[data-cat="administration"]   .cat-icon { background: rgba(127, 29, 29, 0.12);  color: var(--tag-maroon); }

/* Manual-only categories — uploaded by the user, never auto-classified */
#docs-view-root .cat-card[data-cat="quotes-indications"] .cat-icon { background: rgba(13, 148, 136, 0.12); color: var(--tag-teal); }

#docs-view-root .cat-card[data-cat="cancellations"]    .cat-icon { background: rgba(219, 39, 119, 0.12); color: var(--tag-magenta); }

#docs-view-root .cat-card[data-cat="policy"]           .cat-icon { background: rgba(37, 99, 235, 0.12);  color: var(--tag-blue); }

#docs-view-root .cat-card[data-cat="subjectivity"]     .cat-icon { background: rgba(251, 113, 133, 0.12); color: var(--tag-coral); }

#docs-view-root .cat-card[data-cat="underwriting"]     .cat-icon { background: rgba(107, 114, 128, 0.12); color: var(--tag-black); }

#docs-view-root .cat-body { flex: 1; min-width: 0; }

#docs-view-root .cat-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 2px;
}

#docs-view-root .cat-card.active .cat-name { color: var(--signal-ink); }

#docs-view-root .cat-desc {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.3;
}

#docs-view-root .cat-count {
  position: absolute;
  top: 10px; right: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface-alt);
  padding: 2px 8px;
  border-radius: 10px;
  min-width: 26px;
  text-align: center;
}

#docs-view-root .cat-card.active .cat-count { background: var(--signal); color: #0A2540; }

#docs-view-root .tags-panel {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  background: var(--sidebar-bg);
  border-left: 1px solid var(--border);
  overflow: hidden;
  min-width: 0;
}

#docs-view-root .tags-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#docs-view-root .tags-header-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  font-weight: 700;
}

#docs-view-root .tags-count-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--signal-ink);
  background: var(--signal-pale);
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--signal-tint);
  font-weight: 600;
}

#docs-view-root .color-filter {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

#docs-view-root .color-filter-btn {
  width: 100%;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#docs-view-root .color-filter-btn:hover { border-color: var(--border-strong); }

#docs-view-root .color-filter-display {
  display: flex;
  align-items: center;
  gap: 8px;
}

#docs-view-root .color-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

#docs-view-root .color-dot.all { background: conic-gradient(var(--tag-red), var(--tag-maroon), var(--tag-orange), var(--tag-yellow), var(--tag-green), var(--tag-teal), var(--tag-blue), var(--tag-purple), var(--tag-magenta), var(--tag-pink), var(--tag-coral), var(--tag-black), var(--tag-red)); }

#docs-view-root .color-dot.red { background: var(--tag-red); }

#docs-view-root .color-dot.maroon { background: var(--tag-maroon); }

#docs-view-root .color-dot.blue { background: var(--tag-blue); }

#docs-view-root .color-dot.green { background: var(--tag-green); }

#docs-view-root .color-dot.yellow { background: var(--tag-yellow); }

#docs-view-root .color-dot.purple { background: var(--tag-purple); }

#docs-view-root .color-dot.orange { background: var(--tag-orange); }

#docs-view-root .color-dot.pink { background: var(--tag-pink); }

#docs-view-root .color-dot.black { background: var(--tag-black); border: 1px solid var(--border-strong); }

#docs-view-root .color-dot.teal { background: var(--tag-teal); }

#docs-view-root .color-dot.magenta { background: var(--tag-magenta); }

#docs-view-root .color-dot.coral { background: var(--tag-coral); }

#docs-view-root .color-filter-menu {
  position: absolute;
  top: calc(100% - 8px);
  left: 16px; right: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  z-index: 50;
  display: none;
}

#docs-view-root .color-filter-menu.visible { display: block; }

#docs-view-root .color-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
  text-align: left;
}

#docs-view-root .color-option:hover { background: var(--surface-alt); }

#docs-view-root .color-option.active { color: var(--signal-ink); background: var(--signal-pale); }

#docs-view-root .tags-list {
  overflow-y: auto;
  padding: 8px 10px;
}

#docs-view-root .tagged-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 7px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.2s ease;
}

#docs-view-root .tagged-item:hover {
  transform: translateX(2px);
  border-color: var(--border-strong);
}

#docs-view-root .tagged-item.tag-red { --tc: var(--tag-red-rgb); }

#docs-view-root .tagged-item.tag-maroon { --tc: var(--tag-maroon-rgb); }

#docs-view-root .tagged-item.tag-blue { --tc: var(--tag-blue-rgb); }

#docs-view-root .tagged-item.tag-green { --tc: var(--tag-green-rgb); }

#docs-view-root .tagged-item.tag-yellow { --tc: var(--tag-yellow-rgb); }

#docs-view-root .tagged-item.tag-purple { --tc: var(--tag-purple-rgb); }

#docs-view-root .tagged-item.tag-orange { --tc: var(--tag-orange-rgb); }

#docs-view-root .tagged-item.tag-pink { --tc: var(--tag-pink-rgb); }

#docs-view-root .tagged-item.tag-black { --tc: var(--tag-black-rgb); }

#docs-view-root .tagged-item.tag-teal { --tc: var(--tag-teal-rgb); }

#docs-view-root .tagged-item.tag-magenta { --tc: var(--tag-magenta-rgb); }

#docs-view-root .tagged-item.tag-coral { --tc: var(--tag-coral-rgb); }

#docs-view-root .tagged-item.tag-red, #docs-view-root .tagged-item.tag-maroon, #docs-view-root .tagged-item.tag-blue, #docs-view-root .tagged-item.tag-green, #docs-view-root .tagged-item.tag-yellow, #docs-view-root .tagged-item.tag-purple, #docs-view-root .tagged-item.tag-orange, #docs-view-root .tagged-item.tag-pink, #docs-view-root .tagged-item.tag-black, #docs-view-root .tagged-item.tag-teal, #docs-view-root .tagged-item.tag-magenta, #docs-view-root .tagged-item.tag-coral {
  border-color: rgba(var(--tc), 0.55);
  background:
    linear-gradient(90deg, rgba(var(--tc), 0.18) 0%, rgba(var(--tc), 0.05) 40%, var(--surface) 100%),
    var(--surface);
  box-shadow:
    0 0 0 1px rgba(var(--tc), 0.25),
    0 0 14px -2px rgba(var(--tc), 0.45);
}

#docs-view-root .tagged-item.tag-red:hover, #docs-view-root .tagged-item.tag-maroon:hover, #docs-view-root .tagged-item.tag-blue:hover, #docs-view-root .tagged-item.tag-green:hover, #docs-view-root .tagged-item.tag-yellow:hover, #docs-view-root .tagged-item.tag-purple:hover, #docs-view-root .tagged-item.tag-orange:hover, #docs-view-root .tagged-item.tag-pink:hover, #docs-view-root .tagged-item.tag-black:hover, #docs-view-root .tagged-item.tag-teal:hover, #docs-view-root .tagged-item.tag-magenta:hover, #docs-view-root .tagged-item.tag-coral:hover {
  border-color: rgb(var(--tc));
  box-shadow:
    0 0 0 1px rgba(var(--tc), 0.45),
    0 0 22px 0 rgba(var(--tc), 0.65);
}

#docs-view-root .tagged-item.tag-red::before, #docs-view-root .tagged-item.tag-maroon::before, #docs-view-root .tagged-item.tag-blue::before, #docs-view-root .tagged-item.tag-green::before, #docs-view-root .tagged-item.tag-yellow::before, #docs-view-root .tagged-item.tag-purple::before, #docs-view-root .tagged-item.tag-orange::before, #docs-view-root .tagged-item.tag-pink::before, #docs-view-root .tagged-item.tag-black::before, #docs-view-root .tagged-item.tag-teal::before, #docs-view-root .tagged-item.tag-magenta::before, #docs-view-root .tagged-item.tag-coral::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: rgb(var(--tc));
  box-shadow: 0 0 8px 0 rgba(var(--tc), 0.8);
}

#docs-view-root .tagged-body { flex: 1; min-width: 0; padding-left: 4px; }

#docs-view-root .tagged-name {
  font-size: 12.5px;
  color: var(--text);
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 2px;
}

/* v8.6.11: filename / page reference shown as muted subtext below the
   tag title. Clamped so it never expands past one short line. */
#docs-view-root .tagged-sub {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

#docs-view-root .tagged-label {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 1px 6px;
  border-radius: 3px;
  line-height: 1.4;
}

#docs-view-root .tagged-item.tag-red    .tagged-label, #docs-view-root .tagged-item.tag-maroon .tagged-label, #docs-view-root .tagged-item.tag-blue   .tagged-label, #docs-view-root .tagged-item.tag-green  .tagged-label, #docs-view-root .tagged-item.tag-yellow .tagged-label, #docs-view-root .tagged-item.tag-purple .tagged-label, #docs-view-root .tagged-item.tag-orange .tagged-label, #docs-view-root .tagged-item.tag-pink   .tagged-label, #docs-view-root .tagged-item.tag-black  .tagged-label {
  color: rgb(var(--tc));
  background: rgba(var(--tc), 0.15);
  border: 1px solid rgba(var(--tc), 0.35);
}

html[data-theme="light"] #docs-view-root .tagged-item.tag-yellow .tagged-label {
  color: #854D0E;
}

#docs-view-root .tagged-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.12s ease;
  flex-shrink: 0;
}

#docs-view-root .tagged-item:hover .tagged-actions { opacity: 1; }

#docs-view-root .tags-empty {
  /* v8.6.48: same compact spotlight treatment as .docs-empty */
  text-align: center;
  padding: 24px 16px;
  margin: 10px;
  color: var(--text-tertiary);
  background: linear-gradient(135deg, var(--signal-pale) 0%, var(--surface-alt) 80%);
  border: 1px solid var(--signal-tint);
  border-radius: var(--radius);
}

#docs-view-root .tags-empty svg { width: 30px; height: 30px; color: var(--signal-dim); opacity: 0.65; margin-bottom: 10px; }

#docs-view-root .tags-empty-title { font-family: var(--font-display); font-size: 14px; font-style: italic; font-weight: 500; letter-spacing: -0.01em; color: var(--signal-ink); margin-bottom: 4px; }

#docs-view-root .tags-empty-sub { font-size: 11px; color: var(--text-secondary); }

#docs-view-root .tags-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
}

#docs-view-root .tags-footer .btn {
  flex: 1;
  justify-content: center;
  padding: 6px 10px;
  font-size: 11px;
}

#docs-view-root .anno-toolbox {
  position: fixed;
  top: 52px;             /* just below topbar */
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.04);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 0.22s;
  max-width: calc(100vw - 40px);
}

html[data-theme="light"] #docs-view-root .anno-toolbox {
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.14), 0 0 0 1px var(--border);
}

#docs-view-root .anno-toolbox.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(6px);
  transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

#docs-view-root .anno-toolbox-header { display: none; }

#docs-view-root .anno-toolbox-body { padding: 0; }

#docs-view-root .anno-toolbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

#docs-view-root .anno-tools-row {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

#docs-view-root .anno-btn {
  width: 30px; height: 30px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

#docs-view-root .anno-btn svg { width: 13px; height: 13px; }

#docs-view-root .anno-btn:hover {
  background: var(--surface-alt);
  color: var(--text);
  border-color: var(--border);
}

#docs-view-root .anno-btn.active {
  background: var(--signal);
  color: #0A2540;
  border-color: var(--signal);
}

#docs-view-root .anno-divider {
  width: 1px; height: 20px;
  background: var(--border);
  margin: 0 4px;
}

#docs-view-root .anno-options-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  min-height: 36px;
  flex-wrap: wrap;
}

#docs-view-root .anno-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  font-weight: 700;
  margin-right: 2px;
}

#docs-view-root .opt-group { display: none; align-items: center; gap: 8px; }

#docs-view-root .opt-group.visible { display: flex; }

#docs-view-root .anno-swatches { display: flex; gap: 3px; }

#docs-view-root .anno-swatch {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}

#docs-view-root .anno-swatch:hover { transform: scale(1.15); }

#docs-view-root .anno-swatch.active {
  border-color: var(--signal);
  box-shadow: 0 0 0 2px var(--signal-pale);
}

#docs-view-root .anno-strokes { display: flex; gap: 2px; }

#docs-view-root .anno-stroke-btn {
  width: 28px; height: 22px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

#docs-view-root .anno-stroke-btn:hover { background: var(--surface-alt); }

#docs-view-root .anno-stroke-btn.active { background: var(--signal-pale); border-color: var(--signal); }

#docs-view-root .anno-stroke-preview {
  display: block;
  width: 14px;
  background: var(--text-secondary);
  border-radius: 1px;
}

#docs-view-root .anno-stroke-btn.active .anno-stroke-preview { background: var(--signal-ink); }

#docs-view-root .anno-opacity {
  width: 70px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

#docs-view-root .anno-opacity::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--signal);
  cursor: pointer;
}

#docs-view-root .anno-opacity::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--signal);
  border: none;
}

#docs-view-root .anno-fontsize-btns { display: flex; gap: 2px; }

#docs-view-root .anno-fontsize-btn {
  width: 24px; height: 22px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

#docs-view-root .anno-fontsize-btn:hover { background: var(--surface-alt); color: var(--text); }

#docs-view-root .anno-fontsize-btn.active { background: var(--signal-pale); color: var(--signal-ink); border-color: var(--signal); }

#docs-view-root .anno-fill-toggle {
  width: 28px; height: 22px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

#docs-view-root .anno-fill-toggle svg { width: 12px; height: 12px; }

#docs-view-root .anno-fill-toggle:hover { background: var(--surface-alt); color: var(--text); }

#docs-view-root .anno-fill-toggle.active { background: var(--signal-pale); color: var(--signal-ink); border-color: var(--signal); }

#docs-view-root .anno-action-group { display: flex; gap: 2px; margin-left: auto; align-items: center; }

#docs-view-root .anno-action-btn {
  width: 28px; height: 26px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

#docs-view-root .anno-action-btn svg { width: 12px; height: 12px; }

#docs-view-root .anno-action-btn:hover { background: var(--surface-alt); color: var(--text); border-color: var(--border); }

#docs-view-root .anno-action-btn.danger:hover { color: var(--danger); border-color: var(--danger); }

#docs-view-root .anno-preview-btn {
  padding: 0 10px !important;
  width: auto !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  gap: 5px !important;
  height: 26px !important;
}

#docs-view-root .anno-canvas-wrap {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
}

#docs-view-root .anno-canvas-wrap.drawing { pointer-events: auto; }

#docs-view-root .anno-canvas {
  position: absolute;
  inset: 0;
  /* Explicit width/height: 100% to defend against browser quirks where
     replaced elements (canvas) with only inset:0 fall back to intrinsic
     300×150 size. NO !important — inline styles set by resizeCanvas()
     have higher specificity and can still override if needed. */
  width: 100%;
  height: 100%;
  background: transparent;
  touch-action: none;
}

#docs-view-root .anno-canvas-wrap[data-tool="pen"], #docs-view-root .anno-canvas-wrap[data-tool="highlighter"], #docs-view-root .anno-canvas-wrap[data-tool="rectangle"], #docs-view-root .anno-canvas-wrap[data-tool="ellipse"], #docs-view-root .anno-canvas-wrap[data-tool="arrow"], #docs-view-root .anno-canvas-wrap[data-tool="line"], #docs-view-root .anno-canvas-wrap[data-tool="text"] { cursor: crosshair; }

#docs-view-root .anno-canvas-wrap[data-tool="sticky"] { cursor: cell; }

#docs-view-root .anno-canvas-wrap[data-tool="eraser"] {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20'%3E%3Ccircle cx='10' cy='10' r='8' fill='none' stroke='%23F87171' stroke-width='2'/%3E%3C/svg%3E") 10 10, auto;
}

#docs-view-root .anno-canvas-wrap .anno-text-input, #docs-view-root .anno-canvas-wrap .anno-sticky { pointer-events: auto; }

#docs-view-root .anno-text-input {
  position: absolute;
  z-index: 10;
  background: var(--surface);
  border: 2px solid currentColor;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  min-width: 80px;
  min-height: 40px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

#docs-view-root .anno-text-dragbar {
  height: 14px;
  background: currentColor;
  opacity: 0.15;
  cursor: move;
  border-radius: 2px 2px 0 0;
  flex-shrink: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

#docs-view-root .anno-text-dragbar::after {
  content: '';
  width: 20px; height: 2px;
  background: currentColor;
  opacity: 0.5;
  border-radius: 1px;
}

#docs-view-root .anno-text-close {
  position: absolute;
  right: 2px; top: 50%;
  transform: translateY(-50%);
  width: 12px; height: 12px;
  border: none;
  background: var(--danger);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

#docs-view-root .anno-text-close svg { width: 8px; height: 8px; }

#docs-view-root .anno-text-input:hover .anno-text-close, #docs-view-root .anno-text-input.selected .anno-text-close { opacity: 1; }

#docs-view-root .anno-text-editable {
  flex: 1;
  padding: 4px 6px;
  outline: none;
  line-height: 1.3;
  font-weight: 500;
  overflow-y: auto;
  word-wrap: break-word;
  white-space: pre-wrap;
  background: transparent;
}

#docs-view-root .anno-text-input.committed {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  cursor: pointer;
}

#docs-view-root .anno-text-input.committed .anno-text-editable {
  cursor: default;
  user-select: none;
}

#docs-view-root .anno-text-input.committed .anno-text-dragbar {
  opacity: 0;
  height: 3px;
}

#docs-view-root .anno-text-input.committed:hover {
  background: var(--surface);
  border-color: currentColor;
  border-style: dashed;
  box-shadow: var(--shadow);
}

#docs-view-root .anno-text-input.committed:hover .anno-text-dragbar {
  opacity: 0.15;
  height: 14px;
}

#docs-view-root .anno-text-input.selected {
  background: var(--surface) !important;
  border-style: dashed !important;
  box-shadow: 0 0 0 2px var(--signal-tint), var(--shadow) !important;
}

#docs-view-root .anno-sticky {
  position: absolute;
  z-index: 10;
  width: 140px;
  background: #FEF3C7;
  border: 1px solid #F59E0B;
  border-radius: 4px;
  box-shadow: 2px 3px 10px rgba(0,0,0,0.15);
  overflow: hidden;
  color: #78350f;
}

#docs-view-root .anno-sticky-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 6px;
  background: rgba(245, 158, 11, 0.2);
  border-bottom: 1px solid rgba(245, 158, 11, 0.3);
  cursor: move;
}

#docs-view-root .anno-sticky-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #92400e;
}

#docs-view-root .anno-sticky-close {
  width: 14px; height: 14px;
  border: none;
  background: transparent;
  color: #b45309;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

#docs-view-root .anno-sticky-close svg { width: 9px; height: 9px; }

#docs-view-root .anno-sticky-close:hover { background: #F59E0B; color: #78350f; }

#docs-view-root .anno-sticky-body {
  padding: 6px;
  font-size: 11px;
  line-height: 1.4;
  outline: none;
  min-height: 40px;
  max-height: 120px;
  overflow-y: auto;
  word-wrap: break-word;
}

#docs-view-root .anno-sticky-body:empty::before {
  content: 'Type a note…';
  color: #D97706;
  opacity: 0.6;
  font-style: italic;
}

#docs-view-root .drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 4000;
  background: var(--backdrop-bg);
  backdrop-filter: blur(16px);
  display: none;
  align-items: center;
  justify-content: center;
}

#docs-view-root .drop-overlay.visible { display: flex; }

#docs-view-root .drop-content { text-align: center; color: var(--text); }

#docs-view-root .drop-icon {
  width: 80px; height: 80px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--signal-pale);
  border: 2px dashed var(--signal);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--signal-ink);
}

#docs-view-root .drop-icon svg { width: 32px; height: 32px; }

#docs-view-root .drop-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-style: italic;
  margin-bottom: 6px;
}

#docs-view-root .drop-sub {
  font-size: 13px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

#docs-view-root .modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop-bg);
  backdrop-filter: blur(8px);
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
}

#docs-view-root .modal-backdrop.visible { display: flex; }

#docs-view-root .modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 560px;
  max-width: 92vw;
  box-shadow: var(--shadow-xl);
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

#docs-view-root .modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}

#docs-view-root .modal-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-style: italic;
  margin-bottom: 4px;
}

#docs-view-root .modal-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

#docs-view-root .modal-cat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 14px 20px;
}

#docs-view-root .modal-cat-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  background: var(--surface-alt);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-secondary);
}

#docs-view-root .modal-cat-opt svg { width: 16px; height: 16px; }

#docs-view-root .modal-cat-opt span {
  font-size: 10.5px;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  color: var(--text);
}

#docs-view-root .modal-cat-opt:hover { border-color: var(--border-strong); color: var(--text); }

#docs-view-root .modal-cat-opt.active {
  border-color: var(--signal);
  background: var(--signal-pale);
  color: var(--signal-ink);
  box-shadow: 0 0 0 3px var(--signal-tint);
}

#docs-view-root .modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

#docs-view-root .context-menu {
  position: fixed;
  z-index: 5000;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xl);
  padding: 4px;
  display: none;
}

#docs-view-root .context-menu.visible { display: block; }

#docs-view-root .ctx-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
  width: 100%;
  text-align: left;
}

#docs-view-root .ctx-item:hover { background: var(--surface-alt); }

#docs-view-root .ctx-item.danger { color: var(--danger); }

#docs-view-root .ctx-item.danger:hover { background: rgba(248, 113, 113, 0.12); }

#docs-view-root .ctx-item svg { width: 12px; height: 12px; opacity: 0.7; flex-shrink: 0; }

#docs-view-root .ctx-item kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-tertiary);
  background: var(--surface-alt);
  padding: 1px 5px;
  border-radius: 3px;
}

#docs-view-root .ctx-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 6px;
}

#docs-view-root .color-picker-menu {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 100;
  display: none;
  min-width: 140px;
}

#docs-view-root .color-picker-menu.visible { display: block; }

#docs-view-root .color-picker-menu.preview-dropdown {
  bottom: auto;
  top: calc(100% + 4px);
}

#docs-view-root .color-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 4px;
  margin-bottom: 4px;
  min-width: 180px;
}

#docs-view-root .color-grid-btn {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  cursor: pointer;
  padding: 0;
}

#docs-view-root .color-grid-btn.tag-black {
  border-color: var(--border-strong);
}

#docs-view-root .color-grid-btn.active { border-color: var(--signal); box-shadow: 0 0 0 1px var(--signal-tint); }

#docs-view-root .color-clear-btn {
  width: 100%;
  padding: 4px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 10px;
  cursor: pointer;
}

#docs-view-root .color-clear-btn:hover { color: var(--text); }

#docs-view-root .preview-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  flex-direction: column;
  background: rgba(10, 37, 64, 0.96);
  backdrop-filter: blur(12px);
}

#docs-view-root .preview-modal.visible { display: flex; }

#docs-view-root .preview-header {
  background: var(--sidebar-bg);
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#docs-view-root .preview-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 45%;
  min-width: 0;
}

#docs-view-root .preview-title {
  background: transparent;
  border: 1px solid transparent;
  padding: 5px 8px;
  font-family: var(--font-display);
  font-size: 15px;
  font-style: italic;
  color: var(--text);
  flex: 1;
  outline: none;
  border-radius: var(--radius);
  min-width: 0;
  text-overflow: ellipsis;
}

#docs-view-root .preview-title.editable {
  background: var(--surface);
  border-color: var(--signal);
  font-style: normal;
  font-family: var(--font-sans);
  box-shadow: 0 0 0 3px var(--signal-pale);
}

#docs-view-root .preview-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

#docs-view-root .preview-btn {
  padding: 6px 10px;
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}

#docs-view-root .preview-btn:hover { background: var(--surface-alt); color: var(--text); border-color: var(--border-strong); }

#docs-view-root .preview-btn.active { background: var(--signal); color: #0A2540; border-color: var(--signal); }

#docs-view-root .preview-btn svg { width: 12px; height: 12px; }

#docs-view-root .preview-btn-primary {
  background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
  color: white;
  border-color: transparent;
}

#docs-view-root .preview-btn-primary:hover { background: linear-gradient(135deg, #7C7AED 0%, #9B6BF6 100%); color: white; }

#docs-view-root .preview-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

#docs-view-root .preview-nav-btn {
  width: 28px; height: 28px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#docs-view-root .preview-nav-btn:hover:not(:disabled) { background: var(--surface-alt); color: var(--text); }

#docs-view-root .preview-nav-btn:disabled { opacity: 0.4; cursor: not-allowed; }

#docs-view-root .preview-nav-btn svg { width: 12px; height: 12px; }

#docs-view-root .preview-counter {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  padding: 0 6px;
  min-width: 50px;
  text-align: center;
}

#docs-view-root .preview-color-wrap { position: relative; }

#docs-view-root .preview-body {
  flex: 1;
  overflow: auto;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
}

#docs-view-root .preview-body * { user-select: text; }

#docs-view-root #previewCanvas {
  transition: transform 0.25s ease;
  transform-origin: center center;
  display: flex;
  justify-content: center;
  align-items: center;
  max-width: 100%;
  max-height: 100%;
}

#docs-view-root #previewCanvas img {
  max-width: 100%;
  max-height: calc(100vh - 140px);
  object-fit: contain;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

#docs-view-root .preview-excel-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 90%;
  max-height: calc(100vh - 140px);
}

#docs-view-root .preview-native-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: linear-gradient(90deg, rgba(22, 163, 74, 0.18) 0%, rgba(22, 163, 74, 0.05) 50%, var(--surface) 100%), var(--surface);
  border: 1px solid rgba(22, 163, 74, 0.4);
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px rgba(22, 163, 74, 0.2), 0 0 14px -2px rgba(22, 163, 74, 0.3);
  flex-shrink: 0;
}

#docs-view-root .preview-native-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

#docs-view-root .preview-native-info svg {
  width: 26px; height: 26px;
  color: #16A34A;
  flex-shrink: 0;
}

#docs-view-root .preview-native-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#docs-view-root .preview-native-sub {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

#docs-view-root .preview-native-sub b { color: var(--text); font-weight: 600; }

#docs-view-root .preview-native-btn {
  flex-shrink: 0;
  background: #16A34A !important;
  color: white !important;
  border-color: #16A34A !important;
}

#docs-view-root .preview-native-btn:hover:not(:disabled) {
  background: #15803D !important;
  border-color: #15803D !important;
}

#docs-view-root .preview-native-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#docs-view-root .preview-native-btn svg { width: 14px; height: 14px; margin-right: 2px; }

#docs-view-root .preview-excel, #docs-view-root .preview-word {
  background: white;
  color: #333;
  padding: 30px;
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  max-width: 90%;
  max-height: calc(100vh - 140px);
  overflow: auto;
  font-family: var(--font-sans);
  line-height: 1.5;
}

#docs-view-root .preview-excel table { width: 100%; border-collapse: collapse; font-size: 12px; }

#docs-view-root .preview-excel th {
  background: #F3F4F6; color: #0A2540;
  padding: 6px 10px;
  border: 1px solid #E5E7EB;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  position: sticky;
  top: 0;
}

#docs-view-root .preview-excel td {
  padding: 6px 10px;
  border: 1px solid #F3F4F6;
  font-size: 12px;
  vertical-align: top;
}

#docs-view-root .preview-excel tr:nth-child(even) td { background: #FAFBFC; }

#docs-view-root .preview-word { max-width: 800px; }

#docs-view-root .preview-word h1 { font-size: 22px; margin-bottom: 12px; }

#docs-view-root .preview-word h2 { font-size: 18px; margin: 18px 0 10px; }

#docs-view-root .preview-word h3 { font-size: 15px; margin: 14px 0 8px; }

#docs-view-root .preview-word p { margin-bottom: 10px; }

#docs-view-root .ocr-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
  height: calc(100vh - 120px);
}

#docs-view-root .ocr-image {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
}

#docs-view-root .ocr-image img { max-width: 100%; max-height: 100%; object-fit: contain; }

#docs-view-root .ocr-text {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#docs-view-root .ocr-text-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

#docs-view-root .ocr-text-header h3 { font-size: 13px; font-weight: 600; }

#docs-view-root .ocr-confidence {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

#docs-view-root .ocr-confidence.high { color: var(--success); background: rgba(125, 216, 138, 0.15); }

#docs-view-root .ocr-confidence.medium { color: var(--warning); background: rgba(251, 191, 36, 0.15); }

#docs-view-root .ocr-confidence.low { color: var(--danger); background: rgba(248, 113, 113, 0.15); }

#docs-view-root .ocr-content {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-y: auto;
  color: var(--text);
}

#docs-view-root .toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 5500;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}

#docs-view-root .toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--signal);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  min-width: 260px;
  max-width: 400px;
  pointer-events: auto;
  animation: toastIn 0.2s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

#docs-view-root .toast.success { border-left-color: var(--success); }

#docs-view-root .toast.warning { border-left-color: var(--warning); }

#docs-view-root .toast.error { border-left-color: var(--danger); }

#docs-view-root .toast.info { border-left-color: var(--info); }

#docs-view-root .toast-body { flex: 1; min-width: 0; }

#docs-view-root .toast-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

#docs-view-root .toast-msg {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
}

#docs-view-root .toast-close {
  width: 20px; height: 20px;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#docs-view-root .toast-close:hover { background: var(--surface-alt); color: var(--text); }

#docs-view-root .toast-close svg { width: 11px; height: 11px; }

#docs-view-root .loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 6000;
  background: var(--backdrop-bg);
  backdrop-filter: blur(12px);
  display: none;
  align-items: center;
  justify-content: center;
}

#docs-view-root .loading-overlay.visible { display: flex; }

#docs-view-root .loading-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  text-align: center;
  max-width: 380px;
  min-width: 320px;
  box-shadow: var(--shadow-xl);
}

#docs-view-root .loading-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--signal);
  border-radius: 50%;
  margin: 0 auto 14px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

#docs-view-root .loading-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-style: italic;
  margin-bottom: 4px;
}

#docs-view-root .loading-sub {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  font-family: var(--font-mono);
  word-break: break-all;
}

#docs-view-root .loading-progress {
  height: 3px;
  background: var(--surface-alt);
  border-radius: 2px;
  overflow: hidden;
}

#docs-view-root .loading-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--signal), var(--signal-hover), var(--signal));
  background-size: 200% 100%;
  animation: progressGrad 2s linear infinite;
  transition: width 0.3s ease;
}

@keyframes progressGrad {
  from { background-position: 0% 50%; }
  to { background-position: 200% 50%; }
}

#docs-view-root .loading-pct {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--signal-ink);
  font-weight: 600;
}

@media (max-width: 1200px) {
  #docs-view-root { --docs-panel-w: 260px; --tags-panel-w: 240px; }
}

@media (max-width: 900px) {
  #docs-view-root .workspace { grid-template-columns: 240px 4px 1fr; }
  #docs-view-root .tags-panel, #docs-view-root .workspace > .resizer:nth-of-type(2) { display: none; }
  #docs-view-root .cat-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

@media print {
  #docs-view-root .topbar, #docs-view-root .docs-panel, #docs-view-root .tags-panel, #docs-view-root .resizer, #docs-view-root .anno-toolbar, #docs-view-root .bulk-bar, #docs-view-root .toast-stack, #docs-view-root .loading-overlay, #docs-view-root .preview-header, #docs-view-root .modal-backdrop, #docs-view-root .context-menu, #docs-view-root .drop-overlay { display: none !important; }
  #docs-view-root .preview-body { padding: 0 !important; background: white !important; }
  #docs-view-root .preview-modal { background: white !important; }
  #docs-view-root { background: white !important; color: black !important; }
}

#docs-view-root .hidden { display: none !important; }

/* ──── PHASE 4 · SUBMISSION SCOPE CHIP ────
   Shows in the topbar-center when the docs view is opened from a
   submission context. Compact, removable, signals the active filter. */
#docs-view-root .submission-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 8px 0 10px;
  border: 1px solid var(--signal);
  background: var(--signal-pale);
  color: var(--signal-ink);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-right: 12px;
  white-space: nowrap;
  max-width: 280px;
}
#docs-view-root .submission-chip-icon {
  width: 14px; height: 14px;
  flex-shrink: 0;
  opacity: 0.85;
}
#docs-view-root .submission-chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
#docs-view-root .submission-chip-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  padding: 0;
  margin-left: 2px;
  border: none;
  background: transparent;
  color: inherit;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.12s ease;
}
#docs-view-root .submission-chip-clear:hover {
  background: rgba(var(--tag-red-rgb), 0.18);
  color: var(--danger);
}
#docs-view-root .submission-chip-clear svg {
  width: 12px; height: 12px;
}

/* ──── PHASE 5 · CLOUD SYNC STATUS BADGE ────
   Topbar-right indicator that surfaces when Supabase writes are repeatedly
   failing. Amber to signal warning without alarming; not red, since data
   is safe locally — just not synced. */
#docs-view-root .cloud-sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--warning);
  background: rgba(251, 191, 36, 0.12);
  color: var(--warning);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  margin-right: 8px;
  transition: background 0.12s ease;
}
#docs-view-root .cloud-sync-badge:hover {
  background: rgba(251, 191, 36, 0.22);
}
#docs-view-root .cloud-sync-badge svg {
  width: 14px; height: 14px;
}

/* ──── PHASE 5 · PIPELINE CLASSIFICATION BADGE ────
   Small chip on each thumbnail indicating an auto-classification from
   Altitude's pipeline. Distinguishes pipeline-pushed docs from
   user-uploaded ones at a glance.
   v8.5 Rule 2: chip displays the actual pipeline tag (e.g., "ACORD 125",
   "Lead $5M"), not a generic "AUTO" label, and never includes a page
   number. The tag text is wrapped in a label span so it can ellipsis
   when long without breaking the lightning-bolt icon alignment. */
#docs-view-root .pipeline-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #0A2540;
  background: var(--signal);
  border-radius: 3px;
  z-index: 4;
  pointer-events: none;
  box-shadow: 0 1px 2px rgba(0,0,0,0.18);
  max-width: calc(100% - 12px);
}
#docs-view-root .pipeline-badge svg {
  width: 9px; height: 9px;
  stroke-width: 2.4;
  flex-shrink: 0;
}
#docs-view-root .pipeline-badge-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}


/* v8.7.04 — File Manager page-fit final.
   The earlier media-fill rule used object-fit: cover, which made wide or
   irregular PDF pages look snappy but cropped the sides/bottom inside the
   page card. Keep the fast thumbnail path, but render the entire page inside
   the card. This is CSS-only and does not touch tagging, classification,
   extraction, or Workbench logic. */
#docs-view-root .doc-thumb.doc-thumb-media {
  padding: 8px;
  overflow: hidden;
  background: #05070B;
}

#docs-view-root .doc-thumb.doc-thumb-media img {
  position: absolute;
  inset: 8px;
  width: calc(100% - 16px);
  height: calc(100% - 16px);
  max-width: calc(100% - 16px);
  max-height: calc(100% - 16px);
  object-fit: contain;
  object-position: center center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
  border-radius: 2px;
  background: #fff;
  image-rendering: auto;
}

#docs-view-root .docs-list[data-view="list"] .doc-thumb.doc-thumb-media {
  padding: 0;
}

/* FIX-PHASE-13.3-FILEMANAGER-TOWER-LABELS-2026-05-14
   In-tower documents are colored the Underlying color (yellow) via the
   existing .has-color.tag-yellow path. An unresolved rung (????) is
   additionally highlighted so the user immediately sees it needs a
   relabel — pulsing amber ring, distinct from the steady tower color. */
#docs-view-root .doc-item.is-tower-uncertain {
  box-shadow: 0 0 0 2px var(--tag-yellow, #EAB308),
              0 0 0 5px rgba(var(--tag-yellow-rgb, 234, 179, 8), 0.28);
  animation: stmTowerUncertainPulse 2.4s ease-in-out infinite;
}
@keyframes stmTowerUncertainPulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--tag-yellow, #EAB308),
                          0 0 0 5px rgba(var(--tag-yellow-rgb, 234, 179, 8), 0.28); }
  50%      { box-shadow: 0 0 0 2px var(--tag-yellow, #EAB308),
                          0 0 0 8px rgba(var(--tag-yellow-rgb, 234, 179, 8), 0.12); }
}
#docs-view-root .doc-item.is-tower-doc .pipeline-badge {
  background: rgba(var(--tag-yellow-rgb, 234, 179, 8), 0.16);
  border-color: var(--tag-yellow, #EAB308);
}


/* ==========================================================================
   v8.7.05 — Platform shell stability guard
   Keep the native Document Workspace overlay completely inert unless the
   Documents stage is active. This prevents a stale docs overlay/loading layer
   from covering the Platform topbar or leaving a blank black spacer after the
   user returns from File Manager to the pipeline/submission view.
   ========================================================================== */
body:not(.docs-fullwidth) #docs-view-root {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
body.docs-fullwidth #docs-view-root {
  display: grid !important;
  visibility: visible !important;
  pointer-events: auto !important;
}
body:not(.docs-fullwidth) #docs-view-root .loading-overlay,
body:not(.docs-fullwidth) #docs-view-root .drop-overlay,
body:not(.docs-fullwidth) #docs-view-root .preview-modal,
body:not(.docs-fullwidth) #docs-view-root .modal-backdrop {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}


/* v8.7.08 — Universal System Switcher in Document Workspace topbar */
#docs-view-root .stm-system-nav { position: relative; display: inline-flex; align-items: center; z-index: 120; }
#docs-view-root .stm-system-nav-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px;
  border-radius: 999px; font-family: var(--font-mono); font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.09em; text-transform: uppercase; color: var(--signal);
  background: rgba(158,196,255,0.10); border: 1px solid rgba(158,196,255,0.30);
  cursor: pointer; white-space: nowrap;
}
#docs-view-root .stm-system-nav.open .stm-system-nav-btn,
#docs-view-root .stm-system-nav-btn:hover { background: rgba(158,196,255,0.18); border-color: rgba(158,196,255,0.55); }
#docs-view-root .stm-system-nav-menu {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 226px; padding: 7px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border); box-shadow: var(--shadow-lg); display: none; z-index: 9999;
}
#docs-view-root .stm-system-nav.open .stm-system-nav-menu { display: block; }
#docs-view-root .stm-system-nav-menu button {
  width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 9px 10px; border-radius: 8px;
  color: var(--text); background: transparent; font-family: var(--font-mono); font-size: 11px; font-weight: 650;
  letter-spacing: 0.04em; text-align: left; cursor: pointer;
}
#docs-view-root .stm-system-nav-menu button:hover,
#docs-view-root .stm-system-nav-menu button.active { color: var(--signal); background: rgba(158,196,255,0.12); }
@media (max-width: 1180px) { #docs-view-root .stm-system-nav-label { display:none; } }
