/* Progress Bar */
#readingProgress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 4px;
  background: linear-gradient(90deg, #2dd4bf, #f59e0b);
  z-index: 9999;
  transition: width 0.1s;
}

/* Flashcard Mode */
.flashcard-mode .vocab-def {
  filter: blur(6px);
  background: #f1f5f9;
  color: transparent !important;
  cursor: pointer;
  transition: all 0.3s ease;
  user-select: none;
}
.flashcard-mode .vocab-def:hover,
.flashcard-mode .vocab-def:active {
  filter: blur(0);
  background: transparent;
  color: var(--text-muted, #475569) !important;
}

[data-theme="dark"].flashcard-mode .vocab-def {
  background: #334155;
}
[data-theme="dark"].flashcard-mode .vocab-def:hover {
  background: transparent;
}

/* Flashcard Toggle Button */
.flashcard-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1px solid #e2e8f0;
  padding: 8px 16px;
  border-radius: 99px;
  font-size: 0.9em;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  margin-left: auto; /* Push to right if in flex container */
}
.flashcard-toggle:hover {
  border-color: #22c55e;
  color: #15803d;
  background: #f0fdf4;
}
.flashcard-toggle.active {
  background: #22c55e;
  border-color: #22c55e;
  color: white;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

[data-theme="dark"] .flashcard-toggle {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}
[data-theme="dark"] .flashcard-toggle:hover {
  border-color: #2dd4bf;
  color: #2dd4bf;
  background: rgba(45, 212, 191, 0.1);
}
[data-theme="dark"] .flashcard-toggle.active {
  background: #0f766e;
  border-color: #0f766e;
  color: white;
}

/* Related Notes Section */
.related-section {
  margin-top: 80px;
  border-top: 1px dashed #e2e8f0;
  padding-top: 40px;
}
.related-title {
  font-size: 1.2em;
  font-weight: 700;
  margin-bottom: 24px;
  color: #0f172a;
}
[data-theme="dark"] .related-title {
  color: #f1f5f9;
}
[data-theme="dark"] .related-section {
  border-color: #334155;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}
.related-card {
  display: block;
  text-decoration: none;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px;
  transition: all 0.2s;
}
.related-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.1);
  border-color: #cbd5e1;
}
.related-card-title {
  font-size: 1.1em;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 8px;
  line-height: 1.3;
}
.related-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.related-tag {
  font-size: 0.75em;
  background: #f1f5f9;
  color: #64748b;
  padding: 2px 8px;
  border-radius: 99px;
}
.related-summary {
  font-size: 0.9em;
  color: #64748b;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Dark Mode for Related Cards */
[data-theme="dark"] .related-card {
  background: #1e293b;
  border-color: #334155;
}
[data-theme="dark"] .related-card:hover {
  border-color: #475569;
  background: #253045;
}
[data-theme="dark"] .related-card-title {
  color: #f1f5f9;
}
[data-theme="dark"] .related-tag {
  background: #334155;
  color: #94a3b8;
}
[data-theme="dark"] .related-summary {
  color: #94a3b8;
}

/* Floating TOC */
.toc-container {
    position: fixed;
    top: 100px;
    right: 20px;
    width: 200px;
    max-height: 80vh;
    overflow-y: auto;
    background: transparent;
    padding: 10px;
    display: none; /* Hidden by default on small screens */
    z-index: 100;
}

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

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    border-left: 2px solid #e2e8f0;
}
[data-theme="dark"] .toc-list {
    border-color: #334155;
}

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

.toc-link {
    display: block;
    padding-left: 15px;
    font-size: 0.85em;
    color: #94a3b8;
    text-decoration: none;
    transition: all 0.2s;
    line-height: 1.4;
    cursor: pointer;
    position: relative;
}

.toc-link:hover {
    color: #0f766e;
}
[data-theme="dark"] .toc-link:hover {
    color: #2dd4bf;
}

.toc-link.active {
    color: #0f766e;
    font-weight: 600;
}
[data-theme="dark"] .toc-link.active {
    color: #2dd4bf;
}

.toc-link.active::before {
    content: '';
    position: absolute;
    left: -2px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #0f766e;
}
[data-theme="dark"] .toc-link.active::before {
    background: #2dd4bf;
}
