/* SBU Library Bento — Prototype Dashboard
 * All selectors prefixed .proto-* to guarantee zero collision with production .sbu-*
 * Synthesized from two design critiques (modern dashboard + patron workflow).
 * v0.2.0 — full dashboard with sidebar/results/detail-rail layout.
 */

/* ------------------------------------------------------------------ *
   1. RESET / TOKENS
 * ------------------------------------------------------------------ */
.proto-app {
  /* Color tokens — light theme */
  --p-bg: #f7f7f8;
  --p-surface: #ffffff;
  --p-surface-2: #fafafa;
  --p-surface-hover: #f3f4f6;
  --p-border: #e5e7eb;
  --p-border-strong: #d1d5db;
  --p-ink: #111827;
  --p-ink-2: #374151;
  --p-muted: #6b7280;
  --p-muted-2: #9ca3af;
  --p-accent: #990000;
  --p-accent-soft: #fef2f2;
  --p-accent-hover: #7a0000;
  --p-link: #1d4ed8;
  --p-shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --p-shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --p-shadow-lg: 0 12px 32px rgba(0,0,0,0.12);
  --p-radius: 8px;
  --p-radius-sm: 6px;
  --p-radius-lg: 12px;

  /* Quality flag colors */
  --p-flag-peer: #1e3a8a;        /* navy */
  --p-flag-peer-bg: #dbeafe;
  --p-flag-oa: #14532d;          /* green */
  --p-flag-oa-bg: #dcfce7;
  --p-flag-online: #581c87;      /* purple */
  --p-flag-online-bg: #f3e8ff;
  --p-flag-print: #92400e;       /* brown */
  --p-flag-print-bg: #fef3c7;

  /* Source accents */
  --p-src-articles: #0ea5e9;
  --p-src-catalog: #8b5cf6;
  --p-src-journals: #f59e0b;
  --p-src-website: #10b981;

  /* Sizing */
  --p-side-w: 240px;
  --p-rail-w: 360px;
  --p-row-pad: 14px;
  --p-row-pad-compact: 8px;

  font-family: "Effra", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--p-bg);
  color: var(--p-ink);
  font-size: 14px;
  line-height: 1.5;
  min-height: 70vh;
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-lg);
  overflow: hidden;
  box-shadow: var(--p-shadow-md);
}

.proto-app, .proto-app *, .proto-app *::before, .proto-app *::after { box-sizing: border-box; }

.proto-app[data-theme="dark"] {
  --p-bg: #0f1115;
  --p-surface: #16181d;
  --p-surface-2: #1c1f26;
  --p-surface-hover: #232730;
  --p-border: #2a2e38;
  --p-border-strong: #353a45;
  --p-ink: #e5e7eb;
  --p-ink-2: #d1d5db;
  --p-muted: #9ca3af;
  --p-muted-2: #6b7280;
  --p-accent: #ef4444;
  --p-accent-soft: rgba(239, 68, 68, 0.12);
  --p-accent-hover: #dc2626;
  --p-link: #60a5fa;
  --p-flag-peer-bg: rgba(59, 130, 246, 0.18);
  --p-flag-peer: #93c5fd;
  --p-flag-oa-bg: rgba(16, 185, 129, 0.18);
  --p-flag-oa: #6ee7b7;
  --p-flag-online-bg: rgba(168, 85, 247, 0.18);
  --p-flag-online: #d8b4fe;
  --p-flag-print-bg: rgba(245, 158, 11, 0.18);
  --p-flag-print: #fcd34d;
}

.proto-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* CRITICAL: the [hidden] HTML attribute only sets display:none via the UA
   stylesheet, which loses to any custom display rule (display:flex, grid, etc.).
   This rule re-asserts it across the whole app so .hidden = true actually works. */
.proto-app [hidden] { display: none !important; }

/* Reset buttons inside the app to defeat theme styles */
.proto-app button {
  font-family: inherit;
  font-size: inherit;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  color: inherit;
  box-shadow: none !important;
  text-transform: none;
  letter-spacing: normal;
  line-height: 1.4;
}

.proto-app input, .proto-app select { font: inherit; color: inherit; }
.proto-app a { color: var(--p-link); text-decoration: none; }
.proto-app a:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ *
   2. TOP BAR
 * ------------------------------------------------------------------ */
.proto-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  background: var(--p-surface);
  border-bottom: 1px solid var(--p-border);
}
.proto-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 13px; color: var(--p-ink); letter-spacing: 0.01em; }
.proto-brand-mark {
  background: var(--p-accent);
  color: #fff;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
}
.proto-brand-text { color: var(--p-muted); font-weight: 500; font-size: 12px; }
.proto-utility { display: flex; gap: 6px; }
.proto-util-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: var(--p-radius-sm);
  color: var(--p-muted);
  transition: background 0.12s, color 0.12s;
}
.proto-util-btn:hover { background: var(--p-surface-hover); color: var(--p-ink); }
.proto-util-kbd {
  font-size: 10px;
  padding: 1px 5px;
  background: var(--p-surface-hover);
  border: 1px solid var(--p-border);
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  color: var(--p-ink-2);
}

/* ------------------------------------------------------------------ *
   3. SEARCH RAIL
 * ------------------------------------------------------------------ */
.proto-search-rail {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 16px 18px;
  background: var(--p-surface);
  border-bottom: 1px solid var(--p-border);
}
.proto-searchbar {
  display: flex;
  align-items: stretch;
  gap: 6px;
  padding: 5px;
  border: 1.5px solid var(--p-border-strong);
  border-radius: var(--p-radius);
  background: var(--p-surface);
  transition: border-color 0.12s, box-shadow 0.12s;
  max-width: 1100px;
  margin: 0 auto;
}
.proto-searchbar:focus-within {
  border-color: var(--p-accent);
  box-shadow: 0 0 0 4px rgba(153, 0, 0, 0.08);
}
.proto-mic-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--p-radius-sm);
  color: var(--p-muted);
  transition: background 0.12s, color 0.12s;
}
.proto-mic-btn:hover { background: var(--p-surface-hover); color: var(--p-ink); }
.proto-mic-btn.proto-listening {
  background: var(--p-accent-soft);
  color: var(--p-accent);
  animation: protoPulse 1.2s ease-in-out infinite;
}
@keyframes protoPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }

.proto-q {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 8px 8px;
  font-size: 15px;
  outline: none;
  color: var(--p-ink);
}
.proto-q::placeholder { color: var(--p-muted-2); }

.proto-ai-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: var(--p-radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--p-muted);
  user-select: none;
  position: relative;
  transition: background 0.12s, color 0.12s;
}
.proto-ai-toggle:hover { background: var(--p-surface-hover); color: var(--p-ink); }
.proto-ai-toggle input { width: 14px; height: 14px; accent-color: var(--p-accent); margin: 0; }
.proto-ai-toggle:has(input:checked) {
  background: var(--p-accent-soft);
  color: var(--p-accent);
}
.proto-ai-spark { color: inherit; opacity: 0.85; }

.proto-submit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: var(--p-accent);
  color: #fff;
  border-radius: var(--p-radius-sm);
  font-size: 13px;
  font-weight: 700;
  transition: background 0.12s;
}
.proto-submit:hover { background: var(--p-accent-hover); }
.proto-submit:focus-visible { outline: 2px solid #fff; outline-offset: -3px; }

/* Identifier banner */
.proto-id-banner {
  margin: 10px auto 0;
  max-width: 1100px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--p-flag-online-bg);
  color: var(--p-flag-online);
  border-radius: var(--p-radius-sm);
  font-size: 13px;
}
.proto-id-icon { display: inline-flex; }
.proto-id-text .proto-id-type { font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; font-size: 11px; padding: 1px 6px; background: rgba(255,255,255,0.5); border-radius: 3px; }
.proto-id-value {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 12px;
  background: rgba(255,255,255,0.5);
  padding: 2px 6px;
  border-radius: 3px;
}
.proto-id-cta {
  margin-left: auto;
  padding: 6px 12px;
  background: var(--p-accent);
  color: #fff;
  border-radius: var(--p-radius-sm);
  font-size: 12px;
  font-weight: 700;
  transition: background 0.12s;
}
.proto-id-cta:hover { background: var(--p-accent-hover); }

/* Suggest dropdown */
.proto-suggest {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: calc(100% - 4px);
  width: calc(100% - 36px);
  max-width: 1100px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius);
  box-shadow: var(--p-shadow-lg);
  z-index: 60;
}
.proto-suggest-section { padding: 6px; }
.proto-suggest-section + .proto-suggest-section { border-top: 1px solid var(--p-border); }
.proto-suggest-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--p-muted);
  padding: 6px 10px 4px;
}
.proto-suggest-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--p-radius-sm);
  font-size: 13px;
  color: var(--p-ink);
}
.proto-suggest-item:hover, .proto-suggest-item.proto-active {
  background: var(--p-surface-hover);
}
.proto-suggest-icon { color: var(--p-muted); flex: 0 0 auto; }
.proto-suggest-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proto-suggest-kind {
  font-size: 10px;
  font-weight: 700;
  color: var(--p-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  background: var(--p-surface-hover);
  border-radius: 3px;
  flex: 0 0 auto;
}

/* ------------------------------------------------------------------ *
   4. MAIN LAYOUT (sidebar | results | detail-rail)
 * ------------------------------------------------------------------ */
.proto-main {
  display: grid;
  grid-template-columns: var(--p-side-w) 1fr var(--p-rail-w);
  min-height: 60vh;
}
@media (max-width: 1240px) {
  .proto-app { --p-rail-w: 320px; }
}
@media (max-width: 1080px) {
  .proto-main { grid-template-columns: var(--p-side-w) 1fr; }
  .proto-detail-rail { display: none; }
}
@media (max-width: 760px) {
  .proto-main { grid-template-columns: 1fr; }
  .proto-sidebar { display: none; }
}

/* ------------------------------------------------------------------ *
   5. SIDEBAR
 * ------------------------------------------------------------------ */
.proto-sidebar {
  border-right: 1px solid var(--p-border);
  background: var(--p-surface-2);
  padding: 14px 14px 24px;
  overflow-y: auto;
  max-height: calc(100vh - 140px);
  position: sticky;
  top: 88px;
}
.proto-side-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 800;
  color: var(--p-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 4px 10px;
}
.proto-clear-filters {
  font-size: 11px;
  font-weight: 600;
  color: var(--p-accent);
  text-transform: none;
  letter-spacing: normal;
  padding: 2px 6px;
  border-radius: 3px;
}
.proto-clear-filters:hover { background: var(--p-accent-soft); }

.proto-filter-group {
  border: none;
  margin-bottom: 4px;
}
.proto-filter-group summary {
  list-style: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--p-ink);
  padding: 8px 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--p-radius-sm);
}
.proto-filter-group summary::-webkit-details-marker { display: none; }
.proto-filter-group summary::before {
  content: "▸";
  color: var(--p-muted);
  font-size: 10px;
  transition: transform 0.15s;
}
.proto-filter-group[open] summary::before { transform: rotate(90deg); }
.proto-filter-group summary:hover { background: var(--p-surface-hover); }
.proto-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 18px;
  font-size: 13px;
  color: var(--p-ink-2);
  cursor: pointer;
  border-radius: 4px;
}
.proto-check:hover { background: var(--p-surface-hover); }
.proto-check input { width: 14px; height: 14px; accent-color: var(--p-accent); flex: 0 0 auto; }
.proto-check span:nth-of-type(1) { flex: 1; }
.proto-side-count { font-size: 11px; color: var(--p-muted); font-variant-numeric: tabular-nums; }

.proto-sort {
  display: block;
  width: calc(100% - 12px);
  margin: 4px 6px 4px 18px;
  padding: 6px 8px;
  border: 1px solid var(--p-border-strong);
  border-radius: 4px;
  background: var(--p-surface);
  font-size: 13px;
}
.proto-side-link {
  display: block;
  padding: 5px 6px 5px 18px;
  font-size: 12px;
  color: var(--p-link);
  border-radius: 4px;
}
.proto-side-link:hover { background: var(--p-surface-hover); text-decoration: none; }

/* ------------------------------------------------------------------ *
   6. RESULTS PANE
 * ------------------------------------------------------------------ */
.proto-results-pane {
  padding: 0 18px 100px;
  min-width: 0; /* prevent grid blowout */
  overflow-x: hidden;
}

/* Source segmented tabs */
.proto-source-tabs {
  display: flex;
  gap: 2px;
  padding: 12px 0 8px;
  border-bottom: 1px solid var(--p-border);
  position: sticky;
  top: 132px;
  background: var(--p-bg);
  z-index: 20;
}
.proto-source-tab {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--p-muted);
  border-radius: var(--p-radius-sm) var(--p-radius-sm) 0 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.proto-source-tab:hover { color: var(--p-ink); background: var(--p-surface-hover); }
.proto-source-tab.active {
  color: var(--p-accent);
  border-bottom-color: var(--p-accent);
}
.proto-tab-count {
  margin-left: 4px;
  padding: 1px 6px;
  background: var(--p-surface-hover);
  color: var(--p-muted);
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.proto-source-tab.active .proto-tab-count {
  background: var(--p-accent-soft);
  color: var(--p-accent);
}

/* Toolbar */
.proto-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  font-size: 12px;
}
.proto-toolbar-left { display: flex; align-items: center; gap: 12px; }
.proto-result-count { color: var(--p-muted); font-weight: 600; }
.proto-active-filters { display: flex; gap: 4px; flex-wrap: wrap; }
.proto-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px 2px 8px;
  background: var(--p-accent-soft);
  color: var(--p-accent);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.proto-filter-chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  color: var(--p-accent);
}
.proto-filter-chip-x:hover { background: rgba(153,0,0,0.15); }
.proto-toolbar-right { display: flex; gap: 2px; }
.proto-density-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: var(--p-muted);
  border-radius: 4px;
}
.proto-density-btn:hover { background: var(--p-surface-hover); color: var(--p-ink); }
.proto-density-btn.active { background: var(--p-accent-soft); color: var(--p-accent); }

/* Did-you-mean */
.proto-dym {
  margin: 0 0 12px;
  padding: 10px 14px;
  background: #fef9c3;
  color: #713f12;
  border-radius: var(--p-radius-sm);
  font-size: 13px;
}
.proto-app[data-theme="dark"] .proto-dym { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
.proto-dym a { color: inherit; font-weight: 700; }

/* Empty state */
.proto-status { padding: 40px 0 20px; }
.proto-empty h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--p-ink);
}
.proto-empty p { color: var(--p-muted); font-size: 14px; margin: 0 0 14px; }
.proto-empty h3 {
  font-size: 11px;
  font-weight: 800;
  color: var(--p-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 24px 0 10px;
}
.proto-examples { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.proto-example, .proto-recent-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: 16px;
  font-size: 13px;
  color: var(--p-ink-2);
  transition: all 0.12s;
}
.proto-example:hover, .proto-recent-chip:hover {
  border-color: var(--p-accent);
  color: var(--p-accent);
  background: var(--p-accent-soft);
}
.proto-recent-chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* Source group */
.proto-source-group {
  margin-bottom: 20px;
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius);
  overflow: hidden;
}
.proto-source-group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--p-surface-2);
  border-bottom: 1px solid var(--p-border);
}
.proto-source-group-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--p-ink);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.proto-source-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.proto-source-dot[data-source="articles"] { background: var(--p-src-articles); }
.proto-source-dot[data-source="catalog"]  { background: var(--p-src-catalog); }
.proto-source-dot[data-source="journals"] { background: var(--p-src-journals); }
.proto-source-dot[data-source="website"]  { background: var(--p-src-website); }
.proto-source-group-total {
  font-size: 11px;
  color: var(--p-muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-transform: none;
  letter-spacing: 0;
}
.proto-source-group-actions { display: flex; gap: 6px; }
.proto-see-all {
  font-size: 12px;
  color: var(--p-link);
  font-weight: 600;
}
.proto-load-more {
  display: block;
  width: 100%;
  padding: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--p-accent);
  background: var(--p-surface-2);
  border-top: 1px solid var(--p-border);
  text-align: center;
  transition: background 0.12s;
}
.proto-load-more:hover { background: var(--p-accent-soft); }
.proto-load-more:disabled { color: var(--p-muted); cursor: not-allowed; }

/* Result row (card) */
.proto-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 12px;
  padding: var(--p-row-pad) 16px;
  border-bottom: 1px solid var(--p-border);
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
}
.proto-row:last-child { border-bottom: none; }
.proto-row:hover { background: var(--p-accent-soft); }
.proto-row.proto-row-active {
  background: var(--p-accent-soft);
  box-shadow: inset 3px 0 0 var(--p-accent);
}
.proto-row.proto-row-saved::after {
  content: "★";
  position: absolute;
  top: 8px;
  right: 8px;
  color: #f59e0b;
  font-size: 14px;
}

.proto-app[data-density="compact"] .proto-row { padding: var(--p-row-pad-compact) 16px; gap: 10px; }
.proto-app[data-density="compact"] .proto-row-creator,
.proto-app[data-density="compact"] .proto-row-meta { font-size: 11px; }
.proto-app[data-density="compact"] .proto-row-actions { opacity: 0.4; }
.proto-app[data-density="compact"] .proto-row:hover .proto-row-actions { opacity: 1; }

.proto-row-check {
  display: inline-flex;
  align-items: flex-start;
  padding-top: 3px;
}
.proto-row-check input { width: 16px; height: 16px; accent-color: var(--p-accent); cursor: pointer; }

.proto-row-body { min-width: 0; }
.proto-row-title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--p-ink);
  text-decoration: none;
  line-height: 1.4;
  margin-bottom: 4px;
}
.proto-row-title:hover { color: var(--p-accent); text-decoration: underline; }
.proto-row-creator {
  font-size: 12px;
  color: var(--p-muted);
  margin-bottom: 4px;
}
.proto-row-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--p-muted);
}
.proto-row-meta-source { color: var(--p-ink-2); font-weight: 500; }
.proto-row-meta-dot { color: var(--p-muted-2); }

/* Quality flags */
.proto-flags { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.proto-flag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 3px;
  white-space: nowrap;
}
.proto-flag-peer    { background: var(--p-flag-peer-bg);   color: var(--p-flag-peer); }
.proto-flag-oa      { background: var(--p-flag-oa-bg);     color: var(--p-flag-oa); }
.proto-flag-online  { background: var(--p-flag-online-bg); color: var(--p-flag-online); }
.proto-flag-print   { background: var(--p-flag-print-bg);  color: var(--p-flag-print); }

/* Row actions */
.proto-row-actions {
  display: flex;
  gap: 4px;
  align-items: flex-start;
  flex-shrink: 0;
}
.proto-row-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 4px;
  color: var(--p-muted);
  transition: background 0.12s, color 0.12s;
}
.proto-row-action:hover { background: var(--p-surface-hover); color: var(--p-accent); }
.proto-row-action.proto-row-action-saved { color: #f59e0b; }
.proto-row-action svg { width: 14px; height: 14px; }

/* Skeletons */
.proto-skeleton-group {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius);
  margin-bottom: 16px;
  overflow: hidden;
}
.proto-skeleton-head { padding: 12px 16px; background: var(--p-surface-2); border-bottom: 1px solid var(--p-border); }
.proto-skeleton-row { padding: 14px 16px; border-bottom: 1px solid var(--p-border); }
.proto-skeleton-row:last-child { border-bottom: none; }
.proto-skel-bar {
  height: 12px;
  background: linear-gradient(90deg, var(--p-surface-hover) 0%, var(--p-border) 50%, var(--p-surface-hover) 100%);
  background-size: 200% 100%;
  animation: protoShimmer 1.4s ease-in-out infinite;
  border-radius: 4px;
  margin-bottom: 8px;
}
.proto-skel-bar:last-child { margin-bottom: 0; }
.proto-skel-bar.w70 { width: 70%; }
.proto-skel-bar.w40 { width: 40%; }
.proto-skel-bar.w90 { width: 90%; }
@keyframes protoShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* No-results per group */
.proto-no-results-group {
  padding: 18px 16px;
  text-align: center;
  color: var(--p-muted);
  font-size: 13px;
  font-style: italic;
}

/* Footer */
.proto-footer {
  margin-top: 24px;
  padding: 16px 0;
  border-top: 1px solid var(--p-border);
  text-align: center;
}
.proto-footer a { font-weight: 600; }

/* ------------------------------------------------------------------ *
   7. DETAIL RAIL
 * ------------------------------------------------------------------ */
.proto-detail-rail {
  border-left: 1px solid var(--p-border);
  background: var(--p-surface);
  overflow-y: auto;
  max-height: calc(100vh - 140px);
  position: sticky;
  top: 88px;
}
.proto-detail-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 30px;
  text-align: center;
  color: var(--p-muted);
  height: 100%;
}
.proto-detail-empty svg { color: var(--p-border-strong); margin-bottom: 14px; }
.proto-detail-empty-title { font-size: 14px; font-weight: 600; color: var(--p-ink-2); margin: 0 0 4px; }
.proto-detail-empty-hint { font-size: 12px; color: var(--p-muted); margin: 0; }

.proto-detail { padding: 0; }
.proto-detail-head {
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--p-border);
}
.proto-detail-source {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--p-muted);
  margin-bottom: 8px;
}
.proto-detail-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--p-ink);
  line-height: 1.35;
  margin: 0 0 8px;
}
.proto-detail-title a { color: inherit; }
.proto-detail-creator {
  font-size: 13px;
  color: var(--p-muted);
  margin: 0 0 8px;
}
.proto-detail-flags { margin-top: 10px; }

.proto-detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--p-border);
}
.proto-detail-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  background: var(--p-surface-2);
  color: var(--p-ink-2);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-sm);
  transition: all 0.12s;
}
.proto-detail-action:hover { background: var(--p-accent); color: #fff; border-color: var(--p-accent); }
.proto-detail-action.proto-primary {
  background: var(--p-accent);
  color: #fff;
  border-color: var(--p-accent);
  grid-column: span 2;
}
.proto-detail-action.proto-primary:hover { background: var(--p-accent-hover); }
.proto-detail-action.proto-saved-active { background: #fef3c7; color: #92400e; border-color: #fbbf24; }

.proto-detail-section {
  padding: 14px 20px;
  border-bottom: 1px solid var(--p-border);
}
.proto-detail-section:last-child { border-bottom: none; }
.proto-detail-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--p-muted);
  margin-bottom: 6px;
}
.proto-detail-abstract {
  font-size: 13px;
  line-height: 1.55;
  color: var(--p-ink-2);
  max-height: 260px;
  overflow-y: auto;
}
.proto-detail-abstract.proto-loading { color: var(--p-muted); font-style: italic; }
.proto-detail-meta-list { font-size: 12px; color: var(--p-ink-2); }
.proto-detail-meta-list dt { font-weight: 600; color: var(--p-muted); }
.proto-detail-meta-list dd { margin: 0 0 6px; }

/* Cite tabs in detail */
.proto-cite-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--p-border); margin-bottom: 8px; }
.proto-cite-tab {
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--p-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.proto-cite-tab:hover { color: var(--p-ink); }
.proto-cite-tab.active { color: var(--p-accent); border-bottom-color: var(--p-accent); }
.proto-cite-pre {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 11px;
  background: var(--p-surface-2);
  padding: 10px;
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
  color: var(--p-ink-2);
}
.proto-cite-copy {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  background: var(--p-surface-2);
  color: var(--p-ink-2);
  border: 1px solid var(--p-border);
  border-radius: 4px;
}
.proto-cite-copy:hover { background: var(--p-accent); color: #fff; border-color: var(--p-accent); }
.proto-cite-copy.proto-copied { background: #16a34a; color: #fff; border-color: #16a34a; }

/* ------------------------------------------------------------------ *
   8. SAVED DOCK
 * ------------------------------------------------------------------ */
.proto-saved-dock {
  position: sticky;
  bottom: 0;
  z-index: 40;
  background: var(--p-surface);
  border-top: 1px solid var(--p-border);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.06);
  margin-top: -1px;
}
.proto-saved-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  gap: 12px;
}
.proto-saved-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--p-ink);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.proto-saved-count::before { content: ""; }
.proto-saved-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.proto-saved-actions button {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  background: var(--p-surface-2);
  color: var(--p-ink-2);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-sm);
  transition: all 0.12s;
}
.proto-saved-actions button:hover {
  background: var(--p-accent);
  color: #fff;
  border-color: var(--p-accent);
}
.proto-saved-actions button.proto-saved-clear {
  background: transparent;
  border-color: transparent;
  color: var(--p-muted);
}
.proto-saved-actions button.proto-saved-clear:hover {
  background: transparent;
  color: var(--p-accent);
  border-color: transparent;
  text-decoration: underline;
}

/* ------------------------------------------------------------------ *
   9. OVERLAYS (palette + help)
 * ------------------------------------------------------------------ */
.proto-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}
.proto-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 17, 21, 0.6);
  backdrop-filter: blur(2px);
}
.proto-overlay-modal {
  position: relative;
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-lg);
  box-shadow: var(--p-shadow-lg);
  width: 100%;
  max-width: 560px;
  margin: 0 16px;
  overflow: hidden;
  color: var(--p-ink);
}
.proto-palette-input {
  width: 100%;
  padding: 14px 18px;
  font-size: 15px;
  border: 0;
  border-bottom: 1px solid var(--p-border);
  outline: none;
  background: transparent;
}
.proto-palette-list {
  max-height: 360px;
  overflow-y: auto;
  padding: 6px;
}
.proto-palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--p-ink-2);
  border-radius: var(--p-radius-sm);
}
.proto-palette-item:hover, .proto-palette-item.proto-active {
  background: var(--p-surface-hover);
  color: var(--p-ink);
}
.proto-palette-item-kind {
  margin-left: auto;
  font-size: 10px;
  color: var(--p-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}
.proto-palette-empty {
  padding: 30px 16px;
  text-align: center;
  color: var(--p-muted);
  font-size: 13px;
}

.proto-help-modal { max-width: 480px; padding: 0; }
.proto-help-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--p-border);
}
.proto-help-head h2 { font-size: 15px; font-weight: 700; margin: 0; }
.proto-help-close { font-size: 22px; color: var(--p-muted); padding: 0 6px; }
.proto-help-close:hover { color: var(--p-ink); }
.proto-help-dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 20px;
  padding: 18px 20px 22px;
  margin: 0;
  font-size: 13px;
}
.proto-help-dl dt { display: flex; gap: 4px; align-items: center; }
.proto-help-dl dd { margin: 0; color: var(--p-ink-2); }
.proto-help-dl kbd {
  display: inline-block;
  padding: 2px 7px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  background: var(--p-surface-2);
  border: 1px solid var(--p-border);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--p-ink);
}

/* ------------------------------------------------------------------ *
   10. TOAST
 * ------------------------------------------------------------------ */
.proto-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #111827;
  color: #fff;
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--p-shadow-lg);
  z-index: 1100;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.proto-toast.proto-toast-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
