@import url('/fonts/fonts.css');

/* ===========================================================================
   Lutea — sistema visual
   Basado en DESIGN.md: lienzo crema, cámaras oscuras, bordes de 2px, radios
   sobredimensionados y CERO sombras. La separación es por relleno y borde.
   =========================================================================== */

:root {
  /* Paleta */
  --lavender: #f0d7ff;
  --forest:   #034f46;
  --ember:    #ffa946;
  --ink:      #1a1a1a;
  --cream:    #ffffeb;
  --stone:    #e4e4d0;
  --fog:      #8a8a80;
  --charcoal: #222222;
  --white:    #ffffff;

  /* Roles (tema claro) */
  --canvas:      var(--cream);
  --surface:     var(--cream);
  --chamber:     var(--ink);
  --chamber-txt: var(--cream);
  --text:        var(--ink);
  --text-muted:  var(--fog);
  --border:      var(--ink);
  --accent:      var(--lavender);
  --accent-txt:  var(--ink);
  --secondary:   var(--forest);
  --divider:     var(--stone);

  /* Tipografía */
  --font-display: 'EB Garamond', 'Cormorant Garamond', Georgia, serif;
  --font-ui: 'Figtree', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --text-caption: 0.875rem;
  --text-body-sm: 1rem;
  --text-body: 1.25rem;
  --text-subheading: 1.5rem;

  /* Espaciado */
  --s8: 8px;  --s16: 16px; --s24: 24px; --s32: 32px;
  --s40: 40px; --s48: 48px; --s64: 64px; --s80: 80px;

  /* Formas */
  --r-card: 32px;
  --r-btn: 12px;
  --r-input: 12px;
  --r-pill: 9999px;
  --r-section: 40px;

  --page: 1100px;
  --bw: 2px;

  --tabbar-h: 76px;
}

/* Tema oscuro: se invierten los papeles, no se inventan colores nuevos.
   Bare :root define el claro; se redefine bajo prefers-color-scheme y bajo
   [data-theme] para que el conmutador gane en ambos sentidos. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --canvas:      #141413;
    --surface:     #1f1f1d;
    --chamber:     var(--cream);
    --chamber-txt: var(--ink);
    --text:        var(--cream);
    --text-muted:  #a3a399;
    --border:      var(--cream);
    --divider:     #3a3a36;
  }
}
:root[data-theme='dark'] {
  --canvas:      #141413;
  --surface:     #1f1f1d;
  --chamber:     var(--cream);
  --chamber-txt: var(--ink);
  --text:        var(--cream);
  --text-muted:  #a3a399;
  --border:      var(--cream);
  --divider:     #3a3a36;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--text-body-sm);
  line-height: 1.4;
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 0.98;
  letter-spacing: -0.02em;
  margin: 0;
}

.display { font-size: clamp(2.75rem, 11vw, 5rem); line-height: 0.9; letter-spacing: -0.03em; }
.h-lg    { font-size: clamp(2rem, 7vw, 3.25rem); }
.h-md    { font-size: clamp(1.6rem, 5vw, 2.25rem); }
.h-sm    { font-size: 1.35rem; letter-spacing: -0.01em; }

p { margin: 0 0 var(--s16); }
.muted { color: var(--text-muted); }
.caption { font-size: var(--text-caption); }
.center { text-align: center; }

a { color: inherit; }

:where(button, a, input, select, textarea):focus-visible {
  outline: 3px solid var(--secondary);
  outline-offset: 2px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.hidden { display: none !important; }

/* --- Botones -------------------------------------------------------------- */

.btn {
  font-family: var(--font-ui);
  font-size: var(--text-body-sm);
  font-weight: 500;
  padding: 14px 24px;
  border: var(--bw) solid var(--border);
  border-radius: var(--r-btn);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s8);
  min-height: 48px;
  transition: transform .06s ease;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--accent-txt); border-color: var(--ink); }
.btn-ghost { background: transparent; border-color: transparent; text-decoration: underline; min-height: 40px; padding: 8px 12px; }
.btn-danger { background: transparent; border-color: var(--border); }
.btn-sm { padding: 8px 16px; min-height: 40px; font-size: var(--text-caption); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; gap: var(--s8); flex-wrap: wrap; }

/* --- Formularios ---------------------------------------------------------- */

.field { display: block; margin-bottom: var(--s16); }
.field > span {
  display: block; font-size: var(--text-caption); font-weight: 600;
  margin-bottom: 6px; letter-spacing: .01em;
}
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], select, textarea {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 1rem; /* 16px: por debajo de esto iOS hace zoom al enfocar */
  padding: 13px 14px;
  border: var(--bw) solid var(--border);
  border-radius: var(--r-input);
  background: var(--surface);
  color: var(--text);
  min-height: 48px;
}
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
select { appearance: none; background-image: none; }

/* Campo de fecha: texto con máscara DD/MM/AAAA + botón que abre el selector nativo.
   El <input type="date"> real se queda oculto detrás; solo se usa como calendario, porque
   pintado se ve con el formato del navegador (MM/DD/YYYY si está en inglés). */
.date-field { position: relative; display: flex; align-items: center; }
.date-field .date-text { padding-right: 56px; font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.date-field .date-text[aria-invalid='true'] { border-color: var(--ember); }
.date-pick {
  position: absolute; right: 6px;
  width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: 10px; background: transparent; color: var(--text);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.date-pick svg { width: 21px; height: 21px; }
.date-pick:active { transform: scale(.92); }
/* Invisible pero enfocable por showPicker(): display:none impediría abrir el calendario. */
.date-native {
  position: absolute; right: 14px; bottom: 0;
  width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; min-height: 0;
}

.error-box, .ok-box {
  border: var(--bw) solid var(--border);
  border-radius: var(--r-btn);
  padding: 12px 16px;
  margin-bottom: var(--s16);
  font-size: var(--text-caption);
}
.error-box { background: var(--ember); color: var(--ink); }
.ok-box { background: var(--secondary); color: var(--cream); }

/* --- Tarjetas y cámaras --------------------------------------------------- */

.card {
  background: var(--surface);
  border: var(--bw) solid var(--border);
  border-radius: var(--r-card);
  padding: var(--s24);
  margin-bottom: var(--s16);
}
.chamber {
  background: var(--chamber);
  color: var(--chamber-txt);
  border-radius: var(--r-section);
  padding: var(--s32) var(--s24);
  margin-bottom: var(--s16);
  border: var(--bw) solid var(--chamber);
}
.chamber .muted { color: color-mix(in srgb, var(--chamber-txt) 62%, transparent); }
.accent-card { background: var(--accent); color: var(--ink); border-color: var(--ink); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--secondary); color: var(--cream);
  border-radius: var(--r-pill);
  padding: 7px 14px;
  font-size: var(--text-caption); font-weight: 500;
  border: var(--bw) solid transparent;
}
.badge-outline { background: transparent; color: inherit; border-color: currentColor; }
.badge-ember { background: var(--ember); color: var(--ink); }

/* ===========================================================================
   Estructura de página
   =========================================================================== */

#app { min-height: 100dvh; display: flex; flex-direction: column; }

.screen { display: none; }
.screen.active { display: block; }
/* Las pantallas centradas solo se vuelven flex cuando están activas: si no, `display: flex`
   de .centered-screen empata en especificidad con .screen y gana por orden, y no se ocultan. */
.screen.centered-screen.active { display: flex; }

.wrap { width: 100%; max-width: var(--page); margin: 0 auto; padding: 0 var(--s16); }

main { flex: 1; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s32)); }

.view { display: none; }
.view.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.view-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--s16); padding: var(--s24) 0 var(--s16);
}

/* --- Cabecera ------------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--canvas);
  padding: var(--s8) 0;
  padding-top: calc(var(--s8) + env(safe-area-inset-top));
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s8);
  border: var(--bw) solid var(--border);
  border-radius: var(--r-pill);
  padding: 8px 8px 8px 18px;
  background: var(--surface);
}
.topbar-actions { display: flex; align-items: center; gap: 6px; }

/* Botones redondos de la barra: Admin y el conmutador claro/oscuro. Están arriba y no en
   la barra de pestañas porque abajo solo hay cinco huecos y son los del uso diario. */
.icon-round {
  width: 42px; height: 42px; flex: none;
  border: var(--bw) solid var(--border); border-radius: 50%;
  background: transparent; color: var(--text);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem; line-height: 1; padding: 0;
}
.icon-round svg { width: 21px; height: 21px; }
.icon-round:active { transform: scale(.94); }
.icon-round[aria-current='true'] { background: var(--accent); color: var(--ink); border-color: var(--ink); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.brand span { font-size: 1.05rem; letter-spacing: -0.01em; }

/* El logo va como <use> de un sprite inline, no como <img>: así hereda `currentColor` y
   sigue al tema elegido en Ajustes. Un SVG cargado con <img> no ve el CSS de la página, y
   con su propia media query se volvía invisible al forzar un tema contrario al del sistema. */
.brand-mark { width: 30px; height: 30px; display: block; color: var(--text); flex: none; }
.auth-logo { width: 92px; height: 92px; display: block; margin: 0 auto var(--s16); color: var(--text); }

.desktop-nav { display: none; gap: 4px; }
.desktop-nav button {
  font-family: var(--font-ui); font-size: var(--text-caption); font-weight: 500;
  background: transparent; border: var(--bw) solid transparent; border-radius: var(--r-pill);
  padding: 9px 16px; cursor: pointer; color: var(--text);
}
.desktop-nav button[aria-current='true'] { background: var(--accent); color: var(--ink); border-color: var(--ink); }

/* --- Barra de pestañas (móvil) -------------------------------------------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--canvas);
  border-top: var(--bw) solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-inner {
  max-width: var(--page); margin: 0 auto;
  display: grid; grid-template-columns: repeat(5, 1fr);
  align-items: center; height: var(--tabbar-h);
}
.tab {
  background: none; border: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-family: var(--font-ui); font-size: 0.7rem; font-weight: 500;
  color: var(--text-muted); padding: 6px 2px; height: 100%;
  justify-content: center;
}
.tab svg { width: 24px; height: 24px; }
.tab[aria-current='true'] { color: var(--text); }
.tab[aria-current='true'] .tab-dot { opacity: 1; }
.tab-dot {
  width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0;
}

/* El ⊕ central: el gesto que sostiene el producto. Grande y siempre alcanzable. */
.tab-add {
  justify-self: center;
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--accent); color: var(--ink);
  border: var(--bw) solid var(--ink);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0;
  margin-top: -18px;
}
.tab-add svg { width: 30px; height: 30px; }
.tab-add:active { transform: scale(.94); }

/* ===========================================================================
   Vista Hoy
   =========================================================================== */

.today-hero { text-align: center; padding: var(--s24) 0 var(--s8); }

.wheel-wrap { display: flex; justify-content: center; margin: var(--s8) 0 var(--s24); }
.wheel { width: min(300px, 74vw); height: auto; overflow: visible; }
.wheel-day {
  font-family: var(--font-display); font-size: 62px; fill: var(--text);
  text-anchor: middle; dominant-baseline: central;
}
.wheel-label {
  font-family: var(--font-ui); font-size: 12px; font-weight: 600;
  fill: var(--text-muted); text-anchor: middle; letter-spacing: .08em; text-transform: uppercase;
}

.headline { font-family: var(--font-display); font-size: clamp(2rem, 8vw, 3rem); line-height: 1; margin-bottom: var(--s8); }
.headline-sub { color: var(--text-muted); max-width: 34ch; margin: 0 auto var(--s16); }

.legend { display: flex; flex-wrap: wrap; gap: var(--s8); justify-content: center; margin-top: var(--s16); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-caption); }
.legend-key { width: 18px; height: 18px; border: var(--bw) solid var(--border); border-radius: 5px; flex: none; }

.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--s8); }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--s16); }
.stat { }
.stat-num { font-family: var(--font-display); font-size: 2.4rem; line-height: 1; display: block; }
.stat-lbl { font-size: var(--text-caption); color: var(--text-muted); }

/* ===========================================================================
   Hoja de registro
   =========================================================================== */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: color-mix(in srgb, var(--ink) 55%, transparent);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--canvas);
  border: var(--bw) solid var(--border);
  border-radius: var(--r-section) var(--r-section) 0 0;
  width: 100%; max-width: 640px;
  max-height: 92dvh; display: flex; flex-direction: column;
  animation: rise .22s ease;
}
@keyframes rise { from { transform: translateY(18px); } to { transform: none; } }

.sheet-head { padding: var(--s16) var(--s16) var(--s8); border-bottom: var(--bw) solid var(--divider); }
.sheet-title-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s8); margin-bottom: var(--s8); }
.sheet-body { overflow-y: auto; padding: var(--s16); flex: 1; -webkit-overflow-scrolling: touch; }
.sheet-foot {
  padding: var(--s16);
  padding-bottom: calc(var(--s16) + env(safe-area-inset-bottom));
  border-top: var(--bw) solid var(--divider);
}

/* Tira de días: corregir ayer es el caso común, no la excepción. */
.daystrip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.daystrip::-webkit-scrollbar { display: none; }
.daychip {
  flex: none; min-width: 52px; padding: 8px 6px;
  border: var(--bw) solid var(--border); border-radius: var(--r-btn);
  background: var(--surface); color: var(--text);
  font-family: var(--font-ui); cursor: pointer; text-align: center; line-height: 1.15;
}
.daychip b { display: block; font-size: 1.05rem; font-weight: 600; }
.daychip small { font-size: 0.66rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.daychip[aria-pressed='true'] { background: var(--accent); color: var(--ink); }
.daychip[aria-pressed='true'] small { color: var(--ink); }
.daychip.has-data { border-style: double; border-width: 4px; }

/* Rejilla completa de categorías: nada de carrusel horizontal que esconda contenido. */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: var(--s8); }
.cat-btn {
  border: var(--bw) solid var(--border); border-radius: 18px;
  background: var(--surface); color: var(--text);
  padding: 12px 6px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  font-family: var(--font-ui); font-size: 0.78rem; font-weight: 500; line-height: 1.2;
  min-height: 82px; justify-content: center; text-align: center;
}
.cat-btn .emoji { font-size: 1.45rem; line-height: 1; }
.cat-btn[aria-pressed='true'] { background: var(--accent); color: var(--ink); }
.cat-btn .n {
  font-size: 0.66rem; font-weight: 700;
  background: var(--ink); color: var(--cream);
  border-radius: var(--r-pill); padding: 1px 7px;
}

/* Cuadrícula de opciones: objetivos táctiles enormes, se acierta con el pulgar. */
.opt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--s8); }
.opt-btn {
  border: var(--bw) solid var(--border); border-radius: var(--r-btn);
  background: var(--surface); color: var(--text);
  padding: 16px 12px; cursor: pointer;
  font-family: var(--font-ui); font-size: 0.95rem; font-weight: 500;
  min-height: 60px; text-align: left;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.opt-btn[aria-pressed='true'] { background: var(--accent); color: var(--ink); }
.opt-btn[aria-pressed='true']::after { content: '✓'; font-weight: 700; }
.opt-btn .pips { display: flex; gap: 3px; }
.opt-btn .pip { width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid currentColor; }
.opt-btn .pip.on { background: currentColor; }

.info-note {
  border-left: 4px solid var(--secondary);
  padding: 10px 0 10px 14px; margin: var(--s8) 0 var(--s16);
  font-size: var(--text-caption); color: var(--text-muted);
}

/* ===========================================================================
   Calendario
   =========================================================================== */

.cal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s8); margin-bottom: var(--s16); }
.cal-month { font-family: var(--font-display); font-size: 1.75rem; text-transform: capitalize; }
.cal-nav { display: flex; gap: 6px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: var(--r-btn);
  border: var(--bw) solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-dow {
  text-align: center; font-size: 0.68rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-muted); padding-bottom: 4px;
}
.cal-cell {
  position: relative; aspect-ratio: 1; min-height: 42px;
  border: var(--bw) solid var(--divider); border-radius: 12px;
  background: transparent; color: var(--text);
  font-family: var(--font-ui); font-size: 0.9rem; font-weight: 500;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.cal-cell.empty { border-color: transparent; cursor: default; }
.cal-cell.today { border-color: var(--border); border-width: 3px; font-weight: 700; }
.cal-cell.future { color: var(--text-muted); }

/* Sangrado REGISTRADO: relleno sólido. Cuanto más abundante, más puntos. */
.cal-cell.bleed { background: var(--lavender); color: var(--ink); border-color: var(--ink); }
.cal-cell.spot { background: transparent; border-color: var(--border); border-style: dotted; border-width: 3px; }

/* Sangrado PREVISTO: mismo color pero atenuado y con borde discontinuo.
   El borde (continuo = registrado, discontinuo = previsto) es el canal que no depende del
   color, y el relleno suave deja el número legible en ambos temas — un rayado sobre la
   celda entera lo hacía ilegible (accesibilidad, docs/analisis-clue.md §13). */
.cal-cell.pred-bleed {
  background: color-mix(in srgb, var(--lavender) 30%, var(--canvas));
  border-style: dashed; border-color: var(--lavender); border-width: 3px;
  color: var(--text);
}
.cal-cell.pred-fertile {
  border-style: dashed; border-color: var(--forest); border-width: 3px;
}
.cal-cell.fertile { box-shadow: inset 0 0 0 3px var(--forest); }

.cal-marks { position: absolute; bottom: 4px; left: 0; right: 0; display: flex; justify-content: center; gap: 2px; }
.cal-mark { width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.cal-mark.note { border-radius: 0; }

.cal-legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: var(--s24); }
.cal-legend-item { display: flex; align-items: center; gap: 10px; font-size: var(--text-caption); }
.cal-legend-key { width: 26px; height: 26px; border-radius: 8px; border: var(--bw) solid var(--divider); flex: none; }

/* ===========================================================================
   Análisis
   =========================================================================== */

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 96px 1fr auto; gap: 10px; align-items: center; font-size: var(--text-caption); }
/* display:block es obligatorio: son <span>, y el alto y el ancho no aplican a elementos
   inline, así que las barras salían huecas. */
.bar-track {
  display: block; height: 20px; border: var(--bw) solid var(--border);
  border-radius: var(--r-pill); overflow: hidden;
}
.bar-fill { display: block; height: 100%; background: var(--accent); }
.bar-fill.short { background: repeating-linear-gradient(135deg, var(--accent) 0 4px, transparent 4px 8px); }

.pattern-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.pattern-list li {
  border: var(--bw) solid var(--border); border-radius: var(--r-btn);
  padding: 12px 14px; font-size: 0.95rem;
  display: flex; gap: 10px; align-items: flex-start;
}

.symptom-list { list-style: none; padding: 0; margin: 0; }
.symptom-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--divider); font-size: 0.95rem;
}
.symptom-list li:last-child { border-bottom: 0; }
.symptom-list .count { margin-left: auto; font-weight: 700; }

.spark { width: 100%; height: 80px; overflow: visible; }

/* ===========================================================================
   Ajustes / Admin
   =========================================================================== */

.setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s16);
  padding: 14px 0; border-bottom: 1px solid var(--divider);
}
.setting-row:last-child { border-bottom: 0; }
.setting-row > div:first-child { min-width: 0; }
.setting-row strong { display: block; font-weight: 600; }
.setting-row small { color: var(--text-muted); font-size: var(--text-caption); }

/* Instrucciones desplegables: el proceso de Flo tiene siete pasos y tres trampas, pero no
   puede ocupar media pantalla a quien ya lo sabe o no viene de Flo. */
.howto {
  border: var(--bw) solid var(--divider);
  border-radius: var(--r-btn);
  padding: 12px 14px;
  margin-top: var(--s16);
}
.howto > summary {
  cursor: pointer; font-weight: 600; font-size: var(--text-caption);
  list-style: none; display: flex; align-items: center; gap: 8px;
}
.howto > summary::-webkit-details-marker { display: none; }
.howto > summary::before { content: '▸'; transition: transform .15s ease; }
.howto[open] > summary::before { transform: rotate(90deg); }
.howto[open] > summary { margin-bottom: 10px; }
.howto-steps { margin: 0; padding-left: 1.2rem; font-size: var(--text-caption); line-height: 1.65; }
.howto-steps li { margin-bottom: 8px; }
.howto-steps li:last-child { margin-bottom: 0; }

.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: var(--bw) solid var(--border); border-radius: var(--r-pill);
  background: var(--surface); color: var(--text);
  padding: 9px 16px; cursor: pointer; font-family: var(--font-ui); font-size: 0.9rem; font-weight: 500;
  display: inline-flex; align-items: center; gap: 7px;
}
.chip[aria-pressed='true'] { background: var(--accent); color: var(--ink); }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--text-caption); min-width: 520px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--divider); vertical-align: middle; }
th { font-weight: 700; white-space: nowrap; }

/* ===========================================================================
   Auth / onboarding / PIN
   =========================================================================== */

.centered-screen {
  min-height: 100dvh; flex-direction: column;
  align-items: center; justify-content: center; padding: var(--s24) var(--s16);
}
.auth-card { width: 100%; max-width: 440px; }

.tabs-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: var(--s24); }
.tabs-2 button {
  padding: 12px; border: var(--bw) solid var(--border); border-radius: var(--r-btn);
  background: var(--surface); color: var(--text); cursor: pointer;
  font-family: var(--font-ui); font-weight: 500; font-size: 0.95rem;
}
.tabs-2 button[aria-selected='true'] { background: var(--accent); color: var(--ink); }

.privacy-note {
  border: var(--bw) solid var(--border); border-radius: var(--r-card);
  padding: var(--s16); margin-top: var(--s24); font-size: var(--text-caption);
  background: var(--chamber); color: var(--chamber-txt);
}

.onb-progress { display: flex; gap: 5px; margin-bottom: var(--s32); }
.onb-progress i { flex: 1; height: 5px; border-radius: var(--r-pill); background: var(--divider); }
.onb-progress i.done { background: var(--text); }
#onb-next { margin-left: auto; }

.pin-display { display: flex; gap: 12px; justify-content: center; margin: var(--s24) 0; }
.pin-dot { width: 16px; height: 16px; border-radius: 50%; border: var(--bw) solid var(--border); }
.pin-dot.on { background: var(--ink); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 280px; margin: 0 auto; }
.pin-pad button {
  aspect-ratio: 1.4; border: var(--bw) solid var(--border); border-radius: var(--r-btn);
  background: var(--surface); color: var(--text); font-family: var(--font-display);
  font-size: 1.6rem; cursor: pointer;
}

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  z-index: 60; background: var(--chamber); color: var(--chamber-txt);
  border-radius: var(--r-pill); padding: 12px 22px; font-size: var(--text-caption);
  font-weight: 500; max-width: min(92vw, 460px); text-align: center;
}

.spinner {
  width: 34px; height: 34px; border: 3px solid var(--divider);
  border-top-color: var(--text); border-radius: 50%;
  animation: spin .7s linear infinite; margin: var(--s32) auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===========================================================================
   Escritorio
   =========================================================================== */

@media (min-width: 860px) {
  :root { --tabbar-h: 0px; }
  .tabbar { display: none; }
  .desktop-nav { display: flex; }
  main { padding-bottom: var(--s80); }
  .wrap { padding: 0 var(--s32); }
  .today-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s24); align-items: start; }
  .cal-cell { min-height: 64px; font-size: 1rem; }
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: var(--r-section); max-height: 86dvh; }
  .toast { bottom: 28px; }
  .analysis-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s24); align-items: start; }
  .analysis-grid > * { margin-bottom: 0; }
}

/* El ⊕ del escritorio vive en la barra superior. */
.nav-add { display: none; }
@media (min-width: 860px) { .nav-add { display: inline-flex; } }

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

/* --- Mirando el ciclo de otra persona -------------------------------------- */
/*
 * Confundir el perfil es el peor fallo posible de esta pantalla, así que el aviso va por
 * partida doble: el banner explica y ofrece la salida, y la barra superior —que es la que
 * se queda pegada arriba al hacer scroll— cambia de color y lleva el nombre siempre visible.
 */

.view-banner {
  background: var(--accent);
  color: var(--ink);
  border-bottom: var(--bw) solid var(--ink);
  padding: 10px 0;
  padding-top: calc(10px + env(safe-area-inset-top));
}
.view-banner-inner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.view-banner svg { width: 22px; height: 22px; flex: none; }
.view-banner p { margin: 0; font-size: var(--text-caption); flex: 1; min-width: 180px; }
.view-banner-ro {
  display: inline-block; margin-left: 6px; padding: 1px 8px;
  border: 1.5px solid var(--ink); border-radius: var(--r-pill);
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: .04em;
}
.view-banner .btn { background: var(--ink); color: var(--cream); border-color: var(--ink); }

/* La barra superior teñida: es la señal que sobrevive al scroll. */
body.is-viewing .topbar { padding-top: var(--s8); }
body.is-viewing .topbar-inner { background: var(--accent); color: var(--ink); border-color: var(--ink); }
body.is-viewing .topbar-inner .icon-round { border-color: var(--ink); color: var(--ink); }
body.is-viewing .tabbar-inner { border-color: var(--ink); }

/* El enlace de invitación: ancho completo y en monoespaciada, que es lo que hace falta
   para verlo entero y comprobar que es el que se va a mandar. */
.link-field { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.link-field input {
  flex: 1; min-width: 0; margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem; padding: 10px 12px;
  border: var(--bw) solid var(--divider); border-radius: var(--r-input);
  background: var(--canvas); color: var(--text);
}
.link-field .btn { flex: none; }

.profile-switch { display: flex; align-items: center; }
.profile-switch select {
  font-family: var(--font-ui); font-size: var(--text-caption); font-weight: 600;
  max-width: 44vw; padding: 9px 12px; margin: 0;
  border: var(--bw) solid currentColor; border-radius: var(--r-pill);
  background: transparent; color: inherit; cursor: pointer;
}

@media print { .tabbar, .topbar { display: none; } }
