/* ===== BASE: layout, colours, tabs, buttons, scenario list ===== */
/* Public web app styles. Mobile first, right-to-left, large text for emergencies.
   No inline styles are used anywhere (strict CSP: style-src 'self'). */
:root {
  --bg: #f6f7f9; --card: #ffffff; --ink: #1d2433; --muted: #5b6577; --line: #e1e5ec;
  --brand: #b42318; --brand-d: #8f1c13; --ok: #067647; --warn: #b54708; --info: #175cd3;
  --critical: #b42318; --urgent: #d9480f; --moderate: #b7791f; --minor: #2f855a;
  --radius: 14px; --shadow: 0 1px 3px rgba(16, 24, 40, .1);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); line-height: 1.6; font-size: 17px;
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans Arabic", "Noto Naskh Arabic", Tahoma, Arial, sans-serif;
}
.hidden { display: none !important; }
a { color: var(--info); }

/* ---- header ---- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--brand); color: #fff; padding: 10px 14px; position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { border-radius: 9px; background: #fff; }
.brand b { display: block; font-size: 17px; line-height: 1.2; }
.brand small { display: block; opacity: .9; font-size: 12px; }
.call123 { flex: none; background: #fff; color: var(--brand); font-weight: 800; text-decoration: none; padding: 9px 16px; border-radius: 999px; font-size: 17px; }
.call123:active { transform: scale(.97); }
.disclaimer { background: #fffaeb; color: #7a2e0e; border-bottom: 1px solid #fedf89; padding: 8px 14px; font-size: 14px; text-align: center; }

/* ---- tabs ---- */
.tabs { display: flex; gap: 6px; padding: 10px 12px 0; max-width: 860px; margin: 0 auto; overflow-x: auto; }
.tabs a { flex: 1 1 auto; text-align: center; text-decoration: none; color: var(--muted); background: #e9edf3; padding: 10px 8px; font-size: 14px; border-radius: 12px 12px 0 0; font-weight: 700; white-space: nowrap; }
.tabs a.active { background: var(--card); color: var(--brand); box-shadow: 0 -2px 0 var(--brand) inset; }

main { max-width: 860px; margin: 0 auto; padding: 14px 12px 30px; background: var(--card); min-height: 60vh; border-radius: 0 0 var(--radius) var(--radius); box-shadow: var(--shadow); }
.section-title { font-size: 19px; margin: 18px 0 10px; }
.hint { color: var(--muted); font-size: 14px; margin: 6px 0; }

/* ---- buttons / inputs ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 16px; border-radius: 12px; border: 1px solid var(--line); background: #eef1f6; color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; min-height: 46px; }
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.danger { background: #7a1710; border-color: #7a1710; color: #fff; }
.btn.secondary { background: #667085; border-color: #667085; color: #fff; }
.btn.ai { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.btn.big { width: 100%; font-size: 21px; min-height: 58px; }
.counter { background: rgba(255, 255, 255, .25); border-radius: 999px; padding: 1px 9px; font-size: 13px; }
.searchbar { display: flex; flex-wrap: wrap; gap: 8px; }
.searchbar input { flex: 1 1 150px; min-width: 0; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; font: inherit; min-height: 48px; }
.searchbar #ai-btn { flex: 1 1 100%; }
.searchbar input:focus, textarea:focus, input:focus { outline: 3px solid #fda29b; border-color: var(--brand); }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

.status { margin: 10px 0; min-height: 4px; color: var(--muted); }
.status.loading::before { content: ""; display: inline-block; width: 14px; height: 14px; border: 3px solid #c7d2e5; border-top-color: var(--info); border-radius: 50%; margin-inline-end: 8px; vertical-align: -2px; animation: spin 0.9s linear infinite; }
.status.error { color: #b42318; font-weight: 700; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- red flag banner ---- */
.flag { background: #7a1710; color: #fff; border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; }
.flag ul { margin: 6px 0 10px; padding-inline-start: 22px; }
.flag .btn { background: #fff; color: #7a1710; }

/* ---- home list ---- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { border: 1px solid var(--line); background: #f2f4f7; padding: 7px 14px; border-radius: 999px; cursor: pointer; font: inherit; font-weight: 600; color: var(--ink); }
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.list { display: grid; gap: 8px; }
.item { display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: start; width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer; font: inherit; color: var(--ink); }
.item:hover { border-color: var(--brand); }
.item .t { font-weight: 700; }
.badge { flex: none; font-size: 12px; font-weight: 800; padding: 2px 10px; border-radius: 999px; color: #fff; }
.badge.critical { background: var(--critical); } .badge.urgent { background: var(--urgent); }
.badge.moderate { background: var(--moderate); } .badge.minor { background: var(--minor); }

/* ---- scenario ---- */
.scenario .head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin: 6px 0 10px; }
.scenario h2 { margin: 0; font-size: 24px; line-height: 1.3; }
.back { background: none; border: 0; color: var(--info); font: inherit; font-weight: 700; cursor: pointer; padding: 6px 0; }
.callbar { display: block; text-align: center; background: var(--brand); color: #fff; text-decoration: none; font-weight: 800; font-size: 22px; padding: 14px; border-radius: 14px; margin: 10px 0; }
.steps { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 10px; counter-reset: step; }
.step { counter-increment: step; display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.step img { width: 96px; height: 72px; border-radius: 10px; background: #eef3f8; object-fit: contain; }
.step p { margin: 0; font-size: 19px; font-weight: 700; line-height: 1.5; }
.step p::before { content: counter(step); display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; margin-inline-end: 8px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 15px; vertical-align: 2px; }
.box { border-radius: var(--radius); padding: 12px 14px; margin: 10px 0; }
.box h3 { margin: 0 0 6px; font-size: 17px; }
.box ul { margin: 0; padding-inline-start: 22px; }
.box.dont { background: #fef3f2; border: 1px solid #fecdca; }
.box.call { background: #fff7ed; border: 1px solid #fed7aa; }
details.more { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin: 10px 0; background: #fafbfc; }
details.more summary { cursor: pointer; font-weight: 800; }
details.more p { margin: 8px 0 0; white-space: pre-line; }
.sources { font-size: 14px; color: var(--muted); }
.sources ul { margin: 4px 0; padding-inline-start: 20px; word-break: break-word; }
.notice { border-radius: 12px; padding: 9px 12px; margin: 10px 0; font-size: 14px; }
.notice.review { background: #fffaeb; border: 1px solid #fedf89; color: #7a2e0e; }
.notice.ai { background: #eff4ff; border: 1px solid #b2ccff; color: #1d3a8a; }
.notice.ok { background: #ecfdf3; border: 1px solid #abefc6; color: var(--ok); }
.related { margin-top: 18px; }

/* ---- chat ---- */
.chat-log { display: grid; gap: 10px; margin: 12px 0; max-height: 52vh; overflow-y: auto; padding: 4px; }
.msg { max-width: 92%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; word-break: break-word; }
.msg.user { background: #e0ecff; justify-self: start; }
.msg.bot { background: #f2f4f7; justify-self: end; border: 1px solid var(--line); }
.msg.err { background: #fef3f2; border: 1px solid #fecdca; color: #b42318; justify-self: stretch; max-width: 100%; }
.msg.urgent { border: 2px solid var(--brand); }
.msg .src { display: block; margin-top: 8px; font-size: 13px; color: var(--muted); white-space: normal; }
.msg .src a { display: block; word-break: break-word; }
.chat-steps { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; white-space: normal; }
.chat-steps li { display: flex; gap: 10px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; }
.chat-steps img { width: 64px; height: 64px; object-fit: contain; flex: none; }
.msg .related { display: block; margin-top: 8px; font-size: 14px; white-space: normal; }
.msg .related a { display: inline-block; margin: 4px 0 0 6px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: #fff; }
.msg .note { display: block; margin-top: 8px; font-size: 13px; color: var(--muted); white-space: normal; }
.chat-form { display: flex; gap: 8px; align-items: stretch; }
.chat-photo { display: flex; align-items: center; gap: 10px; margin: 8px 0; padding: 8px; background: #f2f4f7; border: 1px solid var(--line); border-radius: 12px; font-size: 14px; }
.chat-photo img, .chat-thumb { object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.chat-thumb { display: block; margin-bottom: 6px; }
.chat-form textarea { flex: 1; resize: vertical; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; font: inherit; min-height: 52px; }

/* ---- numbers ---- */
.numbers { display: grid; gap: 8px; }
.num { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.num b { font-size: 18px; display: block; }
.num small { color: var(--muted); }
.num a { font-size: 26px; font-weight: 900; color: var(--brand); text-decoration: none; direction: ltr; }

/* ---- kit ---- */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 12px 0; }
.card h3 { margin: 0 0 8px; }
.script { margin: 6px 0; padding-inline-start: 24px; }
.loc-out input { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 10px; direction: ltr; font: inherit; margin-top: 8px; }
.tq-time { font-size: 40px; font-weight: 900; direction: ltr; text-align: center; margin: 6px 0; font-variant-numeric: tabular-nums; }
.handover { display: grid; gap: 8px; }
.handover label { display: grid; gap: 3px; font-weight: 700; font-size: 15px; }
.handover input { padding: 10px; border: 1px solid var(--line); border-radius: 10px; font: inherit; }
.handover-card { border: 3px solid var(--brand); border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; background: #fff; }
.handover-card h4 { margin: 0 0 8px; color: var(--brand); font-size: 19px; }
.handover-card dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 18px; }
.handover-card dt { font-weight: 800; }
.handover-card dd { margin: 0; }
.checklist { margin: 4px 0; padding-inline-start: 22px; }
.checklist li { margin: 4px 0; }

.foot { max-width: 860px; margin: 0 auto; padding: 14px 16px 40px; color: var(--muted); font-size: 13px; text-align: center; }

@media (max-width: 520px) {
  .step { grid-template-columns: 80px 1fr; }
  .step img { width: 80px; height: 60px; }
  .step p { font-size: 18px; }
  .scenario h2 { font-size: 21px; }
}
@media print {
  .top, .tabs, .disclaimer, .searchbar, .callbar, .foot, .back { display: none !important; }
  main { box-shadow: none; }
}

.city-row { margin-top: 10px; }
.city-row input { flex: 1 1 160px; min-width: 0; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; font: inherit; }

/* ===== HUMAN TOUCH: warm palette, mascot, hover and touch effects ===== */
/* "Human touch" layer on top of the base styles above: warm paper look, a friendly mascot, hover/touch delights.
   Rules: no inline styles (CSP), animations only when the user did not ask for reduced motion,
   hover effects only on devices that really hover. Fonts are bundled (works offline). */
@font-face { font-family: "Tajawal"; font-weight: 400; font-display: swap; src: url("/static/fonts/tajawal-arabic-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Tajawal"; font-weight: 700; font-display: swap; src: url("/static/fonts/tajawal-arabic-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Tajawal"; font-weight: 800; font-display: swap; src: url("/static/fonts/tajawal-arabic-800-normal.woff2") format("woff2"); }
@font-face { font-family: "Baloo Bhaijaan 2"; font-weight: 700; font-display: swap; src: url("/static/fonts/baloo-bhaijaan-2-arabic-700-normal.woff2") format("woff2"); }

:root {
  --bg: #fbf5ec; --card: #fffdf9; --line: #eadfd0; --ink: #2a211d; --muted: #6b5d54;
  --paper: #fffdfa; --warm: #f6e9d6; --sticky: #fff1c2; --teal: #0f766e;
  --font-head: "Baloo Bhaijaan 2", "Tajawal", system-ui, sans-serif;
  --shadow: 0 2px 6px rgba(80, 50, 20, .08), 0 8px 22px rgba(80, 50, 20, .06);
}
body {
  font-family: "Tajawal", system-ui, -apple-system, "Segoe UI", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  background-color: var(--bg);
  background-image: radial-gradient(rgba(180, 120, 60, .09) 1px, transparent 1.4px);
  background-size: 22px 22px;
}
h1, h2, h3, .brand b, .scenario h2 { font-family: var(--font-head); }
.section-title { position: relative; }
.section-title::after {
  content: ""; display: block; width: 74px; height: 9px; margin-top: 2px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 74 9'%3E%3Cpath d='M2 6c6-6 10 4 16-1s10 4 16-1 10 4 16-1 10 3 20-1' fill='none' stroke='%23b42318' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat;
}

/* ---- paper surfaces with slightly organic corners ---- */
main { background: var(--card); border-radius: 0 0 22px 22px; }
.item, .step, .num, .card, .box, details.more { background: var(--paper); border-color: var(--line); }
.item, .num { border-radius: 16px 14px 18px 14px; }
.card { border-radius: 18px 14px 20px 14px; }
.tabs a { background: var(--warm); border-radius: 16px 16px 0 0; position: relative; overflow: hidden; transition: background .2s, color .2s; }
.tabs a i { font-style: normal; display: inline-block; }
.tabs a.active { background: var(--card); }

/* ---- header: ECG line + heartbeat 123 + mascot ---- */
.top { background: linear-gradient(135deg, #a3200f, #c7392a); padding-bottom: 14px; }
.ecg { position: absolute; inset-inline: 0; bottom: 0; width: 100%; height: 14px; pointer-events: none; }
.ecg path { fill: none; stroke-width: 1.6; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.ecg-base { stroke: rgba(255, 255, 255, .25); }
.ecg-line { stroke: #fff; stroke-dasharray: 14 86; stroke-dashoffset: 100; }
.call123 { position: relative; display: inline-flex; align-items: center; gap: 6px; overflow: visible; }
.call123 .phone { display: inline-block; }
.brand { position: relative; }
.mascot { flex: none; background: none; border: 0; padding: 0; cursor: pointer; line-height: 0; border-radius: 50%; }
.mascot:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.mascot svg { overflow: visible; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .25)); }
.m-body { fill: #fff1ee; stroke: #fff; stroke-width: 2.4; stroke-linejoin: round; }
.m-shine { fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; opacity: .9; }
.m-eye { fill: #fff; stroke: #e7cfc9; stroke-width: .8; }
.pupil { fill: #2a211d; transform: translate(calc(var(--px, 0) * 1px), calc(var(--py, 0) * 1px)); transition: transform .08s linear; }
.m-lid { fill: #fff1ee; transform-box: fill-box; transform-origin: center top; transform: scaleY(0); }
.m-cheek { fill: #ffb4a8; }
.m-mouth { fill: none; stroke: #b42318; stroke-width: 2.6; stroke-linecap: round; transition: d .2s; }
.m-patch rect { fill: #f6d9a8; stroke: #d8b074; stroke-width: 1; }
.m-patch path { fill: none; stroke: #b42318; stroke-width: 1.6; stroke-linecap: round; }
.m-patch { transform: rotate(-18deg); transform-origin: 40px 25px; }
.mascot.listening svg { transform: rotate(-4deg); }
.say {
  position: absolute; z-index: 30; top: calc(100% + 10px); inset-inline-start: 0; margin: 0; max-width: min(260px, 80vw);
  background: #fff; color: var(--ink); font-size: 15px; font-weight: 700; line-height: 1.4; padding: 8px 12px;
  border-radius: 14px; box-shadow: 0 6px 18px rgba(0, 0, 0, .22); opacity: 0; transform: translateY(-6px) scale(.96);
  pointer-events: none; transition: opacity .2s, transform .2s;
}
.say::before { content: ""; position: absolute; top: -6px; inset-inline-start: 16px; width: 12px; height: 12px; background: #fff; transform: rotate(45deg); }
.say.show { opacity: 1; transform: none; }

/* ---- friendly hello sticky note ---- */
.hello {
  position: relative; display: block; width: 100%; text-align: start; font: inherit; color: var(--ink); cursor: pointer;
  background: var(--sticky); border: 0; border-radius: 6px 14px 10px 16px; padding: 16px 16px 12px; margin: 6px 0 16px;
  box-shadow: 0 6px 14px rgba(120, 80, 10, .15); transform: rotate(-.7deg); transition: transform .25s, box-shadow .25s;
}
.hello::before {
  content: ""; position: absolute; top: -9px; inset-inline-start: 24px; width: 70px; height: 18px; background: rgba(255, 255, 255, .55);
  border: 1px dashed rgba(150, 110, 40, .35); transform: rotate(-3deg);
}
.hello b { display: block; font-family: var(--font-head); font-size: 21px; }
.hello span { display: block; margin: 4px 0 6px; font-size: 17px; }
.hello small { color: #7b5d12; }
.hello:focus-visible { outline: 3px solid #fda29b; }

.btn.primary::before, .btn.danger::before, .btn.ai::before, .btn.secondary::before { display: none; }
/* ---- spotlight that follows the pointer (set by human-touch.js) ---- */
.item, .step, .num, .card, .box, .hello, .btn { position: relative; overflow: hidden; }
.item::before, .step::before, .num::before, .card::before, .box::before, .btn::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .25s;
  background: radial-gradient(180px circle at var(--mx, 50%) var(--my, 50%), rgba(255, 190, 120, .35), transparent 70%);
}
.item > *, .step > *, .num > *, .card > *, .box > * { position: relative; }
.ripple { position: absolute; border-radius: 50%; background: rgba(180, 35, 24, .25); transform: scale(0); pointer-events: none; animation: ripple .6s ease-out forwards; }
.btn.primary .ripple, .btn.danger .ripple, .btn.ai .ripple, .chip.active .ripple, .call123 .ripple, .callbar .ripple { background: rgba(255, 255, 255, .4); }
.tabs a, .chip, .call123, .callbar { overflow: hidden; position: relative; }
.call123 { overflow: hidden; }

/* ---- steps you can tick off ---- */
.steps::before { content: "اضغط على كل خطوة لما تخلّصها ✔"; font-size: 14px; color: var(--muted); margin-bottom: -4px; }
.step { cursor: pointer; transition: transform .2s, box-shadow .2s, opacity .3s, background .3s; user-select: none; }
.step:focus-visible { outline: 3px solid #fda29b; outline-offset: 2px; }
.step.done { background: #f0f9f1; border-color: #b7dfc0; }
.step.done p { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: rgba(6, 118, 71, .5); }
.step.done p::before { content: "✓"; background: var(--ok); }
.step.done img { opacity: .6; filter: saturate(.7); }

/* ---- chat: avatar + typing dots ---- */
.msg { animation: pop .25s ease-out both; }
.msg.bot { position: relative; margin-top: 12px; }
.msg.bot::before { content: ""; position: absolute; top: -14px; inset-inline-end: 8px; width: 28px; height: 32px; background: url("/static/img/mascot.svg") center / contain no-repeat; }
.dots { display: inline-flex; gap: 5px; align-items: center; height: 22px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); opacity: .35; animation: dot 1s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }

/* ---- breathing helper ---- */
.breath {
  display: grid; place-items: center; width: 132px; height: 132px; margin: 10px auto 4px; border-radius: 50%; border: 0;
  background: radial-gradient(circle at 35% 30%, #c8f1ea, #52b7aa 70%); color: #063c37; font: 800 22px var(--font-head); cursor: pointer;
  box-shadow: 0 0 0 10px rgba(15, 118, 110, .12), 0 8px 20px rgba(15, 118, 110, .25);
}
.breath:focus-visible { outline: 3px solid var(--teal); outline-offset: 6px; }

/* ---- footer sign-off ---- */
.foot .made { font-family: var(--font-head); font-size: 16px; color: var(--brand); margin: 0 0 6px; }
.toast {
  position: fixed; z-index: 60; inset-inline: 12px; bottom: calc(18px + env(safe-area-inset-bottom)); margin-inline: auto; max-width: 440px;
  background: #1f2937; color: #fff; text-align: center; font-weight: 700; padding: 12px 16px; border-radius: 16px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .3); opacity: 0; transform: translateY(14px); pointer-events: none; transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: none; }

/* ======================= motion (only when the user allows it) ======================= */
@media (prefers-reduced-motion: no-preference) {
  .ecg-line { animation: ecg 2.8s linear infinite; }
  .call123 { animation: beat 1.8s ease-in-out infinite; }
  .m-lid { animation: blink 5s infinite; }
  .m-lid:nth-of-type(2) { animation-delay: 0s; }
  .mascot.hop svg { animation: hop .6s ease-out; }
  .badge.critical { animation: glow 2s ease-in-out infinite; }
  .list .item { animation: rise .4s ease-out both; }
  .list .item:nth-child(2) { animation-delay: .04s; } .list .item:nth-child(3) { animation-delay: .08s; }
  .list .item:nth-child(4) { animation-delay: .12s; } .list .item:nth-child(5) { animation-delay: .16s; }
  .list .item:nth-child(6) { animation-delay: .2s; } .list .item:nth-child(n+7) { animation-delay: .24s; }
  .steps .step { animation: rise .45s ease-out both; }
  .steps .step:nth-child(2) { animation-delay: .08s; } .steps .step:nth-child(3) { animation-delay: .16s; }
  .steps .step:nth-child(4) { animation-delay: .24s; } .steps .step:nth-child(5) { animation-delay: .32s; }
  .step.done p::before { animation: pop .3s ease-out; }
  .hello .swap, #hello-tip.swap { animation: rise .3s ease-out; }
  .breath.on { animation: breathe 8s ease-in-out infinite; }
  .view:not(.hidden) { animation: fade .25s ease-out; }
}

/* hover / pointer delights: only for devices that really hover */
@media (hover: hover) {
  .item:hover, .step:hover, .num:hover, .card:hover, .box:hover, .btn:hover { box-shadow: var(--shadow); }
  .item:hover::before, .step:hover::before, .num:hover::before, .card:hover::before, .box:hover::before, .btn:hover::before { opacity: 1; }
  .item:hover { border-color: var(--brand); }
  .item:hover .badge { transform: scale(1.1) rotate(-3deg); }
  .item:hover .t { color: var(--brand); }
  .hello:hover { transform: rotate(0deg) translateY(-2px); box-shadow: 0 10px 22px rgba(120, 80, 10, .22); }
  .tabs a:hover { background: #f2dfc3; color: var(--brand); }
  .tabs a.active:hover { background: var(--card); }
  .call123:hover { background: #fff7f5; }
  .callbar:hover { filter: brightness(1.06); }
  .mascot:hover svg { transform: scale(1.08) rotate(-4deg); }
  .mascot svg { transition: transform .2s; }
  .breath:hover { box-shadow: 0 0 0 14px rgba(15, 118, 110, .14), 0 10px 24px rgba(15, 118, 110, .3); }
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .item .badge { transition: transform .2s; }
  .item, .num, .btn, .chip, .step { transition: transform .18s ease, box-shadow .2s, border-color .2s, background .2s; }
  .item:hover { transform: translateY(-2px); }
  .btn:hover { transform: translateY(-2px); }
  .btn:active, .chip:active, .item:active, .step:active { transform: scale(.97); }
  .chip:hover { transform: rotate(-2deg) scale(1.06); }
  .tabs a:hover i { animation: wiggle .5s ease; }
  .call123:hover .phone { animation: ring .6s ease; }
  .step:hover { transform: translateY(-2px); }
  .step img { transition: transform .25s; }
  .step:hover img { transform: rotate(-3deg) scale(1.1); }
  .step:hover p::before { animation: bounce .5s ease; }
  .num:hover { transform: translateX(-3px); }
  .num:hover a { animation: pop .3s ease-out; }
  .box.dont:hover h3 { animation: wiggle .5s ease; }
}

@keyframes ripple { to { transform: scale(1); opacity: 0; } }
@keyframes ecg { to { stroke-dashoffset: 0; } }
@keyframes beat { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, .55); } 14% { box-shadow: 0 0 0 0 rgba(255, 255, 255, .55); transform: scale(1.04); } 60% { box-shadow: 0 0 0 12px rgba(255, 255, 255, 0); transform: none; } }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(0); } 95% { transform: scaleY(1); } }
@keyframes hop { 0% { transform: translateY(0); } 35% { transform: translateY(-9px) rotate(-6deg); } 70% { transform: translateY(0) rotate(3deg); } 100% { transform: none; } }
@keyframes glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(180, 35, 24, .5); } 50% { box-shadow: 0 0 0 6px rgba(180, 35, 24, 0); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 0% { transform: scale(.9); opacity: 0; } 70% { transform: scale(1.04); } 100% { transform: none; opacity: 1; } }
@keyframes dot { 0%, 100% { transform: translateY(0); opacity: .35; } 40% { transform: translateY(-5px); opacity: 1; } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-14deg); } 75% { transform: rotate(14deg); } }
@keyframes ring { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-22deg); } 40% { transform: rotate(20deg); } 60% { transform: rotate(-14deg); } 80% { transform: rotate(10deg); } }
@keyframes bounce { 0%, 100% { transform: none; } 40% { transform: translateY(-5px) scale(1.15); } }
@keyframes breathe { 0%, 100% { transform: scale(.82); } 50% { transform: scale(1.22); } }

@media print { .ecg, .say, .mascot, .toast, .hello { display: none !important; } }

/* narrow screens: icon above the label so all four tabs fit without scrolling */
@media (max-width: 520px) {
  .tabs { gap: 4px; padding-inline: 8px; }
  .tabs a { display: flex; flex-direction: column; align-items: center; gap: 0; padding: 7px 4px; font-size: 13px; line-height: 1.25; }
  .tabs a i { font-size: 18px; line-height: 1.2; }
}

/* ===== CARTOON EXPLAINERS: colours and motion of the animated scenes ===== */
/* Cartoon explainers (static/js/cartoon-explainers.js). Colours are flat and friendly; motion only when allowed. */
.explainer { margin: 16px 0; padding: 12px; background: var(--paper, #fff); border: 1px solid var(--line); border-radius: 18px 14px 20px 14px; }
.explainer h3 { margin: 0 0 8px; font-size: 18px; }
.explainer .stage svg { display: block; width: 100%; height: auto; border-radius: 16px; }
.explainer .cap { margin: 10px 2px 8px; font-size: 18px; font-weight: 800; min-height: 2.9em; }
.explainer .ctrl { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.explainer .dots { display: flex; gap: 8px; }
.explainer .dot { width: 18px; height: 18px; padding: 0; border-radius: 50%; border: 2px solid var(--brand); background: #fff; cursor: pointer; }
.explainer .dot.active { background: var(--brand); }
.explainer .dot:focus-visible { outline: 3px solid #fda29b; outline-offset: 2px; }

/* palette */
.explainer .bg { fill: #eaf6f4; } .explainer .floor { fill: #d9ece8; }
.explainer .sk { fill: #f3c9a5; stroke: #7a4a2a; stroke-width: 3; stroke-linejoin: round; }
.explainer .sl { fill: #2e8b83; stroke: #1d5e58; stroke-width: 3; stroke-linejoin: round; }
.explainer .bl { fill: #d92d20; } .explainer .bld { fill: #8f1c13; } .explainer .drip { fill: #d92d20; }
.explainer .cl { fill: #fff; stroke: #c9ced6; stroke-width: 3; }
.explainer .bn { fill: #f6e7c8; stroke: #d8b074; stroke-width: 3; stroke-linejoin: round; }
.explainer .gz { fill: #fff6df; stroke: #d8b074; stroke-width: 3; }
.explainer .metal { fill: #aeb7c2; stroke: #5f6b7a; stroke-width: 3; } .explainer .shine { fill: #fff; opacity: .7; }
.explainer .hair { fill: #3b2a22; } .explainer .eye { fill: #2a211d; }
.explainer .brow, .explainer .mouth, .explainer .breath { fill: none; stroke: #2a211d; stroke-width: 3; stroke-linecap: round; }
.explainer .mo { fill: #8f1c13; } .explainer .breath { stroke: #7aa7c7; }
.explainer .strap { fill: #232c3b; stroke: #0f1722; stroke-width: 3; } .explainer .buckle { fill: #e7b23e; stroke: #8a6414; stroke-width: 2; }
.explainer .dim { fill: none; stroke: #b42318; stroke-width: 3; stroke-linecap: round; } .explainer .dimt { fill: #b42318; font: 700 16px var(--font-head, sans-serif); }
.explainer .tag { fill: #fff; stroke: #b42318; stroke-width: 3; } .explainer .tagt { fill: #2a211d; font: 800 17px var(--font-head, sans-serif); }
.explainer .ph { fill: #2a211d; } .explainer .scr { fill: #d9f3ee; } .explainer .phb { fill: #667085; }
.explainer .t123 { fill: #b42318; font: 800 20px var(--font-head, sans-serif); }
.explainer .wave { fill: none; stroke: #b42318; stroke-width: 3; stroke-linecap: round; }
.explainer .rbg { fill: #fff; stroke: #e1d6c6; stroke-width: 7; } .explainer .rfg { fill: none; stroke: #0f766e; stroke-width: 7; stroke-linecap: round; stroke-dasharray: 100; transform: rotate(-90deg); }
.explainer .rt { fill: #2a211d; font: 800 12px var(--font-head, sans-serif); }
.explainer .ok { fill: #067647; } .explainer .okp { fill: none; stroke: #fff; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.explainer .bub { fill: #fff; stroke: #9dd3ee; stroke-width: 3; } .explainer .water { fill: #5bb6e8; }
.explainer .ice { fill: #b9e2ff; stroke: #5aa8dd; stroke-width: 3; } .explainer .icet { font-size: 16px; fill: #1e6fa8; }
.explainer .nope { fill: none; stroke: #b42318; stroke-width: 4; stroke-linecap: round; } .explainer .nopec { fill: none; stroke: #b42318; stroke-width: 5; }
.explainer .nopec.big { fill: #fff; } .explainer .nopex { stroke: #b42318; stroke-width: 5; stroke-linecap: round; }
.explainer .up, .explainer .arr, .explainer .up2 { fill: none; stroke: #b42318; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; } .explainer .arr { stroke: #0f766e; } .explainer .up2 { stroke: #0f766e; }
.explainer .cut { fill: none; stroke: #8f1c13; stroke-width: 5; stroke-linecap: round; } .explainer .trk { fill: none; stroke: #d92d20; stroke-width: 4; stroke-linecap: round; }
.explainer .donut { fill: none; stroke: #fff; stroke-width: 12; } .explainer .warn { fill: #f5b301; stroke: #8a6414; stroke-width: 2; stroke-linejoin: round; }
.explainer .sym { font-size: 30px; }

/* beats: things appear when delight "on" is set by the player */
.explainer .a { opacity: 0; transition: opacity .35s ease, transform .5s ease; }
.explainer .a.on { opacity: 1; }
.explainer .a.pop { transform: scale(.6); transform-box: fill-box; transform-origin: center; }
.explainer .a.pop.on { transform: none; }
.explainer .a.slide { transform: translateX(-34px); } .explainer .a.slidel { transform: translateX(-34px); } .explainer .a.slider { transform: translateX(34px); }
.explainer .a.slide.on, .explainer .a.slidel.on, .explainer .a.slider.on { transform: none; }
.explainer .a.press { transform: translateY(-16px); } .explainer .a.press.on { transform: none; }
.explainer .strip:nth-of-type(2) { transition-delay: .12s; } .explainer .strip:nth-of-type(3) { transition-delay: .24s; }
.explainer .strip:nth-of-type(4) { transition-delay: .36s; } .explainer .strip:nth-of-type(5) { transition-delay: .48s; } .explainer .strip:nth-of-type(6) { transition-delay: .6s; }
.explainer .head { transform-origin: 140px 140px; transition: transform .7s ease; } .explainer .head.on { transform: rotate(16deg); }
.explainer .rfg { stroke-dashoffset: 0; }

@media (prefers-reduced-motion: no-preference) {
  .explainer .a.on .drip { animation: fall 1.1s ease-in infinite; }
  .explainer .a.on .drip.d1 { animation-delay: .35s; } .explainer .a.on .drip.d2 { animation-delay: .7s; }
  .explainer .a.press.on { animation: press 1.3s ease-in-out .5s infinite; }
  .explainer .a.ring.on { animation: shake .8s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
  .explainer .a.on .rfg { animation: count 3.2s linear forwards; }
  .explainer .a.on .rod { animation: twist 2.6s ease-in-out forwards; transform-box: fill-box; transform-origin: center bottom; }
  .explainer .a.on .water { animation: fall 0.8s ease-in infinite; } .explainer .a.on .w1 { animation-delay: .25s; } .explainer .a.on .w2 { animation-delay: .5s; }
  .explainer .a.on .hw1 { animation: scrub .7s ease-in-out infinite alternate; } .explainer .a.on .hw2 { animation: scrub .7s ease-in-out infinite alternate-reverse; }
  .explainer .a.on .bub { animation: floaty 1.6s ease-in-out infinite; } .explainer .a.on .b1 { animation-delay: .4s; } .explainer .a.on .b2 { animation-delay: .8s; }
  .explainer .a.on .arrow { animation: nudge 1s ease-in-out infinite; } .explainer .a.on .up2 { animation: lift 1.2s ease-in-out infinite; }
  .explainer .a.on .breath { animation: puff 1.4s ease-in-out infinite; }
  .explainer .a.on .pinch { animation: squeeze 1.2s ease-in-out infinite; }
  .explainer .a.on .soak { animation: seep 1.2s ease-out both; }
  .explainer .a.on .tw { animation: pull 1.8s ease-in-out infinite; }
  .explainer .a.on .heatw { animation: rise 1.6s ease-in-out infinite; }
}
@keyframes fall { 0% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(44px); opacity: 0; } }
@keyframes press { 0%, 100% { transform: none; } 50% { transform: translateY(7px); } }
@keyframes shake { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-7deg); } 40% { transform: rotate(6deg); } 60% { transform: rotate(-5deg); } }
@keyframes count { from { stroke-dashoffset: 0; } to { stroke-dashoffset: 100; } }
@keyframes twist { from { transform: rotate(0); } to { transform: rotate(150deg); } }
@keyframes scrub { from { transform: translateX(-10px); } to { transform: translateX(10px); } }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(8px); } }
@keyframes lift { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes puff { 0%, 100% { opacity: .4; transform: translateX(0); } 50% { opacity: 1; transform: translateX(6px); } }
@keyframes squeeze { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(2px); } }
@keyframes pull { 0%, 40% { transform: none; } 100% { transform: translate(18px, -16px); } }
@keyframes rise { 0%, 100% { transform: translateY(0); opacity: .5; } 50% { transform: translateY(-8px); opacity: 1; } }
@keyframes seep { from { opacity: 0; transform: scale(.4); transform-box: fill-box; transform-origin: center; } to { opacity: .85; transform: none; } }
@media print { .explainer .ctrl { display: none; } }


/* ===== NEW TOOLS: SOS, voice mode, quick triage, quiz, wound diary, hospitals ===== */
.top-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.sosbtn { flex: none; background: #7a1710; color: #fff; font-weight: 800; text-decoration: none; padding: 9px 12px; border-radius: 999px; font-size: 15px; border: 2px solid #fff; }
.sosbtn:active { transform: scale(.97); }
@media (max-width: 460px) { .brand small, .brand .say { display: none; } .call123 { padding: 9px 12px; font-size: 15px; } }
.tabs .dot { color: var(--brand); font-size: 12px; }

.contacts { display: grid; gap: 8px; margin: 8px 0; }
.contact { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.contact .who b { display: block; }
.contact .who small { color: var(--muted); }
.contact .acts, .hospital .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.btn.disabled { opacity: .55; }
#sos-preview { width: 100%; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; font: inherit; background: #f8fafc; }
.handover label select { width: 100%; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; font: inherit; background: #fff; }

.voice-btn { width: 100%; margin: 8px 0; background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
body.vm-open { overflow: hidden; }
.voice-overlay { position: fixed; inset: 0; z-index: 100; background: #111827; color: #fff; display: flex; flex-direction: column; gap: 12px; padding: 14px; overflow-y: auto; }
.voice-overlay .btn { background: #374151; border-color: #4b5563; color: #fff; }
.voice-overlay .btn.primary { background: var(--brand); border-color: var(--brand); }
.vm-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.vm-top b { font-size: 18px; }
.vm-card { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; background: #1f2937; color: #fff; border: 2px solid #4b5563; border-radius: 20px; padding: 18px; font: inherit; cursor: pointer; min-height: 240px; }
.vm-label { font-size: 18px; color: #fca5a5; font-weight: 800; }
.vm-img { max-width: 100%; height: auto; border-radius: 14px; background: #fff; }
.vm-text { font-size: 28px; line-height: 1.5; font-weight: 800; margin: 0; white-space: pre-line; }
.vm-tap { color: #9ca3af; }
.vm-nav { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.vm-nav .btn { font-size: 18px; }
.vm-note { color: #d1d5db; font-size: 14px; margin: 0; }

.triage { max-width: 640px; }
.triage-step { color: var(--muted); font-size: 14px; margin: 4px 0; }
.triage-q { font-size: 22px; line-height: 1.5; margin: 6px 0 14px; }
.triage-answers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.triage-group { margin: 14px 0 6px; color: var(--muted); font-size: 15px; }
.triage-option { display: flex; width: 100%; justify-content: flex-start; margin: 4px 0; text-align: start; }
.triage-result { border: 2px solid var(--line); border-radius: 16px; padding: 14px; background: #fff; }
.triage-result.danger { border-color: var(--brand); background: #fef3f2; }
.triage-result.warn { border-color: #f79009; background: #fffaeb; }
.triage-result.ok { border-color: #12b76a; background: #ecfdf3; }
.triage-result h3 { margin: 0 0 8px; font-size: 21px; }
.triage-result li { margin: 4px 0; font-size: 18px; }

.quiz-options { display: grid; gap: 8px; }
.quiz-option { justify-content: flex-start; text-align: start; width: 100%; }
.quiz-option.right { background: #d1fadf; border-color: #12b76a; }
.quiz-option.wrong { background: #fee4e2; border-color: var(--brand); }
.quiz-feedback { margin-top: 12px; padding: 12px; border-radius: 12px; }
.quiz-feedback.ok { background: #ecfdf3; border: 1px solid #abefc6; }
.quiz-feedback.bad { background: #fef3f2; border: 1px solid #fecdca; }

.diary-card .head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.diary-form { display: grid; gap: 8px; margin: 12px 0; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #fafbfc; }
.diary-form .check { display: flex; align-items: center; gap: 8px; }
.diary-verdict { padding: 12px; border-radius: 12px; margin: 10px 0; font-weight: 700; }
.diary-verdict.urgent { background: #fef3f2; border: 2px solid var(--brand); color: #7a1710; }
.diary-verdict.warn { background: #fffaeb; border: 2px solid #f79009; color: #7a2e0e; }
.diary-verdict.ok { background: #ecfdf3; border: 2px solid #12b76a; color: var(--ok); }
.diary-entry { display: grid; gap: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; margin: 8px 0; background: #fff; }
.diary-entry.urgent { border-color: var(--brand); }
.diary-photo { object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.notice.trust { font-weight: 700; }

/* 7 tabs no longer fit on a phone: keep each one at its natural width and let the row scroll sideways */
.tabs { scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: 0 0 auto; padding: 10px 12px; }
#sos-preview { min-height: 130px; }
.num.hospital a.btn { font-size: 15px; font-weight: 700; color: var(--ink); min-height: 40px; padding: 8px 12px; white-space: nowrap; }
.num.hospital .acts { flex: none; }

.sos-ios-list { display: grid; gap: 8px; }
