:root{
  --bg:#f6f7fb;
  --card:#fff;
  --text:#0f172a;
  --muted:#64748b;
  --border:#e5e7eb;
  --primary:#2563eb;
  --primary2:#1d4ed8;
  --danger:#dc2626;
  --shadow: 0 8px 24px rgba(15, 23, 42, .06);
  --radius: 14px;
}

*{ box-sizing: border-box; }
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.wrap{
  max-width: 980px;
  margin: 22px auto;
  padding: 0 14px 40px;
}

.card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
  padding: 16px;
  margin-bottom: 14px;
}

/* Cabecera con separación visual */
.card.header{
  border-bottom: 4px solid rgba(37, 99, 235, 0.12);
}

/* TEST: marco completo azul y más aire */
.card.focus{
  border: 1px solid rgba(37,99,235,.22);
  box-shadow: 
    0 0 0 1px rgba(37,99,235,.05),     /* refuerzo suave del borde */
    0 6px 18px rgba(15,23,42,.08);     /* sombra difusa */
  margin-top: 22px;
  margin-bottom: 22px;
  padding-top: 20px;
  padding-bottom: 20px;
}


.card + .card{
  margin-top: 50px;
}

.title-row{
  display:flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

h1{
  margin: 0;
  font-size: 25px;
color:#0260ad;
}

.muted{ color: var(--muted); }
.section-title{
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 700;
}

.back{
  text-decoration:none;
  border:1px solid var(--border);
  padding: 8px 10px;
  border-radius: 999px;
  color: var(--text);
  background: #fff;
}

/* Índice más llamativo */
.back-primary{
  border-color: rgba(37,99,235,.35);
  background: rgba(37,99,235,.10);
  color: #1d4ed8;
  font-weight: 800;
}
.back-primary:hover{
  background: rgba(37,99,235,.16);
}

/* Toolbar base */
.toolbar{
  display:flex;
  align-items: flex-end;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.label{
  display:flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

select, input[type="number"], .search{
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  background: #fff;
  min-width: 140px;
}

.search{
  width: 100%;
  min-width: unset;
}

.btn{
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}

.btn.primary{
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}
.btn.primary:hover{ background: var(--primary2); }
.btn:hover{ filter: brightness(.98); }

.btn.danger{
  border-color: var(--danger);
  background: var(--danger);
  color:#fff;
}

/* Botón "Repasar fallos" cálido */
.btn.warning{
  border-color: rgba(245,158,11,.35);
  background: rgba(245,158,11,.18);
  color: #92400e;
  font-weight: 800;
}
.btn.warning:hover{
  background: rgba(245,158,11,.26);
}

/* Stats con icono + etiqueta */
.stats-pill{
  margin-left: auto;
  display:flex;
  gap: 14px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  flex-wrap: wrap;
}

.stats-pill .stat{
  display:flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  white-space: nowrap;
}

.stats-pill .ico{
  font-size: 16px;
  line-height: 1;
}

.stats-pill .lbl{
  color: var(--muted);
  font-weight: 700;
}

.stats-pill b{
  font-size: 16px;
  line-height: 1;
}

/* Botón reiniciar debajo de stats (a la derecha) */
.header-actions{
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

/* TEST */
.focus .qtitle{
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 800; /* pregunta en negrita */
}

.qbox{
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.options{
  display:flex;
  flex-direction: column;
  gap: 10px;
}

.option{
  display:flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
}

.option input{ margin-top: 3px; }

/* letras A/B/C sí en negrita */
.option b{ font-weight: 700; }

/* texto de respuesta NO en negrita */
.option div{ font-weight: 400; }
.option div *{ font-weight: inherit; }

.option.correct{
  border-color: rgba(34,197,94,.45);
  background:#b0d6b9;
}

.option.incorrect{
  border-color: rgba(239,68,68,.45);
  background: #deb1b1;
}

.actions{
  display:flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.result{
  margin-left: auto;
  font-weight: 700;
  color: var(--muted);
}

/* LISTADO */
.list{
  display:flex;
  flex-direction: column;
  gap: 10px;
}

.item{
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
}

.item:hover{
  background: rgba(37,99,235,.04);
  border-color: rgba(37,99,235,.25);
}

/* 2 líneas sí o sí */
.item .row-top{
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: nowrap;
}

.item .q-left{
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item .q-left b{
  font-weight: 800;      /* pregunta del listado en negrita */
  white-space: nowrap;
}

.item .q-right{
  flex: 0 0 auto;
  white-space: nowrap;
  font-weight: 700;
  color: #64748b;
  font-size: 13px;
}

.item .row-bottom{
  margin-top: 6px;
  white-space: nowrap;
}

/* Correcta: MISMO tamaño pero NO negrita */
.item .correcta-line{
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 16px;
  font-weight: 400;      /* <- importante: NO bold */
  color: #0f172a;
}

/* =========================
   CABECERA EN 2 FILAS LIMPIAS
   Fila 1: modo + nº + stats
   Fila 2: repasar (izq) + reiniciar (der)
   ========================= */

@media (min-width: 721px){

  /* La toolbar se convierte en grid de 2 filas */
  .toolbar{
    display: grid !important;
    grid-template-columns: 150px 180px 1fr; /* modo | nº | stats */
    grid-template-rows: auto auto;          /* fila 1 y fila 2 */
    column-gap: 14px;
    row-gap: 12px;                          /* aire entre filas */
    align-items: end;
    margin-top: 14px;
    padding-top: 6px;
  }

  /* Labels en la fila 1 */
  .toolbar .label:nth-of-type(1){
    grid-column: 1;
    grid-row: 1;
  }
  .toolbar .label:nth-of-type(2){
    grid-column: 2;
    grid-row: 1;
  }

  /* Stats en fila 1 a la derecha */
  .stats-pill{
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    margin-left: 0 !important;
    width: max-content;
  }

  /* Repasar fallos: fila 2 izquierda */
  #btnFallos{
    grid-column: 1 / span 2; /* ocupa izq (debajo de modo+nº) */
    grid-row: 2;
    justify-self: start;
    margin-top: 0 !important;
  }

  /* El botón reiniciar lo llevamos a fila 2 derecha */
  .header-actions{
    margin-top: 0 !important;
    display: grid !important;
    grid-template-columns: 1fr;
    justify-items: end;        /* derecha */
  }

  /* Para que visualmente quede alineado con la fila 2 de toolbar */
  .header-actions{
    position: relative;
    top: -44px;                /* sube a la altura de la fila 2 de la toolbar */
    margin-bottom: -44px;      /* compensa el hueco */
  }
}

/* En móvil: seguimos con apilado normal */
@media (max-width: 720px){
  .toolbar{
    display:flex !important;
    gap: 10px;
  }
  .header-actions{
    position: static;
    margin-top: 10px;
    justify-content: flex-end;
    margin-bottom: 0;
  }
}
