:root {
  --bg: #F3F4F8; --card: #FFFFFF; --ink: #14171D; --muted: #535B68; --line: #DCDFE6;
  --blue: #1D4ED8; --red: #C8102E; --alert: #C8102E; --amber: #B45309; --patient: #A9B2C1; --go: #38E0B0; --ok: #0F8A5F;
  --beat: 0.545s; /* 110 per minute */
  --font: 'Atkinson Hyperlegible', 'Noto Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
body.dark {
  --bg: #0E1116; --card: #1A1F27; --ink: #FFFFFF; --muted: #A7B0BD; --line: #2C333E;
  --patient: #4A5363; --blue: #6FA0FF; --alert: #FF7A8A; --amber: #F5B13D; --ok: #5EE0A6; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); -webkit-tap-highlight-color: transparent; transition: background .3s; }
#app { max-width: 480px; margin: 0 auto; }
#view { min-height: 100dvh; display: flex; flex-direction: column; }
button, a, select, textarea { font-family: inherit; }
button:focus-visible, a:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
button { -webkit-user-select: none; user-select: none; }

/* ---------- motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
@keyframes popIn { 0% { opacity: 0; transform: scale(.6); } 60% { transform: scale(1.08); } 100% { opacity: 1; transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes beatIcon { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.22); } 30% { transform: scale(1); } 45% { transform: scale(1.14); } }
@keyframes shine { 0% { transform: translateX(-120%); } 60%, 100% { transform: translateX(220%); } }
@keyframes ecgRun { to { stroke-dashoffset: -100; } }
@keyframes ripple { 0% { transform: scale(.9); opacity: .55; } 100% { transform: scale(2.1); opacity: 0; } }
@keyframes bars { 0%, 100% { transform: scaleY(.25); } 50% { transform: scaleY(1); } }
@keyframes drawCheck { to { stroke-dashoffset: 0; } }
@keyframes blink { 50% { opacity: .25; } }
#view.enter > header { animation: rise .35s var(--ease) backwards; }
#view.enter > main > *:not(.flash):not(.cd) { animation: rise .5s var(--ease) backwards; }
#view.enter > main > *:nth-child(2) { animation-delay: .05s; }
#view.enter > main > *:nth-child(3) { animation-delay: .1s; }
#view.enter > main > *:nth-child(4) { animation-delay: .15s; }
#view.enter > main > *:nth-child(5) { animation-delay: .2s; }
#view.enter > main > *:nth-child(n+6) { animation-delay: .25s; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; gap: 10px; padding: max(12px, env(safe-area-inset-top)) 16px 6px; }
.top h1 { flex: 1; margin: 0; font-size: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.iconbtn { width: 48px; height: 48px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); display: grid; place-items: center; cursor: pointer; flex: none; padding: 0; transition: transform .15s var(--ease), background .2s; }
.iconbtn:active { transform: scale(.92); }
.spacer { width: 48px; flex: none; }
.top:has(+ main .hero2) h1 { display: none; }
.top:has(+ main .hero2) { justify-content: flex-end; position: absolute; inset-inline: 0; max-width: 480px; margin: 0 auto; z-index: 3; }
.top:has(+ main .hero2) .spacer { display: none; }
.top:has(+ main .hero2) .iconbtn { background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .28); color: #fff; backdrop-filter: blur(6px); }

main { flex: 1; display: flex; flex-direction: column; gap: 16px; padding: 8px 16px 16px; }

/* animation stage */
.stage { background: var(--card); border: 1px solid var(--line); border-radius: 24px; aspect-ratio: 16 / 10; display: grid; place-items: center; overflow: hidden; position: relative; }
.stage::after { content: ""; position: absolute; inset: 0; background: radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--blue) 9%, transparent), transparent 70%); pointer-events: none; }
.stage svg { width: 100%; height: 100%; display: block; }

.line { margin: 0; font-size: clamp(26px, 7.6vw, 34px); font-weight: 700; text-align: center; line-height: 1.2; text-wrap: balance; }
.line.alert { color: var(--alert); animation: popIn .35s var(--ease); }
.sub { margin: -8px 0 0; text-align: center; color: var(--muted); font-size: 17px; text-wrap: balance; }
.note { margin: 0; text-align: center; color: var(--muted); font-size: 15px; }
.toast { margin: 0; text-align: center; color: var(--muted); font-size: 18px; font-weight: 700; }
.stepno { margin: -6px 0 -8px; text-align: center; color: var(--muted); font-size: 14px; font-weight: 700; letter-spacing: .08em; font-variant-numeric: tabular-nums; }
.dots { display: flex; justify-content: center; gap: 6px; }
.dots i { width: 28px; height: 6px; border-radius: 3px; background: var(--line); transition: background .3s, width .3s var(--ease); }
.dots i.done { background: color-mix(in srgb, var(--blue) 55%, var(--line)); }
.dots i.on { background: var(--blue); width: 44px; }

/* timers */
.timer { font-size: 60px; font-weight: 700; text-align: center; line-height: 1; font-variant-numeric: tabular-nums; }
.timer.up { display: flex; align-items: center; justify-content: center; gap: 14px; }
.timer .rec, .timer i.rec { width: 14px; height: 14px; border-radius: 50%; background: var(--red); animation: blink 1.2s ease-in-out infinite; flex: none; }
.ringtimer { position: relative; width: 168px; height: 168px; margin: 0 auto; display: grid; place-items: center; }
.ringtimer svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ringtimer circle { fill: none; stroke-width: 9; }
.ringtimer .rt-bg { stroke: var(--line); }
.ringtimer .rt-fg { stroke: var(--blue); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 0; transition: stroke-dashoffset .5s linear; }
.ringtimer .timer { font-size: 38px; }

/* buttons */
.acts { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.btn { min-height: 64px; border-radius: 18px; font-weight: 700; font-size: 21px; border: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 0 16px; text-decoration: none; position: relative; overflow: hidden; transition: transform .15s var(--ease), box-shadow .2s, opacity .2s; }
.btn:active { transform: scale(.97); }
.btn small { font-size: 14px; font-weight: 400; opacity: .85; }
.btn.tall { min-height: 76px; font-size: 23px; }
.btn.dark { background: var(--ink); color: var(--bg); box-shadow: 0 10px 20px -14px rgba(0, 0, 0, .6); }
.btn.out { background: transparent; color: var(--ink); border: 2px solid var(--ink); }
.btn.blue { background: var(--blue); color: #FFFFFF; box-shadow: 0 12px 22px -14px var(--blue); }
body.dark .btn.blue { color: #0B1220; }
.btn.ghost { background: transparent; color: var(--muted); min-height: 52px; font-size: 18px; }
.btn.ghost.attn { color: var(--ink); border: 2px solid var(--go); animation: callPulse 1.2s ease-in-out infinite; }
.btn:disabled { opacity: .4; cursor: default; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row2 .btn { font-size: 18px; min-height: 58px; }

.call { position: sticky; bottom: 0; margin: 0 16px max(16px, env(safe-area-inset-bottom)); min-height: 64px; border-radius: 18px; background: var(--red); color: #FFFFFF; display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 23px; font-weight: 700; text-decoration: none; box-shadow: 0 10px 24px -12px rgba(200, 16, 46, .8); z-index: 30; overflow: hidden; }
.call::after { content: ""; position: absolute; top: 0; bottom: 0; width: 40%; background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .28), transparent); animation: shine 4.5s ease-in-out infinite; }
.call svg { animation: ring .9s ease-in-out 3 .6s; transform-origin: 50% 50%; }
body.callfocus .call { animation: callPulse 1.2s ease-in-out infinite; }
@keyframes callPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.035); } }

/* ---------- home ---------- */
.hero2 { margin: -8px -16px 0; padding: max(64px, calc(env(safe-area-inset-top) + 56px)) 20px 20px; border-radius: 0 0 30px 30px; color: #fff; position: relative; overflow: hidden;
  background: radial-gradient(120% 140% at 100% 0%, #FF5B6E 0%, transparent 55%), linear-gradient(160deg, #B50F2A 0%, #7B0A1D 100%); box-shadow: 0 20px 36px -26px rgba(123, 10, 29, .9); }
.brandrow { display: flex; align-items: center; gap: 14px; }
.logo { width: 58px; height: 58px; border-radius: 18px; background: #fff; color: var(--red); display: grid; place-items: center; box-shadow: 0 8px 18px -8px rgba(0, 0, 0, .5); animation: beatIcon 2.2s ease-in-out infinite; }
.brandrow h2 { margin: 0; font-size: 30px; line-height: 1.05; }
.brandrow p { margin: 3px 0 0; opacity: .88; font-size: 16px; }
.ecg { display: block; width: 100%; height: 38px; margin: 14px 0 10px; overflow: visible; }
.ecg path { fill: none; stroke: rgba(255, 255, 255, .28); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.ecg::after { content: ""; }
.hero2 .ecg { --run: 1; }
.statrow { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 999px; background: rgba(255, 255, 255, .17); border: 1px solid rgba(255, 255, 255, .24); font-size: 14px; font-weight: 700; backdrop-filter: blur(4px); }
.pill b { font-size: 15px; }
.pill .live { width: 8px; height: 8px; border-radius: 50%; background: #5EE0A6; box-shadow: 0 0 0 0 rgba(94, 224, 166, .7); animation: livePing 1.8s ease-out infinite; }
.pill.warn .live { background: #FFD58A; animation: none; }
@keyframes livePing { 70%, 100% { box-shadow: 0 0 0 8px rgba(94, 224, 166, 0); } }

.assistcard { display: flex; align-items: center; gap: 14px; border: 0; border-radius: 22px; padding: 14px 16px; background: linear-gradient(135deg, #1D4ED8, #4F46E5); color: #fff; text-align: start; cursor: pointer; min-height: 84px; margin-top: -2px; box-shadow: 0 16px 28px -18px #1D4ED8; position: relative; overflow: hidden; transition: transform .15s var(--ease); }
.assistcard:active { transform: scale(.98); }
.assistcard::after { content: ""; position: absolute; top: 0; bottom: 0; width: 35%; background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .22), transparent); animation: shine 5s ease-in-out 1s infinite; }
.orbmini { width: 52px; height: 52px; border-radius: 16px; background: rgba(255, 255, 255, .2); display: grid; place-items: center; flex: none; }
.orbmini svg { animation: beatIcon 2.8s ease-in-out infinite; }
.at { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.at b { font-size: 20px; line-height: 1.15; }
.at small { font-size: 14px; opacity: .85; }
.amic { width: 48px; height: 48px; border-radius: 50%; background: #fff; color: #1D4ED8; display: grid; place-items: center; flex: none; }
.gh { margin: 4px 2px -6px; font-size: 13px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile { --tc: var(--blue); min-height: 112px; border-radius: 20px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 19px; font-weight: 700; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 14px; cursor: pointer; text-align: start; position: relative; overflow: hidden; line-height: 1.15; animation: popIn .5s var(--ease) backwards; animation-delay: calc(var(--i, 0) * 45ms + .1s); transition: transform .15s var(--ease), box-shadow .2s; }
.tile:active { transform: scale(.96); }
.tile .ti { width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; background: color-mix(in srgb, var(--tc) 14%, var(--card)); color: var(--tc); }
.tile::before { content: ""; position: absolute; inset-inline-end: -22px; top: -22px; width: 80px; height: 80px; border-radius: 50%; background: color-mix(in srgb, var(--tc) 9%, transparent); }
.tile.tone-red { --tc: var(--alert); }
.tile.tone-amber { --tc: var(--amber); }
.tile.tone-blue { --tc: var(--blue); }
.tile.big { grid-column: span 2; background: linear-gradient(135deg, #1B1F27, #0E1116); color: #fff; flex-direction: row; align-items: center; justify-content: flex-start; gap: 16px; min-height: 96px; font-size: 25px; border-color: transparent; box-shadow: 0 16px 26px -18px rgba(0, 0, 0, .7); }
.tile.big .ti { width: 58px; height: 58px; background: var(--red); color: #fff; }
.tile.big::before { background: rgba(200, 16, 46, .28); width: 120px; height: 120px; inset-inline-end: -30px; top: -30px; }
.tile .beating svg { animation: beatIcon 1.1s ease-in-out infinite; }
.locatecard { display: flex; align-items: center; gap: 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 20px; padding: 12px 16px; min-height: 74px; text-align: start; cursor: pointer; transition: transform .15s var(--ease); }
.locatecard:active { transform: scale(.98); }
.locatecard small { color: var(--muted); }
.pinwrap { width: 46px; height: 46px; border-radius: 15px; background: color-mix(in srgb, var(--blue) 14%, var(--card)); color: var(--blue); display: grid; place-items: center; flex: none; }
.pinwrap svg { animation: pinBob 2s ease-in-out infinite; }
@keyframes pinBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* ---------- setup ---------- */
.welcome { height: 150px; display: grid; place-items: center; color: var(--red); }
.welcome svg { height: 100%; width: auto; max-width: 100%; }
.setuphead { text-align: center; }
.setuphead h2 { margin: 0 0 6px; font-size: 30px; }
.setuphead p { margin: 0; color: var(--muted); font-size: 16px; text-wrap: balance; }
.group { display: flex; flex-direction: column; gap: 10px; }
.group > h3 { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 15px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.langs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.lang { min-height: 60px; border-radius: 16px; border: 2px solid var(--line); background: var(--card); color: var(--ink); font-size: 19px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 14px; cursor: pointer; text-align: start; transition: border-color .2s, background .2s, transform .15s var(--ease); }
.lang small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.lang.on { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 10%, var(--card)); }
.lang.on svg { color: var(--blue); animation: popIn .3s var(--ease); }
.lang:active { transform: scale(.97); }
.lang.busy { opacity: .6; }
.countryrow { display: flex; align-items: center; gap: 10px; }
.flag { font-size: 34px; width: 50px; text-align: center; flex: none; }
.countryrow select { flex: 1; min-width: 0; }
.numcard { display: flex; align-items: center; justify-content: space-between; border-radius: 16px; padding: 12px 16px; background: color-mix(in srgb, var(--red) 9%, var(--card)); border: 1px solid color-mix(in srgb, var(--red) 25%, var(--line)); color: var(--alert); font-weight: 700; }
.numcard span { display: flex; align-items: center; gap: 8px; }
.numcard b { font-size: 34px; font-variant-numeric: tabular-nums; }
.numcard b.pop, .chip.pop { animation: popIn .4s var(--ease); }

.chip { align-self: center; font-size: 15px; font-weight: 700; border-radius: 999px; padding: 6px 12px; background: var(--card); border: 1px solid var(--line); color: var(--muted); }
.chip.warn { background: #33290F; color: #FFD58A; border-color: transparent; }
body:not(.dark) .chip.warn { background: #FFF1D6; color: #7A4B00; }

/* ---------- CPR coach ---------- */
.count { font-size: 84px; font-weight: 700; text-align: center; line-height: 1; font-variant-numeric: tabular-nums; }
.count.bump { animation: bump .18s ease-out; }
@keyframes bump { 0% { transform: scale(1.08); } 100% { transform: scale(1); } }
.flash { position: fixed; inset: 0; background: #FFFFFF; opacity: 0; pointer-events: none; transition: opacity .07s; z-index: 5; }
.flash.on { opacity: .8; }
.swap { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; background: var(--card); border-radius: 16px; padding: 12px 14px; font-size: 17px; transition: background .3s; }
.swap b { font-variant-numeric: tabular-nums; }
.swap.now { background: var(--go); color: #0E1116; animation: callPulse .6s ease-in-out 6; }
.bar { grid-column: span 2; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--go); transition: width .5s linear; }

/* 3-2-1-Start overlay */
.cd { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: radial-gradient(circle at 50% 45%, #1B2430, #07090C 75%); color: #fff; text-align: center; transition: opacity .3s, transform .35s var(--ease); }
.cd.out { opacity: 0; transform: scale(1.15); pointer-events: none; }
.cdbox { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.cdbox p { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #A7B0BD; min-height: 28px; }
.cdn { font-size: min(46vw, 220px); font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; position: relative; }
.cdn::before { content: ""; position: absolute; left: 50%; top: 50%; width: 130%; aspect-ratio: 1; border-radius: 50%; border: 6px solid #38E0B0; transform: translate(-50%, -50%) scale(.6); opacity: 0; }
.cdn.pop { animation: cdPop 1s var(--ease); }
.cdn.pop::before { animation: cdRing 1s ease-out; }
.cd.go .cdn { color: #38E0B0; font-size: min(26vw, 130px); }
@keyframes cdPop { 0% { transform: scale(1.7); opacity: 0; } 18% { transform: scale(1); opacity: 1; } 85% { transform: scale(.94); opacity: 1; } 100% { transform: scale(.85); opacity: .35; } }
@keyframes cdRing { 0% { transform: translate(-50%, -50%) scale(.5); opacity: .8; } 100% { transform: translate(-50%, -50%) scale(1.2); opacity: 0; } }
.cd.go .cdn.pop { animation: cdGo .6s var(--ease); }
@keyframes cdGo { 0% { transform: scale(.5); opacity: 0; } 60% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); } }

.camwrap { position: relative; border-radius: 22px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; box-shadow: 0 0 0 0 rgba(56, 224, 176, .0); transition: box-shadow .1s; }
.camwrap.tick { box-shadow: 0 0 0 4px rgba(56, 224, 176, .9); }
.camwrap video, .camwrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.camwrap.mirror video, .camwrap.mirror canvas { transform: scaleX(-1); }
.camstatus { position: absolute; inset-inline-start: 12px; top: 12px; background: rgba(0, 0, 0, .7); color: #FFFFFF; border-radius: 10px; padding: 6px 10px; font-size: 15px; font-weight: 700; max-width: calc(100% - 80px); }
.flipbtn { position: absolute; inset-inline-end: 10px; top: 10px; width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .55); color: #fff; display: grid; place-items: center; cursor: pointer; transition: transform .3s var(--ease); z-index: 2; }
.flipbtn:active { transform: rotate(180deg) scale(.9); }
.camlock { position: absolute; inset-inline-start: 12px; bottom: 10px; color: #fff; background: rgba(0, 0, 0, .55); border-radius: 999px; width: 26px; height: 26px; display: grid; place-items: center; }
.cue { font-size: 38px; font-weight: 700; text-align: center; border-radius: 20px; padding: 14px; background: var(--card); transition: background .3s, color .3s; }
.cue.idle { color: var(--muted); }
.cue.good { background: #0F3B2B; color: #5EE0A6; }
.cue.fix { background: #3A2A06; color: #FFD58A; animation: popIn .3s var(--ease); }
.ratebox { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; background: var(--card); border-radius: 18px; padding: 12px 14px; }
.ratebox b { display: block; font-size: 40px; line-height: 1; font-variant-numeric: tabular-nums; }
.ratebox span { font-size: 13px; color: var(--muted); }
.pu { text-align: end; }
.pu b { font-size: 30px; }
.gauge { direction: ltr; position: relative; height: 10px; border-radius: 5px; background: var(--line); margin: 0 4px 16px; align-self: center; }
.gauge .zone { position: absolute; left: 40%; width: 20%; top: 0; bottom: 0; background: #1FBF8B; border-radius: 5px; opacity: .85; }
.gauge .marker { position: absolute; top: -6px; width: 6px; height: 22px; margin-left: -3px; border-radius: 3px; background: var(--ink); box-shadow: 0 0 0 3px var(--card); transition: left .35s var(--ease); }
.gauge em { position: absolute; top: 15px; font-style: normal; font-size: 10px; color: var(--muted); transform: translateX(-50%); }

/* ---------- assistant ---------- */
.orbwrap { display: flex; flex-direction: column; align-items: center; gap: 14px; padding-top: 6px; }
.orb { position: relative; width: 104px; height: 104px; border-radius: 50%; border: 0; background: linear-gradient(135deg, #1D4ED8, #4F46E5); color: #fff; display: grid; place-items: center; cursor: pointer; box-shadow: 0 18px 30px -16px #1D4ED8; transition: transform .15s var(--ease); }
body.dark .orb { color: #fff; }
.orb:active { transform: scale(.94); }
.orb svg { width: 40px; height: 40px; position: relative; z-index: 1; }
.orb i { position: absolute; inset: 0; border-radius: 50%; border: 3px solid #4F46E5; opacity: 0; }
.orb.listening { background: linear-gradient(135deg, #C8102E, #E23B54); box-shadow: 0 18px 30px -16px #C8102E; }
.orb.listening i { animation: ripple 1.8s ease-out infinite; border-color: #E23B54; }
.orb.listening i:nth-child(3) { animation-delay: .6s; }
.orb.listening i:nth-child(4) { animation-delay: 1.2s; }
.wave { display: flex; align-items: center; justify-content: center; gap: 5px; height: 34px; opacity: .25; transition: opacity .3s; }
.wave.on { opacity: 1; }
.wave b { width: 5px; height: 100%; border-radius: 3px; background: var(--blue); transform: scaleY(.25); }
.wave.on b { animation: bars .9s ease-in-out infinite; }
.wave b:nth-child(2n) { animation-delay: .15s; } .wave b:nth-child(3n) { animation-delay: .3s; } .wave b:nth-child(5n) { animation-delay: .45s; }
#aState { font-size: clamp(22px, 6vw, 28px); }
#aText { resize: none; min-height: 92px; font-size: 20px; }
.tipline { margin-top: -6px; font-size: 14px; }
.rescard { border: 2px solid var(--tc, var(--line)); border-radius: 22px; padding: 14px; background: color-mix(in srgb, var(--tc, var(--card)) 7%, var(--card)); display: flex; flex-direction: column; gap: 12px; animation: popIn .4s var(--ease); }
.rescard.tone-red { --tc: var(--alert); } .rescard.tone-amber { --tc: var(--amber); } .rescard.tone-blue { --tc: var(--blue); }
.reshead { display: flex; align-items: center; gap: 12px; }
.reshead .ti { width: 52px; height: 52px; border-radius: 16px; background: var(--tc); color: #fff; display: grid; place-items: center; flex: none; }
body.dark .reshead .ti { color: #0E1116; }
.reshead div { flex: 1; min-width: 0; }
.reshead small { display: block; color: var(--muted); font-size: 14px; }
.reshead b { font-size: 24px; line-height: 1.1; }
.callbadge { display: inline-flex; align-items: center; gap: 5px; background: var(--red); color: #fff; font-weight: 700; font-size: 14px; padding: 6px 10px; border-radius: 999px; animation: callPulse 1.2s ease-in-out infinite; }
.checking { margin: 0; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 15px; }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--blue); animation: spin .8s linear infinite; }
.altlabel { margin: 0; color: var(--muted); font-size: 14px; }
.altrow { display: flex; gap: 8px; flex-wrap: wrap; }
.altchip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 14px; padding: 10px 14px; font-weight: 700; font-size: 16px; cursor: pointer; min-height: 48px; }
.altchip.tone-red svg { color: var(--alert); } .altchip.tone-amber svg { color: var(--amber); } .altchip.tone-blue svg { color: var(--blue); }
.rescard.unsure { --tc: var(--line); }

/* ---------- location ---------- */
.pinstage { color: var(--blue); }
.locbox { display: flex; flex-direction: column; gap: 12px; text-align: center; }
.coords { margin: 0; font-size: clamp(26px, 7.4vw, 34px); font-weight: 700; font-variant-numeric: tabular-nums; animation: popIn .4s var(--ease); }
.scriptcard { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 14px 16px; }
.script { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.script li { display: flex; align-items: center; gap: 12px; font-size: 19px; font-weight: 700; animation: rise .5s var(--ease) backwards; animation-delay: calc(var(--i) * 70ms + .2s); }
.script li span { width: 30px; height: 30px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font-size: 15px; flex: none; }
body.dark .script li span { color: #0B1220; }

/* stroke */
.checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.check { min-height: 100px; border-radius: 18px; border: 2px solid var(--line); background: var(--card); color: var(--ink); font-size: 18px; font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 10px; cursor: pointer; transition: transform .15s var(--ease), border-color .2s, background .2s; }
.check:active { transform: scale(.96); }
.check[aria-pressed="true"] { border: 3px solid var(--alert); color: var(--alert); background: color-mix(in srgb, var(--red) 8%, var(--card)); animation: popIn .3s var(--ease); }

/* summary */
.okmark { width: 84px; height: 84px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; margin: 4px auto 0; animation: popIn .5s var(--ease); }
body.dark .okmark { color: #0E1116; }
.okmark svg path { stroke-dasharray: 30; stroke-dashoffset: 30; animation: drawCheck .5s .25s ease-out forwards; }
.rows { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 2px 16px; }
.rows div { display: flex; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--line); font-size: 19px; }
.rows div:last-child { border: 0; }
.rows b { font-variant-numeric: tabular-nums; }

/* feedback */
.stars { display: flex; justify-content: center; gap: 4px; }
.starbtn { width: 60px; height: 60px; border: 0; background: transparent; color: var(--line); cursor: pointer; display: grid; place-items: center; padding: 0; transition: transform .2s var(--ease), color .2s; }
.starbtn.on { color: #F2A900; transform: scale(1.1); }
.starbtn.on svg { fill: currentColor; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 17px; }
textarea, select { border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 18px; padding: 10px 12px; }
select { min-height: 52px; }
.switch { display: flex; align-items: center; gap: 12px; font-size: 16px; min-height: 48px; }
.switch input { width: 22px; height: 22px; accent-color: var(--blue); flex: none; }

/* settings sheet */
.sheet { border: 0; border-radius: 24px; padding: 0; width: min(440px, 92vw); background: var(--card); color: var(--ink); }
.sheet[open] { animation: popIn .3s var(--ease); }
.sheet::backdrop { background: rgba(0, 0, 0, .45); backdrop-filter: blur(3px); }
.sheetbody { display: flex; flex-direction: column; gap: 16px; padding: 20px; }
.sheetbody h2 { margin: 0; font-size: 24px; }
.sheetbody .field { gap: 8px; }

/* ---------- figures ---------- */
.fig .floor { stroke: var(--line); stroke-width: 3; }
.fig .p { fill: var(--patient); }
.fig .ps { stroke: var(--patient); fill: none; stroke-linecap: round; stroke-linejoin: round; }
.fig .pv { stroke: var(--patient); stroke-width: 12; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.fig .r { stroke: var(--ink); stroke-width: 12; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.fig .rf { fill: var(--ink); }
.fig .a { fill: var(--blue); }
.fig .as { stroke: var(--blue); stroke-width: 5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.fig .w { fill: #FFFFFF; stroke: var(--line); stroke-width: 2; }
.fig .wound { fill: var(--red); }
.fig .film { fill: var(--blue); opacity: .35; }
.fig g { transform-box: view-box; }

.cprPush { animation: cprPush var(--beat) ease-in-out infinite; transform-origin: 182px 120px; }
@keyframes cprPush { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-6deg); } }
.cprArrow { animation: fade var(--beat) ease-in-out infinite; }
.pulse { animation: fade .9s ease-in-out infinite; }
@keyframes fade { 0%, 100% { opacity: .15; } 50% { opacity: 1; } }
.tapArm { animation: tapArm .9s ease-in-out infinite; transform-origin: 150px 80px; }
@keyframes tapArm { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(7deg); } }
.breath { animation: breath 3s ease-in-out infinite; transform-origin: 130px 154px; }
@keyframes breath { 0%, 100% { transform: scaleY(.6); } 50% { transform: scaleY(1.6); } }
.ring { animation: ring .5s ease-in-out infinite; transform-origin: 160px 96px; }
@keyframes ring { 0%, 100% { transform: rotate(-7deg); } 50% { transform: rotate(7deg); } }
.roll { animation: roll 3.2s ease-in-out infinite; transform-origin: 170px 176px; }
@keyframes roll { 0% { transform: rotate(-16deg); opacity: .5; } 40%, 100% { transform: rotate(0); opacity: 1; } }
.strike { animation: strike 1s ease-in infinite; transform-origin: 176px 72px; }
@keyframes strike { 0% { transform: rotate(-35deg); } 28%, 40% { transform: rotate(0); } 100% { transform: rotate(-35deg); } }
.thrust { animation: thrust 1s ease-in-out infinite; }
@keyframes thrust { 0%, 60%, 100% { transform: translate(0, 0); } 25% { transform: translate(-7px, -7px); } }
.press { animation: press 1.6s ease-in-out infinite; }
@keyframes press { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(7px); } }
.flow { stroke-dasharray: 10 12; animation: flow .6s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -22; } }
.ringOff { animation: ringOff 2.2s ease-in-out infinite; }
@keyframes ringOff { 0%, 20% { transform: translateY(0); opacity: 1; } 80% { transform: translateY(-84px); opacity: 0; } 100% { opacity: 0; } }
.wrap { animation: wrap 2.6s ease-in-out infinite; }
@keyframes wrap { 0% { transform: translateX(-130px); opacity: 0; } 45%, 100% { transform: none; opacity: 1; } }

/* ECG line on the home hero */
.hero2 .ecg path.run { stroke: #fff; stroke-dasharray: 22 78; animation: ecgRun 2.4s linear infinite; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition-duration: .001ms !important; }
  .spin { animation-duration: 1.6s !important; animation-iteration-count: infinite !important; }
}

/* calm call bar for guides where a call is only needed if it gets worse */
.call.soft { min-height: 50px; font-size: 17px; background: var(--card); color: var(--alert); border: 2px solid color-mix(in srgb, var(--red) 40%, var(--line)); box-shadow: none; }
.call.soft::after { display: none; }
.call.soft svg { animation: none; }

.tile.wide { grid-column: span 2; flex-direction: row; align-items: center; justify-content: flex-start; gap: 14px; min-height: 80px; }

/* ---------- language picker ---------- */
.subhead { margin: 0; font-size: 15px; font-weight: 700; color: var(--muted); }
#langSuggest { display: flex; flex-direction: column; gap: 8px; }
.lang span { min-width: 0; overflow-wrap: anywhere; }
.alllangs { border: 1px solid var(--line); border-radius: 16px; background: var(--card); overflow: hidden; }
.alllangs > summary { min-height: 54px; display: flex; align-items: center; gap: 8px; padding: 0 16px; font-size: 17px; font-weight: 700; cursor: pointer; list-style: none; }
.alllangs > summary::-webkit-details-marker { display: none; }
.alllangs > summary::after { content: ""; width: 9px; height: 9px; margin-inline-start: auto; border: solid var(--muted); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); transition: transform .2s var(--ease); }
.alllangs[open] > summary::after { transform: rotate(-135deg); }
.alllangs .cnt { font-size: 13px; font-weight: 700; color: var(--muted); background: var(--bg); border-radius: 999px; padding: 2px 9px; }
.langq { display: block; width: calc(100% - 24px); margin: 0 12px 8px; min-height: 48px; font-size: 17px; }
.langlist { max-height: 300px; overflow-y: auto; overscroll-behavior: contain; border-top: 1px solid var(--line); }
.lrow { width: 100%; min-height: 56px; display: flex; align-items: center; gap: 10px; padding: 8px 16px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); font-size: 18px; font-weight: 700; text-align: start; cursor: pointer; }
.lrow[hidden] { display: none; }
.lrow:last-child { border-bottom: 0; }
.lrow .ln { flex: 1; min-width: 0; }
.lrow small { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }
.lrow em { font-style: normal; font-size: 12px; font-weight: 400; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.lrow.on { background: color-mix(in srgb, var(--blue) 10%, var(--card)); }
.lrow.on svg { color: var(--blue); flex: none; }
.lrow:active { background: color-mix(in srgb, var(--blue) 14%, var(--card)); }
.none { margin: 0; padding: 14px 16px; color: var(--muted); text-align: center; }
.mtnote { margin: 0; font-size: 14px; color: var(--muted); text-wrap: balance; }
.langnote { position: fixed; z-index: 40; inset-inline: 16px; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 76px); max-width: 448px; margin: 0 auto; padding: 10px 14px; border-radius: 14px; background: var(--card); border: 2px solid var(--amber); box-shadow: 0 10px 24px -12px rgba(0, 0, 0, .5); font-size: 15px; font-weight: 700; text-align: center; }

/* ---------- right-to-left (ar fa ur he) ---------- */
html[dir="rtl"] .mir { transform: scaleX(-1); }
html[dir="rtl"] .stepno, html[dir="rtl"] .timer, html[dir="rtl"] .count, html[dir="rtl"] .coords, html[dir="rtl"] #swapT { direction: ltr; unicode-bidi: isolate; }   /* clocks and counters keep their digit order */
html[dir="rtl"] .camwrap { direction: ltr; }   /* the video and pose overlay are not mirrored by the language */
html[dir="rtl"] .camwrap .camstatus { unicode-bidi: plaintext; }   /* Arabic message, but the box stays where the overlay puts it */
