:root {
  --bg: #0f172a;
  --bg2: #1e293b;
  --card: #1e293bcc;
  --teal: #4fd1c5;
  --teal-dim: #2c7a72;
  --lav: #a78bfa;
  --rose: #fb7185;
  --amber: #fbbf24;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --radius: 20px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 800px at 20% -10%, #1e3a5f 0%, var(--bg) 55%) fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
#app { max-width: 520px; margin: 0 auto; padding: 24px 20px 90px; min-height: 100%; }

h1 { font-size: 1.9rem; letter-spacing: -0.02em; }
h2 { font-size: 1.4rem; letter-spacing: -0.01em; margin-bottom: 6px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.spacer { height: 16px; }

button { font: inherit; cursor: pointer; border: none; color: inherit; -webkit-tap-highlight-color: transparent; }
.btn {
  display: block; width: 100%; padding: 16px; border-radius: var(--radius);
  background: var(--bg2); color: var(--text); font-size: 1.05rem; font-weight: 600;
  border: 1px solid #334155; transition: transform 0.08s, background 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--teal); color: #062824; border: none; }
.btn.ghost { background: transparent; border: 1px solid #334155; }
.btn.danger-soft { background: #7f1d1d33; border-color: #7f1d1d; }

/* ---------- crisis gate ---------- */
.gate { display: flex; flex-direction: column; justify-content: center; min-height: 82vh; gap: 14px; }
.gate .logo { text-align: center; margin-bottom: 20px; }
.gate .logo .ring {
  width: 84px; height: 84px; margin: 0 auto 14px; border-radius: 50%;
  border: 6px solid var(--teal); display: flex; align-items: center; justify-content: center;
  animation: breatheRing 5s ease-in-out infinite;
}
.gate .logo .ring .dot { width: 26px; height: 26px; border-radius: 50%; background: var(--teal); }
@keyframes breatheRing { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12); } }
.gate h1 { text-align: center; margin-bottom: 4px; }
.gate .q { text-align: center; font-size: 1.25rem; color: var(--muted); margin-bottom: 22px; }
.btn.huge { padding: 26px; font-size: 1.3rem; border-radius: 26px; }
.btn.crisis-yes { background: linear-gradient(135deg, var(--teal), #38b2ac); color: #062824; }

/* ---------- crisis mode ---------- */
.crisis-head { text-align: center; margin: 8px 0 20px; }
.strategy-card {
  display: flex; align-items: center; gap: 16px; width: 100%;
  background: var(--card); border: 1px solid #334155; border-radius: var(--radius);
  padding: 20px; margin-bottom: 14px; text-align: left;
  transition: transform 0.08s;
}
.strategy-card:active { transform: scale(0.97); }
.strategy-card .emoji { font-size: 2.2rem; }
.strategy-card .t { font-size: 1.15rem; font-weight: 700; }
.strategy-card .d { color: var(--muted); font-size: 0.9rem; margin-top: 2px; }
.helpline-note { text-align: center; margin-top: 18px; }
.helpline-note a { color: var(--rose); font-weight: 600; text-decoration: none; }

/* ---------- tool screens ---------- */
.tool-wrap { display: flex; flex-direction: column; min-height: 84vh; }
.tool-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 18px; }
.backrow { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.backrow button { background: none; color: var(--muted); font-size: 1rem; padding: 8px; }

.breath-circle {
  width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, #4fd1c555, #4fd1c511);
  border: 3px solid var(--teal);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 700;
  transition: transform 3.8s ease-in-out;
}
.breath-circle.in { transform: scale(1.35); }
.breath-circle.out { transform: scale(1); }
.phase-label { font-size: 1.3rem; color: var(--teal); font-weight: 600; min-height: 1.6em; }
.big-count { font-size: 3.2rem; font-weight: 800; color: var(--teal); font-variant-numeric: tabular-nums; }

.ground-step { font-size: 1.25rem; font-weight: 600; }
.tap-dots { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.tap-dot {
  width: 52px; height: 52px; border-radius: 50%; border: 2px solid var(--teal);
  background: transparent; font-size: 1.2rem; color: var(--teal);
}
.tap-dot.done { background: var(--teal); color: #062824; }

.emotion-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; }
.emotion-grid .btn { padding: 14px 6px; font-size: 0.95rem; }
.emotion-grid .btn.sel { background: var(--lav); color: #1e1b4b; border: none; }
input[type="range"] { width: 100%; accent-color: var(--teal); }

.progressbar { width: 100%; height: 8px; background: #334155; border-radius: 4px; overflow: hidden; }
.progressbar .fill { height: 100%; background: var(--teal); border-radius: 4px; transition: width 0.3s; }

/* ---------- dashboard ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.streak-pill { background: #78350f55; border: 1px solid var(--amber); color: var(--amber); border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: 0.9rem; }
.hero-check {
  background: linear-gradient(135deg, #134e4a, #1e3a5f); border: 1px solid var(--teal-dim);
  border-radius: var(--radius); padding: 22px; margin-bottom: 20px; text-align: center;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.nav-card {
  background: var(--card); border: 1px solid #334155; border-radius: var(--radius);
  padding: 18px 14px; text-align: center; transition: transform 0.08s;
}
.nav-card:active { transform: scale(0.96); }
.nav-card .emoji { font-size: 1.8rem; display: block; margin-bottom: 6px; }
.nav-card .t { font-weight: 700; display: block; }
.nav-card .sub { color: var(--muted); font-size: 0.8rem; margin-top: 3px; display: block; }

/* ---------- learn ---------- */
.learn-card {
  background: var(--card); border: 1px solid #334155; border-radius: var(--radius);
  padding: 20px; margin-bottom: 14px;
}
.learn-card.unread { border-left: 4px solid var(--teal); }
.learn-card h3 { margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.learn-card p { color: var(--muted); line-height: 1.55; font-size: 0.95rem; }
.learn-card .viz { margin: 14px 0; }
.wot-band { border-radius: 10px; padding: 10px 14px; font-weight: 600; font-size: 0.9rem; margin: 6px 0; }
.wot-hyper { background: #7f1d1d66; color: #fca5a5; }
.wot-window { background: #134e4a; color: var(--teal); padding: 18px 14px; }
.wot-hypo { background: #1e3a8a66; color: #93c5fd; }

/* ---------- quiz ---------- */
.quiz-opt { margin-bottom: 10px; text-align: left; font-weight: 500; }
.quiz-opt.correct { background: #134e4a; border-color: var(--teal); }
.quiz-opt.wrong { background: #7f1d1d55; border-color: var(--rose); }
.quiz-feedback { background: var(--card); border-radius: 14px; padding: 14px; margin-top: 12px; line-height: 1.5; font-size: 0.95rem; }

/* ---------- badges ---------- */
.badge-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.badge {
  background: var(--card); border: 1px solid #334155; border-radius: var(--radius);
  padding: 18px 12px; text-align: center;
}
.badge.locked { opacity: 0.38; filter: grayscale(1); }
.badge .emoji { font-size: 2rem; }
.badge .t { font-weight: 700; margin-top: 6px; font-size: 0.92rem; }
.badge .d { color: var(--muted); font-size: 0.78rem; margin-top: 3px; }

/* ---------- toolkit picker ---------- */
.pick-card {
  display: flex; align-items: center; gap: 14px; width: 100%;
  background: var(--card); border: 2px solid #334155; border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px; text-align: left;
}
.pick-card.sel { border-color: var(--teal); background: #134e4a66; }
.pick-card .num {
  min-width: 30px; height: 30px; border-radius: 50%; background: var(--teal); color: #062824;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.9rem;
}

/* ---------- settings ---------- */
.settings-row { background: var(--card); border: 1px solid #334155; border-radius: 14px; padding: 16px; margin-bottom: 12px; }
.settings-row a { color: var(--teal); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 200%);
  background: var(--teal); color: #062824; font-weight: 700; padding: 14px 22px;
  border-radius: 999px; transition: transform 0.35s cubic-bezier(0.34, 1.4, 0.64, 1);
  z-index: 50; box-shadow: 0 8px 30px #0009; max-width: 90vw; text-align: center;
}
.toast.show { transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .breath-circle, .gate .logo .ring { transition: none; animation: none; }
}
