/* Planificador Diario — estilo de app nativa (referencia: Recordatorios y Calendario de iOS), pensado para leer sin gafas. */
:root {
  --fondo: #f2f2f7;
  --superficie: #ffffff;
  --texto: #1c1c1e;
  --texto-2: #636366;
  --texto-3: #8e8e93;
  --separador: #e3e3e8;
  --relleno: #e9e9ee;
  --acento: #0060df;
  --acento-oscuro: #004fb8;
  --acento-suave: #e5efff;
  --verde: #248a3d;
  --rojo: #d70015;
  --radio: 12px;
  --fuente: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --escala: 1;
  color-scheme: light;
}
html[data-letra="grande"] { --escala: 1.12; }
html[data-letra="muy-grande"] { --escala: 1.25; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; font-size: calc(19px * var(--escala)); }
body {
  margin: 0; background: var(--fondo); color: var(--texto);
  font-family: var(--fuente); font-size: 1rem; line-height: 1.35;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--acento); outline-offset: 2px; }
svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.oculto-visual { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35em;
  min-height: 54px; padding: 0 1em; border: 0; border-radius: var(--radio);
  font-weight: 600; font-size: 1rem; letter-spacing: -.01em;
}
.btn:active { opacity: .8; }
.btn-ancho { width: 100%; }
.btn-primario { background: var(--acento); color: #fff; }
.btn-primario:hover { background: var(--acento-oscuro); }
.btn-secundario { background: var(--acento-suave); color: var(--acento); }
.btn-hecho { background: #e7f4ea; color: var(--verde); }
.btn-hecho svg { stroke-width: 2.6; }
.btn-borrar { background: var(--superficie); color: var(--rojo); margin-top: 12px; }
.btn[disabled] { opacity: .5; }
.enlace { border: 0; background: none; color: var(--acento); font-weight: 400; padding: 8px 4px; min-height: 44px; }
.enlace.fuerte { font-weight: 600; }

/* ---------- entrada ---------- */
.entrada { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 40px 20px; background: var(--fondo); }
.entrada-caja { width: 100%; max-width: 400px; }
.logo {
  width: 76px; height: 76px; border-radius: 18px; background: var(--superficie); margin: 0 0 22px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.06);
  display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden;
}
.logo-mes { font-size: 12px; font-weight: 600; color: var(--rojo); text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; }
.logo-dia { font-size: 38px; font-weight: 300; line-height: 1; color: var(--texto); }
.entrada h1 { font-size: 1.75rem; line-height: 1.15; letter-spacing: -.02em; margin: 0 0 8px; font-weight: 700; }
.entrada .sub { color: var(--texto-2); margin: 0 0 26px; }
.entrada .grupo-campos { margin-bottom: 16px; }
.cambiar { margin: 18px 0 0; color: var(--texto-2); text-align: center; }

/* ---------- campos agrupados (estilo formulario de iOS) ---------- */
.grupo-campos { background: var(--superficie); border-radius: var(--radio); overflow: hidden; }
.celda-campo { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 0 16px; position: relative; }
.celda-campo + .celda-campo::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 1px solid var(--separador); }
.celda-campo > span:first-child { width: 6.2em; flex: none; font-weight: 500; }
.celda-campo input, .celda-campo textarea { flex: 1; min-width: 0; border: 0; background: none; padding: 14px 0; outline: none; font-size: 1rem; }
.celda-campo input::placeholder, .celda-campo textarea::placeholder { color: var(--texto-3); }
.celda-campo:focus-within { background: #fafafc; }
.celda-nota textarea { min-height: 84px; resize: vertical; }
.ver-clave { border: 0; background: none; color: var(--acento); padding: 8px 0 8px 8px; min-height: 44px; }
.error { background: #fdecee; color: var(--rojo); border-radius: var(--radio); padding: 12px 14px; margin: 0 0 14px; }

/* ---------- estructura ---------- */
.marco { max-width: 620px; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
.cabecera { padding: calc(14px + env(safe-area-inset-top)) 20px 6px; }
.cab-sobre { margin: 0; color: var(--texto-2); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; min-height: 1.2em; }
.cab-fila { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.cabecera h1 { margin: 0; font-size: 2rem; line-height: 1.15; letter-spacing: -.025em; font-weight: 700; }
.reloj { font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--texto-2); }
.contenido { padding: 10px 16px 0; }

.pestanas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgba(249,249,251,.94); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid rgba(0,0,0,.12); padding: 4px 8px env(safe-area-inset-bottom);
}
.pestanas-in { display: grid; grid-template-columns: repeat(3, 1fr); max-width: 620px; margin: 0 auto; }
.pestana { min-height: 62px; border: 0; background: none; color: var(--texto-3); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: .7rem; font-weight: 500; }
.pestana svg { font-size: 1.55rem; stroke-width: 1.8; }
.pestana[aria-current="page"] { color: var(--acento); }

/* ---------- tarjetas ---------- */
.tarjeta { background: var(--superficie); border-radius: var(--radio); padding: 18px; margin-bottom: 12px; }
.tarjeta.texto p { margin: 0 0 10px; }
.ahora-etq { margin: 0 0 4px; color: var(--acento); font-weight: 600; font-size: .85rem; }
.ahora-titulo { margin: 0; font-size: 1.75rem; line-height: 1.15; letter-spacing: -.02em; font-weight: 700; }
.ahora-hora { margin: 6px 0 0; color: var(--texto-2); font-variant-numeric: tabular-nums; }
.ahora-nota { margin: 10px 0 0; padding: 10px 12px; background: var(--fondo); border-radius: 8px; }
.barra { height: 6px; background: var(--relleno); border-radius: 3px; overflow: hidden; margin: 16px 0 6px; }
.barra > i { display: block; height: 100%; background: var(--acento); border-radius: 3px; }
.queda { margin: 0 0 16px; color: var(--texto-2); font-size: .85rem; }
.ahora .btn { margin-top: 16px; }
.barra + .queda + .btn { margin-top: 0; }
.despues { padding: 14px 18px; }
.despues-etq { margin: 0; color: var(--texto-2); font-size: .85rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.despues-titulo { margin: 2px 0 0; font-size: 1.15rem; font-weight: 600; }
.despues-cuando { margin: 2px 0 0; color: var(--texto-2); font-size: .85rem; }

.banda {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: left;
  background: var(--acento-suave); color: var(--texto); border: 0; border-radius: var(--radio); padding: 14px 16px; margin-bottom: 12px;
}
.banda strong { display: block; color: var(--acento); }
.banda span span { display: block; color: var(--texto-2); font-size: .85rem; }
.banda svg { color: var(--acento); flex: none; }

/* ---------- listas (celdas agrupadas) ---------- */
.seccion-cab { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 4px 8px; }
.seccion-cab h2 { margin: 0; font-size: 1.25rem; letter-spacing: -.015em; }
.seccion-cab span { color: var(--texto-2); font-size: .85rem; }
.grupo-titulo { margin: 24px 16px 7px; color: var(--texto-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
.lista { list-style: none; margin: 0; padding: 0; background: var(--superficie); border-radius: var(--radio); overflow: hidden; }
.lista li { position: relative; }
.lista li + li::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 1px solid var(--separador); z-index: 1; }
.celda {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 58px; padding: 10px 16px;
  background: none; border: 0; text-align: left; position: relative;
}
button.celda:active { background: #ececf1; }
.c-hora { width: 3.1em; flex: none; font-variant-numeric: tabular-nums; color: var(--texto-2); font-weight: 500; }
.c-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.c-titulo { font-size: 1.05rem; }
.c-sub { color: var(--texto-2); font-size: .8rem; margin-top: 2px; }
.c-ahora { color: var(--acento); font-weight: 600; }
.c-accion { color: var(--acento); }
.c-peligro { color: var(--rojo); }
.c-valor { color: var(--texto-2); }
.c-flecha { color: #c4c4c7; font-size: 1.1rem; display: flex; }
.c-check {
  width: 30px; height: 30px; flex: none; border-radius: 50%; border: 2px solid #c4c4c7;
  display: grid; place-items: center; color: transparent; font-size: 1.05rem;
}
.c-check svg { stroke-width: 3; }
.celda.pasada .c-titulo { color: var(--texto-2); }
.celda.es-ahora { background: var(--acento-suave); }
.celda.es-ahora::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--acento); }
.celda.es-ahora .c-hora { color: var(--acento); font-weight: 700; }
.celda.es-ahora .c-titulo { font-weight: 600; }
.celda.hecha .c-check { background: var(--verde); border-color: var(--verde); color: #fff; }
.celda.hecha .c-titulo { color: var(--texto-3); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.lista-quieta .celda { min-height: 50px; }
.pie-lista { margin: 8px 16px 0; color: var(--texto-2); font-size: .8rem; }

.vacio { background: var(--superficie); border-radius: var(--radio); padding: 28px 20px; margin-top: 6px; }
.vacio h2 { margin: 0 0 6px; font-size: 1.3rem; letter-spacing: -.015em; }
.vacio p { margin: 0 0 20px; color: var(--texto-2); }
.vacio .acciones { display: grid; gap: 10px; }

/* ---------- semana ---------- */
.segmentado { display: grid; grid-auto-columns: 1fr; grid-auto-flow: column; background: var(--relleno); border-radius: 10px; padding: 3px; gap: 2px; }
.segmentado button { min-height: 42px; border: 0; border-radius: 8px; background: none; font-weight: 500; font-size: .9rem; }
.segmentado button[aria-pressed="true"] { background: var(--superficie); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.tira-dias, .dias-sel { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 16px 0 0; }
.dia { border: 0; background: none; display: grid; place-items: center; min-height: 48px; padding: 0; }
.dia-letra { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 1rem; }
.dia.es-hoy .dia-letra { color: var(--rojo); }
.dia[aria-pressed="true"] .dia-letra { background: var(--acento); color: #fff; }
.dia.es-hoy[aria-pressed="true"] .dia-letra { background: var(--rojo); }
.dias-sel { margin: 0; background: var(--superficie); border-radius: var(--radio); padding: 8px 6px; }
.dias-sel .dia[aria-pressed="false"] .dia-letra { background: var(--fondo); color: var(--texto); }
.dias-sel .dia[aria-pressed="true"] .dia-letra { background: var(--acento); }
.atajos { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.atajos button { border: 0; background: var(--superficie); border-radius: 8px; padding: 0 12px; min-height: 40px; font-size: .85rem; color: var(--acento); }
.atajos button[aria-pressed="true"] { background: var(--acento-suave); font-weight: 600; }
.anadir { margin-top: 16px; }

.tabla-envoltura { overflow-x: auto; margin: 16px -16px 0; padding: 0 16px; -webkit-overflow-scrolling: touch; }
.tabla-semana { border-collapse: separate; border-spacing: 0; min-width: 720px; background: var(--superficie); border-radius: var(--radio); overflow: hidden; font-size: .8rem; }
.tabla-semana th, .tabla-semana td { padding: 9px 8px; border-bottom: 1px solid var(--separador); text-align: left; vertical-align: top; }
.tabla-semana thead th { color: var(--texto-2); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; }
.tabla-semana tbody th { color: var(--texto-2); font-weight: 500; font-variant-numeric: tabular-nums; position: sticky; left: 0; background: var(--superficie); border-right: 1px solid var(--separador); }
.tabla-semana tr:last-child th, .tabla-semana tr:last-child td { border-bottom: 0; }
.tabla-semana td { min-width: 88px; }
.tabla-semana td button { all: unset; cursor: pointer; display: block; line-height: 1.3; }
.tabla-semana td button + button { margin-top: 6px; }
.tabla-semana td button:focus-visible { outline: 2px solid var(--acento); }
.tabla-semana .col-hoy { background: #f5f8ff; }
.tabla-semana thead .col-hoy { color: var(--rojo); }

/* ---------- hoja del editor ---------- */
.capa { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.hoja { background: var(--fondo); width: 100%; max-width: 620px; max-height: 94dvh; overflow-y: auto; border-radius: 14px 14px 0 0; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }
.hoja.entra { animation: subir .25s cubic-bezier(.2,.8,.2,1); }
.hoja-cab { position: sticky; top: 0; z-index: 2; background: var(--fondo); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin: 0 -16px 8px; padding: 6px 8px; border-bottom: 1px solid var(--separador); }
.hoja-cab h2 { margin: 0; font-size: 1rem; font-weight: 600; }
.hoja-cab .enlace:first-child { justify-self: start; }
.hoja-cab .enlace:last-child { justify-self: end; }
.hoja .grupo-titulo { margin-left: 16px; }
.hoja > .btn-primario { margin-top: 24px; }
.lista-opciones .celda { min-height: 52px; }
.c-marca { color: transparent; font-size: 1.15rem; display: flex; }
.c-marca svg { stroke-width: 2.6; }
.celda[aria-checked="true"] .c-marca { color: var(--acento); }
@keyframes subir { from { transform: translateY(40px); opacity: 0; } }

/* ---------- ajustes ---------- */
.interruptor { width: 51px; height: 31px; flex: none; border-radius: 16px; border: 0; background: #d9d9de; padding: 2px; position: relative; transition: background-color .2s; }
.interruptor i { display: block; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: transform .2s; }
.interruptor[aria-checked="true"] { background: #34c759; }
.interruptor[aria-checked="true"] i { transform: translateX(20px); }
.hora-celda { border: 0; background: var(--fondo); border-radius: 8px; padding: 6px 10px; font-variant-numeric: tabular-nums; min-height: 40px; }
.pasos { margin: 0; padding-left: 1.3em; }
.pasos li { margin-bottom: 6px; }

/* ---------- avisos en pantalla ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(28,28,30,.92); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 500; font-size: .9rem;
  z-index: 60; max-width: calc(100% - 32px); text-align: center;
}
.alarma { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.4); display: grid; place-items: center; padding: 20px; }
.alarma .tarjeta { max-width: 400px; width: 100%; padding: 24px 20px 20px; margin: 0; }
.alarma .btn { margin-top: 20px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
