:root {
  /* Neutros (fondo / texto / borde) -- estos cambian en modo claro */
  --c-white: #ffffff;
  --c-black: #000000;
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-sidebar: #0b1120;
  --border: #334155;
  --border-strong: #475569;
  --text-faint: #64748b;
  --text-muted: #94a3b8;
  --text-soft: #cbd5e1;
  --text-softer: #e2e8f0;
  --bg-tint: #f1f5f9;
  --text-light: #f8fafc;
  /* Acentos -- casi iguales en ambos modos */
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --blue-800: #1e40af;
  --blue-900: #1e3a8a;
  --blue-950: #172554;
  --blue-500: #3b82f6;
  --blue-400: #60a5fa;
  --blue-300: #93c5fd;
  --blue-200: #bfdbfe;
  --primary-light: #dbeafe;
  --sky-400: #38bdf8;
  --sky-300: #7dd3fc;
  --sky-500: #0ea5e9;
  --sky-700: #0369a1;
  --cyan-200: #a5f3fc;
  --indigo-500: #6366f1;
  --indigo-950: #1e1b4b;
  --violet-600: #7c3aed;
  --purple: #8b5cf6;
  --violet-800: #5b21b6;
  --violet-900: #4c1d95;
  --purple-400: #c084fc;
  --purple-300: #d8b4fe;
  --purple-200: #e9d5ff;
  --tint-purple-dark: #3b1e6d;
  --tint-purple-darker: #241b3d;
  --tint-indigo-dark: #1c0a3d;
  --yellow-400: #facc15;
  --yellow-300: #fde047;
  --yellow-600: #ca8a04;
  --amber-400: #fbbf24;
  --warning: #f59e0b;
  --amber-600: #d97706;
  --amber-900: #78350f;
  --amber-100: #fef3c7;
  --tint-amber-dark: #2b1102;
  --danger: #ef4444;
  --red-600: #dc2626;
  --red-400: #f87171;
  --red-300: #fca5a5;
  --red-900: #7f1d1d;
  --rose-500: #f43f5e;
  --tint-red-dark: #2f0808;
  --green-600: #16a34a;
  --green-400: #4ade80;
  --success: #10b981;
  --emerald-300: #6ee7b7;
  --emerald-900: #064e3b;
  --orange-600: #ea580c;
  --orange-400: #fb923c;
  --tint-navy-dark: #111c30;
  --tint-navy-darker: #090e1a;
  --tint-navy-dark2: #162032;
  --tint-navy-dark3: #0a1230;
}

/* MODO CLARO: solo redefine los tokens neutros (fondo/texto/borde).
   Los acentos (--primary, --danger, --purple, --blue-400...) se quedan
   igual en los dos modos -- ya funcionan bien sobre fondo claro u oscuro. */
:root[data-theme="light"] {
  --bg-dark: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #eef2f7;
  --border: #cbd5e1;
  --border-strong: #94a3b8;
  --text-faint: #64748b;
  --text-muted: #475569;
  --text-soft: #334155;
  --text-softer: #1e293b;
  --bg-tint: #e2e8f0;
  --text-light: #0f172a;
}

* {
  box-sizing: border-box;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg-dark);
  color: var(--text-light);
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: relative;
}

/* BARRA LATERAL */
.sidebar {
  width: 340px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
  gap: 8px;
  flex-shrink: 0;
  height: 100vh;
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 50;
}

.sidebar.collapsed {
  margin-left: -340px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 6px 10px 6px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-logo {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--blue-500), var(--primary-dark));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: white;
  flex-shrink: 0;
}

.brand-text h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
}

.brand-text span {
  font-size: 9.5px;
  color: var(--sky-400);
  font-weight: 700;
  text-transform: uppercase;
}

.global-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  flex-shrink: 0;
}

/* flex-basis del 32%: caben 3 botones en la 1ª fila (3×32% < 100%, y el hueco
   de los gaps hace que el 4º ya no quepa y pase solo a la 2ª fila); los que
   sobran en la 2ª fila crecen (flex-grow:1) para repartirse todo el ancho
   entre ellos, en vez de quedar pequeños y descuadrados. */
.btn-global-tab {
  flex: 1 1 32%;
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 7px 2px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-global-tab:hover {
  color: var(--text-light);
  background: var(--border);
}

.btn-global-tab.active {
  background: var(--primary);
  color: var(--c-white);
  border-color: var(--primary);
}

.sidebar-views {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-views::-webkit-scrollbar {
  width: 5px;
}

.sidebar-views::-webkit-scrollbar-track {
  background: var(--bg-sidebar);
}

.sidebar-views::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.sidebar-panel {
  display: none;
  flex-direction: column;
  gap: 8px;
}

.sidebar-panel.active {
  display: flex;
}

.panel-section-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--sky-400);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.panel-header-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.checkbox-scroll-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 55vh;
  overflow-y: auto;
  padding-right: 4px;
}

.repaso-item-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-soft);
  background: var(--bg-dark);
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.repaso-config-card {
  background: var(--bg-dark);
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-top: 6px;
}

.form-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}

.form-select {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-light);
  padding: 6px;
  border-radius: 5px;
  font-size: 12px;
}

.tree-node {
  border: 1px solid var(--bg-card);
  border-radius: 6px;
  background: var(--bg-dark);
  flex-shrink: 0;
  transition: all 0.15s ease;
  margin-bottom: 4px;
}

.tree-node.open {
  background: var(--tint-navy-dark);
  border-color: var(--primary);
}

.tree-node-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-softer);
  line-height: 1.35;
  gap: 8px;
}

.tree-node-header:hover {
  background: var(--bg-card);
  color: var(--text-light);
}

.tree-node.active-theme>.tree-node-header {
  color: var(--sky-400);
  background: var(--blue-950);
}

.node-title-text {
  flex-grow: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-chevron {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.tree-node.open .node-chevron {
  transform: rotate(90deg);
  color: var(--sky-400);
}

.tree-leaves {
  display: none;
  flex-direction: column;
  gap: 3px;
  padding: 6px 8px 8px 12px;
  background: var(--tint-navy-darker);
  border-top: 1px solid var(--bg-card);
}

.tree-node.open .tree-leaves {
  display: flex;
}

.tree-leaf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  background: var(--bg-dark);
  border: 1px solid transparent;
}

.tree-leaf:hover {
  background: var(--bg-card);
  color: var(--text-light);
  border-color: var(--border);
}

.tree-leaf.active {
  background: var(--primary) !important;
  color: var(--c-white) !important;
  font-weight: 700;
  border-color: var(--primary);
}

.badge-count {
  font-size: 10px;
}

.badge-green {
  color: var(--success);
}

.badge-yellow {
  color: var(--warning);
}

.badge-red {
  color: var(--danger);
}

.badge-blue {
  color: var(--sky-400);
}

.text-danger {
  color: var(--rose-500);
}

.text-accent {
  color: var(--sky-400);
}

.sidebar-footer {
  margin-top: auto;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: 8px;
  flex-shrink: 0;
}

.footer-user-row {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.user-meta {
  font-size: 10.5px;
}

.user-meta strong {
  color: var(--text-light);
  display: block;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-meta span {
  color: var(--success);
  font-weight: 700;
  font-size: 9px;
}

.footer-legal-row {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 6px;
  font-size: 9.5px;
}

.footer-legal-row a {
  color: var(--sky-400);
  text-decoration: none;
  font-weight: 700;
}

.footer-legal-row span {
  color: var(--text-faint);
}

/* DRAWER TAB */
.drawer-tab {
  position: fixed;
  top: 50%;
  left: 340px;
  transform: translateY(-50%);
  width: 22px;
  height: 58px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 8px 8px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 60;
  color: var(--text-muted);
  font-size: 12px;
  transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed~.main-wrapper .drawer-tab {
  left: 0;
}

/* MAIN WRAPPER */
.main-wrapper {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-dark);
  position: relative;
}

.topbar-primary {
  height: 48px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 28px;
  flex-shrink: 0;
  gap: 12px;
}

.header-topic-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-grow: 1;
}

.header-topic-info #header-topic-badge {
  font-size: 12px;
  font-weight: 800;
  color: var(--sky-400);
}

.header-topic-info #header-topic-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-light);
}

.topbar-secondary {
  min-height: 40px;
  height: auto;
  background: var(--tint-navy-dark2);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px 6px 16px;
  flex-shrink: 0;
  font-size: 12px;
  gap: 8px;
}

.sub-title {
  font-weight: 700;
  color: var(--sky-400);
  display: flex;
  align-items: center;
  gap: 6px;
}

.sub-actions {
  display: flex !important;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap !important;
  margin-left: auto;
}

.btn-tool {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  color: var(--text-light);
  padding: 5px 12px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  white-space: nowrap;
}

.btn-tool:hover {
  background: var(--primary);
  border-color: var(--primary);
}

.btn-tool-blue {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--c-white);
}

.btn-xs {
  font-size: 9px;
  padding: 2px 6px;
}

.btn-lg {
  padding: 8px 24px;
  font-size: 13px;
}

.btn-full {
  width: 100%;
  justify-content: center;
  margin-top: 10px;
  padding: 8px;
}

.vertical-side-nav {
  position: absolute;
  right: 0;
  top: 88px;
  bottom: 0;
  width: 44px;
  display: flex;
  flex-direction: column;
  z-index: 99;
  border-left: 1px solid var(--border);
  background: var(--bg-sidebar);
}

.btn-side-arrow {
  flex: 1;
  width: 100%;
  background: var(--bg-card);
  border: none;
  color: var(--sky-400);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-side-arrow:first-child {
  border-bottom: 1px solid var(--border);
}

.btn-side-arrow .arrow-symbol {
  font-size: 24px;
  font-weight: 800;
}

.btn-side-arrow .arrow-text {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  margin-top: 6px;
  color: var(--text-muted);
}

.content-area {
  padding: 0 44px 0 0;
  flex-grow: 1;
  height: calc(100vh - 88px);
  overflow-y: auto;
  position: relative;
}

.tab-pane {
  display: none;
  width: 100%;
  height: 100%;
}

.tab-pane.active {
  display: flex;
  flex-direction: column;
}

iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background: var(--bg-sidebar);
}

.media-center-box {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100%;
  padding: 20px;
  overflow-y: auto;
}

.media-wrapper {
  max-width: 960px;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.watermark-container {
  position: relative;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border-radius: 8px;
  overflow: hidden;
  background: var(--c-black);
}

.watermark-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  z-index: 20;
}

.watermark-diagonal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-32deg);
  color: rgba(255, 255, 255, 0.08);
  font-size: clamp(16px, 2.5vw, 26px);
  font-weight: 900;
  letter-spacing: 3px;
  text-transform: uppercase;
  white-space: nowrap;
  user-select: none;
  width: 130%;
  text-align: center;
}

.watermark-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: rgba(248, 250, 252, 0.75);
  font-size: 10px;
  font-weight: 800;
  background: rgba(11, 17, 32, 0.85);
  padding: 6px 14px;
  backdrop-filter: blur(5px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  user-select: none;
}

/* FLASHCARDS */
.fc-wrapper {
  max-width: 760px;
  margin: 20px auto;
  padding: 10px;
  width: 100%;
  text-align: center;
}

.fc-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.fc-header-row h3 {
  margin: 0;
  font-size: 16px;
  color: var(--sky-400);
}

.fc-header-row span {
  font-size: 12px;
  font-weight: 800;
  background: var(--bg-card);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.fc-scene {
  perspective: 1000px;
  width: 100%;
  max-width: 600px;
  height: 380px;
  margin: 20px auto;
  cursor: pointer;
}

.fc-card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 16px;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.4);
}

.fc-card.flipped {
  transform: rotateY(180deg);
}

.fc-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 16px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--border);
}

.fc-front {
  background: linear-gradient(145deg, var(--bg-card), var(--bg-dark));
  color: var(--text-light);
}

.fc-back {
  background: linear-gradient(145deg, var(--blue-950), var(--bg-dark));
  color: var(--sky-400);
  transform: rotateY(180deg);
  border-color: var(--primary);
}

/* Temas de color por tipo de flashcard (plazo/organo/excepcion/mnemo) — tintan la
   tarjeta ENTERA, no solo la etiqueta, para que se distinga de un vistazo. */
.fc-theme-plazo .fc-front, .fc-theme-plazo .fc-back {
  background: linear-gradient(145deg, var(--red-900), var(--tint-red-dark)) !important;
  border-color: var(--red-400) !important;
}
.fc-theme-organo .fc-front, .fc-theme-organo .fc-back {
  background: linear-gradient(145deg, var(--blue-900), var(--tint-navy-dark3)) !important;
  border-color: var(--blue-400) !important;
}
.fc-theme-excepcion .fc-front, .fc-theme-excepcion .fc-back {
  background: linear-gradient(145deg, var(--amber-900), var(--tint-amber-dark)) !important;
  border-color: var(--amber-400) !important;
}
.fc-theme-mnemo .fc-front, .fc-theme-mnemo .fc-back {
  background: linear-gradient(145deg, var(--violet-900), var(--tint-indigo-dark)) !important;
  border-color: var(--purple-300) !important;
}

.fc-face-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#fc-tag {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  background: var(--border);
}

#fc-difficulty {
  font-size: 10px;
  font-weight: 800;
  color: var(--warning);
}

#fc-legal-ref {
  font-size: 10px;
  font-weight: 800;
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 4px;
}

#fc-question-text {
  font-size: clamp(19px, 3vw, 25px);
  font-weight: 800;
  line-height: 1.4;
  margin: auto 0;
  text-align: center;
  color: var(--text-light);
}

#fc-answer-text {
  font-size: clamp(19px, 3vw, 25px);
  font-weight: 800;
  line-height: 1.4;
  margin: auto 0;
  text-align: center;
  color: var(--text-light);
}

.fc-hint {
  font-size: 11px;
  color: var(--text-faint);
}

.fc-nav-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

/* TEST ENGINE */
.test-wrapper {
  max-width: 860px;
  margin: 20px auto;
  padding: 0 15px;
  width: 100%;
}

.test-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

.test-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.test-header-row h3 {
  margin: 0;
  font-size: 16px;
  color: var(--sky-400);
}

.test-stats-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

#test-score-badge {
  font-size: 12px;
  font-weight: 800;
  color: var(--success);
}

#test-progress-counter {
  font-size: 12px;
  font-weight: 800;
  background: var(--bg-dark);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

#test-question-box {
  margin-bottom: 20px;
}

#test-question-text {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--text-light);
}

#test-options-container {
  margin-bottom: 16px;
}

.test-option-btn {
  width: 100%;
  text-align: left;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 8px;
  color: var(--text-softer);
  font-size: 13.5px;
  cursor: pointer;
  margin-bottom: 10px;
  transition: all 0.15s ease;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.test-option-btn:hover:not(.disabled) {
  background: var(--bg-card);
  border-color: var(--sky-400);
}

.test-option-btn.correct {
  background: var(--emerald-900) !important;
  border-color: var(--success) !important;
  color: var(--emerald-300) !important;
  font-weight: 700;
}

.test-option-btn.incorrect {
  background: var(--red-900) !important;
  border-color: var(--danger) !important;
  color: var(--red-300) !important;
}

#test-rationale-box {
  background: var(--bg-dark);
  border-left: 4px solid var(--sky-400);
  border-radius: 6px;
  padding: 14px;
  margin-top: 16px;
}

.rationale-tag {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--sky-400);
  margin-bottom: 6px;
}

#test-rationale-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-soft);
}

.test-nav-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

/* TUTOR ENGINE */
.tutor-wrapper {
  padding: 20px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.tutor-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 16px;
}

.tutor-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.tutor-header-row h3 {
  margin: 0;
  color: var(--sky-400);
  font-size: 16px;
}

.tutor-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
}

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}

.heatmap-card {
  background: var(--bg-dark);
  border-radius: 6px;
  padding: 8px;
  text-align: center;
}

.tutor-mission-title {
  margin: 0 0 10px 0;
  color: var(--warning);
  font-size: 14px;
}

#tutor-recommendation-text {
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.5;
  margin-bottom: 12px;
}

/* REPASO INTELIGENTE Y TUTOR DE ESTUDIO — MEJORA (13/09/2026) */
.mode-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 8px;
}

.mode-chip {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.mode-chip:hover {
  border-color: var(--sky-400);
  color: var(--text-softer);
}

.mode-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--c-white);
}

.repaso-hint {
  font-size: 10.5px;
  color: var(--text-faint);
  margin: 2px 0 10px;
  line-height: 1.4;
}

.btn-ver-articulo {
  margin-top: 10px;
  display: none;
}

.repaso-summary-card {
  background: var(--bg-card);
  border: 1px solid var(--sky-400);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  max-width: 900px;
  margin: 0 auto;
}

.repaso-summary-stat {
  font-size: 30px;
  font-weight: 900;
  color: var(--sky-400);
}

.article-map-list {
  display: none;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--bg-card);
  text-align: left;
}

.heatmap-card {
  cursor: pointer;
}

.heatmap-card.expanded .article-map-list {
  display: flex;
}

.article-map-item {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 10px;
  color: var(--text-soft);
}

.tutor-plan-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 10px;
}

.tutor-plan-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-light);
  padding: 6px 8px;
  border-radius: 5px;
  font-size: 12px;
}

.tutor-cold-start-notice {
  background: var(--blue-950);
  border: 1px solid var(--primary);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 11.5px;
  color: var(--blue-200);
  margin-bottom: 12px;
  line-height: 1.5;
}

/* MODALES */
.app-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(10px);
  z-index: 350;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.print-modal-container {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  width: 96vw;
  max-width: 1150px;
  height: 94vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.print-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.print-modal-header h3 {
  margin: 0;
  color: var(--sky-400);
  font-size: 15px;
}

.print-modal-header span {
  font-size: 11px;
  color: var(--text-muted);
}

.offset-slider-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-dark);
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.offset-slider-box label {
  font-size: 11px;
  color: var(--text-softer);
  font-weight: 700;
}

.offset-slider-box input[type="range"] {
  width: 120px;
  cursor: pointer;
}

.offset-slider-box span {
  font-size: 10.5px;
  color: var(--sky-400);
  font-weight: 800;
}

.print-modal-actions {
  display: flex;
  gap: 8px;
}

.print-controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
  background: var(--bg-dark);
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.print-controls-grid label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-softer);
  cursor: pointer;
}

.print-preview-workspace {
  flex: 1;
  background: var(--border-strong);
  border-radius: 8px;
  overflow-y: auto;
  padding: 30px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
}

.a4-physical-sheet {
  background: var(--c-white);
  color: var(--c-black);
  width: 210mm;
  min-height: 297mm;
  height: auto;
  padding: 12mm 15mm;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
  border-radius: 2px;
  box-sizing: border-box;
  position: relative;
}

.a4-physical-sheet.landscape {
  width: 297mm;
  min-height: 210mm;
}

.sheet-header-bar {
  display: flex;
  justify-content: space-between;
  background: var(--bg-card);
  color: var(--text-light);
  padding: 8px 14px;
  border-bottom: 2px solid var(--primary);
}

.about-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  max-width: 580px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}

.about-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.about-header h3 {
  margin: 0;
  color: var(--sky-400);
}

.about-body {
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text-soft);
}

.about-brand {
  font-size: 16px;
  font-weight: 800;
  color: var(--yellow-400);
  text-align: center;
  margin-bottom: 8px;
}

/* REGLAS DE IMPRESIÓN LIMPIA */
@media print {
  @page {
    margin: 0;
  }

  body {
    background: var(--c-white) !important;
    color: var(--c-black) !important;
    overflow: visible !important;
    height: auto !important;
  }

  .sidebar,
  .main-wrapper,
  .drawer-tab,
  .app-modal,
  .topbar-primary,
  .topbar-secondary,
  .vertical-side-nav,
  .print-controls-grid,
  .print-modal-header,
  .no-print {
    display: none !important;
  }

  .print-modal-container {
    border: none !important;
    padding: 0 !important;
    width: 100% !important;
    height: auto !important;
    max-width: none !important;
    background: transparent !important;
  }

  .print-preview-workspace {
    background: transparent !important;
    padding: 0 !important;
    overflow: visible !important;
    display: block !important;
  }

  .a4-physical-sheet {
    box-shadow: none !important;
    margin: 0 !important;
    page-break-after: always !important;
    width: 100% !important;
    height: auto !important;
  }
}

/* ============================================================
   ESTILOS ÁRBOL TEMARIO VERTICAL Y FLUIDO (DESKTOP & MOBILE)
   ============================================================ */
#view-tree {
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 8px;
}

.tree-topic-header:hover {
  background: rgba(255, 255, 255, 0.05);
}

.tree-topic-group.open .tree-topic-header {
  color: var(--sky-400) !important;
}

.tree-subtabs-list {
  display: flex !important;
  flex-direction: column !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

.tree-subtab-btn {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  width: 100% !important;
  transition: all 0.15s ease !important;
}

.tree-subtab-btn:hover {
  background: rgba(56, 189, 248, 0.12) !important;
  color: var(--text-light) !important;
}

.tree-subtab-btn.active {
  background: var(--primary) !important;
  color: var(--c-white) !important;
  font-weight: 800 !important;
}

/* Adaptación para pantallas táctiles y móviles */
@media screen and (max-width: 768px) {
  .tree-topic-header {
    padding: 10px 8px !important;
    font-size: 0.88rem !important;
  }

  .tree-subtab-btn {
    padding: 8px 10px !important;
    font-size: 0.82rem !important;
  }
}

/* Ocultar definitivamente barras residuales en cualquier iframe o vista */
.nav-final,
.nav-bar,
.modo-demo,
.selector-secciones {
  display: none !important;
}

/* ============================================================
   RESPONSIVE MÓVIL: SIDEBAR COLAPSADO POR DEFECTO
   ============================================================ */
@media screen and (max-width: 768px) {

  /* La barra lateral nace oculta fuera de pantalla hacia la izquierda */
  .sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    /* La regla base (.sidebar) fija height:100vh, que en móvil incluye el hueco que
       tapa la barra de direcciones/gestos del navegador cuando está visible — eso
       empujaba el pie (email, tema, "Acerca de", cerrar sesión) fuera de la pantalla
       visible, sin forma de hacer scroll hasta él. Con height:auto y top/bottom a 0,
       el navegador calcula la altura real disponible en cada momento. */
    height: auto !important;
    width: 280px !important;
    max-width: 85vw !important;
    margin-left: -280px;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.6);
    z-index: 200 !important;
  }

  /* Cuando se abre (quitando .collapsed o añadiendo .mobile-open) */
  .sidebar.mobile-open,
  .sidebar:not(.collapsed) {
    margin-left: 0 !important;
  }

  /* La pestaña/botón de apertura lateral se sitúa al borde izquierdo — en color
     distinto del resto de la app para que destaque y se note que es tocable */
  .drawer-tab {
    position: fixed;
    top: 50%;
    left: 340px;
    transform: translateY(-50%);
    width: 30px;
    height: 110px;
    background: var(--primary);
    border: 1px solid var(--primary-dark);
    border-left: none;
    border-radius: 0 10px 10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    color: var(--c-white);
    font-size: 16px;
    box-shadow: 2px 0 10px rgba(37, 99, 235, 0.5);
    transition: none; /* en móvil el menú se oculta de golpe (display:none, sin animación
                          posible); si la pestaña sí anima su posición, parece perseguirlo
                          en vez de moverse los dos juntos como un bloque */
  }

  .sidebar.collapsed~.main-wrapper .drawer-tab,
  body.sidebar-collapsed .drawer-tab {
    left: 0 !important;
  }

  .sidebar.mobile-open~.main-wrapper .drawer-tab {
    left: 280px !important;
  }

  .content-area {
    padding: 0 !important;
    height: calc(100vh - 88px);
  }

  .vertical-side-nav {
    display: none !important;
  }

  .topbar-primary,
  .topbar-secondary {
    padding: 0 12px !important;
  }
}
/* --- Flashcards en tema claro (02/10/2026): las tarjetas tintadas y el reverso siguen oscuros,
   asi que el texto tiene que ser blanco (antes usaba --text-light, oscuro en tema claro). --- */
:root[data-theme="light"] .fc-back #fc-answer-text,
:root[data-theme="light"] .fc-back .fc-hint,
:root[data-theme="light"] .fc-card[class*="fc-theme-"] #fc-question-text,
:root[data-theme="light"] .fc-card[class*="fc-theme-"] #fc-answer-text,
:root[data-theme="light"] .fc-card[class*="fc-theme-"] .fc-hint {
  color: #ffffff !important;
}
:root[data-theme="light"] .fc-back #fc-legal-ref,
:root[data-theme="light"] .fc-card[class*="fc-theme-"] #fc-legal-ref {
  background: rgba(0, 0, 0, .28);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, .35);
}
:root[data-theme="light"] .fc-card[class*="fc-theme-"] #fc-difficulty { color: #fde68a; }
/* === Ayudas de estudio: huecos, preguntas abiertas === */
.cloze-line{margin-top:12px;padding:10px 12px;border-radius:8px;background:rgba(0,0,0,.25);font-size:.95em;line-height:1.5}
.cloze-gap{display:inline-block;min-width:64px;text-align:center;border-bottom:2px dashed #fbbf24;color:#fbbf24;font-weight:800;padding:0 4px}
.cloze-hit{background:#fbbf24;color:#111;border-radius:4px;padding:0 4px;font-weight:800}
.open-toggle{font-size:12px;color:var(--text-soft,#94a3b8);cursor:pointer;user-select:none;display:inline-flex;gap:6px;align-items:center}
.open-prompt{text-align:center;padding:18px 10px;border:1px dashed #38bdf8;border-radius:10px;color:var(--text-soft,#94a3b8);font-size:14px;line-height:1.9}

.conf-map{margin-top:12px;padding:10px 12px;border:1px solid #fbbf2466;border-radius:10px;font-size:12px;text-align:left}
.conf-map ul{margin:6px 0 0;padding-left:18px}.conf-map li{margin:6px 0}.conf-ko{color:#f87171}.conf-ok{color:#4ade80}
