:root {
    color-scheme: dark;
    --ink: #edf5f1;
    --muted: #8a9a94;
    --line: rgba(202, 231, 219, .13);
    --panel: #0b1517;
    --panel-2: #101d1f;
    --bg: #050b0d;
    --green: #77f2a4;
    --green-hot: #23ef70;
    --cyan: #58d9e8;
    --amber: #ffc56e;
    --red: #ff6b74;
    --shadow: 0 24px 80px rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 14% -10%, rgba(40, 121, 92, .18), transparent 28rem),
        radial-gradient(circle at 105% 20%, rgba(27, 93, 101, .12), transparent 34rem),
        var(--bg);
    font-family: "Manrope", system-ui, sans-serif;
    min-height: 100vh;
}

button, input, select { font: inherit; }
button, select, input[type="range"] { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 3px;
}

.app-shell { width: min(1740px, 100%); margin: 0 auto; }

.topbar {
    min-height: 76px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 24px;
    padding: 14px clamp(18px, 3vw, 48px);
    border-bottom: 1px solid var(--line);
    background: rgba(5, 11, 13, .72);
    backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand { color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 13px; width: max-content; }
.brand strong { display: block; font-size: 1.03rem; letter-spacing: -.02em; }
.brand small { display: block; color: var(--muted); font: 500 .62rem/1.3 "DM Mono", monospace; letter-spacing: .16em; margin-top: 2px; }
.brand-mark { width: 34px; aspect-ratio: 1; display: grid; place-items: center; border: 1px solid rgba(119, 242, 164, .36); border-radius: 8px; background: rgba(119, 242, 164, .07); }
.brand-mark span { width: 19px; height: 10px; border-left: 2px solid var(--green); border-bottom: 2px solid var(--green); transform: skew(-28deg) rotate(-44deg); filter: drop-shadow(0 0 5px rgba(119, 242, 164, .6)); }

.topbar-center { justify-self: center; display: flex; align-items: center; gap: 9px; color: #9aa8a3; font: 500 .67rem "DM Mono", monospace; letter-spacing: .1em; }
.live-dot { width: 7px; aspect-ratio: 1; border-radius: 50%; background: var(--green-hot); box-shadow: 0 0 12px var(--green-hot); animation: pulse 1.5s ease-out infinite; }
.topbar-divider { height: 14px; width: 1px; background: var(--line); margin: 0 4px; }
@keyframes pulse { 65% { box-shadow: 0 0 0 8px rgba(35, 239, 112, 0); } }

.top-actions { justify-self: end; display: flex; gap: 8px; }
.icon-button, .secondary-button {
    color: #b7c4bf;
    background: #0d1719;
    border: 1px solid var(--line);
    border-radius: 9px;
    min-height: 40px;
    padding: 0 13px;
    display: inline-flex;
    gap: 8px;
    align-items: center;
    transition: border-color .2s, background .2s, color .2s;
}
.icon-button:hover, .secondary-button:hover { color: var(--ink); border-color: rgba(119, 242, 164, .32); background: #122023; }
.icon-button[aria-pressed="true"] { color: var(--green); border-color: rgba(119, 242, 164, .34); }
.button-label { font-size: .75rem; font-weight: 700; }

main { padding: 18px clamp(14px, 2.3vw, 36px) 24px; }
.safety-strip {
    border: 1px solid rgba(255, 197, 110, .18);
    background: linear-gradient(90deg, rgba(255, 197, 110, .08), rgba(255, 197, 110, .025));
    color: #b9b5a9;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    border-radius: 10px;
    padding: 8px 12px;
    margin-bottom: 18px;
    font-size: .73rem;
}
.safety-strip p { margin: 0; flex: 1; }
.safety-strip strong { color: var(--amber); }
.safety-icon { display: grid; place-items: center; border: 1px solid var(--amber); color: var(--amber); width: 19px; aspect-ratio: 1; border-radius: 50%; font: 600 .7rem serif; }
.safety-strip button { border: 0; background: none; color: var(--amber); font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }

.monitor-layout { display: grid; grid-template-columns: minmax(0, 1.82fr) minmax(320px, .7fr); gap: 18px; align-items: start; }
.monitor-panel, .control-panel { border: 1px solid var(--line); border-radius: 13px; background: linear-gradient(145deg, rgba(15, 27, 29, .92), rgba(8, 16, 18, .96)); box-shadow: var(--shadow); }
.monitor-panel { overflow: hidden; }
.monitor-header { min-height: 78px; padding: 16px 20px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.eyebrow { color: #778a83; display: block; font: 500 .61rem/1.5 "DM Mono", monospace; letter-spacing: .16em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.15rem, 2vw, 1.52rem); letter-spacing: -.035em; }
.monitor-status { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.monitor-status span { border: 1px solid var(--line); border-radius: 5px; color: #84948e; padding: 5px 7px; font: 500 .58rem "DM Mono", monospace; }

.screen {
    background: #020807;
    min-height: 584px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 196px;
    grid-template-rows: 1fr auto;
    position: relative;
    isolation: isolate;
    box-shadow: inset 0 0 90px rgba(0, 0, 0, .42);
}
.screen::after { content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: .2; background: repeating-linear-gradient(0deg, transparent 0 2px, rgba(255,255,255,.022) 3px); }
.screen-alarm {
    position: absolute;
    z-index: 8;
    top: 9px;
    right: 210px;
    min-height: 29px;
    padding: 0 10px 0 7px;
    display: none;
    align-items: center;
    gap: 7px;
    color: #fff;
    background: rgba(185, 29, 41, .92);
    border: 1px solid rgba(255, 132, 140, .7);
    border-radius: 5px;
    box-shadow: 0 0 22px rgba(255, 44, 61, .32);
    font: 700 .61rem "DM Mono", monospace;
    letter-spacing: .08em;
}
.screen-alarm.visible { display: flex; animation: alarm-flash .85s steps(1) infinite; }
.screen-alarm span { width: 15px; aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; color: #b91d29; background: #fff; font-size: .62rem; }
@keyframes alarm-flash { 50% { opacity: .55; } }
.audio-gate { position: absolute; z-index: 10; left: 50%; top: 48%; transform: translate(-50%, -50%); min-height: 44px; padding: 0 17px; border: 1px solid rgba(119,242,164,.48); border-radius: 8px; color: #07120c; background: var(--green); box-shadow: 0 10px 34px rgba(0,0,0,.5), 0 0 22px rgba(119,242,164,.16); font-size: .72rem; font-weight: 800; }
.audio-gate span { margin-right: 7px; }
.audio-gate.is-hidden { display: none; }
.audio-pulse-lamp { position: absolute; z-index: 7; top: 11px; left: 46px; display: flex; align-items: center; gap: 5px; color: #53635d; font: 500 .48rem "DM Mono", monospace; letter-spacing: .08em; pointer-events: none; }
.audio-pulse-lamp span { width: 6px; aspect-ratio: 1; border-radius: 50%; background: #314039; }
.audio-pulse-lamp.active { color: var(--green); }
.audio-pulse-lamp.active span { background: var(--green-hot); box-shadow: 0 0 11px var(--green-hot); }
.trace-stack { min-width: 0; display: grid; grid-template-rows: 1.7fr 1fr .8fr; padding: 10px 0 24px; }
.trace-row { min-width: 0; position: relative; overflow: hidden; border-bottom: 1px solid rgba(112, 155, 138, .07); }
.trace-row canvas { display: block; width: 100%; height: 100%; }
.trace-meta { position: absolute; z-index: 4; top: 12px; left: 13px; pointer-events: none; display: flex; gap: 8px; align-items: center; font: 500 .64rem "DM Mono", monospace; text-shadow: 0 0 7px currentColor; }
.trace-meta strong { font-size: .53rem; border: 1px solid currentColor; border-radius: 3px; padding: 2px 3px; opacity: .62; }
.ecg-color { color: var(--green-hot); }
.spo2-color { color: var(--cyan); }
.resp-color { color: var(--amber); }

.vitals { border-left: 1px solid rgba(182, 235, 211, .11); min-width: 0; display: grid; grid-template-rows: 1.1fr 1fr 1.08fr .9fr; padding-bottom: 24px; }
.vital { position: relative; border-bottom: 1px solid rgba(182, 235, 211, .1); padding: 12px 13px; overflow: hidden; }
.vital-label { display: flex; align-items: baseline; justify-content: space-between; font: 500 .68rem "DM Mono", monospace; }
.vital-label small { opacity: .5; }
.vital output { display: block; font: 500 clamp(2.8rem, 5vw, 4.5rem)/.97 "DM Mono", monospace; text-align: right; letter-spacing: -.1em; padding-right: .1em; text-shadow: 0 0 14px color-mix(in srgb, currentColor 52%, transparent); font-variant-numeric: tabular-nums; }
.vital-hr { color: var(--green-hot); }
.vital-spo2 { color: var(--cyan); }
.vital-nibp { color: #f3e9d8; }
.vital-rr { color: var(--amber); }
.vital-nibp output { font-size: clamp(2rem, 3.6vw, 3.1rem); margin-top: 14px; white-space: nowrap; letter-spacing: -.11em; }
.vital-nibp output i { opacity: .45; font-style: normal; font-size: .6em; margin: 0 .08em; }
.limits { position: absolute; left: 12px; bottom: 13px; opacity: .42; text-align: center; font: 500 .51rem/1.35 "DM Mono", monospace; }
.map { text-align: right; opacity: .52; font: 500 .58rem "DM Mono", monospace; margin-top: 5px; }
.screen-footer { grid-column: 1 / -1; height: 24px; display: flex; align-items: center; justify-content: space-between; gap: 15px; border-top: 1px solid rgba(182, 235, 211, .1); color: #53625d; padding: 0 12px; font: 500 .5rem "DM Mono", monospace; letter-spacing: .08em; }
.patient-cue {
    position: absolute;
    z-index: 6;
    left: 14px;
    right: 210px;
    bottom: 32px;
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}
.patient-cue > span { min-width: 84px; border: 1px solid rgba(182,235,211,.12); background: rgba(2,8,7,.78); border-radius: 5px; padding: 5px 7px; }
.patient-cue small { display: block; color: #566761; font: 500 .46rem "DM Mono", monospace; letter-spacing: .08em; }
.patient-cue strong { display: block; color: #a8b9b2; font-size: .63rem; margin-top: 2px; }
.patient-cue p { margin: 0; color: #7d8e88; background: rgba(2,8,7,.78); border-left: 2px solid var(--green); padding: 7px 9px; font-size: .61rem; line-height: 1.4; }
.patient-cue.critical p { border-left-color: var(--red); color: #d7a7aa; }
.patient-cue.critical strong { color: var(--red); }

.transport { min-height: 66px; display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line); }
.primary-button { min-height: 41px; border: 1px solid rgba(119, 242, 164, .4); background: var(--green); color: #07120c; border-radius: 8px; font-weight: 800; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; transition: transform .15s, filter .15s; }
.primary-button:hover { filter: brightness(1.08); transform: translateY(-1px); }
.pause-icon { font: 800 .72rem monospace; }
.secondary-button { min-height: 41px; font-size: .75rem; font-weight: 700; }
.transport-note { margin-left: auto; color: #667670; display: flex; align-items: center; gap: 7px; font-size: .65rem; }
.keyboard-key { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 3px 5px; font: .56rem "DM Mono", monospace; }

.control-panel { padding: 20px; }
.control-heading { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; padding-bottom: 17px; }
.control-heading h2 { margin: 2px 0 0; font-size: 1.22rem; letter-spacing: -.035em; }
.unsaved-badge { color: #7d8f88; border: 1px solid var(--line); padding: 4px 7px; border-radius: 4px; font: 500 .54rem "DM Mono", monospace; letter-spacing: .08em; }
.unsaved-badge.changed { color: var(--amber); border-color: rgba(255, 197, 110, .26); }

.control-group { border-top: 1px solid var(--line); padding: 15px 0; }
.control-group > label, .range-label label, .control-group.compact label { color: #acb9b4; display: block; margin-bottom: 10px; font-size: .71rem; font-weight: 700; }
.select-wrap { position: relative; }
.select-wrap::after { content: "⌄"; position: absolute; right: 12px; top: 50%; transform: translateY(-55%); color: var(--green); pointer-events: none; }
select { width: 100%; appearance: none; min-height: 45px; padding: 0 38px 0 12px; color: var(--ink); background: #0a1315; border: 1px solid rgba(191, 224, 211, .15); border-radius: 7px; font-size: .78rem; font-weight: 700; }
.range-label { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.range-label output { color: var(--green); font: 500 .66rem "DM Mono", monospace; }
input[type="range"] { appearance: none; display: block; width: 100%; height: 4px; border-radius: 8px; background: linear-gradient(90deg, var(--green) var(--fill, 26%), #273432 var(--fill, 26%)); }
input[type="range"]::-webkit-slider-thumb { appearance: none; width: 15px; height: 15px; border-radius: 50%; background: var(--green); border: 3px solid #0d1916; box-shadow: 0 0 0 1px rgba(119, 242, 164, .65), 0 0 11px rgba(119, 242, 164, .25); }
input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; border-radius: 50%; background: var(--green); border: 3px solid #0d1916; }
.range-scale { display: flex; justify-content: space-between; color: #596a64; margin-top: 7px; font: .53rem "DM Mono", monospace; }
.control-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; border-top: 1px solid var(--line); }
.control-group.compact { border-top: 0; padding-bottom: 7px; }
.stepper { display: flex; align-items: center; background: #0a1315; border: 1px solid rgba(191, 224, 211, .15); border-radius: 7px; padding-right: 9px; }
.stepper input { min-width: 0; width: 100%; height: 40px; color: var(--ink); background: transparent; border: 0; padding: 0 5px 0 10px; font: 500 .82rem "DM Mono", monospace; }
.stepper span { color: #60716b; font: .55rem "DM Mono", monospace; }
.is-hidden { display: none; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.event-lab { margin: 7px 0 12px; padding: 15px; border: 1px solid rgba(88, 217, 232, .17); border-radius: 9px; background: linear-gradient(135deg, rgba(88, 217, 232, .055), rgba(88, 217, 232, .012)); }
.event-lab-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.event-lab h3 { margin: 1px 0 0; font-size: .82rem; }
.event-status { color: var(--cyan); border: 1px solid rgba(88, 217, 232, .24); border-radius: 4px; padding: 4px 6px; font: 500 .5rem "DM Mono", monospace; letter-spacing: .08em; }
.event-status.active { color: var(--red); border-color: rgba(255, 107, 116, .35); animation: pulse 1.4s ease-out infinite; }
.event-actions { display: grid; grid-template-columns: 1fr auto; gap: 7px; margin-top: 8px; }
.event-start, .event-stop { min-height: 38px; border-radius: 7px; font-size: .68rem; font-weight: 800; }
.event-start { border: 1px solid rgba(88, 217, 232, .35); background: rgba(88, 217, 232, .12); color: var(--cyan); }
.event-stop { border: 1px solid var(--line); background: #0a1315; color: #82928c; padding: 0 13px; }
.event-start:disabled, .event-stop:disabled { cursor: not-allowed; opacity: .35; }
.event-progress-wrap { margin-top: 11px; }
.event-progress { height: 3px; background: #24312f; border-radius: 5px; overflow: hidden; }
.event-progress span { display: block; width: 0; height: 100%; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); transition: width .25s linear; }
.event-stage-line { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; color: #a8b7b2; font-size: .61rem; }
.event-stage-line span { color: var(--cyan); font: .56rem "DM Mono", monospace; }
.event-progress-wrap p { color: #64756f; font-size: .59rem; line-height: 1.45; margin: 5px 0 0; }
.audio-actions { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 7px; margin-top: 11px; }
.audio-profile-row { margin-bottom: 14px; }
.audio-profile-row > label { color: #acb9b4; display: block; margin-bottom: 9px; font-size: .71rem; font-weight: 700; }
.audio-actions button { min-height: 35px; padding: 0 11px; border-radius: 7px; border: 1px solid rgba(255,107,116,.27); background: rgba(255,107,116,.08); color: #ff959c; font-size: .64rem; font-weight: 800; }
.audio-actions button:hover { border-color: rgba(255,107,116,.55); background: rgba(255,107,116,.13); }
.audio-actions small { grid-column: 1 / -1; color: #61716b; font-size: .54rem; line-height: 1.35; }
.audio-actions small.ready { color: var(--green); }
.audio-teaching-note { margin: 11px 0 0; padding: 9px 10px; border-left: 2px solid var(--cyan); background: rgba(88,217,232,.045); color: #6f837c; font-size: .56rem; line-height: 1.5; }
.audio-teaching-note strong { color: #9db6ad; }
.custom-audio-files { margin-top: 10px; padding: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; border: 1px solid rgba(119,242,164,.15); border-radius: 7px; background: rgba(119,242,164,.035); }
.custom-audio-files label { color: #97a8a1; font-size: .58rem; font-weight: 700; }
.custom-audio-files input { display: block; width: 100%; margin-top: 6px; color: #758780; font-size: .54rem; }
.custom-audio-files small { grid-column: 1 / -1; color: #60716b; font-size: .52rem; }
.custom-audio-files.is-hidden { display: none; }

.teaching-card { margin-top: 4px; padding: 15px; border: 1px solid rgba(119, 242, 164, .16); border-radius: 9px; background: linear-gradient(135deg, rgba(119, 242, 164, .065), rgba(119, 242, 164, .015)); }
.teaching-card-head { display: flex; align-items: center; gap: 11px; }
.lesson-number { width: 31px; aspect-ratio: 1; display: grid; place-items: center; border-radius: 6px; color: var(--green); border: 1px solid rgba(119, 242, 164, .3); font: .65rem "DM Mono", monospace; }
.teaching-card h3 { margin: 1px 0 0; font-size: .8rem; }
.teaching-card ul { margin: 13px 0; padding-left: 17px; color: #9aa9a3; font-size: .68rem; line-height: 1.65; }
.teaching-card li::marker { color: var(--green); }
.prompt { margin: 0; padding-top: 11px; border-top: 1px solid var(--line); color: #71817b; font-size: .65rem; line-height: 1.55; }
.prompt strong { color: #9bb0a8; }
.scenario-button { width: 100%; margin-top: 11px; min-height: 44px; padding: 0 13px; display: flex; align-items: center; justify-content: space-between; color: #aebbb6; border: 1px solid var(--line); border-radius: 8px; background: #0b1517; font-size: .72rem; font-weight: 700; }
.scenario-button:hover { border-color: rgba(119, 242, 164, .35); color: var(--green); }

footer { color: #54635e; min-height: 64px; padding: 18px clamp(18px, 3vw, 48px); display: flex; justify-content: space-between; gap: 18px; font: .58rem "DM Mono", monospace; letter-spacing: .08em; }

dialog { width: min(660px, calc(100% - 24px)); max-height: calc(100vh - 32px); padding: 0; color: var(--ink); background: #0b1517; border: 1px solid rgba(182, 235, 211, .18); border-radius: 13px; box-shadow: 0 40px 130px #000; }
dialog::backdrop { background: rgba(0, 5, 6, .78); backdrop-filter: blur(7px); }
.dialog-card { margin: 0; }
.dialog-head { padding: 20px 22px 16px; display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 2px 0 0; font-size: 1.25rem; }
.dialog-close { border: 0; background: transparent; color: #7f908a; font-size: 1.6rem; line-height: 1; }
.dialog-body { padding: 20px 22px; max-height: 62vh; overflow: auto; color: #9cacA6; font-size: .76rem; line-height: 1.65; }
.dialog-body .lead { color: #c1cec9; }
.dialog-body h3 { color: var(--ink); margin: 20px 0 4px; font-size: .84rem; }
.safety-callout { display: grid; gap: 4px; padding: 13px; border-left: 2px solid var(--amber); background: rgba(255, 197, 110, .06); }
.safety-callout strong { color: var(--amber); }
.source-list { padding-left: 18px; }
.source-list a { color: var(--green); }
.fine-print { color: #6c7c76; }
.dialog-action { width: calc(100% - 44px); margin: 0 22px 22px; }

@media (max-width: 1080px) {
    .monitor-layout { grid-template-columns: 1fr; }
    .control-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
    .control-heading, .rhythm-picker, .teaching-card, .scenario-button, .event-lab { grid-column: 1 / -1; }
    .control-grid { border-top: 1px solid var(--line); }
}

@media (max-width: 720px) {
    .topbar { grid-template-columns: 1fr auto; }
    .topbar-center { display: none; }
    .button-label { display: none; }
    .safety-strip { align-items: flex-start; }
    .safety-strip button { display: none; }
    .monitor-header { align-items: flex-start; }
    .monitor-status span:not(:first-child) { display: none; }
    .screen { min-height: 520px; grid-template-columns: minmax(0, 1fr) 112px; }
    .screen-alarm { right: 120px; }
    .patient-cue { right: 120px; }
    .patient-cue > span { display: none; }
    .vital { padding: 10px 7px; }
    .vital output { font-size: clamp(2rem, 11vw, 3rem); }
    .vital-nibp output { font-size: clamp(1.35rem, 7vw, 2rem); }
    .vital-label { font-size: .55rem; }
    .limits { display: none; }
    .transport-note { display: none; }
    .transport { flex-wrap: wrap; }
    .control-panel { display: block; }
    .control-grid { gap: 0 10px; }
    footer { flex-direction: column; }
}

@media (max-width: 440px) {
    .brand-mark { display: none; }
    main { padding-left: 8px; padding-right: 8px; }
    .monitor-header, .control-panel { padding-left: 13px; padding-right: 13px; }
    .screen { min-height: 480px; grid-template-columns: minmax(0, 1fr) 96px; }
    .screen-alarm { right: 104px; }
    .patient-cue { right: 104px; left: 8px; }
    .trace-meta { left: 7px; }
    .vital-label small, .screen-footer span:nth-child(2) { display: none; }
    .vital output { letter-spacing: -.12em; }
    .primary-button, .secondary-button { flex: 1; padding-left: 8px; padding-right: 8px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
    .live-dot { animation: none; }
    .screen-alarm.visible { animation: none; }
}

/* The fullscreen element is removed from the page layout, so it needs its own
   explicit viewport-sized grid. minmax(0, ...) prevents the lower vital rows
   from being pushed below the visible area by their contents. */
.screen:fullscreen,
.screen:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    margin: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    grid-template-columns: minmax(0, 1fr) clamp(150px, 18vw, 270px);
    grid-template-rows: minmax(0, 1fr) 28px;
    background: #020807;
}

.screen:fullscreen .trace-stack,
.screen:-webkit-full-screen .trace-stack,
.screen:fullscreen .vitals,
.screen:-webkit-full-screen .vitals {
    min-height: 0;
    height: 100%;
}

.screen:fullscreen .vitals,
.screen:-webkit-full-screen .vitals {
    grid-template-rows: repeat(4, minmax(0, 1fr));
    padding-bottom: 0;
    overflow: hidden;
}

.screen:fullscreen .vital,
.screen:-webkit-full-screen .vital {
    min-height: 0;
    padding: clamp(7px, 1.4vh, 15px) clamp(8px, 1.2vw, 16px);
}

.screen:fullscreen .vital output,
.screen:-webkit-full-screen .vital output {
    font-size: clamp(2.2rem, 7.2vh, 5rem);
    line-height: .92;
}

.screen:fullscreen .vital-nibp output,
.screen:-webkit-full-screen .vital-nibp output {
    margin-top: clamp(4px, 1.5vh, 14px);
    font-size: clamp(1.65rem, 5.2vh, 3.6rem);
}

.screen:fullscreen .patient-cue,
.screen:-webkit-full-screen .patient-cue {
    right: calc(clamp(150px, 18vw, 270px) + 14px);
    bottom: 36px;
}

.screen:fullscreen .screen-alarm,
.screen:-webkit-full-screen .screen-alarm {
    right: calc(clamp(150px, 18vw, 270px) + 14px);
}

@media (max-height: 620px) {
    .screen:fullscreen .vital-label,
    .screen:-webkit-full-screen .vital-label { font-size: .54rem; }
    .screen:fullscreen .limits,
    .screen:-webkit-full-screen .limits,
    .screen:fullscreen .map,
    .screen:-webkit-full-screen .map { display: none; }
    .screen:fullscreen .patient-cue > span,
    .screen:-webkit-full-screen .patient-cue > span { display: none; }
}
