:root {
  --teal-50: #effcf9;
  --teal-100: #c7f4ea;
  --teal-300: #6fd6c2;
  --teal-400: #2bb89a;
  --teal-600: #0f9b86;
  --teal-700: #0b7d6c;
  --sand-50: #fdf8f1;
  --sand-100: #f7ecdd;
  --sand-300: #ecd3b3;
  --ink: #1f2a2e;
  --muted: #5b6b6e;
  --danger: #d6455b;
  --warn: #e0892b;
  --bg: #ffffff;
  --bg-soft: #fdf8f1;
  --surface: #ffffff;
  --surface-2: #f6fbfa;
  --border: #f0e6d8;
  --text: #1f2a2e;
  --text-muted: #5b6b6e;
  --shadow: 0 10px 30px rgba(15, 155, 134, 0.12);
  --shadow-lg: 0 20px 60px rgba(15, 155, 134, 0.18);
  --radius: 18px;
  --radius-sm: 12px;
}

[data-theme="dark"] {
  --bg: #0e1718;
  --bg-soft: #11211f;
  --surface: #152625;
  --surface-2: #1a302e;
  --border: #243d3a;
  --text: #e8f3f0;
  --text-muted: #9fb4b0;
  --sand-50: #11211f;
  --shadow: 0 10px 30px rgba(0,0,0,0.45);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  background-image: radial-gradient(1200px 600px at 80% -10%, rgba(43,184,154,0.10), transparent),
                    radial-gradient(900px 500px at -10% 10%, rgba(236,211,179,0.18), transparent);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background-color .3s ease, color .3s ease;
}

a { color: var(--teal-700); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1120px; margin: 0 auto; padding: 0 22px; }

/* NAV */
.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 50;
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: 1px; color: var(--teal-700); font-size: 20px; }
.brand .logo { width: 32px; height: 32px; }
.nav-links { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.nav-links a { color: var(--text-muted); font-weight: 600; font-size: 14px; }
.nav-links a:hover { color: var(--teal-700); text-decoration: none; }
.nav-actions { display: flex; gap: 10px; align-items: center; }
.icon-btn { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; width: 38px; height: 38px; cursor: pointer; font-size: 16px; display: grid; place-items: center; }
.icon-btn:hover { border-color: var(--teal-400); }
select.lang { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: 10px; padding: 8px 10px; font-size: 13px; cursor: pointer; }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 12px 22px; border-radius: 999px; font-weight: 700;
  border: none; cursor: pointer; font-size: 15px; transition: transform .12s ease, box-shadow .12s ease, background .2s;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn-primary { background: var(--teal-600); color: #fff; box-shadow: var(--shadow); }
.btn-ghost { background: transparent; color: var(--teal-700); border: 1.5px solid var(--teal-400); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warn { background: var(--warn); color: #fff; }
.btn-sm { padding: 8px 14px; font-size: 13px; }

/* HERO */
.badge { display: inline-block; background: var(--teal-100); color: var(--teal-700); padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; margin-bottom: 18px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; margin: 30px 0; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.card h3 { margin: 0 0 8px; color: var(--teal-700); font-size: 18px; }
.card .step { font-size: 12px; font-weight: 800; color: var(--teal-400); letter-spacing: 1px; }
.card p { color: var(--text-muted); font-size: 14px; margin: 8px 0 0; }
.card .icon { font-size: 28px; margin-bottom: 8px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin: 30px 0; }
.stat { background: linear-gradient(135deg, var(--teal-600), var(--teal-700)); color: #fff; border-radius: var(--radius); padding: 22px; text-align: center; }
.stat .num { font-size: 34px; font-weight: 800; }
.stat .label { font-size: 13px; opacity: .92; }

.section { padding: 44px 0; }
.section h2 { font-size: 30px; color: var(--text); text-align: center; margin-bottom: 8px; }
.section .sub { text-align: center; color: var(--text-muted); margin-bottom: 26px; }

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px; box-shadow: var(--shadow); max-width: 760px; margin: 0 auto;
}
label { display: block; font-weight: 700; margin: 18px 0 8px; color: var(--text); }
input[type="text"], input[type="email"], textarea, select.field {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 12px;
  font-size: 15px; font-family: inherit; background: var(--surface-2); color: var(--text);
}
input:focus, textarea:focus, select.field:focus { outline: none; border-color: var(--teal-400); }

input[type="range"] { width: 100%; accent-color: var(--teal-600); }
.mood-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-muted); }

.pill { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; }
.pill-low { background: var(--teal-100); color: var(--teal-700); }
.pill-med { background: #fdeccb; color: var(--warn); }
.pill-high { background: #fbd5db; color: var(--danger); }

.room { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: 14px; margin-bottom: 12px; background: var(--surface); }
.room .meta { font-size: 13px; color: var(--text-muted); }
.chat-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 16px; height: 300px; overflow-y: auto; margin-bottom: 14px; }
.msg { margin: 8px 0; }
.msg.me { text-align: right; }
.msg.me span { background: var(--teal-600); color: #fff; }
.msg span { display: inline-block; padding: 8px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); max-width: 75%; }

.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal-day { border: 1px solid var(--border); border-radius: 12px; padding: 12px 6px; text-align: center; cursor: pointer; background: var(--surface); font-size: 13px; }
.cal-day:hover { border-color: var(--teal-400); }
.cal-day.sel { background: var(--teal-600); color: #fff; }
.slots { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.slot { padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px; font-size: 13px; cursor: pointer; background: var(--surface); color: var(--text); }
.slot.sel { background: var(--teal-600); color: #fff; border-color: var(--teal-600); }
.anon-id { font-family: monospace; font-size: 18px; letter-spacing: 2px; background: var(--teal-100); color: var(--teal-700); padding: 10px 16px; border-radius: 12px; display: inline-block; }

.helpline { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px; border: 1px solid var(--border); border-radius: 14px; margin-bottom: 12px; background: var(--surface); }
.helpline .num { font-size: 22px; font-weight: 800; color: var(--teal-700); }

footer { padding: 30px 0; text-align: center; color: var(--text-muted); font-size: 13px; border-top: 1px solid var(--border); margin-top: 40px; }

/* CRISIS OVERLAY */
#crisis-overlay { position: fixed; inset: 0; background: rgba(10,15,15,0.8); z-index: 1000; display: none; align-items: center; justify-content: center; padding: 20px; }
#crisis-overlay.show { display: flex; animation: fade .25s ease; }
.crisis-modal { background: var(--surface); border-radius: 20px; max-width: 480px; width: 100%; padding: 28px; text-align: center; box-shadow: var(--shadow-lg); animation: pop .3s ease; }
.crisis-modal h2 { color: var(--danger); margin-top: 0; }
.crisis-modal .num { font-size: 24px; font-weight: 800; color: var(--teal-700); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px; font-size: 14px; z-index: 900; opacity: 0; transition: opacity .3s, transform .3s; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ANIMATIONS */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { transform: scale(.92); opacity: .4; } to { transform: scale(1); opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
.reveal { animation: rise .6s ease both; }
.reveal.d1 { animation-delay: .08s; }
.reveal.d2 { animation-delay: .16s; }
.reveal.d3 { animation-delay: .24s; }
.reveal.d4 { animation-delay: .32s; }

/* BREATHING */
.breath-stage { display: grid; place-items: center; padding: 40px 0; }
.breath-circle {
  width: 200px; height: 200px; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, var(--teal-300), var(--teal-600));
  box-shadow: 0 0 60px rgba(43,184,154,.5);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 20px;
  transition: transform 4s ease-in-out;
}
.breath-circle.in { transform: scale(1.5); }
.breath-circle.out { transform: scale(1); }

/* CHART */
.chart-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.bar-row { display: flex; align-items: center; gap: 12px; margin: 10px 0; }
.bar-label { width: 70px; font-size: 13px; color: var(--text-muted); }
.bar-track { flex: 1; background: var(--surface-2); border-radius: 999px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--teal-400), var(--teal-600)); border-radius: 999px; transition: width 1s ease; }
.donut-wrap { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; justify-content: center; }
.donut { width: 140px; height: 140px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: var(--text); }

/* JOURNAL */
.journal-list { display: flex; flex-direction: column; gap: 12px; }
.journal-item { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--teal-400); border-radius: 12px; padding: 14px 16px; }
.journal-item .jt { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.journal-item .jb { font-size: 14px; color: var(--text); white-space: pre-wrap; }

/* DASHBOARD GRID */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.kpi .k-num { font-size: 30px; font-weight: 800; color: var(--teal-700); }
.kpi .k-label { font-size: 13px; color: var(--text-muted); }

/* ADMIN TABLE */
.tbl { width: 100%; border-collapse: collapse; margin-top: 12px; }
.tbl th, .tbl td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
.tbl th { color: var(--text-muted); font-weight: 700; }
.tbl tr:hover td { background: var(--surface-2); }

/* GRADIENT HERO + BLOBS (shared keyframes) */
.blob { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .5; z-index: 0; animation: float 14s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0) translateX(0); } 50% { transform: translateY(-24px) translateX(18px); } }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* PAGE TRANSITION */
.page-enter { animation: fade .4s ease; }
body.swap { opacity: 0; transition: opacity .2s ease; }

/* BOTTOM NAV (mobile) */
.bottom-nav { display: none; }
@media (max-width: 640px) {
  .nav-links { display: none; }
  .calendar { grid-template-columns: repeat(4, 1fr); }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(12px); border-top: 1px solid var(--border);
    justify-content: space-around; padding: 8px 4px; padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--text-muted); text-decoration: none; }
  .bottom-nav a .bi { font-size: 20px; }
  .bottom-nav a.active { color: var(--teal-700); }
  main, .section, .home-hero { padding-bottom: 76px; }
}

/* BADGES / STREAK */
.badge-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.ach-badge { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 600; }
.ach-badge.locked { opacity: .45; }
.ach-badge .emo { font-size: 18px; }
.streak-flame { font-size: 26px; }

/* SOS BUTTON (global) */
#sos-fab {
  position: fixed; right: 18px; bottom: 84px; z-index: 70;
  width: 64px; height: 64px; border-radius: 50%; background: var(--danger); color: #fff;
  border: none; font-weight: 800; font-size: 13px; cursor: pointer; box-shadow: 0 10px 30px rgba(214,69,91,.5);
  display: grid; place-items: center; user-select: none; touch-action: none;
}
#sos-fab.holding { transform: scale(.92); }
#sos-ring { position: fixed; right: 18px; bottom: 84px; z-index: 69; width: 64px; height: 64px; pointer-events: none; }
@media (max-width: 640px) { #sos-fab, #sos-ring { bottom: 92px; } }

/* CBT MODULES */
.module-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.module-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); cursor: pointer; transition: transform .2s; }
.module-card:hover { transform: translateY(-4px); }
.module-card h3 { margin: 0 0 6px; color: var(--teal-700); }
.module-card p { color: var(--text-muted); font-size: 14px; }
.thought-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 10px 0; }
@media (max-width: 600px){ .thought-row { grid-template-columns: 1fr; } }
.ground-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.ground-item { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }

/* COMMUNITY FEED */
.feed-compose { display: flex; gap: 10px; margin-bottom: 16px; }
.feed-post { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; }
.feed-post .fh { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.feed-post .fb { font-size: 14px; }
.react-row { display: flex; gap: 10px; margin-top: 10px; }
.react-btn { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; color: var(--text); }
.react-btn:hover { border-color: var(--teal-400); }

/* ONBOARDING TOUR */
#tour-overlay { position: fixed; inset: 0; background: rgba(10,15,15,.72); z-index: 1100; display: none; align-items: center; justify-content: center; padding: 20px; }
#tour-overlay.show { display: flex; animation: fade .3s; }
.tour-card { background: var(--surface); border-radius: 20px; max-width: 440px; width: 100%; padding: 28px; text-align: center; box-shadow: var(--shadow-lg); }
.tour-card .step-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--border); margin: 0 3px; }
.tour-card .step-dot.on { background: var(--teal-600); }

/* MY DATA */
.data-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 16px; margin: 10px 0; font-size: 14px; }
.btn-danger-outline { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); }

/* A11Y */
:focus-visible { outline: 3px solid var(--teal-400); 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; }
[data-theme="contrast"] { --bg:#000; --surface:#000; --surface-2:#111; --text:#fff; --text-muted:#ddd; --border:#444; --teal-700:#5fe3c8; --teal-600:#3fd0b4; }

