/* ============================================================
   ISO - Implantación de Sistemas Operativos
   Apuntes Interactivos | styles.css
   ============================================================ */

/* ---------- Google Font ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---------- Variables de color ---------- */
:root {
  /* Colores claros */
  --bg-primary:      #f8f9fb;
  --bg-secondary:    #ffffff;
  --bg-card:         #ffffff;
  --bg-sidebar:      #f0f2f5;
  --bg-code:         #f3f4f6;

  --text-primary:    #1a1d23;
  --text-secondary:  #4b5563;
  --text-muted:      #9ca3af;

  --accent:          #3b82f6;
  --accent-hover:    #2563eb;
  --accent-light:    #eff6ff;
  --accent-border:   #bfdbfe;

  --success:         #10b981;
  --success-light:   #d1fae5;
  --warning:         #f59e0b;
  --warning-light:   #fef3c7;
  --danger:          #ef4444;
  --danger-light:    #fee2e2;

  --border:          #e5e7eb;
  --border-hover:    #d1d5db;
  --shadow-sm:       0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:       0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg:       0 10px 30px rgba(0,0,0,.1),  0 4px 8px rgba(0,0,0,.04);

  /* Colores de temas (bloques) */
  --block1: #3b82f6;  /* Azul - Fundamentos */
  --block2: #8b5cf6;  /* Violeta - Gestión SO */
  --block3: #10b981;  /* Verde - Instalación */
  --block4: #f59e0b;  /* Ámbar - Configuración */
  --block5: #ef4444;  /* Rojo - Administración */
  --block6: #06b6d4;  /* Cyan - Dominios */
  --block7: #ec4899;  /* Rosa - Seguridad */
}

[data-theme="dark"] {
  --bg-primary:      #0f1117;
  --bg-secondary:    #1a1d27;
  --bg-card:         #1e2130;
  --bg-sidebar:      #161923;
  --bg-code:         #252836;

  --text-primary:    #f1f5f9;
  --text-secondary:  #94a3b8;
  --text-muted:      #64748b;

  --accent:          #60a5fa;
  --accent-hover:    #93c5fd;
  --accent-light:    #1e3a5f;
  --accent-border:   #1d4ed8;

  --success:         #34d399;
  --success-light:   #064e3b;
  --warning:         #fbbf24;
  --warning-light:   #451a03;
  --danger:          #f87171;
  --danger-light:    #450a0a;

  --border:          #2d3148;
  --border-hover:    #3d4165;
  --shadow-sm:       0 1px 3px rgba(0,0,0,.3);
  --shadow-md:       0 4px 12px rgba(0,0,0,.4);
  --shadow-lg:       0 10px 30px rgba(0,0,0,.5);
}

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

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background .3s ease, color .3s ease;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ---------- Layout principal ---------- */
.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

/* ---------- Header ---------- */
.site-header {
  grid-column: 1 / -1;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
  text-decoration: none;
}

.header-brand .brand-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  color: #fff;
  flex-shrink: 0;
}

.header-brand span { display: flex; flex-direction: column; line-height: 1.2; }
.header-brand .brand-title { font-size: .95rem; font-weight: 700; }
.header-brand .brand-sub { font-size: .72rem; font-weight: 400; color: var(--text-muted); }

.header-controls {
  display: flex;
  align-items: center;
  gap: .75rem;
}

/* Barra de búsqueda en header */
.search-wrap {
  position: relative;
}

.search-input {
  width: 280px;
  padding: .45rem .9rem .45rem 2.3rem;
  border: 1px solid var(--border);
  border-radius: 9999px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: .88rem;
  font-family: inherit;
  transition: border .2s, box-shadow .2s, width .3s;
  outline: none;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  width: 340px;
}

.search-icon {
  position: absolute;
  left: .75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: .85rem;
  pointer-events: none;
}

.search-results-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  max-height: 380px;
  overflow-y: auto;
  display: none;
}

.search-results-dropdown.active { display: block; }

.search-result-item {
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-sidebar); }

.search-result-item .result-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.search-result-item .result-text .result-title {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-primary);
}

.search-result-item .result-text .result-desc {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.search-result-item mark {
  background: var(--warning-light);
  color: var(--warning);
  border-radius: 3px;
  padding: 0 2px;
}

.result-tag {
  display: inline-block;
  font-size: .7rem;
  padding: .1rem .45rem;
  border-radius: 9999px;
  background: var(--bg-sidebar);
  color: var(--text-muted);
  margin-right: .25rem;
  margin-top: .25rem;
}

.result-tag.match {
  background: var(--warning-light);
  color: var(--warning);
  font-weight: 600;
}

/* Botón toggle dark/light */
.btn-theme {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: 9999px;
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  transition: all .2s;
}

.btn-theme:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

/* Progress header badge */
.progress-badge {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8rem;
  color: var(--text-secondary);
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: .3rem .75rem;
}

.progress-badge .badge-num {
  font-weight: 700;
  color: var(--accent);
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 1rem 0;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
}

.sidebar-section {
  margin-bottom: .25rem;
}

.sidebar-label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: .75rem 1.25rem .3rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem 1.25rem;
  font-size: .87rem;
  color: var(--text-secondary);
  transition: all .15s;
  border-left: 3px solid transparent;
  text-decoration: none;
  cursor: pointer;
}

.sidebar-link:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  text-decoration: none;
  border-left-color: var(--border-hover);
}

.sidebar-link.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
  border-left-color: var(--accent);
}

.sidebar-link.completed .link-check { color: var(--success); }
.sidebar-link .link-num {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  width: 18px;
  flex-shrink: 0;
}
.sidebar-link .link-text { flex: 1; }
.sidebar-link .link-check {
  font-size: .8rem;
  color: var(--text-muted);
  transition: color .2s;
}

/* ---------- Main Content ---------- */
.main-content {
  padding: 2rem 2.5rem;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  min-width: 0; /* evita que la celda grid se expanda al ancho del contenido */
}

/* ---------- Hero (index) ---------- */
.hero {
  text-align: center;
  padding: 3rem 1rem 2.5rem;
}

.hero-title {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: .5rem;
  line-height: 1.2;
}

.hero-title span { color: var(--accent); }

.hero-subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

/* Barra de progreso global */
.global-progress {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.global-progress h3 {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.progress-track {
  height: 8px;
  background: var(--border);
  border-radius: 9999px;
  overflow: hidden;
  margin-bottom: .75rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: 9999px;
  transition: width .6s cubic-bezier(.34,1.56,.64,1);
}

.progress-stats {
  display: flex;
  gap: 1.5rem;
  font-size: .82rem;
  color: var(--text-secondary);
}

.progress-stats strong { color: var(--text-primary); font-weight: 700; }

/* ---------- Grid de temas ---------- */
.temas-section { margin-bottom: 2rem; }

.section-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.25rem;
}

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

.section-badge {
  font-size: .75rem;
  padding: .15rem .6rem;
  border-radius: 9999px;
  background: var(--bg-sidebar);
  color: var(--text-muted);
  font-weight: 500;
}

.temas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}

/* Tarjeta de tema */
.tema-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem;
  cursor: pointer;
  transition: all .2s;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  display: block;
  position: relative;
  overflow: hidden;
}

.tema-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px;
  height: 100%;
  background: var(--card-color, var(--accent));
}

.tema-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-hover);
  text-decoration: none;
}

.tema-card.done {
  border-color: var(--success-light);
}

.tema-card.done::before { background: var(--success); }

.card-num {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .4rem;
}

.card-title {
  font-size: .92rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: .5rem;
  line-height: 1.4;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin-top: .5rem;
}

.card-tag {
  font-size: .7rem;
  padding: .15rem .5rem;
  border-radius: 9999px;
  background: var(--bg-sidebar);
  color: var(--text-muted);
}

.card-status {
  position: absolute;
  top: .75rem;
  right: .75rem;
  font-size: .85rem;
}

/* ---------- Página de tema ---------- */
.tema-header {
  margin-bottom: 2rem;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.breadcrumb a { color: var(--accent); }
.breadcrumb-sep { color: var(--text-muted); }

.tema-title-block {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.tema-titulo {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.tema-subtitle {
  font-size: .95rem;
  color: var(--text-secondary);
  margin-top: .4rem;
}

.tema-meta {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.meta-chip {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .78rem;
  padding: .3rem .75rem;
  border-radius: 9999px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

/* Botón marcar completado */
.btn-complete {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem 1.1rem;
  border-radius: 9999px;
  border: 2px solid var(--success);
  background: transparent;
  color: var(--success);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all .2s;
  flex-shrink: 0;
}

.btn-complete:hover, .btn-complete.done {
  background: var(--success);
  color: #fff;
}

/* Navegación entre temas */
.tema-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.btn-nav {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem 1.2rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: .85rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all .2s;
  text-decoration: none;
}

.btn-nav:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

/* ---------- Acordeón ---------- */
.accordion { margin-bottom: 1.5rem; }

.accordion-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: .5rem;
  overflow: hidden;
  transition: box-shadow .2s;
}

.accordion-item:hover { box-shadow: var(--shadow-sm); }

.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  cursor: pointer;
  user-select: none;
  gap: .75rem;
}

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

.accordion-left {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.accordion-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.accordion-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.accordion-arrow {
  color: var(--text-muted);
  font-size: .8rem;
  transition: transform .25s;
  flex-shrink: 0;
}

.accordion-item.open .accordion-arrow { transform: rotate(180deg); }

.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height .35s cubic-bezier(.4,0,.2,1), padding .2s;
}

.accordion-item.open .accordion-body { max-height: 5000px; }

.accordion-content {
  padding: .25rem 1.25rem 1.25rem;
  color: var(--text-secondary);
  font-size: .9rem;
  line-height: 1.75;
}

.accordion-content h4 {
  font-size: .88rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 1rem 0 .4rem;
}

.accordion-content ul {
  padding-left: 1.25rem;
  margin: .4rem 0;
}

.accordion-content li { margin-bottom: .3rem; }

.accordion-content code {
  font-family: 'JetBrains Mono', monospace;
  font-size: .82rem;
  background: var(--bg-code);
  padding: .1rem .4rem;
  border-radius: 4px;
  color: var(--accent);
}

.accordion-content pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
  margin: .75rem 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: .82rem;
  line-height: 1.6;
  color: var(--text-primary);
}

.accordion-content .callout {
  border-left: 4px solid var(--accent);
  background: var(--accent-light);
  border-radius: 0 8px 8px 0;
  padding: .75rem 1rem;
  margin: .75rem 0;
  font-size: .875rem;
}

.accordion-content .callout.warning {
  border-left-color: var(--warning);
  background: var(--warning-light);
}

.accordion-content .callout.success {
  border-left-color: var(--success);
  background: var(--success-light);
}

/* ---------- Flashcards ---------- */
.flashcards-section { margin-bottom: 2rem; }

.section-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.flashcards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.flashcard {
  height: 160px;
  perspective: 1000px;
  cursor: pointer;
}

.flashcard-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform .5s cubic-bezier(.4,0,.2,1);
}

.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }

.flashcard-front, .flashcard-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 14px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.flashcard-front {
  background: var(--bg-card);
}

.flashcard-back {
  background: var(--accent);
  transform: rotateY(180deg);
  border-color: var(--accent);
}

.flashcard-front .fc-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: .5rem;
  font-weight: 600;
}

.flashcard-front .fc-term {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.flashcard-back .fc-def {
  font-size: .85rem;
  color: #fff;
  line-height: 1.5;
}

.flashcard-hint {
  font-size: .7rem;
  color: var(--text-muted);
  margin-top: .5rem;
}

.flashcard-back .flashcard-hint { color: rgba(255,255,255,.6); }

/* ---------- Quiz ---------- */
.quiz-section { margin-bottom: 2rem; }

.quiz-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: .75rem;
}

.quiz-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: .5rem;
}

.quiz-progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 9999px;
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 9999px;
  transition: width .4s;
}

.quiz-question {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.quiz-counter {
  font-size: .8rem;
  color: var(--text-muted);
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-bottom: 1.25rem;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all .2s;
  font-size: .9rem;
  color: var(--text-primary);
  background: var(--bg-primary);
  text-align: left;
  font-family: inherit;
  width: 100%;
}

.quiz-option:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-light);
}

.quiz-option.correct {
  border-color: var(--success);
  background: var(--success-light);
  color: var(--success);
}

.quiz-option.incorrect {
  border-color: var(--danger);
  background: var(--danger-light);
  color: var(--danger);
}

.quiz-option:disabled { cursor: not-allowed; }

.option-letter {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--bg-sidebar);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all .2s;
}

.quiz-option.correct .option-letter {
  background: var(--success);
  color: #fff;
}

.quiz-option.incorrect .option-letter {
  background: var(--danger);
  color: #fff;
}

.quiz-option.selected:not(.correct):not(.incorrect) .option-letter {
  background: var(--accent);
  color: #fff;
}

.quiz-explanation {
  font-size: .83rem;
  color: var(--text-secondary);
  background: var(--bg-sidebar);
  border-left: 3px solid var(--accent);
  padding: .75rem 1rem;
  border-radius: 0 8px 8px 0;
  margin-bottom: 1rem;
  display: none;
  line-height: 1.5;
}

.quiz-explanation.visible { display: block; }

.quiz-actions {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
}

.btn-quiz {
  padding: .6rem 1.4rem;
  border-radius: 9999px;
  font-size: .88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all .2s;
}

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

.btn-quiz.primary:hover { background: var(--accent-hover); }

.btn-quiz.secondary {
  background: var(--bg-sidebar);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-quiz.secondary:hover {
  background: var(--border);
  color: var(--text-primary);
}

/* Resultado final del quiz */
.quiz-result {
  text-align: center;
  padding: 1.5rem;
  display: none;
}

.quiz-result.visible { display: block; }

.result-emoji { font-size: 3rem; margin-bottom: .75rem; }

.result-score {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: .25rem;
}

.result-score span { color: var(--accent); }

.result-msg {
  font-size: .95rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

/* ---------- Botones generales ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: 9999px;
  font-size: .88rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  transition: all .2s;
  text-decoration: none;
}

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

/* ---------- Utilidades ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  font-size: .72rem;
  padding: .15rem .55rem;
  border-radius: 9999px;
  font-weight: 500;
}

.tag.blue   { background: var(--accent-light); color: var(--accent); }
.tag.green  { background: var(--success-light); color: var(--success); }
.tag.amber  { background: var(--warning-light); color: var(--warning); }
.tag.red    { background: var(--danger-light); color: var(--danger); }

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

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

/* Evitar que cualquier elemento desborde el ancho de la página */
html { overflow-x: hidden; }

.accordion-content pre,
.accordion-content code,
pre, code {
  max-width: 100%;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    width: 260px;
    height: calc(100vh - 60px);
    z-index: 90;
  }

  .sidebar.mobile-open { display: block; }

  .main-content {
    padding: 1.5rem 1rem;
    overflow-x: hidden;
  }

  .search-input { width: 200px; }
  .search-input:focus { width: 240px; }

  .temas-grid { grid-template-columns: 1fr 1fr; }

  .hero-title { font-size: 1.6rem; }

  /* Código: scroll horizontal propio en lugar de romper el layout */
  .accordion-content pre {
    overflow-x: auto;
    white-space: pre;
    font-size: .78rem;
    -webkit-overflow-scrolling: touch;
  }

  .tema-titulo { font-size: 1.4rem; }

  .tema-title-block { flex-direction: column; }

  .tema-nav { gap: .5rem; }
  .btn-nav  { font-size: .8rem; padding: .5rem .9rem; }
}

@media (max-width: 600px) {
  .temas-grid       { grid-template-columns: 1fr; }
  .flashcards-grid  { grid-template-columns: 1fr; }
  .search-wrap      { display: none; }
  .progress-badge   { display: none; }

  /* En móvil pequeño el código hace wrap para no necesitar scroll */
  .accordion-content pre {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: .74rem;
  }

  .tema-titulo { font-size: 1.2rem; }

  .tema-nav {
    flex-direction: column;
  }

  .btn-nav {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .quiz-container { padding: 1rem; }

  .flashcard { height: auto; min-height: 130px; }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ---------- Animaciones ---------- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeInUp .4s ease both; }

.fade-in-delay-1 { animation-delay: .05s; }
.fade-in-delay-2 { animation-delay: .1s; }
.fade-in-delay-3 { animation-delay: .15s; }

/* ---------- Tema cards colores (data-block = nº de tema) ---------- */
/* Bloque I — Fundamentos (T1–T6) → celeste 🔵 */
.tema-card[data-block="1"]  { --card-color: #38bdf8; }
.tema-card[data-block="2"]  { --card-color: #38bdf8; }
.tema-card[data-block="3"]  { --card-color: #38bdf8; }
.tema-card[data-block="4"]  { --card-color: #38bdf8; }
.tema-card[data-block="5"]  { --card-color: #38bdf8; }
.tema-card[data-block="6"]  { --card-color: #38bdf8; }
/* Bloque II — Instalación (T7–T9) → lila 🟣 */
.tema-card[data-block="7"]  { --card-color: #8b5cf6; }
.tema-card[data-block="8"]  { --card-color: #8b5cf6; }
.tema-card[data-block="9"]  { --card-color: #8b5cf6; }
/* Bloque III — Configuración (T10–T14) → verde 🟢 */
.tema-card[data-block="10"] { --card-color: #10b981; }
.tema-card[data-block="11"] { --card-color: #10b981; }
.tema-card[data-block="12"] { --card-color: #10b981; }
.tema-card[data-block="13"] { --card-color: #10b981; }
.tema-card[data-block="14"] { --card-color: #10b981; }
/* Bloque IV — Dominios (T15–T17) → naranja 🟠 */
.tema-card[data-block="15"] { --card-color: #f97316; }
.tema-card[data-block="16"] { --card-color: #f97316; }
.tema-card[data-block="17"] { --card-color: #f97316; }
/* Bloque V — Gestión avanzada (T18–T20) → gris ⚫ */
.tema-card[data-block="18"] { --card-color: #64748b; }
.tema-card[data-block="19"] { --card-color: #64748b; }
.tema-card[data-block="20"] { --card-color: #64748b; }

/* Mobile nav button */
.btn-menu {
  display: none;
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: 9999px;
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  align-items: center; justify-content: center;
  font-size: 1rem;
}

@media (max-width: 900px) { .btn-menu { display: flex; } }

/* Overlay sidebar mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 80;
  top: 60px;
}

.sidebar-overlay.active { display: block; }
