:root{
  --bg1:#0f2a33; --bg2:#1c4a55; --ink:#f2efe8; --muted:#b8c9cc; --card:rgba(255,255,255,.07);
  --sand:#e8d3a8; --green:#2fb36b; --green2:#1d8a4f; --red:#d9483b; --red2:#a8332a; --idle:#3c6e7a; --idle2:#2a525c;
}
*{box-sizing:border-box}
html,body{margin:0;height:100%}
body{font:16px/1.45 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;color:var(--ink);
  background:var(--bg1);min-height:100dvh;display:flex;flex-direction:column;align-items:center;
  padding:max(16px,env(safe-area-inset-top)) 16px max(16px,env(safe-area-inset-bottom));-webkit-user-select:none;user-select:none}
.bg{position:fixed;inset:0;z-index:-1;background:
  radial-gradient(1200px 600px at 50% -10%, var(--bg2), transparent 70%),
  radial-gradient(800px 500px at 50% 110%, #24404a, transparent 70%), var(--bg1)}
.brand{display:flex;align-items:center;gap:14px;margin:8px 0 22px;width:100%;max-width:440px}
.logo{width:56px;height:56px}
h1{margin:0;font-size:24px;font-weight:600;letter-spacing:.5px}
.tag{margin:0;color:var(--muted);font-size:13px}
main{width:100%;max-width:440px;flex:1;display:flex;flex-direction:column}
.card{background:var(--card);border:1px solid rgba(255,255,255,.1);border-radius:18px;padding:22px;backdrop-filter:blur(6px)}
h2{margin:0 0 8px;font-size:20px;font-weight:600}
.hint{color:var(--muted);font-size:14px;margin:0 0 16px}
.tabs{display:flex;gap:6px;margin-bottom:18px;background:rgba(0,0,0,.2);padding:4px;border-radius:12px}
.tab{flex:1;border:0;background:transparent;color:var(--muted);padding:10px;border-radius:9px;font-size:15px}
.tab.active{background:rgba(255,255,255,.12);color:var(--ink)}
label{display:block;font-size:14px;color:var(--muted);margin-bottom:14px}
input:not([type=range]){display:block;width:100%;margin-top:6px;padding:12px 14px;border-radius:11px;border:1px solid rgba(255,255,255,.15);
  background:rgba(0,0,0,.25);color:var(--ink);font-size:17px}
input:focus{outline:2px solid var(--sand);outline-offset:1px}
button{font:inherit;cursor:pointer;-webkit-tap-highlight-color:transparent}
.primary{width:100%;padding:14px;border:0;border-radius:12px;background:var(--sand);color:#2a2415;font-weight:600;font-size:17px}
.primary:disabled{opacity:.5}
.msg{min-height:1.4em;margin:12px 0 0;font-size:14px;color:var(--sand)}
.msg.err{color:#ffb4a8}
.bar{height:10px;border-radius:6px;background:rgba(0,0,0,.3);overflow:hidden}
#dl-fill{height:100%;width:0;background:linear-gradient(90deg,var(--sand),#f6e9cc);transition:width .2s}

#player{display:flex;flex-direction:column;align-items:center;gap:26px;flex:1;justify-content:center}
.now{display:flex;justify-content:space-between;align-items:center;gap:12px;width:100%;min-height:76px;text-align:left}
.now-text{min-width:0;flex:1}
.section-name{margin:0;font-size:13px;letter-spacing:2px;text-transform:uppercase;color:var(--sand)}
.block-name{margin:4px 0 0;font-size:20px;font-weight:600;line-height:1.2}
.progress{margin:4px 0 0;color:var(--muted);font-size:13px}

.stage{display:flex;align-items:center;justify-content:center;gap:18px;width:100%}
.big{width:min(52vw,210px);flex:none;aspect-ratio:1;border-radius:50%;border:0;color:#fff;display:flex;flex-direction:column;align-items:center;justify-content:center;
  font-size:30px;font-weight:700;letter-spacing:1px;transition:transform .12s,background .3s,box-shadow .3s;
  background:radial-gradient(circle at 35% 30%,var(--idle),var(--idle2));box-shadow:0 18px 50px rgba(0,0,0,.45),inset 0 -8px 20px rgba(0,0,0,.25)}
.big:active{transform:scale(.96)}
.big .sub{font-size:13px;font-weight:400;opacity:.8;margin-top:6px;letter-spacing:.3px}
.big.playing{background:radial-gradient(circle at 35% 30%,var(--green),var(--green2));box-shadow:0 0 0 14px rgba(47,179,107,.18),0 18px 50px rgba(0,0,0,.45)}
.big.paused{background:radial-gradient(circle at 35% 30%,var(--red),var(--red2));box-shadow:0 0 0 14px rgba(217,72,59,.18),0 18px 50px rgba(0,0,0,.45);animation:pulse 1.6s ease-in-out infinite}
.big.done{background:radial-gradient(circle at 35% 30%,var(--sand),#b89b66);color:#2a2415}
@keyframes pulse{0%,100%{box-shadow:0 0 0 10px rgba(217,72,59,.15),0 18px 50px rgba(0,0,0,.45)}50%{box-shadow:0 0 0 22px rgba(217,72,59,.08),0 18px 50px rgba(0,0,0,.45)}}

.mixer{width:100%;display:flex;flex-direction:column;gap:6px}
.mixer label{display:grid;grid-template-columns:56px 1fr 40px;align-items:center;gap:12px;margin:0;color:var(--ink);font-size:15px}
.mixer output{text-align:right;color:var(--muted);font-variant-numeric:tabular-nums;font-size:13px}
input[type=range]{width:100%;accent-color:var(--sand);height:32px}

.phrase{min-height:2.6em;text-align:center;color:var(--muted);font-size:14px;font-style:italic;margin:0;max-width:340px}
.footer{display:flex;justify-content:space-between;align-items:center;width:100%;color:var(--muted);font-size:13px;gap:10px}
.link{background:none;border:0;color:var(--muted);text-decoration:underline;font-size:13px;padding:8px 0}
[hidden]{display:none!important}

/* therapist figure */
.figure-wrap{width:min(30vw,120px);height:min(75vw,300px);flex:none}
.figure{width:100%;height:100%;display:block}
.figure .prone-only,.figure .supine-only{display:none}
.figure[data-view=prone] .prone-only,.figure[data-view=supine] .supine-only{display:block}
.figure .zones ellipse{opacity:0;transition:opacity .4s}
.figure .zones ellipse.on{animation:zonepulse 2.4s ease-in-out infinite}
@keyframes zonepulse{0%,100%{opacity:.45}50%{opacity:1}}
@media (prefers-reduced-motion:reduce){.figure .zones ellipse.on{animation:none;opacity:.8}}

/* header controls, flags, help */
.brand{justify-content:space-between}
.brand-text{flex:1;min-width:0}
.hdr-right{display:flex;align-items:center;gap:8px}
.flags{display:flex;gap:4px;background:rgba(0,0,0,.25);padding:4px;border-radius:12px}
.flag{border:0;background:transparent;font-size:22px;line-height:1;padding:6px 7px;border-radius:9px;opacity:.45;filter:grayscale(.5)}
.flag.active{opacity:1;filter:none;background:rgba(255,255,255,.14)}
.help-btn{width:38px;height:38px;border-radius:50%;border:1px solid rgba(255,255,255,.25);background:rgba(0,0,0,.25);color:var(--sand);font-weight:700;font-size:18px}
.help .help-head{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:8px}
.help-close{border:0;background:rgba(255,255,255,.1);color:var(--ink);width:36px;height:36px;border-radius:50%;font-size:16px}
.help h3{font-size:16px;margin:16px 0 6px;color:var(--sand)}
.help p,.help li{font-size:15px;color:var(--ink);line-height:1.5}
.help ul{padding-left:20px;margin:0}
.help .dot{display:inline-block;width:12px;height:12px;border-radius:50%;vertical-align:-1px;margin-right:4px}
.help .dot.g{background:var(--green)}.help .dot.r{background:var(--red)}.help .dot.i{background:var(--idle)}
.help .warn{color:#ffd2c8;font-size:14px}

/* patient voice selector */
.patient{display:flex;align-items:center;justify-content:space-between;width:100%;gap:12px}
.patient-label{font-size:15px}
.seg{display:flex;background:rgba(0,0,0,.25);padding:4px;border-radius:12px;gap:4px}
.seg button{border:0;background:transparent;color:var(--muted);padding:8px 12px;border-radius:9px;font-size:14px}
.seg button.active{background:rgba(255,255,255,.14);color:var(--ink)}
.seg button:disabled{opacity:.5}
#player{gap:20px}

/* session clock + therapist instruction */
.timer{flex:none;font-variant-numeric:tabular-nums;font-size:34px;font-weight:600;letter-spacing:1px;color:#9deee6;opacity:.9;
  text-shadow:0 0 16px rgba(47,184,176,.55),0 0 2px rgba(157,238,230,.6);font-family:ui-monospace,SFMono-Regular,Menlo,monospace}
.instruction{margin:0;min-height:2.6em;text-align:center;color:var(--sand);font-size:15px;font-weight:600;line-height:1.3;max-width:360px}
.instruction.stop{color:#ffb4a8}
#player{gap:14px}
.phrase{min-height:1.4em;font-size:13px}


/* ---------- block progress bar (massage pacing) ---------- */
.clock-wrap{display:flex;flex-direction:column;align-items:flex-end;gap:6px}
.blockbar{display:flex;align-items:center;gap:8px;width:min(210px,42vw)}
.blockbar-track{flex:1;height:7px;border-radius:99px;background:rgba(255,255,255,.14);overflow:hidden}
#blockbar-fill{height:100%;width:0;border-radius:99px;background:hsl(140 62% 46%);transition:width .25s linear,background .6s linear}
.blockbar-left{font-variant-numeric:tabular-nums;font-size:.72rem;opacity:.75;white-space:nowrap;min-width:62px;text-align:right}
.blockbar-left.over{color:var(--red);opacity:1;font-weight:600}

/* Working: the therapist is on the body. Calm and steady, deliberately NOT the red pulse,
   so the alert states below still mean something. */
.big.working{background:radial-gradient(circle at 35% 30%,#3f7f93,#2b5c6d);box-shadow:0 0 0 14px rgba(63,127,147,.16),0 18px 50px rgba(0,0,0,.45)}
/* Manual mode, block target passed: move on. */
.big.working.alert{background:radial-gradient(circle at 35% 30%,var(--red),var(--red2));animation:alertflash .7s steps(1,end) infinite}
/* Auto mode, about to advance by itself. */
.big.working.warn{background:radial-gradient(circle at 35% 30%,#c98a2e,#a96f1d);animation:alertflash 1s steps(1,end) infinite}
@keyframes alertflash{0%,49%{box-shadow:0 0 0 26px rgba(217,72,59,.30),0 18px 50px rgba(0,0,0,.45);filter:brightness(1.18)}50%,100%{box-shadow:0 0 0 10px rgba(217,72,59,.10),0 18px 50px rgba(0,0,0,.45);filter:brightness(.92)}}
@media (prefers-reduced-motion:reduce){.big.working.alert,.big.working.warn{animation-duration:2.4s}}

.link.hold{font-weight:600;white-space:nowrap;flex:none}
.link.hold.held{color:var(--red)}
@media (max-width:430px){.blockbar{width:min(160px,46vw)}.blockbar-left{font-size:.66rem;min-width:54px}}

/* --- invitation requests + admin footer link (10 Sep) --- */
.apply-row{display:flex;align-items:center;justify-content:center;gap:8px;margin:14px 0 0;color:var(--muted);font-size:13px;flex-wrap:wrap}
.apply-row .link{padding:0;color:var(--sand)}
#apply textarea{width:100%;box-sizing:border-box;background:rgba(0,0,0,.25);border:1px solid rgba(255,255,255,.14);border-radius:10px;color:var(--ink);padding:11px;font:inherit;resize:vertical}
#apply h2{margin:0 0 6px;font-size:20px}
.page-foot{width:100%;max-width:440px;text-align:center;margin:18px 0 8px}
.page-foot a{color:var(--muted);opacity:.55;font-size:12px;text-decoration:none}
.page-foot a:hover{opacity:1;text-decoration:underline}
