:root {
  --oro: #c9a227;
  --oro-osc: #a5821a;
  --oro-claro: #e6c86e;
  --fondo: #fffdf8;
  --panel: #ffffff;
  --texto: #3a3327;
  --gris: #8a8272;
  --borde: #ece3d0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fondo);
  color: var(--texto);
  line-height: 1.6;
  position: relative;
  min-height: 100vh;
}

/* ---- Precipitaciones doradas (fondo claro) ---- */
.lluvia { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.chispa {
  position: absolute; top: -24px; width: 7px; height: 7px; border-radius: 50%;
  background: radial-gradient(circle, var(--oro-claro), var(--oro));
  opacity: .35; box-shadow: 0 0 6px rgba(201,162,39,.35);
  animation: caer linear infinite;
}
@keyframes caer {
  0% { transform: translateY(-6vh); opacity: 0; }
  12% { opacity: .4; }
  100% { transform: translateY(110vh); opacity: 0; }
}
.chispa:nth-child(1){left:6%;animation-duration:11s;animation-delay:0s;}
.chispa:nth-child(2){left:16%;animation-duration:14s;animation-delay:2s;width:5px;height:5px;}
.chispa:nth-child(3){left:27%;animation-duration:9s;animation-delay:1s;}
.chispa:nth-child(4){left:38%;animation-duration:13s;animation-delay:4s;width:9px;height:9px;}
.chispa:nth-child(5){left:48%;animation-duration:10s;animation-delay:.5s;}
.chispa:nth-child(6){left:58%;animation-duration:15s;animation-delay:3s;width:5px;height:5px;}
.chispa:nth-child(7){left:68%;animation-duration:12s;animation-delay:1.5s;}
.chispa:nth-child(8){left:78%;animation-duration:9.5s;animation-delay:5s;width:8px;height:8px;}
.chispa:nth-child(9){left:88%;animation-duration:13.5s;animation-delay:2.5s;}
.chispa:nth-child(10){left:94%;animation-duration:11.5s;animation-delay:4.5s;width:5px;height:5px;}
.chispa:nth-child(11){left:33%;animation-duration:16s;animation-delay:6s;}
.chispa:nth-child(12){left:72%;animation-duration:14.5s;animation-delay:3.5s;width:6px;height:6px;}

.contenedor {
  position: relative; z-index: 1;
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px;
}

.tarjeta {
  background: var(--panel);
  border: 1px solid var(--borde);
  border-radius: 18px;
  padding: 32px 28px;
  max-width: 560px;
  width: 100%;
  box-shadow: 0 10px 30px rgba(140,110,20,.08);
}
.tarjeta-ancha { max-width: 760px; }

.marca { font-weight: 700; color: var(--oro-osc); margin-bottom: 12px; letter-spacing: .3px; }

h1 { font-size: 1.4rem; margin: 0 0 16px; color: var(--texto); }
p { margin: 0 0 14px; }

.boton {
  display: inline-block;
  background: var(--oro); color: #fff; text-decoration: none;
  border: 0; border-radius: 10px; padding: 12px 24px;
  font-size: 1rem; font-weight: 600; cursor: pointer; margin-top: 8px;
  box-shadow: 0 4px 12px rgba(201,162,39,.25);
}
.boton:hover { background: var(--oro-osc); }

.boton-secundario {
  background: #fff; color: var(--oro-osc); border: 1px solid var(--oro); box-shadow: none;
}
.boton-secundario:hover { background: #fdf6e6; }

.campo {
  width: 100%; padding: 12px 14px; font-size: 1rem;
  border: 1px solid var(--borde); border-radius: 10px; margin: 8px 0 4px;
  background: #fffdf6; color: var(--texto);
}
.campo:focus { outline: 2px solid var(--oro-claro); border-color: var(--oro); }

.error {
  background: #fdecea; color: #a12622; border: 1px solid #f5c6c2;
  border-radius: 8px; padding: 10px 12px;
}

.ok {
  background: #fdf4d8; color: #7a5b00; border: 1px solid var(--oro-claro);
  border-radius: 8px; padding: 10px 12px;
}

.pie { color: var(--gris); font-size: .85rem; margin-top: 18px; position: relative; z-index: 1; }

.datos {
  background: #fdf8ec; border: 1px solid var(--borde);
  border-radius: 10px; padding: 14px 16px; margin: 12px 0 18px;
}
.datos p { margin: 4px 0; }

/* ---- Horario: bloques ---- */
h2.bloque {
  font-size: 1.15rem; color: var(--oro-osc);
  margin: 26px 0 4px; border-top: 2px solid var(--borde); padding-top: 18px;
}
.expl { color: var(--gris); font-size: .85rem; margin: 0 0 14px; }

.fila-bloque { display: grid; grid-template-columns: 1fr 200px; gap: 22px; }
@media (max-width: 640px) { .fila-bloque { grid-template-columns: 1fr; } }

.campo-h { margin-bottom: 14px; }
.campo-h .tit { font-weight: 600; font-size: .95rem; }
.subh { color: var(--gris); font-size: .78rem; margin-bottom: 4px; }
.dlabel { margin-top: 12px; }

.reloj {
  width: 100%; max-width: 220px; padding: 10px 12px;
  border: 1px solid var(--borde); border-radius: 10px; font-size: 1rem;
  background: #fffdf6; color: var(--texto);
}
.reloj:focus, .nombre:focus { outline: 2px solid var(--oro-claro); border-color: var(--oro); }

.doble { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.doble > div { flex: 1; min-width: 110px; }
.mini { font-size: .75rem; color: var(--gris); }

.dias {
  background: #fdf8ec; border: 1px solid var(--borde);
  border-radius: 12px; padding: 14px 16px; height: fit-content;
}
.dias h3 { font-size: .9rem; margin: 0 0 8px; color: var(--oro-osc); }
.dia { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: .95rem; color: var(--texto); cursor: pointer; }
.dia input { width: 18px; height: 18px; accent-color: var(--oro); }

.colaciones { margin-top: 8px; border-top: 1px dashed var(--borde); padding-top: 14px; }
.colaciones .tit { font-weight: 600; }
.col-fila { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }

.btn-mas {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--oro);
  background: #fff; color: var(--oro-osc); font-size: 1.3rem; font-weight: 700;
  line-height: 1; cursor: pointer; flex: none;
}
.btn-mas:hover { background: #fdf6e6; }

/* ---- Actividades deportivas o recreativas ---- */
.nombre {
  width: 100%; padding: 10px 12px; border: 1px solid var(--borde);
  border-radius: 10px; font-size: 1rem; background: #fffdf6; color: var(--texto);
}
.act-card { border: 1px solid var(--borde); border-radius: 12px; padding: 16px; margin-bottom: 14px; background: #fffdf6; }
.act-card .campo-h { margin-bottom: 12px; }
.dias-fila { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.dias-fila label {
  display: flex; align-items: center; gap: 6px; border: 1px solid var(--borde);
  border-radius: 8px; padding: 6px 10px; font-size: .9rem; cursor: pointer; background: #fdf8ec;
}
.dias-fila input { width: 16px; height: 16px; accent-color: var(--oro); }

.btn-agregar {
  display: inline-flex; align-items: center; gap: 8px; background: #fff;
  border: 1px solid var(--oro); color: var(--oro-osc); border-radius: 10px;
  padding: 10px 16px; font-size: .95rem; font-weight: 600; cursor: pointer;
}
.btn-agregar:hover { background: #fdf6e6; }
.btn-agregar .sig { font-size: 1.2rem; }

/* ==================== Fase 3 · Tramo 2 — Hábitos ==================== */

/* Marcador de paso estilo sara.cl (rombo dorado) */
.paso-marca {
  font-size: .72rem; letter-spacing: .8px; text-transform: uppercase;
  color: var(--gris); font-weight: 600; margin-bottom: 10px;
}
.paso-marca .rombo { color: var(--oro); margin-right: 6px; font-size: .7rem; }

h1 em { color: var(--oro-osc); font-style: italic; }

.intro { color: var(--gris); font-size: .95rem; margin: 0 0 20px; line-height: 1.7; }

/* ---- Grilla de selección de hábitos ---- */
.grilla-habitos {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 12px; margin: 4px 0 8px;
}
.tarjeta-habito {
  position: relative; display: block; cursor: pointer;
  background: #fff; border: 1.5px solid var(--borde); border-radius: 14px;
  padding: 16px 14px; transition: border-color .15s, background .15s, box-shadow .15s;
}
.tarjeta-habito:hover { border-color: var(--oro-claro); box-shadow: 0 4px 14px rgba(201,162,39,.10); }
.tarjeta-habito.activa { border-color: var(--oro); background: #fdf8ec; }
.tarjeta-habito input { position: absolute; opacity: 0; pointer-events: none; }

.tarjeta-habito .check {
  position: absolute; top: 10px; right: 10px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--oro); color: #fff;
  display: none; align-items: center; justify-content: center;
}
.tarjeta-habito.activa .check { display: flex; }

.ico-habito { color: var(--oro-osc); display: block; line-height: 1; }
.tarjeta-habito.activa .ico-habito { color: var(--oro-osc); }
.nombre-habito { display: block; font-weight: 600; margin-top: 10px; color: var(--texto); }
.desc-habito { display: block; font-size: .8rem; color: var(--gris); margin-top: 3px; line-height: 1.45; }

/* ---- Barra de acción ---- */
.barra-accion {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--borde); gap: 12px;
}
.barra-accion .boton { margin-top: 0; }
.contador { font-size: .88rem; color: var(--gris); }
.contador #n-sel { color: var(--oro-osc); font-weight: 700; }

/* ---- Wizard ---- */
.progreso { height: 5px; background: #f2e8cf; border-radius: 4px; overflow: hidden; margin: 6px 0 20px; }
.progreso-barra { height: 100%; width: 0; background: var(--oro); border-radius: 4px; transition: width .25s ease; }
.cargando { color: var(--gris); padding: 20px 0; }

.wz-cab { display: flex; align-items: center; gap: 12px; }
.wz-ico {
  width: 48px; height: 48px; border-radius: 12px; background: #fdf4d8;
  display: flex; align-items: center; justify-content: center; color: var(--oro-osc);
  flex: 0 0 auto;
}
.wz-nombre { font-size: 1.15rem; font-weight: 600; margin: 0; color: var(--texto); }
.wz-sub { font-size: .8rem; color: var(--gris); margin: 0; }
.wz-desc { color: var(--gris); font-size: .9rem; margin: 12px 0 0; }

.wz-tip {
  background: #fdf4d8; border-radius: 10px; padding: 11px 14px;
  margin: 16px 0; font-size: .86rem; color: var(--oro-osc);
}

.wz-campos { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.wz-campo { display: flex; flex-direction: column; }
.wz-campo-ancho { grid-column: 1 / -1; }
.wz-campo label { font-size: .82rem; color: var(--gris); margin-bottom: 5px; }
.wz-campo .campo { margin: 0; }
@media (max-width: 560px) { .wz-campos { grid-template-columns: 1fr; } }

/* Horas (tipo fijo) */
.hora-fila { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.hora-fila .campo { margin: 0; flex: 1; }
.quita-hora {
  background: #fff; border: 1px solid var(--borde); border-radius: 8px;
  color: var(--gris); width: 38px; height: 42px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.quita-hora:hover { border-color: #e0a; color: #b23; border-color: #f0c9c4; }
.mini-boton {
  background: #fff; border: 1px dashed var(--oro-claro); color: var(--oro-osc);
  border-radius: 8px; padding: 8px 14px; font-size: .86rem; cursor: pointer; margin-top: 2px;
}
.mini-boton:hover { background: #fdf8ec; }

/* Días (tipo dias_semana) */
.dias-chips { display: flex; gap: 7px; flex-wrap: wrap; }
.dia-chip {
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer;
  background: #fff; border: 1.5px solid var(--borde); color: var(--gris);
  font-weight: 600; font-size: .9rem;
}
.dia-chip.on { background: var(--oro); border-color: var(--oro); color: #fff; }

/* ---- Resumen final ---- */
.listo-cab { text-align: center; margin-bottom: 18px; }
.listo-check {
  width: 54px; height: 54px; border-radius: 50%; background: #fdf4d8;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--oro-osc); margin-bottom: 8px;
}
.listo-cab h1 { margin: 0; }
.listo-cab .intro { margin-top: 6px; }

.lista-resumen { border: 1px solid var(--borde); border-radius: 12px; overflow: hidden; }
.fila-resumen {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px;
  border-bottom: 1px solid var(--borde);
}
.fila-resumen:last-child { border-bottom: 0; }
.ico-resumen { color: var(--oro-osc); flex: 0 0 auto; line-height: 1; }
.nombre-resumen { font-weight: 600; color: var(--texto); flex: 1; }
.cfg-resumen { font-size: .85rem; color: var(--gris); }

/* El panel usa dos botones seguidos: separarlos */
.datos + .boton { margin-right: 8px; }

/* ==================== Fase 3 · Tramo 2 · §5 — Bloques y actividades ==================== */

/* Bloque de día / actividades dentro del wizard */
.wz-bloque {
  border: 1px solid var(--borde); border-radius: 12px;
  padding: 14px 16px; margin: 12px 0;
}
.wz-bloque-cab {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 12px; flex-wrap: wrap;
}
.wz-bloque-tit { font-weight: 600; font-size: .98rem; color: var(--texto); }
.wz-bloque-dias {
  font-size: .78rem; background: #f1ede0; color: #7a5f12;
  padding: 4px 11px; border-radius: 20px;
}
.wz-bloque-sub { font-size: .8rem; color: var(--gris); margin: 0 0 12px; }

.wz-bloque-act { background: #fffdf5; border-color: var(--oro-claro); }

/* Fila de horario nombrado: nombre + hora + quitar */
.horarios-lista { margin-bottom: 4px; }
.horario-fila { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.horario-fila .campo { margin: 0; }
.horario-fila .campo-nombre { flex: 1.2; min-width: 0; }
.horario-fila .campo-hora { flex: .8; min-width: 0; max-width: 140px; }

.quita-fila, .quita-act {
  background: #fff; border: 1px solid var(--borde); border-radius: 8px;
  color: var(--gris); width: 40px; height: 44px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.quita-fila:hover, .quita-act:hover { border-color: #f0c9c4; color: #b23; }

/* Actividades: tarjeta interna por actividad */
.act-fila {
  border: 1px solid var(--borde); border-radius: 10px;
  padding: 12px; margin-bottom: 10px; background: #fff;
}
.act-fila-top { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.act-fila-top .campo-nombre { flex: 1; min-width: 0; margin: 0; }
.act-fila-horas { display: flex; gap: 10px; margin-bottom: 10px; }
.act-fila-horas label {
  flex: 1; display: flex; flex-direction: column;
  font-size: .74rem; color: var(--gris); gap: 4px;
}
.act-fila-horas .campo { margin: 0; }
.act-fila .dias-chips { margin-top: 2px; }
.act-fila .dia-chip { width: 34px; height: 34px; border-radius: 8px; font-size: .82rem; }

/* Resumen final: tarjeta por hábito con líneas por bloque/actividad */
.tarjeta-resumen {
  border: 1px solid var(--borde); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 12px; background: #fff;
}
.tarjeta-resumen-cab {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.tarjeta-resumen-cab .ico-resumen { color: var(--oro-osc); flex: 0 0 auto; line-height: 1; }
.tarjeta-resumen-cab .nombre-resumen { font-weight: 600; color: var(--texto); }

.lineas-resumen { display: flex; flex-direction: column; gap: 8px; }
.linea-resumen {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; background: #fdf8ec; border-radius: 8px;
}
.linea-tit { font-weight: 600; font-size: .84rem; color: var(--oro-osc); }
.linea-dias {
  font-size: .74rem; background: #f1ede0; color: #7a5f12;
  padding: 2px 8px; border-radius: 20px;
}
.linea-detalle { font-size: .84rem; color: var(--gris); margin-left: auto; }

/* ===== Fase 3 · Tramo 3: "Mis hábitos" (maqueta v2) ===== */
.mh-tarjeta {
  border: 1px solid var(--oro-claro); border-radius: 14px;
  padding: 16px 18px; margin-bottom: 14px; background: #fffefb;
  transition: opacity .25s ease;
}
.mh-tarjeta.mh-off { opacity: .55; background: #faf9f6; }
.mh-cab { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.mh-ico { color: var(--oro-osc); line-height: 1; flex: 0 0 auto; }
.mh-nombre { font-weight: 600; color: var(--texto); flex: 1; }
.mh-estado { font-size: .78rem; color: var(--gris); font-style: italic; }
.mh-lineas { margin-bottom: 10px; }
.mh-editor { margin: 6px 0 10px; }
.mh-editor-botones { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.mh-editor-botones .boton { margin-top: 0; }
.mh-pie {
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px dashed var(--oro-claro); padding-top: 10px;
}
.mh-acciones { display: flex; gap: 8px; }
.mh-apoyo { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.mh-apoyo-txt { font-size: .88rem; color: var(--texto); }
.mh-apoyo-check { position: absolute; opacity: 0; width: 0; height: 0; }
.mh-switch {
  width: 38px; height: 22px; border-radius: 11px; background: #ddd;
  position: relative; transition: background .2s ease; flex: 0 0 auto;
}
.mh-switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  transition: left .2s ease; box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.mh-apoyo-check:checked + .mh-switch { background: var(--oro); }
.mh-apoyo-check:checked + .mh-switch::after { left: 18px; }
.mh-apoyo-check:disabled + .mh-switch { opacity: .5; cursor: not-allowed; }
.mh-apoyo-check:focus-visible + .mh-switch { outline: 2px solid var(--oro-claro); }

/* ===== Ajustes Tramo 3 (petición del dueño 8-jul) ===== */
/* Volver al panel arriba en Mis hábitos */
.mh-volver-top { display: inline-block; margin-bottom: 14px; }

/* Frase junto al toggle de apoyo */
.mh-apoyo-txt { display: flex; flex-direction: column; line-height: 1.25; }
.mh-apoyo-frase { font-size: .74rem; color: var(--gris); font-weight: 400; }

/* Nota de guardado sobre la barra inferior */
.mh-nota-guardado {
  font-size: .82rem; color: var(--gris); text-align: right;
  margin: 4px 0 2px; font-style: italic;
}

/* Tarjeta pausada: se atenúa el contenido, NO los controles,
   para que el botón Activar quede claramente visible */
.mh-tarjeta.mh-off { opacity: 1; }
.mh-tarjeta.mh-off .mh-cab,
.mh-tarjeta.mh-off .mh-lineas { opacity: .55; }
.mh-tarjeta.mh-off .mh-pie { opacity: 1; }

/* Botón Activar destacado (mismo peso visual que los activos) */
.mh-toggle-estado[data-accion="activar"] {
  background: var(--oro); border-color: var(--oro);
  color: #fff; font-weight: 600;
}
.mh-toggle-estado[data-accion="activar"]:hover { background: var(--oro-osc); }

/* Panel de inicio: acciones ordenadas y equilibradas */
.panel-acciones { display: grid; gap: 10px; margin: 18px 0 14px; }
.panel-acciones .boton {
  margin: 0; display: block; text-align: center; width: auto;
}
.panel-salir { margin-top: 4px; }
.panel-salir .boton { display: block; width: 100%; text-align: center; margin: 0; }

/* ===== Fase 4: caja de conexión Google Calendar ===== */
.google-caja {
  border: 1px solid var(--oro-claro); border-radius: 12px;
  padding: 16px 18px; margin: 16px 0 18px; background: #fffefb;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-start;
}
.google-estado { margin: 0; font-size: .92rem; color: var(--texto); }
.google-on { color: #2e7d32; font-weight: 600; }
.google-off { color: #b26a00; }
.google-caja .boton, .google-caja .mini-boton { margin: 0; }
.google-caja form { margin: 0; }
.aviso { color: #b26a00; }

/* ===== Fase 4·B2: overlay "Espera mientras realizamos tu cambio" ===== */
/* Cubre la pantalla durante desactivar/reactivar/guardar de "Mis hábitos".
   Bloquea la interacción (evita clics repetidos) y da feedback claro. */
.mh-overlay {
  position: fixed; inset: 0; z-index: 999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(58, 51, 39, .45);
  padding: 20px;
}
.mh-overlay[hidden] { display: none; }
.mh-overlay-caja {
  background: var(--panel); border: 1px solid var(--oro-claro);
  border-radius: 12px; padding: 26px 30px; max-width: 320px;
  text-align: center; box-shadow: 0 8px 30px rgba(58,51,39,.18);
}
.mh-spinner {
  width: 40px; height: 40px; margin: 0 auto 14px;
  border: 3px solid var(--borde); border-top-color: var(--oro);
  border-radius: 50%; animation: mh-giro .9s linear infinite;
}
@keyframes mh-giro { to { transform: rotate(360deg); } }
.mh-overlay-titulo { font-size: 1rem; font-weight: 600; margin: 0 0 6px; color: var(--texto); }
.mh-overlay-sub { font-size: .9rem; margin: 0; color: var(--gris); }
/* Estado "listo": ícono de check en vez de spinner */
.mh-overlay.mh-listo .mh-spinner {
  animation: none; border: none;
  display: flex; align-items: center; justify-content: center;
}
.mh-check { color: #2e7d32; }

/* --- Política de privacidad (Fase 7A) --- */
.tarjeta h2 { font-size: 1.02rem; color: var(--oro-osc); margin: 20px 0 6px; }
.tarjeta h2:first-of-type { margin-top: 12px; }
.pie a { color: var(--gris); text-decoration: underline; }
.pie a:hover { color: var(--oro-osc); }
