/* Monitorbild im Browser - Farben und Maße wie im Windows-Programm. */

:root {
    --bg: #06080a;
    --chrome: #0c0f12;
    --head: #12161a;
    --line: #1d2328;
    --text: #e8ecef;
    --dim: #8a97a2;
    --trace: #40ff78;
    --spo2: #5adcff;
    --co2: #ffe15a;
    --warn: #ffaa3c;
    --alarm: #ff5a5a;
    --tap: 46px;   /* kleinste Fläche, die ein Finger sicher trifft */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    /* Kein Gummiband-Scrollen und keine Textauswahl: Das soll sich wie ein
       Gerät anfühlen, nicht wie eine Webseite. */
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

#app { height: 100%; }

.boot {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.boot-title { font-size: 22px; font-weight: 600; letter-spacing: .02em; }
.boot-note { color: var(--dim); font-size: 13px; }

/* ---------------------------------------------------------------- Rahmen */

.app {
    height: 100%;
    display: grid;
    grid-template-rows: auto 1fr auto;
    /* Unter die abgerundeten Ecken und den Home-Balken des iPads. */
    padding: env(safe-area-inset-top) env(safe-area-inset-right)
             env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.topbar {
    height: 36px;
    background: var(--head);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    gap: 12px;
}
.topbar .title { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .dim { color: var(--dim); }
.topbar .warn { color: var(--warn); font-size: 12px; white-space: nowrap; }

.body { display: grid; grid-template-columns: 1fr 250px; min-height: 0; }

/* ------------------------------------------------------------ Kurvenfeld */

.wave { position: relative; background: var(--bg); overflow: hidden; }
.wave canvas { display: block; }

.overlay { position: absolute; inset: 0; pointer-events: none; }

.lead-label {
    position: absolute;
    left: 8px;
    margin-top: 4px;
    color: #78ffa0;
    font-size: 14px;
    font-weight: 700;
}

.cal {
    position: absolute;
    left: 2px;
    width: 22px;
    overflow: visible;
}
.cal polyline { fill: none; stroke: rgba(90, 130, 105, .6); stroke-width: 1; }

.footer {
    position: absolute;
    left: 10px;
    bottom: 6px;
    color: #6e7d87;
    font-size: 12px;
}

.frozen {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    color: #ffbe46;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: .04em;
}

/* ------------------------------------------------------------ Vitalwerte */

.vitals { background: var(--chrome); padding: 4px 0; overflow: hidden; }
.vital { padding: 6px 12px 2px; }
.vhead { display: flex; justify-content: space-between; align-items: baseline; }
.vlabel { font-size: 12px; font-weight: 600; color: var(--text); }
.vlabel.hr { color: var(--trace); }
.vlabel.spo2 { color: var(--spo2); }
.vlabel.co2 { color: var(--co2); }
.vunit { font-size: 12px; color: #78828c; }

.vvalue {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 44px;
    font-weight: 700;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
}
.vvalue.small { font-size: 30px; }
.vvalue.hr { color: var(--trace); }
.vvalue.hr.alarm { color: var(--alarm); }
.vvalue.spo2 { color: var(--spo2); }
.vvalue.co2 { color: var(--co2); }

/* -------------------------------------------------------------- Werkzeug */

.toolbar {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    background: var(--head);
    border-top: 1px solid var(--line);
}
.tb {
    flex: 1;
    min-height: var(--tap);
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #171c21;
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
}
.tb:active { background: #222a31; }
.tb.on { background: #1f3a2a; border-color: #2f6b47; color: #9bffc0; }
.tb[disabled] { opacity: .5; }

/* -------------------------------------------------------------- Klappe */

.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); }

.panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(420px, 92vw);
    background: var(--chrome);
    border-left: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    font-size: 16px;
    font-weight: 600;
}
.panel-head .x {
    width: var(--tap);
    height: var(--tap);
    border: 0;
    background: none;
    color: var(--dim);
    font-size: 28px;
    line-height: 1;
}
.panel-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 14px 24px;
}

.panel h3 {
    font-size: 11px;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--dim);
    font-weight: 600;
    margin: 18px 0 7px;
}
.panel .note { font-size: 12px; color: var(--warn); margin: 6px 0 0; line-height: 1.4; }

.sel {
    width: 100%;
    min-height: var(--tap);
    background: #171c21;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0 10px;
    font-size: 15px;
    font-family: inherit;
}

.rng { width: 100%; height: var(--tap); accent-color: var(--trace); }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
    flex: 1 1 0;
    min-width: 72px;
    min-height: var(--tap);
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #171c21;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    padding: 4px 6px;
}
.seg button em { font-style: normal; font-size: 11px; color: var(--dim); }
.seg button.on { background: #1f3a2a; border-color: #2f6b47; color: #9bffc0; }
.seg button.on em { color: #6fcf96; }

.sw {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: var(--tap);
    font-size: 14px;
    line-height: 1.3;
}
.sw input { width: 24px; height: 24px; flex: none; accent-color: var(--trace); }

/* ---------------------------------------------------------- Hochformat */

@media (orientation: portrait) {
    /* Hochkant ist für ein Monitorbild zu schmal: Die Vitalwerte wandern
       unter die Kurve, statt sie auf die halbe Breite zu drücken. */
    .body { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
    .vitals { display: flex; justify-content: space-between; padding: 2px 4px; }
    .vital { padding: 4px 8px; }
    .vvalue { font-size: 30px; }
    .vvalue.small { font-size: 22px; }
    .topbar .warn { display: none; }
}

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #7a1d1d;
    color: #fff;
    padding: 10px 14px;
    font-size: 14px;
    z-index: 100;
}
#blazor-error-ui a { color: #fff; margin-left: 10px; text-decoration: underline; }
