:root {
  color-scheme: dark;
  --negro: #000;
  --amarillo: #FCC716;
  --blanco: #fff;
  --gris: #1a1a1a;
  --gris2: #2a2a2a;
  --texto2: #b5b5b5;
  --borde: #333;
  --fuente: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--negro); color: var(--blanco); font-family: var(--fuente); -webkit-tap-highlight-color: transparent; }
body { min-height: 100vh; min-height: 100dvh; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
#app { max-width: 560px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom)); }

/* Cabecera */
.cab { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.cab h1 { font-size: 20px; font-weight: 800; margin: 0; letter-spacing: .02em; }
.cab h1 b { color: var(--amarillo); }
.icono-btn { background: none; border: 1px solid var(--borde); border-radius: 12px; width: 44px; height: 44px; display: grid; place-items: center; font-size: 20px; }
.icono-btn:active { background: var(--gris2); }

/* Tarjetas */
.tarjeta { background: var(--gris); border: 1px solid var(--borde); border-radius: 18px; padding: 16px; margin-bottom: 14px; }
.tarjeta h2 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--texto2); margin: 0 0 12px; }
.fila { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.fila + .fila { margin-top: 10px; }
.etq { font-size: 15px; font-weight: 600; }
.sub { font-size: 13px; color: var(--texto2); }

/* Botones */
.btn { border: none; border-radius: 14px; padding: 14px 18px; font-weight: 800; font-size: 16px; background: var(--gris2); }
.btn:active { transform: scale(.98); }
.btn.prim { background: var(--amarillo); color: var(--negro); }
.btn.ancho { width: 100%; }
.btn.chico { padding: 9px 12px; font-size: 14px; border-radius: 10px; }
.btn.borde { background: none; border: 1px solid var(--borde); }
.btn.peligro { background: none; border: 1px solid #5a2020; color: #ff8a8a; }
.botones { display: flex; gap: 10px; margin-top: 14px; }
.botones > * { flex: 1; }

/* Selector de tiempo y números */
.paso { display: flex; align-items: center; gap: 6px; }
.paso button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--borde); background: var(--negro); font-size: 20px; font-weight: 700; line-height: 1; }
.paso button:active { background: var(--gris2); }
.paso input { width: 72px; text-align: center; background: var(--negro); border: 1px solid var(--borde); border-radius: 10px; height: 40px; font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.paso input:focus, .campo:focus { outline: 2px solid var(--amarillo); outline-offset: 1px; }
.campo { width: 100%; background: var(--negro); border: 1px solid var(--borde); border-radius: 10px; padding: 11px 12px; font-size: 16px; }

/* Lista de temporizadores */
.timer { display: flex; align-items: center; gap: 12px; background: var(--gris); border: 1px solid var(--borde); border-radius: 18px; padding: 14px; margin-bottom: 10px; }
.timer .info { flex: 1; min-width: 0; }
.timer .nom { font-weight: 800; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer .det { font-size: 13px; color: var(--texto2); margin-top: 3px; }
.play { width: 52px; height: 52px; border-radius: 50%; border: none; background: var(--amarillo); color: var(--negro); font-size: 22px; display: grid; place-items: center; flex: none; }
.vacio { color: var(--texto2); text-align: center; padding: 18px; }

/* Intervalos en el editor */
.intervalo { background: var(--negro); border: 1px solid var(--borde); border-left: 6px solid var(--c, var(--amarillo)); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.intervalo .fila:first-child { margin-bottom: 10px; }
.colores { display: flex; gap: 6px; }
.color { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; }
.color.sel { border-color: var(--blanco); box-shadow: 0 0 0 2px var(--negro) inset; }
.mini { background: none; border: 1px solid var(--borde); border-radius: 8px; width: 34px; height: 34px; font-size: 15px; }
.mini:disabled { opacity: .3; }
.intervalo .paso button { width: 36px; }
.intervalo .paso input { width: 64px; }

/* Interruptor */
.sw { position: relative; width: 50px; height: 30px; flex: none; }
.sw input { opacity: 0; width: 0; height: 0; position: absolute; }
.sw span { position: absolute; inset: 0; background: var(--gris2); border-radius: 30px; transition: .2s; }
.sw span::before { content: ''; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: var(--blanco); border-radius: 50%; transition: .2s; }
.sw input:checked + span { background: var(--amarillo); }
.sw input:checked + span::before { transform: translateX(20px); background: var(--negro); }
.sw input:focus-visible + span { outline: 2px solid var(--amarillo); outline-offset: 2px; }

/* Pantalla del temporizador */
.correr { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--fondo, var(--negro)); color: var(--tinta, var(--blanco)); transition: background .25s; padding: calc(14px + env(safe-area-inset-top)) 16px calc(18px + env(safe-area-inset-bottom)); user-select: none; -webkit-user-select: none; }
.correr .arriba { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 15px; }
.correr .arriba button { background: none; border: 2px solid currentColor; color: inherit; border-radius: 12px; height: 40px; padding: 0 14px; font-weight: 800; opacity: .85; }
.correr .centro { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; min-height: 0; }
.correr .fase { font-size: clamp(26px, 8vw, 44px); font-weight: 800; text-transform: uppercase; letter-spacing: .03em; line-height: 1.1; max-width: 100%; overflow-wrap: anywhere; }
.correr .reloj { font-size: clamp(96px, 34vw, 240px); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; letter-spacing: -.02em; }
.correr .cuenta { font-size: 18px; font-weight: 700; opacity: .85; }
.correr .sig { font-size: 15px; font-weight: 600; opacity: .75; margin-top: 8px; }
.correr .barra { height: 8px; border-radius: 8px; background: color-mix(in srgb, currentColor 22%, transparent); overflow: hidden; margin: 10px 0 14px; }
.correr .barra i { display: block; height: 100%; width: 0; background: currentColor; }
.correr .total { display: flex; justify-content: space-between; font-size: 14px; font-weight: 700; opacity: .85; margin-bottom: 12px; }
.correr .controles { display: flex; gap: 12px; justify-content: center; align-items: center; }
.correr .controles button { border: 2px solid currentColor; background: none; color: inherit; border-radius: 50%; width: 64px; height: 64px; font-size: 22px; display: grid; place-items: center; }
.correr .controles .grande { width: 88px; height: 88px; font-size: 32px; background: var(--tinta, var(--blanco)); color: var(--fondo, var(--negro)); border-color: var(--tinta, var(--blanco)); }
.correr.pausa .reloj { opacity: .45; }
.fin { text-align: center; }
.fin .reloj { font-size: 64px !important; }

.aviso { font-size: 13px; color: var(--texto2); line-height: 1.5; }
.pie { text-align: center; font-size: 12px; color: #777; margin-top: 22px; }

/* ---------- Hábitos ---------- */
#app { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.nav { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.94); border-top: 1px solid var(--borde); display: flex; justify-content: center; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); z-index: 5; backdrop-filter: blur(8px); }
.nav div { display: flex; width: 100%; max-width: 560px; }
.nav a { flex: 1; text-align: center; color: var(--texto2); text-decoration: none; font-size: 12px; font-weight: 700; padding: 6px 0; border-radius: 12px; }
.nav a b { display: block; font-size: 20px; line-height: 1.2; }
.nav a.act { color: var(--amarillo); }
.semana { display: grid; grid-template-columns: 28px repeat(7, 1fr) 28px; gap: 4px; align-items: center; margin-bottom: 16px; }
.semana > button.flecha { background: none; border: none; color: var(--texto2); font-size: 22px; padding: 0; height: 56px; }
.dia { background: var(--gris); border: 1px solid var(--borde); border-radius: 14px; padding: 7px 0; text-align: center; font-weight: 700; }
.dia small { display: block; font-size: 11px; color: var(--texto2); font-weight: 600; }
.dia span { font-size: 17px; }
.dia.hoy { border-color: var(--amarillo); }
.dia.sel { background: var(--amarillo); color: var(--negro); border-color: var(--amarillo); }
.dia.sel small { color: var(--negro); }
.dia.futuro { opacity: .45; }
.dia i { display: block; width: 6px; height: 6px; border-radius: 50%; margin: 3px auto 0; background: transparent; }
.dia i.ok { background: var(--verde, #2ECC71); }
.dia.sel i.ok { background: var(--negro); }
.progreso { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.progreso svg { flex: none; }
.progreso .t1 { font-size: 22px; font-weight: 800; }
.hab { display: flex; align-items: center; gap: 12px; background: var(--gris); border: 1px solid var(--borde); border-radius: 18px; padding: 12px 12px 12px 14px; margin-bottom: 10px; }
.hab.hecho { border-color: color-mix(in srgb, var(--c) 55%, var(--borde)); }
.hab .emo { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-size: 22px; background: color-mix(in srgb, var(--c) 18%, #000); flex: none; }
.hab .info { flex: 1; min-width: 0; cursor: pointer; }
.hab .nom { font-weight: 800; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hab.hecho .nom { color: var(--texto2); }
.hab .det { font-size: 13px; color: var(--texto2); margin-top: 3px; }
.check { width: 46px; height: 46px; border-radius: 50%; border: 2px solid var(--c); background: none; display: grid; place-items: center; font-size: 22px; font-weight: 800; color: var(--negro); flex: none; }
.check.on { background: var(--c); }
.cant { display: flex; align-items: center; gap: 4px; flex: none; }
.cant button { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--borde); background: var(--negro); font-size: 18px; font-weight: 800; }
.cant b { min-width: 48px; text-align: center; font-variant-numeric: tabular-nums; font-size: 15px; }
.cant b.ok { color: var(--c); }
.titulo-sec { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--texto2); margin: 20px 2px 10px; }
.dias-sin { font-size: 20px; font-weight: 800; color: var(--c); flex: none; text-align: right; line-height: 1.1; }
.dias-sin small { display: block; font-size: 11px; color: var(--texto2); font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--gris); border: 1px solid var(--borde); border-radius: 16px; padding: 12px 8px; text-align: center; }
.stat b { display: block; font-size: 22px; font-weight: 800; color: var(--c, var(--amarillo)); }
.stat span { font-size: 12px; color: var(--texto2); font-weight: 600; }
.mes .cab-mes { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-weight: 800; }
.mes .cab-mes span::first-letter { text-transform: uppercase; }
.mes .cab-mes button { background: none; border: 1px solid var(--borde); border-radius: 10px; width: 36px; height: 36px; font-size: 18px; }
.grilla { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.grilla .ds { text-align: center; font-size: 11px; color: var(--texto2); font-weight: 700; padding-bottom: 2px; }
.celda { aspect-ratio: 1; border-radius: 10px; border: 1px solid var(--borde); background: var(--negro); font-size: 13px; font-weight: 700; display: grid; place-items: center; padding: 0; position: relative; }
.celda.prog { background: color-mix(in srgb, var(--c) 30%, #000); }
.celda.ok { background: var(--c); color: var(--negro); border-color: var(--c); }
.celda.mal { background: #3a1414; border-color: #5a2020; color: #ff9b9b; }
.celda.off { opacity: .35; }
.celda.sel { outline: 2px solid var(--blanco); outline-offset: 1px; }
.celda.nota::after { content: ''; position: absolute; top: 4px; right: 4px; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .7; }
.celda:disabled { opacity: .2; }
textarea.campo { min-height: 90px; resize: vertical; line-height: 1.45; }
.emojis { display: flex; flex-wrap: wrap; gap: 6px; }
.emojis button { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--borde); background: var(--negro); font-size: 20px; }
.emojis button.sel { border-color: var(--amarillo); background: var(--gris2); }
.seg { display: flex; background: var(--negro); border: 1px solid var(--borde); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: none; background: none; border-radius: 9px; padding: 9px 4px; font-weight: 700; font-size: 13px; color: var(--texto2); }
.seg button.sel { background: var(--amarillo); color: var(--negro); }
.diasem { display: flex; gap: 5px; }
.diasem button { flex: 1; height: 38px; border-radius: 10px; border: 1px solid var(--borde); background: var(--negro); font-weight: 800; font-size: 13px; }
.diasem button.sel { background: var(--amarillo); color: var(--negro); border-color: var(--amarillo); }
.campo-lbl { display: block; font-size: 13px; font-weight: 700; color: var(--texto2); margin: 14px 0 7px; }
.sug { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--borde); }
.sug:last-child { border-bottom: none; }
.sug .info { flex: 1; }
.tarea { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--borde); }
.tarea:last-child { border-bottom: none; }
.tarea .txt { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tarea.hecha .txt { color: var(--texto2); text-decoration: line-through; }
.tarea .check { width: 30px; height: 30px; font-size: 15px; border-color: var(--amarillo); --c: var(--amarillo); }
.tarea .fecha { font-size: 12px; color: var(--texto2); }
.tarea .fecha.vencida { color: #ff8a8a; }
.nueva { display: flex; gap: 8px; }
.nota-item { border-left: 4px solid var(--c); padding: 4px 0 4px 12px; margin-bottom: 16px; }
.nota-item .cab-nota { font-size: 13px; color: var(--texto2); font-weight: 700; margin-bottom: 4px; }
.nota-item p { margin: 0; white-space: pre-wrap; line-height: 1.5; overflow-wrap: anywhere; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 12px; scrollbar-width: none; }
.chip { flex: none; border: 1px solid var(--borde); background: var(--negro); border-radius: 20px; padding: 7px 12px; font-size: 13px; font-weight: 700; }
.chip.sel { background: var(--amarillo); color: var(--negro); border-color: var(--amarillo); }

/* Volver a RAMS Entrena (cuando se abre desde ahí) */
.volver-entrena { display: inline-block; color: var(--amarillo); text-decoration: none; font-weight: 700; font-size: 14px; padding: 4px 0 10px; }
