*{box-sizing:border-box}
html,body{margin:0;padding:0}

:root{
  --bg1:#edf6ff;
  --bg2:#f7fbff;
  --surface:rgba(255,255,255,.74);
  --surface-2:rgba(255,255,255,.58);
  --surface-3:rgba(255,255,255,.44);
  --line:rgba(41,72,97,.10);
  --text:#163047;
  --muted:#6f8798;
  --primary:#73c7e8;
  --primary-2:#b2e6f8;
  --accent:#9fd8c8;
  --danger:#cf5a62;
  --shadow:0 18px 46px rgba(24,53,81,.10);
  --ring:0 0 0 1px rgba(255,255,255,.18) inset;
  --btnText:#143042;
}

body[data-theme="patient"]{
  --bg1:#eef7ff;
  --bg2:#f8fcff;
  --surface:rgba(255,255,255,.74);
  --surface-2:rgba(255,255,255,.58);
  --surface-3:rgba(255,255,255,.45);
  --line:rgba(39,77,106,.10);
  --text:#183144;
  --muted:#6e8698;
  --primary:#7dcaf0;
  --primary-2:#bfe8fb;
  --accent:#a6ddcf;
  --btnText:#143042;
}

body[data-theme="child"]{
  --bg1:#fff6f0;
  --bg2:#fffbf7;
  --surface:rgba(255,255,255,.82);
  --surface-2:rgba(255,255,255,.68);
  --surface-3:rgba(255,255,255,.54);
  --line:rgba(133,93,62,.10);
  --text:#533728;
  --muted:#8f7564;
  --primary:#ffbf8d;
  --primary-2:#ffe0bf;
  --accent:#ffd2e1;
  --btnText:#533728;
}

body[data-theme="sport"]{
  --bg1:#eefaf3;
  --bg2:#f8fffb;
  --surface:rgba(255,255,255,.74);
  --surface-2:rgba(255,255,255,.58);
  --surface-3:rgba(255,255,255,.45);
  --line:rgba(35,93,62,.10);
  --text:#173927;
  --muted:#688774;
  --primary:#86dbab;
  --primary-2:#c5f0d7;
  --accent:#97d3f2;
  --btnText:#173927;
}

body[data-theme="night"]{
  --bg1:#0d1825;
  --bg2:#132234;
  --surface:rgba(18,31,47,.76);
  --surface-2:rgba(18,31,47,.60);
  --surface-3:rgba(18,31,47,.48);
  --line:rgba(201,222,241,.10);
  --text:#eaf4ff;
  --muted:#9db3c8;
  --primary:#73d9e8;
  --primary-2:#a3edf5;
  --accent:#7fc6de;
  --shadow:0 24px 60px rgba(0,0,0,.28);
  --ring:0 0 0 1px rgba(255,255,255,.04) inset;
  --btnText:#0d2330;
}

body{
  min-height:100vh;
  color:var(--text);
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  background:
    radial-gradient(circle at 0% 0%, rgba(255,255,255,.8), transparent 26%),
    radial-gradient(circle at 100% 8%, rgba(255,255,255,.35), transparent 20%),
    linear-gradient(135deg,var(--bg1),var(--bg2));
  -webkit-font-smoothing:antialiased;
}

.hidden{display:none!important}

.app-shell{
  min-height:100vh;
  padding:18px;
}

.topbar,
.main-wrap{
  width:min(1420px,100%);
  margin:0 auto;
}

.topbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:16px;
  padding:12px 6px 20px;
}

.brand{
  display:flex;
  align-items:center;
  gap:14px;
}

.logo{
  width:72px;
  height:72px;
  flex:0 0 auto;
}

.eyebrow{
  margin:0 0 4px;
  color:var(--muted);
  font-size:.74rem;
  line-height:1;
  text-transform:uppercase;
  letter-spacing:.14em;
}

h1{
  margin:0;
  font-size:1.38rem;
  line-height:1.05;
  font-weight:760;
}

h2,h3{
  margin:0 0 10px;
}

p{
  line-height:1.55;
}

.screen{display:none}
.screen.active{display:block}

.card{
  background:linear-gradient(180deg,var(--surface),var(--surface-2));
  border:1px solid var(--line);
  border-radius:28px;
  box-shadow:var(--shadow),var(--ring);
  backdrop-filter:blur(18px) saturate(1.06);
  -webkit-backdrop-filter:blur(18px) saturate(1.06);
  padding:24px;
}

.card-hero{
  display:grid;
  grid-template-columns:1.55fr 1fr;
  gap:22px;
  margin-bottom:18px;
}

.hero-copy h2{
  font-size:clamp(1.58rem,2.8vw,2.48rem);
  line-height:1.08;
  margin:0 0 12px;
}

.hero-copy p:last-child{
  margin:0;
  color:var(--muted);
  max-width:72ch;
}

.home-grid{
  display:grid;
  grid-template-columns:1fr 1.12fr;
  gap:18px;
}

.section-head{
  margin-bottom:16px;
}

.section-note{
  margin:0;
  color:var(--muted);
}

.program-list{
  display:grid;
  gap:12px;
}

.program-card{
  width:100%;
  border:1px solid var(--line);
  border-radius:22px;
  background:linear-gradient(180deg,var(--surface-3),rgba(255,255,255,.18));
  padding:16px 17px;
  text-align:left;
  cursor:pointer;
  color:var(--text);
  transition:transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease;
  box-shadow:0 8px 24px rgba(17,41,63,.04);
}

.program-card:hover{
  transform:translateY(-1px);
  box-shadow:0 12px 28px rgba(17,41,63,.08);
}

.program-card.active{
  border-color:var(--primary);
  background:linear-gradient(180deg,rgba(255,255,255,.56),rgba(255,255,255,.24));
  box-shadow:0 0 0 1px rgba(255,255,255,.20) inset, 0 14px 30px rgba(19,48,71,.10);
}

body[data-theme="night"] .program-card{
  background:linear-gradient(180deg,rgba(255,255,255,.05),rgba(255,255,255,.03));
  box-shadow:none;
}

body[data-theme="night"] .program-card.active{
  background:linear-gradient(180deg,rgba(255,255,255,.09),rgba(255,255,255,.05));
  box-shadow:0 0 0 1px rgba(255,255,255,.04) inset;
}

.program-card strong{
  display:block;
  margin-bottom:6px;
  font-size:1.01rem;
  color:var(--text);
}

.program-card p{
  margin:0;
  color:var(--muted);
}

.meta{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-top:10px;
}

.tag{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:34px;
  padding:8px 14px;
  border-radius:999px;
  background:rgba(255,255,255,.42);
  border:1px solid var(--line);
  color:var(--text);
  font-size:.87rem;
  font-weight:600;
  box-shadow:0 1px 0 rgba(255,255,255,.15) inset;
}

body[data-theme="night"] .tag{
  background:rgba(255,255,255,.08);
  color:var(--text);
  border:1px solid rgba(255,255,255,.10);
}

.form-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:14px;
}

.advanced-grid{
  margin-top:14px;
}

.field{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.field span{
  font-weight:650;
}

.field small{
  color:var(--muted);
}

.field-checkbox{
  justify-content:flex-end;
}

select,
input[type="range"],
input[type="checkbox"]{
  width:100%;
}

select{
  padding:13px 14px;
  border-radius:16px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.65);
  color:var(--text);
  outline:none;
  box-shadow:0 1px 0 rgba(255,255,255,.22) inset;
}

body[data-theme="night"] select{
  background:rgba(255,255,255,.06);
  color:var(--text);
}

input[type="range"]{
  accent-color:var(--primary);
}

input[type="checkbox"]{
  width:22px;
  height:22px;
  accent-color:var(--primary);
}

.advanced{
  margin-top:14px;
  padding-top:14px;
  border-top:1px dashed var(--line);
}

.advanced summary{
  cursor:pointer;
  font-weight:700;
}

.actions{
  display:flex;
  gap:12px;
  flex-wrap:wrap;
  margin-top:20px;
}

.btn{
  appearance:none;
  border:none;
  border-radius:999px;
  padding:13px 18px;
  font-weight:740;
  cursor:pointer;
  transition:transform .16s ease, box-shadow .16s ease, opacity .16s ease, background .16s ease, border-color .16s ease;
}

.btn:hover{
  transform:translateY(-1px);
}

.btn-primary{
  background:linear-gradient(135deg,var(--primary),var(--primary-2));
  color:var(--btnText);
  box-shadow:0 12px 28px rgba(74,139,166,.18);
}

.btn-secondary{
  background:rgba(255,255,255,.58);
  color:var(--text);
  border:1px solid var(--line);
}

.btn-ghost{
  background:transparent;
  color:var(--text);
  border:1px solid var(--line);
}

.btn-danger{
  color:var(--danger);
  border-color:rgba(207,90,98,.22);
}

.top-actions{
  display:flex;
  gap:10px;
  align-items:center;
}

.session-grid{
  display:grid;
  grid-template-columns:1.34fr .78fr;
  gap:18px;
}

.card-session{
  padding-bottom:22px;
}

.session-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:14px;
}

.mini-metrics{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

.metric-chip{
  min-width:116px;
  background:rgba(255,255,255,.34);
  border:1px solid var(--line);
  border-radius:18px;
  padding:12px 14px;
}

body[data-theme="night"] .metric-chip{
  background:rgba(255,255,255,.05);
}

.metric-chip span,
.stat-card span{
  display:block;
  color:var(--muted);
  font-size:.86rem;
}

.metric-chip strong,
.stat-card strong{
  display:block;
  margin-top:4px;
  font-size:1.18rem;
}

.canvas-wrap{
  margin-top:14px;
  position:relative;
}

#breathCanvas{
  width:100%;
  height:auto;
  display:block;
  aspect-ratio:1/1;
  border-radius:28px;

  background:
    radial-gradient(circle at center,
      rgba(255,255,255,.95) 0%,
      rgba(255,255,255,.6) 40%,
      rgba(255,255,255,.2) 60%,
      transparent 70%),
    radial-gradient(circle at center,
      rgba(115,199,232,.35),
      transparent 65%);

  box-shadow:
    0 0 60px rgba(115,199,232,.35),
    0 0 120px rgba(115,199,232,.25),
    inset 0 0 0 1px rgba(255,255,255,.15);

  transition:transform 4s cubic-bezier(.4,0,.2,1),
             box-shadow 4s cubic-bezier(.4,0,.2,1);
}

body[data-theme="night"] #breathCanvas{
  background:
    radial-gradient(circle at center, rgba(255,255,255,.10), rgba(255,255,255,.03) 48%, transparent 72%),
    radial-gradient(circle at center, color-mix(in srgb, var(--primary-2) 28%, transparent), transparent 58%);
}

.hint{
  margin:14px 0 0;
  color:var(--muted);
}

.session-side{
  display:grid;
  gap:18px;
}

.metric-list{
  display:grid;
  gap:10px;
}

.metric-list div{
  display:flex;
  justify-content:space-between;
  gap:12px;
  padding-bottom:10px;
  border-bottom:1px dashed var(--line);
}

.metric-list div:last-child{
  border-bottom:none;
  padding-bottom:0;
}

.tips{
  margin:0;
  padding-left:18px;
  color:var(--muted);
}

.tips li+li{
  margin-top:8px;
}

.stats-cards{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:12px;
}

.stat-card{
  min-width:116px;
  background:rgba(255,255,255,.36);
  border:1px solid var(--line);
  border-radius:20px;
  padding:14px;
}

body[data-theme="night"] .stat-card{
  background:rgba(255,255,255,.05);
}

.chart-box{
  margin-top:18px;
  padding:14px;
  border:1px solid var(--line);
  border-radius:24px;
  background:rgba(255,255,255,.24);
}

body[data-theme="night"] .chart-box{
  background:rgba(255,255,255,.03);
}

#statsChart{
  width:100%;
  height:auto;
  display:block;
}

.history-list{
  display:grid;
  gap:10px;
  max-height:760px;
  overflow:auto;
  padding-right:2px;
}

.history-item{
  padding:14px;
  border-radius:18px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.28);
}

body[data-theme="night"] .history-item{
  background:rgba(255,255,255,.04);
}

.history-item strong{
  display:block;
  margin-bottom:4px;
}

.muted{
  color:var(--muted);
}

.countdown{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background:rgba(0,0,0,.35);
  backdrop-filter:blur(6px);
  z-index:9999;
}

.countdown div{
  font-size:120px;
  font-weight:800;
  color:white;
  text-shadow:0 10px 40px rgba(0,0,0,.5);
  animation:countPulse 1s ease infinite;
}

@keyframes countPulse{
  0%{transform:scale(.9);opacity:.6}
  50%{transform:scale(1);opacity:1}
  100%{transform:scale(.9);opacity:.6}
}

@media (max-width:1080px){
  .card-hero,
  .home-grid,
  .session-grid{
    grid-template-columns:1fr;
  }
}

@media (max-width:760px){
  .app-shell{padding:14px}
  .topbar{
    flex-direction:column;
    align-items:stretch;
    padding-bottom:14px;
  }
  .top-actions{
    justify-content:flex-end;
  }
  .card{
    padding:18px;
    border-radius:24px;
  }
  .form-grid,
  .stats-cards{
    grid-template-columns:1fr;
  }
  .actions{
    flex-direction:column;
  }
  .btn{
    width:100%;
  }
  .session-head{
    flex-direction:column;
  }
}

/* ===== FULLSCREEN SESSION STABLE ===== */

body.fullscreen-session{
  overflow:hidden;
  background:#000;
}

body.fullscreen-session .topbar,
body.fullscreen-session .session-side{
  display:none !important;
}

body.fullscreen-session .app-shell,
body.fullscreen-session .main-wrap{
  width:100vw;
  max-width:none;
  height:100vh;
  margin:0;
  padding:0;
}

body.fullscreen-session #homeScreen,
body.fullscreen-session #statsScreen{
  display:none !important;
}

body.fullscreen-session #sessionScreen{
  display:block !important;
  position:fixed;
  inset:0;
  width:100vw;
  height:100vh;
  z-index:9999;
  background:#000;
  overflow:hidden;
}

body.fullscreen-session .session-grid{
  display:block;
  width:100%;
  height:100%;
}

body.fullscreen-session .card-session{
  position:relative;
  width:100%;
  height:100%;
  padding:0;
  margin:0;
  border:none;
  border-radius:0;
  box-shadow:none;
  background:transparent;
  backdrop-filter:none;
  -webkit-backdrop-filter:none;
}

body.fullscreen-session .canvas-wrap{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  margin:0;
}

body.fullscreen-session #breathCanvas{
  position:absolute;
  inset:0;
  width:100vw;
  height:100vh;
  aspect-ratio:auto;
  border-radius:0;
  box-shadow:none;
  background:#000;
}

body.fullscreen-session .session-head{
  position:absolute;
  top:56px;
  left:50%;
  transform:translateX(-50%);
  z-index:20;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:14px;
  text-align:center;
  color:#fff;
  width:min(92vw,560px);
}

body.fullscreen-session .mini-metrics{
  justify-content:center;
}

body.fullscreen-session .metric-chip{
  background:rgba(255,255,255,.14);
  border:1px solid rgba(255,255,255,.12);
  color:#fff;
  backdrop-filter:blur(10px);
  -webkit-backdrop-filter:blur(10px);
}

body.fullscreen-session .metric-chip span{
  color:rgba(255,255,255,.72);
}

body.fullscreen-session .metric-chip strong{
  color:#fff;
}

body.fullscreen-session .hint{
  position:absolute;
  left:50%;
  bottom:150px;
  transform:translateX(-50%);
  z-index:20;
  color:#fff;
  text-align:center;
  width:min(90vw,520px);
  margin:0;
}

body.fullscreen-session .actions{
  position:absolute;
  left:50%;
  bottom:36px;
  transform:translateX(-50%);
  z-index:20;
  justify-content:center;
  margin:0;
  width:min(94vw,720px);
}

body.fullscreen-session .btn{
  width:auto;
}

@media (max-width:760px){
  body.fullscreen-session .session-head{
    top:42px;
  }

  body.fullscreen-session .hint{
    bottom:132px;
  }

  body.fullscreen-session .actions{
    bottom:22px;
    width:min(92vw,420px);
  }
}
.breathing-inhale #breathCanvas{
  transform:scale(1.08);
  box-shadow:
    0 0 80px rgba(115,199,232,.45),
    0 0 160px rgba(115,199,232,.35);
}

.breathing-exhale #breathCanvas{
  transform:scale(0.92);
  box-shadow:
    0 0 40px rgba(115,199,232,.25),
    0 0 80px rgba(115,199,232,.2);
}
body.breathing-inhale #breathCanvas{
  filter:brightness(1.06) saturate(1.08);
}

body.breathing-exhale #breathCanvas{
  filter:brightness(.96) saturate(.98);
}

body.breathing-holdHigh #breathCanvas,
body.breathing-holdLow #breathCanvas{
  filter:brightness(1.01);
}
body.breathing-inhale #breathCanvas{

filter:brightness(1.08) saturate(1.1);
transform:scale(1.02);

}

body.breathing-exhale #breathCanvas{

filter:brightness(.95) saturate(.95);
transform:scale(.98);

}

body.breathing-holdHigh #breathCanvas{

filter:brightness(1.02);

}

body.breathing-holdLow #breathCanvas{

filter:brightness(1);

}
body.fullscreen-session{

background:
radial-gradient(circle at center,
rgba(120,200,255,.15),
rgba(0,0,0,0) 60%),
#000;

}
#breathCanvas{

transition:
filter .6s ease,
transform 4s cubic-bezier(.4,0,.2,1);

}