/* Priors website: EMS patient care concept demo (assets/demos/ems.js).
   Uses the site's colour tokens; the patient monitor stays dark in both themes, like the real thing. */

.ems {
  container: ems / inline-size;
  --ems-skin: color-mix(in srgb, var(--fg) 7%, var(--surface));
  --ems-skin-line: color-mix(in srgb, var(--fg) 32%, var(--surface));
  --ems-mk-ink: #ffffff;
  --ems-bezel: #1e2521;
  --ems-mon: #0b100d;
  --ems-mon-line: #1d2822;
  --ems-mon-k: #8fa596;
  --ems-hr: #5fd38f;
  --ems-sp: #5ac3df;
  --ems-rr: #ffd166;
  --ems-ebl: #ff9b6b;
  --ems-alarm: #ff7b6e;
  margin-top: clamp(2rem, 5vw, 3rem);
  min-width: 0;
}
:root[data-theme="dark"] .ems { --ems-mk-ink: #0c1511; --ems-bezel: #070a08; --ems-mon: #070b09; --ems-mon-line: #1a251f; }

/* Concept badge and note above the tablet */
.ems-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .7rem; margin-bottom: .8rem; }
.ems-concept { font: 600 .66rem/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; padding: .38rem .55rem; border-radius: 3px; background: var(--fg); color: var(--bg); }
.ems-note { font-size: .84rem; color: var(--muted); flex: 1 1 280px; min-width: 0; }

/* Device frame */
.ems-tablet { background: var(--ems-bezel); padding: 12px; border-radius: 20px; box-shadow: 0 30px 60px -36px rgba(0,0,0,.7), inset 0 0 0 1px rgba(255,255,255,.06); }
:root[data-theme="dark"] .ems-tablet { box-shadow: 0 30px 60px -36px rgba(0,0,0,.9), inset 0 0 0 1px var(--line); }
.ems-screen { background: var(--bg); color: var(--fg); border-radius: 10px; overflow: hidden; font-size: .94rem; line-height: 1.45; }
.ems-k { display: block; font: 600 .64rem/1.3 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.ems h3.ems-h { font: 600 .72rem/1.2 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0; }

/* Top bar */
.ems-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.1rem; padding: .55rem .8rem; background: var(--sign); color: var(--sign-fg); }
.ems-app { display: flex; align-items: center; gap: .55rem; }
.ems-app-mk { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ems-app-n { display: grid; line-height: 1.05; }
.ems-app-n b { font: 800 1.05rem/1 var(--font-display); letter-spacing: .05em; text-transform: uppercase; }
.ems-app-n span { font: 500 .66rem var(--font-mono); letter-spacing: .08em; opacity: .85; }
.ems-inc { display: grid; line-height: 1.15; padding-left: 1.1rem; border-left: 1px solid rgba(255,255,255,.25); min-width: 0; }
.ems-inc b { font: 600 .64rem var(--font-mono); letter-spacing: .1em; opacity: .85; }
.ems-inc span { font-weight: 600; font-size: .86rem; }
.ems-clock { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.ems-clock-t { font: 600 1.05rem/1 var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.ems-unit { font: 600 .66rem/1 var(--font-mono); letter-spacing: .1em; padding: .3rem .42rem; border-radius: 3px; background: rgba(255,255,255,.18); }
.ems.is-paused .ems-clock::after { content: "Paused"; font: 600 .62rem/1 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; padding: .3rem .42rem; border-radius: 3px; background: var(--sign-fg); color: var(--sign); }
.ems-ctl { display: flex; gap: .4rem; }
.ems-bar-btn { font: 600 .78rem/1 var(--font-body); color: inherit; background: transparent; border: 1px solid rgba(255,255,255,.45); border-radius: 4px; padding: .45rem .7rem; min-height: 32px; cursor: pointer; }
.ems-bar-btn:hover { background: rgba(255,255,255,.12); }
.ems-bar-btn[aria-pressed="true"] { background: var(--sign-fg); color: var(--sign); }
.ems-bar :focus-visible { outline-color: var(--sign-fg); }
.ems[data-phase="brief"] .ems-bar-btn:first-child, .ems[data-phase="done"] .ems-bar-btn:first-child { display: none; }

/* Patient strip */
.ems-pt { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.6rem; padding: .6rem .9rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.ems-pt-id b { display: block; font: 800 1.3rem/1 var(--font-display); text-transform: uppercase; letter-spacing: .02em; }
.ems-pt-id span { font: 500 .7rem var(--font-mono); color: var(--muted); }
.ems-pt-cc span:last-child { font-size: .86rem; font-weight: 600; }
.ems-pt-st { margin-left: auto; display: grid; justify-items: end; gap: .2rem; }
.ems-pill { display: inline-flex; align-items: center; gap: .4rem; font: 600 .72rem/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; padding: .32rem .6rem; border-radius: 99px; color: var(--muted); border: 1px solid currentColor; }
.ems-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.ems-pill.is-stable { color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.ems-pill.is-serious { color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.ems-pill.is-critical { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.ems-pill.is-critical::before { animation: ems-blink 1s steps(2, start) infinite; }

/* Briefing */
.ems-brief { display: grid; gap: 1rem; padding: 1rem; }
.ems-cad { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--clay); border-radius: 6px; padding: 1rem 1.1rem; display: grid; gap: .55rem; align-content: start; }
.ems-cad-h { font: 800 clamp(1.4rem, 4.5cqi, 1.9rem)/1.02 var(--font-display); text-transform: uppercase; }
.ems-cad-n { font: 400 .84rem/1.55 var(--font-mono); color: var(--fg); }
.ems-how { display: grid; gap: .7rem; align-content: start; padding: .3rem .2rem; }
.ems-how ol { margin: 0; padding: 0; list-style: none; counter-reset: ems; display: grid; gap: .5rem; font-size: .9rem; }
.ems-how li { counter-increment: ems; display: grid; grid-template-columns: 1.6rem minmax(0, 1fr); gap: .4rem; }
.ems-how li::before { content: counter(ems); font: 600 .7rem/1.7rem var(--font-mono); width: 1.6rem; height: 1.6rem; text-align: center; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--clay); margin-top: -.15rem; }
.ems-go { justify-self: start; margin-top: .3rem; }
@container ems (min-width: 700px) { .ems-brief { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); padding: 1.3rem; gap: 1.5rem; } }

/* Work area: monitor, body, MARCH, tools, log. One column, then two. */
.ems-work { display: grid; gap: 10px; padding: 10px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "mon" "body" "march" "tools" "log"; }
@container ems (min-width: 860px) {
  .ems-work { grid-template-columns: minmax(0, .95fr) minmax(0, 1.2fr); grid-template-areas: "body mon" "body march" "body tools" "body log"; grid-template-rows: auto auto auto 1fr; padding: 12px; gap: 12px; }
}
.ems-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px; min-width: 0; }
.ems-ph { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem .8rem; margin-bottom: .7rem; }

/* Body diagram */
.ems-bodyp { grid-area: body; container: emsbody / inline-size; align-self: start; }
.ems-views { display: inline-flex; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.ems-views button { position: relative; font: 600 .8rem/1 var(--font-body); padding: .5rem .85rem; min-height: 34px; border: 0; background: var(--bg); color: var(--fg); cursor: pointer; }
.ems-views button + button { border-left: 1px solid var(--line); }
.ems-views button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.ems-views button:focus-visible { outline-offset: -3px; }
.ems-vdot { display: none; position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }
.ems-views button.has-find[aria-pressed="false"] .ems-vdot { display: block; }
.ems-body-in { display: grid; gap: 12px; }
@container emsbody (min-width: 400px) { .ems-body-in { grid-template-columns: minmax(150px, 205px) minmax(0, 1fr); align-items: start; } }
.ems-scene { margin: 12px 0 0; padding-top: 10px; border-top: 1px dashed var(--line); display: grid; gap: 6px; }
.ems-scene div { display: grid; grid-template-columns: 7.2em minmax(0, 1fr); gap: .6rem; align-items: baseline; }
.ems-scene dt { font: 600 .6rem/1.3 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.ems-scene dd { margin: 0; font-size: .82rem; }
.ems-figw { display: grid; justify-items: center; gap: .3rem; padding: .4rem 0; border-radius: 6px; background: radial-gradient(ellipse 70% 55% at 50% 45%, color-mix(in srgb, var(--pine) 7%, transparent), transparent 75%); }
.ems-fig { display: block; width: 100%; max-width: 205px; height: auto; touch-action: manipulation; overflow: visible; }
.ems-figcap { font: 500 .64rem var(--font-mono); letter-spacing: .06em; color: var(--muted); text-align: center; }
.ems-bp { fill: var(--ems-skin); stroke: var(--ems-skin-line); stroke-width: 1.2; cursor: pointer; transition: fill .15s ease; -webkit-tap-highlight-color: transparent; }
.ems-bp:hover { fill: color-mix(in srgb, var(--clay) 14%, var(--ems-skin)); }
.ems-bp.is-sel { fill: color-mix(in srgb, var(--clay) 30%, var(--ems-skin)); stroke: var(--clay); stroke-width: 2; }
.ems-bp:focus { outline: none; }
.ems-bp:focus-visible { stroke: var(--fg); stroke-width: 2.6; stroke-dasharray: 5 2.5; }
.ems-spine { fill: none; stroke: var(--ems-skin-line); stroke-width: 1; stroke-dasharray: 3 4; pointer-events: none; }
.ems-side { font: 600 11px var(--font-mono); fill: var(--muted); }
.ems-over { pointer-events: none; }
.ems-frac { fill: none; stroke: var(--fg); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: .7; }
.ems-tq { fill: var(--fg); }
.ems-splint { fill: none; stroke: var(--pine); stroke-width: 2.2; stroke-dasharray: 6 3; }
.ems-collar { fill: color-mix(in srgb, var(--fg) 72%, transparent); }
.ems-mask { fill: color-mix(in srgb, var(--water) 28%, transparent); stroke: var(--water); stroke-width: 1.4; }
.ems-iv circle { fill: var(--water); }
.ems-iv path { stroke: var(--water); stroke-width: 1.6; }
.ems-seal { fill: color-mix(in srgb, var(--pine) 22%, var(--surface)); stroke: var(--pine); stroke-width: 1.4; }
.ems-dress { fill: var(--surface); stroke: var(--muted); stroke-width: 1.2; }
.ems-mk-dot { fill: var(--bad); }
.ems-mk-ring { fill: none; stroke: var(--bad); stroke-width: 1.5; opacity: 0; transform-box: fill-box; transform-origin: center; }
.ems-mk.sev-urg .ems-mk-dot, .ems-mk.is-slow .ems-mk-dot { fill: var(--warn); }
.ems-mk.is-done .ems-mk-dot { fill: var(--pine); }
.ems-mk.is-bleed .ems-mk-ring { animation: ems-pulse 1.4s ease-out infinite; }
.ems-mk-n { font: 700 9.5px var(--font-mono); fill: var(--ems-mk-ink); }

.ems-body-side { display: grid; gap: 10px; align-content: start; min-width: 0; }
.ems-inj { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ems-inj-b { width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .6rem; padding: .5rem .65rem; min-height: 50px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); font: inherit; text-align: left; cursor: pointer; }
.ems-inj-b:hover { border-color: var(--muted); }
.ems-inj-b.is-sel { border-color: var(--clay); box-shadow: inset 0 0 0 1px var(--clay); }
.ems-inj-n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font: 700 .7rem/1 var(--font-mono); color: var(--ems-mk-ink); background: var(--warn); }
.ems-inj-b.sev-life .ems-inj-n { background: var(--bad); }
.ems-inj-b.is-done .ems-inj-n { background: var(--pine); }
.ems-inj-t { display: grid; line-height: 1.25; min-width: 0; }
.ems-inj-t b { font-size: .86rem; font-weight: 600; }
.ems-inj-t span { font-size: .78rem; color: var(--muted); }
.ems-inj-st { font: 600 .6rem/1.2 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--bad); text-align: right; max-width: 7.5em; }
.ems-inj-b.sev-urg .ems-inj-st { color: var(--warn); }
.ems-inj-b.is-done .ems-inj-st { color: var(--pine); }
.ems-sel { display: grid; gap: .2rem; padding: .65rem .75rem; border-radius: 6px; border: 1px dashed var(--line); background: color-mix(in srgb, var(--fg) 3%, var(--surface)); min-height: 6.2rem; align-content: start; }
.ems-sel b { font-size: .95rem; }
.ems-sel span:last-child { font-size: .84rem; color: var(--muted); }

/* Monitor */
.ems-mon { grid-area: mon; background: var(--ems-mon); color: #dfe8e1; border: 1px solid var(--ems-mon-line); border-radius: 8px; padding: 9px 10px 10px; min-width: 0; }
.ems-mon-top { display: flex; align-items: center; gap: .6rem; margin-bottom: .35rem; }
.ems-mon h3.ems-h { color: var(--ems-mon-k); }
.ems-mon-k { margin-left: auto; font: 500 .6rem var(--font-mono); letter-spacing: .08em; color: var(--ems-mon-k); }
.ems-alarm { font: 600 .62rem/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; padding: .3rem .5rem; border-radius: 3px; background: #3a2b0f; color: #ffc062; }
.ems-alarm.is-crit { background: #4d1613; color: #ff8f84; animation: ems-blink 1s steps(2, start) infinite; }
.ems-wavew { position: relative; border-bottom: 1px solid var(--ems-mon-line); }
.ems-wave { display: block; width: 100%; height: 96px; }
.ems-wl { position: absolute; left: 2px; font: 600 .56rem var(--font-mono); letter-spacing: .1em; text-transform: uppercase; opacity: .85; }
.ems-wl-1 { top: 0; color: var(--ems-hr); }
.ems-wl-2 { top: 57%; color: var(--ems-sp); }
.ems-vitals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin-top: 8px; background: var(--ems-mon-line); border: 1px solid var(--ems-mon-line); border-radius: 6px; overflow: hidden; }
.ems-vt { background: var(--ems-mon); padding: 6px 8px 7px; display: grid; align-content: start; min-width: 0; }
.ems-vl { font: 600 .62rem var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ems-mon-k); }
.ems-vrow { display: flex; align-items: baseline; gap: .25rem; min-width: 0; }
.ems-vv { font: 800 2.35rem/1 var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: .01em; color: #e8eee9; white-space: nowrap; }
.ems-vtr { font-size: .72rem; opacity: .85; }
.ems-vs { font: 500 .6rem/1.35 var(--font-mono); color: var(--ems-mon-k); letter-spacing: .04em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-hr .ems-vl, .c-hr .ems-vv, .c-hr .ems-vtr { color: var(--ems-hr); }
.c-sp .ems-vl, .c-sp .ems-vv, .c-sp .ems-vtr { color: var(--ems-sp); }
.c-rr .ems-vl, .c-rr .ems-vv, .c-rr .ems-vtr { color: var(--ems-rr); }
.ems-ebl .ems-vl, .ems-ebl .ems-vv { color: var(--ems-ebl); }
.ems-vt.is-alarm { background: #24100e; }
.ems-vt.is-alarm .ems-vl::after { content: " !"; color: var(--ems-alarm); }
.ems-ebl-v { font-size: 1.7rem; }
.ems-ebl-bar { position: relative; display: block; height: 6px; margin: .3rem 0 .25rem; border-radius: 3px; background: #1f2a24; overflow: hidden; }
.ems-ebl-fill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffc062, #ff6b5b); border-radius: 3px; }
.ems-ebl .ems-vs { white-space: normal; }
.ems-ebl-bar i { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--ems-mon); }
@container ems (max-width: 480px) {
  .ems-vv { font-size: 1.85rem; }
  .c-bp .ems-vv { font-size: 1.45rem; }
  .ems-ebl-v { font-size: 1.4rem; }
  .ems-vl { letter-spacing: .05em; white-space: nowrap; }
  .ems-vt.ems-ebl.is-alarm .ems-vl::after { content: none; }
  .ems-wave { height: 84px; }
}

/* MARCH strip */
.ems-march { grid-area: march; list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.ems-march li { display: flex; align-items: center; gap: .45rem; padding: .4rem .55rem; min-height: 40px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); min-width: 0; position: relative; }
.ems-march b { font: 900 1.25rem/1 var(--font-display); color: var(--muted); }
.ems-march span { font-size: .7rem; line-height: 1.15; color: var(--muted); min-width: 0; }
.ems-march li.is-next { border-color: var(--clay); }
.ems-march li.is-next b { color: var(--clay); }
.ems-march li.is-done { background: color-mix(in srgb, var(--pine) 10%, var(--surface)); border-color: color-mix(in srgb, var(--pine) 45%, var(--line)); }
.ems-march li.is-done b { color: var(--pine); }
.ems-march li.is-done::after { content: "\2713"; position: absolute; top: 3px; right: 6px; font-size: .7rem; font-weight: 700; color: var(--pine); }
@container ems (max-width: 600px) { .ems-march li { justify-content: center; } .ems-march span:not(.sr-only) { display: none; } }

/* Treatments */
.ems-toolp { grid-area: tools; }
.ems-target { font-size: .82rem; color: var(--muted); }
.ems-target b { color: var(--fg); }
.ems-tools { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ems-tool { position: relative; overflow: hidden; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; column-gap: .55rem; align-items: center; padding: .6rem .65rem; min-height: 60px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); font: inherit; text-align: left; cursor: pointer; transition: border-color .15s ease, background-color .15s ease; }
.ems-tool:hover:not([aria-disabled="true"]) { border-color: var(--muted); background: var(--surface); }
.ems-tool:active:not([aria-disabled="true"]) { transform: translateY(1px); }
.ems-ic { grid-row: span 2; width: 24px; height: 24px; fill: none; stroke: var(--pine); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ems-tn { font: 600 .86rem/1.15 var(--font-body); }
.ems-tc { font: 500 .62rem/1.3 var(--font-mono); color: var(--muted); letter-spacing: .03em; }
.ems-tool.is-done { border-color: color-mix(in srgb, var(--pine) 55%, var(--line)); }
.ems-tool.is-done .ems-tok::after { content: "\2713"; position: absolute; top: 4px; right: 7px; font-size: .8rem; font-weight: 700; color: var(--pine); }
.ems-tbar { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--clay); }
.ems-tool.is-working .ems-tbar { width: 100%; animation: ems-fill .6s linear; }
.ems-tool[aria-disabled="true"] { cursor: not-allowed; }
.ems-tool[aria-disabled="true"]:not(.is-working) { opacity: .55; }
.ems-tool-go { background: var(--sign); color: var(--sign-fg); border-color: var(--sign); }
.ems-tool-go .ems-ic { stroke: currentColor; }
.ems-tool-go .ems-tc { color: inherit; opacity: .82; }
.ems-tool-go:hover:not([aria-disabled="true"]) { background: color-mix(in srgb, var(--sign) 88%, #000); border-color: var(--sign); }
.ems-tool-go:focus-visible { outline-color: var(--clay); }
@container ems (max-width: 520px) {
  .ems-tool { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; row-gap: .2rem; align-items: start; padding: .55rem .5rem; min-height: 78px; }
  .ems-ic { grid-row: auto; width: 22px; height: 22px; }
  .ems-tn { font-size: .8rem; }
  .ems-tsub { display: none; }
}
.ems-fb { margin-top: 10px; min-height: 2.9em; padding: .5rem .7rem; border-radius: 6px; font-size: .86rem; border-left: 3px solid var(--line); background: var(--bg); color: var(--muted); }
.ems-fb.is-ok { border-left-color: var(--pine); color: var(--fg); }
.ems-fb.is-bad { border-left-color: var(--clay); color: var(--fg); background: color-mix(in srgb, var(--clay) 8%, var(--bg)); }
.ems-trans { margin-top: 10px; padding: .8rem .9rem; border: 1px solid var(--line); border-left: 4px solid var(--sign); border-radius: 6px; background: var(--bg); display: grid; gap: .45rem; }
.ems-trans-h { font-weight: 600; font-size: .92rem; }
.ems-trans-n { font-size: .8rem; color: var(--muted); }
.ems-tr-bar { position: relative; display: block; height: 8px; border-radius: 4px; background: var(--line); margin: .2rem 7px; }
.ems-tr-fill { position: relative; display: block; height: 100%; width: 0; border-radius: 4px; background: var(--sign); }
.ems-tr-fill::after { content: ""; position: absolute; right: -7px; top: -3px; width: 14px; height: 14px; border-radius: 50%; background: var(--clay); box-shadow: 0 0 0 2px var(--bg); }

/* Run log */
.ems-logp { grid-area: log; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.ems-log { list-style: none; margin: 0; padding: 0; max-height: 196px; overflow-y: auto; border-radius: 4px; }
.ems-log li { display: grid; grid-template-columns: 4.6em minmax(0, 1fr); gap: .5rem; padding: .32rem 0; border-top: 1px dashed var(--line); font-size: .8rem; line-height: 1.4; }
.ems-log li:first-child { border-top: 0; }
.ems-log time { font: 500 .7rem/1.6 var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.ems-log .is-err span, .ems-log .is-fault span { color: var(--clay); }
.ems-log .is-sys span { color: var(--muted); font-style: italic; }

/* Handoff report */
.ems-report { padding: clamp(.9rem, 3cqi, 1.4rem); display: grid; gap: 1.1rem; }
.ems-rep-head { display: grid; gap: .35rem; }
.ems h3.ems-rep-title { font: 900 clamp(1.6rem, 5cqi, 2.4rem)/1 var(--font-display); text-transform: uppercase; }
.ems-rep-title:focus { outline: none; }
.ems-rep-top { display: grid; gap: 12px; }
@container ems (min-width: 760px) { .ems-rep-top { grid-template-columns: auto minmax(0, 1.1fr) minmax(0, 1fr); align-items: stretch; } }
.ems-score { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .9rem 1.3rem; display: grid; justify-items: center; align-content: center; gap: .25rem; text-align: center; min-width: 10rem; }
.ems-score-n b { font: 900 4rem/.9 var(--font-display); color: var(--clay); }
.ems-score-n span { font: 600 1.1rem var(--font-display); color: var(--muted); }
.ems-score-g { font: 800 1.25rem/1 var(--font-display); text-transform: uppercase; }
.ems-bk { list-style: none; margin: 0; padding: .8rem 1rem; display: grid; gap: .55rem; align-content: center; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.ems-lost-why { margin: 0; padding: .8rem 1rem; align-self: stretch; display: flex; align-items: center; font-size: .9rem; line-height: 1.5; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--clay); border-radius: 8px; }
.ems-bk li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(60px, 34%) 3.2em; align-items: center; gap: .6rem; font-size: .84rem; }
.ems-bk b { font: 600 .76rem var(--font-mono); text-align: right; }
.ems-bk-bar { display: block; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.ems-bk-bar i { display: block; height: 100%; background: var(--pine); border-radius: 3px; }
.ems-keys { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ems-keys div { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: .5rem .65rem; min-width: 0; }
.ems-keys dt { font: 600 .6rem/1.3 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.ems-keys dd { margin: .15rem 0 0; font: 800 1.35rem/1.05 var(--font-display); }
.ems-keys div:first-child dd { color: var(--clay); }
.ems-rep-cols { display: grid; gap: 14px; }
@container ems (min-width: 760px) { .ems-rep-cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); } }
.ems-rep-col { min-width: 0; }
.ems-h4 { font: 600 .72rem/1.2 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 .5rem; }
.ems-int { list-style: none; margin: 0; padding: 0; counter-reset: emsi; }
.ems-int li { counter-increment: emsi; display: grid; grid-template-columns: 3.4em minmax(0, 1fr) auto; gap: .5rem; align-items: baseline; padding: .38rem 0; border-top: 1px dashed var(--line); font-size: .86rem; }
.ems-int li:first-child { border-top: 0; }
.ems-int time { font: 500 .72rem var(--font-mono); color: var(--muted); }
.ems-int em { font: 600 .6rem var(--font-mono); font-style: normal; letter-spacing: .06em; text-transform: uppercase; color: var(--clay); white-space: nowrap; }
.ems-int li.is-err span { color: var(--muted); text-decoration: line-through; }
.ems-missed { margin-top: .6rem; font-size: .84rem; color: var(--muted); }
.ems-missed b { color: var(--clay); }
.ems-mist { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: .2rem .9rem; }
.ems-mist div { display: grid; grid-template-columns: 1.7em minmax(0, 1fr); gap: .6rem; padding: .6rem 0; border-top: 1px dashed var(--line); }
.ems-mist div:first-child { border-top: 0; }
.ems-mist dt { font: 900 1.6rem/1 var(--font-display); color: var(--clay); }
.ems-mist dd { margin: 0; font-size: .86rem; line-height: 1.5; }
.ems-mist dd b { font-weight: 600; }
.ems-rep-act { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem 1.2rem; }

/* Narrow screens */
@container ems (max-width: 520px) {
  .ems-tablet { padding: 6px; border-radius: 14px; }
  .ems-screen { border-radius: 9px; }
  .ems-bar { padding: .5rem .6rem; gap: .45rem .8rem; }
  .ems-inc { padding-left: 0; border-left: 0; order: 3; flex: 1 1 100%; }
  .ems-pt { padding: .55rem .65rem; gap: .45rem 1rem; }
  .ems-pt-cc, .ems-scene { display: none; }
  .ems-ctl { order: 4; }
  .ems-work { padding: 6px; gap: 8px; }
  .ems-panel { padding: 10px; }
  .ems-brief { padding: .7rem; }
}

@keyframes ems-pulse { from { opacity: .9; transform: scale(1); } to { opacity: 0; transform: scale(1.9); } }
@keyframes ems-blink { 50% { opacity: .35; } }
@keyframes ems-fill { from { width: 0; } to { width: 100%; } }
@media (prefers-reduced-motion: reduce) {
  .ems *, .ems *::before, .ems *::after { animation: none !important; transition: none !important; }
  .ems-tool:active:not([aria-disabled="true"]) { transform: none; }
}
