/* ==========================================================================
   ACADEMIC WORD COUNT CHECKER - PREMIUM APPLE NATIVE UI DESIGN SYSTEM
   ========================================================================== */

/* --- Fonts & Serifs --- */
@import url('https://fonts.googleapis.com/css2?family=Merriweather:ital,wght@0,300;0,400;0,700;1,300;1,400&family=JetBrains+Mono:wght@400;500&display=swap');

/* --- Root Variables & Premium Color Tokens --- */
:root {
  /* System Typography Stacks */
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: Georgia, Merriweather, "Times New Roman", serif;
  --font-mono: 'JetBrains Mono', Menlo, Monaco, Consolas, monospace;

  /* Common Spacing & Radii (iOS & macOS standard proportions) */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  
  --transition-fast: 0.1s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --transition-normal: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-elastic: 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  
  /* Layered Shadows (Ultra-delicate paper sheet shadows) */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.02), 0 2px 4px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.015), 0 8px 24px rgba(0, 0, 0, 0.03), 0 24px 64px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 30px -10px rgba(0, 0, 0, 0.08), 0 20px 50px -15px rgba(0, 0, 0, 0.06);

  /* Section Highlighting Colors (Sophisticated, ultra-light academic pastels) */
  --color-sec-title: #b45309;       
  --color-sec-title-bg: #fffbeb;    
  --color-sec-abstract: #6d28d9;    
  --color-sec-abstract-bg: #faf5ff; 
  --color-sec-body: #0284c7;        
  --color-sec-body-bg: #f0f9ff;     
  --color-sec-headings: #0d9488;    
  --color-sec-headings-bg: #f0fdfa; 
  --color-sec-footnotes: #ea580c;   
  --color-sec-footnotes-bg: #fff7ed; 
  --color-sec-tables: #16a34a;      
  --color-sec-tables-bg: #f0fdf4;   
  --color-sec-equations: #8b5cf6;
  --color-sec-equations-bg: #f5f3ff;
  --color-sec-references: #e11d48;  
  --color-sec-references-bg: #fff1f2; 
  --color-sec-appendices: #0891b2;  
  --color-sec-appendices-bg: #ecfeff; 
  --color-sec-unclassified: #4b5563;
  --color-sec-unclassified-bg: #f3f4f6;
}

/* --- LIGHT THEME (Apple Classic Silver) --- */
[data-theme="light"] {
  --bg-app: #f5f5f7;              /* Apple light gray desktop */
  --bg-sidebar: #ffffff;          /* Clean white side column */
  --bg-panel: #ffffff;            
  --bg-input: #f5f5f7;            /* Integrated light-gray input backgrounds */
  
  --border-primary: #e8e8ed;      /* Flat slate border */
  --border-hover: #d2d2d7;
  --border-focus: #0071e3;        /* iOS blue */
  
  --text-primary: #1d1d1f;        /* Deep charcoal */
  --text-secondary: #86868b;      /* Slate secondary label */
  --text-muted: #86868b;          
  
  --accent: #0071e3;              
  --accent-light: #359eff;
  --accent-bg: rgba(0, 113, 227, 0.05);
  
  --scrollbar-thumb: rgba(0, 0, 0, 0.12);
  --scrollbar-track: transparent;
  
  /* Empty workspace variables */
  --bg-empty-workspace: #f5f5f7;
  --bg-empty-card: #ffffff;
  --border-empty-card: rgba(0, 0, 0, 0.08);
  --text-empty-title: #1d1d1f;
  --text-empty-desc: #86868b;
  --bg-empty-btn: rgba(0, 0, 0, 0.03);
  --border-empty-btn: rgba(0, 0, 0, 0.08);
  --text-empty-btn: #1d1d1f;
  --border-empty-divider: rgba(0, 0, 0, 0.06);
  --text-empty-privacy: #86868b;
}

/* --- DARK THEME (Apple Soft Charcoal) --- */
[data-theme="dark"] {
  --bg-app: #161617;              /* Premium Apple dark */
  --bg-sidebar: #1e1e1f;          
  --bg-panel: #1e1e1f;            
  --bg-input: #161617;            
  
  --border-primary: #2c2c2e;      /* Apple dark slate border */
  --border-hover: #3a3a3c;
  --border-focus: #0a84ff;        
  
  --text-primary: #f5f5f7;        
  --text-secondary: #86868b;      
  --text-muted: #6e6e73;          
  
  --accent: #0a84ff;              
  --accent-light: #409cff;
  --accent-bg: rgba(10, 132, 255, 0.12);
  
  --scrollbar-thumb: rgba(255, 255, 255, 0.15);
  --scrollbar-track: transparent;
  
  /* Empty workspace variables */
  --bg-empty-workspace: #000000;
  --bg-empty-card: #0c0c0e;
  --border-empty-card: rgba(255, 255, 255, 0.06);
  --text-empty-title: #ffffff;
  --text-empty-desc: #86868b;
  --bg-empty-btn: rgba(255, 255, 255, 0.02);
  --border-empty-btn: rgba(255, 255, 255, 0.08);
  --text-empty-btn: #ffffff;
  --border-empty-divider: rgba(255, 255, 255, 0.05);
  --text-empty-privacy: #515154;
}

/* --- Base Resets & Defaults --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-ui);
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

/* Integrated Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
  border: 2px solid transparent;
  background-clip: padding-box;
}

/* --- Main Layout --- */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  position: relative;
  overflow: hidden;
}

/* Left Sidebar Controls */
.sidebar {
  width: 420px;
  min-width: 420px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-primary);
  display: flex;
  flex-direction: column;
  height: 100%;
  z-index: 10;
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

/* Right Main Document Viewer */
.viewer-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: var(--bg-app);
  position: relative;
  overflow: hidden;
}

/* --- Sidebar Header --- */
.sidebar-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  background: var(--text-primary);
  width: 28px;
  height: 28px;
  border-radius: 7px; /* macOS style Squircle */
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg-sidebar);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.logo-icon i {
  width: 14px;
  height: 14px;
}

.logo-text {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.theme-toggle-btn {
  background: transparent;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background-color var(--transition-fast), color var(--transition-fast), transform 0.1s ease;
}

.theme-toggle-btn:hover {
  background-color: rgba(120, 120, 128, 0.08);
  color: var(--text-primary);
}

.theme-toggle-btn:active {
  transform: scale(0.92);
}

/* --- Sidebar Scrollable Content --- */
.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 24px 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-scroll::after {
  content: "";
  display: block;
  height: 24px;
  flex-shrink: 0;
}

/* Editorial Sidebar Section Groups (Replaces cards with elegant whitespace & dividers) */
.sidebar-card {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-primary);
  transition: none;
}

.sidebar-card:last-of-type {
  border-bottom: none;
}

.sidebar-card:hover {
  border-color: var(--border-primary);
}

/* Pinned Goal Tracker at bottom of sidebar */
.sidebar-goal-fixed {
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border-primary);
  border-bottom: none !important;
  padding: 20px 24px !important;
  flex-shrink: 0;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.02);
}

/* Elegant Notion-style Section Headers */
.card-title {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: none;
  padding-bottom: 0;
}

.card-title i {
  color: var(--text-secondary);
  width: 14px;
  height: 14px;
  opacity: 0.8;
}

/* --- Segmented Navigation Controls --- */
.tabs-navigation {
  display: flex;
  background: rgba(120, 120, 128, 0.08);
  border: none;
  padding: 2px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 5px 8px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: calc(var(--radius-sm) - 2px);
  transition: background-color var(--transition-fast), color var(--transition-fast), transform 0.1s ease, box-shadow var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.tab-btn.active {
  background: var(--bg-panel);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 1px rgba(0, 0, 0, 0.04);
}

.tab-btn:active {
  transform: scale(0.97);
}

.tab-btn:not(.active):hover {
  color: var(--text-primary);
}

/* Premium Apple Drag & Drop Zone */
.file-upload-zone {
  border: 1px dashed rgba(120, 120, 128, 0.25);
  border-radius: var(--radius-sm);
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  background: rgba(120, 120, 128, 0.02);
  transition: border-color var(--transition-normal), background-color var(--transition-normal);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.file-upload-zone:hover {
  background-color: rgba(120, 120, 128, 0.04);
  border-color: rgba(120, 120, 128, 0.35);
}

.file-upload-zone.dragging {
  border-color: var(--accent);
  background: rgba(0, 113, 227, 0.05);
}

.upload-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(120, 120, 128, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.upload-icon i {
  width: 16px;
  height: 16px;
}

.upload-title {
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--text-primary);
}

.upload-subtitle {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.file-input {
  display: none;
}

/* Elegant Inputs & Textareas */
.paste-textarea {
  width: 100%;
  height: 140px;
  background: var(--bg-input);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  resize: vertical;
  line-height: 1.45;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.paste-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  background: var(--bg-panel);
}

.paste-action-bar {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

/* Tactile Scale-active Buttons */
.primary-btn {
  background: var(--text-primary);
  color: var(--bg-sidebar);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-weight: 500;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: opacity var(--transition-fast), transform 0.12s ease;
}

.primary-btn:hover {
  opacity: 0.92;
}

.primary-btn:active {
  transform: scale(0.97);
}

.secondary-btn {
  background: var(--bg-panel);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-weight: 500;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), transform 0.12s ease;
}

.secondary-btn:hover {
  background: var(--bg-input);
  border-color: var(--border-hover);
}

.secondary-btn:active {
  transform: scale(0.97);
}

/* Manual Text Area Inputs */
.manual-sections-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 2px;
}
.manual-sections-wrapper::after {
  content: "";
  display: block;
  height: 8px;
  flex-shrink: 0;
}

.section-input-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: rgba(120, 120, 128, 0.03);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-primary);
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.section-input-row:focus-within {
  border-color: var(--border-focus);
  background-color: var(--bg-panel);
}

.section-input-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.words-pill {
  font-size: 0.65rem;
  background: rgba(120, 120, 128, 0.08);
  padding: 1px 6px;
  border-radius: 99px;
  font-weight: 500;
}

.section-input-field {
  width: 100%;
  height: 48px;
  background: transparent;
  border: none;
  resize: none;
  color: var(--text-primary);
  font-size: 0.8rem;
  font-family: var(--font-ui);
  line-height: 1.4;
}

.section-input-field:focus {
  outline: none;
}

/* --- Apple Segmented Rules Presets Dashboard --- */
.presets-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.preset-card {
  background: rgba(120, 120, 128, 0.04);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), transform 0.12s ease, box-shadow var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.preset-card:hover {
  background: rgba(120, 120, 128, 0.08);
}

.preset-card.active {
  background: var(--bg-panel);
  border-color: var(--border-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .preset-card.active {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.05);
  box-shadow: none;
}

.preset-card:active {
  transform: scale(0.96);
}

.preset-name {
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--text-primary);
}

.preset-desc {
  font-size: 0.65rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* --- iOS Table List & Toggles Group --- */
.rules-list {
  display: flex;
  flex-direction: column;
  background: rgba(120, 120, 128, 0.04);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 1px;
}

[data-theme="dark"] .rules-list {
  background: rgba(255, 255, 255, 0.04);
}

.rule-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-panel);
  border: none;
  border-radius: 0;
  transition: background-color var(--transition-fast);
}

.rules-list .rule-toggle-row:first-of-type {
  border-top-left-radius: calc(var(--radius-sm) - 4px);
  border-top-right-radius: calc(var(--radius-sm) - 4px);
}

.rules-list .rule-toggle-row:last-of-type {
  border-bottom-left-radius: calc(var(--radius-sm) - 4px);
  border-bottom-right-radius: calc(var(--radius-sm) - 4px);
}

.rule-toggle-row:hover {
  background-color: var(--bg-input);
}

.rule-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rule-indicator {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.rule-label {
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--text-primary);
}

.rule-subtext {
  font-size: 0.68rem;
  color: var(--text-secondary);
  margin-top: 1px;
}

/* ==========================================
   HIGH-FIDELITY iOS TOGGLES
   ========================================== */
.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(120, 120, 128, 0.16); /* Apple iOS standard background grey */
  transition: background-color 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 999px;
}

[data-theme="dark"] .slider {
  background-color: rgba(255, 255, 255, 0.16);
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background-color: #ffffff;
  transition: transform 0.22s cubic-bezier(0.25, 0.8, 0.25, 1);
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.05);
}

input:checked + .slider {
  background-color: #34c759 !important; /* Perfect emerald iOS active green */
}

input:checked + .slider:before {
  transform: translateX(18px);
}

input:disabled + .slider {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Report Table & Metrics --- */
.sidebar-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.stat-metric-card {
  background: rgba(120, 120, 128, 0.04);
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  text-align: center;
  transition: background-color var(--transition-fast);
}

.stat-metric-card:hover {
  background: rgba(120, 120, 128, 0.08);
}

.metric-big {
  font-family: var(--font-ui);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  display: block;
  margin-bottom: 2px;
  line-height: 1.2;
}

.metric-label {
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
}

.breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  margin-top: 6px;
}

.breakdown-table th, 
.breakdown-table td {
  padding: 8px 6px;
  text-align: left;
  border-bottom: 1px solid var(--border-primary);
}

.breakdown-table th {
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.breakdown-table tr.total-row {
  font-weight: 600;
  color: var(--text-primary);
}

.breakdown-table tr.total-row td {
  border-top: 1px solid var(--border-primary);
  padding-top: 10px;
}

.section-indicator-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.section-indicator-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

/* --- Apple Clean Linear Progress Tracker --- */
.progress-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.circular-progress {
  display: none; 
}

.progress-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.progress-label {
  font-size: 0.78rem;
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  color: var(--text-primary);
}

.linear-progress-bar-bg {
  width: 100%;
  height: 6px;
  background-color: rgba(120, 120, 128, 0.08);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

[data-theme="dark"] .linear-progress-bar-bg {
  background-color: rgba(255, 255, 255, 0.08);
}

.linear-progress-bar-fill {
  height: 100%;
  width: 0%;
  background-color: var(--accent); /* Native accents color */
  border-radius: 3px;
  transition: width var(--transition-normal);
}

.target-input-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.target-num-input {
  width: 80px;
  background: var(--bg-input);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xs);
  padding: 3px 6px;
  font-weight: 600;
  font-size: 0.75rem;
  text-align: right;
  transition: border-color var(--transition-fast);
}

.target-num-input:focus {
  outline: none;
  border-color: var(--border-focus);
}

/* Hide spin-buttons in goal tracker number input */
.target-num-input::-webkit-outer-spin-button,
.target-num-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.target-num-input {
  -moz-appearance: textfield;
}

/* ==========================================================================
   RIGHT PANEL: THE EDITORIAL PAPER CANVAS
   ========================================================================== */

/* Top Viewer Actions Bar */
.viewer-actions-bar {
  padding: 14px 28px;
  border-bottom: 1px solid var(--border-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-sidebar);
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.viewer-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-badge {
  background: rgba(120, 120, 128, 0.06);
  border: 1px solid transparent;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 8px;
  border-radius: 99px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-badge.active::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 4px;
  background: #34c759; /* Emerald Green dot */
  border-radius: 50%;
}

.privacy-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  color: var(--text-secondary);
  justify-content: center;
  margin-top: 10px;
  opacity: 0.8;
}

.privacy-badge i {
  width: 12px;
  height: 12px;
}

.action-buttons-group {
  display: flex;
  gap: 8px;
}

.document-scroller {
  flex: 1;
  overflow-y: auto;
  padding: 28px 36px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background-color: var(--bg-app);
  min-height: 0; /* Flex child overflow fix */
  transition: background-color var(--transition-normal);
}

.document-scroller.empty {
  background-color: var(--bg-empty-workspace) !important;
}

.empty-state-card {
  background-color: var(--bg-empty-card) !important;
  border: 1px solid var(--border-empty-card) !important;
  box-shadow: 0 24px 50px rgba(0,0,0,0.15);
}

[data-theme="dark"] .empty-state-card {
  box-shadow: 0 24px 50px rgba(0,0,0,0.8) !important;
}

.empty-title {
  color: var(--text-empty-title) !important;
}

.empty-desc {
  color: var(--text-empty-desc) !important;
}

.empty-privacy {
  color: var(--text-empty-privacy) !important;
}

/* The elegant virtual LaTeX sheet of paper */
.document-page-canvas {
  width: 100%;
  max-width: 780px;
  background: #ffffff !important;  
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 2px;
  padding: 56px 64px;
  box-shadow: var(--shadow-md);
  min-height: 980px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 10px;
  overflow: visible; /* Allow picker popups to extend beyond page bounds */
  
  /* High-fidelity Editorial Serif Journal Typography */
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.65;
  color: #1d1d1f !important; /* Dark premium graphite ink - always dark on white paper */
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
  
  /* Editorial Uniform Alignment & Bounds Security */
  text-align: justify;
  text-justify: inter-word;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

/* PDF Canvas Page Rendering */
.pdf-canvas-page {
  width: 100%;
  display: block;
  border-radius: 2px 2px 0 0;
}

/* PDF Highlight Overlay Layer */
.pdf-highlight-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Individual PDF Highlight Region */
.pdf-highlight {
  position: absolute;
  border-radius: 2px;
  pointer-events: auto;
  cursor: pointer;
  transition: opacity 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.pdf-highlight:hover {
  opacity: 1 !important;
  box-shadow: 0 0 0 1.5px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.08);
  filter: brightness(0.95);
  z-index: 2;
}

.pdf-highlight.excluded {
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,0.03) 3px,
    rgba(0,0,0,0.03) 6px
  ) !important;
  border-left-color: #9ca3af !important;
}

/* Custom Floating Tooltip */
.pdf-highlight-tooltip {
  position: absolute;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: rgba(30, 30, 30, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
  font-size: 0.7rem;
  font-weight: 400;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 100;
  transform: translateX(-50%);
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
  letter-spacing: 0.01em;
}

.pdf-tt-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.pdf-tt-status.incl { color: #6ee7b7; }
.pdf-tt-status.excl { color: #fca5a5; }

.pdf-tt-hint {
  color: rgba(255,255,255,0.45);
  font-size: 0.62rem;
  margin-left: 4px;
}

/* Section Reclassification Picker Popup */
.pdf-section-picker {
  position: absolute;
  background: rgba(30, 30, 30, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 10px;
  padding: 6px;
  z-index: 200;
  pointer-events: auto;
  transform: translateX(-50%);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.08);
  min-width: 180px;
}

.pdf-picker-title {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.62rem;
  color: rgba(255,255,255,0.4);
  padding: 4px 10px 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.pdf-picker-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  transition: background 0.1s ease;
}

.pdf-picker-option:hover {
  background: rgba(255,255,255,0.12);
}

.pdf-picker-option.active {
  background: rgba(255,255,255,0.18);
  color: #fff;
  font-weight: 600;
}

/* PDF Color Legend Bar */
.pdf-legend-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 20px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 0.7rem;
  color: #555;
  align-items: center;
  max-width: 780px;
  width: 100%;
}

.pdf-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pdf-legend-item span:first-child {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

/* ==========================================
   DOCX NATIVE RENDERING (docx-preview)
   ========================================== */

/* Container for docx-preview rendered content */
.docx-native-page {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  min-height: auto !important;
  margin: 0 auto !important;
  
  /* Reset all inherited styles that destroy DOCX layout */
  font-family: initial !important;
  font-size: initial !important;
  line-height: normal !important;
  text-align: initial !important;
  text-justify: auto !important;
  word-wrap: normal !important;
  overflow-wrap: normal !important;
  word-break: normal !important;
  hyphens: none !important;
  color: initial !important;
}

/* Specificity override for dark theme to prevent double-border and double-shadow on the workspace wrapper */
[data-theme="dark"] .document-page-canvas.docx-native-page {
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
}

/* Premium Word-Workspace Print Layout Workspace */
.docx-native-page .docx-preview-wrapper {
  background: transparent !important;
  padding: 20px 0 !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  gap: 30px !important;
  margin: 0 auto !important;
  border: none !important;
  box-shadow: none !important;
  box-sizing: border-box !important;
}

/* Theme support for Word-Workspace print layout background in dark theme */
[data-theme="dark"] .docx-native-page .docx-preview-wrapper {
  background: transparent !important;
}

/* Faithful DOCX page sheets */
.docx-native-page section.docx-preview-page,
.docx-native-page section[class*="page"] {
  background: #ffffff !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
  border: 1px solid rgba(0, 0, 0, 0.08) !important;
  border-radius: 2px !important;
  position: relative !important;
  margin: 0 auto !important;
  color: #000000 !important; /* Always black text on white paper for DOCX */
}

/* Make sure docx-preview images fit within the page */
.docx-native-page img {
  max-width: 100% !important;
  height: auto !important;
}

/* Ensure tables from docx-preview don't overflow */
.docx-native-page table {
  max-width: 100% !important;
  word-break: normal !important; /* Revert break-word which destroys tables */
}

/* Premium Responsive Academic Table Formatting */
.document-page-canvas table {
  width: 100% !important;
  max-width: 100% !important;
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.9rem;
}

.document-page-canvas th,
.document-page-canvas td {
  border: 1px solid #e2e8f0;
  padding: 8px 10px;
  text-align: left;
}

/* Publication-grade semantic heading typography */
.document-page-canvas h1,
.document-page-canvas h2,
.document-page-canvas h3,
.document-page-canvas h4 {
  font-family: var(--font-serif);
  font-weight: 700;
  color: #1d1d1f !important;
  margin-top: 14px;
  margin-bottom: 6px;
  line-height: 1.35;
}
.document-page-canvas h1 { font-size: 1.45rem; }
.document-page-canvas h2 { font-size: 1.25rem; }
.document-page-canvas h3 { font-size: 1.12rem; }
.document-page-canvas h4 { font-size: 1.02rem; }

.document-page-canvas th {
  background-color: rgba(120, 120, 128, 0.04);
  font-weight: 600;
  color: var(--text-primary);
}

[data-theme="dark"] .document-page-canvas {
  background: #ffffff !important; /* Keep the manuscript white paper in dark theme too */
  color: #1d1d1f !important;
  box-shadow: 0 10px 40px rgba(0,0,0,0.36);
  border: 1px solid rgba(0, 0, 0, 0.15);
}

/* Empty state is now handled by JavaScript rendering */

/* --- Color Coded Section Classes (Sophisticated, elegant low-saturation pastel tints) --- */
.doc-para {
  position: relative;
  padding: 8px 14px;
  border-radius: var(--radius-xs);
  border-left: 3px solid transparent;
  transition: background-color var(--transition-fast), transform var(--transition-fast), border-color var(--transition-fast);
  cursor: pointer;
  margin-bottom: 2px;
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: break-word;
  overflow: hidden;
}

.doc-para:hover {
  background: rgba(0, 0, 0, 0.015);
  transform: translateX(1px);
}

/* Included Visual Style */
.doc-para.included {
  opacity: 1;
}

/* Excluded Visual Style (Faded ink with clean thin line-through) */
.doc-para.excluded {
  opacity: 0.35;
  text-decoration: line-through;
  text-decoration-color: rgba(0, 0, 0, 0.25);
  background-color: #fafbfc !important;
  border-color: #d1d5db !important;
}

/* Gentle Pastel Tints with subtle Left Border Indicators */
.doc-para.sec-title {
  border-color: var(--color-sec-title);
  background-color: var(--color-sec-title-bg);
}
.doc-para.sec-abstract {
  border-color: var(--color-sec-abstract);
  background-color: var(--color-sec-abstract-bg);
  font-style: italic;
}
.doc-para.sec-body {
  border-color: var(--color-sec-body);
  background-color: var(--color-sec-body-bg);
}
.doc-para.sec-headings {
  border-color: var(--color-sec-headings);
  background-color: var(--color-sec-headings-bg);
  font-family: var(--font-ui);
  font-weight: 600;
}
.doc-para.sec-footnotes {
  border-color: var(--color-sec-footnotes);
  background-color: var(--color-sec-footnotes-bg);
  font-size: 0.85rem;
  line-height: 1.45;
}
.doc-para.sec-tables {
  border-color: var(--color-sec-tables);
  background-color: var(--color-sec-tables-bg);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}
.doc-para.sec-equations {
  border-color: var(--color-sec-equations);
  background-color: var(--color-sec-equations-bg);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-style: italic;
}
.doc-para.sec-references {
  border-color: var(--color-sec-references);
  background-color: var(--color-sec-references-bg);
  font-size: 0.9rem;
  padding-left: 24px;
  text-indent: -12px;
}
.doc-para.sec-appendices {
  border-color: var(--color-sec-appendices);
  background-color: var(--color-sec-appendices-bg);
}
.doc-para.sec-unclassified {
  border-color: var(--color-sec-unclassified);
  background-color: var(--color-sec-unclassified-bg);
}

/* Floating Notion-style Tag Badge on Hover */
.doc-para::after {
  content: attr(data-label-full);
  position: absolute;
  right: 10px;
  top: 6px;
  font-family: var(--font-ui);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: #1d1d1f;
  opacity: 0;
  transform: translateY(-1px);
  pointer-events: none;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  z-index: 10;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.doc-para:hover::after {
  opacity: 1;
  transform: translateY(0);
}

/* Smart Inline Citations Highlight */
.citation-highlight {
  background-color: rgba(245, 158, 11, 0.1);
  border-bottom: 1.5px dashed rgba(217, 119, 6, 0.6);
  padding: 0 1px;
  border-radius: 2px;
  cursor: help;
  position: relative;
  transition: all var(--transition-fast);
}

.citation-highlight.citation-excluded {
  background-color: rgba(0, 0, 0, 0.04);
  border-bottom-color: rgba(0, 0, 0, 0.2);
  text-decoration: line-through;
  opacity: 0.6;
}

.citation-highlight::before {
  content: "CITATION";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-2px);
  font-family: var(--font-ui);
  font-size: 0.5rem;
  font-weight: 700;
  background: #1d1d1f;
  color: #ffffff;
  padding: 1px 4px;
  border-radius: 3px;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.citation-highlight:hover::before {
  opacity: 1;
}

/* Equation Highlight Styles */
.equation-highlight {
  background-color: rgba(139, 92, 246, 0.1);
  border-bottom: 1.5px dashed rgba(139, 92, 246, 0.6);
  padding: 0 1px;
  border-radius: 2px;
  cursor: help;
  position: relative;
  transition: all var(--transition-fast);
}

.equation-highlight.equation-excluded {
  background-color: rgba(0, 0, 0, 0.04);
  border-bottom-color: rgba(0, 0, 0, 0.2);
  text-decoration: line-through;
  opacity: 0.6;
}

.equation-highlight::before {
  content: "EQUATION";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-2px);
  font-family: var(--font-ui);
  font-size: 0.5rem;
  font-weight: 700;
  background: #8b5cf6;
  color: #ffffff;
  padding: 1px 4px;
  border-radius: 3px;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.equation-highlight:hover::before {
  opacity: 1;
}

/* ==========================================================================
   POPUP MENU AND INTERACTIVE WIDGETS
   ========================================================================== */

/* Premium Apple-native Context Popover Menu */
.inline-edit-menu {
  position: absolute;
  background: var(--bg-panel);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  padding: 5px;
  width: 190px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: popoverFadeIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes popoverFadeIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.edit-menu-header {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-secondary);
  padding: 4px 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-primary);
  margin-bottom: 3px;
}

.edit-menu-item {
  background: transparent;
  border: none;
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-primary);
  text-align: left;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.edit-menu-item:hover {
  background: var(--bg-input);
}

.edit-menu-item.active {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
}

.menu-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

/* Floating iOS Scroll Back to Top Button */
.fab-btn {
  position: absolute;
  bottom: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--text-primary);
  color: var(--bg-sidebar);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--transition-normal), transform var(--transition-normal), background-color var(--transition-fast);
  z-index: 10;
}

.fab-btn.visible {
  opacity: 1;
  transform: translateY(0);
}

.fab-btn:hover {
  opacity: 0.95;
}

.fab-btn:active {
  transform: scale(0.92);
}

.fab-btn i {
  width: 16px;
  height: 16px;
}

/* Responsive Adaptive Layouts */
@media (max-width: 1024px) {
  .app-container {
    flex-direction: column;
    overflow-y: auto;
  }
  
  .sidebar {
    width: 100%;
    min-width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-primary);
  }
  
  .viewer-container {
    height: auto;
    min-height: 100vh;
  }
  
  .document-scroller {
    padding: 20px;
  }
  
  .document-page-canvas {
    padding: 32px;
    min-height: auto;
  }
}

/* ==========================================
   ACADEMIC MULTI-PAGE STACK WRAPPER & FOOTER
   ========================================== */

/* Page wrapper to stack A4 paper sheets with elegant spacing */
#document-canvas {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 100%; /* Prevent black/empty background when content is short */
  margin-bottom: 56px; /* Forces browser to respect scroll bottom padding */
}

/* Elegant Editorial Page Footer (Pushed to bottom via flex auto-margin) */
.page-footer {
  margin-top: auto; 
  padding-top: 14px;
  border-top: 1px solid rgba(0, 0, 0, 0.04);
  display: flex;
  justify-content: space-between;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: #86868b; /* Hardcoded for white paper background */
  opacity: 0.7;
  user-select: none;
}

