:root {
  --bg: #f6f4ef;
  --bg-card: #ffffff;
  --texto: #23201a;
  --texto-suave: #5a554a;
  --acento: #7a1f2b;
  --acento-suave: #f3e3e5;
  --borde: #ddd6c8;
  --ok: #2e6b3f;
  --ok-bg: #e2f0e5;
  --mal: #a02a2a;
  --mal-bg: #f8e4e4;
  --sombra: 0 1px 3px rgba(35, 32, 26, .08);
}

[data-theme="oscuro"] {
  --bg: #191714;
  --bg-card: #24211c;
  --texto: #ece7dc;
  --texto-suave: #b3aa99;
  --acento: #d98894;
  --acento-suave: #3a2a2d;
  --borde: #403a30;
  --ok: #7fc78f;
  --ok-bg: #1f3325;
  --mal: #e08a8a;
  --mal-bg: #3a2222;
  --sombra: 0 1px 3px rgba(0, 0, 0, .4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="claro"]) {
    --bg: #191714;
    --bg-card: #24211c;
    --texto: #ece7dc;
    --texto-suave: #b3aa99;
    --acento: #d98894;
    --acento-suave: #3a2a2d;
    --borde: #403a30;
    --ok: #7fc78f;
    --ok-bg: #1f3325;
    --mal: #e08a8a;
    --mal-bg: #3a2222;
    --sombra: 0 1px 3px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

html { font-size: 17px; }

body {
  margin: 0;
  font-family: Georgia, 'Times New Roman', serif;
  background: var(--bg);
  color: var(--texto);
  line-height: 1.6;
}

a { color: var(--acento); }

.contenedor {
  max-width: 760px;
  margin: 0 auto;
  padding: 1rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  padding: .75rem 1rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--borde);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar a.marca {
  font-weight: bold;
  text-decoration: none;
  color: var(--texto);
}

.topbar .acciones { display: flex; gap: .5rem; }

button, .boton {
  font-family: inherit;
  font-size: .95rem;
  padding: .55rem 1rem;
  border: 1px solid var(--borde);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--texto);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  min-height: 44px;
}

button:hover, .boton:hover { border-color: var(--acento); }

button:focus-visible, .boton:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--acento);
  outline-offset: 2px;
}

button.primario, .boton.primario {
  background: var(--acento);
  border-color: var(--acento);
  color: #fff;
}

[data-theme="oscuro"] button.primario,
[data-theme="oscuro"] .boton.primario,
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="claro"]) button.primario { color: #2a1518; }
}

h1 { font-size: 1.5rem; line-height: 1.25; margin: 1rem 0 .5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; margin: 1.2rem 0 .3rem; }
h4 { font-size: 1rem; margin: 1rem 0 .2rem; }

.subtitulo { color: var(--texto-suave); margin-top: 0; }

details.bloque {
  background: var(--bg-card);
  border: 1px solid var(--borde);
  border-radius: 10px;
  margin: .7rem 0;
  box-shadow: var(--sombra);
  overflow: hidden;
}

details.bloque > summary {
  cursor: pointer;
  padding: .9rem 1rem;
  font-weight: bold;
  font-size: 1.02rem;
  list-style: none;
  position: relative;
  padding-right: 2.4rem;
}

details.bloque > summary::after {
  content: "▸";
  position: absolute;
  right: 1rem;
  transition: transform .15s;
}

details.bloque[open] > summary::after { transform: rotate(90deg); }

details.bloque > .contenido { padding: 0 1rem 1rem; }

.tabla-scroll { overflow-x: auto; }

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

th, td {
  border: 1px solid var(--borde);
  padding: .45rem .6rem;
  text-align: left;
  vertical-align: top;
}

th { background: var(--acento-suave); }

.cinta {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
  margin: .8rem 0;
}

.tarjeta-unidad {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--borde);
  border-radius: 10px;
  padding: .9rem 1rem;
  margin: .6rem 0;
  text-decoration: none;
  color: var(--texto);
  box-shadow: var(--sombra);
}

.tarjeta-unidad:hover { border-color: var(--acento); }

.tarjeta-unidad .num { color: var(--acento); font-weight: bold; margin-right: .4rem; }

.tarjeta-unidad .meta {
  display: block;
  font-size: .85rem;
  color: var(--texto-suave);
  margin-top: .2rem;
}

.etiqueta {
  display: inline-block;
  font-size: .75rem;
  padding: .1rem .5rem;
  border-radius: 999px;
  border: 1px solid var(--borde);
  color: var(--texto-suave);
  margin-left: .4rem;
}

.etiqueta.leida { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }

.progreso {
  background: var(--borde);
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
}

.progreso > div {
  background: var(--acento);
  height: 100%;
  width: 0;
  transition: width .3s;
}

.buscador {
  width: 100%;
  font-size: 1rem;
  padding: .7rem 1rem;
  border: 1px solid var(--borde);
  border-radius: 10px;
  background: var(--bg-card);
  color: var(--texto);
  font-family: inherit;
}

/* Quiz */
.quiz-opciones { display: flex; flex-direction: column; gap: .5rem; margin: .8rem 0; }

.quiz-opcion {
  text-align: left;
  width: 100%;
  padding: .8rem 1rem;
  line-height: 1.45;
}

.quiz-opcion .letra {
  font-weight: bold;
  margin-right: .5rem;
  color: var(--acento);
}

.quiz-opcion.correcta { background: var(--ok-bg); border-color: var(--ok); }
.quiz-opcion.incorrecta { background: var(--mal-bg); border-color: var(--mal); }
.quiz-opcion:disabled { cursor: default; }

.quiz-enunciado { font-weight: bold; margin-bottom: .3rem; }

.quiz-meta {
  display: flex;
  justify-content: space-between;
  color: var(--texto-suave);
  font-size: .85rem;
  margin-bottom: .5rem;
}

.quiz-feedback {
  border-radius: 8px;
  padding: .7rem .9rem;
  margin: .6rem 0;
  font-size: .93rem;
}

.quiz-feedback.ok { background: var(--ok-bg); color: var(--ok); }
.quiz-feedback.mal { background: var(--mal-bg); color: var(--mal); }

.quiz-pista {
  background: var(--acento-suave);
  border-radius: 8px;
  padding: .6rem .9rem;
  margin: .5rem 0;
  font-size: .9rem;
}

.quiz-item { border-top: 1px solid var(--borde); padding-top: 1rem; margin-top: 1rem; }
.quiz-item:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }

.resumen-resultado {
  background: var(--bg-card);
  border: 1px solid var(--borde);
  border-radius: 10px;
  padding: 1rem;
  margin: 1rem 0;
}

.nav-unidades {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  margin: 1.5rem 0;
}

footer {
  color: var(--texto-suave);
  font-size: .85rem;
  text-align: center;
  padding: 2rem 1rem;
}

@media (max-width: 480px) {
  html { font-size: 16px; }
  .nav-unidades { flex-direction: column; }
}
