/* Fake heart monitor — xscript.net */

:root {
  --bg: #000;
  --panel: #07090b;
  --panel-head: #101418;
  --line: #1c2228;
  --line-bright: #39424b;
  --text: #eef1f3;
  --muted: #8a939c;
  --dim: #59626b;
  --ecg: #3dff6e;
  --pleth: #2fe3ff;
  --resp: #ffe04a;
  --nibp: #ff7ad9;
  --temp: #eef1f3;
  --red: #ff3434;
  --yellow: #ffd21f;
  --cyan: #2fe3ff;
  --font-data: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-label: 'Barlow Condensed', 'Arial Narrow', var(--font-data);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { background: #0b0d0f; }

body {
  font-family: var(--font-data);
  background: #0b0d0f;
  color: var(--text);
  overflow-x: hidden;
  min-height: 100vh;
  font-variant-numeric: tabular-nums;
}

button, select { font-family: inherit; }
[hidden] { display: none !important; }

/* ---------- App shell ---------- */
.monitor {
  height: 100vh;
  min-height: 560px;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}
.monitor:fullscreen { height: 100vh; width: 100vw; min-height: 0; }
.monitor:-webkit-full-screen { height: 100vh; width: 100vw; min-height: 0; }

/* ---------- Header ---------- */
.hm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 14px;
  background: var(--panel-head);
  border-bottom: 1px solid var(--line-bright);
  flex: 0 0 auto;
}
.hm-left, .hm-right { display: flex; align-items: center; gap: 12px; flex: 1 1 0; min-width: 0; }
.hm-right { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.hm-logo {
  width: 30px; height: 30px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  border: 1.5px solid var(--ecg);
  border-radius: 6px;
}
.hm-logo svg { width: 22px; height: 14px; display: block; }
.hm-name { display: flex; flex-direction: column; line-height: 1.05; }
.hm-title { font-family: var(--font-label); font-weight: 700; font-size: 1.45rem; letter-spacing: 0.16em; color: var(--text); }
.hm-sub { font-family: var(--font-label); font-size: 0.72rem; letter-spacing: 0.22em; color: var(--muted); white-space: nowrap; }

.hm-sim {
  font-family: var(--font-label);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--yellow);
  border: 1px dashed var(--yellow);
  padding: 3px 8px;
  white-space: nowrap;
}

.hm-center { display: flex; flex-direction: column; align-items: center; line-height: 1.1; flex: 0 0 auto; text-align: center; }
.hm-bed { font-family: var(--font-label); font-size: 1.3rem; font-weight: 700; letter-spacing: 0.14em; color: var(--text); white-space: nowrap; }
.hm-bed b { color: var(--muted); font-weight: 600; }
.hm-pt { font-family: var(--font-label); font-size: 0.8rem; letter-spacing: 0.14em; color: var(--muted); white-space: nowrap; }
.hm-pt span { color: var(--text); }

.hm-pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-label);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  color: var(--muted);
}
.hm-pick select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line-bright);
  padding: 5px 6px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.hbtn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line-bright);
  padding: 6px 10px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.hbtn:hover, .hbtn:focus-visible { background: rgba(255, 255, 255, 0.1); border-color: var(--text); }
.hbtn[aria-pressed="true"] { color: var(--ecg); border-color: var(--ecg); }
.hbtn.is-shock { color: var(--yellow); border-color: var(--yellow); }
.hbtn.is-shock:hover, .hbtn.is-shock:focus-visible { background: rgba(255, 210, 31, 0.14); }
.hbtn.is-shock.is-fired { background: var(--yellow); color: #000; }

:focus-visible { outline: 2px solid var(--ecg); outline-offset: 2px; }

/* ---------- Alarm bar ---------- */
.hm-alarms {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 4px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-label);
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  white-space: nowrap;
  overflow: hidden;
}
.al { padding: 2px 10px; }
.al.is-red { background: var(--red); color: #fff; animation: slowPulse 2s ease-in-out infinite; }
.al.is-yellow { background: var(--yellow); color: #000; }
.al.is-cyan { color: var(--cyan); box-shadow: inset 0 0 0 1px var(--cyan); }
.al-none { color: var(--dim); font-weight: 600; }
.al-state { margin-left: auto; display: flex; gap: 14px; color: var(--muted); font-weight: 600; font-size: 0.84rem; }
.al-state span:empty { display: none; }
#alFrozen { color: var(--text); }

/* ---------- Main ---------- */
.hm-main {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 23vw);
}
.hm-waves { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--bg); }
.hm-waves canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hm-nums { display: flex; flex-direction: column; border-left: 1px solid var(--line); min-height: 0; }
.nb {
  --c: var(--text);
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto 1fr auto;
  padding: 6px 12px 7px;
  border-bottom: 1px solid var(--line);
  color: var(--c);
  overflow: hidden;
}
.nb:last-child { border-bottom: 0; }
.nb-hr { --c: var(--ecg); flex-grow: 1.45; }
.nb-spo2 { --c: var(--pleth); flex-grow: 1.15; }
.nb-nibp { --c: var(--nibp); }
.nb-rr { --c: var(--resp); flex-grow: 0.85; }
.nb-temp { --c: var(--temp); flex-grow: 0.75; }

.nb-h { display: flex; align-items: baseline; gap: 8px; font-family: var(--font-label); }
.nb-l { font-size: 1.05rem; font-weight: 700; letter-spacing: 0.1em; }
.nb-l sub { font-size: 0.7em; vertical-align: baseline; }
.nb-u { font-size: 0.8rem; letter-spacing: 0.08em; opacity: 0.75; }
.nb-lim { font-size: 0.68rem; line-height: 1.1; text-align: right; opacity: 0.7; font-family: var(--font-label); letter-spacing: 0.06em; }
.nb-v {
  grid-column: 1 / -1;
  align-self: center;
  justify-self: end;
  font-family: var(--font-label);
  font-weight: 600;
  line-height: 0.92;
  letter-spacing: 0.01em;
  font-size: clamp(2.4rem, 7.2vh, 6.2rem);
  white-space: nowrap;
}
.nb-hr .nb-v { font-size: clamp(3rem, 11vh, 9.5rem); }
.nb-spo2 .nb-v { font-size: clamp(2.7rem, 8.5vh, 7.5rem); }
.nb-nibp .nb-v { font-size: clamp(2rem, 6.2vh, 5.2rem); }
.nb-temp .nb-v, .nb-rr .nb-v { font-size: clamp(2rem, 5.6vh, 4.6rem); }
.nb-v small { font-size: 0.45em; margin-left: 6px; opacity: 0.8; }
.nb-s { grid-column: 1 / -1; justify-self: end; font-family: var(--font-label); font-size: 0.82rem; font-weight: 600; letter-spacing: 0.12em; opacity: 0.8; white-space: nowrap; }

.nb.is-red, .nb.is-yellow, .nb.is-cyan { box-shadow: inset 3px 0 0 var(--a); }
.nb.is-red { --a: var(--red); }
.nb.is-yellow { --a: var(--yellow); }
.nb.is-cyan { --a: var(--cyan); }
.nb.is-red .nb-l, .nb.is-yellow .nb-l { background: var(--a); color: #000; padding: 0 6px; }
.nb.is-red .nb-l { color: #fff; animation: slowPulse 2s ease-in-out infinite; }

/* ---------- Footer strip ---------- */
.hm-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 5px 14px;
  border-top: 1px solid var(--line-bright);
  background: var(--panel-head);
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  white-space: nowrap;
}
.hf-data { display: flex; align-items: center; gap: 18px; min-width: 0; overflow: hidden; }
.hf-data b { color: var(--text); font-weight: 600; }
.hf-ctl { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.hf-ctl .hbtn { padding: 4px 8px; font-size: 0.62rem; }

@keyframes slowPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* ---------- Reference content ---------- */
.tool-info {
  max-width: 900px;
  margin: 44px auto 40px;
  padding: 0 24px;
  color: #a3aab2;
  line-height: 1.7;
  font-size: 0.92rem;
}
.tool-info h1 { color: var(--text); font-size: 1.3rem; letter-spacing: 0.03em; margin-bottom: 14px; line-height: 1.35; }
.tool-info h2 {
  color: var(--text);
  font-size: 1.02rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 32px 0 10px;
  padding-left: 10px;
  border-left: 3px solid var(--ecg);
}
.tool-info h3 { color: var(--text); font-size: 0.94rem; margin: 22px 0 6px; }
.tool-info p { margin-bottom: 12px; }
.tool-info ul { margin: 0 0 12px 22px; }
.tool-info li { margin-bottom: 6px; }
.tool-info a { color: #6dff92; }
.tool-info strong { color: var(--text); }
.tool-info kbd {
  font-family: var(--font-data);
  font-size: 0.8em;
  border: 1px solid var(--line-bright);
  border-bottom-width: 2px;
  padding: 0 5px;
  border-radius: 3px;
  color: var(--text);
}
.tool-info code { font-family: var(--font-data); font-size: 0.85em; color: var(--text); background: var(--panel-head); padding: 1px 5px; }
.tool-info .note {
  border: 1px solid var(--yellow);
  background: rgba(255, 210, 31, 0.07);
  color: #d9dde1;
  padding: 10px 14px;
  margin: 0 0 14px;
}
.glossary { margin: 0 0 12px; }
.glossary dt { color: var(--text); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.84rem; margin-top: 16px; }
.glossary dd { margin: 4px 0 0; }

.table-wrap { overflow-x: auto; margin: 0 0 14px; }
.ref-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; min-width: 560px; }
.ref-table th, .ref-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line-bright); vertical-align: top; }
.ref-table th { color: var(--text); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; }
.ref-table td:first-child { color: var(--text); font-weight: 600; white-space: nowrap; }

.site-foot {
  border-top: 1px solid var(--line-bright);
  background: var(--panel-head);
  padding: 15px;
  text-align: center;
  font-size: 0.8rem;
}
.site-foot-links { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }
.site-foot-links a { color: var(--text); text-decoration: none; }
.site-foot-links a:hover { text-decoration: underline; }
.site-foot-note { color: var(--muted); font-size: 0.72rem; }

/* ---------- Responsive ---------- */
@media (max-width: 1600px) {
  .hm-pick span { display: none; }
}

@media (max-width: 1380px) {
  .hm-sub, .hm-pt { display: none; }
  .hm-head .hbtn { padding: 6px 7px; letter-spacing: 0.06em; }
  .hm-right { gap: 6px; }
}

@media (max-width: 1100px) {
  .monitor { height: auto; min-height: 0; }
  .hm-head { flex-wrap: wrap; }
  .hm-left, .hm-right { flex: 1 1 auto; }
  .hm-center { order: -1; width: 100%; }
  .hm-pt { display: block; }
  .hm-main { grid-template-columns: 1fr; }
  .hm-waves { height: 420px; }
  .hm-nums { display: grid; grid-template-columns: repeat(5, 1fr); border-left: 0; border-top: 1px solid var(--line); }
  .nb { border-bottom: 0; border-right: 1px solid var(--line); min-height: 128px; }
  .nb:last-child { border-right: 0; }
  .nb .nb-v { font-size: 2.6rem; }
  .nb-hr .nb-v, .nb-spo2 .nb-v { font-size: 3.4rem; }
  .hm-foot { flex-wrap: wrap; white-space: normal; justify-content: center; }
  .hf-data { flex-wrap: wrap; justify-content: center; gap: 6px 16px; }
  .hf-ctl { flex: 1 1 100%; flex-wrap: wrap; justify-content: center; }
}

@media (max-width: 680px) {
  .hm-left, .hm-right { justify-content: center; flex-wrap: wrap; }
  .hm-waves { height: 330px; }
  .hm-nums { grid-template-columns: repeat(2, 1fr); }
  .nb { border-bottom: 1px solid var(--line); }
  .nb-hr { grid-column: 1 / -1; }
  .al-state { display: none; }
  .hm-alarms { flex-wrap: wrap; white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  .al.is-red, .nb.is-red .nb-l { animation: none; }
  .hbtn { transition: none; }
}
