/* ---- Card CSS variables ---- */

:root {
  --card-bg: rgba(0, 0, 0, 0.03);
  --card-backdrop-blur: blur(8px);
  --card-border-radius: 16px;
  --card-hover-shadow:
    0 16px 48px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(228, 87, 46, 0.2),
    0 0 30px rgba(228, 87, 46, 0.1);
  --card-hover-border: rgba(228, 87, 46, 0.3);
  --popup-bg: linear-gradient(180deg, #2a2c35 0%, #1a1a1e 100%);
  --popup-shadow:
    0 16px 48px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(228, 87, 46, 0.2),
    0 0 40px rgba(0, 0, 0, 0.4);
  --popup-border-radius: 12px;
  --popup-z-index: 1400;
}

[data-theme="dark"] {
  --card-bg: rgba(26, 28, 37, 0.6);
  --card-backdrop-blur: blur(8px);
  --card-border-radius: 16px;
  --card-hover-shadow:
    0 16px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(228, 87, 46, 0.2),
    0 0 30px rgba(228, 87, 46, 0.1);
  --card-hover-border: rgba(228, 87, 46, 0.3);
  --popup-bg: linear-gradient(180deg, #1a1c25 0%, #0e0e12 100%);
  --popup-shadow:
    0 16px 48px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(228, 87, 46, 0.2),
    0 0 40px rgba(0, 0, 0, 0.4);
  --popup-border-radius: 12px;
  --popup-z-index: 1400;
}

/* ---- Card fadeInUp animation ---- */

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- Video card ---- */

.video-card {
  display: block;
  border-radius: var(--card-border-radius);
  overflow: hidden;
  background: var(--card-bg);
  backdrop-filter: var(--card-backdrop-blur);
  -webkit-backdrop-filter: var(--card-backdrop-blur);
  border: 1px solid var(--border-color);
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  opacity: 0;
  animation: fadeInUp 0.6s ease forwards;
}

.video-card:hover {
  transform: scale(1.04) translateY(-4px);
  box-shadow: var(--card-hover-shadow);
  border-color: var(--card-hover-border);
  text-decoration: none;
}

.video-card-thumbnail {
  position: relative;
  overflow: hidden;
}

.video-card-thumbnail img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.video-card:hover .video-card-thumbnail img {
  transform: scale(1.08);
}

.video-card-placeholder {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--primary-dark) 100%
  );
}

.video-card-placeholder-letter {
  font-size: 2.5rem;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
}

.video-card-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.video-card:hover .video-card-overlay {
  opacity: 1;
}

.video-card-overlay-label {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
}

.video-card-overlay-label svg {
  width: 14px;
  height: 14px;
}

.video-card-body {
  padding: 12px 16px;
}

.video-card-title {
  font-size: 0.95rem;
  color: var(--text-heading);
  margin: 0 0 4px 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-card-author {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.video-card-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  opacity: 0.85;
}

@supports not (backdrop-filter: blur(8px)) {
  .video-card {
    background: var(--surface-bg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .video-card {
    opacity: 1;
    animation: none;
  }

  .video-card-thumbnail img {
    transition: none;
  }

  .video-card:hover {
    transform: none;
  }

  .video-card:hover .video-card-thumbnail img {
    transform: none;
  }
}

/* ---- Video card showcase variant ---- */

.video-card--showcase {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}

.video-card--showcase .video-card-thumbnail {
  flex-shrink: 0;
  width: 280px;
}

/* biome-ignore lint/style/noDescendingSpecificity: targets a different element than the :hover card image rule, the lint only compares the trailing img */
.video-card--showcase .video-card-thumbnail img {
  height: 100%;
}

.video-card--showcase .video-card-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 16px 16px 16px 0;
  min-width: 0;
}

.video-card--showcase .video-card-title {
  font-size: 1.1rem;
  margin: 0 0 6px 0;
}

.video-card--showcase .video-card-author {
  margin-bottom: 8px;
}

.video-card-description {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- Category card (showcase style) ---- */

.category-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.category-cards-heading {
  font-size: 1.3rem;
  color: var(--text-heading);
  margin-bottom: 16px;
  font-weight: 600;
}

.category-card {
  display: block;
  border-radius: var(--card-border-radius);
  overflow: hidden;
  background: var(--card-bg);
  backdrop-filter: var(--card-backdrop-blur);
  -webkit-backdrop-filter: var(--card-backdrop-blur);
  border: 1px solid var(--border-color);
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  opacity: 0;
  animation: fadeInUp 0.6s ease forwards;
}

.category-card:hover {
  transform: scale(1.04) translateY(-4px);
  box-shadow: var(--card-hover-shadow);
  border-color: var(--card-hover-border);
  text-decoration: none;
}

/* The frame carries the ratio so every card has the same height, whatever
   the natural ratio of its image (4:3 YouTube hqdefault, article cover...) */
.category-card-thumbnail {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
}

/* biome-ignore lint/style/noDescendingSpecificity: targets a different element than the :hover card image rule, the lint only compares the trailing img */
.category-card-thumbnail img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.category-card:hover .category-card-thumbnail img {
  transform: scale(1.08);
}

.category-card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--primary-dark) 100%
  );
}

.category-card-placeholder-letter {
  font-size: 2.5rem;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
}

.category-card-logo {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.category-card-logo--initial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  color: white;
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--primary-dark) 100%
  );
}

.category-card-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
  opacity: 0;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.category-card:hover .category-card-overlay {
  opacity: 1;
}

.category-card-overlay-label {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
}

.category-card-overlay-label svg {
  width: 14px;
  height: 14px;
}

.category-card-body {
  padding: 16px;
}

.category-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-heading);
  margin: 0 0 4px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.category-card-handle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.category-card-date {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.category-card-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 500;
  line-height: 1;
  background: var(--surface-bg);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  flex-shrink: 0;
  white-space: nowrap;
}

.category-card-description {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@supports not (backdrop-filter: blur(8px)) {
  .category-card {
    background: var(--surface-bg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .category-card {
    opacity: 1;
    animation: none;
  }

  .category-card-thumbnail img {
    transition: none;
  }

  .category-card:hover {
    transform: none;
  }

  .category-card:hover .category-card-thumbnail img {
    transform: none;
  }
}

/* ---- Card hover popup ---- */

.card-hover-popup {
  position: fixed;
  z-index: var(--popup-z-index);
  border-radius: var(--popup-border-radius);
  box-shadow: var(--popup-shadow);
  background: var(--popup-bg);
  overflow: hidden;
  transform: scale(0.92);
  opacity: 0;
  transform-origin: center center;
  transition:
    transform 200ms cubic-bezier(0.4, 0, 0.2, 1),
    opacity 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.card-hover-popup--visible {
  transform: scale(1);
  opacity: 1;
}

.card-hover-popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: calc(var(--popup-z-index) - 1);
  opacity: 0;
  transition: opacity 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.card-hover-popup-backdrop--visible {
  opacity: 1;
}

.card-hover-popup-media {
  position: relative;
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
}

.card-hover-popup-media iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* biome-ignore lint/style/noDescendingSpecificity: targets a different element than the :hover card image rule, the lint only compares the trailing img */
.card-hover-popup-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-hover-popup-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--primary-dark) 100%
  );
}

.card-hover-popup-placeholder-letter {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.card-hover-popup-logo {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.card-hover-popup-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  cursor: pointer;
  z-index: 3;
  border: none;
  padding: 0;
  color: white;
}

.card-hover-popup-info {
  padding: 16px;
  color: white;
}

.card-hover-popup-title {
  font-weight: 600;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: white;
}

.card-hover-popup-subtitle-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-hover-popup-subtitle {
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  color: rgba(255, 255, 255, 0.7);
}

.card-hover-popup-subtitle--link {
  color: var(--primary);
  text-decoration: none;
}

.card-hover-popup-subtitle--link:hover {
  text-decoration: underline;
}

.card-hover-popup-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 500;
  line-height: 1;
  flex-shrink: 0;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.7);
}

.card-hover-popup-description {
  font-size: 0.75rem;
  opacity: 0.8;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
  color: rgba(255, 255, 255, 0.8);
}

.card-hover-popup-cta {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
}

.card-hover-popup-cta svg {
  width: 14px;
  height: 14px;
}

.card-hover-popup-cta-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.card-hover-popup-cta-button:hover {
  background: var(--primary-dark);
}


/* ---- Light mode (default) ---- */

:root {
  --secondary-header-height: 44px;
  --primary: #e4572e;
  --primary-dark: #c43e1a;
  --primary-light: #f06a42;
  --bg-default: #ffffff;
  --navbar-bg: #f5f5f5;
  --sidebar-bg: #fafafa;
  --footer-bg: #f0f0f0;
  --text-primary: #333;
  --text-secondary: #666;
  --text-heading: #111;
  --border-color: rgba(0, 0, 0, 0.1);
  --surface-bg: rgba(0, 0, 0, 0.03);
  --hover-bg: rgba(0, 0, 0, 0.05);
  --active-bg: rgba(0, 0, 0, 0.08);
  --overlay-bg: rgba(0, 0, 0, 0.5);
  --input-border: rgba(0, 0, 0, 0.2);
  --input-border-hover: rgba(0, 0, 0, 0.25);
  --button-surface: rgba(0, 0, 0, 0.06);
  --button-hover: rgba(0, 0, 0, 0.1);
  --shadow-color: rgba(0, 0, 0, 0.15);
  --shadow-heavy: rgba(0, 0, 0, 0.25);
  --thumbnail-placeholder: rgba(0, 0, 0, 0.05);
  --close-btn-bg: rgba(0, 0, 0, 0.7);
}

/* ---- Dark mode ---- */

[data-theme="dark"] {
  --bg-default: #0e0e12;
  --navbar-bg: #1a1a2e;
  --sidebar-bg: #141424;
  --footer-bg: #111;
  --text-primary: #e0e0e0;
  --text-secondary: #999;
  --text-heading: #fff;
  --border-color: rgba(255, 255, 255, 0.06);
  --surface-bg: rgba(255, 255, 255, 0.03);
  --hover-bg: rgba(255, 255, 255, 0.05);
  --active-bg: rgba(255, 255, 255, 0.1);
  --overlay-bg: rgba(0, 0, 0, 0.7);
  --input-border: rgba(255, 255, 255, 0.2);
  --input-border-hover: rgba(255, 255, 255, 0.25);
  --button-surface: rgba(255, 255, 255, 0.03);
  --button-hover: rgba(255, 255, 255, 0.1);
  --shadow-color: rgba(0, 0, 0, 0.4);
  --shadow-heavy: rgba(0, 0, 0, 0.4);
  --thumbnail-placeholder: rgba(255, 255, 255, 0.05);
  --close-btn-bg: rgba(0, 0, 0, 0.7);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
  background: var(--bg-default);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
}

/* ---- Document page ---- */

.document-page {
  max-width: 800px;
}

.document-title-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.document-title {
  font-size: 1.8rem;
  color: var(--text-heading);
  margin-bottom: 12px;
  line-height: 1.3;
  flex: 1;
}

.add-to-collection-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
  font-size: 0.8rem;
  white-space: nowrap;
}

.add-to-collection-btn:hover {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
  opacity: 0.85;
}

.add-to-collection-label {
  line-height: 1;
}

.document-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.document-meta a {
  color: var(--primary);
}

.document-description {
  font-family: "Literata", Georgia, "Times New Roman", serif;
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.7;
  margin-bottom: 24px;
  letter-spacing: 0.01em;
}

.blog-article-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--primary);
  font-size: 0.9rem;
  text-decoration: none;
}

.blog-article-link:hover {
  text-decoration: underline;
}

.document-header-row {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
  align-items: flex-start;
}

.document-thumbnail {
  flex: 0 0 25%;
  max-width: 25%;
  border-radius: 12px;
  overflow: hidden;
}

.document-thumbnail img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.document-intro-quote {
  font-family: "Literata", Georgia, "Times New Roman", serif;
  border-left: 3px solid var(--primary);
  padding: 16px 20px;
  margin: 0 0 32px 0;
  color: var(--text-secondary);
  font-style: italic;
  font-size: 1.05rem;
  line-height: 1.75;
  background: var(--surface-bg);
  border-radius: 0 8px 8px 0;
  letter-spacing: 0.01em;
}

/* ---- Table of contents ---- */

.document-toc {
  margin-bottom: 32px;
  padding: 16px 20px;
  background: var(--surface-bg);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.document-toc-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 12px;
}

.document-toc-list {
  list-style: decimal;
  padding-left: 20px;
  margin: 0;
}

.document-toc-list li {
  margin-bottom: 6px;
}

.document-toc-link {
  color: var(--primary);
  text-decoration: none;
  font-size: 0.92rem;
  line-height: 1.5;
}

.document-toc-link:hover {
  text-decoration: underline;
}

/* ---- Prev/Next navigation ---- */

.document-prev-next {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.document-prev-next-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--primary);
  text-decoration: none;
  font-size: 0.9rem;
  max-width: 45%;
}

.document-prev-next-link:hover {
  text-decoration: underline;
}

.document-prev-next-link.next {
  margin-left: auto;
  text-align: right;
}

.document-prev-next-arrow {
  flex-shrink: 0;
  font-size: 1.1rem;
}

.document-prev-next-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Related videos ---- */

.document-related {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.document-related-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 16px;
}

.document-related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.document-related-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-bg);
  border: 1px solid var(--border-color);
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

.document-related-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow-color);
}

.document-related-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.document-related-info {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.document-related-card-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-heading);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.document-related-card-author {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* ---- Category stats ---- */

.category-stats {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-bottom: 24px;
}

/* ---- Chapters list ---- */

.chapters-container {
  margin: 32px 0;
  border-radius: 12px;
  background: var(--surface-bg);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.chapters-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  border-bottom: 1px solid var(--border-color);
}

.chapters-count {
  font-family: "Literata", Georgia, "Times New Roman", serif;
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
  font-style: italic;
  letter-spacing: 0.02em;
}

.chapters-list {
  list-style: none;
  margin: 0;
  padding: 8px 0;
}

.chapter-item {
  padding: 10px 20px;
  margin: 0 8px;
  border-radius: 8px;
  scroll-margin-top: calc(var(--secondary-header-height) + 60px + 16px);
}

.chapter-row {
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  border-radius: 8px;
  margin: -6px -10px;
  padding: 6px 10px;
  transition: background 0.2s ease;
}

.chapter-row:hover {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.chapter-title {
  flex: 1;
  font-family: "Literata", Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.chapter-timestamp {
  font-family: "Roboto Mono", monospace;
  font-size: 0.72rem;
  color: var(--text-secondary);
  flex-shrink: 0;
  opacity: 0.8;
}

.chapter-play-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--primary-dark) 100%
  );
  color: white;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
  font-size: 12px;
}

.chapter-play-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 10px var(--shadow-color);
}

.chapter-sections {
  padding-left: 20px;
  padding-right: 16px;
  margin-top: 12px;
  border-left: 2px solid color-mix(in srgb, var(--primary) 20%, transparent);
  margin-left: 14px;
}

.chapter-section {
  margin: 12px 0;
}

.chapter-section:last-child {
  margin-bottom: 16px;
}

.section-label {
  font-family: "Literata", Georgia, "Times New Roman", serif;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.01em;
}

.section-content {
  font-family: "Literata", Georgia, "Times New Roman", serif;
  font-size: 0.95rem;
  color: var(--text-secondary);
  white-space: pre-wrap;
  margin-top: 6px;
  line-height: 1.7;
  letter-spacing: 0.01em;
}

/* ---- Source block (non-YouTube documents) ---- */

.document-source {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 28px 0;
  padding: 14px 18px;
  border-radius: 12px;
  background: var(--surface-bg);
  border: 1px solid var(--border-color);
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.document-source-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
}

.document-source-label {
  font-family: "Literata", Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.02em;
}

.document-source-link,
.document-source-author a {
  color: var(--text-primary);
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--primary) 40%, transparent);
}

.document-source-link:hover,
.document-source-author a:hover {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.document-source-credit {
  font-family: "Literata", Georgia, "Times New Roman", serif;
  font-style: italic;
  margin: 0;
  line-height: 1.6;
}

.document-source-cta {
  align-self: flex-start;
  color: var(--primary);
  font-weight: 500;
  text-decoration: none;
}

.document-source-cta:hover {
  text-decoration: underline;
}

/* ---- Audio documents ---- */

.document-audio {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0 24px;
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--surface-bg);
}

.document-audio-label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.document-audio-player {
  width: 100%;
}

/* ---- Static chapter rows and figures (textual sources) ---- */

.chapter-row--static {
  cursor: default;
}

.chapter-row--static:hover {
  background: transparent;
}

.chapter-source-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: var(--text-secondary);
  text-decoration: none;
  border: 1px solid var(--border-color);
  flex-shrink: 0;
  transition:
    color 0.2s ease,
    border-color 0.2s ease;
}

.chapter-source-link:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.section-figures {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 12px;
}

.section-figure {
  margin: 0;
  padding: 12px;
  border-radius: 10px;
  background: var(--surface-bg);
  border: 1px solid var(--border-color);
}

.section-figure-link {
  display: block;
}

.section-figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.section-figure-caption {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
  font-family: "Literata", Georgia, "Times New Roman", serif;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.section-figure-credit {
  font-size: 0.78rem;
  opacity: 0.85;
}

.section-figure-transcript {
  margin-top: 10px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.section-figure-transcript summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 500;
  list-style-position: inside;
}

.section-figure-transcript-text {
  font-family: "Literata", Georgia, "Times New Roman", serif;
  white-space: pre-wrap;
  margin: 8px 0 0 0;
  line-height: 1.7;
}

/* ---- Further reading ---- */

.document-resources {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.document-resources-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 14px;
}

.document-resources-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.document-resource {
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--surface-bg);
  border: 1px solid var(--border-color);
}

.document-resource-link {
  color: var(--text-primary);
  font-weight: 500;
  text-decoration: none;
  line-height: 1.5;
}

.document-resource-link:hover {
  color: var(--primary);
}

.document-resource-host {
  display: inline-block;
  margin-left: 8px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  opacity: 0.85;
}

.document-resource-description {
  margin: 6px 0 0 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.document-related-thumb--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--primary-dark) 100%
  );
}

.search-thumbnail-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--primary-dark) 100%
  );
}

.search-video-card-thumbnail .search-thumbnail-placeholder {
  width: 100%;
  height: 112px;
  border-radius: 8px;
  font-size: 2rem;
}

/* ---- Mobile master-detail transition ---- */

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

@keyframes mobileSlideInFromLeft {
  from {
    transform: translateX(-30%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.mobile-slide-forward,
.mobile-slide-back {
  will-change: transform, opacity;
}

/* ---- Category page ---- */

.category-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
}

.category-header-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.category-header-breadcrumb a {
  text-decoration: none;
  transition: color 0.2s;
}

.category-header-brand {
  color: var(--text-secondary);
}

.category-header-brand:hover {
  color: var(--text-primary);
}

.category-header-sep {
  color: var(--text-secondary);
  user-select: none;
}

.category-header-handle {
  color: var(--primary);
  font-weight: 600;
}

.category-header-handle:hover {
  text-decoration: underline;
}

.category-title {
  font-size: 1.6rem;
  color: var(--text-heading);
  margin-bottom: 24px;
}

.category-header .category-title {
  margin-top: 4px;
  margin-bottom: 12px;
}

@media (prefers-reduced-motion: reduce) {
  .mobile-slide-forward,
  .mobile-slide-back {
    animation: none;
  }
}

/* ---- Welcome page ---- */

.welcome-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
}

.welcome-owner-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--border-color);
}

.welcome-header-text {
  min-width: 0;
}

.welcome-title {
  font-size: 2rem;
  color: var(--text-heading);
  margin-bottom: 4px;
}

.welcome-description {
  color: var(--text-secondary);
  font-size: 1.1rem;
  line-height: 1.6;
  margin: 0;
}

.welcome-content {
  line-height: 1.7;
  font-size: 1rem;
  margin-bottom: 24px;
}

.welcome-content h1 {
  font-size: 1.8rem;
  color: var(--text-heading);
  margin: 32px 0 12px;
}

.welcome-content h2 {
  font-size: 1.5rem;
  color: var(--text-heading);
  margin: 28px 0 10px;
}

.welcome-content h3 {
  font-size: 1.25rem;
  color: var(--text-heading);
  margin: 24px 0 8px;
}

.welcome-content p {
  margin: 0 0 16px;
}

.welcome-content ul,
.welcome-content ol {
  margin: 0 0 16px;
  padding-left: 24px;
}

.welcome-content li {
  margin-bottom: 4px;
}

.welcome-content a {
  color: var(--primary);
  text-decoration: none;
}

.welcome-content a:hover {
  text-decoration: underline;
}

.welcome-content strong {
  font-weight: 600;
  color: var(--text-heading);
}

.welcome-content code {
  background: var(--surface-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: "Roboto Mono", monospace;
}

.welcome-content pre {
  background: var(--surface-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  margin: 0 0 16px;
  overflow-x: auto;
}

.welcome-content pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

.welcome-content blockquote {
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  margin: 0 0 16px;
  color: var(--text-secondary);
  background: var(--surface-bg);
  border-radius: 0 8px 8px 0;
}

.welcome-content blockquote p:last-child {
  margin-bottom: 0;
}

.welcome-content hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 24px 0;
}

.welcome-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

/* ---- Admonitions (:::info, :::tip, etc.) ---- */

.welcome-content .admonition {
  margin: 1em 0;
  padding: 1em;
  border-left: 4px solid;
  border-radius: 4px;
}

.welcome-content .admonition-note {
  background-color: rgba(100, 100, 100, 0.15);
  border-color: #6c757d;
}

.welcome-content .admonition-tip {
  background-color: rgba(40, 167, 69, 0.15);
  border-color: #28a745;
}

.welcome-content .admonition-info {
  background-color: rgba(0, 123, 255, 0.15);
  border-color: #007bff;
}

.welcome-content .admonition-warning {
  background-color: rgba(255, 193, 7, 0.15);
  border-color: #ffc107;
}

.welcome-content .admonition-danger,
.welcome-content .admonition-caution {
  background-color: rgba(220, 53, 69, 0.15);
  border-color: #dc3545;
}

.welcome-content .admonition p:last-child {
  margin-bottom: 0;
}

.welcome-stats {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ---- Welcome banner ---- */

.welcome-banner-wrapper {
  position: relative;
  overflow: hidden;
  border-radius: 12px 12px 0 0;
  margin-bottom: 24px;
}

.welcome-banner {
  display: block;
  width: 100%;
  max-height: 300px;
  object-fit: cover;
}

.welcome-banner-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60%;
  background: linear-gradient(to top, var(--bg-default) 0%, transparent 100%);
  pointer-events: none;
}

/* ---- Sticky video player (editorial frame) ---- */

.player-frame {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  width: 580px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg-default);
  border: 1px solid rgba(108, 51, 39, 0.35);
  box-shadow:
    0 32px 72px -16px rgba(0, 0, 0, 0.55),
    0 12px 28px -8px rgba(50, 12, 0, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.04);
  font-family:
    "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  color: var(--text-primary);
  animation: player-frame-drift 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes player-frame-drift {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.player-frame-head {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 14px 12px 16px;
  background: linear-gradient(180deg, #1a1620 0%, #16131a 100%);
  border-bottom: 1px solid rgba(228, 87, 46, 0.18);
}

.player-frame-head::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(228, 87, 46, 0.55),
    transparent
  );
}

.player-frame-monogram {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--primary-dark) 100%
  );
  display: grid;
  place-items: center;
  color: #fff;
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.04em;
  box-shadow:
    0 4px 12px rgba(228, 87, 46, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.player-frame-titleblock {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}

.player-frame-eyebrow {
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--primary);
  font-weight: 600;
}

.player-frame-title {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 500;
  font-size: 14px;
  line-height: 1.2;
  color: #f0e9e2;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-frame-channel {
  font-size: 11px;
  color: #9c9098;
  font-weight: 400;
  margin-top: 2px;
}

.player-frame-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.player-frame-btn {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  color: #9c9098;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease;
}

.player-frame-btn:hover {
  background: rgba(230, 213, 208, 0.06);
  color: #f0e9e2;
  border-color: rgba(230, 213, 208, 0.08);
}

.player-frame-btn--danger:hover {
  background: rgba(228, 87, 46, 0.12);
  border-color: rgba(228, 87, 46, 0.3);
  color: var(--primary-light);
}

.player-frame-btn svg {
  width: 14px;
  height: 14px;
}

.player-frame-well {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
}

.player-frame-iframe {
  display: block;
  border: none;
  width: 100%;
  height: 100%;
}

.player-frame-timeline {
  position: relative;
  padding: 8px 14px 8px;
  background: linear-gradient(180deg, #16131a 0%, #100e14 100%);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  line-height: 1;
}

.player-frame-timeline-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 9.5px;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
  line-height: 1;
}

.player-frame-chapter {
  color: #e6d5d0;
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-size: 11.5px;
  letter-spacing: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-frame-chapter::before {
  content: "";
  width: 8px;
  height: 1px;
  background: var(--primary);
  flex: none;
}

.player-frame-chapter--empty::before {
  display: none;
}

.player-frame-time {
  font-variant-numeric: tabular-nums;
  color: #9c9098;
  font-size: 10px;
  letter-spacing: 0.05em;
}

.player-frame-timeline-bar {
  position: relative;
  height: 2px;
  background: rgba(230, 213, 208, 0.08);
  border-radius: 99px;
  overflow: visible;
}

.player-frame-progress {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--primary-dark), var(--primary));
  border-radius: 99px;
  box-shadow: 0 0 8px rgba(228, 87, 46, 0.4);
}

.player-frame-progress::after {
  content: "";
  position: absolute;
  right: -3px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  background: #fff;
  border: 1.5px solid var(--primary);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.player-frame-tick {
  position: absolute;
  top: -1.5px;
  bottom: -1.5px;
  width: 1px;
  background: rgba(230, 213, 208, 0.25);
}

.player-frame-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px 6px 14px;
  background: linear-gradient(180deg, #100e14 0%, #0c0a10 100%);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  gap: 12px;
}

.player-frame-source {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #6c636c;
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  line-height: 1;
}

.player-frame-yt-mark {
  color: #ff3333;
  flex: none;
}

.player-frame-open-yt {
  appearance: none;
  background: transparent;
  border: 1px solid rgba(230, 213, 208, 0.14);
  color: #9c9098;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 4px 8px 4px 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease;
  text-decoration: none;
  line-height: 1;
}

.player-frame-open-yt:hover {
  border-color: rgba(228, 87, 46, 0.4);
  color: #f0e9e2;
  background: rgba(228, 87, 46, 0.06);
  text-decoration: none;
}

.player-frame-open-yt svg {
  width: 11px;
  height: 11px;
}

/* ---- SearchBar ---- */

.yt-search {
  display: flex;
  align-items: center;
  height: 40px;
}

.yt-search--navbar {
  flex: 0 1 932px;
}

.yt-search--sidebar {
  width: 100%;
  height: 36px;
}

.yt-search__input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  height: 100%;
  background: transparent;
  border: 1px solid var(--input-border);
  border-right: none;
  border-radius: 20px 0 0 20px;
  padding-left: 16px;
  transition: border-color 0.2s;
}

.yt-search__input-wrapper:focus-within {
  border-color: var(--primary);
}

.yt-search__icon-left {
  display: flex;
  align-items: center;
  color: var(--text-secondary);
  margin-right: 8px;
  flex-shrink: 0;
}

.yt-search__input {
  flex: 1;
  height: 100%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
  padding: 0;
  min-width: 0;
}

.yt-search__input::placeholder {
  color: var(--text-secondary);
}

.yt-search__clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 100%;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s;
}

.yt-search__clear:hover {
  color: var(--text-primary);
}

.yt-search__button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 100%;
  background: var(--button-surface);
  border: 1px solid var(--input-border-hover);
  border-radius: 0 20px 20px 0;
  color: var(--text-primary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

.yt-search__button:hover:not(:disabled) {
  background: var(--button-hover);
}

.yt-search__button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.yt-search__spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--text-primary);
  border-right-color: transparent;
  border-radius: 50%;
  animation: yt-search-spin 0.75s linear infinite;
}

@keyframes yt-search-spin {
  to {
    transform: rotate(360deg);
  }
}

.yt-search--sidebar .yt-search__input-wrapper {
  padding-left: 12px;
  border-radius: 18px 0 0 18px;
}

.yt-search--sidebar .yt-search__button {
  width: 50px;
  border-radius: 0 18px 18px 0;
}

.yt-search--sidebar .yt-search__input {
  font-size: 14px;
}

/* ---- GlobalSearch modal ---- */

.global-search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--overlay-bg);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  z-index: 9999;
  backdrop-filter: blur(4px);
}

.global-search-dialog {
  background: var(--bg-default);
  color: var(--text-primary);
  border-radius: 16px;
  width: 90%;
  max-width: 900px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px var(--shadow-heavy);
}

.global-search-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.global-search-input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--surface-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  transition: border-color 0.2s;
}

.global-search-input-wrapper:focus-within {
  border-color: var(--primary);
}

.global-search-icon {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.global-search-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 1rem;
  outline: none;
}

.global-search-input::placeholder {
  color: var(--text-secondary);
}

.global-search-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: var(--button-hover);
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.2s;
}

.global-search-clear:hover {
  background: var(--input-border);
  color: var(--text-primary);
}

.global-search-clear svg {
  width: 14px;
  height: 14px;
}

.global-search-close {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 0.2s;
}

.global-search-close:hover {
  background: var(--button-hover);
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.global-search-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--primary);
  border-right-color: transparent;
  border-radius: 50%;
  animation: global-search-spin 0.75s linear infinite;
  flex-shrink: 0;
}

@keyframes global-search-spin {
  to {
    transform: rotate(360deg);
  }
}

.global-search-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.global-search-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.global-search-empty-icon {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--surface-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}

.global-search-empty-icon svg {
  width: 48px;
  height: 48px;
  color: var(--text-secondary);
  opacity: 0.5;
}

.global-search-empty h3 {
  margin: 0 0 8px;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.global-search-empty p {
  margin: 0;
  color: var(--text-secondary);
  max-width: 400px;
}

.global-search-section {
  margin-bottom: 32px;
}

.global-search-section-title {
  margin: 0 0 8px;
  padding-bottom: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
}

.global-search-section-count {
  margin: 0 0 16px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.global-search-site-group {
  margin-bottom: 20px;
}

.global-search-site-group:last-child {
  margin-bottom: 0;
}

.global-search-site-handle {
  margin: 0 0 8px;
  padding: 4px 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
}

.search-handle-group-videos {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 8px;
  border-left: 2px solid var(--border-color);
}

.global-search-results {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.global-search-result-card {
  display: flex;
  gap: 16px;
  padding: 12px;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.global-search-result-card:hover {
  background: var(--surface-bg);
}

.global-search-thumbnail {
  flex-shrink: 0;
  width: 200px;
  cursor: pointer;
}

.global-search-thumbnail img {
  width: 100%;
  height: 112px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--thumbnail-placeholder);
}

.global-search-author {
  display: block;
  margin-top: 4px;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.global-search-result-content {
  flex: 1;
  min-width: 0;
}

.global-search-result-title {
  margin: 0 0 8px;
  padding: 0;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-primary);
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  line-height: 1.3;
  width: 100%;
}

.global-search-result-title:hover {
  text-decoration: underline;
}

.global-search-matches {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.global-search-match {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 8px;
  border: none;
  background: transparent;
  font-family: inherit;
  color: inherit;
  text-align: left;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
  width: 100%;
}

.global-search-match:hover {
  background: var(--hover-bg);
}

.global-search-timestamp {
  flex-shrink: 0;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--primary);
  color: var(--bg-default);
  border-radius: 12px;
}

.global-search-headline {
  flex: 1;
  font-size: 0.8rem;
  color: var(--text-secondary);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.global-search-headline mark {
  background: var(--primary);
  color: var(--bg-default);
  border-radius: 3px;
  padding: 1px 4px;
  font-weight: 500;
}

.global-search-more {
  font-size: 0.75rem;
  color: var(--text-secondary);
  padding-left: 8px;
}

/* ---- Search skeleton placeholders ---- */

@keyframes global-search-shimmer {
  0% {
    background-position: -400px 0;
  }
  100% {
    background-position: 400px 0;
  }
}

.global-search-skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-bg) 25%,
    var(--hover-bg) 50%,
    var(--surface-bg) 75%
  );
  background-size: 800px 100%;
  animation: global-search-shimmer 1.5s ease-in-out infinite;
  border-radius: 6px;
}

.global-search-skeleton-card {
  pointer-events: none;
}

.global-search-skeleton-section-title {
  height: 20px;
  width: 180px;
  margin-bottom: 12px;
}

.global-search-skeleton-thumbnail {
  width: 100%;
  height: 112px;
  border-radius: 8px;
}

.global-search-skeleton-title {
  height: 16px;
  width: 75%;
  margin-bottom: 12px;
}

.global-search-skeleton-line {
  height: 12px;
  width: 100%;
}

.global-search-skeleton-line-short {
  width: 60%;
}

/* ---- Search filter bar ---- */

.global-search-filter-bar {
  padding: 0 16px;
  border-bottom: 1px solid var(--border-color);
}

/* ---- Search filter tags ---- */

.search-filter-tags {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 4px;
  scrollbar-width: none;
}

.search-filter-tags::-webkit-scrollbar {
  display: none;
}

.search-filter-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.search-filter-tag:hover {
  background: var(--hover-bg);
}

.search-filter-tag--all.search-filter-tag--active {
  background: var(--active-bg);
  color: var(--text-primary);
  border-color: var(--input-border);
  font-weight: 600;
}

.search-filter-tag--handle.search-filter-tag--active {
  background: #1a3a5c;
  color: #7db8f0;
  border-color: #2a5a8c;
}

.search-filter-tag--category.search-filter-tag--active {
  background: #3a2a1a;
  color: #f0b87d;
  border-color: #5a4a2a;
}

.search-filter-tag--video.search-filter-tag--active {
  background: #1a3a2a;
  color: #7df0a0;
  border-color: #2a5a3a;
}

.search-filter-tag--chapter.search-filter-tag--active {
  background: #3a1a3a;
  color: #d07df0;
  border-color: #5a2a5a;
}

/* ---- Search result sections ---- */

.search-result-section {
  margin-bottom: 24px;
}

.search-result-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.search-result-section-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.search-result-section-badge {
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 10px;
}

.search-result-section-badge--handle {
  background: #1a3a5c;
  color: #7db8f0;
}

.search-result-section-badge--category {
  background: #3a2a1a;
  color: #f0b87d;
}

.search-result-section-badge--video {
  background: #1a3a2a;
  color: #7df0a0;
}

.search-result-section-badge--chapter {
  background: #3a1a3a;
  color: #d07df0;
}

.search-result-section-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.search-result-section-show-more {
  margin-top: 8px;
  padding: 0;
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
}

.search-result-section-show-more:hover {
  text-decoration: underline;
}

/* ---- Search handle card ---- */

.search-handle-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}

.search-handle-card:hover {
  background: var(--hover-bg);
}

.search-handle-card-logo {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--border-color);
}

.search-handle-card-logo-placeholder {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a3a5c;
  color: #7db8f0;
  font-weight: 700;
  font-size: 1.1rem;
}

.search-handle-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.search-handle-card-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-handle-card-handle {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.search-handle-card-badge {
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 12px;
  background: var(--surface-bg);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  white-space: nowrap;
}

/* ---- Search category card ---- */

.search-category-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}

.search-category-card:hover {
  background: var(--hover-bg);
}

.search-category-card-thumbnail {
  width: 64px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--thumbnail-placeholder);
}

.search-category-card-thumbnail-placeholder {
  width: 64px;
  height: 36px;
  border-radius: 6px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #3a2a1a;
  color: #f0b87d;
  font-weight: 600;
  font-size: 0.8rem;
}

.search-category-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.search-category-card-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-category-card-handle {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.search-category-card-badge {
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 12px;
  background: var(--surface-bg);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  white-space: nowrap;
}

/* ---- Search video card ---- */

.search-video-card {
  display: flex;
  gap: 16px;
  padding: 12px;
  border-radius: 8px;
  transition: background 0.15s;
}

.search-video-card:hover {
  background: var(--hover-bg);
}

.search-video-card-thumbnail {
  flex-shrink: 0;
  width: 200px;
  cursor: pointer;
}

.search-video-card-thumbnail img {
  width: 100%;
  height: 112px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--thumbnail-placeholder);
}

.search-video-card-author {
  display: block;
  margin-top: 4px;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.search-video-card-content {
  flex: 1;
  min-width: 0;
}

.search-video-card-title {
  margin: 0 0 8px;
  padding: 0;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-primary);
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  line-height: 1.3;
  width: 100%;
}

.search-video-card-title:hover {
  text-decoration: underline;
}

.search-video-card-matches {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ---- Search chapter card ---- */

.search-chapter-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  border: none;
  background: transparent;
  font-family: inherit;
  color: inherit;
  text-align: left;
  width: 100%;
}

.search-chapter-card:hover {
  background: var(--hover-bg);
}

.search-chapter-card-thumbnail {
  flex-shrink: 0;
  width: 80px;
  height: 45px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--thumbnail-placeholder);
}

.search-chapter-card-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.search-chapter-card-top-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.search-chapter-card-headline {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-chapter-card-headline mark {
  background: var(--primary);
  color: var(--bg-default);
  border-radius: 3px;
  padding: 1px 4px;
  font-weight: 500;
}

.search-chapter-card-meta {
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  opacity: 0.7;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-chapter-card-handle {
  margin-left: 4px;
}

/* ---- User menu ---- */

.user-menu-container {
  position: relative;
  display: flex;
  align-items: center;
}

.user-menu-avatar-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 50%;
  transition: opacity 0.2s;
}

.user-menu-avatar-btn:hover {
  opacity: 0.85;
}

.user-menu-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.user-menu-avatar-large {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chip-premium {
  background: linear-gradient(135deg, #ffd700, #ffaa00);
  color: #1a1a1a;
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 260px;
  background: var(--sidebar-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 8px 24px var(--shadow-heavy);
  z-index: 200;
  overflow: hidden;
}

.user-menu-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.user-menu-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.user-menu-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-heading);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-email {
  font-size: 0.75rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  color: var(--text-primary);
  text-decoration: none;
  transition: background 0.15s;
  font-size: 0.9rem;
}

.user-menu-item:hover {
  background: var(--hover-bg);
  text-decoration: none;
}

.user-menu-item-primary {
  color: var(--primary);
  font-weight: 500;
}

.user-menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: 0;
}

.user-menu-legal {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 0.75rem;
}

.user-menu-legal a {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  text-decoration: none;
}

.user-menu-legal a:hover {
  color: var(--text-primary);
  text-decoration: none;
}

.user-menu-legal-separator {
  color: var(--text-secondary);
}

.user-menu-version {
  text-align: center;
  padding: 8px 16px;
  font-size: 0.7rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-color);
}

.user-menu-signin-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: opacity 0.2s;
  white-space: nowrap;
}

.user-menu-signin-btn:hover {
  opacity: 0.85;
}

.user-menu-signup-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  margin-left: 8px;
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition:
    background 0.2s,
    opacity 0.2s;
  white-space: nowrap;
}

.user-menu-signup-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  opacity: 0.9;
}

.user-menu-item-logout,
.user-menu-item-signin {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.9rem;
  text-align: left;
  transition: background 0.15s;
}

.user-menu-item-logout:hover,
.user-menu-item-signin:hover {
  background: var(--hover-bg);
}

.user-menu-item-signin {
  color: var(--primary);
  font-weight: 500;
}

/* ---- Theme toggle ---- */

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

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

.theme-toggle svg {
  width: 20px;
  height: 20px;
  transition: transform 0.3s ease;
}

/* ---- Navbar logo ---- */

.navbar-logo {
  color: var(--primary);
  font-weight: 800;
  font-size: 1.3rem;
  text-decoration: none;
  letter-spacing: -0.5px;
}

.navbar-logo:hover {
  text-decoration: none;
  opacity: 0.85;
}

/* ---- Sidebar animations ---- */

@keyframes sidebarFadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sidebar-category-header {
  transition: background-color 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 6px;
  margin: 0 4px;
}

.sidebar-category-header:hover {
  background: var(--hover-bg);
}

.sidebar-category-header--active {
  background: var(--active-bg);
  border-left: 3px solid var(--primary);
}

.sidebar-doc-item {
  transition:
    background-color 0.25s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 6px;
  margin: 0 4px;
}

.sidebar-doc-item--active {
  background: var(--active-bg);
  border-left: 3px solid var(--primary);
}

.sidebar-doc-item:hover {
  background: var(--hover-bg);
  transform: translateX(2px);
}

.sidebar-doc-item:active {
  transform: scale(0.99);
}

.sidebar-doc-item img {
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-doc-item:hover img {
  transform: scale(1.03);
}

.sidebar-fade-in-up {
  animation: sidebarFadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.sidebar-collapse {
  overflow: hidden;
  transition:
    max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: max-height, opacity;
}

.sidebar-collapse--expanded {
  opacity: 1;
}

.sidebar-collapse--collapsed {
  opacity: 0;
  pointer-events: none;
}

/* ---- Sidebar resize & toggle ---- */

.sidebar {
  transition:
    width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar--collapsed {
  transition:
    width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-resize-handle {
  width: 6px;
  cursor: col-resize;
  position: relative;
  flex-shrink: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-resize-handle::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -3px;
  right: -3px;
}

.sidebar-resize-handle-line {
  width: 2px;
  height: 100%;
  background: var(--border-color);
  transition:
    background 0.2s,
    width 0.2s;
  border-radius: 1px;
}

.sidebar-resize-handle:hover .sidebar-resize-handle-line,
.sidebar-resize-handle:active .sidebar-resize-handle-line {
  width: 4px;
  background: var(--primary);
}

.sidebar-toggle-btn {
  position: sticky;
  top: 112px;
  z-index: 11;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: 7px;
  background: var(--sidebar-bg);
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  margin-left: -14px;
  margin-right: -14px;
  align-self: flex-start;
  transition:
    color 0.25s,
    background 0.25s,
    border-color 0.25s,
    box-shadow 0.25s;
}

.sidebar-toggle-btn:hover {
  color: var(--text-primary);
  background: var(--hover-bg);
  border-color: var(--text-secondary);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.06);
}

/* ---- Ad unit ---- */

.ad-banner-container {
  margin: 16px 0;
}

/* ---- Navbar sticky container ---- */

.navbar-sticky-container {
  position: sticky;
  top: 0;
  z-index: 100;
}

/* ---- Navbar search panel (mobile slide-down) ---- */

.navbar-search-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  background: var(--navbar-bg);
  border-bottom: 1px solid transparent;
}

.navbar-search-panel--open {
  max-height: 60px;
  border-bottom-color: var(--border-color);
}

.navbar-search-panel-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 10px;
}

.navbar-search-panel-inner .yt-search {
  flex: 1;
  height: 36px;
}

.navbar-search-panel-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.navbar-search-panel-close:hover {
  color: var(--text-primary);
  background: var(--hover-bg);
}

/* ---- Navbar search trigger (mobile) ---- */

.navbar-search-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.navbar-search-trigger:hover {
  color: var(--text-primary);
  background: var(--hover-bg);
  border-color: var(--text-secondary);
}

.navbar-search-trigger svg {
  width: 20px;
  height: 20px;
}

/* ---- Secondary header ---- */

.secondary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--secondary-header-height);
  padding: 0 24px;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 60px;
  z-index: 99;
}

.secondary-header-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex-shrink: 0;
}

.secondary-header-brand {
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s;
}

.secondary-header-brand:hover {
  color: var(--text-primary);
  text-decoration: none;
}

.secondary-header-sep {
  color: var(--text-secondary);
  font-size: 0.85rem;
  user-select: none;
}

.secondary-header-handle {
  color: var(--primary);
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: none;
  white-space: nowrap;
}

.secondary-header-handle:hover {
  text-decoration: underline;
}

.secondary-header-avatar-link {
  display: flex;
  align-items: center;
}

.secondary-header-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

.secondary-header-search-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
  margin-left: 4px;
}

.secondary-header-search-toggle:hover {
  color: var(--text-primary);
  background: var(--hover-bg);
  border-color: var(--text-secondary);
}

.secondary-header-inline-search {
  display: flex;
  align-items: center;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  transition:
    max-width 0.3s ease,
    opacity 0.3s ease;
}

.secondary-header-inline-search--open {
  max-width: 220px;
  opacity: 1;
}

.secondary-header-inline-search-input {
  width: 180px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  background: var(--surface-bg);
  color: var(--text-primary);
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.2s;
}

.secondary-header-inline-search-input:focus {
  border-color: var(--primary);
}

.secondary-header-inline-search-input::placeholder {
  color: var(--text-secondary);
}

.secondary-header-inline-search-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  margin-left: 2px;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.secondary-header-inline-search-close:hover {
  color: var(--text-primary);
  background: var(--hover-bg);
}

.secondary-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-left: auto;
}

.secondary-header-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.secondary-header-thumbnail {
  width: 40px;
  height: 22px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}

.secondary-header-breadcrumb-segment {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.secondary-header-breadcrumb-current {
  color: var(--text-primary);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

.secondary-header-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.secondary-header-back-btn:hover {
  color: var(--text-primary);
  background: var(--hover-bg);
}

/* ---- Category picker popup ---- */

.category-picker-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}

.category-picker-popup {
  background: var(--bg-default);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 90%;
  max-width: 400px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px var(--shadow-heavy);
  overflow: hidden;
}

.category-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.category-picker-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-heading);
}

.category-picker-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.category-picker-close:hover {
  color: var(--text-primary);
  background: var(--hover-bg);
}

.category-picker-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.category-picker-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 0;
}

.category-picker-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--primary);
  border-right-color: transparent;
  border-radius: 50%;
  animation: category-picker-spin 0.75s linear infinite;
}

@keyframes category-picker-spin {
  to {
    transform: rotate(360deg);
  }
}

.category-picker-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  padding: 16px 0;
  color: var(--primary);
}

.category-picker-retry-btn {
  padding: 6px 16px;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.category-picker-retry-btn:hover {
  background: var(--hover-bg);
  border-color: var(--primary);
  color: var(--primary);
}

.category-picker-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 0;
  text-align: center;
  color: var(--text-primary);
}

.category-picker-checkmark {
  animation: category-picker-pop 0.4s ease;
}

.category-picker-checkmark svg {
  color: #4caf50;
}

@keyframes category-picker-pop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  60% {
    transform: scale(1.2);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

.category-picker-empty {
  text-align: center;
  padding: 24px 0;
  color: var(--text-secondary);
}

.category-picker-dashboard-link {
  display: inline-block;
  margin-top: 8px;
  padding: 8px 16px;
  background: var(--primary);
  color: #fff;
  border-radius: 20px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: opacity 0.2s;
}

.category-picker-dashboard-link:hover {
  opacity: 0.85;
  text-decoration: none;
}

.category-picker-exists-notice {
  margin: 0 0 12px;
  padding: 8px 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  text-align: center;
}

.category-picker-label {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.category-picker-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.category-picker-item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.category-picker-item:hover {
  background: var(--hover-bg);
  border-color: var(--primary);
  color: var(--text-heading);
}

.category-picker-item--nested {
  font-size: 0.85rem;
  opacity: 0.9;
  border-style: dashed;
}

/* ---- Responsive ---- */

@media (max-width: 996px) {
  .yt-search--navbar {
    flex: 0 1 400px;
  }
}

@media (max-width: 899px) {
  .secondary-header {
    padding: 0 12px;
    gap: 8px;
  }

  .secondary-header-search-toggle,
  .secondary-header-inline-search {
    display: none;
  }

  .add-to-collection-label {
    display: none;
  }

  .secondary-header-thumbnail {
    width: 32px;
    height: 18px;
  }

  .secondary-header-breadcrumb-segment {
    font-size: 0.75rem;
  }

  .navbar {
    height: 60px;
    padding: 0 16px;
  }

  .navbar h1 {
    flex: 1;
    min-width: 0;
    overflow: hidden;
  }

  .user-menu-signin-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
  }

  .user-menu-signin-btn span {
    display: none;
  }

  .document-header-row {
    flex-direction: column;
  }

  .document-thumbnail {
    flex: none;
    max-width: 100%;
  }

  .player-frame {
    bottom: 10px;
    right: 10px;
    left: 10px;
    width: auto;
  }

  .video-card:hover {
    transform: scale(1.02) translateY(-2px);
  }

  .video-card:hover .video-card-thumbnail img {
    transform: scale(1.04);
  }

  .category-cards-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
    gap: 12px;
  }

  .category-card:hover {
    transform: scale(1.02) translateY(-2px);
  }

  .category-card:hover .category-card-thumbnail img {
    transform: scale(1.04);
  }

  .global-search-overlay {
    padding-top: 5vh;
  }

  .global-search-dialog {
    width: 95%;
    max-height: 90vh;
  }

  .global-search-result-card {
    flex-direction: column;
    gap: 12px;
  }

  .global-search-thumbnail {
    width: 100%;
  }

  /* biome-ignore lint/style/noDescendingSpecificity: targets a different element than the :hover card image rule, the lint only compares the trailing img */
  .global-search-thumbnail img {
    height: 180px;
  }

  .search-video-card {
    flex-direction: column;
    gap: 12px;
  }

  .search-video-card-thumbnail {
    width: 100%;
  }

  /* biome-ignore lint/style/noDescendingSpecificity: targets a different element than the :hover card image rule, the lint only compares the trailing img */
  .search-video-card-thumbnail img {
    height: 180px;
  }

  .search-chapter-card-thumbnail {
    width: 60px;
    height: 34px;
  }

  .search-handle-group-videos {
    padding-left: 4px;
  }

  .welcome-banner {
    max-height: 180px;
  }

  .welcome-owner-avatar {
    width: 60px;
    height: 60px;
  }

  .video-card--showcase {
    flex-direction: column;
    gap: 0;
  }

  .video-card--showcase .video-card-thumbnail {
    width: 100%;
  }

  .video-card--showcase .video-card-body {
    padding: 12px 16px;
  }

  .sidebar-resize-handle {
    display: none;
  }

  .sidebar-toggle-btn {
    display: none;
  }

  .main {
    padding: 8px;
  }

  .document-page {
    max-width: 100%;
  }

  /* Mobile screen container */
  .mobile-screen {
    width: 100%;
    overflow-y: auto;
    height: calc(100vh - 104px);
  }

  /* Hide sidebar on mobile — desktop only component */
  .sidebar,
  .sidebar-resize-handle,
  .sidebar-toggle-btn {
    display: none;
  }

  .chapter-title {
    white-space: normal;
  }

  .chapter-play-btn {
    width: 44px;
    height: 44px;
    font-size: 16px;
  }

  .chapter-row {
    gap: 10px;
    padding: 8px 4px;
    margin: -8px -4px;
  }

  .chapter-item {
    padding: 12px 8px;
  }

  .document-intro-quote {
    padding: 12px 14px;
  }

  .document-related-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
  }

  .document-prev-next {
    margin-top: 24px;
    padding-top: 16px;
  }

  .document-prev-next-link {
    font-size: 0.82rem;
  }

  .mobile-slide-forward {
    animation: mobileSlideInFromRight 300ms cubic-bezier(0.4, 0, 0.2, 1) both;
  }

  .mobile-slide-back {
    animation: mobileSlideInFromLeft 300ms cubic-bezier(0.4, 0, 0.2, 1) both;
  }

  .mobile-category-view {
    padding: 8px;
  }

  .document-title-row .document-title {
    display: none;
  }

  .category-picker-popup {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
    height: 100%;
  }

  .secondary-header--mobile {
    flex-direction: column;
    height: auto;
    padding: 6px 12px;
    gap: 4px;
  }

  .secondary-header-mobile-row1 {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
  }

  .secondary-header-local-search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
    margin-left: auto;
    transition: all 0.2s ease;
  }

  .secondary-header-local-search-btn:hover {
    color: var(--text-primary);
    background: var(--hover-bg);
    border-color: var(--text-secondary);
  }

  .secondary-header-mobile-row2 {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    min-width: 0;
  }

  .mobile-category-empty {
    color: var(--text-secondary);
    padding: 16px 0;
    font-size: 0.9rem;
  }
}

:root {
  --primary: #e5c185;
  --primary-dark: #d4a968;
  --primary-light: #ebd0a0;
  --bg-default: #fbf2c4;
}

[data-theme='dark'] {
  --bg-default: #1a1a2e;
}