/* App para teléfono: una columna centrada con botón de crisis flotante.
   La versión web para computadora (web.html) añade css/web.css encima. */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --text: #1f2a2e;
  --muted: #56666c;
  --line: #dde3e0;
  --accent: #2f7d78;
  --accent-strong: #235f5b;
  --accent-soft: #dcedea;
  --on-accent: #ffffff;
  --sos: #b42318;
  --sos-strong: #8f1c13;
  --sos-soft: #fbe9e7;
  --on-sos: #ffffff;
  --focus: #1d4ed8;
  --shadow: 0 1px 2px rgb(20 40 40 / 6%), 0 6px 20px rgb(20 40 40 / 6%);
  --sos-shadow: 0 6px 18px rgb(120 20 10 / 30%);
  --radius: 18px;
  --gutter: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12191b;
    --surface: #1b2427;
    --surface-2: #223034;
    --text: #e7eeec;
    --muted: #a3b3b2;
    --line: #2e3d41;
    --accent: #6cc3b9;
    --accent-strong: #8fd6cd;
    --accent-soft: #1f3b3a;
    --on-accent: #0d1f1d;
    --sos: #e5534b;
    --sos-strong: #f07067;
    --sos-soft: #3a1d1b;
    --on-sos: #1a0503;
    --focus: #93c5fd;
    --shadow: none;
    --sos-shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12191b;
  --surface: #1b2427;
  --surface-2: #223034;
  --text: #e7eeec;
  --muted: #a3b3b2;
  --line: #2e3d41;
  --accent: #6cc3b9;
  --accent-strong: #8fd6cd;
  --accent-soft: #1f3b3a;
  --on-accent: #0d1f1d;
  --sos: #e5534b;
  --sos-strong: #f07067;
  --sos-soft: #3a1d1b;
  --on-sos: #1a0503;
  --focus: #93c5fd;
  --shadow: none;
  --sos-shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.55;
  padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px));
}

a { color: var(--accent-strong); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; text-wrap: balance; }
h1 { font-size: 1.6rem; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; }
p { margin: 0 0 1rem; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
/* Elementos que reciben foco por programa (para lectores de pantalla) no necesitan marco */
[tabindex="-1"]:focus, [tabindex="-1"]:focus-visible { outline: none; }

.skip {
  position: absolute; left: 8px; top: -60px; z-index: 30;
  background: var(--surface); padding: 8px 12px; border-radius: 8px;
}
.skip:focus { top: 8px; }

/* ---------- Estructura ---------- */

.shell { min-height: 100dvh; display: flex; flex-direction: column; }

.side {
  display: flex; align-items: center;
  padding-block: calc(12px + env(safe-area-inset-top, 0px)) 12px;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  max-width: 640px; width: 100%; margin: 0 auto;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--text); text-decoration: none; font-weight: 650;
}
.brand img { width: 32px; height: 32px; }
.sidenav, .side-bottom { display: none; }

main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding-block: 8px 24px;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  outline: none;
}

.footer {
  max-width: 640px; width: 100%; margin: 0 auto;
  padding-block: 16px;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  color: var(--muted); font-size: .9rem;
  border-top: 1px solid var(--line);
}
.footer nav { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 8px; }
.footer a { color: var(--muted); }
.footer p { margin: 0; }

/* Botón de crisis */
.sos {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 22px;
  background: var(--sos); color: var(--on-sos);
  border-radius: 999px; text-decoration: none; font-weight: 700;
  white-space: nowrap;
}
.sos:hover { background: var(--sos-strong); }
.sos-float {
  position: fixed; z-index: 20;
  left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  box-shadow: var(--sos-shadow);
}
.sos-float[aria-current="page"] { display: none; }

/* ---------- Componentes ---------- */
.lead { color: var(--muted); font-size: 1.05rem; max-width: 62ch; }
.eyebrow { color: var(--accent-strong); font-weight: 650; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; margin-bottom: .25rem; }
.section-title { font-size: 1.1rem; margin: 28px 0 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.moods { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 20px 0; padding: 0; list-style: none; }
@media (min-width: 480px) { .moods { grid-template-columns: 1fr 1fr; } }
.mood {
  display: flex; align-items: center; gap: 12px;
  width: 100%; height: 100%; min-height: 64px; padding: 12px 16px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px;
  font: inherit; text-align: left; cursor: pointer;
  text-decoration: none;
  transition: border-color .15s, background-color .15s;
}
.mood:hover { border-color: var(--accent); background: var(--accent-soft); }
.mood .emoji { font-size: 1.5rem; line-height: 1; }
.mood.crisis { border-color: color-mix(in srgb, var(--sos) 45%, var(--line)); }
.mood.crisis:hover { background: var(--sos-soft); border-color: var(--sos); }
@media (min-width: 480px) { .moods li.crisis-item { grid-column: 1 / -1; } }

.tool-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.tool-card {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 16px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s;
}
.tool-card:hover { border-color: var(--accent); }
.tool-card > span:last-child { min-width: 0; }
.tool-card .ico {
  flex: none; width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-strong);
}
.tool-card .ico svg { width: 26px; height: 26px; }
.tool-card h3 { margin: 0 0 4px; font-size: 1.1rem; }
.tool-card p { margin: 0; color: var(--muted); font-size: .95rem; }
.tool-card .meta { font-size: .85rem; color: var(--accent-strong); margin-top: 6px; font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 22px;
  border-radius: 999px; border: 1px solid transparent;
  background: var(--accent); color: var(--on-accent);
  font: inherit; font-weight: 650; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--accent-strong); }
.btn.secondary { background: transparent; color: var(--accent-strong); border-color: var(--line); }
.btn.secondary:hover { background: var(--accent-soft); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.btn-row .btn { flex: 1 1 140px; }

.back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px; color: var(--muted); text-decoration: none; font-size: .95rem; }
.back:hover { color: var(--text); }
.back svg { width: 18px; height: 18px; flex: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 16px; padding: 0; border: 0; }
.chips legend { font-weight: 650; margin-bottom: 8px; padding: 0; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span {
  display: inline-block; padding: 10px 16px; min-height: 44px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
}
.chip input:checked + span { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.hint { color: var(--muted); font-size: .9rem; margin-top: -8px; }

/* Respiración */
.breath { display: grid; place-items: center; text-align: center; padding: 12px 0 4px; background: var(--bg); border-radius: var(--radius); }
.breath-stage { position: relative; width: min(72vw, 280px); max-width: 100%; aspect-ratio: 1; display: grid; place-items: center; }
.breath-ring { position: absolute; inset: 0; border-radius: 50%; border: 2px dashed var(--line); }
.breath-circle {
  width: 100%; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--accent) 55%, var(--surface)), var(--accent));
  transform: scale(var(--scale, .45));
  opacity: .9;
}
.breath-label { font-size: 1.35rem; font-weight: 650; margin-top: 20px; min-height: 2em; }
.breath-count { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 1.1rem; }
.breath-remaining { color: var(--muted); font-size: .9rem; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kbd-hint { display: none; color: var(--muted); font-size: .85rem; margin-top: 10px; }
kbd { font: inherit; font-size: .8rem; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; background: var(--surface); }

/* Pantalla completa (para proyectar) */
.breath:fullscreen { padding: 4vh 4vw; align-content: center; }
.breath:fullscreen .breath-stage { width: min(60vh, 70vw); }
.breath:fullscreen .breath-label { font-size: clamp(1.6rem, 4vh, 2.6rem); }
.breath:fullscreen .breath-count { font-size: clamp(1.2rem, 3vh, 2rem); }
.breath:fullscreen .breath-remaining { font-size: 1.1rem; }
.breath:fullscreen .kbd-hint { display: block; }

@media (prefers-reduced-motion: reduce) {
  .breath-circle { transform: scale(.8) !important; opacity: var(--opacity, .6); }
  .tool-card, .mood { transition: none; }
}

/* Pasos */
.progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 4px 0 18px; }
.progress > span { display: block; height: 100%; width: var(--p, 0%); background: var(--accent); transition: width .4s ease; }
.step-num { color: var(--muted); font-size: .9rem; }
.dots { display: flex; flex-wrap: wrap; gap: 12px; margin: 18px 0 4px; padding: 0; list-style: none; }
.dot {
  width: 52px; height: 52px; border-radius: 50%;
  border: 2px solid var(--accent); background: transparent; cursor: pointer;
  font: inherit; color: var(--accent-strong); font-weight: 700;
}
.dot[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.timer { margin: 18px 0 4px; }
.timer-label { font-weight: 650; font-size: 1.15rem; }
.timer-bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 8px; }
.timer-bar > span { display: block; height: 100%; width: var(--p, 0%); background: var(--accent); transition: width 1s linear; }
.timer-secs { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .95rem; margin-top: 4px; }

/* Instalar / descargar */
.install-card { margin-top: 24px; }
.install-card h2 { font-size: 1.15rem; }
.install-help { margin: 14px 0 0; padding-left: 1.3rem; color: var(--text); }
.install-help li + li { margin-top: 6px; }
.side-download { min-height: 44px; font-size: .95rem; }

/* Cierre */
.rating { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.rating .btn { flex: 1 1 90px; }
.thanks { color: var(--accent-strong); font-weight: 600; }

/* Ayuda */
.help-hero { border-left: 5px solid var(--sos); }
.help-grid { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
.line { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.line > div { min-width: 0; }
.line h3 { margin: 0; }
.line p { margin: 4px 0 0; color: var(--muted); font-size: .95rem; }
.call {
  display: inline-flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 20px;
  border-radius: 999px; background: var(--sos); color: var(--on-sos); font-weight: 700; text-decoration: none;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.call:hover { background: var(--sos-strong); }
.call.alt { background: var(--accent); color: var(--on-accent); }

ul.plain { padding-left: 1.2rem; margin: 0 0 1rem; }
ul.plain li + li { margin-top: 6px; }

.switch { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.switch input { width: 24px; height: 24px; margin-top: 2px; accent-color: var(--accent); flex: none; }

.muted { color: var(--muted); }
.small { font-size: .9rem; }
.center { text-align: center; }
.desktop-only { display: none; }
.mobile-only { display: block; }
.offline-note {
  font-size: .85rem; color: var(--muted); background: var(--surface-2);
  padding: 6px 12px; border-radius: 999px; display: inline-block; margin-bottom: 12px;
}
