/* ============================================================
   Clases Particulares — Main Stylesheet
   A polished educational platform with warm earth tones.
   ============================================================ */

/* ────────────────────────────────────────────────────────────
   0. CSS Custom Properties
   ──────────────────────────────────────────────────────────── */

:root {
  /* Light mode palette */
  --bg-primary: #faf8f5;
  --bg-secondary: #f0ebe4;
  --bg-tertiary: #e8e0d5;
  --text-primary: #2c2418;
  --text-secondary: #5c4f3d;
  --text-muted: #8a7e6b;
  --accent-primary: #8b5e3c;
  --accent-secondary: #4a7c59;
  --accent-gold: #b8943e;
  --border: #d4cbb8;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(44, 36, 24, 0.06);
  --shadow-md: 0 4px 12px rgba(44, 36, 24, 0.08);
  --shadow-lg: 0 8px 28px rgba(44, 36, 24, 0.12);
  --shadow-xl: 0 16px 48px rgba(44, 36, 24, 0.14);

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 999px;

  /* Layout */
  --top-bar-h: 56px;
  --sidebar-w: 280px;
  --content-max-w: 760px;
  --tab-bar-h: 44px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
  --transition-sidebar: 250ms ease;
}

[data-theme="dark"] {
  --bg-primary: #1a1814;
  --bg-secondary: #242019;
  --bg-tertiary: #2e2a22;
  --text-primary: #e8e0d0;
  --text-secondary: #b8ad9a;
  --text-muted: #7a7060;
  --accent-primary: #c4845c;
  --accent-secondary: #6aad7b;
  --accent-gold: #d4a84a;
  --border: #3a352c;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.35);
}

/* ────────────────────────────────────────────────────────────
   1. Reset & Base
   ──────────────────────────────────────────────────────────── */

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

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

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-secondary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background-color var(--transition-slow),
              color var(--transition-slow);
}

img,
svg {
  display: block;
  max-width: 100%;
}

/* Timeline SVG must NOT be constrained — it scrolls horizontally */
.timeline-container svg {
  max-width: none;
}

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

a:hover {
  color: var(--accent-secondary);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

code,
pre,
kbd {
  font-family: 'JetBrains Mono', Consolas, 'Courier New', monospace;
}

/* ────────────────────────────────────────────────────────────
   2. Accessibility
   ──────────────────────────────────────────────────────────── */

.skip-to-content {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: 9999;
  padding: 12px 24px;
  background: var(--accent-primary);
  color: #fff;
  font-weight: 600;
  border-radius: var(--radius-md);
}

.skip-to-content:focus {
  position: fixed;
  top: 8px;
  left: 8px;
  width: auto;
  height: auto;
  overflow: visible;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ────────────────────────────────────────────────────────────
   3. Top Bar
   ──────────────────────────────────────────────────────────── */

.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--top-bar-h);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg-primary) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: background-color var(--transition-slow),
              border-color var(--transition-slow);
}

.top-bar__left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.top-bar__hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  transition: background-color var(--transition-fast);
}

.top-bar__hamburger:hover {
  background-color: var(--bg-tertiary);
}

.top-bar__hamburger svg {
  width: 20px;
  height: 20px;
  color: var(--text-primary);
}

.top-bar__logo {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  transition: color var(--transition-slow);
}

.top-bar__logo span {
  color: var(--accent-primary);
}

.top-bar__center {
  flex: 1;
  max-width: 420px;
  margin: 0 24px;
}

.top-bar__search {
  position: relative;
  width: 100%;
}

.top-bar__search-input {
  width: 100%;
  height: 36px;
  padding: 0 36px 0 36px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: border-color var(--transition-fast),
              background-color var(--transition-slow),
              box-shadow var(--transition-fast);
}

.top-bar__search-input::placeholder {
  color: var(--text-muted);
}

.top-bar__search-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-primary) 15%, transparent);
}

.top-bar__search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.top-bar__search-shortcut {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  pointer-events: none;
}

.top-bar__right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.top-bar__icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: background-color var(--transition-fast),
              color var(--transition-fast);
}

.top-bar__icon-btn:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.top-bar__icon-btn svg {
  width: 18px;
  height: 18px;
}

.top-bar__mobile-search {
  display: none;
}

/* ────────────────────────────────────────────────────────────
   4. Sidebar
   ──────────────────────────────────────────────────────────── */

.sidebar {
  position: fixed;
  top: var(--top-bar-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 90;
  display: flex;
  flex-direction: column;
  transition: width var(--transition-sidebar),
              transform var(--transition-sidebar),
              background-color var(--transition-slow),
              border-color var(--transition-slow);
}

/* Sidebar collapse toggle button */
.sidebar-toggle {
  position: fixed;
  top: calc(var(--top-bar-h) + 12px);
  left: calc(var(--sidebar-w) - 14px);
  z-index: 95;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: left var(--transition-sidebar),
              background-color var(--transition-slow),
              border-color var(--transition-slow),
              transform var(--transition-fast);
}

.sidebar-toggle:hover {
  background: var(--bg-tertiary);
  transform: scale(1.1);
}

.sidebar-toggle svg {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  transition: transform var(--transition-sidebar);
}

/* Collapsed state */
body.sidebar-collapsed .sidebar {
  width: 0;
  overflow: hidden;
}

body.sidebar-collapsed .sidebar-toggle {
  left: 8px;
}

body.sidebar-collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

body.sidebar-collapsed .main {
  margin-left: 0;
}

.sidebar__header {
  padding: 20px 16px 12px;
  font-family: 'Lora', Georgia, serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar__class-list {
  list-style: none;
  flex: 1;
  padding: 0 8px;
}

.sidebar__class-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background-color var(--transition-fast),
              border-color var(--transition-fast);
}

.sidebar__class-item:hover {
  background-color: var(--bg-tertiary);
}

.sidebar__class-item.is-active {
  background-color: var(--bg-tertiary);
  border-left-color: var(--accent-primary);
}

.sidebar__class-item.is-coming-soon {
  opacity: 0.5;
  cursor: default;
}

.sidebar__class-item.is-coming-soon:hover {
  background-color: transparent;
}

.sidebar__class-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  background: var(--accent-primary);
}

.sidebar__class-item:nth-child(3n+2) .sidebar__class-badge {
  background: var(--accent-secondary);
}

.sidebar__class-item:nth-child(3n) .sidebar__class-badge {
  background: var(--accent-gold);
}

.sidebar__class-info {
  flex: 1;
  min-width: 0;
}

.sidebar__class-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--transition-slow);
}

.sidebar__class-period {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.sidebar__class-check {
  width: 18px;
  height: 18px;
  color: var(--accent-secondary);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.sidebar__class-item.is-studied .sidebar__class-check {
  opacity: 1;
}

.sidebar__divider {
  height: 1px;
  margin: 12px 16px;
  background: var(--border);
  transition: background-color var(--transition-slow);
}

.sidebar__resources {
  padding: 8px;
  margin-top: auto;
}

.sidebar__resources-header {
  padding: 8px 12px 8px;
  font-family: 'Lora', Georgia, serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar__resource-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: background-color var(--transition-fast),
              color var(--transition-fast);
}

.sidebar__resource-item:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.sidebar__resource-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-muted);
}

/* Sidebar overlay backdrop (mobile) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 85;
  opacity: 0;
  transition: opacity var(--transition-sidebar);
}

.sidebar-backdrop.is-visible {
  display: block;
  opacity: 1;
}

/* ────────────────────────────────────────────────────────────
   5. Main Content Area
   ──────────────────────────────────────────────────────────── */

.main {
  margin-left: var(--sidebar-w);
  padding-top: var(--top-bar-h);
  min-height: 100vh;
  transition: margin-left var(--transition-sidebar);
}

.main__inner {
  max-width: var(--content-max-w);
  margin: 0 auto;
  padding: 40px 32px 80px;
}

/* Content container — provides readable line width and padding */
#content,
.content {
  max-width: var(--content-max-w);
  margin: 0 auto;
  padding: 40px 36px 80px;
}

/* ────────────────────────────────────────────────────────────
   6. Landing Page
   ──────────────────────────────────────────────────────────── */

.landing__hero {
  text-align: center;
  padding: 48px 0 40px;
}

.landing__title {
  font-family: 'Lora', Georgia, serif;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
  transition: color var(--transition-slow);
}

.landing__subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.6;
}

/* Progress bar */
.landing__progress {
  max-width: 400px;
  margin: 28px auto 0;
}

.landing__progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.landing__progress-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-pill);
  overflow: hidden;
  transition: background-color var(--transition-slow);
}

.landing__progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-gold), var(--accent-primary));
  border-radius: var(--radius-pill);
  transition: width 600ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Class card grid */
.landing__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 40px;
}

.class-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-base),
              box-shadow var(--transition-base),
              background-color var(--transition-slow),
              border-color var(--transition-slow);
}

.class-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.class-card.is-coming-soon {
  opacity: 0.5;
  cursor: default;
}

.class-card.is-coming-soon:hover {
  transform: none;
  box-shadow: none;
}

.class-card__badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-family: 'Lora', Georgia, serif;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent-primary);
  margin-bottom: 14px;
}

.class-card:nth-child(3n+2) .class-card__badge {
  background: var(--accent-secondary);
}

.class-card:nth-child(3n) .class-card__badge {
  background: var(--accent-gold);
}

.class-card__title {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.35;
  transition: color var(--transition-slow);
}

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

.class-card__status {
  position: absolute;
  top: 16px;
  right: 16px;
}

.class-card__status-icon {
  width: 22px;
  height: 22px;
}

.class-card__status-icon--studied {
  color: var(--accent-secondary);
}

.class-card__status-icon--coming-soon {
  color: var(--text-muted);
}

/* ────────────────────────────────────────────────────────────
   7. Class Page
   ──────────────────────────────────────────────────────────── */

.class-page__header {
  padding: 32px 0 24px;
}

.class-page__number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-family: 'Lora', Georgia, serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent-primary);
  margin-bottom: 16px;
}

.class-page__title {
  font-family: 'Lora', Georgia, serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 6px;
  transition: color var(--transition-slow);
}

.class-page__period {
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* Tab bar */
.tab-bar {
  height: var(--tab-bar-h);
  border-bottom: 1px solid var(--border);
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  gap: 2px;
  position: sticky;
  top: var(--top-bar-h);
  background: var(--bg-primary);
  z-index: 50;
  transition: background-color var(--transition-slow),
              border-color var(--transition-slow);
}

.tab-bar::-webkit-scrollbar {
  display: none;
}

.tab-bar__item {
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color var(--transition-fast),
              border-color var(--transition-fast),
              background-color var(--transition-fast);
}

.tab-bar__item:hover {
  color: var(--text-primary);
  background-color: var(--bg-secondary);
}

.tab-bar__item.is-active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
  background-color: color-mix(in srgb, var(--accent-primary) 6%, transparent);
}

/* Tab content */
.tab-content {
  padding-top: 28px;
  animation: fadeIn var(--transition-base) ease;
}

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

/* ────────────────────────────────────────────────────────────
   8. Content Typography
   ──────────────────────────────────────────────────────────── */

.content h1 {
  font-family: 'Lora', Georgia, serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.35;
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  transition: color var(--transition-slow),
              border-color var(--transition-slow);
}

.content h2 {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  margin-top: 56px;
  margin-bottom: 24px;
  padding-left: 16px;
  border-left: 4px solid var(--accent-primary);
  transition: color var(--transition-slow),
              border-color var(--transition-slow);
}

.content h3 {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  margin-top: 44px;
  margin-bottom: 18px;
  transition: color var(--transition-slow);
}

.content h4 {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 32px;
  margin-bottom: 14px;
}

.content p {
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--text-secondary);
  margin-bottom: 22px;
  transition: color var(--transition-slow);
}

.content strong {
  color: var(--text-primary);
  font-weight: 600;
  transition: color var(--transition-slow);
}

.content em {
  font-style: italic;
}

.content blockquote {
  margin: 32px 0;
  padding: 20px 24px;
  border-left: 4px solid var(--accent-primary);
  background: var(--bg-secondary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.8;
  transition: background-color var(--transition-slow),
              border-color var(--transition-slow);
}

.content blockquote p {
  margin-bottom: 8px;
}

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

.content blockquote cite {
  display: block;
  margin-top: 8px;
  font-size: 0.875rem;
  font-style: normal;
  font-weight: 500;
  color: var(--text-muted);
}

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

.content ul {
  list-style: none;
}

.content ul li {
  position: relative;
  padding-left: 10px;
  margin-bottom: 14px;
  line-height: 1.8;
}

.content ul li::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 0.65em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-primary);
}

.content ol {
  list-style: none;
  counter-reset: ordered-list;
}

.content ol li {
  counter-increment: ordered-list;
  position: relative;
  padding-left: 10px;
  margin-bottom: 14px;
  line-height: 1.8;
}

.content ol li::before {
  content: counter(ordered-list) '.';
  position: absolute;
  left: -24px;
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--accent-primary);
}

.content hr {
  border: none;
  height: 1px;
  margin: 48px 0;
  background: linear-gradient(
    90deg,
    transparent,
    var(--border) 20%,
    var(--border) 80%,
    transparent
  );
}

.content code {
  font-size: 0.875em;
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--accent-primary);
  transition: background-color var(--transition-slow);
}

.content pre {
  margin: 20px 0;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  transition: background-color var(--transition-slow),
              border-color var(--transition-slow);
}

.content pre code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* Tables */
.content .table-wrapper {
  margin: 32px 0;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  transition: border-color var(--transition-slow);
}

.content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.925rem;
}

.content thead {
  background: var(--bg-tertiary);
  transition: background-color var(--transition-slow);
}

.content th {
  padding: 14px 18px;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.825rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.content td {
  padding: 14px 18px;
  line-height: 1.7;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
}

.content tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--bg-secondary) 50%, transparent);
}

.content tbody tr {
  transition: background-color var(--transition-fast);
}

.content tbody tr:hover {
  background: var(--bg-tertiary);
}

/* ────────────────────────────────────────────────────────────
   9. Cross References
   ──────────────────────────────────────────────────────────── */

.cross-ref {
  color: var(--accent-primary);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color var(--transition-fast),
              background-color var(--transition-fast);
}

.cross-ref:hover {
  color: var(--accent-secondary);
  background-color: color-mix(in srgb, var(--accent-primary) 8%, transparent);
  border-radius: var(--radius-sm);
}

/* ────────────────────────────────────────────────────────────
   10. Tooltip
   ──────────────────────────────────────────────────────────── */

.tooltip {
  position: absolute;
  z-index: 200;
  max-width: 320px;
  min-width: 200px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 16px;
  pointer-events: auto;
  animation: tooltipIn var(--transition-fast) ease;
  transition: background-color var(--transition-slow),
              border-color var(--transition-slow);
}

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

.tooltip__arrow {
  position: absolute;
  top: -6px;
  left: 24px;
  width: 12px;
  height: 12px;
  background: var(--bg-primary);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  transform: rotate(45deg);
  transition: background-color var(--transition-slow),
              border-color var(--transition-slow);
}

.tooltip__title {
  font-family: 'Lora', Georgia, serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.tooltip__body {
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

.tooltip__link {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-primary);
}

/* ────────────────────────────────────────────────────────────
   11. Search Dropdown
   ──────────────────────────────────────────────────────────── */

.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 400px;
  overflow-y: auto;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 150;
  animation: tooltipIn var(--transition-fast) ease;
  transition: background-color var(--transition-slow),
              border-color var(--transition-slow);
}

.search-dropdown__empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.search-dropdown__group-label {
  padding: 10px 16px 4px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.search-dropdown__item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.search-dropdown__item:hover,
.search-dropdown__item.is-focused {
  background-color: var(--bg-secondary);
}

.search-dropdown__item-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent-primary);
  flex-shrink: 0;
  margin-top: 2px;
}

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

.search-dropdown__item-section {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.search-dropdown__item-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.search-dropdown__item-text mark {
  background: color-mix(in srgb, var(--accent-gold) 30%, transparent);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

/* ────────────────────────────────────────────────────────────
   12. SVG Container
   ──────────────────────────────────────────────────────────── */

.svg-container {
  max-width: 100%;
  margin: 24px auto;
  padding: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  text-align: center;
  overflow: hidden;
  transition: background-color var(--transition-slow),
              border-color var(--transition-slow);
}

.svg-container svg {
  max-width: 100%;
  height: auto;
}

.svg-container__caption {
  margin-top: 12px;
  font-size: 0.825rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ────────────────────────────────────────────────────────────
   13. Coming Soon State
   ──────────────────────────────────────────────────────────── */

.coming-soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px;
  min-height: 400px;
}

.coming-soon__ornament {
  width: 64px;
  height: 64px;
  margin-bottom: 24px;
  color: var(--text-muted);
  opacity: 0.5;
}

.coming-soon__title {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  transition: color var(--transition-slow);
}

.coming-soon__period {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.coming-soon__message {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 380px;
  line-height: 1.6;
}

/* ────────────────────────────────────────────────────────────
   14. Timeline Page
   ──────────────────────────────────────────────────────────── */

.timeline-container {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  cursor: grab;
  -webkit-overflow-scrolling: touch;
  padding: 24px 0;
  position: relative;
}

.timeline-container:active {
  cursor: grabbing;
}

.timeline-container__inner {
  display: flex;
  align-items: flex-start;
  min-width: max-content;
  padding: 0 40px;
  position: relative;
}

.timeline-container__line {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--border);
}

.timeline-container__controls {
  position: sticky;
  bottom: 16px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding-top: 16px;
  z-index: 10;
}

.timeline-zoom-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  color: var(--text-primary);
  font-size: 1.15rem;
  transition: background-color var(--transition-fast),
              transform var(--transition-fast);
}

.timeline-zoom-btn:hover {
  background: var(--bg-tertiary);
  transform: scale(1.05);
}

/* ────────────────────────────────────────────────────────────
   15. Global Resources — Glossary
   ──────────────────────────────────────────────────────────── */

.glossary__nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 28px;
}

.glossary__nav-letter {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: background-color var(--transition-fast),
              color var(--transition-fast);
}

.glossary__nav-letter:hover,
.glossary__nav-letter.is-active {
  background: var(--accent-primary);
  color: #fff;
}

.glossary__nav-letter.is-empty {
  opacity: 0.35;
  pointer-events: none;
}

.glossary__section-title {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent-primary);
  margin: 28px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.glossary__entry {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 12px;
  transition: background-color var(--transition-slow),
              border-color var(--transition-slow);
}

.glossary__entry-term {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.glossary__entry-def {
  font-size: 0.925rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.glossary__entry-classes {
  margin-top: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.glossary__entry-class-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
}

/* ────────────────────────────────────────────────────────────
   16. Global Resources — Characters
   ──────────────────────────────────────────────────────────── */

.characters__list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.character-entry {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: background-color var(--transition-slow),
              border-color var(--transition-slow);
}

.character-entry__header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.character-entry__header:hover {
  background: var(--bg-tertiary);
}

.character-entry__avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Lora', Georgia, serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-primary);
  flex-shrink: 0;
  border: 2px solid var(--border);
  transition: background-color var(--transition-slow),
              border-color var(--transition-slow);
}

.character-entry__name {
  font-family: 'Lora', Georgia, serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.character-entry__dates {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.character-entry__toggle {
  margin-left: auto;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
}

.character-entry.is-expanded .character-entry__toggle {
  transform: rotate(180deg);
}

.character-entry__body {
  display: none;
  padding: 0 20px 16px;
  font-size: 0.925rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.character-entry.is-expanded .character-entry__body {
  display: block;
  animation: fadeIn var(--transition-base) ease;
}

/* ────────────────────────────────────────────────────────────
   17. Mark As Studied Button
   ──────────────────────────────────────────────────────────── */

.btn-studied {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  font-weight: 600;
  border: 2px solid var(--accent-gold);
  color: var(--accent-gold);
  background: transparent;
  margin-top: 40px;
  transition: all var(--transition-base);
}

.btn-studied:hover {
  background: color-mix(in srgb, var(--accent-gold) 10%, transparent);
}

.btn-studied svg {
  width: 18px;
  height: 18px;
}

.btn-studied.is-studied {
  background: var(--accent-gold);
  color: #fff;
  border-color: var(--accent-gold);
}

.btn-studied.is-studied:hover {
  background: color-mix(in srgb, var(--accent-gold) 85%, black);
  border-color: color-mix(in srgb, var(--accent-gold) 85%, black);
}

/* ────────────────────────────────────────────────────────────
   18. Utility Classes
   ──────────────────────────────────────────────────────────── */

.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.mt-sm  { margin-top: 8px; }
.mt-md  { margin-top: 16px; }
.mt-lg  { margin-top: 32px; }
.mb-sm  { margin-bottom: 8px; }
.mb-md  { margin-bottom: 16px; }
.mb-lg  { margin-bottom: 32px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ────────────────────────────────────────────────────────────
   19. Custom Scrollbar
   ──────────────────────────────────────────────────────────── */

/* Webkit */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
  border: 2px solid transparent;
  background-clip: padding-box;
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ────────────────────────────────────────────────────────────
   R. Renderer Markup Styles
   Styles for classes generated by renderer.js
   ──────────────────────────────────────────────────────────── */

/* --- Hamburger button (mobile) --- */
.hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  flex-direction: column;
  gap: 5px;
  transition: background-color var(--transition-fast);
}

.hamburger:hover {
  background-color: var(--bg-tertiary);
}

.hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

/* --- Logo --- */
.logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-primary), #a0782c);
  color: #fff;
  margin-right: 8px;
  vertical-align: middle;
  flex-shrink: 0;
}

.logo-icon svg {
  width: 18px;
  height: 18px;
}

.logo-text {
  vertical-align: middle;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

/* --- Search wrapper --- */
.search-wrapper {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  height: 38px;
  padding: 0 16px 0 40px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: border-color var(--transition-fast),
              background-color var(--transition-slow),
              box-shadow var(--transition-fast);
}

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

.search-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-primary) 15%, transparent);
}

.search-wrapper--focused .search-input {
  border-color: var(--accent-primary);
}

.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* --- Theme toggle icons --- */
.icon-sun,
.icon-moon {
  position: absolute;
  transition: opacity var(--transition-slow),
              transform var(--transition-slow);
}

.icon-sun {
  color: var(--accent-gold);
  opacity: 1;
  transform: rotate(0deg);
}

.icon-moon {
  color: var(--accent-gold);
  opacity: 0;
  transform: rotate(-90deg);
}

[data-theme="dark"] .icon-sun {
  opacity: 0;
  transform: rotate(90deg);
}

[data-theme="dark"] .icon-moon {
  opacity: 1;
  transform: rotate(0deg);
}

/* --- Sidebar headings and structure --- */
.sidebar__heading {
  padding: 20px 16px 10px;
  font-family: 'Lora', Georgia, serif;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

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

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background-color var(--transition-fast),
              color var(--transition-fast);
}

.sidebar__link:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.sidebar__link-icon {
  color: var(--text-muted);
  flex-shrink: 0;
  display: flex;
}

/* --- Sidebar class items (renderer-generated) --- */
.sidebar-class {
  list-style: none;
}

.sidebar-class__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border-left: 3px solid transparent;
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background-color var(--transition-fast),
              border-color var(--transition-fast),
              color var(--transition-fast);
}

.sidebar-class__link:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.sidebar-class__link--disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.sidebar-class__num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-class__title {
  flex: 1;
  min-width: 0;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-class__check {
  color: var(--accent-secondary);
  flex-shrink: 0;
}

.sidebar-class--active .sidebar-class__link {
  background-color: var(--bg-tertiary);
  border-left-color: var(--accent-primary);
}

.sidebar-class--dimmed {
  opacity: 0.4;
}

/* Sidebar resource links */
.sidebar-resource__link {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background-color var(--transition-fast),
              color var(--transition-fast);
}

.sidebar-resource__link:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.sidebar-resource__link--active {
  background-color: var(--bg-tertiary);
  color: var(--accent-primary);
  font-weight: 600;
}

/* --- Hub (full-page landing) --- */
.hub {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  padding: 40px 24px;
  position: relative;
  transition: background-color var(--transition-slow);
}

.hub__theme {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: transparent;
  border: none;
  transition: background-color var(--transition-fast);
}

.hub__theme:hover {
  background: var(--bg-tertiary);
}

.hub__hero {
  text-align: center;
  margin-bottom: 56px;
}

.hub__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--accent-primary), #a0782c);
  color: #fff;
  margin-bottom: 28px;
  box-shadow: var(--shadow-md);
}

.hub__title {
  font-family: 'Inter', sans-serif;
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin-bottom: 8px;
  border-bottom: none;
  padding-bottom: 0;
}

.hub__subtitle {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.25rem;
  font-style: italic;
  color: var(--accent-primary);
  margin-bottom: 20px;
}

.hub__desc {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto;
}

.hub__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
  max-width: 960px;
  width: 100%;
}

.hub__card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 36px 28px 28px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  text-decoration: none;
  color: var(--text-primary);
  overflow: hidden;
  transition: transform var(--transition-base),
              box-shadow var(--transition-base),
              border-color var(--transition-base);
}

.hub__card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  opacity: 0;
  transition: opacity var(--transition-base);
}

.hub__card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-xl);
}

.hub__card:hover::before {
  opacity: 1;
}

.hub__card--historia::before { background: var(--accent-primary); }
.hub__card--filosofia::before { background: var(--accent-gold); }
.hub__card--crypto::before { background: var(--accent-secondary); }

.hub__card--historia:hover { border-color: var(--accent-primary); }
.hub__card--filosofia:hover { border-color: var(--accent-gold); }
.hub__card--crypto:hover { border-color: var(--accent-secondary); }

.hub__card-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.hub__card--historia .hub__card-icon {
  background: color-mix(in srgb, var(--accent-primary) 12%, transparent);
  color: var(--accent-primary);
}

.hub__card--filosofia .hub__card-icon {
  background: color-mix(in srgb, var(--accent-gold) 12%, transparent);
  color: var(--accent-gold);
}

.hub__card--crypto .hub__card-icon {
  background: color-mix(in srgb, var(--accent-secondary) 12%, transparent);
  color: var(--accent-secondary);
}

.hub__card-title {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 10px;
  border-bottom: none;
  padding-bottom: 0;
}

.hub__card-desc {
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text-secondary);
  flex: 1;
  margin-bottom: 18px;
}

.hub__card-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: var(--radius-pill);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  align-self: flex-start;
}

.hub__footer {
  margin-top: 56px;
  font-size: 0.825rem;
  color: var(--text-muted);
}

/* Hub responsive */
@media (max-width: 860px) {
  .hub__title { font-size: 2.5rem; }
  .hub__grid { grid-template-columns: 1fr; max-width: 420px; gap: 20px; }
  .hub__hero { margin-bottom: 40px; }
}

@media (max-width: 480px) {
  .hub { padding: 32px 16px; }
  .hub__title { font-size: 2rem; }
  .hub__logo { width: 52px; height: 52px; font-size: 1.15rem; margin-bottom: 20px; }
  .hub__card { padding: 28px 22px 24px; }
}

/* --- Filosofía sidebar pillar tabs --- */
.filo-pillar-tabs {
  display: flex;
  gap: 0;
  padding: 12px 12px 0;
}

.filo-pillar-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.filo-pillar-tab:hover {
  color: var(--text-primary);
}

.filo-pillar-tab--active {
  color: var(--accent-gold);
  border-bottom-color: var(--accent-gold);
}

.filo-pillar-tab svg {
  flex-shrink: 0;
}

/* Filo sidebar items */
.filo-sidebar-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.filo-sidebar-cap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filo-sidebar-cat-header {
  padding: 12px 12px 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 6px;
  list-style: none;
}

.filo-sidebar-cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.filo-sidebar-atom {
  padding-left: 28px !important;
  font-size: 0.825rem !important;
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
}
.filo-sidebar-atom-state {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.filo-sidebar-tree-link {
  color: var(--accent-gold) !important;
  font-weight: 600 !important;
}

.sidebar__link--active {
  background: var(--bg-tertiary);
  color: var(--accent-gold) !important;
  font-weight: 600;
}

/* --- Filosofía section --- */

/* Back links */
.filo-back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 32px; font-size: 0.875rem; font-weight: 500; color: var(--text-muted); text-decoration: none; transition: color 150ms ease; }
.filo-back:hover { color: var(--accent-gold); }
.filo-back svg { flex-shrink: 0; }

/* Landing hero */
.filo-hero { text-align: center; padding-bottom: 40px; }
.filo-hero__icon { display: inline-flex; align-items: center; justify-content: center; width: 80px; height: 80px; border-radius: 50%; background: color-mix(in srgb, var(--accent-gold) 10%, transparent); color: var(--accent-gold); margin-bottom: 24px; }
.filo-hero__title { font-family: 'Lora', Georgia, serif; font-size: 2.75rem; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; border-bottom: none; padding-bottom: 0; }
.filo-hero__subtitle { font-family: 'Lora', Georgia, serif; font-size: 1.15rem; font-style: italic; color: var(--accent-gold); margin-bottom: 16px; }
.filo-hero__desc { font-size: 1rem; color: var(--text-muted); max-width: 500px; margin: 0 auto; line-height: 1.7; }

/* Mode toggle (Classic / Átomos) */
.filo-mode { display: flex; justify-content: center; gap: 4px; margin-bottom: 36px; padding: 4px; background: var(--bg-secondary); border-radius: var(--radius-pill); width: fit-content; margin-left: auto; margin-right: auto; }
.filo-mode__btn { padding: 8px 20px; border-radius: var(--radius-pill); font-size: 0.85rem; font-weight: 600; border: none; background: transparent; color: var(--text-muted); cursor: pointer; transition: all 150ms ease; }
.filo-mode__btn--active { background: var(--accent-gold); color: #fff; }

/* Chapter cards grid (classic mode) */
.filo-chapters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

.filo-chapter-card { position: relative; padding: 22px 20px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-lg); cursor: pointer; transition: transform 200ms ease, box-shadow 200ms ease, border-color 200ms ease; text-decoration: none; color: var(--text-primary); display: block; }
.filo-chapter-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--accent-gold); }
.filo-chapter-card--coming-soon { opacity: 0.5; cursor: default; }
.filo-chapter-card--coming-soon:hover { transform: none; box-shadow: none; border-color: var(--border); }

.filo-chapter-card__badge { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; font-size: 0.75rem; font-weight: 700; color: #fff; margin-bottom: 12px; }
.filo-chapter-card__title { font-family: 'Lora', Georgia, serif; font-size: 1rem; font-weight: 600; margin-bottom: 4px; border-bottom: none; padding-bottom: 0; }
.filo-chapter-card__period { font-size: 0.8rem; color: var(--text-muted); }

/* Resources row */
.filo-resources { display: flex; gap: 16px; margin-top: 40px; justify-content: center; }
.filo-resources__link { display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-pill); font-size: 0.85rem; font-weight: 500; color: var(--text-secondary); text-decoration: none; transition: border-color 150ms ease, color 150ms ease; }
.filo-resources__link:hover { border-color: var(--accent-gold); color: var(--accent-gold); }

/* Skill tree grid */
.filo-skill-tree { position: relative; }
.filo-skill-tree__filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.filo-skill-tree__filter { padding: 6px 16px; border-radius: var(--radius-pill); font-size: 0.8rem; font-weight: 500; border: 1px solid var(--border); background: var(--bg-secondary); color: var(--text-secondary); cursor: pointer; transition: all 150ms ease; }
.filo-skill-tree__filter--active { border-color: var(--accent-gold); background: var(--accent-gold); color: #fff; }

.filo-skill-tree__grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }

.filo-skill-tree__tier-label { grid-column: 1 / -1; font-family: 'Lora', Georgia, serif; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; padding: 8px 0 4px; border-bottom: 1px solid var(--border); margin-top: 8px; }

.filo-atom-node { padding: 16px; background: var(--bg-secondary); border: 2px solid var(--border); border-radius: var(--radius-lg); cursor: pointer; transition: all 200ms ease; text-align: center; }
.filo-atom-node:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.filo-atom-node--locked { opacity: 0.4; cursor: default; }
.filo-atom-node--locked:hover { transform: none; box-shadow: none; }
.filo-atom-node--available { border-color: var(--accent-gold); }
.filo-atom-node--started { border-color: var(--accent-gold); background: color-mix(in srgb, var(--accent-gold) 8%, var(--bg-secondary)); }
.filo-atom-node--mastered { border-color: var(--accent-gold); background: color-mix(in srgb, var(--accent-gold) 15%, var(--bg-secondary)); }

.filo-atom-node__dot { width: 10px; height: 10px; border-radius: 50%; margin: 0 auto 10px; }
.filo-atom-node__title { font-size: 0.825rem; font-weight: 600; color: var(--text-primary); line-height: 1.3; }
.filo-atom-node__check { color: var(--accent-gold); margin-top: 6px; }

/* Atom reader view */
.filo-atom-header { padding-bottom: 24px; }
.filo-atom-header__title { font-family: 'Lora', Georgia, serif; font-size: 2rem; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; border-bottom: none; padding-bottom: 0; }
.filo-atom-header__meta { display: flex; gap: 10px; flex-wrap: wrap; }
.filo-atom-header__badge { font-size: 0.75rem; font-weight: 600; padding: 3px 12px; border-radius: var(--radius-pill); color: #fff; }
.filo-atom-header__tier { font-size: 0.75rem; font-weight: 600; padding: 3px 12px; border-radius: var(--radius-pill); background: var(--bg-tertiary); color: var(--text-muted); }

.filo-atom-deps { margin-bottom: 24px; font-size: 0.875rem; color: var(--text-secondary); }
.filo-atom-deps__item { display: inline-flex; align-items: center; gap: 4px; margin-right: 12px; }
.filo-atom-deps__item--done { color: var(--accent-gold); }
.filo-atom-deps__item--locked { color: var(--text-muted); }

.filo-atom-tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.filo-atom-tab { padding: 10px 20px; font-size: 0.85rem; font-weight: 500; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; cursor: pointer; text-decoration: none; transition: color 150ms ease, border-color 150ms ease; }
.filo-atom-tab:hover { color: var(--text-primary); }
.filo-atom-tab--active { color: var(--accent-gold); border-bottom-color: var(--accent-gold); font-weight: 600; }
.filo-atom-tab--locked { opacity: 0.4; cursor: default; }

.filo-atom-content { min-height: 200px; padding: 24px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.filo-atom-content__empty { text-align: center; color: var(--text-muted); padding: 40px 0; font-style: italic; }

.filo-atom-complete { display: flex; justify-content: center; margin-top: 32px; }
.filo-atom-complete__btn { display: inline-flex; align-items: center; gap: 8px; padding: 12px 28px; border-radius: var(--radius-pill); font-size: 0.9rem; font-weight: 600; border: 2px solid var(--accent-gold); color: var(--accent-gold); background: transparent; cursor: pointer; transition: all 200ms ease; }
.filo-atom-complete__btn:hover { background: color-mix(in srgb, var(--accent-gold) 10%, transparent); }
.filo-atom-complete__btn--active { background: var(--accent-gold); color: #fff; }

/* Chapter view (coming soon) */
.filo-cap-header { display: flex; align-items: center; gap: 20px; padding: 32px 0 24px; }
.filo-cap-header__badge { display: flex; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: 50%; font-family: 'Lora', Georgia, serif; font-size: 1.25rem; font-weight: 700; color: #fff; flex-shrink: 0; box-shadow: var(--shadow-md); }
.filo-cap-header__title { font-family: 'Lora', Georgia, serif; font-size: 1.75rem; font-weight: 700; color: var(--text-primary); border-bottom: none; padding-bottom: 0; }
.filo-cap-header__period { font-size: 0.9rem; color: var(--text-muted); margin-top: 4px; }

/* Filo sidebar */
.filo-sidebar-section { padding: 0 8px; }
.filo-sidebar-heading { padding: 20px 16px 10px; font-family: 'Lora', Georgia, serif; font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.filo-sidebar-link { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius-md); font-size: 0.875rem; color: var(--text-secondary); text-decoration: none; transition: background-color 150ms ease, color 150ms ease; }
.filo-sidebar-link:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.filo-sidebar-link--active { background: var(--bg-tertiary); color: var(--accent-gold); font-weight: 600; }
.filo-sidebar-num { display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; font-size: 0.65rem; font-weight: 700; color: #fff; flex-shrink: 0; }

/* Responsive */
@media (max-width: 767px) {
  .filo-chapters { grid-template-columns: repeat(2, 1fr); }
  .filo-skill-tree__grid { grid-template-columns: repeat(2, 1fr); }
  .filo-hero__title { font-size: 2rem; }
  .filo-resources { flex-direction: column; align-items: center; }
  .filo-atom-header__title { font-size: 1.5rem; }
}

@media (max-width: 479px) {
  .filo-chapters { grid-template-columns: 1fr; }
  .filo-skill-tree__grid { grid-template-columns: 1fr; }
}

/* --- Landing page --- */
.landing-hero {
  text-align: center;
  padding: 56px 0 20px;
}

.landing-title {
  font-family: 'Lora', Georgia, serif;
  font-size: 2.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
  line-height: 1.2;
  border-bottom: none;
  padding-bottom: 0;
}

.landing-subtitle {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.2rem;
  font-weight: 400;
  font-style: italic;
  color: var(--accent-primary);
  margin-bottom: 16px;
}

.landing-desc {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 540px;
  margin: 0 auto;
  line-height: 1.7;
}

.landing-progress {
  max-width: 400px;
  margin: 32px auto 0;
}

.progress-label {
  font-size: 0.825rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-align: center;
}

.progress-bar-track {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-gold), var(--accent-primary));
  border-radius: var(--radius-pill);
  transition: width 600ms cubic-bezier(0.22, 1, 0.36, 1);
}

.landing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 44px;
}

/* Card state modifiers */
.class-card--coming-soon {
  opacity: 0.4;
  cursor: default;
}

.class-card--coming-soon:hover {
  transform: none;
  box-shadow: none;
}

.class-card__lock,
.class-card__check {
  position: absolute;
  top: 14px;
  right: 14px;
  color: var(--text-muted);
}

.class-card__check {
  color: var(--accent-secondary);
}

/* --- Class page header --- */
.clase-header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 36px 0 28px;
}

.clase-header__badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  font-family: 'Lora', Georgia, serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  box-shadow: var(--shadow-md);
}

.clase-header__text {
  flex: 1;
}

.clase-header__title {
  font-family: 'Lora', Georgia, serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
  margin-bottom: 4px;
  border-bottom: none;
  padding-bottom: 0;
}

.clase-header__period {
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* --- Tab bar --- */
.tabs-bar {
  border-bottom: 2px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  position: sticky;
  top: var(--top-bar-h);
  background: var(--bg-primary);
  z-index: 50;
  transition: background-color var(--transition-slow),
              border-color var(--transition-slow);
}

.tab {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  text-decoration: none;
  transition: color var(--transition-fast),
              border-color var(--transition-fast),
              background-color var(--transition-fast);
}

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

.tab--active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
  font-weight: 600;
}

/* --- Class content area --- */
.clase-content {
  padding-top: 32px;
  animation: fadeIn var(--transition-base) ease;
}

.clase-content__empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 1.05rem;
  padding: 60px 0;
}

/* Embedded SVG figures */
.clase-figure {
  margin: 36px 0;
  padding: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  text-align: center;
  overflow: hidden;
  transition: background-color var(--transition-slow),
              border-color var(--transition-slow);
}

.clase-figure svg {
  max-width: 100%;
  height: auto;
}

/* Coming soon placeholder */
.coming-soon-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 80px 24px;
  color: var(--text-muted);
}

.coming-soon-placeholder__icon {
  margin-bottom: 24px;
  opacity: 0.4;
}

.coming-soon-placeholder h2 {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: 8px;
  border-bottom: none;
  padding-bottom: 0;
}

.coming-soon-placeholder p {
  font-size: 1rem;
  color: var(--text-muted);
}

/* --- Studied toggle --- */
.studied-toggle {
  display: flex;
  justify-content: center;
  padding: 48px 0 16px;
}

.studied-toggle__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  font-weight: 600;
  border: 2px solid var(--accent-gold);
  color: var(--accent-gold);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition-base);
}

.studied-toggle__btn:hover {
  background: color-mix(in srgb, var(--accent-gold) 10%, transparent);
}

.studied-toggle__btn svg {
  width: 18px;
  height: 18px;
}

.studied-toggle__btn--active {
  background: var(--accent-gold);
  color: #fff;
  border-color: var(--accent-gold);
}

.studied-toggle__btn--active:hover {
  background: color-mix(in srgb, var(--accent-gold) 85%, black);
  border-color: color-mix(in srgb, var(--accent-gold) 85%, black);
}

/* --- Prev / Next navigation --- */
.prev-next {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 16px;
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.prev-next__link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  max-width: 48%;
  transition: background-color var(--transition-fast),
              border-color var(--transition-fast),
              transform var(--transition-fast);
}

.prev-next__link:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent-primary);
  transform: translateY(-1px);
  color: var(--text-primary);
}

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

.prev-next__arrow {
  font-size: 1.2rem;
  color: var(--accent-primary);
  flex-shrink: 0;
}

.prev-next__label {
  font-weight: 500;
  line-height: 1.3;
}

/* --- Resource pages --- */
.resource-header {
  padding: 36px 0 8px;
}

.resource-header h1 {
  font-family: 'Lora', Georgia, serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  border-bottom: none;
  padding-bottom: 0;
}

/* Filter bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0;
}

.filter-btn {
  padding: 7px 18px;
  border-radius: var(--radius-pill);
  font-size: 0.825rem;
  font-weight: 500;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.filter-btn--active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}

/* Filter search */
.filter-search {
  margin: 16px 0;
}

.filter-search__input {
  width: 100%;
  height: 42px;
  padding: 0 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  color: var(--text-primary);
  transition: border-color var(--transition-fast);
}

.filter-search__input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.filter-search__input::placeholder {
  color: var(--text-muted);
}

/* Letter navigation */
.letter-anchors {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 16px 0 24px;
}

.letter-anchor {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background-color var(--transition-fast),
              color var(--transition-fast);
}

.letter-anchor:hover {
  background: var(--accent-primary);
  color: #fff;
}

/* Glosario cards */
.glosario-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.glosario-letter {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-primary);
  margin: 32px 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

.glosario-letter:first-child {
  margin-top: 0;
}

.glosario-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  margin-bottom: 10px;
  transition: background-color var(--transition-fast),
              border-color var(--transition-fast);
}

.glosario-card:hover {
  border-color: var(--accent-primary);
}

.glosario-card__term {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 2px;
  display: inline;
}

.glosario-card__badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 10px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  margin-left: 8px;
  vertical-align: middle;
}

.glosario-card__def {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-secondary);
  margin: 10px 0 0;
}

/* Personaje cards */
.personajes-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.personaje-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 26px;
  transition: background-color var(--transition-fast),
              border-color var(--transition-fast);
}

.personaje-card:hover {
  border-color: var(--accent-primary);
}

.personaje-card__header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}

.personaje-card__name {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.personaje-card__dates {
  font-size: 0.825rem;
  color: var(--text-muted);
}

.personaje-card__who {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-secondary);
  margin: 0 0 8px;
}

.personaje-card__why {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-secondary);
  margin: 0 0 12px;
  padding-left: 14px;
  border-left: 3px solid var(--accent-gold);
  font-style: italic;
}

.personaje-card__classes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.personaje-card__class-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  transition: transform var(--transition-fast),
              box-shadow var(--transition-fast);
}

.personaje-card__class-badge:hover {
  transform: scale(1.15);
  box-shadow: var(--shadow-md);
  color: #fff;
}

.personaje-card__details {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.personaje-card__details p {
  font-size: 0.925rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.personaje-card__expand {
  display: inline-block;
  margin-top: 10px;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--accent-primary);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.personaje-card__expand:hover {
  color: var(--accent-secondary);
}

/* --- Cross-reference tooltip --- */
.crossref-tooltip {
  position: fixed;
  z-index: 300;
  max-width: 360px;
  min-width: 220px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 16px 20px;
  pointer-events: auto;
  animation: tooltipIn var(--transition-fast) ease;
  transition: background-color var(--transition-slow),
              border-color var(--transition-slow);
}

.crossref-tooltip[hidden] {
  display: none;
}

.crossref-tooltip__title {
  font-family: 'Lora', Georgia, serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-primary);
  text-decoration: none;
}

.crossref-tooltip__title:hover {
  text-decoration: underline;
}

.crossref-tooltip__badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  margin-left: 6px;
  vertical-align: middle;
}

.crossref-tooltip__dates {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: 8px;
}

.crossref-tooltip__text {
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--text-secondary);
  margin-top: 8px;
}

/* --- Error / loading / search states --- */
.error-page {
  text-align: center;
  padding: 80px 24px;
}

.error-page h2 {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: 8px;
  border-bottom: none;
}

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

.search-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
}

.search-query {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 0;
  color: var(--text-muted);
}

.loading__spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

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

/* ────────────────────────────────────────────────────────────
   R2. Typography & Visual Enhancements
   ──────────────────────────────────────────────────────────── */

/* Decorative quotation mark on blockquotes */
.content blockquote {
  position: relative;
}

.content blockquote::before {
  content: '\201C';
  position: absolute;
  left: -6px;
  top: -12px;
  font-family: 'Lora', Georgia, serif;
  font-size: 4rem;
  color: var(--accent-primary);
  opacity: 0.12;
  line-height: 1;
  pointer-events: none;
}

/* First strong in a paragraph gets accent color */
.clase-content > p > strong:first-child,
.content > p > strong:first-child {
  color: var(--accent-primary);
}

/* Better nested lists */
.content li > ul,
.content li > ol {
  margin-top: 8px;
  margin-bottom: 4px;
}

/* Section titles (h2) — add subtle background highlight */
.content h2 {
  padding: 12px 16px;
  background: color-mix(in srgb, var(--accent-primary) 4%, transparent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* ────────────────────────────────────────────────────────────
   20. Responsive — Tablet (< 1200px)
   ──────────────────────────────────────────────────────────── */

@media (max-width: 1199px) {
  :root {
    --sidebar-w: 240px;
  }

  .landing-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .landing-title {
    font-size: 2.1rem;
  }
}

/* ────────────────────────────────────────────────────────────
   21. Responsive — Mobile (< 768px)
   ──────────────────────────────────────────────────────────── */

@media (max-width: 767px) {
  :root {
    --sidebar-w: 280px;
  }

  .hamburger {
    display: flex;
  }

  .top-bar__center {
    display: none;
  }

  .sidebar-toggle {
    display: none;
  }

  /* Sidebar overlay mode */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
    z-index: 95;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
    opacity: 1;
  }

  .main {
    margin-left: 0;
  }

  #content,
  .content {
    padding: 24px 16px 48px;
  }

  .landing-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }

  .landing-hero {
    padding: 32px 0 28px;
  }

  .landing-title {
    font-size: 1.8rem;
  }

  .landing-desc {
    font-size: 0.95rem;
  }

  .prev-next {
    flex-direction: column;
  }

  .prev-next__link {
    max-width: 100%;
  }

  .class-card {
    padding: 18px 16px;
  }

  .class-card__badge {
    width: 34px;
    height: 34px;
    font-size: 0.9rem;
    margin-bottom: 10px;
  }

  .class-card__title {
    font-size: 0.95rem;
  }

  .clase-header__title {
    font-size: 1.5rem;
  }

  .clase-header__badge {
    width: 44px;
    height: 44px;
    font-size: 1.1rem;
  }

  .tabs-bar {
    margin: 0 -16px;
    padding: 0 16px;
  }

  .content h1 { font-size: 1.65rem; }
  .content h2 { font-size: 1.3rem; margin-top: 32px; }
  .content h3 { font-size: 1.15rem; }
  .content p  { font-size: 1rem; }

  .tooltip,
  .crossref-tooltip {
    max-width: calc(100vw - 32px);
    left: 16px !important;
    right: 16px !important;
  }
}

/* ────────────────────────────────────────────────────────────
   22. Responsive — Small Mobile (< 480px)
   ──────────────────────────────────────────────────────────── */

@media (max-width: 479px) {
  .class-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
  }

  .class-card__badge {
    margin-bottom: 0;
    width: 38px;
    height: 38px;
  }

  .class-card__info {
    flex: 1;
    min-width: 0;
  }

  .class-card__title {
    font-size: 0.925rem;
  }

  .tab {
    padding: 0 12px;
    font-size: 0.8rem;
  }

  .clase-header {
    padding: 24px 0 16px;
    gap: 14px;
  }

  .clase-header__badge {
    width: 38px;
    height: 38px;
    font-size: 0.95rem;
  }

  .clase-header__title {
    font-size: 1.3rem;
  }

  .landing-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .btn-studied {
    width: 100%;
    justify-content: center;
  }

  .glossary__nav-letter {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
  }

  .character-entry__header {
    padding: 12px 16px;
  }

  .character-entry__avatar {
    width: 38px;
    height: 38px;
    font-size: 0.95rem;
  }
}

/* ────────────────────────────────────────────────────────────
   23. Reduced Motion
   ──────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ────────────────────────────────────────────────────────────
   24. Print Styles
   ──────────────────────────────────────────────────────────── */

@media print {
  .top-bar,
  .sidebar,
  .sidebar-backdrop,
  .tab-bar,
  .btn-studied,
  .search-dropdown,
  .tooltip,
  .timeline-container__controls,
  .hamburger {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 12pt;
  }

  .main {
    margin-left: 0 !important;
    padding-top: 0 !important;
  }

  .main__inner {
    max-width: 100%;
    padding: 0;
  }

  .content h1,
  .content h2,
  .content h3,
  .content h4 {
    color: #000;
    page-break-after: avoid;
  }

  .content p,
  .content li {
    color: #222;
  }

  .content blockquote {
    border-left-color: #666;
    background: #f5f5f5;
  }

  .content a {
    color: #000;
    text-decoration: underline;
  }

  .content a[href]::after {
    content: ' (' attr(href) ')';
    font-size: 0.8em;
    color: #555;
  }

  .class-card,
  .glossary__entry,
  .character-entry {
    break-inside: avoid;
  }

  .landing-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ────────────────────────────────────────────────────────────
   25. Sidebar slide animation (mobile)
   ──────────────────────────────────────────────────────────── */

@media (max-width: 767px) {
  .sidebar {
    transition: transform var(--transition-sidebar),
                box-shadow var(--transition-sidebar);
  }
}

/* ────────────────────────────────────────────────────────────
   26. Selection styling
   ──────────────────────────────────────────────────────────── */

::selection {
  background: color-mix(in srgb, var(--accent-primary) 25%, transparent);
  color: var(--text-primary);
}

/* ────────────────────────────────────────────────────────────
   27. Loading / skeleton states
   ──────────────────────────────────────────────────────────── */

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent,
    color-mix(in srgb, var(--bg-primary) 50%, transparent) 50%,
    transparent
  );
  animation: shimmer 1.8s ease-in-out infinite;
}

@keyframes shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.skeleton--text {
  height: 1em;
  width: 75%;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
}

.skeleton--circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.skeleton--card {
  height: 140px;
}

/* ────────────────────────────────────────────────────────────
   28. Notification / toast (optional UX)
   ──────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  color: var(--text-primary);
  animation: toastIn 300ms ease;
}

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

.toast.is-leaving {
  animation: toastOut 200ms ease forwards;
}

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

.toast__icon {
  width: 20px;
  height: 20px;
  color: var(--accent-secondary);
  flex-shrink: 0;
}

/* ────────────────────────────────────────────────────────────
   29. Dark-mode toggle button
   ──────────────────────────────────────────────────────────── */

/* Language toggle */
.lang-toggle {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-fast);
  cursor: pointer;
  border: none;
  background: none;
}
.lang-toggle:hover {
  background-color: var(--bg-tertiary);
}
.lang-toggle__label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
}

.theme-toggle {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-fast);
}

.theme-toggle:hover {
  background-color: var(--bg-tertiary);
}

.theme-toggle__sun,
.theme-toggle__moon {
  position: absolute;
  width: 18px;
  height: 18px;
  transition: opacity var(--transition-slow),
              transform var(--transition-slow);
}

.theme-toggle__sun {
  color: var(--accent-gold);
  opacity: 1;
  transform: rotate(0deg);
}

.theme-toggle__moon {
  color: var(--accent-gold);
  opacity: 0;
  transform: rotate(-90deg);
}

[data-theme="dark"] .theme-toggle__sun {
  opacity: 0;
  transform: rotate(90deg);
}

[data-theme="dark"] .theme-toggle__moon {
  opacity: 1;
  transform: rotate(0deg);
}

/* ────────────────────────────────────────────────────────────
   30. Full-width search (mobile overlay)
   ──────────────────────────────────────────────────────────── */

.search-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg-primary);
  padding: var(--top-bar-h) 16px 16px;
  flex-direction: column;
  transition: background-color var(--transition-slow);
}

.search-overlay.is-open {
  display: flex;
  animation: fadeIn var(--transition-base) ease;
}

.search-overlay__bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.search-overlay__input {
  flex: 1;
  height: 44px;
  padding: 0 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 1rem;
  color: var(--text-primary);
}

.search-overlay__input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.search-overlay__cancel {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent-primary);
  white-space: nowrap;
}

.search-overlay__results {
  flex: 1;
  overflow-y: auto;
}
