/* ==========================================================================
   STAGE 4: SAVED PROFILES BAR, REPORTS LIBRARY DRAWER & EDITORIAL MAGAZINE READER
   Supports both Obsidian (dark) and Vogue (warm ivory) themes + Responsive Mobile
   ========================================================================== */

:root {
  --bg-app: var(--bg-canvas);
  --gold: var(--accent-gold);
  --gold-soft: var(--accent-gold-soft);
  --border-gold: var(--border-hairline);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-sans: 'Manrope', 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

.arcana-popover-card {
  z-index: 1500 !important;
}

.library-top-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  border-color: var(--border-gold);
}

.library-top-btn.active {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold);
}

.library-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--gold-soft);
  border: 1px solid var(--border-gold);
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 800;
}

/* 1. Saved Profiles Quick Switcher Bar */
.saved-profiles-bar {
  margin-bottom: 10px;
}

.profiles-bar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  overflow-x: auto;
  scrollbar-width: thin;
}

.profiles-bar-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

.profiles-pills-track {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 1px;
}

.profile-pill-item {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  transition: all 0.16s ease;
  flex-shrink: 0;
}

.profile-pill-item.active {
  background: var(--gold-soft);
  border-color: var(--gold);
}

.profile-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 11.5px;
  cursor: pointer;
  white-space: nowrap;
}

.profile-pill-item.active .profile-pill-btn strong {
  color: var(--gold);
}

.prof-date {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
}

.prof-rep-cnt {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg-surface);
  border: 1px solid var(--border-gold);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--gold);
}

.profile-del-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  padding: 2px 7px 2px 2px;
  cursor: pointer;
  line-height: 1;
}

.profile-del-btn:hover {
  color: #ef4444;
}

.profiles-save-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

/* 2. Saved Reports Library Drawer Panel */
.library-drawer-panel {
  margin-bottom: 14px;
}

.library-drawer-card {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-gold);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-elevated);
}

.library-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 0;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.library-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 10px;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}

.lib-report-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 13px;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.lib-report-card:hover {
  border-color: var(--border-gold);
}

.lib-report-card.compare-selected {
  border-color: var(--gold);
  background: var(--gold-soft);
}

.lib-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}

.lib-pin-btn,
.lib-del-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  padding: 1px 4px;
  line-height: 1;
}

.lib-card-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 16.5px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
}

.lib-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* 3. Full-Screen Editorial Magazine Report Reader & Side-by-Side Comparator */
.editorial-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(6, 7, 12, 0.82);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.editorial-modal-sheet {
  width: min(1040px, 98vw);
  height: min(92vh, 940px);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  background: var(--bg-app);
  border: 1.5px solid var(--border-gold);
  box-shadow: var(--shadow-elevated);
  overflow: hidden;
}

.editorial-modal-sheet.compare-sheet {
  width: min(1360px, 99vw);
}

.editorial-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.editorial-scroll-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px 40px 32px;
}

.editorial-masthead {
  text-align: center;
  padding: 18px 20px 22px 20px;
  margin-bottom: 18px;
  border-bottom: 2px double var(--border-gold);
  background: linear-gradient(180deg, var(--gold-soft), transparent);
  border-radius: var(--radius-md);
}

.editorial-masthead-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
}

.editorial-masthead-title {
  margin: 0 0 12px 0;
  font-family: var(--font-serif);
  font-size: clamp(24px, 3.2vw, 36px);
  font-weight: 700;
  line-height: 1.15;
  color: var(--text-primary);
}

.editorial-passport-strip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-secondary);
}

.editorial-toc {
  margin-bottom: 22px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
}

.editorial-toc-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.editorial-toc-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.editorial-toc-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.editorial-toc-btn:hover {
  border-color: var(--gold);
}

.toc-num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 800;
  color: var(--gold);
}

.editorial-modal-sheet:not(.compare-sheet) .editorial-chapters-stack,
.editorial-modal-sheet:not(.compare-sheet) .editorial-toc {
  max-width: 780px;
  margin-left: auto;
  margin-right: auto;
}

.editorial-chapters-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.editorial-chapter {
  padding: 20px 24px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
}

.editorial-chapter-kicker {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--gold);
  margin-bottom: 4px;
}

.editorial-chapter-title {
  margin: 0 0 10px 0;
  font-family: var(--font-serif);
  font-size: 23px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.22;
}

.ed-evidence-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.editorial-prose {
  font-size: 15px;
  line-height: 1.72;
  color: var(--text-primary);
  margin-bottom: 14px;
  white-space: pre-line;
}

.editorial-callout-flow,
.editorial-callout-lever {
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  margin-top: 10px;
}

.editorial-callout-flow {
  background: var(--bg-input);
  border-left: 3px solid #10b981;
}

.editorial-callout-lever {
  background: var(--gold-soft);
  border-left: 3px solid var(--gold);
}

.ed-callout-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--gold);
  margin-bottom: 4px;
}

.ed-callout-body {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-primary);
  white-space: pre-line;
}

/* Side-by-Side Comparison Grid */
.ed-compare-selectors-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-input);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.ed-compare-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.ed-compare-cell {
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
}

.ed-compare-cell.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-style: italic;
}

@media (max-width: 820px) {
  .editorial-modal-backdrop {
    padding: 6px;
  }
  .editorial-scroll-body {
    padding: 14px 12px 28px 12px;
  }
  .editorial-chapter {
    padding: 14px 14px;
  }
  .ed-compare-selectors-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .ed-compare-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .profiles-bar-inner {
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 9px;
  }
  .profiles-save-btn {
    margin-left: auto;
    padding: 3px 8px;
    font-size: 11px;
    min-height: 26px;
  }
  .profiles-pills-track {
    order: 3;
    flex: 0 0 100%;
    width: 100%;
  }
  .arcana-mode-switcher .seg-btn {
    font-size: 10.5px;
    padding: 5px 3px;
  }
  .consultant-gender-toggle,
  .alpha-top-btn,
  .library-top-btn {
    white-space: nowrap;
    padding: 3px 6px !important;
    font-size: 10.5px !important;
    min-height: 28px !important;
  }
  .alpha-quota-badge,
  .library-count-badge {
    white-space: nowrap;
    padding: 0 4px;
    font-size: 10px;
  }
}

@media print {
  body > .app-shell > *:not(#editorial-reader-modal) {
    display: none !important;
  }
  .editorial-modal-backdrop {
    position: static !important;
    background: none !important;
    padding: 0 !important;
  }
  .editorial-modal-sheet {
    width: 100% !important;
    height: auto !important;
    border: none !important;
    box-shadow: none !important;
  }
  .editorial-topbar {
    display: none !important;
  }
  .editorial-scroll-body {
    overflow: visible !important;
    padding: 0 !important;
  }
}

.top-settings-popover {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 1100; width: 310px;
  display: flex; flex-direction: column; gap: 10px; padding: 12px 14px;
  border-radius: 12px; background: var(--bg-elevated); border: 1px solid var(--gold);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.72);
}
.settings-pop-row { display: flex; flex-direction: column; gap: 4px; }
.settings-pop-label { font-size: 11px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; }
.library-modal-sheet {
  width: min(1080px, 95vw); max-height: 86vh; overflow-y: auto; margin: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85);
}


