/* ========================================
   CSS Custom Properties - Design System
   ======================================== */
:root {
  /* Color Palette - Primary (Bootstrap Blue) */
  --color-primary-50: #e7f1ff;
  --color-primary-100: #cfe2ff;
  --color-primary-200: #9ec5fe;
  --color-primary-300: #6ea8fe;
  --color-primary-400: #3d8bfd;
  --color-primary-500: #0d6efd;
  --color-primary-600: #0a58ca;
  --color-primary-700: #084298;
  --color-primary-800: #052c65;
  --color-primary-900: #031633;

  /* Color Palette - Neutral (Bootstrap Grays) */
  --color-neutral-50: #f8f9fa;
  --color-neutral-100: #f1f3f5;
  --color-neutral-200: #e9ecef;
  --color-neutral-300: #dee2e6;
  --color-neutral-400: #ced4da;
  --color-neutral-500: #adb5bd;
  --color-neutral-600: #6c757d;
  --color-neutral-700: #495057;
  --color-neutral-800: #343a40;
  --color-neutral-900: #212529;

  /* Color Palette - Accent */
  --color-accent-500: #6f42c1;
  --color-accent-600: #5a32a3;
  --color-accent-700: #432874;

  /* Color Palette - Semantic (Bootstrap) */
  --color-success: #198754;
  --color-warning: #ffc107;
  --color-error: #dc3545;
  --color-info: #0dcaf0;

  /* Typography - Font Families */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-serif: Georgia, 'Times New Roman', serif;
  --font-mono: 'SF Mono', Monaco, 'Cascadia Code', Consolas, monospace;

  /* Typography - Font Sizes (1.25 modular scale) */
  --text-xs: 0.64rem;    /* 10.24px */
  --text-sm: 0.8rem;     /* 12.8px */
  --text-base: 1rem;     /* 16px */
  --text-lg: 1.25rem;    /* 20px */
  --text-xl: 1.563rem;   /* 25px */
  --text-2xl: 1.953rem;  /* 31.25px */
  --text-3xl: 2.441rem;  /* 39px */
  --text-4xl: 3.052rem;  /* 48.83px */

  /* Typography - Font Weights */
  --font-light: 300;
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  /* Typography - Line Heights */
  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  --leading-loose: 2;

  /* Spacing Scale (1.5 ratio) */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.5rem;    /* 24px */
  --space-6: 2rem;      /* 32px */
  --space-7: 3rem;      /* 48px */
  --space-8: 4rem;      /* 64px */
  --space-9: 6rem;      /* 96px */

  /* Border Radius */
  --radius-sm: 0.25rem;   /* 4px - Bootstrap default */
  --radius-md: 0.375rem;  /* 6px */
  --radius-lg: 0.5rem;    /* 8px - Bootstrap default */
  --radius-xl: 1rem;      /* 16px */
  --radius-2xl: 1.5rem;   /* 24px */
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  --shadow-md: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);
  --shadow-xl: 0 2rem 4rem rgba(0, 0, 0, 0.2);
  --shadow-2xl: 0 3rem 6rem rgba(0, 0, 0, 0.25);

  /* Transitions */
  --transition-fast: 150ms ease-in-out;
  --transition-base: 250ms ease-in-out;
  --transition-slow: 350ms ease-in-out;

  /* Z-Index Scale */
  --z-base: 1;
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
}

/* ========================================
   Base Styles
   ======================================== */
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-neutral-800);
  background-color: var(--color-neutral-50);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   Typography
   ======================================== */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  letter-spacing: -0.025em;
  color: var(--color-neutral-900);
  margin-bottom: var(--space-4);
}

h1 {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
}

h2 {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
}

h3 {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
}

h4 {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
}

h5 {
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  color: var(--color-neutral-700);
  border-bottom: 2px solid var(--color-neutral-200);
  padding-bottom: var(--space-2);
}

h6 {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-neutral-600);
}

p {
  margin-bottom: var(--space-4);
  line-height: var(--leading-relaxed);
}

a {
  color: var(--color-primary-600);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-700);
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--color-primary-500);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 0.125rem 0.375rem;
  background: var(--color-neutral-100);
  border-radius: var(--radius-sm);
  color: var(--color-accent-700);
}

/* ========================================
   Cards & Containers
   ======================================== */
#main-view .card {
  margin-bottom: var(--space-6);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  background: white;
}

.card-header {
  background: var(--color-primary-500) !important;
  color: white !important;
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
  padding: var(--space-4) var(--space-5);
  font-weight: var(--font-semibold);
  font-size: var(--text-lg);
}

.card-header * {
  color: white !important;
}

.card-title {
  color: white !important;
  margin-bottom: 0;
}

.card-body {
  padding: var(--space-5);
}

.info-card {
  border: 1px solid var(--color-neutral-200);
  border-radius: var(--radius-lg);
}


/* ========================================
   Navigation & Header
   ======================================== */
.navbar {
  box-shadow: var(--shadow-sm);
  padding: var(--space-3) var(--space-4);
  transition: all var(--transition-base);
  position: relative;
  z-index: var(--z-sticky);
}

/* Secondary navbars within content (e.g., Overview, Word, etc.) */
.card .navbar,
#main-view .navbar {
  z-index: var(--z-base);
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-neutral-200);
}

.navbar-brand {
  font-weight: var(--font-bold);
  font-size: var(--text-xl);
  letter-spacing: -0.025em;
  transition: color var(--transition-fast);
}

/* Navbar toggler for mobile */
.navbar-toggler {
  padding: 0.25rem 0.75rem;
}

.navbar-toggler:focus {
  outline: none;
}

/* Dark navbar toggler (white icon) */
.navbar-dark .navbar-toggler {
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.navbar-dark .navbar-toggler:focus {
  box-shadow: 0 0 0 0.25rem rgba(255, 255, 255, 0.25);
}

.navbar-dark .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* Light navbar toggler (dark icon) */
.navbar-light .navbar-toggler {
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.navbar-light .navbar-toggler:focus {
  box-shadow: 0 0 0 0.25rem rgba(0, 0, 0, 0.1);
}

.navbar-light .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%280, 0, 0, 0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

.navbar-brand:hover {
  opacity: 0.8;
}

/* Main navbar dark theme links */
.navbar-dark .navbar-brand {
  color: white !important;
}

.navbar-dark .nav-link {
  color: rgba(255, 255, 255, 0.75) !important;
}

.navbar-dark .nav-link:hover {
  color: white !important;
  background: rgba(255, 255, 255, 0.1);
}

.navbar-dark .nav-link.active {
  color: white !important;
  background: rgba(255, 255, 255, 0.15);
}

/* Light navbar links (for secondary navbars) */
.navbar-light .nav-link {
  font-weight: var(--font-medium);
  color: var(--color-neutral-700) !important;
  padding: var(--space-2) var(--space-4) !important;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  position: relative;
}

.navbar-light .nav-link:hover {
  color: var(--color-primary-600) !important;
  background: var(--color-primary-50);
}

.navbar-light .nav-link.active {
  color: var(--color-primary-700) !important;
  background: var(--color-primary-100);
  font-weight: var(--font-semibold);
}

.navbar-light .nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 2px;
  background: var(--color-primary-600);
  border-radius: var(--radius-full);
}

/* Dropdown styling */
.dropdown-menu {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  margin-top: var(--space-2);
  background: white;
  z-index: var(--z-dropdown);
  max-height: 400px;
  overflow-y: auto;
  /* Constrain width to prevent horizontal overflow */
  overflow-x: hidden;
}

/* Topic dropdown specific - responsive width */
#topicDropdownMenu {
  /* Desktop: wide dropdown that extends across most of navbar */
  /* Bootstrap container max-widths: 540px, 720px, 960px, 1140px, 1320px */
  width: max(600px, 70vw);
  max-width: min(1100px, calc(100vw - 2rem));
}

/* Tablet/smaller desktop: scale down more gracefully - prevent overflow */
@media (max-width: 1199px) and (min-width: 992px) {
  #topicDropdownMenu {
    width: 65vw;
    max-width: calc(100vw - 4rem);
  }
}

/* Mobile: narrower width to fit in collapsed navbar */
@media (max-width: 991px) {
  #topicDropdownMenu {
    width: auto;
    min-width: 200px;
    max-width: calc(100vw - 4rem);
  }
}

#topicDropdownMenu .dropdown-item {
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.dropdown-item {
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-base);
  color: var(--color-neutral-700);
  transition: all var(--transition-fast);
}

.dropdown-item:hover {
  background: var(--color-primary-50);
  color: var(--color-primary-700);
}

.dropdown-item:active,
.dropdown-item.active {
  background: var(--color-primary-100);
  color: var(--color-primary-800);
}

.dropdown-toggle::after {
  margin-left: var(--space-2);
  transition: transform var(--transition-fast);
}

.dropdown.show .dropdown-toggle::after {
  transform: rotate(180deg);
}

/* ========================================
   Buttons & Forms
   ======================================== */
.btn {
  font-weight: var(--font-medium);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
  transition: all var(--transition-fast);
  border: none;
  font-size: var(--text-sm);
}

.btn-primary {
  background: var(--color-primary-500);
  border: none;
  color: white;
}

.btn-primary:hover {
  background: var(--color-primary-600);
  color: white;
}

.btn-primary:active {
  background: var(--color-primary-700);
  color: white;
}

.btn-outline-primary {
  border: 2px solid var(--color-primary-500);
  color: var(--color-primary-500);
  background: transparent;
}

.btn-outline-primary:hover {
  background: var(--color-primary-500);
  border-color: var(--color-primary-500);
  color: white;
}

.btn-outline-primary:active {
  background: var(--color-primary-600);
  border-color: var(--color-primary-600);
  color: white;
}

.btn-outline-secondary {
  border: 1px solid var(--color-neutral-300);
  color: var(--color-neutral-700);
  background: transparent;
}

.btn-outline-secondary:hover {
  background: var(--color-neutral-100);
  border-color: var(--color-neutral-400);
  color: var(--color-neutral-900);
}

.btn-outline-warning {
  border: 2px solid var(--color-warning);
  color: var(--color-warning);
  background: transparent;
}

.btn-outline-warning:hover {
  background: var(--color-warning);
  border-color: var(--color-warning);
  color: white;
}

.btn-outline-warning:active {
  background: #f57c00;
  border-color: #f57c00;
}

.form-control {
  border: 1px solid var(--color-neutral-300);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
  background: white;
}

.form-control:focus {
  border-color: var(--color-primary-500);
  box-shadow: 0 0 0 3px var(--color-primary-50);
  outline: none;
}

.form-control::placeholder {
  color: var(--color-neutral-400);
}

.form-label {
  font-weight: var(--font-medium);
  font-size: var(--text-sm);
  color: var(--color-neutral-700);
  margin-bottom: var(--space-2);
}

.form-check-label {
  font-size: var(--text-sm);
  color: var(--color-neutral-700);
  cursor: pointer;
}

/* ========================================
   Modals
   ======================================== */
.modal-content {
  border: none;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2xl);
  backdrop-filter: blur(10px);
}

.modal-header {
  border-bottom: 1px solid var(--color-neutral-200);
  padding: var(--space-5);
  background: var(--color-primary-500) !important;
  color: white !important;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-header * {
  color: white !important;
}

.modal-header .btn-close {
  filter: brightness(0) invert(1);
  opacity: 0.8;
}

.modal-header .btn-close:hover {
  opacity: 1;
}

.modal-title {
  font-weight: var(--font-bold);
  font-size: var(--text-2xl);
  color: white !important;
}

.modal-body {
  padding: var(--space-5);
}

.modal-footer {
  border-top: 1px solid var(--color-neutral-200);
  padding: var(--space-4) var(--space-5);
}

#settingsModal .help {
  color: var(--color-neutral-600);
  font-size: var(--text-sm);
  margin-bottom: var(--space-5);
  line-height: var(--leading-relaxed);
}

/* Cache stats table styling */
#cache-stats {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--color-neutral-600);
}

#cache-stats .d-flex {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--color-neutral-600);
}

#cache-stats strong {
  font-weight: var(--font-medium);
  color: var(--color-neutral-700);
}

/* ========================================
   Utilities & Special Elements
   ======================================== */
.word {
  font-style: italic;
  color: var(--color-primary-600);
  font-weight: var(--font-medium);
}

.hidden {
  display: none;
}

.wordlist-message {
  font-style: italic;
  color: var(--color-neutral-600);
}

.wordlist-message a {
  color: var(--color-primary-600);
  text-decoration: none;
  font-weight: var(--font-medium);
}

.wordlist-message a:hover {
  color: var(--color-primary-700);
  text-decoration: underline;
}


/* ========================================
   About Page
   ======================================== */
.about-content {
  line-height: var(--leading-relaxed);
  font-size: var(--text-base);
  max-width: 75ch;
  color: var(--color-neutral-800);
}

.about-content h5 {
  color: var(--color-neutral-700);
  border-bottom: 2px solid var(--color-neutral-200);
  padding-bottom: var(--space-2);
}

.about-content ul {
  padding-left: var(--space-5);
}

.about-content ul li {
  margin-bottom: var(--space-2);
}

/* ========================================
   Alerts & Notifications
   ======================================== */
.alert {
  border: none;
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}

.alert-info {
  background: var(--color-info);
  color: var(--color-neutral-900);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.alert-success {
  background: var(--color-success);
  color: white;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.alert-warning {
  background: var(--color-warning);
  color: var(--color-neutral-900);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.alert-danger,
.alert-error {
  background: var(--color-error);
  color: white;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

#notification {
  animation: slideInRight var(--transition-base);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ========================================
   Table Styling Enhancements
   ======================================== */

/* Base table styles */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: var(--space-5);
  background: white;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* Bootstrap table overrides */
.table {
  margin-bottom: var(--space-5);
  border-collapse: separate;
  border-spacing: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* Table headers */
thead th,
.table thead th {
  background: var(--color-neutral-100);
  color: var(--color-neutral-800);
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-3) var(--space-4);
  border-bottom: 2px solid var(--color-neutral-300);
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
}

/* Sticky headers for scrolling tables */
.table-sticky-header thead th {
  position: sticky;
  top: 0;
  background: var(--color-neutral-100);
  z-index: 10;
}

/* Table cells */
tbody td,
.table tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-neutral-200);
  color: var(--color-neutral-800);
  vertical-align: middle;
  line-height: var(--leading-relaxed);
}

/* Remove border from last row */
tbody tr:last-child td,
.table tbody tr:last-child td {
  border-bottom: none;
}

/* Zebra striping */
.table-striped tbody tr:nth-child(odd),
tbody tr:nth-child(odd) {
  background: var(--color-neutral-50);
}

.table-striped tbody tr:nth-child(even),
tbody tr:nth-child(even) {
  background: white;
}

/* Hover effect on rows */
.table-hover tbody tr:hover,
tbody tr:hover {
  background: var(--color-primary-50);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.table-hover tbody tr:hover td,
tbody tr:hover td {
  color: var(--color-neutral-900);
}

/* Clickable rows */
tbody tr.clickable-row {
  cursor: pointer;
  transition: all var(--transition-fast);
}

tbody tr.clickable-row:hover {
  background: var(--color-primary-50);
  transform: translateX(2px);
  box-shadow: -3px 0 0 var(--color-primary-500);
}

/* Column alignment helpers */
.text-right,
td.text-end,
th.text-end {
  text-align: right;
}

.text-center,
td.text-center,
th.text-center {
  text-align: center;
}

/* Number columns */
.table-number {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

/* Compact table variant */
.table-sm tbody td,
.table-sm thead th {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
}

/* Bordered table */
.table-bordered {
  border: 1px solid var(--color-neutral-200);
}

.table-bordered td,
.table-bordered th {
  border: 1px solid var(--color-neutral-200);
}

/* Sortable column headers */
th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: var(--space-6);
}

th.sortable:hover {
  background: var(--color-neutral-200);
}

th.sortable::after {
  content: '↕';
  position: absolute;
  right: var(--space-3);
  opacity: 0.3;
  font-size: var(--text-xs);
}

th.sortable.sort-asc::after {
  content: '↑';
  opacity: 1;
}

th.sortable.sort-desc::after {
  content: '↓';
  opacity: 1;
}

/* Responsive tables */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-lg);
}

/* Mobile: Stack table rows as cards */
@media (max-width: 768px) {
  .table-mobile-cards {
    border: 0;
  }

  .table-mobile-cards thead {
    display: none;
  }

  .table-mobile-cards tbody tr {
    display: block;
    margin-bottom: var(--space-4);
    border: 1px solid var(--color-neutral-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    background: white;
  }

  .table-mobile-cards tbody td {
    display: block;
    text-align: right;
    padding: var(--space-3);
    border-bottom: 1px solid var(--color-neutral-200);
  }

  .table-mobile-cards tbody td:last-child {
    border-bottom: none;
  }

  .table-mobile-cards tbody td::before {
    content: attr(data-label);
    float: left;
    font-weight: var(--font-semibold);
    color: var(--color-neutral-600);
    text-transform: uppercase;
    font-size: var(--text-xs);
    letter-spacing: 0.05em;
  }
}

/* Badge/pill styling for counts */
.table-badge {
  display: inline-block;
  padding: 0.25em 0.6em;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  vertical-align: baseline;
  border-radius: var(--radius-full);
  background: var(--color-neutral-200);
  color: var(--color-neutral-700);
}

.table-badge.badge-primary {
  background: var(--color-primary-100);
  color: var(--color-primary-700);
}

/* Progress bars in table cells */
.table-progress {
  height: 8px;
  background: var(--color-neutral-200);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: var(--space-1);
}

.table-progress-bar {
  height: 100%;
  background: var(--color-primary-500);
  border-radius: var(--radius-full);
  transition: width var(--transition-base);
}

/* Highlight search results in tables */
.table-highlight {
  background: #fff3cd;
  padding: 0.125em 0.25em;
  border-radius: var(--radius-sm);
  font-weight: var(--font-medium);
}

/* Empty state */
.table-empty {
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--color-neutral-600);
  font-style: italic;
}

.table-empty i {
  font-size: var(--text-3xl);
  color: var(--color-neutral-400);
  margin-bottom: var(--space-3);
  display: block;
}

/* Word links in tables and word index */
.word-link {
  text-decoration: none !important;
  transition: all var(--transition-fast);
}

.word-link:hover {
  text-decoration: underline !important;
  color: var(--color-primary-700) !important;
}

/* Word links in word index view */
.word-links .word-link {
  text-decoration: none;
  color: var(--color-primary-600);
  transition: all var(--transition-fast);
}

.word-links .word-link:hover {
  text-decoration: underline;
  color: var(--color-primary-700);
}

/* ========================================
   Floating Back to Top Buttons
   ======================================== */
#floating-document-btn,
#floating-top-btn,
#floating-topic-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
}

#floating-document-btn i,
#floating-top-btn i,
#floating-topic-btn i {
  font-size: 1.75rem;
  line-height: 1;
  margin: 0;
}

#floating-document-btn:hover i,
#floating-top-btn:hover i,
#floating-topic-btn:hover i {
  transform: scale(1.1);
  transition: transform var(--transition-fast);
}

/* ========================================
   Citation View Styles
   ======================================== */

/* Citation style selector dropdown */
#citation-style-select {
  min-width: 100px;
  color: var(--color-neutral-900) !important;
  background-color: white !important;
  border: 1px solid var(--color-neutral-400);
}

#citation-style-select option {
  color: var(--color-neutral-900) !important;
  background-color: white !important;
}

#citation-style-select:focus {
  border-color: var(--color-primary-500);
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
  color: var(--color-neutral-900) !important;
}

/* Ensure form-select has proper styling */
.form-select-sm {
  color: var(--color-neutral-900) !important;
  background-color: white !important;
}

/* Ensure label for citation style is visible */
.card-header label[for="citation-style-select"] {
  color: var(--color-neutral-900);
  font-weight: 500;
}

/* Citation display area */
.citation-display {
  padding: 1rem;
  background-color: var(--color-neutral-50);
  border: 1px solid var(--color-neutral-300);
  border-radius: 0.375rem;
}

.citation-display .csl-entry {
  margin-bottom: 0;
}

.citation-display em {
  font-style: italic;
}

.citation-display a {
  color: var(--color-primary-600);
  text-decoration: none;
}

.citation-display a:hover {
  color: var(--color-primary-700);
  text-decoration: underline;
}

/* ========================================
   Footer
   ======================================== */
.footer {
  margin-top: 3rem;
  background-color: var(--color-neutral-50);
  border-top: 1px solid var(--color-neutral-300);
  font-size: var(--text-sm);
}

.footer p {
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

.footer a {
  color: var(--color-primary-600);
  transition: color 0.2s ease;
}

.footer a:hover {
  color: var(--color-primary-700);
}

.footer .bi-github {
  margin-right: 0.25rem;
  font-size: 1.1em;
  vertical-align: middle;
}

/* ========================================
   Diagnostics View
   ======================================== */
#topic-quality-chart {
  background-color: var(--color-neutral-50);
  border: 1px solid var(--color-neutral-300);
  border-radius: 0.375rem;
  padding: 1rem;
}

#topic-quality-chart svg {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
}

#topic-quality-chart .domain {
  stroke: var(--color-neutral-400);
}

#topic-quality-chart .tick line {
  stroke: var(--color-neutral-300);
}

#topic-quality-chart text {
  fill: var(--color-neutral-700);
}

#diagnostics-table {
  font-size: var(--text-sm);
}

#diagnostics-table th {
  background-color: var(--color-neutral-100);
  border-bottom: 2px solid var(--color-neutral-300);
  font-weight: 600;
}

#diagnostics-table td {
  vertical-align: middle;
}

.tooltip {
  pointer-events: none;
  z-index: 9999;
  visibility: hidden;
}