/* =====================================================
   CITATION MASTER — REDESIGNED STYLESHEET
   Design system: dark forest green, Manrope + Newsreader
   ===================================================== */

/* ─── CSS Custom Properties ─── */
:root {
  --primary:                  #4edea3;
  --primary-dim:              rgba(78,222,163,0.15);
  --bg:                       #0e1511;
  --surface:                  #0e1511;
  --surface-container-lowest: #09100c;
  --surface-container-low:    #161d19;
  --surface-container:        #1a211d;
  --surface-container-high:   #242c27;
  --outline-variant:          #3c4a42;
  --outline:                  #4f5d55;
  --on-surface:               #dde4dd;
  --on-surface-variant:       #bbcabf;
  --on-primary:               #002116;
  --error:                    #ef4444;
  --warning:                  #f59e0b;

  --font-sans:   'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif:  'Newsreader', 'Georgia', serif;

  --radius-sm:   0.375rem;
  --radius-md:   0.5rem;
  --radius-lg:   0.75rem;
  --radius-xl:   1rem;
  --radius-2xl:  1.25rem;
  --sidebar-mobile-rail-width: 64px;
}

/* ─── Reset ─── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html { height: 100%; }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--on-surface);
  line-height: 1.6;
  overflow-y: auto;
  height: 100%;
}

/* ─── Scrollbars ─── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--outline-variant); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--outline); }

/* =====================================================
   MAIN LAYOUT
   ===================================================== */
.app-container {
  display: flex;
  height: 100vh;
  background: var(--bg);
}

.app-container.blurred {
  filter: blur(8px) brightness(0.7);
  pointer-events: none;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  overflow-y: auto;
  min-width: 0;
}

/* =====================================================
   SIDEBAR
   ===================================================== */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background-color: var(--surface-container-low);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--outline-variant);
  transition: transform 0.3s ease;
  height: 100vh;
  overflow-y: hidden;
  position: sticky;
  top: 0;
}

.sidebar.show { transform: translateX(0); }

/* Sidebar Header */
.sidebar-header {
  padding: 16px 16px 12px;
  display: flex;
  align-items: center;
  border-bottom: none;
  margin-bottom: 8px;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-text {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 700;
  color: var(--on-surface);
  letter-spacing: -0.01em;
}

.sidebar-logo-mark {
  width: 22px;
  height: 22px;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  display: block;
  border-radius: 4px;
}

/* ─── Sidebar Navigation ─── */
.sidebar-nav {
  flex: 1;
  padding: 10px 10px 8px;
  overflow-y: auto;
  min-height: 0;
}

.sidebar-primary-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.my-library-list {
  margin-top: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 12px;
  color: color-mix(in srgb, var(--on-surface-variant) 88%, #e9efe9);
  text-decoration: none;
  border-radius: 10px;
  margin-bottom: 2px;
  font-size: 12px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-weight: 700;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
  border: 1px solid transparent;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: var(--font-sans);
  cursor: pointer;
}

.nav-item:hover {
  background-color: color-mix(in srgb, var(--surface-container) 86%, #06110d);
  color: var(--on-surface);
}

.nav-item.active {
  background: transparent;
  border-color: transparent;
  color: color-mix(in srgb, var(--on-surface-variant) 88%, #e9efe9);
}

.nav-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.nav-icon {
  font-size: 17px;
  flex-shrink: 0;
  color: inherit;
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 20;
}

.nav-item-upload .nav-icon {
  font-variation-settings: 'FILL' 1, 'wght' 600, 'GRAD' 0, 'opsz' 20;
}

.nav-item-library {
  color: color-mix(in srgb, var(--on-surface-variant) 88%, #e9efe9);
}

.nav-item-library.active {
  background: transparent;
  border-color: transparent;
  color: color-mix(in srgb, var(--on-surface-variant) 88%, #e9efe9);
}

/* ─── Collections & Section Controls ─── */
.collections-section {
  margin-top: 4px;
  padding: 0 10px;
  display: flex;
  flex-direction: column;
}

.collection-item {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  color: var(--on-surface-variant);
  text-decoration: none;
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
  margin-left: 18px;
  font-size: 12px;
  transition: background-color 0.15s ease;
  border: none;
  background: transparent;
  font-family: var(--font-sans);
  text-align: left;
}

.collection-item:hover { background-color: var(--surface-container); }

.section-title-with-icon {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--on-surface-variant);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px;
  margin-bottom: 4px;
}

.section-add-btn {
  background: var(--surface-container-high);
  border: 1px solid var(--outline-variant);
  color: var(--on-surface-variant);
  cursor: pointer;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.section-add-btn:hover {
  background-color: var(--primary-dim);
  border-color: var(--primary);
  color: var(--primary);
}

.section-add-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ─── Document History ─── */
.document-history-item-wrapper {
  position: relative;
  margin-bottom: 2px;
  z-index: 1;
}

.document-history-item-wrapper:has(.doc-options-menu.show) {
  z-index: 99999 !important;
  position: relative;
  isolation: isolate;
}

#documentHistory:has(.doc-options-menu.show) { overflow: visible !important; }

.document-history-item {
  position: relative;
  padding: 7px 10px;
  display: block;
  text-decoration: none;
  cursor: pointer;
  color: var(--on-surface-variant);
  margin-left: 0;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  font-size: 12px;
}

/* When history is collapsed and there are hidden rows, fade the last visible row. */
.document-history-item-wrapper.history-tail-fade .document-history-item {
  opacity: 0.82;
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 24%, rgba(0,0,0,0.18) 100%);
  mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 24%, rgba(0,0,0,0.18) 100%);
}

.document-history-item:hover { background: rgba(255,255,255,0.04); }
.document-history-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.document-history-item.selected { background-color: transparent !important; }
.document-history-item.selected .doc-title {
  color: var(--primary) !important;
  font-weight: 600 !important;
}
.document-history-item.selected .doc-details { color: var(--on-surface-variant) !important; }

.doc-title {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--on-surface-variant);
}

.doc-details { font-size: 11px; color: var(--on-surface-variant); opacity: 0.7; }

.document-history-collapsed {
  position: relative;
  max-height: 260px;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.document-history-collapsed::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 26px;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(22,29,25,0) 0%, var(--surface-container-low) 90%);
}

.document-history-expanded {
  max-height: none;
  overflow: visible;
  padding-bottom: 10px;
  margin-bottom: 10px;
  transition: max-height 0.3s ease;
}

#documentHistory.document-history-collapsed {
  max-height: 260px;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.document-history-collapsed:has(.doc-options-menu.show) {
  overflow: visible !important;
  z-index: 2001;
}

.document-history-collapsed:has(.doc-options-menu.show)::after,
.document-history-collapsed.menu-open::after { display: none; }

#documentHistory.document-history-expanded {
  max-height: none;
  overflow: visible;
}

.expand-control {
  margin-left: 0;
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.expand-control.ready { opacity: 1; }

.expand-link {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--on-surface-variant);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background-color 0.15s;
  border: none;
  background: transparent;
  width: 100%;
  cursor: pointer;
  font-family: var(--font-sans);
  text-align: left;
}

.expand-link:hover {
  background: rgba(255,255,255,0.04);
  color: var(--on-surface);
}

/* ─── History Item Menus ─── */
.history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-item-header .doc-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-menu-trigger {
  cursor: pointer !important;
  padding: 2px 6px !important;
  user-select: none;
  font-size: 14px;
  line-height: 1;
  border-radius: var(--radius-sm) !important;
  transition: background-color 0.15s ease !important;
  color: var(--on-surface-variant);
  border: none;
  background: transparent;
  font-family: var(--font-sans);
}

.history-menu-trigger:hover { background: var(--surface-container-high); }
.history-menu-trigger:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.doc-options-menu {
  position: absolute;
  top: 100%;
  right: 12px;
  background-color: var(--surface-container-high);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-lg);
  display: none;
  flex-direction: column;
  min-width: 180px;
  z-index: 99999 !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.doc-options-menu .menu-item {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--on-surface);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer !important;
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  font-family: var(--font-sans);
}

.doc-options-menu .menu-item:hover { background: rgba(255,255,255,0.06); }
.doc-options-menu .menu-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.doc-options-menu.show {
  display: flex;
  position: absolute !important;
}

.document-history-collapsed:has(.doc-options-menu.show),
.document-history-collapsed.menu-open { overflow: visible !important; }

.doc-options-menu .menu-item.delete { color: var(--error); }

/* ─── Sidebar Footer ─── */
.sidebar-footer {
  padding: 8px;
  margin-top: auto;
  flex-shrink: 0;
  border-top: 1px solid var(--outline-variant);
}

.plan-info-section { padding: 0 2px; }

.usage-stats-title {
  font-size: 9px;
  font-weight: 700;
  color: color-mix(in srgb, var(--on-surface-variant) 92%, #d9e2dc);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.current-plan {
  background-color: var(--surface-container);
  border-radius: 10px;
  padding: 7px;
  border: 1px solid var(--outline-variant);
}

.current-plan-balance {
  background: linear-gradient(165deg, color-mix(in srgb, var(--surface-container-low) 88%, #0a1310), color-mix(in srgb, var(--surface-container-lowest) 96%, #040806));
  border-color: color-mix(in srgb, var(--primary) 38%, var(--outline-variant));
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--primary) 12%, transparent);
}

.plan-name {
  font-size: 12px;
  color: var(--on-surface-variant);
  line-height: 1.8;
}

.plan-stats {
  font-size: 11px;
  color: var(--on-surface-variant);
  opacity: 0.8;
  line-height: 1.5;
}

.plan-stats div { margin-bottom: 1px; }

.credit-balance {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin: 0 0 6px;
}

.credit-count {
  font-size: 22px;
  line-height: 1;
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: -0.02em;
}

.credit-label {
  font-size: 9px;
  line-height: 1;
  color: color-mix(in srgb, var(--primary) 94%, #ecfff7);
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
}

.last-topup-card {
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface-container-lowest) 96%, #020705);
  border: 1px solid color-mix(in srgb, var(--outline-variant) 70%, transparent);
  padding: 5px 7px;
  margin-bottom: 6px;
}

.last-topup-date {
  font-size: 8px;
  color: var(--on-surface-variant);
  margin-bottom: 2px;
  text-transform: uppercase;
}

.last-topup-pack {
  font-size: 9px;
  color: var(--on-surface);
  font-weight: 600;
}

.topup-btn {
  display: flex;
  width: 100%;
  justify-content: center;
  align-items: center;
  gap: 0;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--primary) 80%, transparent);
  background: var(--primary);
  color: var(--on-primary);
  text-decoration: none;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  transition: filter 0.2s ease, transform 0.2s ease;
  margin-bottom: 10px;
}

.topup-btn:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.topup-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.sidebar-topup-btn {
  background: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 75%, transparent);
  color: var(--on-primary);
  border-radius: 8px;
  padding: 5px 8px;
  min-height: 27px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  gap: 4px;
  margin-bottom: 6px;
}

.sidebar-topup-btn i {
  font-size: 9px;
}

.referral-copy {
  font-size: 9px;
  color: color-mix(in srgb, var(--on-surface-variant) 90%, #f0f7f2);
  text-align: center;
  line-height: 1.2;
  margin-bottom: 4px;
}

.referral-link {
  display: inline-block;
  width: 100%;
  text-align: center;
  color: var(--primary);
  text-decoration: underline;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.referral-link:hover {
  color: color-mix(in srgb, var(--primary) 90%, #dfffee);
}

.referral-popup-card {
  max-width: 460px;
}

.referral-popup-copy {
  font-size: 13px;
  color: var(--on-surface-variant);
  margin-bottom: 10px;
  line-height: 1.45;
}

.referral-popup-input {
  font-family: var(--font-sans);
  font-size: 12px;
  margin-bottom: 10px;
}

.referral-popup-actions {
  display: flex;
  justify-content: flex-end;
}

/* ─── History Loading ─── */
.history-loading {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 12px 10px;
  color: var(--on-surface-variant);
  font-size: 12px;
  margin-left: 22px;
  gap: 8px;
}

.history-loading.history-empty {
  margin-left: 38px;
  padding: 8px 0;
  gap: 0;
}

.history-loading::before { display: none !important; }

@keyframes logoSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.history-loading-logo {
  width: 16px;
  height: 16px;
  background-image: url('./CitationMasterLogo.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  animation: logoSpin 1.5s linear infinite;
  flex-shrink: 0;
  filter: brightness(0) invert(1);
}

/* =====================================================
   TOP HEADER
   ===================================================== */
.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background-color: var(--bg);
  flex-shrink: 0;
}

.mobile-menu-btn {
  background: none;
  border: none;
  color: var(--on-surface);
  font-size: 20px;
  cursor: pointer;
  margin-right: 16px;
  display: none;
  padding: 4px;
}

/* ─── User Section ─── */
.user-section {
  position: relative;
  display: flex;
  align-items: center;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4edea3 0%, #2db87c 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--on-primary);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  position: relative;
  border: 2px solid var(--outline-variant);
  transition: border-color 0.2s;
  padding: 0;
  font-family: inherit;
}

.user-avatar:hover { border-color: var(--primary); }
.user-avatar:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.avatar-initial { line-height: 1; }

.subscription-badge {
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--primary);
  color: var(--on-primary);
  font-size: 7px;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 700;
  display: none;
  z-index: 10;
  white-space: nowrap;
}

.subscription-badge:not(:empty) {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.login-btn {
  background: var(--primary);
  border: none;
  color: var(--on-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  transition: opacity 0.2s;
}

.login-btn:hover { opacity: 0.9; }

/* ─── User Menu Dropdown ─── */
.user-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background-color: var(--surface-container-high);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-lg);
  padding: 6px 0;
  min-width: 210px;
  display: none;
  z-index: 1000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.user-menu.show { display: block; }

.user-info {
  padding: 10px 14px 10px;
  border-bottom: 1px solid var(--outline-variant);
  margin-bottom: 4px;
}

.user-email { font-size: 13px; color: var(--on-surface); }
.user-tier  { font-size: 11px; color: var(--on-surface-variant); margin-top: 2px; }

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  color: var(--on-surface);
  text-decoration: none;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: var(--font-sans);
}

.menu-item:hover { background-color: rgba(255,255,255,0.05); }
.menu-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.menu-icon {
  font-size: 16px;
  color: var(--on-surface-variant);
  font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 20;
  flex-shrink: 0;
}

/* =====================================================
   CONTENT AREA & WELCOME SECTION
   ===================================================== */
.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 32px 32px;
  width: 100%;
  overflow-y: auto;
}

/* Welcome Section */
.welcome-section {
  width: min(100%, 980px);
  text-align: left;
  margin: 48px auto 36px;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.welcome-title {
  font-family: var(--font-sans);
  font-size: clamp(36px, 4.5vw, 52px);
  line-height: 1.08;
  font-weight: 700;
  color: var(--on-surface);
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.welcome-subtitle {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 16px;
  color: var(--on-surface-variant);
  margin-bottom: 0;
}

/* ─── Style Carousel ─── */
.upload-workspace {
  width: min(100%, 980px);
  margin: 0 auto 20px;
}

.upload-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.default-style-indicator {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--on-surface);
}

.default-style-indicator strong {
  color: var(--primary);
}

.default-style-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--primary) 15%, transparent);
  flex-shrink: 0;
}

.experimental-style-picker {
  position: relative;
}

.experimental-style-btn {
  background: var(--surface-container-low);
  border: 1px solid var(--outline-variant);
  color: var(--on-surface);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 12px;
  font-weight: 700;
  border-radius: 10px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.experimental-style-btn:hover {
  border-color: var(--primary);
  background: var(--surface-container);
}

.experimental-style-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.experimental-style-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 210px;
  padding: 6px;
  border-radius: var(--radius-lg);
  background: var(--surface-container-high);
  border: 1px solid var(--outline-variant);
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  display: none;
  z-index: 1200;
}

.experimental-style-menu.show {
  display: block;
}

.experimental-style-menu button {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--on-surface);
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font-sans);
}

.experimental-style-menu button:hover {
  background: rgba(255,255,255,0.05);
}

.experimental-style-divider {
  height: 1px;
  background: var(--outline-variant);
  margin: 6px 4px;
}

.experimental-style-section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--on-surface-variant);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px 6px;
}

.upload-dropzone {
  width: 100%;
  border: 1.5px dashed rgba(78,222,163,0.20);
  border-radius: 14px;
  min-height: 360px;
  background: linear-gradient(180deg, rgba(16,28,22,0.70) 0%, rgba(14,21,17,0.55) 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 26px;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.upload-dropzone:hover {
  border-color: rgba(78,222,163,0.42);
  background: linear-gradient(180deg, rgba(20,35,28,0.78) 0%, rgba(14,21,17,0.70) 100%);
}

.upload-dropzone.drag-active {
  border-color: var(--primary);
  background: linear-gradient(180deg, rgba(20,35,28,0.82) 0%, rgba(14,21,17,0.78) 100%);
  box-shadow: 0 0 0 2px rgba(78,222,163,0.18) inset;
  transform: scale(0.998);
}

.upload-dropzone:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.upload-drop-icon-wrap {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(78,222,163,0.30);
  background: rgba(78,222,163,0.08);
  margin-bottom: 16px;
}

.upload-drop-icon {
  font-size: 44px;
  color: var(--primary);
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 48;
}

.upload-drop-title {
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 800;
  color: var(--on-surface);
  max-width: 760px;
}

.upload-drop-title-mobile { display: none; }

.upload-drop-subtitle {
  margin-top: 10px;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 20px;
  color: var(--on-surface-variant);
}

.upload-drop-subtitle-mobile { display: none; }

.upload-drop-link {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.upload-drop-note {
  margin-top: 14px;
  text-align: center;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 13px;
  color: var(--on-surface-variant);
  opacity: 0.75;
}

.style-carousel {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  transition: transform 0.15s ease;
}

.style-card {
  background-color: var(--surface-container);
  border: 1.5px solid var(--outline-variant);
  border-radius: var(--radius-lg);
  padding: 22px 14px;
  text-align: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;
}

.style-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(78,222,163,0.18);
  background-color: var(--surface-container-high);
}

.style-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 0%, rgba(78,222,163,0.06) 100%);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.style-card:hover::before { opacity: 1; }

.document-icon {
  font-size: 36px;
  color: var(--primary);
  margin-bottom: 10px;
  display: flex;
  justify-content: center;
}

.document-icon .material-symbols-outlined {
  font-size: 36px;
  font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 40;
}

.style-name {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 700;
  color: var(--on-surface);
  margin-bottom: 4px;
}

.style-description {
  font-size: 11px;
  color: var(--on-surface-variant);
  line-height: 1.4;
}

/* ─── Hidden File Input ─── */
.file-input { display: none; }

/* =====================================================
   PROGRESS AREA
   ===================================================== */
.progress-area {
  width: 100%;
  max-width: 760px;
  margin: 24px auto 32px;
  display: none;
}

.progress-container {
  background: rgba(22, 29, 25, 0.25);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-xl);
  padding: 28px 28px 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

/* Neural Engine Active Pill */
.neural-engine-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--primary-dim);
  border: 1px solid rgba(78,222,163,0.3);
  border-radius: 99px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.04em;
  margin-bottom: 20px;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 0.3; transform: scale(0.7); }
  50%       { opacity: 1;   transform: scale(1.1); }
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse-dot 1.4s ease-in-out infinite;
  flex-shrink: 0;
}

/* Processing — large background watermark logo, centered within the container */
.progress-logo-bg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 220px;
  height: 220px;
  background-image: url('./CitationMasterLogo.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.10;
  pointer-events: none;
  z-index: 0;
}

/* Ensure content inside progress-container sits above the watermark */
.progress-container > *:not(.progress-logo-bg) {
  position: relative;
  z-index: 1;
}

/* Done message */
.progress-message {
  color: var(--on-surface);
  font-family: var(--font-sans);
  font-size: 16px;
  text-align: center;
  margin-bottom: 8px;
  line-height: 1.6;
}

/* ─── Scoreboard ─── */
.scoreboard {
  margin-top: 20px;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.scoreboard.visible { opacity: 1; }

.scoreboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.score-card {
  background: rgba(22, 29, 25, 0.75);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-md);
  padding: 14px 8px;
  text-align: center;
}

.score-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}

.score-value.pending { color: var(--outline); }

.score-label {
  font-size: 10px;
  color: var(--on-surface-variant);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.3;
}

/* Shimmer animations */
@keyframes label-shimmer {
  from { background-position: 100% 0; }
  to   { background-position:   0% 0; }
}

.score-label.label-shimmering {
  background: linear-gradient(90deg, var(--on-surface-variant) 15%, #d4f4ec 50%, var(--on-surface-variant) 85%);
  background-size: 400% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: label-shimmer 2s linear infinite;
}

.score-value.label-shimmering {
  background: linear-gradient(90deg, var(--primary) 10%, #c8f8ee 50%, var(--primary) 90%);
  background-size: 400% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: label-shimmer 1.6s linear infinite;
}

@media (max-width: 600px) {
  .scoreboard-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ─── Live Synthesis Panel ─── */
.live-synthesis-panel {
  margin-top: 18px;
  background: rgba(22, 29, 25, 0.75);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-md);
  overflow: hidden;
  text-align: left;
}

.synthesis-panel-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--outline-variant);
  font-size: 11px;
  font-weight: 600;
  color: var(--on-surface-variant);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(22, 29, 25, 0.75);
}

/* Milestone log (AI thinking ticker) */
.milestone-log {
  padding: 10px 14px;
  max-height: 150px;
  overflow-y: auto;
  scrollbar-width: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.milestone-log::-webkit-scrollbar { display: none; }

@keyframes dot-pulse {
  0%, 100% { opacity: 0.15; transform: scale(0.7); }
  50%       { opacity: 1;    transform: scale(1.15); }
}

.milestone-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  margin-left: 4px;
}

.milestone-dots span {
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0.15;
  animation: dot-pulse 1.2s ease-in-out infinite;
}

.milestone-dots span:nth-child(1) { animation-delay: 0s; }
.milestone-dots span:nth-child(2) { animation-delay: 0.2s; }
.milestone-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes insight-fade-in {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: translateY(0); }
}

.insight-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12px;
  color: #d1d5db;
  animation: insight-fade-in 0.35s ease both;
  transition: opacity 0.5s ease;
}

.insight-item.insight-fading {
  opacity: 0.3;
  animation: none;
}

.insight-item.insight-fading .milestone-dots { display: none !important; }
.insight-item.insight-fading .milestone-dots span { animation: none !important; }

.insight-check {
  color: var(--primary);
  font-size: 11px;
  flex-shrink: 0;
  width: 12px;
  margin-top: 1px;
}

.insight-text { flex: 1; line-height: 1.4; }


/* ─── "Show me results" button (generated by JS) ─── */
.search-popup-btn,
.login-dialog button {
  background-color: var(--primary);
  color: var(--on-primary);
  border: none;
  padding: 12px 28px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-sans);
  transition: opacity 0.2s;
  width: 100%;
}

.search-popup-btn:hover, .login-dialog button:hover { opacity: 0.9; }

/* =====================================================
   RESULTS AREA — TABBED
   ===================================================== */

/* Tab bar */
.results-tab-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: color-mix(in srgb, var(--surface-container-lowest) 92%, #020605);
  border-bottom: 1px solid var(--outline-variant);
  margin-bottom: 0;
  padding: 10px 14px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.results-tabs {
  display: flex;
  gap: 0;
}

.results-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--on-surface-variant);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}

.results-tab .material-symbols-outlined {
  font-size: 16px;
}

.results-tab:hover {
  color: var(--on-surface);
}

.results-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.results-tab-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 4px;
}

.results-tab-actions .action-btn {
  border-radius: 10px;
  padding: 7px 13px;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 45%, transparent);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

/* =====================================================
   RESULTS AREA
   ===================================================== */
.results-area {
  align-self: stretch;
  width: 100%;
  display: none;
  height: auto;
  max-height: none;
  overflow: visible;
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface-container-lowest) 94%, #020605);
}

.results-container {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  gap: 0 !important;
  display: flex;
  flex-direction: column;
  height: auto;
  max-height: none;
  overflow: visible;
}

/* Results Section — flat tab panel (no card border in tabbed mode) */
.results-section {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  overflow: visible !important;
  transition: all 0.2s ease;
  margin-bottom: 0 !important;
}

.results-section:hover { border-color: var(--outline) !important; }

.results-section.collapsed .content-box { display: none; }

.results-section.expanded .section-actions {
  opacity: 1;
  transform: translateX(0);
}

.results-section.collapsed .section-actions {
  opacity: 0;
  transform: translateX(10px);
  pointer-events: none;
}

/* Section Header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface-container) !important;
  border-bottom: 1px solid var(--outline-variant);
  transition: background 0.15s ease;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
}

.section-header:hover { background: var(--surface-container-high) !important; }

.results-section.collapsed .section-header {
  border-radius: var(--radius-lg) !important;
  border-bottom: none;
}

.section-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-header-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-align: left;
}
.section-header-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.section-toggle-arrow {
  width: 20px;
  height: 20px;
  background: var(--outline-variant);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.section-toggle-arrow:hover { background: var(--outline); }

.results-section:not(.collapsed) .section-toggle-arrow .material-symbols-outlined {
  transform: rotate(90deg);
}

.section-title-results,
h3.section-title-results,
.results-section h3,
.results-section .section-title-results {
  font-family: var(--font-sans) !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  color: var(--on-surface) !important;
  letter-spacing: 0.01em !important;
  margin: 0 !important;
}

.section-title-results::before { display: none !important; }
.section-header h3 { font-weight: 600 !important; }

/* Section Actions */
.section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.25s ease;
}

/* ─── Action Buttons ─── */
.action-btn {
  background: var(--surface-container-high);
  color: var(--on-surface);
  border: 1px solid var(--outline-variant);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-sans);
  font-weight: 500;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 5px;
}

.action-btn:hover { background: var(--outline-variant); border-color: var(--outline); }

.action-btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.action-btn.primary:hover { opacity: 0.9; }

.action-btn i, .action-btn .material-symbols-outlined { font-size: 14px; }

/* Download button override */
.action-btn.download,
button[onclick*="downloadDocument"],
.download-btn {
  background: var(--surface-container-high) !important;
  color: var(--on-surface) !important;
  border: 1px solid var(--outline-variant) !important;
}

/* Legacy copy button */
.copy-btn {
  background-color: var(--primary);
  color: var(--on-primary);
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
  transition: opacity 0.2s;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 5px;
}

.copy-btn:hover { opacity: 0.9; }

/* ─── Dropdown Menus ─── */
.dropdown { position: relative; display: inline-block; }

.dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--surface-container-high);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  min-width: 190px;
  z-index: 1000;
  margin-top: 5px;
}

.dropdown-menu.show { display: block; }

.dropdown-menu a,
.dropdown-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--on-surface);
  text-decoration: none;
  font-size: 13px;
  transition: background-color 0.15s ease;
  border-bottom: 1px solid var(--outline-variant);
  width: 100%;
  background: transparent;
  border-left: none;
  border-right: none;
  border-top: none;
  text-align: left;
  font-family: var(--font-sans);
  cursor: pointer;
}

.dropdown-menu a:last-child,
.dropdown-menu button:last-child { border-bottom: none; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.dropdown-menu a:first-child,
.dropdown-menu button:first-child { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.dropdown-menu a:hover,
.dropdown-menu button:hover { background-color: rgba(255,255,255,0.05); }
.dropdown-menu button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.dropdown-toggle {
  background: var(--surface-container-high) !important;
  border: 1px solid var(--outline-variant) !important;
  color: var(--on-surface) !important;
  padding: 6px 10px !important;
  border-radius: var(--radius-md) !important;
  cursor: pointer !important;
  font-size: 14px !important;
  transition: all 0.15s ease !important;
  display: flex !important;
  align-items: center !important;
}

.dropdown-toggle:hover { background: var(--outline-variant) !important; }

/* ─── Content Box & Items ─── */
.content-box {
  background: var(--surface-container-lowest) !important;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg) !important;
  padding: 18px;
  max-height: none !important;
  height: auto !important;
  overflow: visible !important;
}

.footnote-item, .bib-entry {
  font-family: var(--font-serif);
  margin-bottom: 10px;
  padding: 10px 14px;
  background: var(--surface-container-low);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-md);
  line-height: 1.55;
  color: var(--on-surface);
  transition: all 0.15s ease;
  position: relative;
}

.footnote-item:hover, .bib-entry:hover {
  border-color: var(--outline);
  background: var(--surface-container);
}

#footnotesContent,
#bibliographyContent {
  max-height: none !important;
  overflow: visible !important;
}

/* =====================================================
   BIBLIOGRAPHY — INDENTATION & STATUS ICONS
   ===================================================== */
.bib-entry {
  text-indent: -1.5em;
  padding-left: calc(1.5em + 40px);
}

[data-style="IEEE"] .bib-entry { text-indent: 0; padding-left: 40px; }

[data-style="IEEE"] .dym-panel,
[data-style="IEEE"] .dym-uncertain-panel { margin-left: 0; }

.bib-entry .status-icon {
  position: absolute;
  left: 8px;
  top: 14px;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  z-index: 2;
  text-indent: 0;
}

.bib-entry .status-icon.verified      { color: #22c55e; }
.bib-entry .status-icon.verified_updated { color: #22c55e; }
.bib-entry .status-icon.unverified    { color: #b91c1c; }
.bib-entry .status-icon.missing       { color: var(--error); }

.bib-entry .status-icon.verified_updated .plus-badge {
  position: absolute;
  right: -6px;
  bottom: -6px;
  font-size: 10px;
  background: var(--surface-container-low);
  border-radius: 50%;
  padding: 1px;
  color: #22c55e;
}

/* AI status badges */
.bib-entry .status-icon.ai_suggested { color: #6366f1; }
.bib-entry .status-icon.ai_suggested:hover { color: #4f46e5; }
.bib-entry .status-icon.ai_verified  { color: #22c55e; }

.bib-entry .status-icon.ai_verified .ai-chip {
  display: inline-block;
  position: absolute;
  right: -10px;
  bottom: -7px;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0;
  background: var(--surface-container-low);
  color: #22c55e;
  border-radius: 3px;
  padding: 0 2px;
  line-height: 11px;
}

/* Bibliography heading */
.bibliography-heading,
h2.bibliography-title,
.content-header h2,
#bibliographyContent h1,
#bibliographyContent h2,
.content-box h1,
.content-box h2 {
  font-size: 1.4em !important;
  font-weight: bold;
  color: var(--on-surface);
  margin-bottom: 14px;
}

/* =====================================================
   DID YOU MEAN — INLINE PANELS
   ===================================================== */
.dym-panel {
  text-indent: 0;
  padding-left: 0;
  margin: 8px 0 8px -1.5em;
  padding: 10px 12px;
  background: #1e1e2e;
  border: 1px solid #6366f1;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: #d4d4d8;
  line-height: 1.5;
  font-style: normal;
}

.dym-panel * { text-indent: 0; }

.dym-reasoning {
  margin-bottom: 10px;
  color: #a1a1aa;
  font-style: italic;
  padding-left: 0;
  word-wrap: break-word;
}

.dym-compare { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.dym-compare-row { display: flex; align-items: baseline; gap: 8px; }
.dym-compare-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #71717a;
  flex: 0 0 60px;
  letter-spacing: 0.04em;
}

.dym-compare-text {
  flex: 1;
  background: #27272a;
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 12px;
  color: #e4e4e7;
  word-wrap: break-word;
  line-height: 1.5;
}

.dym-compare-text.dym-suggested { border-left: 2px solid #6366f1; color: #c4b5fd; }

.dym-source-link {
  display: inline-block;
  margin-bottom: 8px;
  color: #818cf8;
  font-size: 12px;
  text-decoration: underline;
}

.dym-actions { display: flex; gap: 8px; }

.dym-btn {
  padding: 4px 14px;
  border-radius: 4px;
  border: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.dym-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.dym-accept { background: #22c55e; color: #000; }
.dym-accept:hover:not(:disabled) { opacity: 0.85; }
.dym-reject { background: #3f3f46; color: #d4d4d8; }
.dym-reject:hover:not(:disabled) { background: #52525b; }
.dym-status-msg { margin-top: 6px; font-size: 12px; color: #f59e0b; }

/* Uncertain panel */
.dym-uncertain-panel {
  text-indent: 0;
  padding-left: 0;
  margin: 8px 0 8px -1.5em;
  padding: 10px 12px;
  background: #1e0e0e;
  border: 1px solid var(--error);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: #d4d4d8;
  line-height: 1.5;
  font-style: normal;
}

.dym-uncertain-panel * { text-indent: 0; }
[data-style="IEEE"] .dym-uncertain-panel { margin-left: 40px; }

.dym-uncertain-heading {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #b91c1c;
  margin-bottom: 6px;
}

.dym-uncertain-reasoning { color: #a1a1aa; font-style: italic; word-wrap: break-word; }

.dym-uncertain-source {
  display: inline-block;
  margin-top: 8px;
  color: #f87171;
  font-size: 12px;
  text-decoration: underline;
}

/* =====================================================
   VERIFIED CITATION AUDIT PANEL
   ===================================================== */
.verified-panel {
  text-indent: 0;
  padding-left: 0;
  margin: 8px 0 8px -1.5em;
  padding: 10px 12px;
  background: #0a1410;
  border: 1px solid #22c55e;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: #d4d4d8;
  line-height: 1.5;
  font-style: normal;
}

.verified-panel * { text-indent: 0; }
[data-style="IEEE"] .verified-panel { margin-left: 0; }

.verified-panel-heading {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #4ade80;
  margin-bottom: 6px;
}

.verified-panel-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.verified-panel-top-row .verified-panel-heading { margin-bottom: 0; }

.verified-report-btn {
  border: 1px solid #f59e0b;
  background: transparent;
  color: #facc15;
  border-radius: 4px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.verified-report-btn:hover { background: rgba(245,158,11,0.14); }
.verified-report-btn:focus { outline: 2px solid rgba(250,204,21,0.55); outline-offset: 1px; }

.verified-source-link {
  display: inline-block;
  margin-bottom: 8px;
  color: #4ade80;
  font-size: 12px;
  text-decoration: underline;
}

.verified-feedback-title { font-size: 14px; font-weight: 600; color: #dcfce7; margin-bottom: 8px; }

.verified-feedback-input {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  box-sizing: border-box;
  background: #050b08;
  color: #e4e4e7;
  border: 1px solid #22c55e;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.4;
}

.verified-feedback-input::placeholder { color: #a1a1aa; }
.verified-feedback-actions { margin-top: 8px; display: flex; justify-content: flex-end; }

.verified-feedback-submit {
  border: 1px solid #22c55e;
  background: #14532d;
  color: #dcfce7;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}

.verified-feedback-submit:hover:not(:disabled) { background: #166534; }
.verified-feedback-submit:disabled { opacity: 0.65; cursor: not-allowed; }
.verified-feedback-status { margin-top: 8px; font-size: 12px; }
.verified-feedback-pending { color: #86efac; }
.verified-feedback-error   { color: #fca5a5; }
.verified-feedback-success { color: #dcfce7; font-size: 12px; line-height: 1.5; }

.verified-audit-table {
  width: 100%;
  display: table;
  border-collapse: separate;
  border-spacing: 0 2px;
  font-size: 12px;
  table-layout: fixed;
}

.verified-audit-table td { padding: 2px 6px 2px 0; vertical-align: middle; line-height: 1.4; }
.verified-audit-label { font-weight: 600; color: #86efac; white-space: nowrap; padding-right: 8px; width: 80px; }
.verified-audit-before { color: #71717a; text-decoration: line-through; width: 42%; word-break: break-word; }
.verified-audit-arrow { color: #4ade80; padding: 0 4px; white-space: nowrap; width: 28px; text-align: center; }
.verified-audit-after { color: #d4d4d8; width: 42%; word-break: break-word; }

/* =====================================================
   POPUPS & OVERLAYS
   ===================================================== */
.search-popup-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.75);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.search-popup, .about-popup, .login-dialog {
  background: var(--surface-container);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-xl);
  padding: 24px;
  width: 90%;
  max-width: 560px;
  position: relative;
  max-height: 80vh;
  overflow-y: auto;
}

.search-popup-title, .about-popup h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--on-surface);
  margin-bottom: 18px;
}

.search-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: var(--on-surface-variant);
  cursor: pointer;
  font-size: 20px;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  display: flex;
  align-items: center;
}

.search-close-btn:hover { background-color: var(--surface-container-high); color: var(--on-surface); }

.search-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

/* About Popup */
.about-popup {
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

#aboutPopup { z-index: 9999 !important; }
#aboutPopup.show { display: flex !important; opacity: 1 !important; visibility: visible !important; }

.about-popup .search-popup-header { flex-shrink: 0; margin-bottom: 18px; }

.about-tagline { font-size: 17px; color: var(--primary); margin-bottom: 18px; font-weight: 500; }

.about-content { line-height: 1.6; overflow-y: auto; flex: 1; padding-right: 8px; }

.about-section { margin-top: 22px; }

.about-section h4 { font-size: 15px; font-weight: 600; color: var(--on-surface); margin-bottom: 10px; }
.about-section ol { margin-bottom: 18px; }
.about-description { color: var(--on-surface-variant); margin-bottom: 22px; line-height: 1.6; }
.about-section ul li, .about-section ol li { color: var(--on-surface-variant); line-height: 1.5; }

.beta-disclaimer {
  background-color: rgba(232,185,35,0.1);
  border: 1px solid rgba(232,185,35,0.3);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-top: 22px;
}

.beta-disclaimer h4 { color: #e8b923 !important; }

.bug-report-popup {
  background: #1e2225;
  border: 1px solid #3a4148;
  border-radius: 18px;
  padding: 20px;
  width: min(92vw, 760px);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bug-report-popup .search-popup-header {
  margin-bottom: 2px;
}

.bug-report-popup .search-close-btn {
  top: 8px;
  right: 8px;
}

.bug-report-input {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  border: 1px solid #3c444c;
  background: #1f2328;
  color: #f4f6f8;
  border-radius: 12px;
  padding: 14px;
  line-height: 1.45;
  font-size: 16px;
  font-family: var(--font-sans);
}

.bug-report-input::placeholder {
  color: #9aa2ab;
}

.bug-report-input:focus-visible {
  outline: 2px solid #8fa6ff;
  outline-offset: 2px;
}

.bug-report-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 20px;
}

.bug-report-status {
  font-size: 13px;
}

.bug-report-status.error {
  color: #f8b4b4;
}

.bug-report-status.success {
  color: #98f5c3;
}

.bug-report-status.pending {
  color: #c3d3ff;
}

.bug-report-char-count {
  margin-left: auto;
  color: #a6adb6;
  font-size: 13px;
}

.bug-report-actions {
  display: flex;
  justify-content: flex-end;
}

.bug-report-submit-btn {
  border: 0;
  border-radius: 999px;
  background: #eceff3;
  color: #101417;
  font-weight: 600;
  padding: 11px 24px;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.bug-report-submit-btn:hover:not(:disabled) {
  opacity: 0.9;
}

.bug-report-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.account-settings-popup {
  background: #121917;
  border: 1px solid #2d3a35;
  border-radius: 18px;
  padding: 20px;
  width: min(92vw, 620px);
  max-height: 88vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.danger-settings-section {
  background: #0f1513;
  border: 1px solid #2a3531;
  border-radius: 14px;
  padding: 14px;
}

.danger-settings-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.danger-settings-row h4 {
  margin: 0;
  font-size: 15px;
  color: #ecf3ef;
}

.danger-settings-icon {
  font-size: 15px;
  color: #f3a3a3;
}

.danger-settings-section p {
  margin: 0 0 12px;
  color: #c7d3cd;
  line-height: 1.55;
  font-size: 13px;
}

.danger-settings-btn {
  border: 1px solid rgba(255, 113, 113, 0.35);
  border-radius: 10px;
  background: #671c20;
  color: #ffe9e9;
  width: 100%;
  padding: 11px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.danger-settings-btn:hover:not(:disabled) {
  opacity: 0.92;
  transform: translateY(-1px);
}

.danger-settings-btn:disabled {
  opacity: 0.58;
  cursor: not-allowed;
  transform: none;
}

.danger-settings-btn-library {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.18);
  color: #facc15;
}

.danger-settings-btn-account {
  border-color: rgba(255, 96, 96, 0.4);
  background: #7a1f24;
}

.account-settings-status {
  font-size: 13px;
  line-height: 1.45;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 10px 12px;
}

.account-settings-status.pending {
  color: #c3d3ff;
  border-color: rgba(143, 166, 255, 0.35);
  background: rgba(66, 84, 124, 0.22);
}

.account-settings-status.success {
  color: #baf3c5;
  border-color: rgba(69, 184, 122, 0.35);
  background: rgba(22, 86, 53, 0.22);
}

.account-settings-status.error {
  color: #ffc5c5;
  border-color: rgba(255, 110, 110, 0.36);
  background: rgba(123, 34, 34, 0.2);
}

/* ─── Forms & Inputs ─── */
.search-input, .login-dialog input {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface-container-lowest);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-md);
  color: var(--on-surface);
  font-family: var(--font-sans);
  font-size: 14px;
  transition: border-color 0.2s;
}

.search-input:focus { border-color: var(--primary); }
.search-input:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.search-input::placeholder { color: var(--on-surface-variant); }

.login-error { color: var(--error); font-size: 14px; margin-bottom: 8px; }
.login-input-container { margin-bottom: 18px; }

/* ─── Firebase UI ─── */
.firebaseui-container { max-width: 360px !important; }

#firebaseUIDialog .firebase-ui-container {
  background: #fff !important;
  width: 360px;
  max-width: 90%;
  margin: 0 auto;
  padding: 24px !important;
  border-radius: var(--radius-lg);
  box-shadow: inset 0 0 0 1px #000, 0 4px 24px rgba(0,0,0,0.2);
  text-align: center;
  font-family: var(--font-sans) !important;
}

#firebaseUIDialog .firebase-ui-container .fm-logo {
  display: block;
  margin: 50px auto 22px;
  max-height: 58px;
}

.firebaseui-idp-button { border-radius: 6px !important; }
.firebaseui-idp-google .firebaseui-idp-text { color: #444 !important; }
.firebaseui-idp-button.firebaseui-idp-google { width: 100% !important; border-radius: 6px !important; }
.firebaseui-idp-button.firebaseui-idp-password { background-color: var(--primary) !important; border-color: var(--primary) !important; }
.firebaseui-idp-button.firebaseui-idp-password .firebaseui-idp-text { color: var(--on-primary) !important; }
.firebaseui-title { font-size: 1.4em; color: var(--primary); }
.firebaseui-card-footer, #firebaseUIDialog .firebase-ui-container > button,
#firebaseUIDialog .firebase-ui-container > .firebaseui-idp-list + * { display: none !important; }
#firebaseui-auth-container { max-width: 100% !important; }
.firebaseui-card-content { padding: 20px !important; }

/* =====================================================
   DOCUMENT VIEWER
   ===================================================== */
.document-viewer {
  background: #f5f5f5;
  padding: 20px;
  border-radius: var(--radius-md);
  height: auto !important;
  min-height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  border: 1px solid #ddd;
  width: 100%;
}

.document-page {
  background: white;
  width: 8.5in;
  height: auto !important;
  min-height: auto !important;
  margin: 0 auto 40px auto;
  padding: 1in 1in 2in 1in;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  font-family: 'Times New Roman', serif;
  font-size: 12pt;
  line-height: 1.6;
  color: #000;
  overflow: visible !important;
}

.document-page:last-of-type { margin-bottom: 60px !important; padding-bottom: 3in !important; }
.document-page p { margin: 0 0 12pt 0; }
.document-page h1, .document-page h2, .document-page h3 { color: #000; margin: 18pt 0 6pt 0; }
.document-page sup { font-size: 8pt; vertical-align: super; }

/* Paginated viewer */
.document-viewer-paginated {
  background: #e5e5e5;
  padding: 40px 20px;
  border-radius: var(--radius-md);
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.document-page-container { display: flex; justify-content: center; width: 100%; }

.document-viewer-paginated .document-page {
  background: white;
  width: 8.5in;
  min-height: 11in;
  margin: 0;
  padding: 1in;
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
  font-family: 'Times New Roman', serif;
  font-size: 12pt;
  line-height: 1.6;
  color: #000;
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid #d1d1d1;
}

.page-header { height: 0.5in; display: flex; justify-content: flex-end; align-items: flex-start; margin-bottom: 0.25in; }
.page-number { font-size: 10pt; color: #666; margin-top: 0.25in; margin-right: 0.25in; }
.page-content { flex: 1; overflow: hidden; }
.page-footer { height: 0.5in; margin-top: auto; border-top: 1px solid #ccc; margin-top: 0.25in; padding-top: 0.25in; font-size: 10pt; }

.document-page[data-page="1"] .page-header { display: none; }
.document-page:hover { box-shadow: 0 6px 12px rgba(0,0,0,0.2); transition: box-shadow 0.2s ease; }
.document-viewer-paginated .document-page-container:last-child { margin-bottom: 40px; }

/* ─── Doc Viewer element ─── */
#docViewer {
  width: 100%;
  min-height: 100vh;
  overflow: visible !important;
  margin-top: 20px;
  height: auto;
}

#docViewer > iframe:not(#original-iframe):not(#processed-iframe) {
  width: 100% !important;
  height: 100vh !important;
  min-height: 100vh !important;
  max-height: none !important;
  border: none;
  overflow: hidden !important;
}

.results-section #docViewer { min-height: 100vh; width: 100%; }

.results-section.expanded { max-height: none !important; overflow: visible !important; }

/* Document toggle switch */
.doc-toggle {
  margin-bottom: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.doc-toggle-switch {
  position: relative;
  width: 80px;
  height: 32px;
  background: var(--surface-container-high);
  border-radius: 16px;
  border: 2px solid var(--outline-variant);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
}

.doc-toggle-switch.processed { background: var(--primary); border-color: var(--primary); }
.doc-toggle-handle {
  position: absolute;
  top: 2px; left: 2px;
  width: 24px; height: 24px;
  background: white;
  border-radius: 50%;
  transition: all 0.3s ease;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  z-index: 3;
}
.doc-toggle-switch.processed .doc-toggle-handle { transform: translateX(48px); }
.handle-label { font-size: 8px; font-weight: 600; color: #333; line-height: 1; }
.toggle-label-left, .toggle-label-right {
  position: absolute;
  font-size: 8px; font-weight: 600;
  color: var(--on-surface-variant);
  transition: color 0.3s ease;
  z-index: 1;
  pointer-events: none;
}
.toggle-label-left { left: 8px; top: 50%; transform: translateY(-50%); }
.toggle-label-right { right: 6px; top: 50%; transform: translateY(-50%); display: flex; align-items: center; }
.toggle-label-right img { width: 14px !important; height: 11px !important; }
.doc-toggle-switch.processed .toggle-label-left { color: rgba(255,255,255,0.7); }
.doc-toggle-switch:not(.processed) .toggle-label-right { opacity: 0.6; }
.doc-toggle-switch.processed .toggle-label-right { color: rgba(255,255,255,0.9); }

/* =====================================================
   COMPARE MODE
   ===================================================== */
.compare-mode-container { display: flex; gap: 20px; width: 100%; margin-top: 10px; max-width: 100%; }

.compare-document-viewer {
  flex: 1;
  background: var(--surface-container-lowest);
  padding: 10px;
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
  max-width: 50%;
}

.compare-document-header {
  background: var(--surface-container-high);
  color: var(--on-surface);
  margin: 0 0 10px 0;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
}

.compare-loading-overlay {
  position: absolute;
  top: 60px; left: 10px; right: 10px; bottom: 10px;
  background: var(--surface-container-lowest);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 40px;
  z-index: 100;
  border-radius: var(--radius-md);
}

.compare-loading-spinner { margin-bottom: 14px; width: 28px; height: 28px; }
.compare-loading-text { color: var(--on-surface); font-size: 14px; margin: 0; }

.compare-exit-container { text-align: center; margin: 18px 0; }

.compare-exit-btn {
  background: var(--surface-container-low);
  color: var(--on-surface);
  border: 1px solid var(--outline-variant);
  padding: 6px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.compare-exit-btn:hover { background: var(--surface-container); border-color: var(--outline); }

#original-iframe, #processed-iframe {
  border: none !important;
  border-radius: var(--radius-md) !important;
  display: block !important;
  background: white !important;
  width: 100% !important;
  height: 850px !important;
  min-height: 850px !important;
  max-height: 850px !important;
  margin: 0 auto;
}

/* =====================================================
   DOCUMENT LOADING
   ===================================================== */
@keyframes spin { to { transform: rotate(360deg); } }

#documentLoadingOverlay {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 100;
}

.custom-loading-spinner {
  width: 48px; height: 48px;
  margin: 0 auto 18px;
  background-image: url('./CitationMasterLogo.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  animation: logoSpin 2s linear infinite;
}

/* =====================================================
   SHARED DOCUMENT MODE
   ===================================================== */
.shared-mode .sidebar,
.shared-mode .top-header,
.shared-mode .welcome-section,
.shared-mode .upload-workspace,
.shared-mode .style-carousel { display: none !important; }

.shared-mode .main-content { margin-left: 0 !important; width: 100% !important; max-width: 100% !important; }
.shared-mode .content-area { padding-top: 40px; max-width: 100% !important; width: 100% !important; }

.shared-mode .results-area,
.shared-mode .results-section { max-width: 100% !important; width: 100% !important; margin: 0 !important; }

.shared-mode .document-viewer,
.shared-mode .compare-mode-container,
.shared-mode #docViewer { max-width: 100% !important; width: 100% !important; }

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 1200px) {
  .upload-drop-title { font-size: 26px; }
  .upload-drop-subtitle { font-size: 19px; }
  .style-carousel { grid-template-columns: repeat(3, 1fr); max-width: 580px; }
}

@media (max-width: 768px) {
  body {
    overflow: hidden;
  }

  .app-container {
    height: 100dvh;
    max-height: 100dvh;
  }

  .main-content {
    overflow: hidden;
    min-height: 0;
  }

  .style-carousel { grid-template-columns: repeat(2, 1fr); max-width: 380px; }

  .upload-meta-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .experimental-style-picker {
    width: 100%;
  }

  .experimental-style-btn {
    width: 100%;
    justify-content: space-between;
  }

  .experimental-style-menu {
    left: 0;
    right: auto;
    width: 100%;
  }

  .upload-dropzone {
    min-height: 300px;
    padding: 20px 16px;
  }

  .upload-drop-title { font-size: 24px; }
  .upload-drop-subtitle { font-size: 17px; }

  .upload-drop-icon-wrap {
    width: 78px;
    height: 78px;
  }

  .upload-drop-icon {
    font-size: 36px;
  }

  .mobile-menu-btn { display: flex; }

  .top-header {
    min-height: 56px;
    padding: 10px 16px 10px 10px;
  }

  .mobile-menu-btn {
    margin-right: 0;
    width: 24px;
    height: 24px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    width: var(--sidebar-mobile-rail-width);
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    box-shadow: none;
    transition: width 0.24s ease, box-shadow 0.24s ease;
  }

  .sidebar-header {
    height: 56px;
    padding: 0;
    margin-bottom: 0;
    align-items: center;
  }

  .sidebar .logo-section {
    width: 100%;
    justify-content: center;
    gap: 0;
  }

  .sidebar .logo-text { display: none; }

  .sidebar-nav { padding: 10px 6px 8px; }
  .sidebar-primary-actions {
    align-items: center;
    margin-top: 10px;
  }

  .sidebar .nav-item {
    justify-content: center;
    gap: 0;
    padding: 10px;
    min-height: 44px;
    font-size: 0;
  }

  .sidebar .nav-item .nav-icon { font-size: 20px; }

  .sidebar .my-library-list,
  .sidebar .sidebar-footer { display: none; }

  .sidebar.show {
    width: min(86vw, 320px);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.42);
  }

  .sidebar.show .sidebar-header {
    height: 56px;
    padding: 0 16px;
    margin-bottom: 4px;
  }

  .sidebar.show .logo-section {
    justify-content: flex-start;
    gap: 10px;
    width: auto;
  }

  .sidebar.show .logo-text { display: inline; }

  .sidebar.show .sidebar-nav { padding: 10px 10px 8px; }

  .sidebar.show .sidebar-primary-actions {
    align-items: stretch;
    margin-top: 2px;
  }

  .sidebar.show .nav-item {
    justify-content: flex-start;
    gap: 9px;
    padding: 11px 12px;
    font-size: 12px;
  }

  .sidebar.show .my-library-list,
  .sidebar.show .sidebar-footer { display: block; }

  .sidebar.show .sidebar-footer {
    max-height: none;
    overflow: visible;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
  }

  .sidebar.show .current-plan {
    padding: 6px;
  }

  .sidebar.show .usage-stats-title {
    margin-bottom: 4px;
  }

  .sidebar.show .credit-count {
    font-size: 20px;
  }

  .sidebar.show .last-topup-card {
    margin-bottom: 4px;
    padding: 4px 7px;
  }

  .sidebar.show .sidebar-topup-btn {
    margin-bottom: 4px;
    min-height: 25px;
  }

  .sidebar.show .referral-copy {
    margin-bottom: 2px;
  }

  .sidebar + .main-content {
    margin-left: var(--sidebar-mobile-rail-width);
    width: calc(100% - var(--sidebar-mobile-rail-width));
  }

  .sidebar.show + .main-content {
    margin-left: 0;
    width: 100%;
  }

  .content-area {
    padding: 8px 14px 10px;
  }

  .welcome-section {
    margin: 6px auto 8px;
  }

  .welcome-title {
    font-size: clamp(36px, 7.8vw, 40px);
    margin-bottom: 6px;
  }

  .welcome-subtitle {
    font-size: 13px;
    line-height: 1.35;
  }

  .upload-workspace {
    margin: 0 auto 6px;
  }

  .upload-meta-row {
    margin-bottom: 8px;
  }

  .upload-dropzone {
    min-height: 186px;
    padding: 14px 14px;
  }

  .upload-drop-icon-wrap {
    width: 64px;
    height: 64px;
    margin-bottom: 12px;
  }

  .upload-drop-icon {
    font-size: 30px;
  }

  .upload-drop-note { display: none; }

  .upload-drop-title-desktop,
  .upload-drop-subtitle-desktop { display: none; }

  .upload-drop-title-mobile,
  .upload-drop-subtitle-mobile { display: inline; }

  .document-page { width: 95%; transform: scale(0.9); }
  .document-viewer-paginated { padding: 20px 10px; }
}

@media (max-width: 480px) {
  .upload-drop-title { font-size: 17px; }
  .upload-drop-subtitle { font-size: 14px; }
  .welcome-title { font-size: clamp(33px, 8.4vw, 36px); }
  .welcome-subtitle { font-size: 12px; }
  .upload-dropzone { min-height: 170px; }
  .experimental-style-btn {
    width: 100%;
    justify-content: space-between;
  }
  .experimental-style-menu {
    left: 0;
    right: auto;
    width: 100%;
  }
  .style-carousel { grid-template-columns: 1fr; max-width: 220px; }
  .scoreboard-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1000px) {
  .document-page { width: 95%; transform: scale(0.9); }
  .document-viewer-paginated { padding: 20px 10px; }
}

/* ── Partial Processing ─────────────────────────────────────────────────── */

.bib-entry--locked {
  opacity: 0.35;
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
  position: relative;
}

/* Inline unlock CTA — sits in the bibliography list after the 2 blurred previews */
.bib-unlock-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: color-mix(in srgb, var(--primary) 8%, var(--surface-container));
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 4px 0;
  flex-wrap: wrap;
}

.bib-unlock-cta__text {
  font-size: 0.85rem;
  color: var(--on-surface-variant);
  flex: 1;
}

.bib-unlock-cta__text strong {
  color: var(--on-surface);
}

.btn--unlock {
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font-sans);
  white-space: nowrap;
}

.btn--unlock:hover { opacity: 0.88; }

.btn--topup {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  cursor: pointer;
  font-size: 0.82rem;
  font-family: var(--font-sans);
  white-space: nowrap;
}

.btn--topup:hover { background: color-mix(in srgb, var(--primary) 10%, transparent); }

/* Top banner — kept for accessibility/screen-reader announcement only; visually hidden */
.partial-banner {
  display: none;
}

.footnotes-partial-notice {
  font-size: 0.82rem;
  color: var(--on-surface-variant);
  border-left: 3px solid color-mix(in srgb, var(--primary) 40%, transparent);
  padding-left: 10px;
  margin-bottom: 10px;
}

.history-badge--partial {
  display: inline-block;
  font-size: 0.72rem;
  background: color-mix(in srgb, var(--primary) 12%, var(--surface-container));
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  border-radius: 10px;
  padding: 1px 7px;
  color: #888;
  margin-left: 6px;
  vertical-align: middle;
}

/* ── End Partial Processing ──────────────────────────────────────────────── */

/* ── Out-of-verifications notice ──────────────────────────────────────────── */
.no-balance-notice {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  padding: 32px 28px;
  max-width: 400px;
  margin: 24px auto 0;
}

.no-balance-notice__icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 12%, var(--surface-container));
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--primary);
}

.no-balance-notice__heading {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--on-surface);
  margin: 0;
}

.no-balance-notice__body {
  font-size: 0.92rem;
  color: var(--on-surface-variant);
  line-height: 1.6;
  margin: 0;
}

.no-balance-notice__actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.no-balance-notice__topup {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 28px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.15s ease;
  width: 100%;
  justify-content: center;
}

.no-balance-notice__topup:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.no-balance-notice__referral {
  font-size: 0.85rem;
  color: var(--on-surface-variant);
}

.no-balance-notice__referral a {
  color: var(--primary);
  text-decoration: none;
}

.no-balance-notice__referral a:hover {
  text-decoration: underline;
}

.no-balance-notice__dismiss {
  font-size: 0.82rem;
  color: var(--on-surface-variant);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  opacity: 0.7;
}

.no-balance-notice__dismiss:hover {
  opacity: 1;
}
/* ── End out-of-verifications notice ─────────────────────────────────────── */

/* Partial Processing Overrides */
.partial-bib-shell {
  background: color-mix(in srgb, var(--surface-container-low) 82%, #132318);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-lg);
  padding: 12px;
  width: 100%;
}

.partial-bib-heading {
  margin: 0 0 2px;
  font-size: 0.95rem;
  color: var(--on-surface);
}

.partial-bib-subheading {
  margin: 0 0 10px;
  font-size: 0.78rem;
  color: var(--on-surface-variant);
}

.partial-bib-unlocked {
  display: block;
  text-indent: 0;
  padding: 9px 12px 9px 38px;
  margin-bottom: 8px;
  border: 1px solid color-mix(in srgb, var(--outline-variant) 85%, transparent);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface-container-low) 82%, #0a1210);
}

.partial-bib-audit-icon {
  left: 10px !important;
  top: 13px !important;
  cursor: pointer;
}

.partial-bib-text {
  text-indent: 0;
  padding-left: 0;
}

.partial-bib-index {
  font-weight: 600;
  color: var(--on-surface);
  margin-right: 3px;
}

.partial-bib-lock-summary {
  margin: 2px 0 10px;
  padding: 5px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: center;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: #c79292;
  font-weight: 700;
}

.partial-bib-lock-summary::before,
.partial-bib-lock-summary::after {
  content: '';
  flex: 1;
  height: 1px;
  background: color-mix(in srgb, var(--outline) 70%, transparent);
}

.partial-bib-locked-row {
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--surface-container-high) 75%, #18241d);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 8px;
  position: relative;
}

.partial-bib-locked-text {
  flex: 1;
  color: var(--on-surface);
  opacity: 0.36;
  filter: blur(2.5px);
  text-indent: 0;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.partial-bib-lock-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: #c79292;
  font-size: 0.95rem;
}

.partial-bib-cta {
  margin-top: 8px;
  background: color-mix(in srgb, var(--surface-container-high) 70%, #17261c);
  border: 1px solid color-mix(in srgb, var(--primary) 38%, transparent);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.partial-bib-cta-copy {
  min-width: 0;
}

.partial-bib-cta-title {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--on-surface);
}

.partial-bib-cta-desc {
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--on-surface-variant);
}

.partial-bib-cta .btn--unlock {
  min-width: 180px;
  padding: 11px 14px;
  font-size: 0.86rem;
  letter-spacing: 0.03em;
}

.partial-bib-cta-btn {
  min-width: 140px;
  padding: 7px 13px;
  border-radius: 10px;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 45%, transparent);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.partial-bib-cta-btn i {
  font-size: 0.74rem;
}

.partial-bib-unlocked .verified-panel {
  margin: 10px 0 0 0;
  width: 100%;
  box-sizing: border-box;
  text-indent: 0;
}

.footnotes-partial-notice {
  margin: 12px 14px 10px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--primary) 36%, transparent);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface-container-low) 86%, #0b1310);
}

.results-section.collapsed .footnotes-partial-notice {
  display: none !important;
}

.footnotes-partial-title {
  font-size: 0.8rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--primary);
  font-weight: 700;
  margin-bottom: 6px;
}

.footnotes-partial-body {
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--on-surface-variant);
  margin-bottom: 10px;
}

.footnotes-partial-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.footnotes-partial-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  font-family: var(--font-sans);
}

.footnotes-partial-link:hover {
  text-decoration: underline;
}

.footnotes-partial-sep {
  color: color-mix(in srgb, var(--on-surface-variant) 70%, transparent);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
}

#footnotesContent.footnotes-content--partial-preview {
  padding-top: 6px;
  padding-left: 0;
  padding-bottom: 12px;
}

.footnote-item--original {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-indent: 0;
  padding: 12px 14px;
  margin-bottom: 0;
  border-left: none;
  border-right: none;
  border-radius: 0;
  border-top: none;
  border-bottom: 1px solid color-mix(in srgb, var(--outline-variant) 55%, transparent);
  background: transparent;
}

.footnote-original-main {
  min-width: 0;
}

.footnote-original-text {
  line-height: 1.55;
  color: var(--on-surface);
}

.footnote-original-icon {
  width: 16px;
  height: 16px;
  margin-top: 3px;
  border: 2px solid #9aa3a3;
  border-radius: 50%;
  display: inline-block;
  position: relative;
  box-sizing: border-box;
  opacity: 0.95;
}

.footnote-original-icon::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9aa3a3;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.partial-footnotes-topup {
  margin-top: 14px;
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface-container-low) 84%, #0b1310);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.partial-footnotes-topup-left {
  min-width: 0;
  flex: 1;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
  row-gap: 6px;
  align-items: center;
}

.partial-footnotes-topup-icon {
  width: 36px;
  height: 36px;
  border: 1px solid color-mix(in srgb, var(--primary) 45%, transparent);
  border-radius: 9px;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  grid-row: 1 / span 2;
}

.partial-footnotes-topup-copy {
  font-size: 0.9rem;
  color: var(--on-surface);
}

.partial-footnotes-topup-copy strong {
  color: var(--primary);
}

#footnotesContent .footnote-item:last-child {
  margin-bottom: 0;
}

.partial-footnotes-topup-progress {
  height: 4px;
  width: 180px;
  max-width: 100%;
  background: color-mix(in srgb, var(--outline-variant) 70%, transparent);
  border-radius: 999px;
  overflow: hidden;
}

.partial-footnotes-topup-progress span {
  display: block;
  height: 100%;
  background: var(--primary);
}

.partial-footnotes-topup-btn {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 45%, transparent);
  color: var(--primary);
  border-radius: 10px;
  padding: 7px 13px;
  min-width: 140px;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.partial-footnotes-topup-btn i {
  font-size: 0.74rem;
}

.partial-footnotes-topup-btn:hover {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}

@media (max-width: 768px) {
  #footnotesContent.footnotes-content--partial-preview {
    padding-left: 0;
  }
  .partial-bib-cta {
    flex-direction: column;
    align-items: stretch;
  }
  .partial-bib-cta .btn--unlock {
    min-width: 0;
  }
  .partial-footnotes-topup {
    flex-direction: column;
    align-items: stretch;
  }
  .partial-footnotes-topup-progress {
    width: 100%;
  }
}
