/* © 2026 Christian Dworeck / kardiologi.se. All rights reserved. Copying or redistribution without permission is not allowed. */
:root {
  --bg: #08121c;
  --panel: #0e1b2a;
  --panel-2: #142536;
  --line: #223a52;
  --text: #e3edf6;
  --muted: #8fa9c2;
  --accent: #6cb4f0;
  --accent-ink: #04223f;
  --brand: #0756aa;     /* button blue of kardiologi.se */
  --head: #cfe3f7;      /* headings: light variant of the dark blue #173F59 used on kardiologi.se */
  --amber: #ffc861;
  --coral: #ff7a6b;
  --good: #5ee6a8;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: Raleway, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 13px/1.45 var(--sans); display: flex; flex-direction: column; overflow: hidden;
}
kbd {
  font: 600 10.5px var(--mono); padding: 1px 5px; border-radius: 4px;
  background: #0a1522; border: 1px solid #2c4766; color: #bcd3ea; margin-left: 4px;
}
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 8px 14px; border-bottom: 1px solid var(--line); background: #0a1522; flex: none;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { display: block; flex: none; line-height: 0; }
.brand .logo img { width: 40px; height: 40px; border-radius: 50%; }
.brand strong { display: block; font-size: 15px; letter-spacing: .02em; }
.brand span { color: var(--muted); font-size: 12px; }
.brand .copyright { display: block; font-size: 10.5px; opacity: .75; }
.pulse {
  width: 10px; height: 10px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 4px rgba(108, 180, 240, .18);
}
.top-controls { display: flex; align-items: center; gap: 8px; }
.vitals { display: flex; align-items: center; gap: 8px; min-width: 0; }
.vitals canvas { width: 200px; height: 44px; border-radius: 7px; border: 1px solid var(--line); display: block; }
.case-pick { display: flex; align-items: center; gap: 8px; color: var(--muted); }
select, .btn, .hold, .pedal, .seg button, .chips button {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid #2a4565; border-radius: 8px; padding: 6px 10px; cursor: pointer;
}
select { padding: 6px 8px; max-width: 100%; }
select.full, .btn.full { width: 100%; }
.btn:hover, .hold:hover, .chips button:hover, .seg button:hover { border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 8px; font-size: 12.5px; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 700; }
.btn.primary:hover { background: #0a68cc; border-color: #0a68cc; }
/* Help button: yellow, so it is easy to find (the warm yellow already used in the simulator, dark blue text) */
#btnHelp { background: var(--amber); border-color: var(--amber); color: var(--accent-ink); font-weight: 700; }
#btnHelp:hover { background: #ffd98a; border-color: #ffd98a; }
.btn.tool.on, .seg button.on, .chips button.on { background: #0d3a6b; border-color: var(--accent); color: #d8eaff; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.layout {
  flex: 1; min-height: 0; display: grid; gap: 10px; padding: 10px;
  grid-template-columns: 256px minmax(0, 1fr) 372px;
}
.col { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin; scrollbar-color: #27405c transparent; }
.col-center { overflow: hidden; align-items: center; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; flex: none; }
.panel h2 {
  margin: 0 0 8px; font: 650 11px var(--sans); letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.panel h3 {
  margin: 12px 0 6px; padding-top: 10px; border-top: 1px solid var(--line);
  font: 650 12px var(--sans); display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.tag {
  font: 500 11px var(--mono); color: #adc6df; background: #0a1623; border: 1px solid var(--line);
  border-radius: 20px; padding: 2px 8px; letter-spacing: 0; text-transform: none; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 230px;
}
.tag.strong { color: var(--accent); border-color: #2a5f94; }
.brief b { display: block; font-size: 13.5px; margin-bottom: 3px; }
.brief .pt { color: var(--amber); margin-bottom: 5px; }
.brief p { margin: 0; color: #c0d1e4; font-size: 12.5px; }
.mini { width: 100%; aspect-ratio: 1; display: block; border-radius: 7px; background: #050607; border: 1px solid var(--line); }

.monitor {
  position: relative; aspect-ratio: 1; height: 100%; max-height: calc(100vh - 148px); max-width: 100%;
  flex: 0 1 auto; border-radius: 12px; overflow: hidden; background: #050607;
  border: 1px solid #223d5a; box-shadow: 0 0 0 5px #0a1520, 0 12px 40px rgba(0, 0, 0, .5);
  touch-action: none; cursor: grab;
}
.monitor.tooling { cursor: crosshair; }
.monitor canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#fluoro { filter: blur(.45px) contrast(1.06); }
.pedals { display: flex; align-items: stretch; gap: 8px; width: 100%; max-width: 900px; flex: none; }
.pedal { padding: 8px 14px; font-weight: 650; min-width: 128px; user-select: none; touch-action: none; }
.pedal.on { background: #5a4712; border-color: var(--amber); color: #fff0c7; }
.pedal.cine.on { background: #5c1f18; border-color: var(--coral); color: #ffe1dc; }
.metrics { margin: 0; flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.metrics div { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px; }
.metrics dt { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; }
.metrics dd { margin: 0; font: 600 14px var(--mono); }
.toast {
  position: absolute; left: 50%; bottom: 76px; transform: translateX(-50%); max-width: 620px;
  background: #0f2740; border: 1px solid var(--accent); color: #e6f2ff; padding: 8px 14px; border-radius: 9px;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 5; text-align: center;
}
.toast.show { opacity: 1; }
.toast.warn { border-color: var(--amber); background: #2a2108; color: #ffe9b8; }
.toast.bad { border-color: var(--coral); background: #2f100c; color: #ffd9d3; }
.col-center { position: relative; }

.slider-row { display: grid; grid-template-columns: 34px 1fr 34px; align-items: center; gap: 6px; color: var(--muted); font: 600 11px var(--mono); margin-bottom: 4px; }
.slider-row span:last-child { text-align: right; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.chips-label { color: var(--muted); font-size: 11px; margin: 7px 0 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chips button { padding: 3px 8px; font-size: 12px; border-radius: 20px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 7px; align-items: center; }
.row.three { grid-template-columns: repeat(3, 1fr); }
.row.four { grid-template-columns: repeat(4, 1fr); }
.row.dev { grid-template-columns: 1fr 1fr; }
.row.end { display: flex; justify-content: flex-end; margin-top: 14px; }
.seg { display: flex; }
.seg button { border-radius: 0; padding: 5px 8px; font-size: 12px; flex: 1; }
.seg button:first-child { border-radius: 7px 0 0 7px; }
.seg button:last-child { border-radius: 0 7px 7px 0; }
.hint { color: var(--muted); font-size: 11.5px; margin: 7px 0 0; }
.hold { padding: 7px 4px; font-size: 12px; user-select: none; touch-action: none; white-space: nowrap; }
.hold.on { background: #0d3a6b; border-color: var(--accent); }
.hold.inflate.on { background: #5a4712; border-color: var(--amber); }
.check { display: flex; align-items: center; gap: 7px; margin-top: 6px; color: #c0d1e4; cursor: pointer; }
.check input { accent-color: var(--accent); }
.gauge { position: relative; height: 12px; background: #0a1623; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.gauge #pBar { height: 100%; width: 0; background: var(--good); }
.gauge i { position: absolute; top: 0; bottom: 0; width: 2px; background: #e3edf6; opacity: .55; }
.gauge #pRbp { background: var(--coral); opacity: .9; }
.pending { border: 1px dashed var(--coral); border-radius: 8px; padding: 8px; margin-bottom: 8px; display: grid; gap: 6px; }
.pending[hidden] { display: none; }
.findings { margin: 0 0 8px; padding: 0; list-style: none; display: grid; gap: 4px; }
.findings li { display: flex; justify-content: space-between; align-items: center; gap: 6px; background: #0a1623; border: 1px solid var(--line); border-radius: 7px; padding: 4px 8px; }
.findings li button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; }
.findings .empty { color: var(--muted); justify-content: flex-start; }
.log { margin: 0; padding: 0; list-style: none; max-height: 190px; overflow-y: auto; font: 11.5px/1.4 var(--mono); color: #a9c0bf; scrollbar-width: thin; }
.log li { padding: 2px 0; border-bottom: 1px solid #15283b; }
.log li.bad { color: var(--coral); }
.log li.good { color: var(--good); }
.log time { color: #6a86a3; margin-right: 6px; }

.dlg {
  background: var(--panel); color: var(--text); border: 1px solid #2d4a6b; border-radius: 14px;
  padding: 20px 22px; width: min(880px, 94vw); max-height: 90vh; overflow-y: auto;
}
#resultDlg[open] { display: flex; flex-direction: column; overflow: hidden; }
#resultBody { overflow-y: auto; min-height: 0; padding-right: 6px; }
.dlg.small { width: min(380px, 92vw); }
.dlg select.full { width: 100%; margin-top: 10px; }
.row.end.gap { gap: 8px; }
.dlg::backdrop { background: rgba(2, 6, 12, .72); }
.dlg h2 { margin: 0 0 10px; font-size: 19px; }
.dlg h3 { margin: 14px 0 6px; font-size: 13px; color: var(--accent); text-transform: uppercase; letter-spacing: .07em; }
.dlg ol, .dlg ul { margin: 0; padding-left: 19px; color: #c5d8d7; }
.dlg li { margin-bottom: 4px; }
.help-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 22px; margin-bottom: 14px; }
.keys { border-collapse: collapse; width: 100%; }
.keys td { padding: 3px 4px; border-bottom: 1px solid var(--line); color: #c5d8d7; }
.score-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 4px; }
.score-head .num { font: 700 44px var(--mono); color: var(--accent); }
.score-head .grade { font-size: 17px; font-weight: 650; }
.tbl { width: 100%; border-collapse: collapse; margin-top: 6px; }
.tbl th { text-align: left; color: var(--muted); font: 650 10.5px var(--sans); text-transform: uppercase; letter-spacing: .07em; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl td.pts { font: 600 13px var(--mono); white-space: nowrap; }
.tbl .note { color: #a9c0bf; font-size: 12px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; background: var(--coral); }
.dot.ok { background: var(--good); }
.dot.part { background: var(--amber); }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px; }

@media (max-width: 1180px) {
  .vitals canvas { display: none; }
  body { overflow: auto; }
  .layout { grid-template-columns: 1fr; }
  .col { overflow: visible; }
  .monitor { max-height: none; width: 100%; height: auto; }
  .col-left { display: grid; grid-template-columns: repeat(2, 1fr); }
  .help-grid { grid-template-columns: 1fr; }
}

/* cine review (reference monitor) */
.ref-wrap { position: relative; }
.ref-wrap canvas { cursor: pointer; }
.ref-full-btn {
  position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; padding: 0; cursor: pointer;
  background: rgba(5, 8, 9, .6); border: 1px solid #3d5f85; border-radius: 5px; display: grid; place-items: center;
}
.ref-full-btn span { width: 11px; height: 11px; border: 2px solid #dce9f7; border-radius: 1px; display: block; }
.ref-full-btn:hover { border-color: var(--accent); }
.ref-full-btn:hover span { border-color: var(--accent); }
.ref-full-btn:disabled { opacity: .3; cursor: default; }
.ref-nav { display: flex; align-items: center; gap: 6px; margin-top: 7px; }
.ref-nav span { flex: 1; text-align: center; font: 600 11px var(--mono); color: #c5d8d7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ref-nav .btn:disabled { opacity: .35; }
.ref-dlg {
  width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 14px;
  background: #020405; border: none; color: var(--text);
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
}
.ref-dlg[open] { display: flex; }
.ref-dlg::backdrop { background: #020405; }
.ref-dlg canvas { width: min(calc(100vh - 90px), 96vw); height: auto; aspect-ratio: 1; border-radius: 8px; cursor: pointer; }
.ref-nav.big { width: min(calc(100vh - 90px), 96vw); margin: 0; }
.ref-nav.big span { font-size: 15px; }

/* full screen button for the whole simulator (top right) */
.app-full-btn { width: 40px; align-self: stretch; padding: 0; display: grid; place-items: center; }
.app-full-btn span { width: 14px; height: 14px; border: 2px solid #dce9f7; border-radius: 2px; display: block; }
.app-full-btn.on span { width: 10px; height: 10px; }
.app-full-btn:hover span { border-color: var(--accent); }
.resume-full { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 50; box-shadow: 0 6px 24px rgba(0,0,0,.5); }
.resume-full[hidden] { display: none; }
.dlg-field { display: grid; grid-template-columns: 90px 1fr; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.dlg-field select { width: 100%; }
.dlg-field[hidden] { display: none; }
#cathSel option.guide { font-weight: 700; }
#cathSel optgroup { font-style: normal; }

/* blood pressure falling after a perforation */
#vitals.alarm { color: #ffd9d3; border-color: var(--coral); background: #2f100c; }

/* look of kardiologi.se: bold headings, small blue capitals for section titles, 8 px corners */
.panel > h2 { color: var(--accent); }   /* small blue capitals like "NYHET · KARDIOLOGIKARTAN" */
.panel h3, .dlg h2, .dlg h3 { color: var(--head); font-weight: 750; }
.brand strong { font-weight: 750; color: var(--head); }
.panel { border-radius: 10px; }

/* defibrillator and pacemaker */
.btn.danger { background: #b3261e; border-color: #e0483e; color: #fff; font-weight: 700; white-space: nowrap; }
.btn.danger:hover { background: #cf2f26; }
.btn.danger.call { animation: defibCall .7s ease-in-out infinite alternate; }
@keyframes defibCall { from { box-shadow: 0 0 0 0 rgba(224, 72, 62, .0); } to { box-shadow: 0 0 0 6px rgba(224, 72, 62, .55); } }
#btnPacer { white-space: nowrap; }
body.shock::after { content: ""; position: fixed; inset: 0; background: #fff; pointer-events: none; z-index: 99; animation: shockFlash .35s ease-out forwards; }
@keyframes shockFlash { from { opacity: .85; } to { opacity: 0; } }

/* header: room for the vitals readout, defibrillator and pacemaker */
.vitals { flex: none; }
#vitals { flex: none; font-size: 12.5px; }
.top-controls { min-width: 0; }
.top-controls .btn { white-space: nowrap; }
.case-pick select { max-width: 230px; }
@media (max-width: 1560px) { .brand span:not(.copyright):not(.pulse) { display: none; } .top { gap: 10px; } }
@media (max-width: 1360px) { .vitals canvas { width: 130px; } .case-pick { font-size: 0; gap: 0; } .case-pick select { font-size: 13px; width: 170px; max-width: 170px; } }

/* enlarged anatomy guide: square, a little lower than the window, at most about two thirds of the width */
.guide-big {
  position: fixed; z-index: 40; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(calc(100vh - 60px), 66vw); aspect-ratio: 1;
  background: #08121c; border: 1px solid var(--accent); border-radius: 10px; box-shadow: 0 18px 60px rgba(0, 0, 0, .65);
}
.guide-big[hidden] { display: none; }
.guide-big canvas { width: 100%; height: 100%; display: block; border-radius: 10px; }
.guide-big .ref-full-btn { top: 10px; right: 10px; width: 30px; height: 30px; }
/* the enlarge button of the anatomy guide sits bottom right: the angle labels are at the top */
#guideFull { top: auto; bottom: 6px; }
.guide-big .ref-full-btn { top: auto; bottom: 10px; }

/* tool options: two columns, two rows */
.check-grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 10px; }
.check-grid .check { white-space: nowrap; }

/* controls shown only when something is chosen */
.ctl[hidden] { display: none; }
.ctl > .row:first-child, .ctl > h3:first-child { margin-top: 8px; }

/* enlarged ECG / pressure strip, about 4 times the small one */
.vitals canvas { cursor: zoom-in; }
.ecg-big { position: fixed; z-index: 45; width: min(820px, calc(100vw - 16px)); padding: 8px; cursor: zoom-out;
  background: #08121c; border: 1px solid var(--accent); border-radius: 10px; box-shadow: 0 16px 50px rgba(0, 0, 0, .6); }
.ecg-big[hidden] { display: none; }
.ecg-big canvas { width: 100%; height: auto; display: block; border-radius: 6px; }
.ecg-big-label { display: flex; gap: 16px; margin-top: 6px; font: 12px var(--mono); color: #c0d1e4; }
.ecg-big-label .g { color: #5ee6a8; } .ecg-big-label .r { color: #ff8f7a; }
.ecg-big-label span:last-child { margin-left: auto; }

/* "Go to AP" between the C-arm title and the angle readout */
.panel h2 .go-ap { padding: 2px 10px; font: 600 11.5px var(--sans); letter-spacing: 0; text-transform: none; }
/* title row of the C-arm panel: three columns, so the button stays in the middle whatever the angle readout says */
#carmTitle { display: grid; grid-template-columns: 1fr auto 1fr; }
#carmTitle #angleRead { justify-self: end; }

/* disclaimer: notice window, footer line, note in the score window */
.disc-dlg { width: min(620px, 94vw); }
.disc-dlg h2 { color: var(--head); }
.disclaimer-text p { margin: 0 0 10px; line-height: 1.5; color: #c7d6e6; font-size: 13.5px; }
.disclaimer-text p:last-child { color: var(--muted); font-size: 12px; }
#helpDlg .disclaimer-text p { font-size: 12.5px; }
.foot { flex: none; display: flex; align-items: center; gap: 12px; padding: 3px 14px 5px; font-size: 11.5px; color: var(--muted); }
.foot .foot-copy { margin-left: auto; opacity: .75; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link-btn:hover { color: #fff; }
.score-note { margin: 8px 0 0; }

/* QRS beep switch on the enlarged ECG strip */
.ecg-big { position: fixed; }
.ecg-big .beep-btn { position: absolute; top: 14px; right: 14px; cursor: pointer; padding: 3px 10px; }
.ecg-big .beep-btn.off { border-color: var(--accent); color: var(--accent); }

/* ---- demonstration film (js/demo.js) ---- */
.demo-block { position: fixed; left: 0; right: 0; bottom: 0; top: 0; z-index: 30; background: transparent; }
.demo-panel {
  position: fixed; z-index: 31; box-sizing: border-box; overflow-y: auto; padding: 12px 14px;
  background: #0c1c2e; border: 2px solid var(--amber); border-radius: 12px; box-shadow: 0 10px 34px rgba(0,0,0,.6);
  display: flex; flex-direction: column; gap: 9px;
}
.demo-block[hidden], .demo-panel[hidden] { display: none; }
.demo-head { display: flex; justify-content: space-between; align-items: center; font: 600 11px var(--mono); color: var(--muted); }
.demo-tag { background: var(--amber); color: var(--accent-ink); padding: 2px 8px; border-radius: 999px; letter-spacing: .04em; text-transform: uppercase; }
.demo-bar { height: 4px; background: #1c3148; border-radius: 2px; overflow: hidden; flex: none; }
.demo-bar i { display: block; height: 100%; background: var(--amber); transition: width .4s; }
.demo-title { margin: 2px 0 0; font-size: 17px; line-height: 1.25; color: #fff; }
.demo-text { margin: 0; font-size: 14px; line-height: 1.5; color: var(--text); }
.demo-keys { display: flex; align-items: center; gap: 8px; color: var(--amber); font: 700 18px var(--mono); }
.demo-keys kbd {
  margin: 0; font: 700 17px var(--mono); padding: 7px 12px; border-radius: 8px; background: var(--amber); color: var(--accent-ink);
  border: 1px solid #ffe2a6; animation: demoGlow .7s ease-in-out infinite alternate;
}
.demo-note { font-size: 12px; color: var(--muted); margin-top: auto; }
.demo-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.demo-glow { animation: demoGlow .7s ease-in-out infinite alternate; border-color: var(--amber) !important; }
@keyframes demoGlow {
  from { box-shadow: 0 0 0 2px rgba(255,200,97,.55), 0 0 6px 1px rgba(255,200,97,.35); }
  to { box-shadow: 0 0 0 3px rgba(255,200,97,1), 0 0 20px 6px rgba(255,200,97,.85); }
}

/* hint at the first opening of the page: points to the Case menu (js/demo.js) */
.tutor-hint {
  position: fixed; z-index: 35; display: flex; align-items: center; gap: 8px; cursor: pointer;
  font: 700 15px var(--sans); color: var(--accent-ink); background: var(--amber); border: 1px solid #ffe2a6;
  padding: 8px 16px 8px 12px; border-radius: 999px; animation: demoGlow .7s ease-in-out infinite alternate;
}
.tutor-hint .tutor-arrow { font-size: 24px; line-height: 1; animation: tutorBob .7s ease-in-out infinite alternate; }
@keyframes tutorBob { from { transform: translateY(2px); } to { transform: translateY(-5px); } }
/* version number next to the name at the top left */
.brand strong .ver { font: 500 10.5px var(--mono); color: var(--muted); margin-left: 6px; letter-spacing: 0; }
