/* Footcheck taskpane — cards, tables, badges, accordions */

/* Import fonts */
@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

:root {
  --bg: #ffffff;
  --bg-cream: #F9F7F1;           /* Legal pad cream - paper color */
  --bg-charcoal: #2A2A3A;        /* Charcoal for sidebar */
  --bg-charcoal-light: #3A3A4A;  /* Lighter charcoal for hover */
  --text-charcoal: #1A1A2E;      /* Deep charcoal text */
  --muted: #6b7280;
  --border: #e5e7eb;
  --border-dark: #4A4A5A;        /* Border for dark backgrounds */
  --card-bg: #f9fafb;
  --card-hover: #f3f4f6;
  --accent: #A83232;             /* Cinnabar/Dried Ink */
  --positive: #16a34a;
  --negative: #dc2626;
  --neutral: #6b7280;
  --warn: #d97706;
  --radius: 10px;
  
  /* Rubrication color palette - muted tones */
  --rubric-primary: #A83232;      /* Cinnabar/Dried Ink */
  --rubric-secondary: #8B2828;    /* Darker dried ink */
  --rubric-accent: #6B1F1F;       /* Deep dried ink */
  --rubric-light: #F5E6E6;        /* Light warm tint */
  --rubric-muted: #D4A5A5;        /* Muted red */
  --earth-primary: #92400e;        /* Brown */
  --earth-secondary: #78350f;      /* Darker brown */
  --earth-accent: #451a03;         /* Darkest brown */
  --earth-light: #fde68a;          /* Light brown */
  --earth-muted: #fbbf24;          /* Muted brown */
}

* { box-sizing: border-box; }
body { 
  font-family: 'Century Schoolbook', 'EB Garamond', 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, serif;
  padding: 12px; 
  color: var(--text-charcoal); 
  background: var(--bg-cream);
  margin: 0;
  height: 100vh;
  overflow: hidden; /* Prevent body scroll - let content areas scroll instead */
  display: flex;
  flex-direction: column;
}

/* Headings use Centaur-style font */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Centaur', 'EB Garamond', 'Palatino Linotype', Georgia, serif;
}

/* App Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0; /* Prevent header from shrinking */
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-left h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-charcoal);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Credit Display */
.credit-display {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 13px;
}

.credit-label {
  color: var(--muted);
  font-weight: 500;
}

.credit-bar-container {
  width: 60px;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}

.credit-bar-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease, background-color 0.3s ease;
  border-radius: 4px;
}

.credit-bar-fill.warning {
  background: var(--warn);
}

.credit-bar-fill.low {
  background: var(--negative);
}

.credit-amount {
  font-weight: 600;
  min-width: 48px;
  text-align: right;
}

.credit-amount.warning {
  color: var(--warn);
}

.credit-amount.low {
  color: var(--negative);
}

.btn-text {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 14px;
}

.btn-text:hover {
  color: var(--accent);
}

/* Sidebar Credit Display */
.sidebar-credit-display {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-credit-display .credit-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-credit-display .credit-label {
  font-size: 13px;
  color: var(--muted);
}

.sidebar-credit-display .credit-amount {
  font-size: 16px;
  font-weight: 700;
  color: #111827;
}

.sidebar-credit-display .credit-amount.warning {
  color: var(--warn);
}

.sidebar-credit-display .credit-amount.low {
  color: var(--negative);
}

.sidebar-credit-bar {
  width: 100%;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}

.btn-full {
  width: 100%;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.user-email {
  color: var(--muted);
  font-size: 13px;
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
}

h3 { margin: 0 0 8px; }
h4 { margin: 0 0 12px; color: var(--accent); }
h5 { margin: 16px 0 8px; color: var(--muted); font-size: 14px; font-weight: 600; }
#status { 
  font-size: 12px; 
  color: var(--muted); 
  margin-bottom: 8px;
  flex-shrink: 0; /* Prevent status from shrinking */
}

/* Authentication Overlay and Modal Styles */
.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.auth-modal {
  max-width: 360px;
  width: 90%;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-modal h4 {
  margin-top: 0;
  margin-bottom: 24px;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  color: var(--rubric-primary);
}

.auth-input-group {
  margin-bottom: 20px;
}

.auth-input-group input {
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
}

.auth-input-group input:last-child {
  margin-bottom: 0;
}

.auth-input-group input:focus {
  outline: none;
  border-color: var(--rubric-primary);
  box-shadow: 0 0 0 2px rgba(185, 28, 28, 0.1);
}

.auth-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-buttons button {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.auth-buttons .btn-primary {
  background: var(--rubric-primary);
  color: white;
}

.auth-buttons .btn-primary:hover {
  background: var(--rubric-secondary);
}

.auth-buttons .btn-secondary {
  background: var(--card-bg);
  color: var(--muted);
  border: 1px solid var(--border);
}

.auth-buttons .btn-secondary:hover {
  background: var(--card-hover);
}

.auth-error {
  margin-top: 12px;
  padding: 8px 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  color: #dc2626;
  font-size: 12px;
}

.auth-success {
  margin-top: 12px;
  padding: 8px 12px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  color: var(--positive);
  font-size: 12px;
}

.auth-loading {
  margin-top: 12px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.loading-spinner-small {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--rubric-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Loading Overlay Styles */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10001;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s ease-out;
}

.loading-overlay.hidden {
  display: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.loading-modal {
  max-width: 400px;
  width: 90%;
  padding: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  animation: modalSlideIn 0.3s ease-out;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  margin: 0 auto 24px;
  border: 4px solid var(--border);
  border-top-color: var(--rubric-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-modal h4 {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 600;
  color: var(--rubric-primary);
}

.loading-message {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 16px;
}

.loading-timeout {
  margin-top: 24px;
  padding: 16px;
  background: #fef2f2;
  border: 1px solid var(--rubric-light);
  border-radius: 8px;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.loading-timeout p {
  margin: 0 0 12px;
  color: var(--rubric-primary);
  font-size: 14px;
  font-weight: 500;
}

.loading-timeout p:last-of-type {
  margin-bottom: 16px;
}

.loading-timeout button {
  width: 100%;
}

.engine-loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(4px);
  z-index: 9999;
  transition: opacity 0.25s ease;
  opacity: 1;
}

.engine-loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.engine-loading-card {
  background: #ffffff;
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
  width: min(420px, 90%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.engine-loading-spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 4px solid rgba(185, 28, 28, 0.15);
  border-top-color: var(--rubric-primary);
  animation: fc-spin 1s linear infinite;
}

/* Inline parse overlay - similar styling to engine loading overlay */
.inline-parse-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(4px);
  z-index: 9999;
  transition: opacity 0.25s ease;
  opacity: 1;
}

.inline-parse-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.inline-parse-card {
  background: #ffffff;
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
  width: min(420px, 90%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.inline-parse-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(185, 28, 28, 0.15);
  border-top-color: var(--rubric-primary);
  border-radius: 50%;
  animation: fc-spin 1s linear infinite;
}

.inline-parse-status {
  font-size: 18px;
  font-weight: 600;
  color: #111827;
}

.inline-parse-detail {
  font-size: 14px;
  color: var(--muted);
  min-height: 20px;
}

.inline-parse-progress {
  font-size: 14px;
  font-weight: 500;
  color: #475569;
  margin-top: 8px;
}

.engine-loading-status {
  font-size: 18px;
  font-weight: 600;
  color: #111827;
}

.engine-loading-detail {
  font-size: 14px;
  color: var(--muted);
  min-height: 20px;
}

.engine-loading-retry {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
}

.engine-loading-retry.visible {
  display: inline-flex;
}

.engine-loading-retry:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

@keyframes fc-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Footnote Group Headers - Collapsible */
.footnote-group-header {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 16px 0 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  position: relative;
}

.footnote-group-header:hover {
  background: var(--card-hover);
  border-color: var(--rubric-primary);
  box-shadow: 0 2px 6px rgba(185, 28, 28, 0.1);
  transform: translateY(-1px);
}

.footnote-group-header:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.footnote-group-header:focus {
  outline: 2px solid var(--rubric-primary);
  outline-offset: 2px;
}

.footnote-group-header:focus:not(:focus-visible) {
  outline: none;
}

.footnote-group-header[aria-expanded="true"] {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-color: var(--border);
  box-shadow: 0 2px 6px rgba(185, 28, 28, 0.1);
}

.footnote-group-header[aria-expanded="true"]::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}

/* Level-specific header styling */
.footnote-group-header[data-level="1"] {
  border-left: 3px solid var(--rubric-primary);
  background: #fef2f2;
}

.footnote-group-header[data-level="2"] {
  border-left: 3px solid var(--rubric-secondary);
  background: #fef2f2;
}

.footnote-group-header[data-level="3"] {
  border-left: 3px solid var(--earth-primary);
  background: #fffbeb;
}

.footnote-group-header[data-level="4"] {
  border-left: 3px solid var(--earth-secondary);
  background: #fffbeb;
}

.footnote-group-header .header-content {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
}

.footnote-group-header .chev {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 18px;
  color: var(--text-charcoal);
  font-weight: bold;
  min-width: 18px;
  text-align: center;
}

.footnote-group-header[aria-expanded="true"] .chev {
  transform: rotate(90deg);
}

.footnote-group-header .header-text {
  flex: 1;
}

.footnote-group-header .header-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-charcoal);
  margin: 0 0 4px;
  line-height: 1.3;
}

.footnote-group-header .header-meta {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
  line-height: 1.4;
}

.footnote-group-header .header-count {
  background: var(--rubric-primary);
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  min-width: 24px;
  text-align: center;
  box-shadow: 0 1px 2px rgba(185, 28, 28, 0.08);
}

/* Footnote group content container */
.footnote-group-content {
  background: white;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  position: relative;
}

.footnote-group-content:not(.show) {
  display: none;
  opacity: 0;
  transform: translateY(-10px);
}

.footnote-group-content.show {
  opacity: 1;
  transform: translateY(0);
}

.footnote-group-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}

/* Nested headers within content containers */
.footnote-group-content .footnote-group-header {
  margin: 8px 0;
  border-left: 3px solid var(--rubric-light);
  background: #fefefe;
}

.footnote-group-content .footnote-group-header[data-level="2"] {
  border-left-color: var(--rubric-muted);
  margin-left: 16px;
}

.footnote-group-content .footnote-group-header[data-level="3"] {
  border-left-color: var(--earth-light);
  margin-left: 32px;
}

.footnote-group-content .footnote-group-header[data-level="4"] {
  border-left-color: var(--earth-muted);
  margin-left: 48px;
}

/* Nested content containers */
.footnote-group-content .footnote-group-content {
  margin: 8px 0 8px 16px;
  border-left: 2px solid var(--rubric-light);
  background: #fefefe;
  position: relative;
}

.footnote-group-content .footnote-group-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: -16px;
  width: 16px;
  height: 2px;
  background: var(--rubric-light);
}

.footnote-group-content .footnote-group-content .footnote-group-content {
  margin-left: 32px;
  border-left-color: var(--earth-light);
}

.footnote-group-content .footnote-group-content::before {
  left: -32px;
  width: 32px;
  background: var(--earth-light);
}

.footnote-group-content .footnote-group-content .footnote-group-content .footnote-group-content {
  margin-left: 48px;
  border-left-color: var(--earth-muted);
}

.footnote-group-content .footnote-group-content .footnote-group-content::before {
  left: -48px;
  width: 48px;
  background: var(--earth-muted);
}

/* Visual hierarchy indicators - removed icons for cleaner look */

/* Removed all level icons for cleaner appearance */
.footnote-group-header[data-level]::before {
  content: none;
  font-size: 12px;
  opacity: 0.4;
}

/* Adjust header content padding to accommodate icons */
.footnote-group-header .header-content {
  padding-left: 32px;
}

/* Adjust spacing for cards within groups */
.footnote-group-content .card {
  margin-bottom: 8px;
  border-radius: 6px;
  border-left: 3px solid transparent;
  transition: border-left-color 0.2s ease;
}

.footnote-group-content .card:hover {
  border-left-color: var(--rubric-primary);
}

.footnote-group-content .card:last-child {
  margin-bottom: 0;
}

/* Add subtle background for content areas */
.footnote-group-content {
  background: white;
}

/* Enhanced rubrication theme for the overall interface */
.footnote-group-header[data-level="1"] .header-count {
  background: var(--rubric-primary);
  border: 2px solid var(--rubric-secondary);
}

.footnote-group-header[data-level="2"] .header-count {
  background: var(--rubric-secondary);
  border: 2px solid var(--rubric-accent);
}

.footnote-group-header[data-level="3"] .header-count {
  background: var(--earth-primary);
  border: 2px solid var(--earth-secondary);
}

.footnote-group-header[data-level="4"] .header-count {
  background: var(--earth-secondary);
  border: 2px solid var(--earth-accent);
}

/* Improved hover effects with rubrication colors */
.footnote-group-header[data-level="1"]:hover {
  border-color: var(--rubric-secondary);
  box-shadow: 0 2px 8px rgba(185, 28, 28, 0.12);
}

.footnote-group-header[data-level="2"]:hover {
  border-color: var(--rubric-accent);
  box-shadow: 0 2px 8px rgba(185, 28, 28, 0.15);
}

.footnote-group-header[data-level="3"]:hover {
  border-color: var(--earth-secondary);
  box-shadow: 0 2px 8px rgba(146, 64, 14, 0.15);
}

.footnote-group-header[data-level="4"]:hover {
  border-color: var(--earth-accent);
  box-shadow: 0 2px 8px rgba(120, 53, 15, 0.15);
}

/* Special styling for no-heading group */
.footnote-group-header[data-group="no-heading"] {
  background: #f8f9fa;
  border-color: var(--muted);
}

.footnote-group-header[data-group="no-heading"] .header-title {
  color: var(--muted);
}

.footnote-group-header[data-group="no-heading"] .chev {
  color: var(--muted);
}

.footnote-group-header[data-group="no-heading"] .header-count {
  background: var(--muted);
}

/* Footnote group spacing and layout */
.footnote-group-header + .footnote-group-content {
  margin-top: 0;
}

/* Ensure proper spacing between groups */
.footnote-group-header:first-child {
  margin-top: 0;
}

/* Different heading level styles */
.footnote-group-header[data-level="0"] .header-title {
  font-size: 14px;
  color: var(--muted);
  font-style: italic;
}

.footnote-group-header[data-level="1"] .header-title {
  font-size: 18px;
  color: var(--text-charcoal);
  font-weight: 700;
}

.footnote-group-header[data-level="2"] .header-title {
  font-size: 16px;
  color: var(--text-charcoal);
  font-weight: 600;
}

.footnote-group-header[data-level="3"] .header-title {
  font-size: 15px;
  color: #3A3A4A;
  font-weight: 600;
}

.footnote-group-header[data-level="4"] .header-title {
  font-size: 14px;
  color: #4A4A5A;
  font-weight: 500;
}

/* Footnote list container improvements */
#footnote-list {
  padding: 0;
}

#footnote-list > li {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Empty state styling */
#footnote-list .empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
  font-style: italic;
  background: var(--card-bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin: 16px 0;
}

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tab-btn {
  background: transparent;
  border: none;
  padding: 6px 10px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab-btn.active { border-bottom-color: var(--accent); font-weight: 600; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Database status and setup */
.db-status {
  padding: 12px;
  background: var(--card-bg);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

/* Database progress display */
.db-progress {
  padding: 16px;
  background: var(--card-bg);
  border-radius: var(--radius);
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.progress-header h4 {
  margin: 0;
  color: #111827;
  font-size: 14px;
  font-weight: 600;
}

.progress-status {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-fill {
  height: 100%;
  background: #111827;
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.progress-text {
  color: var(--muted);
  font-weight: 500;
}

.progress-count {
  color: #111827;
  font-weight: 600;
}

.progress-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.progress-label {
  color: var(--muted);
  font-weight: 500;
}

.progress-value {
  color: #111827;
  font-weight: 600;
}

/* Loading indicators */
.loading-indicator {
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-style: italic;
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

/* Processing section for real-time updates */
.processing-section {
  margin-bottom: 16px;
  border: 1px solid var(--warn);
  border-radius: var(--radius);
  background: #fef3c7;
}

.processing-section .folder-header {
  background: var(--warn);
  color: white;
  padding: 8px 12px;
  border-radius: var(--radius) var(--radius) 0 0;
  font-weight: 600;
  font-size: 12px;
}

.processing-section .file-card {
  border: none;
  border-radius: 0;
  background: transparent;
}

.processing-section .file-card:last-child {
  border-radius: 0 0 var(--radius) var(--radius);
}

/* Real-time status updates */
.file-card.processing .status-text {
  color: var(--warn);
  font-weight: 600;
  animation: pulse 2s infinite;
}

/* Progress cards (during processing) */
.file-card.progress-card {
  border-left: 3px solid var(--warn);
  background: #fef3c7;
}

.file-card.progress-card .file-card-header {
  background: transparent;
}

.file-card.progress-card .file-title {
  font-weight: 600;
}

.file-card.progress-card .status-text {
  font-weight: 600;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* File status colors for real-time updates */
.file-status .status-text {
  transition: color 0.3s ease;
}

.file-status .status-text[style*="color: #d97706"] {
  color: var(--warn) !important;
}

.file-status .status-text[style*="color: #16a34a"] {
  color: var(--positive) !important;
}

.file-status .status-text[style*="color: #dc2626"] {
  color: var(--negative) !important;
}

.file-status .status-text[style*="color: #ca8a04"] {
  color: #ca8a04 !important;
}

.status-loading {
  color: var(--muted);
  font-style: italic;
}

.data-source-pane {
  padding: 0;
}

.setup-description {
  color: var(--muted);
  margin-bottom: 12px;
  font-size: 13px;
}

.source-option { 
  margin: 8px 0; 
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
}

.radio-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  width: 100%;
}

.radio-label input[type="radio"] {
  margin: 0;
  margin-top: 2px;
}

.radio-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.radio-text strong {
  color: #111827;
  font-size: 14px;
  font-weight: 600;
}

.radio-description {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.auto-selected-indicator {
  color: var(--accent);
  font-size: 11px;
  font-style: italic;
  margin-left: 4px;
  opacity: 0.8;
}

.folder-controls {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.metadata-option {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.metadata-option .radio-label {
  margin-bottom: 8px;
}

.metadata-option .radio-label:last-child {
  margin-bottom: 0;
}

.metadata-option .radio-description {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  max-width: 400px;
}

.embedding-option {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.embedding-option .radio-label {
  margin-bottom: 8px;
}

.embedding-option .radio-label:last-child {
  margin-bottom: 0;
}

.embedding-option .radio-description {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  max-width: 400px;
}

.embedding-provider-options.hidden {
  display: none;
}

.folder-selection {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.selected-folder {
  flex: 1;
  padding: 6px 10px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--muted);
}

.setup-actions {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.config-summary {
  margin: 12px 0;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.summary-item:last-child {
  border-bottom: none;
}

.summary-label {
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
}

.summary-value {
  color: #111827;
  font-size: 12px;
}

/* Button styles */
.btn-primary {
  background: var(--rubric-primary);
  color: white;
  border-color: var(--rubric-primary);
  transition: all 0.2s ease;
}

.btn-primary:hover:not(:disabled) {
  background: var(--rubric-secondary);
  border-color: var(--rubric-secondary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(185, 28, 28, 0.25);
}

.btn-secondary {
  background: white;
  color: #111827;
  border-color: #111827;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: #f8fafc;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Backend unavailable button state */
.btn-secondary.backend-unavailable {
  background-color: #f8d7da;
  color: #721c24;
  border-color: #f5c6cb;
  cursor: not-allowed;
  opacity: 0.7;
}

.btn-secondary.backend-unavailable:hover {
  background-color: #f8d7da;
  color: #721c24;
  border-color: #f5c6cb;
}

.btn-secondary.backend-unavailable:active {
  background-color: #f8d7da;
  color: #721c24;
  border-color: #f5c6cb;
}

.option-group {
  margin-bottom: 16px;
}

.option-group:last-child {
  margin-bottom: 0;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.checkbox-label:hover {
  background: var(--card-hover);
}

.checkbox-label.active {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
}

.checkbox-label input[type="checkbox"] {
  margin: 0;
  margin-top: 2px;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.checkbox-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.checkbox-text strong {
  color: #111827;
  font-size: 14px;
  font-weight: 600;
}

.checkbox-description {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.source-selection {
  flex: 1;
}

.btn-icon {
  margin-right: 8px;
  font-size: 14px;
}

.placeholder-icon {
  font-size: 32px;
  margin-bottom: 16px;
  opacity: 0.6;
}

.placeholder-text {
  font-size: 14px;
  line-height: 1.4;
  max-width: 200px;
}

/* Loading and result states */
.loading-indicator {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-style: italic;
}

.error-message {
  color: var(--negative);
  background: #fef2f2;
  border: 1px solid #fecaca;
  padding: 16px;
  border-radius: var(--radius);
  margin: 16px 0;
  font-size: 14px;
  line-height: 1.4;
}

.success-message {
  color: var(--positive);
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  padding: 16px;
  border-radius: var(--radius);
  margin: 16px 0;
  font-size: 14px;
  line-height: 1.4;
}

/* Card styles for suggestions */
.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.card-header {
  padding: 16px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.card-header:hover {
  background: var(--card-hover);
}

.card-header.expandable {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.card-header.expandable:hover {
  background: var(--card-hover);
}

.card-header .chev {
  transition: transform 0.2s ease;
  font-size: 16px;
  color: var(--muted);
  font-weight: bold;
  min-width: 16px;
  text-align: center;
}

.card-header.expanded .chev {
  transform: rotate(90deg);
}

.card-title {
  font-weight: 600;
  color: #111827;
  margin-bottom: 4px;
}

.card-sub {
  font-size: 12px;
  color: var(--muted);
}

.card-body {
  padding: 16px;
  display: none;
}

.card-body.show {
  display: block;
}

.card-body .expandable-text {
  background: #f8f9fa;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  margin: 12px 0;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 200px;
  overflow: hidden;
  transition: max-height 0.3s ease;
  position: relative;
}

.card-body .expandable-text.expanded {
  max-height: none;
}

.card-body .expandable-text:not(.expanded)::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 20px;
  background: linear-gradient(transparent, #f8f9fa);
  pointer-events: none;
}

.card-body .text-toggle {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  text-decoration: underline;
  padding: 0;
  margin: 8px 0;
  transition: color 0.2s ease;
}

.card-body .text-toggle:hover {
  color: #1d4ed8;
  text-decoration: none;
}

.card-body .text-toggle:focus {
  outline: none;
  text-decoration: none;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.card-actions a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.card-actions a:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.card-actions a.read-more {
  background: #f0f9ff;
  border-color: #bae6fd;
  color: #0369a1;
}

.card-actions a.read-more:hover {
  background: #0369a1;
  border-color: #0369a1;
  color: white;
}

.card-actions a.original-doc {
  background: #fef3c7;
  border-color: #fde68a;
  color: #92400e;
}

.card-actions a.original-doc:hover {
  background: #92400e;
  border-color: #92400e;
  color: white;
}

.small {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
  line-height: 1.4;
}

/* IARepo suggestion styles */
.suggestion-rationale {
  background: #f0f9ff;
  border-left: 3px solid var(--accent);
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 13px;
  line-height: 1.5;
  border-radius: 4px;
}

.suggestion-rationale strong {
  color: var(--accent);
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.footnote-preview {
  margin-bottom: 12px;
}

.footnote-preview strong {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: #111827;
}

.suggestion-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.suggestion-actions button {
  flex: 1;
}

.section-text-preview {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.snip {
  background: var(--card-bg);
  padding: 12px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 12px;
  line-height: 1.4;
  margin: 12px 0;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--border);
}

.muted {
  color: var(--muted);
  font-style: italic;
}

.hidden {
  display: none !important;
}

.separator {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

.additional-sources {
  margin-top: 0;
}

.provider-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.provider-placeholder {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: #fafafa;
  text-align: center;
  transition: all 0.2s ease;
}

.provider-placeholder:hover {
  border-color: #111827;
  background: #f8f9fa;
}

.provider-logo {
  font-size: 20px;
  margin-bottom: 6px;
}

.provider-name {
  font-size: 11px;
  font-weight: 500;
  line-height: 1.2;
}

.error-message {
  color: var(--negative);
  background: #fef2f2;
  border: 1px solid #fecaca;
  padding: 8px 12px;
  border-radius: 6px;
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.4;
}

.success-message {
  color: var(--positive);
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  padding: 8px 12px;
  border-radius: 6px;
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.4;
}

/* File list section */
.file-list-section {
  margin: 12px 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

#btn-toggle-files {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  justify-content: flex-start;
  padding: 8px 10px;
}

.toggle-icon {
  transition: transform 0.2s ease;
  font-size: 14px;
  font-weight: bold;
}

.toggle-icon.expanded {
  transform: rotate(90deg);
}

.file-list {
  margin-top: 8px;
}

.file-actions-footer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.button-group {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 8px;
}

.help-text {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  line-height: 1.3;
}

.file-list h5 {
  margin: 0 0 8px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.file-tree {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.folder-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  overflow: hidden;
}

.folder-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  cursor: pointer;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  transition: background 0.2s ease;
}

.folder-header:hover {
  background: var(--card-hover);
}

.folder-header .chev {
  transition: transform 0.2s ease;
  font-size: 14px;
  font-weight: bold;
}

.folder-header[aria-expanded="true"] .chev {
  transform: rotate(90deg);
}

.folder-title {
  font-weight: 600;
  flex: 1;
  color: #111827;
  font-size: 13px;
}

.file-count {
  font-size: 11px;
  color: var(--muted);
  background: var(--border);
  padding: 2px 6px;
  border-radius: 10px;
}

.folder-body {
  display: none;
  padding: 6px;
  background: white;
}

.folder-body.show {
  display: block;
}

.file-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  overflow: hidden;
  transition: background 0.2s ease;
  margin-bottom: 3px;
}

.file-card:last-child {
  margin-bottom: 0;
}

.file-card:hover {
  background: var(--card-hover);
}

.file-card-header {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  cursor: pointer;
}

.file-card-header .chev {
  transition: transform 0.2s ease;
  font-size: 14px;
  font-weight: bold;
}

.file-card-header[aria-expanded="true"] .chev {
  transform: rotate(90deg);
}

.file-title {
  font-weight: 600;
  flex: 1;
  font-size: 13px;
}

.file-status {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 70px;
  justify-content: flex-end;
}

.processing-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.processing-spinner.hidden {
  display: none;
}

.status-text {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.file-card-body {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: none;
}

.file-card-body.show {
  display: block;
}

.file-metadata {
  margin: 12px 0;
  padding: 12px;
  background: var(--card-bg);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.metadata-title {
  margin: 0 0 8px 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metadata-item {
  margin: 4px 0;
  font-size: 12px;
  line-height: 1.4;
}

.metadata-item strong {
  color: var(--muted);
  font-weight: 600;
  margin-right: 4px;
}

.file-path {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
  margin-bottom: 6px;
}

.file-info {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}

.file-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.btn-re-ocr {
  background: #111827;
  color: white;
  border-color: #111827;
  font-size: 11px;
  padding: 3px 6px;
}

.btn-re-ocr:hover {
  background: #374151;
}

.btn-re-ocr:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Re-OCR state styles */
.file-card.re-ocr-pending .status-text {
  color: var(--warn);
  font-weight: 600;
  animation: pulse 2s infinite;
}

.file-card.re-ocr-processing .status-text {
  color: var(--warn);
  font-weight: 600;
  animation: pulse 2s infinite;
}

.file-card.re-ocr-completed .status-text {
  color: var(--positive);
  font-weight: 600;
}

/* Success pill styles */
.status-pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  text-align: center;
  border: 1px solid;
}

.status-pill.success {
  background: #ecfdf5;
  border-color: #bbf7d0;
  color: var(--positive);
}

/* Animation for pending/processing states */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.panel {
  margin: 12px 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.panel button {
  flex: 0 0 auto; /* Don't stretch buttons */
  white-space: nowrap; /* Prevent text wrapping */
}

/* Upload section - centered with document name above */
#upload-section {
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 12px;
  background: var(--bg-cream);
  border-radius: var(--radius);
}

#upload-section .document-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-charcoal);
  margin-bottom: 8px;
  display: block;
  width: 100%;
}

#upload-section .button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Ensure upload section buttons use dried ink theme */
#upload-section .btn-primary {
  background: var(--rubric-primary) !important;
  border-color: var(--rubric-primary) !important;
  color: white !important;
}

#upload-section .btn-primary:hover:not(:disabled) {
  background: var(--rubric-secondary) !important;
  border-color: var(--rubric-secondary) !important;
}

/* Policy Controls Container */
.policy-controls-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

/* Internet Policy Controls */
.internet-policy-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--card-bg);
  border-radius: 4px;
  border: 1px solid var(--border);
  flex-shrink: 0; /* Prevent policy controls from shrinking */
}

.policy-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.policy-select {
  font-size: 12px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: #111827;
}

/* Styling for locked internet-policy when Internet Only is selected */
.policy-select.locked-for-internet-only {
  background: var(--muted-bg, #f3f4f6);
  color: var(--muted);
  cursor: not-allowed;
  border-color: var(--accent);
  opacity: 0.8;
}

.policy-select.locked-for-internet-only:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-alpha, rgba(59, 130, 246, 0.2));
}

.policy-help {
  font-size: 14px;
  color: var(--muted);
  cursor: help;
  font-weight: bold;
}

button {
  border: 1px solid var(--border);
  background: #fff;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  flex: 0 0 auto; /* Prevent buttons from stretching by default */
  white-space: nowrap; /* Prevent text wrapping */
}
button:hover { background: #f8fafc; }
button[disabled] { opacity: 0.5; cursor: not-allowed; }

.small { font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.container { display: flex; flex-direction: column; gap: 10px; }

/* Card / accordion */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  overflow: hidden;
  transition: background 0.2s ease;
}
.card:hover { background: var(--card-hover); }
.card-header {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  display: flex;
  align-items: flex-start; /* Change to flex-start to allow wrapping */
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  flex-wrap: wrap; /* Allow items to wrap to next line */
  min-width: 0; /* Allow flex container to shrink */
}
.card-header .chev { 
  transition: transform 0.2s ease; 
  flex-shrink: 0; /* Don't shrink the chevron */
  margin-top: 2px; /* Align with first line of text */
}
.card-header[aria-expanded="true"] .chev { transform: rotate(90deg); }
.card-title { 
  font-weight: 600; 
  min-width: 0; /* Allow text wrapping in flex container */
  word-wrap: break-word;
  word-break: break-word;
  white-space: normal; /* Allow wrapping */
  flex: 1 1 auto; /* Allow title to grow and shrink */
  max-width: 100%; /* Prevent overflow */
}
.card-sub { 
  margin-left: auto; 
  font-size: 12px; 
  color: var(--muted);
  min-width: 0; /* Allow text wrapping in flex container */
  word-wrap: break-word;
  word-break: break-word;
  white-space: normal;
  flex-shrink: 0; /* Don't shrink the sub */
}

.card-body {
  display: none;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--border);
  background: #fff;
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: break-word;
}
.card-body.show { display: block; }

/* Table */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 4px 0 10px;
}
.table th, .table td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 6px 6px;
  vertical-align: top;
  word-wrap: break-word;
  word-break: break-word;
  white-space: normal;
  max-width: 100%;
}
.table th { width: 160px; color: var(--muted); font-weight: 500; }

/* Badges for label */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: #f3f4f6;
  word-wrap: break-word;
  word-break: break-word;
  white-space: normal;
  max-width: 100%;
}
/* VERIFIED badges (green tones) */
.badge.supports { background: #ecfdf5; border-color: #bbf7d0; color: var(--positive); }
.badge.partial { background: #f0fdf4; border-color: #86efac; color: #15803d; }

/* ISSUES badges (red tones) */
.badge.disputes, .badge.refutes { background: #fef2f2; border-color: #fecaca; color: var(--negative); }
.badge.hallucination { background: #fee2e2; border-color: #fca5a5; color: #991b1b; font-weight: 500; }
.badge.hallucination::before { content: "⚠ "; }

/* UNRESOLVED - Access Issues (orange - source exists but can't access) */
.badge.paywalled { background: #fff7ed; border-color: #fdba74; color: #c2410c; }
.badge.paywalled::before { content: "🔒 "; }
.badge.access_denied { background: #fff7ed; border-color: #fed7aa; color: #c2410c; }
.badge.access_denied::before { content: "🚫 "; }
.badge.bot_protected { background: #fef3c7; border-color: #fcd34d; color: #92400e; }
.badge.bot_protected::before { content: "🤖 "; }
.badge.blocked { background: #fff7ed; border-color: #fed7aa; color: #c2410c; }

/* UNRESOLVED - Not Found (orange-red) */
.badge.not_found { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.badge.not_found::before { content: "❌ "; }

/* UNRESOLVED - Technical Issues (yellow) */
.badge.timeout { background: #fef9c3; border-color: #fde047; color: #854d0e; }
.badge.timeout::before { content: "⏱ "; }
.badge.network_error { background: #fef9c3; border-color: #fde047; color: #854d0e; }
.badge.network_error::before { content: "📡 "; }
.badge.error { background: #fef3c7; border-color: #fde68a; color: var(--warn); }

/* UNRESOLVED - Resolution Incomplete (yellow) */
.badge.vague_citation { background: #f5f5f5; border-color: #d4d4d4; color: #525252; }
.badge.vague_citation::before { content: "❓ "; }
.badge.no_search_results { background: #fef9c3; border-color: #fde047; color: #854d0e; }
.badge.no_search_results::before { content: "🔍 "; }
.badge.ambiguous { background: #fef3c7; border-color: #fde68a; color: #92400e; }
.badge.ambiguous::before { content: "⚖ "; }
.badge.insufficient { background: #fef3c7; border-color: #fde68a; color: var(--warn); }
.badge.warn { background: #fffbeb; border-color: #fde68a; color: var(--warn); }
.badge.unclear, .badge.mixed { background: #f5f5f5; color: var(--neutral); }

/* New web resolution status badges */
.badge.exists { background: #ecfdf5; border-color: #bbf7d0; color: var(--positive); }
.badge.unfound { background: #fef2f2; border-color: #fecaca; color: var(--negative); }
.badge.paywalled { background: #fffbeb; border-color: #fde68a; color: var(--warn); }
.badge.blocked { background: #fef2f2; border-color: #fecaca; color: var(--negative); }
.badge.free { background: #ecfdf5; border-color: #bbf7d0; color: var(--positive); }

/* Secondary labels (LLM-flagged issues that don't change main verdict) */
.badge.secondary-badge {
  font-size: 10px;
  padding: 1px 5px;
  margin-left: 4px;
  opacity: 0.85;
}
.badge.secondary-badge::before {
  content: "⚠ ";
  font-size: 9px;
}
/* Quote-related secondary labels */
.badge.quote-mismatch, .badge.quote_mismatch { background: #fef2f2; border-color: #fecaca; color: var(--negative); }
.badge.quote-not-found, .badge.quote_not_found { background: #fef9c3; border-color: #fde047; color: #854d0e; }
.badge.quote-altered, .badge.quote_altered { background: #fff7ed; border-color: #fdba74; color: #c2410c; }

/* Footnote and inline citation badges */
.badge-footnote, .badge-inline-citation {
  font-size: 11px;
  padding: 2px 6px;
  margin-right: 4px;
  vertical-align: baseline;
  font-weight: 500;
  background: #e5e7eb;
  border-color: #d1d5db;
  color: #374151;
}
.badge-footnote {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}
.badge-inline-citation {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}

/* Source link styling */
.source-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.source-link:hover {
  text-decoration: underline;
}

/* Snips accordion */
.snips {
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: #fafafa;
  margin-top: 6px;
}
.snips-header {
  width: 100%;
  border: none;
  background: transparent;
  padding: 8px 10px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.snips-body { display: none; padding: 4px 10px 10px; }
.snips-body.show { display: block; }

.snip {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  margin-top: 8px;
  padding: 8px;
  font-size: 12px;
  white-space: pre-wrap;
}

/* Utility */
.row { display: flex; gap: 8px; align-items: center; }
.spacer { flex: 1; }
.hidden { display: none; }


.card-header .pending {
  font-size: 11px; margin-left: 8px; padding: 2px 6px; border-radius: 10px;
  background: #fff3cd; color: #8a6d3b; border: 1px solid #ffe7a3;
  animation: fcPulse 1.2s infinite;
  word-wrap: break-word;
  word-break: break-word;
  white-space: normal;
  max-width: 100%;
}
@keyframes fcPulse { 0%{opacity:.55} 50%{opacity:1} 100%{opacity:.55} }

.result-block { margin-top: 10px; }

/* ========================================
   Ask User Inline Pane
   ======================================== */

.fc-inline-ask {
  margin: 12px 0;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--rubric-primary);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
  position: relative;
}

.fc-inline-ask:hover {
  border-color: var(--rubric-primary);
  box-shadow: 0 2px 6px rgba(185, 28, 28, 0.1);
  transform: translateY(-1px);
}

.fc-inline-ask .citation-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
  padding: 4px 8px;
  background: var(--card-bg);
  border-radius: 4px;
  display: inline-block;
}

.fc-inline-ask-question {
  margin-bottom: 12px;
  padding: 10px 12px;
  background: #fef2f2;
  border-left: 3px solid var(--rubric-primary);
  border-radius: 6px;
  color: #111827;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.fc-inline-ask-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}

.fc-inline-ask-actions .btn-secondary {
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.fc-inline-ask-actions .btn-secondary:hover {
  background: var(--card-hover);
  border-color: var(--rubric-primary);
  color: var(--rubric-primary);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(185, 28, 28, 0.1);
}

.fc-inline-ask-actions .btn-secondary.active {
  background: var(--rubric-primary);
  border-color: var(--rubric-primary);
  color: white;
}

.fc-inline-ask-chip {
  margin-left: auto;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #fef2f2;
  border: 1px solid var(--rubric-light);
  border-radius: 9999px;
  font-size: 12px;
  color: var(--rubric-primary);
  font-weight: 500;
}

.fc-inline-ask-chip:not(.hidden) {
  display: inline-flex;
}

.fc-inline-ask-chip .chip-label {
  font-weight: 600;
  color: var(--rubric-accent);
}

.fc-inline-ask-chip .chip-clear {
  margin-left: 4px;
  padding: 0;
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  color: var(--rubric-primary);
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  transition: all 0.2s ease;
}

.fc-inline-ask-chip .chip-clear:hover {
  background: var(--rubric-light);
  color: var(--rubric-accent);
}

.fc-inline-ask-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.fc-inline-ask .free-input {
  flex: 1;
  min-width: 200px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: var(--bg);
  color: #111827;
  transition: all 0.2s ease;
}

.fc-inline-ask .free-input:focus {
  outline: none;
  border-color: var(--rubric-primary);
  box-shadow: 0 0 0 2px rgba(185, 28, 28, 0.1);
}

.fc-inline-ask .free-input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.fc-inline-ask .ok {
  padding: 10px 16px;
  border-radius: 6px;
  border: 1px solid var(--rubric-primary);
  background: var(--rubric-primary);
  color: white;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.fc-inline-ask .ok:hover {
  background: var(--rubric-secondary);
  border-color: var(--rubric-secondary);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(185, 28, 28, 0.2);
}

.fc-inline-ask .ok:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(185, 28, 28, 0.2);
}

.fc-inline-ask .cancel {
  padding: 10px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.fc-inline-ask .cancel:hover {
  background: var(--card-hover);
  border-color: var(--muted);
  color: #111827;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.fc-inline-ask .cancel:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.fc-inline-ask.submitted {
  opacity: 0.4;
  pointer-events: none;
  z-index: 1;
  position: relative;
  border-color: var(--muted);
  border-left-color: var(--muted);
}

.fc-inline-ask.submitted button,
.fc-inline-ask.submitted input {
  pointer-events: none;
  opacity: 0.6;
}

.fc-inline-ask:not(.submitted) {
  z-index: 10;
  position: relative;
}


.card-header { 
  display: flex; 
  align-items: flex-start; /* Change to flex-start to allow wrapping */
  gap: 8px; 
  min-width: 0; /* Allow flex children to shrink and wrap */
  flex-wrap: wrap; /* Allow items to wrap to next line */
}
.card-header .spacer { flex: 1; min-width: 0; }
.card-header .chev {
  flex-shrink: 0; /* Don't shrink the chevron */
  margin-top: 2px; /* Align with first line of text */
}
.card-header .card-title {
  min-width: 0; /* Allow text wrapping in flex container */
  word-wrap: break-word;
  word-break: break-word;
  white-space: normal; /* Allow wrapping */
  flex: 1 1 auto; /* Allow title to grow and shrink */
  max-width: 100%; /* Prevent overflow */
}
.card-header .card-sub {
  min-width: 0; /* Allow text wrapping in flex container */
  word-wrap: break-word;
  word-break: break-word;
  white-space: normal;
  flex-shrink: 0; /* Don't shrink the sub */
}
.card-header .pending,
.card-header .badge {
  word-wrap: break-word;
  word-break: break-word;
  white-space: normal;
  max-width: 100%;
  flex-shrink: 0; /* Don't shrink badges */
}
.card-header .status-icons {
  flex-shrink: 0; /* Don't shrink status icons */
}

.status-icons { display: inline-flex; gap: 6px; align-items: center; }
.si { font-size: 12px; line-height: 1; vertical-align: middle; }
.si.ok   { color: #16a34a; } /* green-600 */
.si.ask  { color: #d97706; font-size: 18px;} /* amber-600 */
.si.fail { color: #dc2626; } /* red-600  */

/* Web status icons */
.si.web-exists { color: #16a34a; } /* green-600 */
.si.web-unfound { color: #dc2626; } /* red-600 */
.si.paywalled { color: #d97706; } /* amber-600 */
.si.blocked { color: #dc2626; } /* red-600 */


.badge.dry { background: #f5f5f5; color: #6b7280; border-color: #e5e7eb; }

/* Modal ask dialog */
#fc-ask-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
#fc-ask-modal.show { display: flex; }
#fc-ask-modal .fc-ask-box {
  width: min(520px, 92vw);
  max-width: 92vw;
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
  font-family: 'Segoe UI', system-ui, sans-serif;
}
#fc-ask-q { margin-bottom: 12px; white-space: pre-wrap; }
#fc-ask-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  outline: none;
  margin-bottom: 12px;
  font-size: 14px;
}
.fc-ask-actions { display: flex; gap: 8px; justify-content: flex-end; }
.fc-ask-actions .cancel {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #ddd;
  background: #f6f6f6;
  cursor: pointer;
}
.fc-ask-actions .ok {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #2563eb;
  background: #2563eb;
  color: white;
  cursor: pointer;
}

/* Folder confirmation modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal.show {
  display: flex;
}

.modal-content {
  width: min(480px, 90vw);
  max-width: 90vw;
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
  font-family: 'Segoe UI', system-ui, sans-serif;
}

.modal-content h4 {
  margin: 0 0 16px 0;
  color: #111827;
  font-size: 18px;
  font-weight: 600;
}

.modal-body {
  margin-bottom: 20px;
}

.modal-body p {
  margin: 0 0 12px 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.modal-body p:last-of-type {
  margin-bottom: 0;
}

.folder-summary {
  margin: 16px 0;
  padding: 12px;
  background: var(--card-bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.modal-note {
  font-style: italic;
  color: var(--muted);
  font-size: 13px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.modal-actions .btn-primary {
  min-width: 120px;
}

.modal-actions .btn-secondary {
  min-width: 80px;
}

/* Modal details */
.modal-details {
  margin: 12px 0;
  padding: 12px;
  background: var(--card-bg);
  border-radius: var(--radius);
}

.detail-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.detail-item:last-child {
  margin-bottom: 0;
}

.detail-label {
  font-weight: 500;
  color: var(--muted);
}

.detail-value {
  font-weight: 600;
  color: var(--accent);
}

.modal-warning {
  color: var(--warn);
  font-weight: 500;
  margin-top: 12px;
  padding: 8px 12px;
  background: rgba(217, 119, 6, 0.1);
  border-radius: var(--radius);
  border-left: 3px solid var(--warn);
}

/* Error message styling */
.error-message {
  color: var(--negative);
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.25);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin: 8px 0;
  font-size: 14px;
}

/* Failure reason styling */
.failure-reason {
  color: var(--negative);
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.25);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin: 8px 0;
  font-size: 14px;
  font-weight: 500;
}

.failure-reason-row {
  background: rgba(220, 38, 38, 0.04);
  border-left: 3px solid var(--negative);
}

.failure-reason-row td:first-child {
  color: var(--negative);
  font-weight: 600;
}

.header-container { display: flex; align-items: center; justify-content: space-between; }
.app-version { font-size: 0.8em; color: #666; font-family: monospace; }



.tauri-only, .browser-only {
  display: none;
}

body.env-tauri .tauri-only {
  display: inline-block; /* Or whatever your default button display is */
}

body.env-browser .browser-only {
  display: inline-block;
}

/* ==== Split Pane Layout (Desktop) ==== */
.fc-split {
  display: grid;
  grid-template-columns: 60% 40%; /* Document on left, footnotes on right */
  gap: 10px;
  flex: 1;
  min-height: 0; /* Allow grid to shrink */
  overflow: hidden; /* Prevent grid from scrolling */
}

/* Three-column layout with sidebar - widened columns */
.fc-split.fc-three-column {
  grid-template-columns: 330px 1fr 570px !important; /* Sidebar | Document | Footnotes (widened by 50%) */
}

#fn-pane, #doc-pane, #sidebar-pane {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0; /* Allow flex children to shrink below content size */
}

/* Sidebar Pane - Light Grey */
#sidebar-pane {
  order: 0;
  background: #EAEAEA;
}

#sidebar-pane .pane-header {
  background: #E0E0E0;
}

#sidebar-pane .pane-title {
  color: var(--text-charcoal);
}

#sidebar-pane .sidebar-section-title {
  color: var(--text-charcoal);
}

#sidebar-pane .small.muted {
  color: #666;
}

/* Document Pane - Cream/Paper */
#doc-pane {
  order: 1;
  background: var(--bg-cream);
}

#doc-pane .pane-header {
  background: var(--bg-cream);
}

/* Footnotes Pane - White with charcoal headings */
#fn-pane {
  order: 2;
  background: #fff;
}

#fn-pane .pane-header {
  background: #fff;
}

#fn-pane .pane-title {
  color: var(--text-charcoal);
}

/* Sidebar Styles */
.sidebar-content {
  padding: 12px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.sidebar-content::-webkit-scrollbar {
  display: none;
}

.sidebar-section {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.sidebar-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--rubric-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 10px 0;
}

.sidebar-text {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 12px 0;
}

.sidebar-steps {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.sidebar-steps li {
  margin-bottom: 6px;
}

.sidebar-steps li strong {
  color: #111827;
}

.sidebar-control {
  margin-bottom: 8px;
}

.sidebar-select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg);
  color: #111827;
}

.sidebar-select:focus {
  outline: none;
  border-color: var(--rubric-primary);
}

.sidebar-hint {
  font-size: 11px;
  color: var(--muted);
  margin: 6px 0 0 0;
  font-style: italic;
}

.sidebar-account {
  background: #fef2f2;
  border-radius: var(--radius);
  padding: 12px;
  margin: 0 -12px;
  width: calc(100% + 24px);
  border-bottom: none;
}

.account-placeholder {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-icon {
  font-size: 20px;
}

.sidebar-link {
  font-size: 13px;
  color: var(--rubric-primary);
  text-decoration: none;
}

.sidebar-link:hover {
  text-decoration: underline;
}

.sidebar-home-link {
  display: inline-block;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  padding: 8px 0;
  transition: color 0.2s;
}

.sidebar-home-link:hover {
  color: var(--rubric-primary);
}

/* Responsive: slightly smaller on medium screens */
@media (max-width: 1600px) {
  .fc-split.fc-three-column {
    grid-template-columns: 300px 1fr 500px;
  }
}

@media (max-width: 1200px) {
  .fc-split.fc-three-column {
    grid-template-columns: 1fr 1fr;
  }

  #sidebar-pane {
    display: none;
  }
  
  #doc-pane {
    order: 1;
  }
  
  #fn-pane {
    order: 2;
  }
}

@media (max-width: 768px) {
  .fc-split.fc-three-column {
    grid-template-columns: 1fr;
  }
}

/* Resolution pane styling */
.resolution-pane {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 70vh;
  max-height: calc(100vh - 180px);
}

.resolution-list {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Resolution card specific styling */
.resolution-card {
  width: 100%;
  max-width: 100%;
  overflow: visible;
  height: auto !important;
  min-height: auto !important;
  max-height: none !important;
}

.resolution-card .card-body {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: visible;
  height: auto !important;
  min-height: auto !important;
  max-height: none !important;
}

.resolution-card .results {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: visible;
  height: auto !important;
  min-height: auto !important;
}

.resolution-card .fc-inline-ask {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: visible;
  height: auto !important;
}

.resolution-card .fc-inline-ask {
  display: block !important;
  width: 100% !important;
  border: 2px solid #e5e7eb !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Add extra spacing between multiple asks in the same footnote */
.resolution-card .fc-inline-ask + .fc-inline-ask {
  margin-top: 16px !important;
  border-top: 3px solid var(--accent);
}

.resolution-card .fc-inline-ask-question {
  word-wrap: break-word;
  white-space: normal;
  width: 100%;
  max-width: 100%;
}

.resolution-card .fc-inline-ask-actions,
.resolution-card .fc-inline-ask-input-row {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.resolution-card .fc-inline-ask input,
.resolution-card .fc-inline-ask button {
  box-sizing: border-box;
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
  flex-shrink: 0; /* Prevent header from shrinking */
}

.pane-header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.pane-sub {
  font-size: 12px;
  color: var(--muted);
}

/* Citation Tabs */
.citation-tabs {
  display: flex;
  gap: 0;
  padding: 0;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
  flex-shrink: 0;
}

.citation-tab {
  flex: 1;
  padding: 8px 4px;
  border: none;
  background: transparent;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.citation-tab:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.03);
}

.citation-tab.active {
  color: var(--rubric-primary);
  border-bottom-color: var(--rubric-primary);
}

/* Tab with Verified status (green) */
.citation-tab[data-tab="verified"].active {
  color: var(--positive);
  border-bottom-color: var(--positive);
}

/* Tab with Issues status (red) */
.citation-tab[data-tab="issues"].active {
  color: var(--negative);
  border-bottom-color: var(--negative);
}

/* Tab with Unresolved status (yellow/orange) */
.citation-tab[data-tab="unresolved"].active {
  color: var(--warn);
  border-bottom-color: var(--warn);
}

.tab-count {
  background: var(--border);
  color: var(--text);
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  text-align: center;
}

.citation-tab.active .tab-count {
  background: currentColor;
  color: white;
}

.citation-tab[data-tab="verified"] .tab-count {
  background: #dcfce7;
  color: #166534;
}

.citation-tab[data-tab="issues"] .tab-count {
  background: #fee2e2;
  color: #991b1b;
}

.citation-tab[data-tab="unresolved"] .tab-count {
  background: #fef3c7;
  color: #92400e;
}

.pane-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #111827;
}

#fn-list-wrap {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px;
  flex: 1;
  min-height: 0; /* Allow flex child to shrink and enable scrolling */
  scrollbar-width: none; /* Firefox - hide scrollbar */
  -ms-overflow-style: none; /* IE and Edge - hide scrollbar */
}

#fn-list-wrap::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera - hide scrollbar */
}

#doc-pages {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px;
  flex: 1;
  min-height: 0; /* Allow flex child to shrink and enable scrolling */
  background: #fff;
  scrollbar-width: none; /* Firefox - hide scrollbar */
  -ms-overflow-style: none; /* IE and Edge - hide scrollbar */
}

#doc-pages::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera - hide scrollbar */
}

/* Page card */
.doc-page {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  background: var(--card-bg);
}
.doc-page .page-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px 0;
  font-size: 12px;
  color: var(--muted);
}
.doc-page .page-body {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
  font-size: 13px;
}

/* Highlights for references/definitions */
mark.fn-ref  { background: #fffbcc; padding: 0 2px; border-radius: 3px; }
mark.fn-def  { background: #ccfbf1; padding: 0 2px; border-radius: 3px; }
.doc-page.focused {
  box-shadow: 0 0 0 2px #bae6fd inset;
  background: #f0f9ff;
}

/* Page tools */
.pane-tools {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
#page-jump {
  font-size: 12px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: #111827;
}

/* Context highlight */
mark.fn-ctx { background: #fde68a; padding: 0 2px; border-radius: 3px; }


/* === Add-in style cards === */
.card-list { display: flex; flex-direction: column; gap: 8px; }

.card {
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.card-header {
  width: 100%;
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: start; /* Change to start to allow wrapping */
  gap: 8px;
  padding: 10px 12px;
  background: var(--card-bg, #f9fafb);
  border: 0;
  cursor: pointer;
  text-align: left;
}

.card-header .chev {
  display: inline-block;
  transform: rotate(0deg);
  transition: transform 0.15s ease;
  font-weight: 700;
  color: #6b7280;
  margin-top: 2px; /* Align with first line of text */
}

.card-header[aria-expanded="true"] .chev {
  transform: rotate(90deg);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  word-wrap: break-word;
  word-break: break-word;
  white-space: normal;
  min-width: 0; /* Allow text wrapping in grid */
  overflow-wrap: break-word;
}

.card-sub {
  font-size: 12px;
  color: #6b7280;
  word-wrap: break-word;
  word-break: break-word;
  white-space: normal;
  min-width: 0; /* Allow text wrapping in grid */
}

.card-body {
  display: none;
  padding: 10px 12px;
  border-top: 1px solid var(--border, #e5e7eb);
  background: #fff;
}

.card-body.show { display: block; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  text-align: left;
  white-space: nowrap;
  color: #4b5563;
  padding: 6px 8px 6px 0;
  vertical-align: top;
  width: 140px;
}

.table td {
  padding: 6px 0;
  color: #111827;
}

.hidden { display: none; }

/* Buttons (reuse your palette) */
.btn-primary {
  border-radius: 6px;
  border: 1px solid var(--rubric-primary);
  background: var(--rubric-primary);
  color: #fff;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}
.btn-primary:disabled { opacity: 0.6; cursor: default; }

/* Data Source Selection Message */
.data-source-selection-message {
  background: #fef2f2;
  border: 1px solid var(--rubric-light);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(185, 28, 28, 0.08);
}

.selection-instruction h4 {
  margin: 0 0 8px;
  color: var(--rubric-accent);
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.selection-instruction p {
  margin: 0 0 12px;
  color: #7f1d1d;
  font-size: 14px;
  line-height: 1.5;
}

.selection-instruction ul {
  margin: 0;
  padding-left: 20px;
  color: #7f1d1d;
}

.selection-instruction li {
  margin-bottom: 6px;
  font-size: 14px;
  line-height: 1.4;
}

.selection-instruction li strong {
  color: var(--rubric-accent);
  font-weight: 600;
}

/* Engine Controls */
.engine-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.engine-controls button {
  font-size: 12px;
  padding: 4px 8px;
}

.engine-status {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

.engine-controls .btn-primary {
  background: var(--positive);
  border-color: var(--positive);
}

.engine-controls .btn-primary:hover {
  background: #15803d;
  border-color: #15803d;
}

.engine-controls .btn-secondary {
  background: var(--negative);
  border-color: var(--negative);
  color: white;
}

.engine-controls .btn-secondary:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}

/* A container for each sub-citation's audit results within a card */
.citation-block {
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px dashed var(--border);
}

/* Remove the top border for the very first citation in the list */
.citation-block:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.file-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-cell .file-label {
  flex: 1;
  word-break: break-word;
}

.file-cell .file-change-btn {
  border: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
}

.file-cell .file-change-btn:hover,
.file-cell .file-change-btn:focus-visible {
  background: rgba(185, 28, 28, 0.08);
  outline: none;
}

/* The container for the status text (e.g., "Resolving...") on the right */
.citation-status {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-align: right;
  white-space: normal;
  word-wrap: break-word;
  word-break: break-word;
  min-width: 0; /* Allow wrapping in flex container */
}

/* The animated 'pending' state text */
.citation-status .pending {
  color: var(--warn); /* Use the existing warning color */
  animation: fcPulse 1.5s infinite; /* Reuse the existing pulse animation */
  padding: 3px 8px;
  background-color: #fffbeb; /* Light yellow background */
  border-radius: 999px; /* Pill shape */
  border: 1px solid #fde68a; /* Light yellow border */
  word-wrap: break-word;
  word-break: break-word;
  white-space: normal;
  max-width: 100%;
}

/* A placeholder for where the results table will eventually go. */
/* This prevents the card height from "jumping" as content loads. */
.table-placeholder {
  min-height: 24px;
}

/* Button loading state with spinner */
button.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}

button .spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

/* === Word Add-in Setup Tab Styles === */
#tab-addin {
  padding: 20px;
  max-width: 800px;
  margin: 0 auto;
}

#tab-addin h2 {
  margin: 0 0 24px 0;
  color: var(--rubric-primary);
  font-size: 24px;
  font-weight: 700;
  text-align: center;
}

#tab-addin .section {
  margin-bottom: 32px;
  padding: 20px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

#tab-addin .section h3 {
  margin: 0 0 16px 0;
  color: var(--rubric-primary);
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

#tab-addin .section ol {
  margin: 0 0 16px 0;
  padding-left: 20px;
}

#tab-addin .section li {
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.5;
  color: #111827;
}

#tab-addin .section li b {
  color: var(--rubric-primary);
  font-weight: 600;
}

#tab-addin .section p {
  margin: 0 0 12px 0;
  font-size: 14px;
  line-height: 1.5;
  color: #111827;
}

#tab-addin .section p:last-child {
  margin-bottom: 0;
}

/* Manifest URL box */
.manifest-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0;
  padding: 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.manifest-box input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  background: white;
}

.manifest-box button {
  padding: 8px 12px;
  font-size: 13px;
  white-space: nowrap;
}

.manifest-box .btn-link {
  padding: 8px 12px;
  background: var(--rubric-primary);
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-size: 13px;
  transition: background-color 0.2s ease;
}

.manifest-box .btn-link:hover {
  background: var(--rubric-secondary);
  color: white;
}

/* Sideload box */
.sideload-box {
  margin: 16px 0;
  padding: 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.sideload-box .sideload-info {
  margin: 0 0 16px 0;
  padding: 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
  color: #374151;
}

.sideload-box label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--muted);
  font-size: 13px;
}

.sideload-box input {
  width: 100%;
  padding: 8px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: white;
}

.manifest-source-option {
  margin: 12px 0;
  padding: 8px 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.manifest-source-option .radio-label {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 6px;
  cursor: pointer;
  padding: 6px 4px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.manifest-source-option .radio-label:hover {
  background: var(--card-hover);
}

.manifest-source-option .radio-label:last-child {
  margin-bottom: 0;
}

.manifest-source-option .radio-label input[type="radio"] {
  margin: 0;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.manifest-source-option .radio-text {
  font-size: 13px;
  color: #111827;
  line-height: 1.4;
  flex: 1;
  min-width: 0;
}

.manifest-source-option .radio-text strong {
  color: var(--rubric-primary);
  font-weight: 600;
  display: block;
  margin-bottom: 2px;
}

.manifest-source-option .radio-text:not(:has(strong)) {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

.sideload-box .button-group {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.sideload-box button {
  flex: 1;
  padding: 10px 12px;
  font-size: 13px;
}

/* Status row */
.status-row {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  margin-top: 8px;
}

.status-row.info {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  color: #0369a1;
}

.status-row.success {
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  color: var(--positive);
}

.status-row.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--negative);
}

/* Hint box */
.hint-box {
  margin: 16px 0;
  padding: 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  border-left: 4px solid var(--rubric-primary);
}

.hint-box h4 {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--rubric-primary);
}

.hint-box p {
  margin: 0 0 12px 0;
  font-size: 13px;
  color: #374151;
}

.hint-box .note {
  margin-top: 12px;
  padding: 8px 12px;
  background: white;
  border-radius: 6px;
  font-size: 12px;
  color: #6b7280;
  border: 1px solid #e5e7eb;
}

/* Platform instructions */
.platform-instructions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin: 12px 0;
}

.platform-instructions:has(.windows-only:not([style*="display: none"])):has(.macos-only:not([style*="display: none"])) {
  grid-template-columns: 1fr 1fr;
}

.platform-section {
  padding: 12px;
  background: white;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}

/* Ensure platform-specific sections respect display:none */
.windows-only[style*="display: none"],
.macos-only[style*="display: none"] {
  display: none !important;
}

.platform-section h5 {
  margin: 0 0 8px 0;
  font-size: 13px;
  font-weight: 600;
  color: #111827;
}

.platform-section ol {
  margin: 0;
  padding-left: 16px;
  font-size: 12px;
  color: #374151;
}

.platform-section li {
  margin-bottom: 4px;
}

.platform-section .note-small {
  margin-top: 12px;
  padding: 8px;
  background: #fffbeb;
  border-left: 3px solid #f59e0b;
  border-radius: 4px;
  font-size: 11px;
  line-height: 1.4;
  color: #92400e;
}

.platform-section code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: #dc2626;
  border: 1px solid #e5e7eb;
}

.platform-section code.powershell-command {
  display: block;
  padding: 10px 12px;
  margin: 8px 0;
  background: #1e293b;
  color: #e2e8f0;
  font-size: 11px;
  line-height: 1.4;
  word-break: break-all;
  border: none;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.platform-section p {
  margin: 8px 0;
  font-size: 13px;
}

/* Troubleshooting details in platform section */
.troubleshooting-details {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fffbeb;
}

.troubleshooting-details summary {
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
  color: #92400e;
  list-style-position: outside;
}

.troubleshooting-details summary:hover {
  background: #fef3c7;
}

.troubleshooting-details[open] summary {
  border-bottom: 1px solid var(--border);
  background: #fef3c7;
}

.troubleshooting-content {
  padding: 12px;
}

.troubleshooting-content p {
  margin: 8px 0 4px 0;
  font-size: 12px;
  font-weight: 600;
  color: #78350f;
}

.troubleshooting-content ul,
.troubleshooting-content ol {
  margin: 4px 0 12px 0;
  padding-left: 20px;
  font-size: 12px;
}

.troubleshooting-content li {
  margin-bottom: 4px;
  color: #374151;
}

.troubleshooting-content .help-note {
  margin-top: 12px;
  padding: 8px;
  background: #ecfdf5;
  border-left: 3px solid var(--positive);
  border-radius: 4px;
  font-size: 11px;
  color: #065f46;
  font-style: italic;
}

@media (max-width: 600px) {
  .platform-instructions {
    grid-template-columns: 1fr;
  }
}

/* Details/summary styling */
#tab-addin details {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
}

#tab-addin details summary {
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 600;
  color: var(--rubric-primary);
  background: transparent;
  border: none;
  outline: none;
  font-size: 14px;
}

#tab-addin details summary:hover {
  background: var(--card-hover);
}

#tab-addin details[open] summary {
  border-bottom: 1px solid var(--border);
}

#tab-addin details ul {
  margin: 0;
  padding: 16px;
  padding-top: 12px;
}

#tab-addin details li {
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.4;
}

#tab-addin details li b {
  color: var(--rubric-primary);
  font-weight: 600;
}

#tab-addin details p {
  margin: 0 0 8px 0;
  padding: 0 16px 16px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
}

#tab-addin details p:last-child {
  margin-bottom: 0;
  padding-bottom: 16px;
}

/* Hint text */
.hint {
  font-style: italic;
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
}

/* ========================================
   Verify All Overlay
   ======================================== */

.verify-all-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  backdrop-filter: blur(2px);
  transition: opacity 0.2s ease;
}

.verify-all-overlay.hidden {
  display: none;
}

.verify-all-card {
  width: min(620px, 94vw);
  max-height: 90vh;
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideInScale 0.3s ease-out;
  transition: all 0.3s ease;
}

.verify-all-card.minimized {
  max-height: 60px;
  width: min(400px, 94vw);
}

@keyframes slideInScale {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.verify-all-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--rubric-primary) 0%, var(--rubric-secondary) 100%);
  border-bottom: 1px solid var(--rubric-accent);
}

.verify-all-header h3 {
  margin: 0;
  color: white;
  font-size: 16px;
  font-weight: 600;
}

.verify-all-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.verify-all-minimize,
.verify-all-cancel {
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.verify-all-minimize {
  padding: 4px 10px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

.verify-all-minimize:hover,
.verify-all-cancel:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
}

.verify-all-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Stage Progress */
.verify-all-stages {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.verify-stage {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  transition: all 0.3s ease;
}

.verify-stage.pending {
  opacity: 0.6;
}

.verify-stage.active {
  border-color: var(--rubric-primary);
  background: #fef2f2;
  box-shadow: 0 0 0 1px var(--rubric-light);
}

.verify-stage.complete {
  border-color: var(--positive);
  background: #f0fdf4;
}

.stage-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.stage-icon {
  font-size: 18px;
  line-height: 1;
}

.stage-label {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
  color: #111827;
}

.stage-count {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.stage-progress {
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
}

.stage-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--rubric-primary) 0%, var(--rubric-secondary) 100%);
  transition: width 0.4s ease;
  border-radius: 3px;
}

.verify-stage.complete .stage-progress-bar {
  background: linear-gradient(90deg, var(--positive) 0%, #15803d 100%);
}

/* Resolution Section */
.verify-all-resolutions {
  border-top: 2px solid var(--border);
  padding-top: 16px;
}

.verify-all-resolutions.hidden {
  display: none;
}

.resolutions-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.resolution-icon {
  font-size: 18px;
  line-height: 1;
}

.resolution-label {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
  color: #111827;
}

.resolution-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  background: var(--rubric-primary);
  color: white;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.resolutions-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: none;
  overflow: visible;
}

.resolution-item {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  animation: slideIn 0.3s ease-out;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.resolution-item.resolved {
  opacity: 0;
  transform: scale(0.95);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.resolution-item-header {
  padding: 10px 12px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

.resolution-context {
  font-size: 12px;
  font-weight: 600;
  color: var(--rubric-primary);
}

/* Adapt inline asks within overlay */
.resolution-ask-container {
  padding: 12px;
  position: relative;
  z-index: 1;
}

.resolution-ask-container .card {
  border: none;
  background: transparent;
  margin: 0;
  padding: 0;
  position: relative;
}

.resolution-ask-container .card-body {
  padding: 0;
  background: transparent;
  display: block !important;
}

.resolution-ask-container .results {
  margin: 0;
  display: block;
}

.resolution-ask-container .fc-inline-ask {
  margin: 0;
  border: 1px solid #e5e7eb !important;
  padding: 10px !important;
  background: #ffffff !important;
  border-radius: 10px;
  position: relative;
  pointer-events: auto;
  z-index: 2;
}

.resolution-ask-container .fc-inline-ask button {
  pointer-events: auto;
  cursor: pointer;
}

/* Completion State */
.verify-all-complete {
  text-align: center;
  padding: 40px 20px;
  animation: fadeIn 0.5s ease;
}

.verify-all-complete.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.complete-icon {
  font-size: 48px;
  color: var(--positive);
  margin-bottom: 12px;
}

.complete-message {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
}

/* ========================================
   Database Build Overlay
   ======================================== */

.database-build-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
  transition: opacity 0.2s ease;
}

.database-build-overlay.hidden {
  display: none;
}

.database-build-card {
  width: min(620px, 94vw);
  max-height: 90vh;
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideInScale 0.3s ease-out;
  transition: all 0.3s ease;
}

.database-build-card.minimized {
  max-height: 60px;
  width: min(400px, 94vw);
}

.database-build-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--rubric-primary) 0%, var(--rubric-secondary) 100%);
  border-bottom: 1px solid var(--rubric-accent);
}

.database-build-header h3 {
  margin: 0;
  color: white;
  font-size: 16px;
  font-weight: 600;
}

.database-build-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.database-build-minimize,
.database-build-cancel {
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.database-build-minimize {
  padding: 4px 10px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

.database-build-minimize:hover,
.database-build-cancel:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
}

.database-build-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Overall Progress */
.database-build-overall {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}

.overall-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.overall-label {
  font-weight: 600;
  font-size: 14px;
  color: #111827;
}

.overall-count {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.overall-progress {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 10px;
}

.overall-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--rubric-primary) 0%, var(--rubric-secondary) 100%);
  transition: width 0.4s ease;
  border-radius: 4px;
}

.overall-message {
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
}

/* Stage Progress */
.database-build-stages {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.build-stage {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  transition: all 0.3s ease;
}

.build-stage.hidden {
  display: none;
}

.build-stage.complete {
  border-color: var(--positive);
  background: #f0fdf4;
}

.build-stage .stage-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.build-stage .stage-icon {
  font-size: 16px;
  line-height: 1;
}

.build-stage .stage-label {
  flex: 1;
  font-weight: 600;
  font-size: 13px;
  color: #111827;
}

.build-stage .stage-detail {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

.build-stage .stage-progress {
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  overflow: hidden;
}

.build-stage .stage-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--rubric-primary) 0%, var(--rubric-secondary) 100%);
  transition: width 0.4s ease;
  border-radius: 2px;
}

.build-stage.complete .stage-progress-bar {
  background: linear-gradient(90deg, var(--positive) 0%, #15803d 100%);
}

/* Files List */
.database-build-files {
  border-top: 2px solid var(--border);
  padding-top: 16px;
}

.files-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.files-icon {
  font-size: 16px;
  line-height: 1;
}

.files-label {
  font-weight: 600;
  font-size: 14px;
  color: #111827;
}

.files-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  transition: all 0.2s ease;
}

.file-item.processing {
  border-color: var(--rubric-primary);
  background: #fef2f2;
}

.file-item.complete {
  border-color: var(--positive);
  background: #f0fdf4;
}

.file-item.error {
  border-color: var(--danger);
  background: #fef2f2;
}

.file-item .file-icon {
  font-size: 16px;
  line-height: 1;
}

.file-item .file-name {
  flex: 1;
  color: #111827;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item .file-status {
  font-size: 14px;
  line-height: 1;
}

/* Completion State */
.database-build-complete {
  text-align: center;
  padding: 40px 20px;
  animation: fadeIn 0.5s ease;
}

.database-build-complete.hidden {
  display: none;
}

.database-build-complete .complete-icon {
  font-size: 48px;
  color: var(--positive);
  margin-bottom: 12px;
}

.database-build-complete .complete-message {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 8px;
}

.database-build-complete .complete-stats {
  font-size: 14px;
  color: var(--muted);
}

/* Error State */
.database-build-error {
  text-align: center;
  padding: 40px 20px;
  animation: fadeIn 0.5s ease;
}

.database-build-error.hidden {
  display: none;
}

.database-build-error .error-icon {
  font-size: 48px;
  color: var(--danger);
  margin-bottom: 12px;
}

.database-build-error .error-message {
  font-size: 16px;
  font-weight: 600;
  color: var(--danger);
  margin-bottom: 8px;
}

.database-build-error .error-details {
  font-size: 13px;
  color: var(--muted);
  max-width: 400px;
  margin: 0 auto;
}

/* Code styling */
#tab-addin code {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--rubric-primary);
}

/* ==================== Citation Type Filter Panel ==================== */
.citation-type-filter-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}

.citation-type-filter-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}

.citation-type-filter-toggle:hover {
  background: var(--card-hover);
  color: #111827;
}

.citation-type-filter-toggle .toggle-icon {
  display: inline-block;
  margin-right: 8px;
  transition: transform 0.2s ease;
  font-size: 14px;
  color: var(--accent);
}

.citation-type-filter-toggle .toggle-icon.expanded {
  transform: rotate(90deg);
}

.citation-type-filter-toggle .toggle-text {
  flex: 1;
}

.citation-type-filter-toggle .filter-summary {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}

.citation-type-filter-content {
  display: none;
  padding: 0 12px 12px;
  border-top: 1px solid var(--border);
}

.citation-type-filter-content.show {
  display: block;
}

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

.type-filter-title {
  font-weight: 600;
  font-size: 12px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.type-filter-legend {
  display: flex;
  gap: 16px;
  padding-right: 4px;
}

.type-filter-legend .legend-item {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-width: 32px;
  text-align: center;
}

/* Category wrapper */
.category-wrapper {
  margin-bottom: 4px;
}

.category-wrapper:last-child {
  margin-bottom: 0;
}

/* Category row */
.category-row {
  display: flex;
  align-items: center;
  padding: 6px 4px;
  font-size: 13px;
  font-weight: 500;
  background: var(--card-hover);
  border-radius: 4px;
  margin-bottom: 2px;
}

.category-row:hover {
  background: var(--border);
}

.category-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.category-toggle:hover {
  color: var(--accent);
}

.category-label {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.category-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-count {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.category-count.has-count {
  color: var(--accent);
  font-weight: 500;
}

.category-controls {
  display: flex;
  gap: 16px;
}

/* Subtypes container */
.subtypes-container {
  margin-left: 20px;
  padding-left: 8px;
  border-left: 2px solid var(--border);
}

/* Subtype row */
.subtype-row {
  display: flex;
  align-items: center;
  padding: 4px 4px;
  font-size: 12px;
}

.subtype-row:hover {
  background: var(--card-hover);
  border-radius: 4px;
}

.subtype-spacer {
  width: 8px;
}

.type-label {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.type-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
}

.type-count {
  color: transparent;
  font-size: 11px;
  flex-shrink: 0;
  transition: color 0.2s ease;
}

.type-count.has-count {
  color: var(--accent);
  font-weight: 500;
}

.type-filter-controls {
  display: flex;
  gap: 16px;
}

.filter-checkbox-label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  cursor: pointer;
}

.filter-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

.filter-checkbox:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.filter-checkbox.show-checkbox {
  accent-color: var(--positive);
}

.filter-checkbox.verify-checkbox {
  accent-color: var(--accent);
}

/* ===== Usage Modal ===== */
.usage-modal .modal-content {
  width: min(520px, 90vw);
}

.usage-modal .close-modal {
  float: right;
  font-size: 24px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}

.usage-modal .close-modal:hover {
  color: var(--accent);
}

.usage-modal h3 {
  margin: 0 0 16px 0;
  font-size: 18px;
  font-weight: 600;
  color: #111827;
}

.usage-date-range {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--card-bg);
  border-radius: 8px;
  flex-wrap: wrap;
}

.usage-date-range label {
  font-size: 13px;
  color: var(--muted);
}

.usage-date-range input[type="date"] {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
}

.usage-summary {
  max-height: 400px;
  overflow-y: auto;
}

.usage-total {
  padding: 12px;
  background: var(--accent);
  color: white;
  border-radius: 8px;
  font-size: 16px;
  margin-bottom: 16px;
}

.usage-category {
  margin-bottom: 16px;
  padding: 12px;
  background: var(--card-bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.usage-category h4 {
  margin: 0 0 8px 0;
  font-size: 14px;
  font-weight: 600;
  color: #111827;
}

.usage-category ul {
  margin: 0;
  padding: 0 0 0 16px;
  font-size: 13px;
}

.usage-category li {
  padding: 4px 0;
  color: var(--muted);
}

.usage-category li strong {
  color: #111827;
}

.usage-category li.empty {
  font-style: italic;
  color: var(--muted);
}

.usage-date-info {
  margin-top: 12px;
  text-align: right;
  color: var(--muted);
}

.usage-summary .loading,
.usage-summary .error {
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.usage-summary .error {
  color: var(--negative);
}

/* =============================================================================
   TEXT SELECTION CONTEXT MENU
   ============================================================================= */

.selection-context-menu {
  position: fixed;
  z-index: 10000;
  background: var(--bg-charcoal);
  border: 1px solid var(--border-dark);
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
  padding: 4px;
  min-width: 180px;
  animation: selectionMenuFadeIn 0.15s ease-out;
}

@keyframes selectionMenuFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.selection-menu-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #f9fafb;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  text-align: left;
  font-family: inherit;
}

.selection-menu-btn:hover {
  background: var(--rubric-primary);
  color: white;
}

.selection-menu-btn:active {
  background: var(--rubric-secondary);
}

.selection-menu-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.selection-menu-btn:disabled:hover {
  background: transparent;
}

.selection-menu-btn svg {
  flex-shrink: 0;
  opacity: 0.8;
}

.selection-menu-btn:hover svg {
  opacity: 1;
}

/* Spinner for loading state */
.selection-menu-btn .spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: selectionSpinner 0.7s linear infinite;
}

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

/* Highlight for manually added citations */
.card[data-manual="true"] {
  border-left: 3px solid var(--rubric-primary);
}

.card[data-manual="true"] .card-header::before {
  content: "Manual";
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  background: var(--rubric-light);
  color: var(--rubric-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 8px;
}
