/* ==========================================================================
   VETMEDICA - Professional Veterinary Internal Medicine Book Design System
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=Lora:ital,wght@0,400;0,500;0,600;0,700;1,400;1,600&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

/* --- CSS Variables & Design Tokens --- */
:root {
  /* Color Palette - Light Mode (Serene Medical Book) */
  --bg-primary: #faf9f6;
  --bg-surface: #ffffff;
  --bg-sidebar: #f3f1ec;
  --bg-header: rgba(250, 249, 246, 0.85);
  --bg-card: #ffffff;
  --bg-subtle: #f1efea;
  
  --border-light: rgba(0, 0, 0, 0.08);
  --border-medium: rgba(0, 0, 0, 0.14);
  --border-active: #0f766e;
  
  --text-title: #0f172a;
  --text-heading: #1e293b;
  --text-body: #334155;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  
  --brand-primary: #0f766e;
  --brand-hover: #0d9488;
  --brand-light: #e6f4f1;
  --brand-accent: #14b8a6;
  
  --pearl-bg: #fffbeb;
  --pearl-border: #fcd34d;
  --pearl-text: #92400e;
  --pearl-icon: #d97706;
  
  --pitfall-bg: #fef2f2;
  --pitfall-border: #fca5a5;
  --pitfall-text: #991b1b;
  --pitfall-icon: #dc2626;

  --drug-bg: #ffffff;
  --drug-border: #e2e8f0;
  --drug-header: #f8fafc;
  --drug-tag-bg: #e0f2fe;
  --drug-tag-text: #0369a1;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  --shadow-modal: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Lora', Georgia, Cambria, 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', monospace;

  --font-reader-body: var(--font-serif);
  --reader-font-size: 1.06rem;
  --reader-line-height: 1.85;

  --sidebar-width: 330px;
  --toc-width: 250px;
  --header-height: 64px;
}

[data-theme="dark"] {
  /* Color Palette - Dark Mode (Obsidian Book) */
  --bg-primary: #0b0f17;
  --bg-surface: #111827;
  --bg-sidebar: #0d131f;
  --bg-header: rgba(11, 15, 23, 0.88);
  --bg-card: #131c2e;
  --bg-subtle: #1a2438;

  --border-light: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.15);
  --border-active: #14b8a6;

  --text-title: #f8fafc;
  --text-heading: #f1f5f9;
  --text-body: #cbd5e1;
  --text-muted: #94a3b8;
  --text-faint: #64748b;

  --brand-primary: #14b8a6;
  --brand-hover: #2dd4bf;
  --brand-light: rgba(20, 184, 166, 0.14);
  --brand-accent: #2dd4bf;

  --pearl-bg: rgba(217, 119, 6, 0.12);
  --pearl-border: rgba(245, 158, 11, 0.35);
  --pearl-text: #fef3c7;
  --pearl-icon: #fbbf24;

  --pitfall-bg: rgba(220, 38, 38, 0.12);
  --pitfall-border: rgba(239, 68, 68, 0.35);
  --pitfall-text: #fee2e2;
  --pitfall-icon: #f87171;

  --drug-bg: #111827;
  --drug-border: #1f2937;
  --drug-header: #1e293b;
  --drug-tag-bg: rgba(56, 189, 248, 0.15);
  --drug-tag-text: #38bdf8;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

/* --- Base & Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-body);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* --- Scroll Progress Bar --- */
#scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3.5px;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent), #38bdf8);
  z-index: 1000;
  transform-origin: 0 50%;
  transform: scaleX(0);
  transition: transform 0.1s linear;
}

@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) {
    @keyframes grow-progress {
      from { transform: scaleX(0); }
      to { transform: scaleX(1); }
    }
    #scroll-progress {
      animation: grow-progress auto linear;
      animation-timeline: scroll(root block);
    }
  }
}

/* --- App Layout Grid --- */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --- Header Bar --- */
.main-header {
  position: sticky;
  top: 0;
  height: var(--header-height);
  background-color: var(--bg-header);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 500;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.mobile-menu-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-heading);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 8px;
}

.mobile-menu-toggle:hover {
  background-color: var(--bg-subtle);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
}

.brand-emblem-wrapper {
  width: 36px;
  height: 36px;
  position: relative;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 6px rgba(15, 118, 110, 0.2));
}

.brand-emblem-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-text {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 1.45rem;
  letter-spacing: -0.035em;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

.brand-wiki {
  color: var(--text-title);
}

.brand-vet {
  color: #0d9488;
  background: linear-gradient(135deg, #0f766e 0%, #14b8a6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-left: 1px;
}

[data-theme="dark"] .brand-vet {
  background: linear-gradient(135deg, #14b8a6 0%, #2dd4bf 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Search Trigger Button */
.header-search-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  color: var(--text-muted);
  padding: 0.45rem 0.9rem;
  border-radius: 99px;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  min-width: 260px;
}

.header-search-btn:hover {
  border-color: var(--brand-primary);
  color: var(--text-heading);
  box-shadow: 0 0 0 3px var(--brand-light);
}

.kbd-shortcut {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-medium);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--text-muted);
}

/* Header Controls Right */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.action-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-heading);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
}

.action-btn:hover {
  background-color: var(--bg-subtle);
  border-color: var(--border-light);
}

.badge-count {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--brand-primary);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  width: 17px;
  height: 17px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Font Reader Adjuster Widget */
.reader-controls-group {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 2px;
}

.reader-control-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.reader-control-btn:hover, .reader-control-btn.active {
  color: var(--brand-primary);
  background: var(--brand-light);
}

/* --- Main Layout Workspace --- */
.main-workspace {
  display: flex;
  flex: 1;
}

/* --- Left Category Tree Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-height));
  position: sticky;
  top: var(--header-height);
  flex-shrink: 0;
  overflow: hidden;
  transition: transform 0.3s ease;
  z-index: 400;
}

.sidebar-header {
  padding: 1.1rem 1.25rem 0.8rem;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-filter-input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  font-size: 0.85rem;
  color: var(--text-heading);
  outline: none;
  transition: border-color 0.2s ease;
}

.sidebar-filter-input:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px var(--brand-light);
}

.sidebar-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.6rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 0.8rem 0.75rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border-medium) transparent;
}

/* Tree Category Accordion Item */
.category-group {
  margin-bottom: 0.4rem;
}

.category-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border: none;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  color: var(--text-heading);
  font-weight: 700;
  font-size: 0.84rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
}

.category-header:hover {
  background-color: rgba(0,0,0,0.04);
}

[data-theme="dark"] .category-header:hover {
  background-color: rgba(255,255,255,0.05);
}

.cat-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat-folder-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--brand-primary);
  font-weight: 700;
}

.cat-chevron {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
  color: var(--text-muted);
  flex-shrink: 0;
}

.category-group.expanded .cat-chevron {
  transform: rotate(90deg);
}

.cat-count-pill {
  font-size: 0.7rem;
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border-light);
  padding: 1px 6px;
  border-radius: 99px;
  font-weight: 600;
}

/* Sub-categories & Disease links */
.category-items-container {
  display: none;
  padding-left: 0.8rem;
  margin-top: 0.2rem;
}

.category-group.expanded .category-items-container {
  display: block;
}

.sub-category-block {
  margin-bottom: 0.5rem;
}

.sub-category-title {
  font-size: 0.73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  padding: 0.3rem 0.6rem 0.1rem;
}

.disease-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  color: var(--text-body);
  text-decoration: none;
  font-size: 0.83rem;
  line-height: 1.35;
  transition: all 0.15s ease;
  margin-bottom: 2px;
}

.disease-link:hover {
  background-color: var(--bg-surface);
  color: var(--brand-primary);
}

/* CRITICAL USER RULE: NO BORDER RADIUS ON LEFT & RIGHT FOR ACTIVE DISEASE ITEM IN SIDEBAR */
.disease-link.active {
  background-color: var(--brand-light);
  color: var(--brand-primary);
  font-weight: 700;
  border-radius: 0 !important;
  box-shadow: inset 3px 0 0 var(--brand-primary);
}

/* --- Reader Content Panel Center --- */
.reader-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2.5rem 2rem 4rem;
  overflow-y: auto;
  min-width: 0;
}

.reader-content {
  width: 100%;
  max-width: 840px;
}

/* Empty State / Welcome Screen */
.welcome-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 3rem 2.5rem;
  text-align: center;
  box-shadow: var(--shadow-md);
  margin-top: 1rem;
}

.welcome-icon {
  width: 64px;
  height: 64px;
  background: var(--brand-light);
  color: var(--brand-primary);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
}

.welcome-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-title);
  margin-bottom: 0.8rem;
  letter-spacing: -0.02em;
}

.welcome-desc {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 600px;
  margin: 0 auto 2rem;
  line-height: 1.7;
}

.quick-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 2rem;
  text-align: left;
}

.stat-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 1.2rem;
}

.stat-val {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--brand-primary);
}

.stat-lbl {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Article Reader Styling */
.article-header {
  margin-bottom: 2.5rem;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 1.8rem;
}

.article-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.crumb-link {
  color: var(--brand-primary);
  text-decoration: none;
  font-weight: 600;
}

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

.article-title-en-primary {
  font-size: 2.3rem;
  font-weight: 800;
  color: var(--text-title);
  line-height: 1.2;
  letter-spacing: -0.025em;
  margin-bottom: 0.4rem;
}

.article-title-tr-sub {
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 1.2rem;
}

.article-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
}

.meta-tags {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.meta-pill {
  font-size: 0.76rem;
  font-weight: 600;
  background: var(--bg-subtle);
  color: var(--text-body);
  border: 1px solid var(--border-light);
  padding: 3px 10px;
  border-radius: 99px;
}

.meta-pill.brand {
  background: var(--brand-light);
  color: var(--brand-primary);
  border-color: transparent;
}

.article-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-icon-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  color: var(--text-heading);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon-label:hover {
  background: var(--brand-light);
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}

.btn-icon-label.bookmarked {
  background: var(--brand-primary);
  color: #ffffff;
  border-color: var(--brand-primary);
}

/* Article Content Body */
.article-body {
  font-family: var(--font-reader-body);
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  color: var(--text-body);
}

/* Reader Font Mode Toggle (Book vs Clean) */
html[data-reader-font="sans"] .article-body,
body[data-reader-font="sans"] .article-body {
  font-family: var(--font-sans) !important;
}

html[data-reader-font="serif"] .article-body,
body[data-reader-font="serif"] .article-body {
  font-family: var(--font-serif) !important;
}

/* Medical Section Block */
.section-block {
  margin-bottom: 2.8rem;
  scroll-margin-top: calc(var(--header-height) + 1.5rem);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-light);
}

.section-icon-box {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--brand-light);
  color: var(--brand-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.section-title {
  font-family: var(--font-sans);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-title);
  letter-spacing: -0.015em;
}

.section-paragraph {
  margin-bottom: 1rem;
  text-align: justify;
}

/* Pearls and Pitfalls Special Grid */
.pearls-pitfalls-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin-top: 1rem;
}

.pearl-box, .pitfall-box {
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  position: relative;
}

.pearl-box {
  background-color: var(--pearl-bg);
  border: 1px solid var(--pearl-border);
  color: var(--pearl-text);
}

.pitfall-box {
  background-color: var(--pitfall-bg);
  border: 1px solid var(--pitfall-border);
  color: var(--pitfall-text);
}

.box-title {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.pearl-box .box-title { color: var(--pearl-icon); }
.pitfall-box .box-title { color: var(--pitfall-icon); }

.box-list {
  padding-left: 1.2rem;
  font-size: 0.95rem;
  line-height: 1.7;
}

.box-list li {
  margin-bottom: 0.4rem;
}

/* ==========================================================================
   NEW DRUG PROTOCOLS ENHANCED STRUCTURED CARDS (RESPONSIVE GRID & BADGES)
   ========================================================================== */
.drug-protocols-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.2rem;
  margin-top: 1.2rem;
}

.drug-card {
  background: var(--drug-bg);
  border: 1px solid var(--drug-border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.drug-card:hover {
  border-color: var(--border-active);
  box-shadow: var(--shadow-md);
}

.drug-card-header {
  background: var(--drug-header);
  padding: 0.8rem 1.2rem;
  border-bottom: 1px solid var(--drug-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.drug-card-num-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.drug-num-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--brand-primary);
  color: #ffffff;
  padding: 2px 8px;
  border-radius: 6px;
}

.drug-name-heading {
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-title);
}

.drug-category-pill {
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--brand-light);
  color: var(--brand-primary);
  padding: 2px 8px;
  border-radius: 99px;
  font-family: var(--font-sans);
}

.drug-card-body {
  padding: 1.1rem 1.2rem;
  font-family: var(--font-sans);
}

.drug-dose-badge {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
  background: var(--drug-tag-bg);
  color: var(--drug-tag-text);
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.drug-dose-icon {
  flex-shrink: 0;
  color: var(--brand-primary);
}

.drug-notes-text {
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text-body);
}

.drug-caution-banner {
  background: var(--pearl-bg);
  border: 1px solid var(--pearl-border);
  color: var(--pearl-text);
  padding: 0.8rem 1rem;
  border-radius: 10px;
  margin-top: 1rem;
  font-size: 0.88rem;
  line-height: 1.6;
  font-family: var(--font-sans);
}

.drug-caution-banner.pitfall {
  background: var(--pitfall-bg);
  border: 1px solid var(--pitfall-border);
  color: var(--pitfall-text);
}

/* References Section */
.references-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.reference-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.88rem;
  color: var(--text-body);
  font-family: var(--font-sans);
}

.ref-bullet {
  color: var(--brand-primary);
  font-weight: 700;
}

/* --- Right Side Table of Contents (TOC) --- */
.toc-sidebar {
  width: var(--toc-width);
  padding: 2.5rem 1.25rem 2rem 0.5rem;
  height: calc(100vh - var(--header-height));
  position: sticky;
  top: var(--header-height);
  flex-shrink: 0;
  display: none;
}

@media (min-width: 1240px) {
  .toc-sidebar {
    display: block;
  }
}

.toc-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.8rem;
  padding-left: 0.75rem;
}

.toc-list {
  list-style: none;
  border-left: 2px solid var(--border-light);
  padding-left: 0;
}

.toc-item {
  margin-bottom: 2px;
}

.toc-link {
  display: block;
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-left: -2px;
  transition: all 0.15s ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toc-link:hover {
  color: var(--brand-primary);
}

.toc-link.active {
  color: var(--brand-primary);
  font-weight: 700;
  border-left-color: var(--brand-primary);
  background: var(--brand-light);
  border-radius: 0 4px 4px 0;
}

/* --- Command-K Search Modal --- */
dialog#search-modal {
  margin: auto;
  border: 1px solid var(--border-medium);
  border-radius: 20px;
  background: var(--bg-surface);
  color: var(--text-body);
  width: 92%;
  max-width: 720px;
  max-height: 82vh;
  box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.35);
  padding: 0;
  overflow: hidden;

  transform: scale(0.96);
  opacity: 0;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

dialog#search-modal[open] {
  opacity: 1;
  transform: scale(1);
}

@starting-style {
  dialog#search-modal[open] {
    opacity: 0;
    transform: scale(0.96);
  }
}

dialog#search-modal::backdrop {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.2s ease;
}

dialog#search-modal[open]::backdrop {
  opacity: 1;
}

.modal-search-header {
  display: flex;
  align-items: center;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--border-medium);
  gap: 0.85rem;
  background: linear-gradient(135deg, var(--bg-surface) 0%, var(--bg-subtle) 100%);
}

.modal-search-input {
  flex: 1;
  background: transparent;
  border: none;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-heading);
  outline: none;
  font-family: var(--font-sans);
}

.modal-search-input::placeholder {
  color: var(--text-muted);
  font-weight: 500;
}

.modal-search-kbd {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--bg-subtle);
  border: 1px solid var(--border-medium);
  color: var(--text-muted);
  padding: 2px 7px;
  border-radius: 6px;
}

.modal-close-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border-medium);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.modal-close-btn:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
  transform: scale(1.08);
}

.modal-results-container {
  max-height: 55vh;
  overflow-y: auto;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.search-result-item {
  display: block;
  padding: 0.85rem 1.1rem;
  border-radius: 12px;
  text-decoration: none;
  color: var(--text-body);
  border: 1px solid transparent;
  transition: all 0.15s ease;
  background: transparent;
}

.search-result-item:hover, .search-result-item.selected {
  background-color: var(--brand-light);
  border-color: rgba(15, 118, 110, 0.2);
  transform: translateX(3px);
}

.search-res-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-heading);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.search-res-cat {
  font-size: 0.72rem;
  background: var(--bg-subtle);
  color: var(--brand-primary);
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 700;
  flex-shrink: 0;
}

.modal-search-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.4rem;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-medium);
  font-size: 0.76rem;
  color: var(--text-muted);
}

.modal-footer-hints {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.modal-footer-hints kbd {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  padding: 1px 5px;
  border-radius: 4px;
  margin: 0 2px;
  color: var(--text-heading);
  font-weight: 700;
}

.modal-footer-brand {
  font-weight: 600;
  color: var(--brand-primary);
}

.search-res-en {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

.search-res-excerpt {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- Bookmarks Drawer --- */
.bookmarks-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  height: 100vh;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-medium);
  box-shadow: var(--shadow-lg);
  z-index: 600;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.bookmarks-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  padding: 1.2rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-title);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

/* --- Mobile & Tablet Breakpoint & Offcanvas --- */
@media (max-width: 1099px) {
  .mobile-menu-toggle {
    display: flex;
  }

  .header-search-btn {
    display: none !important;
  }

  .sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    height: calc(100vh - var(--header-height));
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .reader-wrapper {
    padding: 1.5rem 1rem 3rem;
  }

  .article-title-en-primary {
    font-size: 1.75rem;
  }

  /* Mobile Actions Overflow */
  .header-actions > .reader-controls-group,
  .header-actions > #btn-toggle-bookmarks,
  .header-actions > #btn-toggle-theme,
  .header-actions > #btn-print-article {
    display: none !important;
  }

  .mobile-actions-wrapper {
    display: block !important;
  }
}

/* --- Print Stylesheet --- */
@media print {
  #scroll-progress, .main-header, .sidebar, .toc-sidebar, .article-actions, .bookmarks-drawer {
    display: none !important;
  }

  .app-container, .main-workspace, .reader-wrapper {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
  }

  .reader-content {
    max-width: 100% !important;
  }

  .article-body {
    font-size: 11pt !important;
    line-height: 1.6 !important;
    color: #000 !important;
  }
}

/* Sidebar Discipline Group Headers */
.discipline-divider {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem 0.4rem;
  margin-top: 0.8rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-primary);
  border-bottom: 1px solid var(--border-light);
}

.discipline-divider:first-child {
  margin-top: 0;
}

.discipline-divider.surgery {
  color: #d97706;
}

[data-theme="dark"] .discipline-divider.surgery {
  color: #fbbf24;
}

@media print {
  .section-block {
    page-break-inside: avoid;
  }
}

/* ==========================================================================
   Minimalist Google Translate & Language Selector
   ========================================================================== */

/* Stealth Overrides for Google Translate Default UI */
body {
  top: 0 !important;
  position: static !important;
}

.goog-te-banner-frame,
.goog-te-banner,
.skiptranslate iframe,
#goog-gt-tt,
.goog-te-balloon-frame,
.goog-tooltip,
.goog-tooltip:hover {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.goog-text-highlight {
  background-color: transparent !important;
  box-shadow: none !important;
}

#google_translate_element {
  display: none !important;
}

body > .skiptranslate {
  display: none !important;
}

/* UI Language Selector */
.lang-selector-wrapper {
  position: relative;
}

.lang-btn {
  width: auto !important;
  padding: 0 0.55rem !important;
  gap: 0.35rem;
  display: inline-flex;
  align-items: center;
}

.lang-badge {
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--font-sans);
  letter-spacing: 0.05em;
  background: var(--brand-light);
  color: var(--brand-primary);
  padding: 1px 5px;
  border-radius: 4px;
  text-transform: uppercase;
}

.lang-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  padding: 0.5rem;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.96);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.lang-dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.lang-dropdown-header {
  padding: 0.4rem 0.6rem 0.5rem;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 0.35rem;
  display: flex;
  flex-direction: column;
}

.lang-dropdown-header span:first-child {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-heading);
}

.lang-subhead {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.lang-dropdown-list {
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lang-dropdown-list::-webkit-scrollbar {
  width: 4px;
}

.lang-dropdown-list::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 4px;
}

.lang-option-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  background: transparent;
  border: none;
  width: 100%;
  color: var(--text-body);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  text-align: left;
}

.lang-option-item:hover {
  background: var(--bg-subtle);
  color: var(--text-heading);
}

.lang-option-item.active {
  background: var(--brand-light);
  color: var(--brand-primary);
  font-weight: 700;
}

.lang-option-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lang-option-flag {
  font-size: 1.05rem;
  line-height: 1;
}

.lang-option-code-pill {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  text-transform: uppercase;
}

.lang-option-item.active .lang-option-code-pill {
  background: var(--brand-primary);
  color: #fff;
}

/* Sidebar Main Discipline Accordion Headers */
.discipline-group-block {
  margin-top: 0.75rem;
}

.discipline-group-block:first-child {
  margin-top: 0;
}

.discipline-toggle-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.62rem 0.85rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  color: var(--brand-primary);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.18s ease;
}

.discipline-toggle-btn:hover {
  border-color: var(--border-medium);
  background: var(--bg-surface);
}

.discipline-group-block.surgery .discipline-toggle-btn {
  color: #d97706;
}

.discipline-group-block.exotic .discipline-toggle-btn {
  color: #059669;
}

.discipline-group-block.gynecology .discipline-toggle-btn {
  color: #e11d48;
}

.discipline-group-block.bovine .discipline-toggle-btn {
  color: #0284c7;
}

.discipline-group-block.smallruminant .discipline-toggle-btn {
  color: #0d9488;
}

.discipline-group-block.equine .discipline-toggle-btn {
  color: #8b5cf6;
}

.discipline-group-block.poultry .discipline-toggle-btn {
  color: #ea580c;
}

[data-theme="dark"] .discipline-group-block.surgery .discipline-toggle-btn {
  color: #fbbf24;
}

[data-theme="dark"] .discipline-group-block.exotic .discipline-toggle-btn {
  color: #34d399;
}

[data-theme="dark"] .discipline-group-block.gynecology .discipline-toggle-btn {
  color: #fb7185;
}

[data-theme="dark"] .discipline-group-block.bovine .discipline-toggle-btn {
  color: #38bdf8;
}

[data-theme="dark"] .discipline-group-block.smallruminant .discipline-toggle-btn {
  color: #2dd4bf;
}

[data-theme="dark"] .discipline-group-block.equine .discipline-toggle-btn {
  color: #c084fc;
}

[data-theme="dark"] .discipline-group-block.poultry .discipline-toggle-btn {
  color: #fb923c;
}

.discipline-left {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.discipline-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.discipline-count-pill {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.06);
  color: currentColor;
}

[data-theme="dark"] .discipline-count-pill {
  background: rgba(255, 255, 255, 0.1);
}

.discipline-chevron {
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.discipline-group-block.collapsed .discipline-chevron {
  transform: rotate(-90deg);
}

.discipline-group-block.collapsed .discipline-categories-container {
  display: none;
}

.discipline-categories-container {
  padding-top: 0.35rem;
}

/* Mobile Actions Overflow Dropdown Styles */
.mobile-actions-wrapper {
  position: relative;
  display: none;
}

.mobile-actions-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  color: var(--text-heading);
  cursor: pointer;
  transition: all 0.15s ease;
}

.mobile-actions-toggle-btn:hover {
  background: var(--bg-surface);
  border-color: var(--border-medium);
}

.mobile-actions-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 230px;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 0.6rem;
  display: none;
  flex-direction: column;
  gap: 0.35rem;
  z-index: 1000;
  backdrop-filter: blur(16px);
}

.mobile-actions-dropdown.show {
  display: flex;
  animation: dropdownFade 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.mobile-actions-header {
  padding: 0.2rem 0.4rem 0.4rem;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.mobile-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.4rem;
}

.mobile-menu-item.font-row {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  padding: 0.4rem;
  background: var(--bg-subtle);
  border-radius: 8px;
}

.mobile-menu-label {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-heading);
}

.mobile-menu-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.55rem 0.6rem;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--text-body);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  text-align: left;
}

.mobile-menu-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-heading);
}

.mobile-menu-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ==========================================================================
   WIKIPEDIA-STYLE HOME PORTAL DESIGN
   ========================================================================== */

.wiki-home-portal {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem 0 4rem;
}

/* Top Main Banner Image */
.wiki-main-banner-wrap {
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-medium);
  margin-bottom: 2rem;
  background: var(--bg-surface);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.wiki-main-banner-wrap:hover {
  box-shadow: var(--shadow-md);
}

.wiki-main-banner-img {
  width: 100%;
  height: auto;
  max-height: 260px;
  display: block;
  object-fit: cover;
  border-radius: 16px;
}

.wiki-hero-banner {
  background: linear-gradient(135deg, var(--bg-surface) 0%, var(--bg-subtle) 100%);
  border: 1px solid var(--border-medium);
  border-radius: 16px;
  padding: 2.2rem 2rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.wiki-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  border-radius: 99px;
  background: var(--brand-light);
  color: var(--brand-primary);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.8rem;
}

.wiki-hero-title {
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--text-title);
  letter-spacing: -0.02em;
  margin-bottom: 0.6rem;
  font-family: var(--font-sans);
}

.wiki-hero-subtitle {
  font-size: 1.02rem;
  color: var(--text-body);
  max-width: 680px;
  margin: 0 auto 1.5rem;
  line-height: 1.6;
}

.wiki-hero-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.wiki-hero-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.4rem;
  border-radius: 99px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
  border: none;
}

.wiki-hero-btn.primary {
  background: var(--brand-primary);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.wiki-hero-btn.primary:hover {
  background: var(--brand-hover);
  transform: translateY(-1px);
}

.wiki-hero-btn.secondary {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  color: var(--text-heading);
}

.wiki-hero-btn.secondary:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.wiki-section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 2.2rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border-light);
  color: var(--brand-primary);
}

.wiki-section-header h2 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-title);
  margin: 0;
  letter-spacing: -0.01em;
}

/* Featured Article Card */
.wiki-featured-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-left: 4px solid var(--brand-primary);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.wiki-featured-card:hover {
  box-shadow: var(--shadow-md);
}

.featured-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.featured-tag {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--brand-primary);
  color: #fff;
  text-transform: uppercase;
}

.featured-subtag {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.featured-title {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-title);
  margin-bottom: 0.6rem;
  line-height: 1.3;
}

.featured-excerpt {
  font-size: 0.94rem;
  color: var(--text-body);
  line-height: 1.6;
  margin-bottom: 1.2rem;
}

.featured-read-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--brand-primary);
  text-decoration: none;
  transition: gap 0.18s ease;
}

.featured-read-btn:hover {
  gap: 0.6rem;
  color: var(--brand-hover);
}

/* Species Portals Grid */
.wiki-species-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.85rem;
}

.species-card {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.9rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.species-card:hover {
  border-color: var(--brand-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.species-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.species-info h4 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-title);
  margin: 0 0 2px;
}

.species-info p {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 0 0 4px;
  line-height: 1.2;
}

.species-count {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--brand-primary);
}

/* Clinical Pearls Highlight */
.wiki-pearls-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.wiki-pearl-item {
  background: var(--pearl-bg);
  border: 1px solid var(--pearl-border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
}

.pearl-badge {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--pearl-text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
}

.pearl-text {
  font-size: 0.9rem;
  color: var(--pearl-text);
  line-height: 1.55;
}

/* Discover Cards Grid */
.wiki-discover-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.85rem;
}

.discover-card {
  display: block;
  padding: 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  text-decoration: none;
  transition: all 0.18s ease;
}

.discover-card:hover {
  border-color: var(--brand-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.discover-tag {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--brand-primary);
  text-transform: uppercase;
  margin-bottom: 0.3rem;
}

.discover-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-title);
  margin: 0 0 0.3rem;
  line-height: 1.3;
}

.discover-cat {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Panoramic Banner Carousel Component */
.wiki-banner-carousel {
  position: relative;
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  aspect-ratio: 1536 / 256;
}

.carousel-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.carousel-slide.active {
  opacity: 1;
  visibility: visible;
}

.carousel-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.slide-caption {
  position: absolute;
  bottom: 10px;
  left: 14px;
  padding: 4px 12px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 99px;
  letter-spacing: 0.02em;
}

.carousel-dots {
  position: absolute;
  bottom: 10px;
  right: 14px;
  display: flex;
  gap: 6px;
  z-index: 5;
}

.carousel-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  transition: all 0.2s ease;
}

.carousel-dots .dot.active {
  background: #ffffff;
  width: 20px;
  border-radius: 99px;
}

/* Article Header Banner Strip */
.article-banner-strip {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  max-height: 180px;
}

.article-banner-strip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* --- Vademecum Dashboard Layout Rules --- */

/* Desktop Layout (>= 1100px) */
@media (min-width: 1100px) {
  body.home-view .toc-sidebar {
    display: flex !important;
    flex-direction: column;
    width: 320px;
    padding: 0 !important;
    height: calc(100vh - var(--header-height, 64px));
    position: sticky;
    top: var(--header-height, 64px);
    background: var(--bg-surface);
    border-left: 1px solid var(--border-medium);
    flex-shrink: 0;
  }

  body.home-view #vademecum-widget-container {
    display: flex !important;
    flex-direction: column;
    gap: 0.85rem;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 1.15rem 1rem 1rem 1rem;
    box-shadow: none;
    position: static;
    height: 100%;
    max-height: none;
    overflow: hidden;
    margin: 0 !important;
  }

  body.home-view .reader-wrapper {
    max-width: 980px;
    margin: 0 auto;
    padding-top: 1.5rem !important;
  }
}

/* Tablet & Mobile Layout (< 1100px) - Vademecum stacked above footer */
@media (max-width: 1099px) {
  body.home-view .main-workspace {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  body.home-view .reader-wrapper {
    display: contents;
  }

  body.home-view .reader-content {
    order: 1;
    width: 100%;
    max-width: 840px;
    margin: 0 auto;
    padding: 1.25rem 1rem !important;
  }

  body.home-view .toc-sidebar {
    order: 2;
    display: block !important;
    width: 100% !important;
    max-width: 840px;
    margin: 1.5rem auto 0;
    padding: 0 1rem !important;
    height: auto !important;
    position: static !important;
    border-left: none !important;
  }

  body.home-view #vademecum-widget-container {
    display: flex !important;
    flex-direction: column;
    gap: 0.85rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    position: static;
    height: auto;
    max-height: 560px;
    margin: 0 !important;
  }

  body.home-view .site-footer {
    order: 3;
    width: 100%;
    max-width: 840px;
    margin: 2rem auto 0;
    padding: 0 1rem 2rem;
  }
}

body.home-view #toc-container {
  display: none !important;
}

body:not(.home-view) #vademecum-widget-container {
  display: none !important;
}

body:not(.home-view) #toc-container {
  display: block !important;
}

body.home-view .welcome-card {
  margin-top: 0 !important;
}

.vademecum-widget-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.vademecum-widget-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-heading);
  letter-spacing: -0.01em;
  margin: 0;
}

.vademecum-search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.vademecum-search-box svg {
  position: absolute;
  left: 0.75rem;
  color: var(--text-muted);
  pointer-events: none;
}

.vademecum-search-input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.2rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-medium);
  border-radius: 10px;
  font-size: 0.84rem;
  color: var(--text-heading);
  outline: none;
  transition: all 0.15s ease;
}

.vademecum-search-input:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-light);
  background: var(--bg-surface);
}

.vademecum-pills-row {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding: 6px 4px 8px 4px;
  align-items: center;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.vademecum-pill {
  white-space: nowrap;
  background: var(--bg-subtle);
  border: 1px solid var(--border-medium);
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 99px;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.vademecum-pill:hover, .vademecum-pill.active {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #ffffff;
}

.vademecum-pill {
  white-space: nowrap;
  background: var(--bg-subtle);
  border: 1px solid var(--border-medium);
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 99px;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.vademecum-pill:hover, .vademecum-pill.active {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #ffffff;
}

.vademecum-drug-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  max-height: none;
  overflow-y: auto;
  padding-right: 4px;
}

.vademecum-drug-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  cursor: pointer;
  transition: all 0.18s ease;
}

.vademecum-drug-card:hover {
  border-color: var(--brand-primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.08);
}

.vademecum-drug-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.vademecum-drug-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.25;
}

.vademecum-controlled-badge {
  font-size: 0.65rem;
  font-weight: 800;
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.12);
  padding: 1px 5px;
  border-radius: 4px;
  flex-shrink: 0;
}

.vademecum-drug-class {
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vademecum-species-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.vademecum-species-chip {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--brand-dark);
  background: rgba(15, 118, 110, 0.07);
  padding: 1px 6px;
  border-radius: 4px;
}

/* --- Vademecum Monograph Slide-Over Side Drawer --- */
.vademecum-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.vademecum-drawer-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.vademecum-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 660px;
  background: var(--bg-surface);
  box-shadow: -10px 0 35px rgba(0, 0, 0, 0.22);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  z-index: 10000;
}

@media (max-width: 640px) {
  .vademecum-drawer {
    width: 100% !important;
    max-width: 100% !important;
  }
}

.vademecum-drawer-backdrop.open .vademecum-drawer {
  transform: translateX(0);
}

.vademecum-drawer-content {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Prevent body background scrolling when drawer is open */
body.vademecum-drawer-active {
  overflow: hidden !important;
}

.monograph-header {
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--bg-surface) 0%, var(--bg-subtle) 100%);
  border-bottom: 1px solid var(--border-medium);
  position: relative;
}

.monograph-close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-medium);
  color: var(--text-heading);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.monograph-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* --- Structured Medical Lists & Item Cards --- */
.medical-item-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.medical-item-card {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 0.9rem 1.1rem;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.medical-item-card:hover {
  background: var(--bg-surface);
  border-color: rgba(15, 118, 110, 0.4);
  transform: translateX(3px);
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.08);
}

.item-number-badge {
  flex-shrink: 0;
  min-width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand-light);
  border: 1.5px solid rgba(15, 118, 110, 0.3);
  color: var(--brand-primary);
  font-size: 0.8rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.item-content {
  flex: 1;
  font-size: 0.93rem;
  line-height: 1.6;
  color: var(--text-body);
}

.item-title {
  color: var(--brand-primary);
  font-weight: 800;
  letter-spacing: -0.01em;
  font-size: 0.95rem;
}

.item-desc {
  color: var(--text-body);
}

.lead-paragraph {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 0.85rem;
  line-height: 1.5;
}

/* --- Diagnostic Algorithm Flowchart Stepper --- */
.diagnostic-algorithm-wrapper {
  background: var(--bg-subtle);
  border: 1.5px solid var(--border-medium);
  border-radius: 16px;
  padding: 1.5rem;
  margin: 1.25rem 0 1.75rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.03);
}

.algorithm-header-strip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding-bottom: 0.85rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.algorithm-icon {
  font-size: 1.2rem;
}

.algorithm-header-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--brand-primary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.algorithm-preamble {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.algorithm-timeline {
  display: flex;
  flex-direction: column;
  position: relative;
}

.algorithm-step-card {
  display: flex;
  align-items: stretch;
  gap: 1.25rem;
  position: relative;
}

.step-sidebar {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  width: 38px;
}

.step-node-badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-primary) 0%, #0d9488 100%);
  color: #ffffff;
  font-size: 0.88rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.3);
  border: 2px solid var(--bg-surface);
  z-index: 2;
}

.step-connecting-line {
  flex: 1;
  width: 3px;
  background: linear-gradient(to bottom, var(--brand-primary) 0%, var(--border-medium) 100%);
  margin: 4px 0;
  border-radius: 2px;
  min-height: 24px;
}

.algorithm-step-card:last-child .step-connecting-line {
  display: none;
}

.step-card-content {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
}

.algorithm-step-card:hover .step-card-content {
  border-color: var(--brand-primary);
  transform: translateX(4px);
  box-shadow: 0 6px 18px rgba(15, 118, 110, 0.1);
}

.step-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.step-number-label {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

.step-tag {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--brand-primary);
  background: var(--brand-light);
  padding: 2px 9px;
  border-radius: 99px;
  letter-spacing: 0.02em;
}

.step-tag.gold {
  color: #b45309;
  background: rgba(245, 158, 11, 0.12);
}

.step-title {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--text-heading);
  margin-bottom: 0.35rem;
}

.step-body {
  font-size: 0.92rem;
  color: var(--text-body);
  line-height: 1.55;
  margin: 0;
}

/* --- Site Footer & AI Disclaimer --- */
.site-footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-light);
  width: 100%;
  max-width: 840px;
  box-sizing: border-box;
}

.footer-container {
  width: 100%;
  margin: 0 auto;
}

.footer-brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none !important;
}

.footer-disclaimer-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 0.85rem 1.15rem;
  margin-bottom: 1.25rem;
  box-shadow: none;
}

.disclaimer-header {
  margin-bottom: 0.35rem;
}

.disclaimer-title-wrap {
  display: flex;
  align-items: center;
}

.disclaimer-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 0;
}

.disclaimer-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

.footer-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 1.25rem;
  padding-bottom: 1.5rem;
  border-top: 1px solid var(--border-light);
  font-size: 0.82rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
}

.footer-brand .brand-wiki {
  color: var(--brand-primary);
  font-size: 1.05rem;
  font-weight: 800;
}

.footer-brand .brand-vet {
  color: var(--text-heading);
  font-size: 1.05rem;
  font-weight: 800;
}

.footer-tagline {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
}

.footer-copy {
  font-size: 0.8rem;
  color: var(--text-muted);
}
