/* GCSE Revision Hub - Subject Page Styles */
/* Shared styles for physics, chemistry, biology, history pages */

/* Page layout */
.subject-page {
  min-height: 100vh;
}

/* Main header */
.main-header {
  padding: var(--space-xl) var(--space-lg);
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.main-header h1 {
  font-size: var(--font-2xl);
  font-weight: 700;
  margin-bottom: var(--space-xs);
  color: var(--text-primary);
}

.main-header p {
  color: var(--text-muted);
  font-size: var(--font-base);
  margin: 0;
}

/* Footer and button styles are now in components.css */

/* Add padding to page content so it's not hidden behind fixed footer */
.page-wrapper {
  padding-bottom: 56px;
}

.back-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-sm);
}

.back-link:hover {
  color: var(--accent-hover);
}

.controls-bar {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* Hide unused elements */
.nav-tip,
.search-box,
.topic-emoji,
.sidebar-emoji,
.nav-emoji {
  display: none;
}

/* Sidebar Progress Bar (Premium Feature) */
.sidebar-progress {
  padding: var(--space-md);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: var(--radius-xs);
  overflow: hidden;
  margin-bottom: var(--space-sm);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--gradient-accent);
  border-radius: var(--radius-xs);
  transition: width var(--transition-normal);
}

.progress-text {
  font-size: var(--font-xs);
  color: var(--text-muted);
  text-align: center;
}

/* Viewed topic indicator in sidebar */
.sidebar-link.topic-viewed {
  color: var(--text-muted);
}

.topic-check {
  color: var(--success);
  margin-left: auto;
  font-weight: bold;
  font-size: var(--font-xs);
}

/* ==================== */
/* TOPIC COMPLETE CHECKBOX */
/* ==================== */

/* Container at bottom of topic */
.mark-complete-container {
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border);
  text-align: center;
}

/* The checkbox wrapper */
.topic-complete-checkbox {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* The checkbox box */
.checkbox-box {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-sm);
  font-weight: bold;
  color: transparent;
  background: var(--bg-card);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.topic-complete-checkbox:hover .checkbox-box {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.1);
}

.topic-complete-checkbox.checked .checkbox-box {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.topic-complete-checkbox.checked:hover .checkbox-box {
  background: #16a34a;
  border-color: #16a34a;
}

/* Label text (footer only) */
.checkbox-label {
  font-size: var(--font-base);
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.topic-complete-checkbox:hover .checkbox-label {
  color: var(--accent);
}

.topic-complete-checkbox.checked .checkbox-label {
  color: var(--success);
}

/* Header checkbox specific styles */
.topic-complete-checkbox[data-position="header"] {
  margin-left: auto;
  margin-right: var(--space-md);
}

.topic-complete-checkbox[data-position="header"] .checkbox-box {
  width: 22px;
  height: 22px;
  font-size: var(--font-xs);
}

/* Footer checkbox specific styles */
.topic-complete-checkbox[data-position="footer"] {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-card);
  min-height: var(--touch-target-min);
}

.topic-complete-checkbox[data-position="footer"]:hover {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.05);
}

.topic-complete-checkbox[data-position="footer"].checked {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.1);
}

/* ==================== */
/* CONFIDENCE STARS */
/* ==================== */

/* Compact stars in topic header */
.confidence-stars-compact {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  margin-right: var(--space-sm);
}

.confidence-stars-compact .star {
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-fast), transform var(--transition-fast);
  min-width: 20px;
  min-height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.confidence-stars-compact .star:hover {
  transform: scale(1.2);
}

.confidence-stars-compact .star.filled,
.confidence-stars-compact .star.hover {
  color: #f59e0b;
}

/* Full confidence rating section in footer */
.confidence-rating {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

.confidence-label {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  font-weight: 500;
}

.confidence-stars {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.confidence-stars .star {
  font-size: 28px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-fast), transform var(--transition-fast);
  min-width: var(--touch-target-min);
  min-height: var(--touch-target-min);
  display: flex;
  align-items: center;
  justify-content: center;
}

.confidence-stars .star:hover {
  transform: scale(1.15);
}

.confidence-stars .star.filled,
.confidence-stars .star.hover {
  color: #f59e0b;
}

.confidence-hint {
  font-size: var(--font-xs);
  color: var(--text-muted);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .confidence-stars-compact .star {
    font-size: 12px;
    min-width: 18px;
    min-height: 18px;
  }

  .confidence-stars .star {
    font-size: 24px;
  }
}

/* ============================================
   PURE CSS THEME TOGGLE (no JavaScript)
   ============================================ */

#theme-toggle {
  display: none;
}

.controls-bar {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle-label {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  height: 28px;
}

.theme-toggle-label:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Show "Light" by default (dark mode), hide "Dark" */
.dark-icon { display: inline; }
.light-icon { display: none; }

/* When checked (light mode), show "Dark", hide "Light" */
body:has(#theme-toggle:checked) .dark-icon { display: none; }
body:has(#theme-toggle:checked) .light-icon { display: inline; }

/* ============================================
   PURE CSS SIDEBAR TOGGLE (no JavaScript)
   ============================================ */

/* Hidden checkbox for sidebar state */
#sidebar-toggle {
  display: none;
}

/* When checkbox is checked, show sidebar */
#sidebar-toggle:checked ~ .page-wrapper .sidebar {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

#sidebar-toggle:checked ~ .page-wrapper .sidebar-overlay {
  opacity: 1;
  visibility: visible;
}

/* SVG Icons - inline SVGs use currentColor for theme support */
.icon {
  width: 18px;
  height: 18px;
  vertical-align: middle;
  color: currentColor;
}

/* For any remaining img-based icons (like close button) */
img.icon {
  opacity: 0.7;
  /* Dark mode (default): invert black SVGs to white */
  filter: invert(1);
}

img.icon:hover {
  opacity: 1;
}

/* Light mode: don't invert img icons */
body:has(#theme-toggle:checked) img.icon {
  filter: invert(0);
}

/* Menu button styling */
.menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  min-height: var(--touch-target-min);
  min-width: var(--touch-target-min);
  color: var(--text-primary);
  cursor: pointer;
}

.menu-btn:hover {
  background: var(--bg-hover);
}

.menu-btn .icon {
  color: currentColor;
  opacity: 1;
}

/* Close button as label */
.sidebar-close {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: var(--font-lg);
  cursor: pointer;
  padding: var(--space-xs);
}

.sidebar-close:hover {
  color: var(--text-primary);
}

/* Overlay closes sidebar when clicked */
.sidebar-overlay {
  position: fixed;
  top: 48px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 150;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

/* Container */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: var(--space-lg);
  width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}

/* Stats bar */
.stats-bar {
  display: flex;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
  flex-wrap: wrap;
}

.stat-item {
  text-align: center;
}

.stat-number,
.stat-value {
  font-size: var(--font-xl);
  font-weight: 700;
  color: var(--accent);
  /* Reset gradient text */
  background: none;
  -webkit-background-clip: unset;
  -webkit-text-fill-color: var(--accent);
  background-clip: unset;
}

.stat-label {
  font-size: var(--font-xs);
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Units */
details.unit {
  margin: var(--space-lg) 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  overflow: hidden;
  max-width: 100%;
  box-sizing: border-box;
}

details.unit > summary {
  padding: var(--space-md) var(--space-lg);
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

details.unit > summary::-webkit-details-marker {
  display: none;
}

details.unit > summary:hover {
  background: var(--bg-hover);
}

details.unit > summary h2 {
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

details.unit > summary p {
  font-size: var(--font-sm);
  color: var(--text-muted);
}

details.unit .unit-chevron {
  font-size: var(--font-base);
  color: var(--text-muted);
  transition: transform var(--transition-fast);
}

details.unit[open] .unit-chevron {
  transform: rotate(180deg);
}

details.unit[open] > summary {
  border-bottom: 1px solid var(--border);
}

details.unit > .unit-content {
  padding: var(--space-md);
  overflow: hidden;
  max-width: 100%;
  box-sizing: border-box;
}

/* Override all unit color classes to monochrome */
.unit-energy, .unit-particle, .unit-electricity, .unit-forces,
.unit-waves, .unit-magnetism, .unit-atomic,
details.unit[class*="unit-"] {
  background: var(--bg-card) !important;
  border-color: var(--border) !important;
  border-left-width: 1px !important;
}

.unit-energy h2, .unit-particle h2, .unit-electricity h2, .unit-forces h2,
.unit-waves h2, .unit-magnetism h2, .unit-atomic h2 {
  color: var(--text-primary) !important;
}

/* Section headers */
.section-header {
  margin: var(--space-xl) 0 var(--space-lg);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.section-header h2 {
  color: var(--text-primary);
  font-size: var(--font-lg);
  font-weight: 600;
}

/* Topics */
details.topic {
  background: transparent !important;
  border-radius: 0 !important;
  margin: 0;
  border: none !important;
  border-bottom: 1px solid var(--border) !important;
  overflow: hidden;
  box-shadow: none !important;
  max-width: 100%;
  box-sizing: border-box;
}

details.topic summary,
summary.topic-header {
  display: flex;
  align-items: center;
  padding: var(--space-md);
  cursor: pointer;
  gap: var(--space-md);
  list-style: none;
  filter: none !important;
}

details.topic summary::-webkit-details-marker,
summary.topic-header::-webkit-details-marker {
  display: none;
}

details.topic summary:hover,
summary.topic-header:hover {
  background: var(--bg-hover);
}

.topic-number {
  display: none;
}

.topic-info {
  flex: 1;
}

.topic-title {
  font-size: var(--font-base);
  font-weight: 600;
  margin-bottom: var(--space-xs);
  color: var(--text-primary) !important;
}

.topic-summary {
  font-size: var(--font-sm);
  color: var(--text-muted);
  opacity: 1 !important;
}

.topic-meta {
  display: none;
}

.chevron {
  color: var(--text-muted) !important;
  transition: transform var(--transition-fast);
}

details.topic[open] .chevron {
  transform: rotate(180deg);
}

details.topic[open] > summary,
details.topic[open] > summary.topic-header {
  border-bottom: 1px solid var(--border);
}

/* Override all topic color classes */
.topic-energy, .topic-particle, .topic-electricity, .topic-forces,
.topic-waves, .topic-magnetism, .topic-atomic, .topic-flash,
.topic-calc, .topic-react, .topic-elec,
details.topic[class*="topic-"] {
  background: var(--bg-card) !important;
  border-color: var(--border) !important;
}

.topic-energy .topic-title, .topic-particle .topic-title,
.topic-electricity .topic-title, .topic-forces .topic-title,
.topic-waves .topic-title, .topic-magnetism .topic-title,
.topic-atomic .topic-title, .topic-flash .topic-title,
.topic-calc .topic-title, .topic-react .topic-title,
.topic-elec .topic-title {
  color: var(--text-primary) !important;
}

.topic-content {
  padding: var(--space-md) 0;
  border: none !important;
  background: transparent !important;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}

/* Content boxes — flat design, no card containers */
.content-box {
  background: transparent;
  border-radius: 0;
  padding: 0 var(--space-md);
  margin: 0;
  border-left: none;
  max-width: 100%;
  box-sizing: border-box;
}

.content-box h4 {
  margin: var(--space-lg) 0 var(--space-sm);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
  font-size: var(--font-lg);
  font-weight: 700;
  color: var(--text-primary) !important;
}

.content-box:first-child h4 {
  border-top: none;
  margin-top: var(--space-sm);
  padding-top: 0;
}

/* Override all box color classes — flat, no card background */
.box-story, .box-deepdive, .box-facts, .box-diagram,
.box-rpa, .box-tips, .box-questions, .box-summary,
.box-equation, .box-rp, .box-common, .box-compare {
  border-color: transparent !important;
  background: transparent !important;
}

/* Coloured headings for visual variety */
.box-story h4 { color: var(--color-story, var(--text-primary)) !important; }
.box-deepdive h4 { color: var(--color-deepdive, var(--text-primary)) !important; }
.box-facts h4 { color: var(--color-facts, var(--text-primary)) !important; }
.box-tips h4 { color: var(--color-tips, var(--text-primary)) !important; }
.box-questions h4 { color: var(--color-questions, var(--text-primary)) !important; }
.box-diagram h4, .box-rpa h4, .box-summary h4,
.box-equation h4, .box-rp h4, .box-common h4, .box-compare h4 {
  color: var(--text-primary) !important;
}

.story-hook {
  color: var(--text-secondary);
  line-height: 1.8;
}

/* Paragraphs and lists */
.para {
  margin: var(--space-sm) 0;
  color: var(--text-secondary);
}

.fact-list {
  margin: var(--space-sm) 0 var(--space-sm) var(--space-lg);
}

.fact-list li {
  margin: var(--space-xs) 0;
  color: var(--text-secondary);
}

.highlight {
  background: rgba(59, 130, 246, 0.2);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--accent);
}

/* Equations */
.equation {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin: var(--space-md) 0;
  text-align: center;
}

.equation-label {
  font-size: var(--font-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.equation-formula {
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--accent) !important;
  font-family: var(--font-mono);
  /* Reset gradient */
  background: none !important;
  -webkit-background-clip: unset !important;
  -webkit-text-fill-color: var(--accent) !important;
}

.equation-meaning {
  font-size: var(--font-sm);
  color: var(--text-muted) !important;
  margin-top: var(--space-xs);
}

/* Tables */
.units-table,
table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  margin: var(--space-md) 0;
  font-size: var(--font-sm);
  table-layout: fixed;
  word-wrap: break-word;
}

.units-table th,
table th {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.units-table td,
table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

/* Analogies */
.analogy {
  background: var(--bg-hover) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin: var(--space-sm) 0;
}

.analogy-title {
  font-weight: 600;
  color: var(--accent);
  margin-bottom: var(--space-xs);
}

/* Video Embeds */
.topic-video {
  margin: var(--space-lg) 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.topic-video h4 {
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
  font-size: var(--font-base);
}

.video-container {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  height: 0;
  overflow: hidden;
  border-radius: var(--radius-sm);
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: var(--radius-sm);
}

.video-credit {
  margin-top: var(--space-sm);
  font-size: var(--font-xs);
  color: var(--text-muted);
}

/* Video Link - compact inline style */
.video-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: var(--font-sm);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  transition: background 0.2s, border-color 0.2s;
}

.video-link:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
}

.video-link::before {
  content: "▶";
  color: #ef4444;
  font-size: 0.85em;
}

/* Topic video container */
.topic-video {
  margin-bottom: var(--space-md);
}

/* Diagrams */
.diagram-box {
  background: var(--bg-card) !important;
  border: 1px dashed var(--border) !important;
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin: var(--space-sm) auto;
  font-family: var(--font-mono);
  white-space: pre;
  overflow-x: auto;
  font-size: var(--font-xs);
  line-height: 1.4;
  color: var(--text-secondary) !important;
  max-width: 800px;
}

.diagram-box img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* Questions */
details.question {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-md);
  margin: var(--space-sm) 0;
}

details.question summary {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-md);
  cursor: pointer;
  color: var(--text-primary) !important;
  list-style: none;
}

details.question summary::-webkit-details-marker {
  display: none;
}

details.question summary:hover {
  background: var(--bg-hover);
}

.q-label {
  background: var(--accent);
  color: white;
  padding: 2px var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: var(--font-xs);
  font-weight: 600;
  white-space: nowrap;
}

.answer-box {
  background: var(--bg-secondary) !important;
  padding: var(--space-md);
  border-top: 1px solid var(--border) !important;
}

.working-step {
  color: var(--text-secondary) !important;
  line-height: 1.9;
  margin: var(--space-xs) 0;
}

.mark-point {
  background: var(--success);
  color: white !important;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: var(--font-xs);
  font-weight: 600;
  margin-left: var(--space-xs);
}

/* Flashcards */
details.flashcard {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-md);
  margin: var(--space-xs) 0;
}

details.flashcard summary {
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  color: var(--text-primary) !important;
  font-weight: 500;
  list-style: none;
}

details.flashcard summary::-webkit-details-marker {
  display: none;
}

details.flashcard summary:hover {
  background: var(--bg-hover);
}

.flash-a {
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-secondary) !important;
  color: var(--text-secondary) !important;
  border-top: 1px solid var(--border) !important;
}

/* Footer */
.footer {
  text-align: center;
  padding: var(--space-xl) var(--space-lg);
  margin-top: var(--space-xl);
  border-top: 1px solid var(--border);
  background: transparent !important;
}

.footer p {
  color: var(--text-muted);
}

/* Sidebar - floating with fade */
.sidebar {
  position: fixed;
  top: 60px;
  left: 12px;
  width: 280px;
  max-height: calc(100vh - 72px);
  background: var(--bg-secondary);
  z-index: 200;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  /* Fade animation */
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: opacity var(--transition-normal), visibility var(--transition-normal), transform var(--transition-normal);
}

.sidebar-header {
  display: flex;
  flex-direction: column;
  padding: var(--space-xl) var(--space-md) var(--space-md) var(--space-md);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-secondary);
}

.sidebar-header h2 {
  color: var(--text-primary);
  font-weight: 600;
  font-size: var(--font-base);
}

.sidebar-header p {
  color: var(--text-muted);
  font-size: var(--font-xs);
}

details.sidebar-section {
  border-bottom: 1px solid var(--border);
}

details.sidebar-section > summary {
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

details.sidebar-section > summary::-webkit-details-marker {
  display: none;
}

details.sidebar-section > summary:hover {
  background: var(--bg-hover);
}

.sidebar-section-title {
  color: var(--text-muted);
  font-size: var(--font-xs);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-section-title a {
  color: var(--text-muted);
  text-decoration: none;
}

.sidebar-section-title a:hover {
  color: var(--accent);
}

.sidebar-chevron {
  color: var(--text-muted);
  font-size: var(--font-sm);
  transition: transform var(--transition-fast);
}

details.sidebar-section[open] .sidebar-chevron {
  transform: rotate(180deg);
}

.sidebar-links {
  padding: 0 var(--space-md) var(--space-sm);
}

.sidebar-link {
  display: block;
  padding: var(--space-xs) var(--space-sm);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-sm);
  margin: 2px 0;
}

.sidebar-link:hover {
  background: var(--bg-hover);
  color: var(--accent);
}

/* Responsive */
@media (max-width: 768px) {
  .sticky-nav {
    padding: var(--space-sm) var(--space-md);
  }

  .menu-btn {
    display: block;
  }

  .container {
    padding: var(--space-md);
  }

  .stats-bar {
    gap: var(--space-md);
  }

  .main-header h1 {
    font-size: var(--font-xl);
  }

  .diagram-box {
    font-size: var(--font-xs);
  }
}

/* ==================== */
/* SIDEBAR SEARCH */
/* ==================== */

.sidebar-search {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
}

#topic-search {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-primary);
  font-size: var(--font-sm);
  transition: border-color var(--transition-fast);
}

#topic-search:focus {
  outline: none;
  border-color: var(--accent);
}

#topic-search::placeholder {
  color: var(--text-muted);
}

/* ==================== */
/* POSITION INDICATOR */
/* ==================== */

.sidebar-position {
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border);
  font-size: var(--font-xs);
}

.position-current {
  font-weight: 600;
  color: var(--accent);
}

.position-unit {
  color: var(--text-muted);
  margin-top: 2px;
}

/* ==================== */
/* ACTIVE SIDEBAR LINK */
/* ==================== */

.sidebar-link.active {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
  font-weight: 500;
}

/* ==================== */
/* PRINT STYLES */
/* ==================== */

@media print {
  .sticky-nav,
  .sidebar,
  .sidebar-overlay,
  .menu-btn {
    display: none !important;
  }

  .container {
    max-width: none;
    padding: 0;
  }

  details.unit,
  details.topic,
  details.question,
  details.flashcard {
    display: block !important;
  }

  details.unit[open],
  details.topic[open],
  details.question[open],
  details.flashcard[open] {
    break-inside: avoid;
  }
}
