/* ============================================================
   QuietMind — tema noturno premium (azul escuro + accent teal).
   Mobile-first. Minimalista, combinando com sono/silêncio.
   ============================================================ */

:root {
  --bg:        #0b1220;   /* fundo principal (azul quase preto) */
  --bg-2:      #111c30;   /* cartões */
  --bg-3:      #18263d;   /* cartões elevados / inputs */
  --line:      #22334d;   /* bordas sutis */
  --text:      #e8eef7;   /* texto principal */
  --muted:     #97a6bf;   /* texto secundário */
  --teal:      #2dd4bf;   /* accent */
  --teal-dim:  #1f9e8f;
  --danger:    #f87171;
  --warn:      #fbbf24;
  --radius:    18px;
  --radius-sm: 12px;
  --shadow:    0 10px 30px rgba(0,0,0,.35);
  --safe-b:    env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* O atributo [hidden] deve SEMPRE esconder, mesmo quando uma classe define
   display (ex.: .sos-overlay usa display:grid). Sem isto, o overlay do SOS
   cobre a tela inteira o tempo todo, tampando o app. */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ── App shell ─────────────────────────────────────────── */
.app-root { min-height: 100dvh; display: flex; flex-direction: column; }

.screen {
  flex: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 20px calc(96px + var(--safe-b));
  animation: fade .25s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Telas de auth/onboarding sem tab bar usam padding menor embaixo. */
.screen--flat { padding-bottom: calc(32px + var(--safe-b)); }

/* ── Boot ──────────────────────────────────────────────── */
.boot { flex: 1; display: grid; place-content: center; text-align: center; color: var(--muted); gap: 14px; }
.boot__pulse {
  width: 56px; height: 56px; margin: 0 auto; border-radius: 50%;
  background: radial-gradient(circle, var(--teal), transparent 70%);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { transform: scale(.85); opacity: .6; } 50% { transform: scale(1.1); opacity: 1; } }

/* ── Tipografia ────────────────────────────────────────── */
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 8px; letter-spacing: -.02em; }
h2 { font-size: 1.2rem; margin: 0 0 6px; letter-spacing: -.01em; }
h3 { font-size: 1rem; margin: 0 0 4px; }
.lead { color: var(--muted); margin: 0 0 24px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.tiny { font-size: .8rem; }

/* ── Botões ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px 18px; border: 0; border-radius: var(--radius-sm);
  font-size: 1rem; font-weight: 600; color: #04231f;
  background: linear-gradient(180deg, var(--teal), var(--teal-dim));
  box-shadow: 0 6px 18px rgba(45,212,191,.25);
  transition: transform .08s ease, opacity .2s ease;
}
.btn:active { transform: translateY(1px) scale(.995); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--line); box-shadow: none;
}
.btn--danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); box-shadow: none; }
.btn--sm { width: auto; padding: 10px 16px; font-size: .9rem; }
.btn-row { display: flex; gap: 12px; }
.btn-row .btn { width: 100%; }

/* ── Cartões ───────────────────────────────────────────── */
.card {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }
.card--accent { border-color: var(--teal-dim); }

/* ── Formulários ───────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.input {
  width: 100%; padding: 14px; border-radius: var(--radius-sm);
  background: var(--bg-3); border: 1px solid var(--line); color: var(--text);
  font-size: 1rem;
}
.input:focus { outline: none; border-color: var(--teal); }
.form-error { color: var(--danger); font-size: .85rem; margin-top: 6px; min-height: 1em; }

/* ── Opções (quiz / tracker) ───────────────────────────── */
.options { display: grid; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 12px;
  padding: 16px; border-radius: var(--radius-sm);
  background: var(--bg-3); border: 1px solid var(--line);
  color: var(--text); text-align: left; font-size: 1rem; width: 100%;
  transition: border-color .15s ease, background .15s ease;
}
.option:active { transform: scale(.99); }
.option.is-selected { border-color: var(--teal); background: rgba(45,212,191,.08); }
.option .dot {
  width: 20px; height: 20px; border-radius: 50%; flex: 0 0 auto;
  border: 2px solid var(--line); display: grid; place-content: center;
}
.option.is-selected .dot { border-color: var(--teal); }
.option.is-selected .dot::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--teal); }

/* Chips multi-seleção */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  padding: 10px 14px; border-radius: 999px; font-size: .9rem;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--text);
}
.chip.is-selected { border-color: var(--teal); background: rgba(45,212,191,.12); color: var(--teal); }

/* ── Progresso do quiz ─────────────────────────────────── */
.qz-progress { height: 4px; background: var(--bg-3); border-radius: 999px; overflow: hidden; margin-bottom: 24px; }
.qz-progress > i { display: block; height: 100%; background: var(--teal); transition: width .3s ease; }

/* ── Range (intensidade) ───────────────────────────────── */
.range-val { font-size: 2.4rem; font-weight: 700; text-align: center; color: var(--teal); }
input[type=range] { width: 100%; accent-color: var(--teal); height: 32px; }

/* ── Player v2 ──────────────────────────────────────────── */

/* Cartão principal do player */
.player-card {
  background: linear-gradient(165deg, var(--bg-3) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 28px 22px 22px;
  text-align: center;
  position: relative;
  overflow: hidden;
  margin-bottom: 20px;
}
.player-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 130px;
  background: radial-gradient(ellipse at 50% -20%, rgba(45,212,191,.16), transparent 70%);
  pointer-events: none;
}

/* Waveform — 14 barras animadas */
.wave-viz {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  height: 54px;
  margin: 0 0 22px;
  position: relative;
  z-index: 1;
}
.wave-viz span {
  width: 3px;
  height: 6px;
  background: linear-gradient(180deg, var(--teal) 0%, rgba(45,212,191,.35) 100%);
  border-radius: 2px 2px 1px 1px;
  opacity: .25;
  transition: height .35s ease, opacity .35s ease;
}
.wave-viz.is-playing span { opacity: 1; animation: waveBar .9s ease-in-out infinite alternate; }
@keyframes waveBar { from { height: 5px; } to { height: 46px; } }

/* Stagger individual de cada barra (14 barras) */
.wave-viz.is-playing span:nth-child(1)  { animation-duration:1.05s; animation-delay:0.00s; }
.wave-viz.is-playing span:nth-child(2)  { animation-duration:0.80s; animation-delay:0.11s; }
.wave-viz.is-playing span:nth-child(3)  { animation-duration:1.30s; animation-delay:0.18s; }
.wave-viz.is-playing span:nth-child(4)  { animation-duration:0.92s; animation-delay:0.05s; }
.wave-viz.is-playing span:nth-child(5)  { animation-duration:1.14s; animation-delay:0.23s; }
.wave-viz.is-playing span:nth-child(6)  { animation-duration:0.72s; animation-delay:0.32s; }
.wave-viz.is-playing span:nth-child(7)  { animation-duration:1.22s; animation-delay:0.27s; }
.wave-viz.is-playing span:nth-child(8)  { animation-duration:0.88s; animation-delay:0.14s; }
.wave-viz.is-playing span:nth-child(9)  { animation-duration:1.08s; animation-delay:0.20s; }
.wave-viz.is-playing span:nth-child(10) { animation-duration:1.40s; animation-delay:0.08s; }
.wave-viz.is-playing span:nth-child(11) { animation-duration:0.94s; animation-delay:0.25s; }
.wave-viz.is-playing span:nth-child(12) { animation-duration:1.18s; animation-delay:0.38s; }
.wave-viz.is-playing span:nth-child(13) { animation-duration:0.78s; animation-delay:0.07s; }
.wave-viz.is-playing span:nth-child(14) { animation-duration:1.02s; animation-delay:0.34s; }

/* Exibição de frequência */
.freq-display {
  font-size: 2.6rem; font-weight: 800; color: var(--teal);
  letter-spacing: -.04em; line-height: 1;
  margin-bottom: 4px; position: relative; z-index: 1;
}
.freq-hint {
  font-size: .76rem; color: var(--muted);
  margin-bottom: 14px; position: relative; z-index: 1;
}

/* Play button compacto e elegante */
.play-btn-v2 {
  width: 60px; height: 60px; border-radius: 50%; border: 0;
  background: linear-gradient(145deg, var(--teal), var(--teal-dim));
  color: #04231f;
  box-shadow: 0 4px 18px rgba(45,212,191,.38), 0 0 0 7px rgba(45,212,191,.09);
  display: inline-grid; place-content: center;
  transition: transform .12s ease, box-shadow .15s ease;
  margin-bottom: 20px; position: relative; z-index: 1;
}
.play-btn-v2:active { transform: scale(.88); box-shadow: 0 2px 10px rgba(45,212,191,.25); }
.play-btn-v2 svg { width: 22px; height: 22px; }

/* Modo (Pure tone / Masking) */
.mode-pills { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.mode-pill {
  padding: 9px 16px; border-radius: 999px; font-size: .82rem;
  background: var(--bg); border: 1px solid var(--line); color: var(--muted);
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.mode-pill.is-selected {
  border-color: var(--teal); color: var(--teal);
  background: rgba(45,212,191,.1);
}

/* Timer (15 min / 30 min / ...) */
.timer-pills { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 14px; }
.timer-pill {
  padding: 9px 14px; border-radius: 999px; font-size: .82rem;
  background: var(--bg); border: 1px solid var(--line); color: var(--muted);
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.timer-pill.is-selected {
  border-color: var(--teal); color: var(--teal);
  background: rgba(45,212,191,.1);
}

/* Status de reprodução */
.player-status {
  font-size: .8rem; color: var(--muted); min-height: 1.4em; text-align: center;
  position: relative; z-index: 1;
}

/* Círculo de respiração (Calm) */
.breathe-ring {
  width: 160px; height: 160px; border-radius: 50%;
  margin: 0 auto 24px;
  background: radial-gradient(circle at 50%, rgba(45,212,191,.18), rgba(45,212,191,.04) 70%);
  border: 1.5px solid rgba(45,212,191,.28);
  display: grid; place-content: center;
  position: relative;
  transition: transform .12s linear;
  box-shadow: 0 0 0 10px rgba(45,212,191,.06), 0 0 0 20px rgba(45,212,191,.03);
}
.breathe-phase { font-size:1rem; font-weight:600; color:var(--teal); text-align:center; }
.breathe-count { font-size:1.6rem; font-weight:700; color:var(--text); text-align:center; line-height:1.2; }

/* Compatibilidade: mantém .play-btn e .timer-row caso usados em outro lugar */
.play-btn {
  width: 60px; height: 60px; border-radius: 50%; border: 0;
  background: linear-gradient(180deg, var(--teal), var(--teal-dim));
  color: #04231f; box-shadow: 0 6px 20px rgba(45,212,191,.3);
  display: inline-grid; place-content: center;
}
.timer-row { display: flex; gap: 8px; justify-content: center; margin-top: 18px; }
.tune { margin-top: 22px; }
.tune output { display: block; text-align: center; color: var(--teal); font-weight: 600; margin-top: 4px; }

/* ── SOS button (sempre acessível na home) ─────────────── */
.sos-cta {
  width: 100%; padding: 22px; border: 0; border-radius: var(--radius);
  background: linear-gradient(135deg, #b91c1c, #ef4444);
  color: #fff; font-size: 1.15rem; font-weight: 700;
  box-shadow: 0 10px 30px rgba(185,28,28,.45); margin-bottom: 18px;
}
.sos-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: radial-gradient(circle at 50% 40%, #132034, #07101c);
  display: grid; place-content: center; text-align: center; padding: 24px;
}

/* ── Dark Screen button + overlay ─────────────────────── */
.dark-btn {
  display: none; width: 100%; margin-top: 18px;
  padding: 14px 20px; border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--radius); background: transparent;
  color: var(--muted); font-size: 0.9rem; cursor: pointer;
  transition: opacity .2s;
}
.dark-btn.visible { display: block; }
.dark-btn:active  { opacity: .6; }

.dark-overlay {
  position: fixed; inset: 0; z-index: 9998; background: #000;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: max(48px, env(safe-area-inset-bottom, 48px));
}
.dark-overlay__hint {
  color: rgba(255,255,255,0.18); font-size: 0.78rem; letter-spacing: 0.06em;
  animation: darkHintFade 3s forwards 1.2s;
}
@keyframes darkHintFade { to { opacity: 0; } }

/* ── Tab bar ───────────────────────────────────────────── */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; justify-content: space-around;
  background: rgba(11,18,32,.92); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 8px 8px calc(8px + var(--safe-b));
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); font-size: .68rem; padding: 4px 10px; flex: 1; text-align: center;
}
.tabbar a.is-active { color: var(--teal); }
.tabbar a svg { width: 22px; height: 22px; }

/* ── Listas / sessões v2 ───────────────────────────────── */
.session {
  display: flex; align-items: center; gap: 14px; padding: 16px;
  background: linear-gradient(135deg, var(--bg-3) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line);
  border-radius: 20px; margin-bottom: 10px;
  width: 100%; text-align: left; color: var(--text);
  text-decoration: none; position: relative; overflow: hidden;
  transition: border-color .15s ease;
}
.session::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 80px;
  background: radial-gradient(ellipse at 0% 0%, rgba(45,212,191,.09), transparent 60%);
  pointer-events: none;
}
.session:active { transform: scale(.99); }
.session__icon {
  width: 46px; height: 46px; border-radius: 14px;
  background: rgba(45,212,191,.14);
  display: grid; place-content: center; color: var(--teal); flex: 0 0 auto;
}
.session__icon svg { width: 22px; height: 22px; }
.session__meta { flex: 1; position: relative; z-index: 1; }
.session__meta b { display: block; font-size: .95rem; margin-bottom: 2px; }
.session__meta small { color: var(--muted); font-size: .79rem; }
/* Botão play compacto dentro do card de sessão */
.session__play {
  width: 42px; height: 42px; border-radius: 50%; flex: 0 0 auto;
  background: linear-gradient(145deg, var(--teal), var(--teal-dim));
  display: grid; place-content: center; color: #04231f;
  box-shadow: 0 3px 14px rgba(45,212,191,.28);
  position: relative; z-index: 1;
}
.session__play svg { width: 16px; height: 16px; }

/* ── Stats / progress ──────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px 10px; text-align: center; }
.stat b { display: block; font-size: 1.8rem; color: var(--teal); }
.stat span { font-size: .72rem; color: var(--muted); }

.insight { padding: 14px; border-left: 3px solid var(--teal); background: rgba(45,212,191,.06); border-radius: 8px; margin-bottom: 10px; }

/* Gráfico simples (barras) */
.chart { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding: 8px 0; }
.chart i { flex: 1; background: linear-gradient(180deg, var(--teal), var(--teal-dim)); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }

/* ── Paywall ───────────────────────────────────────────── */
.price { font-size: 3rem; font-weight: 800; letter-spacing: -.03em; }
.price span { font-size: 1rem; color: var(--muted); font-weight: 500; }
.benefit { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.benefit svg { color: var(--teal); flex: 0 0 auto; margin-top: 2px; }
.recur-note { font-size: .82rem; color: var(--muted); text-align: center; margin-top: 14px; }

/* ── Disclaimer / rodapé ───────────────────────────────── */
.disclaimer { font-size: .72rem; color: var(--muted); text-align: center; margin-top: 24px; line-height: 1.5; }

/* ── Header de tela ────────────────────────────────────── */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.topbar .back { background: none; border: 0; color: var(--muted); font-size: 1.4rem; padding: 4px 8px; }

/* ── Toast ─────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(86px + var(--safe-b)); transform: translateX(-50%);
  background: var(--bg-3); border: 1px solid var(--line); color: var(--text);
  padding: 12px 18px; border-radius: 999px; font-size: .9rem; z-index: 60; box-shadow: var(--shadow);
  animation: fade .2s ease;
}

/* ── Utilidades ────────────────────────────────────────── */
.stack > * + * { margin-top: 14px; }
.spacer { height: 18px; }
.divider { height: 1px; background: var(--line); margin: 20px 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.badge { font-size: .7rem; padding: 3px 8px; border-radius: 999px; background: rgba(45,212,191,.14); color: var(--teal); }

/* ============================================================
   Advertorial (back-redirect / exit-intent)
   Tom direto, urgência, leitura corrida no mobile.
   ============================================================ */
.advert { max-width: 560px; }
.advert__alert {
  display: inline-block;
  background: rgba(248,113,113,.14); color: var(--danger);
  border: 1px solid rgba(248,113,113,.4);
  padding: 6px 14px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; letter-spacing: .02em;
  margin-bottom: 14px;
}
.advert__h1 {
  font-size: 1.7rem; line-height: 1.18; margin: 0 0 14px;
  letter-spacing: -.01em;
}
.advert__hi { color: var(--warn); }
.advert__lead { font-size: 1.02rem; color: var(--text); margin-bottom: 22px; }

.advert__card {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 18px 18px 16px; margin-bottom: 18px;
  position: relative;
}
.advert__num {
  position: absolute; top: -14px; left: 16px;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--teal); color: #04231f;
  font-weight: 700; font-size: .92rem;
  display: grid; place-items: center;
}
.advert__card h2 {
  font-size: 1.12rem; line-height: 1.3; margin: 6px 0 10px;
}
.advert__card p { margin: 0 0 10px; font-size: .96rem; }
.advert__card u { text-decoration-color: var(--warn); text-decoration-thickness: 2px; }
.advert__quote {
  border-left: 3px solid var(--teal-dim);
  padding-left: 12px; font-style: italic; color: var(--muted);
  font-size: .9rem;
}
.advert__list { margin: 6px 0 0; padding-left: 18px; }
.advert__list li { margin-bottom: 8px; font-size: .96rem; }
.advert__list li b { color: var(--text); }

/* Bloco 3 — comparativo "Doing nothing" vs "QuietMind" */
.advert__compare {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-top: 12px;
}
.advert__col {
  background: var(--bg-3); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px;
}
.advert__col--good {
  background: rgba(45,212,191,.08);
  border-color: var(--teal-dim);
}
.advert__col-h {
  font-size: .82rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px;
}
.advert__col--good .advert__col-h { color: var(--teal); }
.advert__col ul { margin: 0; padding-left: 16px; }
.advert__col li { font-size: .85rem; margin-bottom: 6px; }

/* Prova social */
.advert__social {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 16px; margin-bottom: 18px;
  text-align: center;
}
.advert__stars { color: var(--warn); font-size: 1.1rem; letter-spacing: 4px; margin-bottom: 8px; }
.advert__social p { margin: 0 0 6px; font-size: .96rem; font-style: italic; }
.advert__social .tiny { font-size: .72rem; }

/* Bloco final de urgência */
.advert__urgency {
  background: linear-gradient(135deg, rgba(45,212,191,.10), rgba(31,158,143,.06));
  border: 1px solid var(--teal-dim);
  border-radius: var(--radius-sm);
  padding: 18px; margin-bottom: 18px;
}
.advert__urgency h2 { font-size: 1.18rem; margin: 0 0 10px; line-height: 1.28; }
.advert__urgency p { margin: 0; font-size: .98rem; }

/* CTA */
.advert__cta {
  width: 100%; padding: 16px; font-size: 1.05rem; font-weight: 700;
  margin-top: 6px;
}
.advert__leave {
  text-align: center; margin-top: 10px;
}
.advert__leave a {
  color: var(--muted); font-size: .85rem; text-decoration: underline;
  text-decoration-color: rgba(151,166,191,.35);
}

/* Mobile: empilha o comparativo */
@media (max-width: 420px) {
  .advert__h1 { font-size: 1.45rem; }
  .advert__compare { grid-template-columns: 1fr; }
}
.badge--warn { background: rgba(251,191,36,.14); color: var(--warn); }
