:root {
  color-scheme: light;
  --bg: #f5f8fb;
  --surface: #ffffff;
  --surface-strong: #eef8f4;
  --ink: #17211b;
  --muted: #617069;
  --line: #dbe5ec;
  --primary: #006b3f; /* Color institucional USB Verde oficial */
  --primary-strong: #045733;
  --accent: #00a887;
  --accent-strong: #082b3f;
  --gold: #ffd166;
  --gold-strong: #b77900;
  --accent-soft: #fff7d6;
  --good: #16803c;
  --bad: #bd2c2c;
  --info: #2563a8;
  --shadow: 0 18px 40px rgba(8, 43, 63, 0.12);
  --radius: 8px;
  
  /* Tipografías institucionales según el manual USB */
  --font-serif: "Palatino Linotype", Palatino, Georgia, serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-family: var(--font-sans);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f0c;
  --surface: #131914;
  --surface-strong: #1b241c;
  --ink: #e3ede6;
  --muted: #8ea194;
  --line: #233126;
  --primary: #15b356; /* Verde institucional ligeramente más luminoso para contraste */
  --primary-strong: #1edb6c;
  --accent: #f59e0b;
  --accent-soft: #2e2008;
  --good: #22c55e;
  --bad: #ef4444;
  --info: #3b82f6;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  
  --sidebar-bg: rgba(19, 25, 20, 0.88);
  --card-bg: rgba(19, 25, 20, 0.92);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(9, 132, 59, 0.08), transparent 32rem),
    linear-gradient(315deg, rgba(217, 119, 6, 0.08), transparent 28rem), var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Colapso de barra lateral en PC */
.app-shell.sidebar-collapsed {
  grid-template-columns: 0px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: var(--sidebar-bg, rgba(255, 255, 255, 0.88));
  backdrop-filter: blur(18px);
  overflow-y: auto;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-shell.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
  margin-left: -320px;
}

/* Fondo oscurecedor y difuminado en movil */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  z-index: 1100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Deshabilitar overlay oscurecedor en PC */
@media (min-width: 1081px) {
  .sidebar-overlay {
    display: none !important;
  }
}

/* Boton flotante de menu hamburguesa glassmorphism (Siempre activo) */
.sidebar-toggle {
  position: fixed;
  top: 14px;
  left: 334px; /* Flota al lado de la barra en PC */
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(7, 59, 46, 0.82);
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 18px rgba(7, 59, 46, 0.25);
  cursor: pointer;
  z-index: 1300;
  display: flex; /* Siempre visible */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-shell.sidebar-collapsed .sidebar-toggle {
  left: 14px; /* Se desplaza a la esquina cuando se colapsa la barra en PC */
}

[data-theme="dark"] .sidebar-toggle {
  background: rgba(9, 19, 16, 0.82);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
}

.sidebar-toggle:hover {
  transform: scale(1.06);
  border-color: var(--gold);
  background: #006b3f;
}

.sidebar-toggle:active {
  transform: scale(0.95);
}

.hamburger-line {
  display: block;
  width: 20px;
  height: 2.5px;
  border-radius: 2px;
  background-color: #ffffff;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Animaciones de transformacion a "X" */
.sidebar-toggle.active .hamburger-line:nth-child(1) {
  transform: translateY(7.5px) rotate(45deg);
  background-color: var(--gold);
}

.sidebar-toggle.active .hamburger-line:nth-child(2) {
  opacity: 0;
  transform: translateX(-10px);
}

.sidebar-toggle.active .hamburger-line:nth-child(3) {
  transform: translateY(-7.5px) rotate(-45deg);
  background-color: var(--gold);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
}

.brand-logo {
  display: block;
  max-width: 230px;
  height: auto;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.05));
  margin-bottom: 2px;
}

[data-theme="dark"] .brand-logo {
  filter: drop-shadow(0 2px 8px rgba(255, 255, 255, 0.08)) brightness(0.95);
}

.brand h1 {
  margin: 4px 0 0;
  font-size: 1.15rem;
  line-height: 1.18;
  font-family: var(--font-serif);
  font-weight: 700;
  color: var(--ink);
}

.eyebrow {
  margin: 0;
  color: var(--primary-strong);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.module-nav {
  display: grid;
  gap: 8px;
}

.nav-button {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.nav-button:hover,
.nav-button.active {
  border-color: var(--line);
  background: var(--surface-strong);
}

.nav-index {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: #e5efe9;
  color: var(--primary-strong);
  font-weight: 800;
}

.nav-title {
  font-size: 0.92rem;
  font-weight: 700;
}

.nav-check {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #cdd8d1;
}

.nav-check.done {
  background: var(--good);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.ghost-button,
.primary-button,
.secondary-button,
.chip-button,
.answer-button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-weight: 750;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease,
    color 120ms ease;
}

#soundToggleButton[aria-pressed="false"] {
  color: var(--muted);
  background: #f8faf8;
}

.ghost-button,
.primary-button,
.secondary-button {
  min-height: 42px;
  padding: 10px 14px;
}

.primary-button {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.secondary-button:hover,
.ghost-button:hover,
.chip-button:hover,
.answer-button:hover {
  border-color: var(--primary);
  background: #edf8f5;
}

.primary-button:hover {
  background: var(--primary-strong);
}

.ghost-button:active,
.primary-button:active,
.secondary-button:active,
.chip-button:active,
.answer-button:active {
  transform: translateY(1px);
}

.content {
  min-width: 0;
  padding: 28px clamp(18px, 4vw, 48px) 56px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
  gap: 28px;
  align-items: end;
  margin: 0 auto 24px;
  max-width: 1180px;
  padding: 20px 0 26px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0)),
    repeating-linear-gradient(90deg, rgba(15, 118, 110, 0.06) 0 1px, transparent 1px 36px),
    repeating-linear-gradient(0deg, rgba(217, 119, 6, 0.05) 0 1px, transparent 1px 36px);
}

.hero h2 {
  margin: 6px 0 12px;
  max-width: 860px;
  font-size: clamp(2rem, 4vw, 4.4rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.hero p:not(.eyebrow) {
  margin: 0;
  max-width: 760px;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.6;
}

.progress-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.progress-value {
  display: block;
  font-size: 2.2rem;
  font-weight: 900;
}

.progress-label {
  display: block;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

.meter {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe8e2;
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 240ms ease;
}

.view {
  max-width: 1180px;
  margin: 0 auto;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.module-card,
.panel,
.quiz-panel,
.lab-panel,
.game-panel,
.study-panel,
.final-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 28px rgba(31, 46, 37, 0.08);
}

.module-card {
  display: flex;
  min-height: 260px;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  overflow: hidden;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease;
}

.module-card:hover {
  transform: translateY(-2px);
  border-color: rgba(15, 118, 110, 0.4);
  box-shadow: 0 16px 34px rgba(31, 46, 37, 0.12);
}

.module-art {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(217, 119, 6, 0.08)),
    #fbfdfb;
}

.module-art svg {
  display: block;
  width: 100%;
  height: 100%;
}

.module-art.card {
  height: 118px;
}

.module-art.hero {
  width: min(220px, 100%);
  height: 134px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.26);
}

.module-card:hover .module-art svg {
  animation: artFloat 1.6s ease-in-out infinite alternate;
}

.module-card-top,
.section-heading,
.question-top,
.toolbar,
.result-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.module-number,
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e5efe9;
  color: var(--primary-strong);
  font-weight: 800;
  font-size: 0.82rem;
}

.module-status {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.module-card h3 {
  margin: 0;
  font-size: 1.25rem;
}

.module-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.module-card .primary-button {
  margin-top: auto;
}

.module-layout {
  display: grid;
  gap: 16px;
}

.module-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 24px;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
}

.module-title-area {
  flex: 1;
  min-width: 0;
}

.module-header h2 {
  margin: 6px 0 8px;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1.02;
}

.module-header p {
  margin: 0;
  max-width: 780px;
  color: rgba(255, 255, 255, 0.84);
  line-height: 1.55;
}

.module-header .pill {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.module-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(340px, 1.1fr);
  gap: 16px;
  align-items: start;
}

.panel,
.quiz-panel,
.lab-panel,
.game-panel,
.study-panel,
.final-panel {
  padding: 18px;
}

.section-heading {
  margin-bottom: 12px;
}

.section-heading h3 {
  margin: 0;
  font-size: 1.08rem;
}

.section-heading.compact {
  margin: 0 0 8px;
}

.concept-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.concept-list li {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdfb;
  line-height: 1.52;
}

.example-box {
  margin-top: 14px;
  padding: 14px;
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--accent-soft);
  line-height: 1.55;
}

.deep-dive {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.06), rgba(217, 119, 6, 0.05));
}

.deep-dive p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.detail-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  line-height: 1.5;
}

.system-use {
  padding: 10px 12px;
  border-radius: var(--radius);
  background: #fff;
  line-height: 1.5;
}

.lab-panel {
  display: grid;
  gap: 14px;
}

.game-panel {
  display: grid;
  gap: 14px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.06), rgba(217, 119, 6, 0.08)),
    rgba(255, 255, 255, 0.94);
}

.game-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.game-intro strong {
  display: block;
  margin-bottom: 4px;
  font-size: 1.04rem;
}

.game-intro p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.game-card {
  display: grid;
  gap: 10px;
  min-height: 156px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  transition:
    border-color 140ms ease,
    transform 140ms ease,
    box-shadow 140ms ease;
}

.game-card:hover {
  transform: translateY(-1px);
  border-color: rgba(15, 118, 110, 0.42);
}

.game-card.correct {
  border-color: rgba(22, 128, 60, 0.7);
  background: #f0fbf2;
  box-shadow: 0 0 0 3px rgba(22, 128, 60, 0.08);
}

.game-card.wrong {
  border-color: rgba(189, 44, 44, 0.62);
  background: #fff6f6;
}

.game-card p {
  margin: 0;
  font-weight: 760;
  line-height: 1.5;
}

.game-card label {
  display: grid;
  gap: 6px;
}

.game-card label span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.game-card select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 8px 10px;
}

.game-feedback {
  min-height: 26px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.45;
}

.study-panel {
  display: grid;
  gap: 14px;
  background: rgba(255, 255, 255, 0.94);
}

.study-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.study-card,
.practice-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdfb;
}

.study-card {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 14px;
}

.study-card.worked {
  background: var(--accent-soft);
  border-color: rgba(217, 119, 6, 0.28);
}

.study-card h4 {
  margin: 0;
  color: var(--primary-strong);
  font-size: 1rem;
}

.study-card p {
  margin: 0;
  line-height: 1.58;
}

.definition-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.definition-list div {
  display: grid;
  gap: 3px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.definition-list div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.definition-list dt {
  color: var(--ink);
  font-weight: 850;
}

.definition-list dd {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.step-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
  line-height: 1.5;
}

.practice-bank {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(37, 99, 168, 0.06), rgba(15, 118, 110, 0.05));
}

.practice-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.practice-card {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 12px;
}

.practice-card p {
  margin: 0;
  font-weight: 760;
  line-height: 1.5;
}

.practice-card .secondary-button {
  width: fit-content;
}

.practice-solution {
  padding: 10px;
  border-radius: var(--radius);
  background: #fff;
  color: var(--primary-strong);
  font-weight: 720;
  line-height: 1.5;
}

.lab-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.field input,
.field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 9px 10px;
  color: var(--ink);
}

.output-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.output-box {
  min-height: 86px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdfb;
}

.output-box strong {
  display: block;
  margin-bottom: 6px;
  color: var(--primary-strong);
  font-size: 0.86rem;
}

.math-line {
  font-family: "Cascadia Mono", "Consolas", monospace;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.math-display,
.latex-display {
  margin: 10px 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.math-line .latex-inline {
  font-family: Georgia, "Times New Roman", serif;
}

.latex-inline,
.latex-display {
  color: #101c15;
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: 0;
}

.latex-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.18em;
  vertical-align: middle;
  white-space: nowrap;
}

.latex-display {
  display: flex;
  justify-content: center;
  padding: 8px 0;
  font-size: 1.08rem;
}

.latex-frac,
.latex-binom {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
}

.latex-frac {
  flex-direction: column;
  gap: 1px;
  line-height: 1.05;
  margin: 0 0.12em;
}

.latex-frac .num,
.latex-frac .den {
  display: block;
  padding: 0 0.22em;
}

.latex-frac .den {
  border-top: 1px solid currentColor;
}

.latex-binom {
  gap: 0.1em;
}

.latex-stack {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  font-size: 0.82em;
}

.math-roman {
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-style: normal;
}

.mathcal {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: 700;
}

.answer-button .latex-inline {
  pointer-events: none;
}

.truth-table,
.matrix-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: var(--radius);
  background: #fff;
}

.truth-table th,
.truth-table td,
.matrix-table th,
.matrix-table td {
  padding: 9px 10px;
  border: 1px solid var(--line);
  text-align: center;
}

.truth-table th,
.matrix-table th {
  background: #eaf2ed;
}

.token-row,
.chip-row,
.answers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.set-token,
.sample-token {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  min-width: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-weight: 800;
}

.set-token.active,
.sample-token.active {
  border-color: var(--primary);
  background: #dff5ee;
  color: var(--primary-strong);
}

.venn {
  position: relative;
  min-height: 220px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fbf9;
}

.venn-circle {
  position: absolute;
  top: 34px;
  width: 180px;
  height: 150px;
  border: 3px solid rgba(15, 118, 110, 0.7);
  border-radius: 50%;
  background: rgba(15, 118, 110, 0.12);
}

.venn-circle.b {
  left: 156px;
  border-color: rgba(217, 119, 6, 0.72);
  background: rgba(217, 119, 6, 0.13);
}

.venn-circle.a {
  left: 56px;
}

.venn-label {
  position: absolute;
  top: 12px;
  font-weight: 900;
}

.venn-label.a {
  left: 116px;
  color: var(--primary-strong);
}

.venn-label.b {
  left: 292px;
  color: var(--accent);
}

.venn-items {
  position: absolute;
  inset: 0;
}

.string-preview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.bar-chart {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  align-items: end;
  min-height: 160px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdfb;
}

.bar {
  display: grid;
  align-items: end;
  gap: 6px;
  height: 132px;
  text-align: center;
  color: var(--muted);
  font-size: 0.74rem;
}

.bar span:first-child {
  display: block;
  width: 100%;
  min-height: 4px;
  border-radius: 4px 4px 0 0;
  background: var(--primary);
}

.graph-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.7fr);
  gap: 12px;
  align-items: start;
}

.graph-canvas {
  width: 100%;
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdfb;
}

.graph-facts {
  display: grid;
  gap: 10px;
}

.quiz-panel {
  display: grid;
  gap: 14px;
}

.question-card.ova-question-style {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

[data-theme="dark"] .question-card.ova-question-style {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.question-card.pulse-good {
  animation: pulseGood 420ms ease;
}

.question-card.pulse-bad {
  animation: pulseBad 420ms ease;
}

.ova-question-header {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 800;
  border-bottom: 1.5px solid var(--line);
  padding-bottom: 8px;
}

.ova-question-prompt {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.5;
}

.ova-question-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.answer-button {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  text-align: left;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  transition: all 150ms ease;
}

.answer-button:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--surface-strong);
}

.ova-question-radio-circle {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  position: relative;
  flex-shrink: 0;
  transition: border-color 150ms ease, background-color 150ms ease;
}

.answer-button.selected {
  border-color: var(--primary);
  background: rgba(9, 132, 59, 0.04);
}

[data-theme="dark"] .answer-button.selected {
  background: rgba(21, 179, 86, 0.06);
}

.answer-button.selected .ova-question-radio-circle {
  border-color: var(--primary);
  background: var(--primary);
}

.answer-button.selected .ova-question-radio-circle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
}

.answer-button.correct {
  border-color: var(--good);
  background: rgba(22, 197, 94, 0.08) !important;
  color: var(--good);
}

.answer-button.correct .ova-question-radio-circle {
  border-color: var(--good);
  background: var(--good);
}

.answer-button.correct .ova-question-radio-circle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(45deg);
  width: 3px;
  height: 7px;
  border-bottom: 2px solid #fff;
  border-right: 2px solid #fff;
  border-radius: 0;
}

.answer-button.wrong {
  border-color: var(--bad);
  background: rgba(239, 68, 68, 0.08) !important;
  color: var(--bad);
}

.answer-button.wrong .ova-question-radio-circle {
  border-color: var(--bad);
  background: var(--bad);
}

.answer-button.wrong .ova-question-radio-circle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 2px;
  background: #fff;
}

.ova-question-option-text {
  font-weight: 500;
  line-height: 1.3;
}

.ova-question-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.ova-question-check-btn {
  min-height: 40px;
  padding: 8px 18px;
}

.ova-question-check-btn:disabled {
  background: var(--line);
  border-color: var(--line);
  color: var(--muted);
  cursor: not-allowed;
  transform: none !important;
}

.ova-question-retry-actions {
  display: flex;
  gap: 10px;
}

.ova-question-retry-btn,
.ova-question-solution-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 14px;
}

.ova-question-feedback {
  margin-top: 10px;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ova-question-feedback.good {
  background: rgba(22, 197, 94, 0.05);
  border-left: 4px solid var(--good);
  color: var(--ink);
}

.ova-question-feedback.bad {
  background: rgba(239, 68, 68, 0.05);
  border-left: 4px solid var(--bad);
  color: var(--ink);
}

.ova-question-feedback p {
  margin: 0;
  font-weight: 500;
  color: var(--muted);
}

[data-theme="dark"] .ova-question-feedback p {
  color: var(--ink);
}

.ova-question-feedback-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.98rem;
  font-weight: 750;
}

.ova-question-feedback.good .ova-question-feedback-header {
  color: var(--good);
}

.ova-question-feedback.bad .ova-question-feedback-header {
  color: var(--bad);
}

.ova-question-feedback-header svg {
  flex-shrink: 0;
}

.final-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
  align-items: start;
}

.score-box {
  position: sticky;
  top: 24px;
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.score-number {
  font-size: 3rem;
  font-weight: 900;
  line-height: 1;
}

.summary-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.summary-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.hidden {
  display: none !important;
}

.celebration {
  position: fixed;
  left: 50%;
  top: 18px;
  z-index: 50;
  min-width: 220px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  color: var(--primary-strong);
  text-align: center;
  transform: translateX(-50%);
  animation: toastIn 1700ms ease forwards;
  pointer-events: none;
}

.celebration strong {
  position: relative;
  z-index: 2;
  font-size: 1rem;
}

.celebration span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7px;
  height: 16px;
  border-radius: 2px;
  background: var(--primary);
  opacity: 0;
  transform: rotate(calc(var(--i) * 21deg)) translateY(0);
  animation: confetti 1100ms ease-out forwards;
  animation-delay: calc(var(--i) * 18ms);
}

.celebration span:nth-child(3n) {
  background: var(--accent);
}

.celebration span:nth-child(4n) {
  background: var(--info);
}

@keyframes artFloat {
  from {
    transform: translateY(0);
  }

  to {
    transform: translateY(-4px);
  }
}

@keyframes pulseGood {
  0% {
    box-shadow: 0 0 0 0 rgba(22, 128, 60, 0.24);
  }

  100% {
    box-shadow: 0 0 0 10px rgba(22, 128, 60, 0);
  }
}

@keyframes pulseBad {
  0% {
    box-shadow: 0 0 0 0 rgba(189, 44, 44, 0.24);
  }

  100% {
    box-shadow: 0 0 0 10px rgba(189, 44, 44, 0);
  }
}

@keyframes toastIn {
  0% {
    opacity: 0;
    transform: translate(-50%, -10px);
  }

  14%,
  82% {
    opacity: 1;
    transform: translate(-50%, 0);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -8px);
  }
}

@keyframes confetti {
  0% {
    opacity: 0;
    transform: rotate(calc(var(--i) * 21deg)) translateY(0) scale(0.7);
  }

  18% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: rotate(calc(var(--i) * 21deg)) translateY(-78px) scale(1);
  }
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr !important;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 290px;
    height: 100vh;
    z-index: 1200;
    transform: translateX(-100%);
    margin-left: 0 !important; /* Ignora el margen negativo de PC */
    box-shadow: 6px 0 26px rgba(0, 0, 0, 0.22);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    left: 14px !important; /* Esquina superior izquierda por defecto */
  }

  .sidebar-toggle.active {
    left: 304px !important; /* Desplazado al lado del drawer (290px + 14px) */
  }

  .module-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero,
  .content-grid,
  .theory-grid,
  .activities-grid,
  .final-grid,
  .study-grid,
  .practice-grid {
    grid-template-columns: 1fr;
  }

  .module-header {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .module-header .module-art.hero {
    grid-column: 1 / -1;
  }

  .score-box {
    position: static;
  }
}

@media (max-width: 760px) {
  .content {
    padding: 16px 12px 42px;
  }

  .sidebar {
    padding: 16px;
  }

  .module-nav,
  .overview-grid,
  .lab-controls,
  .output-grid,
  .string-preview,
  .graph-wrap,
  .game-grid,
  .game-intro {
    grid-template-columns: 1fr;
  }

  .hero {
    padding: 14px 0 22px;
  }

  .module-header {
    grid-template-columns: 1fr;
  }

  .module-art.hero {
    width: 100%;
  }

  .venn-circle {
    width: 150px;
    height: 134px;
  }

  .venn-circle.a {
    left: 26px;
  }

  .venn-circle.b {
    left: 118px;
  }

  .venn-label.a {
    left: 82px;
  }

  .venn-label.b {
    left: 238px;
  }
}

/* ==========================================================================
   NUEVOS ESTILOS: IDENTIDAD VISUAL, PESTAÑAS Y ACCESIBILIDAD DE AUDIO
   ========================================================================== */

/* Fuentes y títulos institucionales */
.brand h1,
.hero h2,
.module-header h2,
.module-card h3,
.section-heading h3,
.section-heading h4,
.final-panel h3,
.game-intro strong {
  font-family: var(--font-serif);
  font-weight: 700;
}

/* Grillas de pestañas */
.theory-grid,
.activities-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(340px, 1.1fr);
  gap: 16px;
  align-items: start;
}

/* Barra de pestañas interactiva (Tabs) */
.module-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 2px solid var(--line);
  padding-bottom: 2px;
  margin-bottom: 18px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.tab-button {
  padding: 10px 18px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
  font-size: 0.92rem;
  transition: all 150ms ease;
  margin-bottom: -2px;
  white-space: nowrap;
}

.tab-button:hover {
  color: var(--primary);
  background: var(--surface-strong);
}

.tab-button.active {
  color: var(--primary);
  border-color: var(--line) var(--line) var(--bg);
  background: var(--bg);
  box-shadow: 0 4px 0 var(--bg);
}

/* Contenido de pestañas */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: tabFadeIn 220ms ease-in-out;
}

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

/* Botones de audio Text-to-Speech (TTS) */
.tts-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  transition: all 120ms ease;
  flex-shrink: 0;
}

.tts-button::after {
  content: "";
  display: block;
  width: 14px;
  height: 14px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23617069" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"></polygon><path d="M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"></path></svg>');
  background-repeat: no-repeat;
  background-position: center;
}

.tts-button:hover {
  border-color: var(--primary);
  background: var(--surface-strong);
}

.tts-button:hover::after {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%2309843b" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"></polygon><path d="M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"></path></svg>');
}

.tts-button.playing {
  border-color: var(--bad);
  background: var(--accent-soft);
  animation: pulseTTS 1.2s infinite alternate;
}

.tts-button.playing::after {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23bd2c2c" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><rect x="4" y="4" width="16" height="16" rx="2" ry="2"></rect></svg>');
}

@keyframes pulseTTS {
  from {
    box-shadow: 0 0 0 0 rgba(189, 44, 44, 0.2);
  }
  to {
    box-shadow: 0 0 0 6px rgba(189, 44, 44, 0.05);
  }
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}

.section-heading.compact {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Modificaciones de colores estáticos para soporte de Modo Oscuro */
.study-card {
  background: var(--surface);
}

.game-card {
  background: var(--surface);
}

.practice-card {
  background: var(--surface);
}

.practice-solution {
  background: var(--surface-strong);
}

.output-box {
  background: var(--surface);
}

.field input,
.field select {
  background: var(--surface);
  color: var(--ink);
}

.definition-list dt {
  color: var(--primary);
}

.example-box {
  background: var(--accent-soft);
  color: var(--ink);
}

.study-card.worked {
  background: var(--accent-soft);
  color: var(--ink);
}

.nav-button:hover,
.nav-button.active {
  background: var(--surface-strong);
  color: var(--primary);
}

/* Estilos para el Enfoque en Ingeniería de Sistemas */
.systems-focus-card {
  margin-top: 18px;
  border-top: 2px solid var(--primary);
  background: rgba(9, 132, 59, 0.015);
}

[data-theme="dark"] .systems-focus-card {
  background: rgba(21, 179, 86, 0.02);
}

.systems-desc {
  font-size: 0.94rem;
  line-height: 1.5;
  color: var(--ink);
  margin-bottom: 12px;
}

.systems-examples {
  background: var(--surface-strong);
  border-radius: 6px;
  padding: 12px 14px;
}

.systems-examples strong {
  display: block;
  font-size: 0.88rem;
  color: var(--primary-strong);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.systems-examples-list {
  margin: 0;
  padding-left: 18px;
  font-size: 0.9rem;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Estilos para el Laboratorio con Retos */
.lab-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 16px;
  align-items: start;
}

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

.lab-challenge-panel {
  border-top: 2px solid var(--accent);
  background: rgba(217, 119, 6, 0.015);
}

.challenge-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.challenge-step,
.challenge-mission {
  background: var(--surface-strong);
  border-radius: 6px;
  padding: 12px 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.challenge-step > strong {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
  letter-spacing: 0.03em;
}

.challenge-mission > strong {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 6px;
  letter-spacing: 0.03em;
}

.challenge-step p,
.challenge-mission p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.challenge-step p strong,
.challenge-mission p strong {
  font-weight: 600;
  letter-spacing: 0.02em;
}

[data-theme="dark"] .challenge-step p,
[data-theme="dark"] .challenge-mission p {
  color: var(--ink);
}

/* Capa visual final del OVA */
.app-shell {
  background:
    radial-gradient(circle at 0% 0%, rgba(0, 168, 135, 0.18), transparent 34rem),
    linear-gradient(135deg, #f7fbff 0%, #f5f8fb 48%, #ffffff 100%);
}

[data-theme="dark"] .app-shell {
  background:
    radial-gradient(circle at 0% 0%, rgba(0, 168, 135, 0.16), transparent 34rem),
    linear-gradient(135deg, #091310 0%, #0b0f0c 48%, #101613 100%);
}

.sidebar {
  border-right: 0;
  background: linear-gradient(180deg, #073b2e 0%, #006b3f 58%, #082b3f 100%);
  color: #fff;
  box-shadow: 8px 0 30px rgba(8, 43, 63, 0.16);
}

.sidebar .brand {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.sidebar .brand-logo {
  width: 76px;
  max-width: 76px;
  padding: 6px;
  border-radius: var(--radius);
  background: #fff;
}

.sidebar .brand h1,
.sidebar .brand small,
.sidebar .eyebrow {
  color: #fff;
}

.sidebar .brand small {
  display: block;
  margin-top: 5px;
  color: #cfeee4;
  font-size: 0.82rem;
  line-height: 1.35;
}

.sidebar-progress {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.1);
}

.sidebar-progress .meter {
  background: rgba(255, 255, 255, 0.22);
}

.sidebar-progress .meter span {
  background: linear-gradient(90deg, var(--gold), #fff);
}

.sidebar-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #eafff8;
  font-size: 0.88rem;
}

.module-nav {
  gap: 9px;
}

.nav-button {
  color: #ecfff9;
  border-color: transparent;
  border-radius: var(--radius);
}

.nav-button:hover,
.nav-button.active {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.13);
}

.nav-index {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.nav-check {
  background: rgba(255, 255, 255, 0.3);
}

.nav-check.done {
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(255, 209, 102, 0.2);
}

.sidebar-footer .ghost-button {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
}

.sidebar-footer .ghost-button:hover {
  border-color: rgba(255, 255, 255, 0.38);
  background: rgba(255, 255, 255, 0.18);
}

#soundToggleButton[aria-pressed="false"] {
  color: #cfeee4;
  background: rgba(255, 255, 255, 0.08);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 420px) minmax(180px, 220px);
  gap: 22px;
  align-items: center;
  min-height: 300px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(241, 255, 251, 0.92)),
    radial-gradient(circle at 76% 34%, rgba(0, 168, 135, 0.18), transparent 18rem);
  box-shadow: var(--shadow);
}

[data-theme="dark"] .hero {
  background:
    linear-gradient(135deg, rgba(19, 25, 20, 0.96), rgba(8, 43, 63, 0.72)),
    radial-gradient(circle at 76% 34%, rgba(0, 168, 135, 0.18), transparent 18rem);
}

.hero h2 {
  color: var(--accent-strong);
}

[data-theme="dark"] .hero h2 {
  color: #eafff8;
}

.hero-media {
  display: grid;
  place-items: center;
  min-width: 0;
  margin: 0;
}

.hero-media img {
  width: min(100%, 420px);
  height: auto;
  filter: drop-shadow(0 18px 28px rgba(8, 43, 63, 0.16));
}

.progress-panel {
  border-color: #cfeee4;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(8, 43, 63, 0.06);
}

[data-theme="dark"] .progress-panel {
  border-color: #233126;
  background: var(--surface);
}

.progress-value {
  color: var(--primary);
}

.meter span {
  background: linear-gradient(90deg, var(--primary), var(--accent), var(--gold));
}

.section-heading {
  padding: 0 0 4px;
}

.section-heading h3 {
  color: var(--accent-strong);
}

[data-theme="dark"] .section-heading h3 {
  color: #eafff8;
}

.module-card,
.panel,
.quiz-panel,
.lab-panel,
.game-panel,
.study-panel,
.final-panel,
.score-box {
  border-color: var(--line);
  background: linear-gradient(180deg, #ffffff, #f9fcff);
  box-shadow: 0 10px 24px rgba(8, 43, 63, 0.07);
}

[data-theme="dark"] .module-card,
[data-theme="dark"] .panel,
[data-theme="dark"] .quiz-panel,
[data-theme="dark"] .lab-panel,
[data-theme="dark"] .game-panel,
[data-theme="dark"] .study-panel,
[data-theme="dark"] .final-panel,
[data-theme="dark"] .score-box {
  background: linear-gradient(180deg, var(--surface), var(--surface-strong));
}

.module-art {
  background:
    linear-gradient(135deg, rgba(0, 168, 135, 0.09), rgba(255, 209, 102, 0.1)),
    #fbfdfb;
}

.module-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 12px;
}

.module-card {
  min-height: 286px;
}

.module-number,
.pill {
  background: #e9fbf6;
  color: var(--primary);
}

.primary-button {
  border-color: var(--primary);
  background: var(--primary);
}

.primary-button:hover {
  background: #045733;
}

.secondary-button:hover,
.ghost-button:hover,
.chip-button:hover,
.answer-button:hover {
  border-color: var(--accent);
  background: #f0fffa;
}

.module-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 220px);
  background:
    linear-gradient(135deg, #073b2e 0%, #006b3f 56%, #082b3f 100%);
  box-shadow: var(--shadow);
}

.module-actions {
  grid-column: 1 / -1;
}

.module-header .module-art.hero {
  justify-self: end;
  height: 134px;
}

.module-tabs {
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 8px 20px rgba(8, 43, 63, 0.05);
}

[data-theme="dark"] .module-tabs {
  background: rgba(19, 25, 20, 0.76);
}

.tab-button.active {
  color: #fff;
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: none;
}

.ova-extra-challenge-panel {
  display: grid;
  grid-column: 1 / -1;
  gap: 14px;
  border-top: 3px solid var(--gold);
  background:
    linear-gradient(135deg, rgba(255, 209, 102, 0.13), rgba(0, 168, 135, 0.08)),
    var(--surface);
}

.ova-extra-challenge-panel > p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.ova-extra-note-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ova-extra-note {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  line-height: 1.45;
}

.ova-extra-note strong {
  display: block;
  margin-bottom: 4px;
  color: var(--primary);
}

.ova-extra-activity {
  display: grid;
  gap: 14px;
}

.ova-extra-activity-head {
  display: grid;
  gap: 5px;
}

.ova-extra-activity-head strong {
  color: var(--accent-strong);
  font-size: 1.05rem;
}

[data-theme="dark"] .ova-extra-activity-head strong {
  color: #eafff8;
}

.ova-extra-activity-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.ova-extra-classify-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.ova-extra-card {
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 178px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease;
}

.ova-extra-card:hover {
  transform: translateY(-1px);
  border-color: rgba(0, 168, 135, 0.45);
}

.ova-extra-card.correct {
  border-color: rgba(22, 128, 60, 0.76);
  background: rgba(34, 197, 94, 0.08);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.08);
}

.ova-extra-card.wrong {
  border-color: rgba(189, 44, 44, 0.68);
  background: rgba(239, 68, 68, 0.07);
}

.ova-extra-token {
  display: grid;
  place-items: center;
  min-height: 48px;
  padding: 8px;
  border-radius: var(--radius);
  background: #e9fbf6;
  color: var(--primary);
  font-weight: 900;
  text-align: center;
}

.ova-extra-card label {
  display: grid;
  gap: 6px;
}

.ova-extra-card label span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.ova-extra-card select,
.ova-extra-validator input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 9px 10px;
}

.ova-extra-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.ova-extra-actions,
.ova-extra-choice-row,
.ova-extra-validator {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.ova-extra-validator input {
  flex: 1 1 240px;
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.ova-extra-sample-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.ova-extra-sample-row.compact {
  gap: 7px;
}

.ova-extra-sample,
.ova-extra-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-weight: 850;
}

.ova-extra-sample:hover,
.ova-extra-chip:hover,
.ova-extra-sample.selected {
  border-color: var(--accent);
  background: #e9fbf6;
  color: var(--primary);
}

.ova-extra-formula {
  width: fit-content;
  max-width: 100%;
  padding: 10px 12px;
  border: 1px dashed #95d5c1;
  border-radius: var(--radius);
  background: #f0fbf7;
  color: #064331;
  overflow-x: auto;
}

.ova-extra-feedback {
  min-height: 44px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--muted);
  line-height: 1.45;
}

.ova-extra-feedback:empty {
  display: none;
}

.ova-extra-feedback strong {
  display: block;
  margin-bottom: 4px;
}

.ova-extra-feedback p {
  margin: 0;
}

.ova-extra-feedback.good {
  border-color: rgba(22, 128, 60, 0.45);
  background: rgba(34, 197, 94, 0.1);
  color: var(--good);
}

.ova-extra-feedback.bad {
  border-color: rgba(189, 44, 44, 0.42);
  background: rgba(239, 68, 68, 0.08);
  color: var(--bad);
}

.ova-extra-euler-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(180px, 0.9fr);
  gap: 12px;
  align-items: center;
}

.ova-extra-graph {
  width: 100%;
  min-height: 160px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(0, 168, 135, 0.08), rgba(255, 209, 102, 0.08));
}

.ova-extra-graph line {
  stroke: var(--primary);
  stroke-width: 7;
  stroke-linecap: round;
}

.ova-extra-graph circle {
  fill: #ffffff;
  stroke: var(--gold-strong);
  stroke-width: 5;
}

.ova-extra-graph text {
  fill: var(--accent-strong);
  font-size: 20px;
  font-weight: 900;
}

.ova-extra-degree-list {
  display: grid;
  gap: 8px;
}

.ova-extra-degree-list span {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-weight: 800;
}

.ova-extra-choice-row .selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 168, 135, 0.14);
}

@media (max-width: 1100px) {
  .ova-extra-classify-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .ova-extra-classify-grid,
  .ova-extra-euler-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1120px) {
  .hero {
    grid-template-columns: minmax(0, 1fr) minmax(210px, 300px);
  }

  .progress-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .sidebar .brand {
    grid-template-columns: 68px minmax(0, 1fr);
  }

  .sidebar .brand-logo {
    width: 68px;
    max-width: 68px;
  }

  .hero,
  .module-header {
    grid-template-columns: 1fr;
  }

  .hero-media {
    order: -1;
  }

  .module-header .module-art.hero {
    justify-self: stretch;
    width: 100%;
  }

  .ova-extra-note-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================
   ESTILOS DE DIÁLOGOS DE CONFIRMACIÓN Y ALERTAS PERSONALIZADAS
   ========================================== */
.ova-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(8, 43, 63, 0.4);
  backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.ova-modal-overlay.active {
  opacity: 1;
}

.ova-modal-card {
  width: min(92%, 440px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 26px;
  box-shadow: 0 24px 60px rgba(8, 43, 63, 0.25);
  transform: scale(0.92);
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

[data-theme="dark"] .ova-modal-card {
  background: var(--surface-strong);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.ova-modal-overlay.active .ova-modal-card {
  transform: scale(1);
}

.ova-modal-header h4 {
  margin: 0;
  font-size: 1.3rem;
  color: var(--primary);
  font-family: var(--font-serif);
  font-weight: 750;
}

.ova-modal-body p {
  margin: 0;
  font-size: 0.98rem;
  color: var(--ink);
  line-height: 1.55;
  opacity: 0.9;
}

.ova-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 10px;
}

/* ==========================================
   CORRECCIÓN DE BOTONES HOVER EN MODO OSCURO
   ========================================== */
[data-theme="dark"] .secondary-button:hover,
[data-theme="dark"] .ghost-button:hover,
[data-theme="dark"] .chip-button:hover,
[data-theme="dark"] .answer-button:hover {
  border-color: var(--primary-strong);
  background: rgba(21, 179, 86, 0.18) !important;
  color: #ffffff !important;
}

[data-theme="dark"] .secondary-button:hover svg,
[data-theme="dark"] .ghost-button:hover svg,
[data-theme="dark"] .chip-button:hover svg {
  stroke: #ffffff !important;
}

/* ==========================================
   AJUSTES PREMIUM ADICIONALES PARA MODO OSCURO
   ========================================== */
[data-theme="dark"] .concept-list li {
  background: var(--surface-strong);
  border-color: var(--line);
}

[data-theme="dark"] .system-use {
  background: var(--surface-strong);
  color: var(--ink);
}

[data-theme="dark"] .game-card {
  background: var(--surface-strong);
  border-color: var(--line);
}

[data-theme="dark"] .game-card.correct {
  background: rgba(34, 197, 94, 0.15) !important;
  border-color: rgba(34, 197, 94, 0.6);
  color: #22c55e;
}

[data-theme="dark"] .game-card.wrong {
  background: rgba(239, 68, 68, 0.15) !important;
  border-color: rgba(239, 68, 68, 0.6);
  color: #ef4444;
}

[data-theme="dark"] .game-card select {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

[data-theme="dark"] .study-card,
[data-theme="dark"] .practice-card {
  background: var(--surface-strong);
  border-color: var(--line);
}

[data-theme="dark"] .practice-solution {
  background: rgba(21, 179, 86, 0.12);
  color: var(--primary-strong);
}

[data-theme="dark"] .field input,
[data-theme="dark"] .field select {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

[data-theme="dark"] .output-box {
  background: var(--surface-strong);
  border-color: var(--line);
}

[data-theme="dark"] .truth-table,
[data-theme="dark"] .matrix-table {
  background: var(--surface-strong);
  border-color: var(--line);
}

[data-theme="dark"] .truth-table th,
[data-theme="dark"] .matrix-table th {
  background: rgba(21, 179, 86, 0.14);
  color: var(--ink);
}

[data-theme="dark"] .set-token,
[data-theme="dark"] .sample-token {
  background: var(--surface-strong);
  border-color: var(--line);
  color: var(--ink);
}

[data-theme="dark"] .set-token.active,
[data-theme="dark"] .sample-token.active {
  background: rgba(21, 179, 86, 0.22);
  border-color: var(--primary-strong);
  color: #ffffff;
}

[data-theme="dark"] .venn {
  background: var(--surface-strong);
  border-color: var(--line);
}

[data-theme="dark"] .bar-chart {
  background: var(--surface-strong);
  border-color: var(--line);
}

[data-theme="dark"] .graph-canvas {
  background: var(--surface-strong);
  border-color: var(--line);
}

[data-theme="dark"] .module-number,
[data-theme="dark"] .pill {
  background: rgba(21, 179, 86, 0.16);
  color: var(--primary-strong);
}

[data-theme="dark"] .ova-extra-token {
  background: rgba(21, 179, 86, 0.16);
  color: var(--primary-strong);
}

[data-theme="dark"] .ova-extra-sample:hover,
[data-theme="dark"] .ova-extra-chip:hover,
[data-theme="dark"] .ova-extra-sample.selected {
  background: rgba(21, 179, 86, 0.22);
  border-color: var(--primary-strong);
  color: #ffffff;
}

[data-theme="dark"] .ova-extra-formula {
  border-color: var(--primary);
  background: rgba(21, 179, 86, 0.1);
  color: #ffffff;
}

/* ==========================================
   ESTILOS DE CERTIFICADO DE COMPLETACIÓN
   ========================================== */
.ova-cert-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(8, 43, 63, 0.45);
  backdrop-filter: blur(8px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.ova-cert-overlay.active {
  opacity: 1;
}

.ova-cert-card {
  width: min(94%, 720px);
  background: #ffffff;
  border: 12px double #006b3f;
  border-radius: 8px;
  padding: 40px;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.35);
  transform: scale(0.92);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: #073b2e;
  position: relative;
  background-image: 
    radial-gradient(circle at 100% 100%, rgba(0, 168, 135, 0.05) 0%, transparent 12rem),
    radial-gradient(circle at 0% 0%, rgba(255, 209, 102, 0.05) 0%, transparent 12rem);
}

[data-theme="dark"] .ova-cert-card {
  background: #ffffff;
  color: #073b2e;
}

.ova-cert-overlay.active .ova-cert-card {
  transform: scale(1);
}

.ova-cert-logo {
  max-width: 160px;
  height: auto;
  margin-bottom: 16px;
}

.ova-cert-eyebrow {
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #ffd166;
  background: #006b3f;
  padding: 4px 14px;
  border-radius: 999px;
  margin-bottom: 20px;
}

.ova-cert-title {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 700;
  margin: 0 0 10px;
  color: #006b3f;
  line-height: 1.15;
}

.ova-cert-subtitle {
  font-size: 0.98rem;
  margin: 0 0 24px;
  font-style: italic;
  color: #556c64;
}

.ova-cert-name {
  font-family: var(--font-serif);
  font-size: 1.95rem;
  font-weight: 800;
  margin: 10px 0 16px;
  border-bottom: 2px solid #e2f0e8;
  padding-bottom: 8px;
  width: 80%;
  color: #073b2e;
}

.ova-cert-body {
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0 0 32px;
  max-width: 86%;
  color: #314b55;
}

.ova-cert-body strong {
  color: #006b3f;
  font-weight: 800;
}

.ova-cert-footer-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  width: 90%;
  margin-top: 10px;
}

.ova-cert-signature {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.ova-cert-signature-line {
  width: 140px;
  border-top: 1.5px solid #006b3f;
}

.ova-cert-signature-name {
  font-size: 0.74rem;
  font-weight: 800;
  color: #073b2e;
}

.ova-cert-signature-role {
  font-size: 0.65rem;
  color: var(--muted);
}

.ova-cert-badge {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  background: radial-gradient(circle, #ffd166 0%, #b77900 100%);
  border-radius: 50%;
  color: #fff;
  font-weight: 900;
  font-size: 0.74rem;
  box-shadow: 0 6px 16px rgba(183, 121, 0, 0.3);
  border: 3px dashed #fff;
  transform: rotate(-10deg);
}

.ova-cert-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

/* ==========================================
   PRINT LAYOUT PARA EL CERTIFICADO (窓口・印刷)
   ========================================== */
@media print {
  body * {
    visibility: hidden;
  }
  
  .ova-cert-overlay,
  .ova-cert-overlay * {
    visibility: visible;
  }
  
  .ova-cert-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: #ffffff !important;
    backdrop-filter: none !important;
    display: block !important;
    opacity: 1 !important;
  }
  
  .ova-cert-card {
    border: 12px double #006b3f !important;
    box-shadow: none !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 1.5cm !important;
    page-break-inside: avoid;
    box-sizing: border-box !important;
  }
  
  .ova-cert-actions {
    display: none !important;
  }
}

/* Pulsación brillante premium para el botón de menú hamburguesa */
.sidebar-toggle {
  animation: sidebarTogglePulse 2s infinite;
}

[data-theme="dark"] .sidebar-toggle {
  animation: sidebarTogglePulseDark 2s infinite;
}

@keyframes sidebarTogglePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 168, 135, 0.4), 0 4px 18px rgba(7, 59, 46, 0.25);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(0, 168, 135, 0), 0 4px 18px rgba(7, 59, 46, 0.35);
    border-color: rgba(0, 168, 135, 0.8);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(0, 168, 135, 0), 0 4px 18px rgba(7, 59, 46, 0.25);
  }
}

@keyframes sidebarTogglePulseDark {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 168, 135, 0.3), 0 4px 18px rgba(0, 0, 0, 0.4);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(0, 168, 135, 0), 0 4px 18px rgba(0, 0, 0, 0.6);
    border-color: rgba(0, 168, 135, 0.6);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(0, 168, 135, 0), 0 4px 18px rgba(0, 0, 0, 0.4);
  }
}

