/* ——— Dinamap (moniteur PNI / SpO₂) ———
 * La page occupe tout l'écran : un mince bandeau (retour, code, plein écran), puis
 * l'appareil, qui remplit toute la place restante, en paysage comme en portrait.
 * Ses dimensions suivent l'unité --u, tirée de la place disponible (unités de
 * conteneur) ; chaque case de l'écran est elle-même un conteneur : ses chiffres
 * lumineux prennent la plus grande taille qui y tient.
 */

/* Unité de l'appareil, calculée une fois sur .device puis héritée en pixels. */
@property --u {
  syntax: '<length>';
  inherits: true;
  initial-value: 6px;
}

body.dina-body {
  background: var(--night-deep);
}
.dina-body :focus-visible {
  outline-color: var(--blue-soft);
}

.dina {
  /* Couleurs des afficheurs : celles du Scope (PNI bleu, pouls turquoise, SpO₂ ambre). */
  --led-pni: #c9ceff;
  --led-pni-glow: rgba(120, 136, 255, 0.8);
  --led-pni-ghost: rgba(182, 189, 255, 0.075);
  --led-pulse: #62ecec;
  --led-pulse-glow: rgba(51, 211, 212, 0.75);
  --led-pulse-ghost: rgba(51, 211, 212, 0.075);
  --led-sp: #ffca66;
  --led-sp-glow: rgba(253, 179, 62, 0.75);
  --led-sp-ghost: rgba(253, 179, 62, 0.085);
  --led-text: #e3eaf4;
  --led-text-glow: rgba(199, 213, 224, 0.5);
  --led-text-ghost: rgba(199, 213, 224, 0.07);

  height: 100vh;
  height: 100dvh;
  min-height: 460px;
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.2vh, 12px);
  padding: clamp(6px, 1.4vh, 14px) clamp(8px, 1.6vw, 18px);
  padding-top: max(clamp(6px, 1.4vh, 14px), env(safe-area-inset-top));
  padding-right: max(clamp(8px, 1.6vw, 18px), env(safe-area-inset-right));
  padding-bottom: max(clamp(6px, 1.4vh, 14px), env(safe-area-inset-bottom));
  padding-left: max(clamp(8px, 1.6vw, 18px), env(safe-area-inset-left));
  background: radial-gradient(120% 90% at 50% 45%, #10295f 0%, var(--night-deep) 72%);
  color: var(--night-text);
}

/* ——— Bandeau ——— */
.dina-top {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
}
.dina-top__start {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.dina-back {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--night-fill);
  color: var(--night-muted);
}
.dina-body .dina-back:hover {
  color: var(--surface);
}
.dina-name {
  view-transition-name: dinamap-title;
  margin: 0;
  font-size: 21px;
  font-weight: 500;
  color: var(--mist);
}
.dina-code {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 4px 18px;
  border-radius: 999px;
  background: var(--night-fill);
}
.dina-code__label {
  font-size: 15px;
  color: var(--night-muted);
}
.dina-code__value {
  font-size: 21px;
  font-weight: 500;
  letter-spacing: 0.22em;
  font-variant-numeric: tabular-nums;
  color: var(--night-text);
}
.dina-link {
  font-size: 15px;
  font-weight: 500;
  color: var(--amber);
}
.dina-link:empty {
  display: none;
}
.dina-icon-btn {
  width: 44px;
  height: 44px;
  flex: none;
  border: 1px solid rgba(199, 213, 224, 0.2);
  border-radius: 50%;
  background: rgba(199, 213, 224, 0.1);
  color: var(--night-text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}
.dina-icon-btn:hover {
  background: rgba(199, 213, 224, 0.18);
}

/* ——— L'appareil ——— */
.dina-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  container-type: size;
}

.device {
  /* Paysage : appareil de référence de 150 × 96 unités. */
  --u: min(100cqw / 150, 100cqh / 96);
  --key: max(44px, calc(var(--u) * 9));
  --depth: max(3px, calc(var(--u) * 0.55));
  --wing: max(104px, calc(var(--u) * 17.5));
  --base: max(60px, calc(var(--u) * 13));
  --pad-x: max(12px, calc(var(--u) * 2.2));
  --gap: max(8px, calc(var(--u) * 1.8));

  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-columns: var(--wing) minmax(0, 1fr) var(--wing);
  grid-template-rows: minmax(0, 1fr) var(--base);
  grid-template-areas:
    'left screen right'
    'base base base';
  gap: var(--gap);
  padding: max(16px, calc(var(--u) * 3.4)) var(--pad-x) 0;
  border-radius: max(26px, calc(var(--u) * 5));
  overflow: hidden;
  /* Coque en plastique moulé, blanc des surfaces Skopéo. */
  background: linear-gradient(180deg, #ffffff 0%, #f3f6f9 34%, #e4eaf1 80%, #d6dee8 100%);
  box-shadow:
    inset 0 2px 1px #ffffff,
    inset 0 -3px 8px rgba(50, 57, 78, 0.14),
    inset 14px 0 24px rgba(255, 255, 255, 0.55),
    inset -14px 0 24px rgba(50, 57, 78, 0.07),
    0 24px 60px rgba(0, 0, 0, 0.55),
    0 6px 16px rgba(0, 0, 0, 0.35);
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Voyant d'alarme sur la tranche supérieure. */
.device__lightbar {
  position: absolute;
  top: max(5px, calc(var(--u) * 1.1));
  left: 50%;
  width: clamp(120px, 26%, 420px);
  height: max(7px, calc(var(--u) * 1.2));
  transform: translateX(-50%);
  border-radius: 999px;
  background: linear-gradient(180deg, #e3e9f0, #f8fafc);
  box-shadow:
    inset 0 1px 2px rgba(50, 57, 78, 0.32),
    0 1px 0 #ffffff;
  transition:
    background 0.2s ease,
    box-shadow 0.2s ease;
}
.device__lightbar[data-level='warning'],
.device__lightbar[data-level='test'] {
  background: linear-gradient(180deg, #ffe0a6, var(--amber));
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.6),
    0 0 max(10px, calc(var(--u) * 2.4)) rgba(253, 179, 62, 0.9);
}
.device__lightbar[data-level='warning'] {
  animation: dina-lightbar 1.4s ease-in-out infinite;
}
@keyframes dina-lightbar {
  50% {
    filter: brightness(0.6) saturate(0.7);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.4);
  }
}

/* ——— Panneaux de touches ——— */
.wing {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  gap: max(6px, calc(var(--u) * 1.2));
  padding: max(8px, calc(var(--u) * 1.4)) 0;
  border-radius: max(20px, calc(var(--u) * 3.6));
  background: linear-gradient(180deg, #e8edf3, #f4f7fa);
  box-shadow:
    inset 0 2px 4px rgba(50, 57, 78, 0.16),
    inset 0 -1px 0 #ffffff;
}
.wing--left {
  grid-area: left;
}
.wing--right {
  grid-area: right;
}
.key-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: max(5px, calc(var(--u) * 0.8));
}
.key-label {
  display: flex;
  align-items: center;
  gap: max(5px, calc(var(--u) * 0.6));
  font-size: max(11px, calc(var(--u) * 1.9));
  line-height: 1.1;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

/* Voyants des touches */
.key-led {
  --led: var(--blue);
  width: max(8px, calc(var(--u) * 1.05));
  height: max(8px, calc(var(--u) * 1.05));
  flex: none;
  border-radius: 50%;
  background: #c5ced9;
  box-shadow:
    inset 0 1px 1.5px rgba(50, 57, 78, 0.45),
    0 1px 0 #ffffff;
  transition:
    background 0.15s ease,
    box-shadow 0.15s ease;
}
.key-led--amber {
  --led: var(--amber);
}
.key-led--teal {
  --led: var(--teal-deep);
}
.key-led[data-on] {
  background: radial-gradient(circle at 35% 30%, #ffffff 0 14%, var(--led) 48%);
  box-shadow:
    0 0 max(6px, calc(var(--u) * 1.4)) var(--led),
    0 0 2px var(--led);
}

/* Touches en relief : une tranche sous le capuchon, qui s'enfonce à l'appui. */
.key {
  --cap-top: #ffffff;
  --cap-bottom: #dde4ec;
  --cap-edge: #b4bfcc;
  --cap-ink: var(--ink);
  width: var(--key);
  height: var(--key);
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--cap-top), var(--cap-bottom));
  color: var(--cap-ink);
  box-shadow:
    0 var(--depth) 0 var(--cap-edge),
    0 calc(var(--depth) + 4px) calc(var(--depth) * 3) rgba(20, 30, 60, 0.3),
    inset 0 2px 1px rgba(255, 255, 255, 0.75),
    inset 0 -2px 3px rgba(0, 0, 0, 0.1);
  transition:
    transform 0.08s ease,
    box-shadow 0.08s ease,
    filter 0.15s ease;
}
.key svg {
  width: 44%;
  height: 44%;
}
.key:hover {
  filter: brightness(1.04);
}
.key:active {
  transform: translateY(var(--depth));
  box-shadow:
    0 0 0 var(--cap-edge),
    0 2px 4px rgba(20, 30, 60, 0.3),
    inset 0 2px 4px rgba(0, 0, 0, 0.2);
}
.key--pill {
  width: calc(var(--key) * 1.55);
  border-radius: 999px;
}
.key--pill svg {
  width: 34%;
}
.key--blue {
  --cap-top: #7e8cff;
  --cap-bottom: var(--blue);
  --cap-edge: #2d3cc0;
  --cap-ink: #ffffff;
}
.key--amber {
  --cap-top: #ffd892;
  --cap-bottom: var(--amber);
  --cap-edge: #c4841c;
  --cap-ink: var(--night-deep);
}
.key--coral {
  --cap-top: #ff9d88;
  --cap-bottom: var(--coral);
  --cap-edge: #c3432b;
  --cap-ink: #ffffff;
}
.key--ink {
  --cap-top: #535c79;
  --cap-bottom: var(--ink);
  --cap-edge: #1a1e2c;
  --cap-ink: var(--mist);
}

/* Bascule + / − */
.rocker {
  width: var(--key);
  height: calc(var(--key) * 1.7);
  display: flex;
  flex-direction: column;
  border-radius: 999px;
  overflow: hidden;
  background: linear-gradient(180deg, #ffffff, #dde4ec);
  box-shadow:
    0 var(--depth) 0 #b4bfcc,
    0 calc(var(--depth) + 4px) calc(var(--depth) * 3) rgba(20, 30, 60, 0.3),
    inset 0 2px 1px rgba(255, 255, 255, 0.75);
}
.rocker__half {
  flex: 1 1 0;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-user-select: none;
  user-select: none;
  transition: background 0.08s ease;
}
.rocker__half + .rocker__half {
  border-top: 1px solid rgba(50, 57, 78, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
.rocker__half svg {
  width: 42%;
  height: 42%;
}
.rocker__half:active {
  background: rgba(50, 57, 78, 0.12);
  box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.16);
}

/* ——— Écran ——— */
.screen {
  grid-area: screen;
  min-width: 0;
  min-height: 0;
  container-type: size;
  padding: max(6px, calc(var(--u) * 1.2));
  border-radius: max(20px, calc(var(--u) * 3.6));
  background: linear-gradient(180deg, #2b3350 0%, #171c2c 100%);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.6),
    inset 0 -1px 1px rgba(255, 255, 255, 0.12),
    0 2px 0 #ffffff,
    0 -1px 0 rgba(50, 57, 78, 0.25);
}
.glass {
  position: relative;
  height: 100%;
  border-radius: max(14px, calc(var(--u) * 2.6));
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr) minmax(0, 1.12fr);
  grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    'status status status'
    'sys map pulse'
    'dia hist spo2';
  gap: 1.6cqh 1.4cqw;
  padding: 1.8cqh 1.8cqw 2.2cqh;
  font-size: clamp(11px, min(3.2cqh, 1.75cqw), 22px);
  background: radial-gradient(130% 100% at 30% 0%, #0f2758 0%, #08173a 48%, #040b22 100%);
  box-shadow: inset 0 0 3em rgba(0, 0, 0, 0.75);
  transition: filter 0.3s ease;
}
/* Reflet de la vitre fumée. */
.glass::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(
    125deg,
    rgba(255, 255, 255, 0.075) 0%,
    rgba(255, 255, 255, 0.025) 32%,
    rgba(255, 255, 255, 0) 36%,
    rgba(255, 255, 255, 0) 72%,
    rgba(255, 255, 255, 0.035) 100%
  );
}

/* Ligne d'état */
.status {
  grid-area: status;
  min-width: 0;
  min-height: 2em;
  display: flex;
  align-items: center;
  gap: 0.9em;
  padding: 0 0.3em 0.5em;
  border-bottom: 1px solid rgba(199, 213, 224, 0.1);
  color: var(--led-text);
  font-size: 0.85em;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 0 0.6em var(--led-text-glow);
  white-space: nowrap;
}
.status__chip {
  padding: 0.2em 0.6em;
  border: 1px solid rgba(199, 213, 224, 0.35);
  border-radius: 0.4em;
}
.status__mode {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--led-pni);
  text-shadow: 0 0 0.6em var(--led-pni-glow);
}
.status__fill {
  flex: 1 1 0;
}
.status__alarm {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.28em 0.85em;
  border-radius: 999px;
  background: var(--amber);
  color: var(--night-deep);
  text-shadow: none;
  font-weight: 700;
  animation: dina-blink 1s steps(1) infinite;
}
.status__alarm svg {
  width: 1.25em;
  height: 1.25em;
}
.status__battery {
  display: flex;
  align-items: center;
  gap: 0.55em;
  color: var(--led-pulse);
  text-shadow: 0 0 0.6em var(--led-pulse-glow);
}
.battery {
  position: relative;
  width: 1.7em;
  height: 0.95em;
  padding: 0.1em;
  border: 0.14em solid currentColor;
  border-radius: 0.2em;
}
.battery::after {
  content: '';
  position: absolute;
  right: -0.34em;
  top: 0.18em;
  bottom: 0.18em;
  width: 0.16em;
  border-radius: 0 0.1em 0.1em 0;
  background: currentColor;
}
.battery__level {
  display: block;
  width: 80%;
  height: 100%;
  border-radius: 0.06em;
  background: currentColor;
}
.status__clock {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}
@keyframes dina-blink {
  0%,
  55% {
    opacity: 1;
  }
  56%,
  100% {
    opacity: 0.35;
  }
}

/* Cases de valeurs */
.field {
  --lit: var(--led-text);
  --glow: var(--led-text-glow);
  --ghost: var(--led-text-ghost);
  /* Largeur de l'afficheur rapportée à sa hauteur, et taille relative de la case. */
  --digits-ratio: 2.06;
  --digits-scale: 1;
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.45em 0.7em 0.55em;
  border-radius: 0.7em;
  background: rgba(199, 213, 224, 0.025);
  container-type: size;
  transition:
    background 0.2s ease,
    box-shadow 0.2s ease;
}
.field--pni {
  --lit: var(--led-pni);
  --glow: var(--led-pni-glow);
  --ghost: var(--led-pni-ghost);
}
.field--pulse {
  --lit: var(--led-pulse);
  --glow: var(--led-pulse-glow);
  --ghost: var(--led-pulse-ghost);
}
.field--spo2 {
  --lit: var(--led-sp);
  --glow: var(--led-sp-glow);
  --ghost: var(--led-sp-ghost);
  --digits-ratio: 2.45;
}
.field--sys {
  grid-area: sys;
}
.field--dia {
  grid-area: dia;
}
.field--map {
  grid-area: map;
}
.field--hist {
  grid-area: hist;
  --digits-scale: 0.62;
}
.field--pulse {
  grid-area: pulse;
}
.field--spo2 {
  grid-area: spo2;
}

.field__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6em;
  line-height: 1.15;
  white-space: nowrap;
}
.field__name {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.4em;
  overflow: hidden;
  font-weight: 600;
  color: var(--lit);
  opacity: 0.92;
}
.field__alt {
  font-weight: 500;
  opacity: 0.5;
  transition: opacity 0.2s ease;
}
.field[data-cuff] .field__alt {
  opacity: 1;
  text-shadow: 0 0 0.6em var(--glow);
}
.field__unit {
  font-size: 0.9em;
  font-weight: 500;
  color: var(--night-muted);
}
.field__body {
  /* Hauteur des chiffres : la plus grande qui tient dans la case. */
  --h: calc(min(100cqh - 2.6em, (100cqw - 1.6em) / var(--digits-ratio)) * var(--digits-scale));
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.field__foot {
  position: absolute;
  left: 0.7em;
  bottom: 0.55em;
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--night-muted);
}
.field[data-stale] .seg {
  opacity: 0.3;
}

/* Battement du pouls */
.beat {
  width: 0.95em;
  height: 0.95em;
  fill: var(--ghost);
  transition: fill 0.06s ease;
}
.beat[data-on] {
  fill: var(--lit);
  filter: drop-shadow(0 0 0.3em var(--glow));
}

/* Afficheurs 7 segments */
.seg {
  height: var(--h);
  display: flex;
  gap: calc(var(--h) * 0.07);
  transition: opacity 0.2s ease;
}
.seg__digit {
  height: 100%;
  width: auto;
  aspect-ratio: 42 / 70;
  overflow: visible;
  transform: skewX(-5deg);
  filter: drop-shadow(0 0 calc(var(--h) * 0.045) var(--glow));
}
.seg__digit polygon {
  fill: var(--ghost);
}
.seg__digit polygon.on {
  fill: var(--lit);
}

/* Bargraphe de pouls (onde de pléthysmographie) */
.bar {
  height: var(--h);
  width: calc(var(--h) * 0.2);
  margin-left: calc(var(--h) * 0.14);
  padding: calc(var(--h) * 0.025);
  display: flex;
  flex-direction: column-reverse;
  gap: calc(var(--h) * 0.02);
  border-radius: calc(var(--h) * 0.04);
  background: rgba(0, 0, 0, 0.35);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
}
.bar__seg {
  flex: 1 1 0;
  border-radius: 1px;
  background: var(--ghost);
}
.bar__seg.on {
  background: var(--lit);
  box-shadow: 0 0 calc(var(--h) * 0.05) var(--glow);
}

/* Alarme sur une case : cadre ambre et chiffres clignotants. */
.field[data-alarm] {
  background: rgba(253, 179, 62, 0.1);
  box-shadow: inset 0 0 0 2px rgba(253, 179, 62, 0.85);
}
.field[data-alarm] .seg__digit polygon.on {
  animation: dina-blink 1s steps(1) infinite;
}

/* Menu des réglages, affiché à la place des cases. */
.menu {
  grid-area: 2 / 1 / -1 / -1;
  z-index: 2;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.8em;
  padding: 1em 1.4em 1.1em;
  border-radius: 0.7em;
  background: linear-gradient(180deg, #0a1d47 0%, #050f2a 100%);
  box-shadow: inset 0 0 0 1px rgba(182, 189, 255, 0.2);
  container-type: size;
  --lit: var(--led-pni);
  --glow: var(--led-pni-glow);
  --ghost: var(--led-pni-ghost);
}
.menu__top {
  display: flex;
  justify-content: space-between;
  font-size: 0.85em;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--night-muted);
}
.menu__label {
  font-size: 1.45em;
  font-weight: 600;
  color: var(--led-text);
  text-shadow: 0 0 0.6em var(--led-text-glow);
}
.menu__value {
  --h: min(100cqh - 8.5em, (100cqw - 8em) / 2.06);
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8em;
}
.menu__unit {
  align-self: flex-end;
  margin-bottom: 1.2em;
  font-size: 1.3em;
  font-weight: 500;
  color: var(--night-muted);
}
.menu__hint {
  text-align: center;
  font-size: 0.85em;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--night-muted);
}

/* Appareil éteint : écran noir, seules les sérigraphies restent visibles. */
.device[data-power='off'] .glass {
  filter: brightness(0.7);
}
.device[data-power='off'] .status,
.device[data-power='off'] .field__foot {
  visibility: hidden;
}
.device[data-power='off'] .field__name,
.device[data-power='off'] .field__unit {
  opacity: 0.22;
  text-shadow: none;
}
.device[data-power='off'] .seg__digit,
.device[data-power='off'] .beat {
  filter: none;
}
.device[data-power='off'] .seg__digit polygon,
.device[data-power='off'] .bar__seg,
.device[data-power='off'] .beat {
  fill: rgba(199, 213, 224, 0.035);
  background: rgba(199, 213, 224, 0.035);
  box-shadow: none;
}

/* ——— Socle bleu : marque, prises ——— */
.base {
  grid-area: base;
  min-width: 0;
  margin: 0 calc(var(--pad-x) * -1);
  padding: 0 max(18px, calc(var(--u) * 4));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: max(12px, calc(var(--u) * 2));
  background: linear-gradient(180deg, #6576ff 0%, var(--blue) 38%, #3a4ce6 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.35),
    inset 0 -4px 10px rgba(0, 0, 0, 0.18);
  color: #ffffff;
}
.brand,
.model {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: max(3px, calc(var(--u) * 0.5));
}
.brand {
  justify-self: start;
}
.model {
  justify-self: end;
  align-items: flex-end;
}
.brand__logo {
  font-family: var(--font-display);
  font-size: max(20px, calc(var(--u) * 3.6));
  line-height: 0.9;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.model__name {
  font-size: max(19px, calc(var(--u) * 3.3));
  line-height: 0.9;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.brand__sub,
.model__sub {
  font-size: max(10px, calc(var(--u) * 1.35));
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.78);
}

.ports {
  display: flex;
  align-items: center;
  gap: max(10px, calc(var(--u) * 2.6));
  padding: max(4px, calc(var(--u) * 0.8)) max(12px, calc(var(--u) * 2.4));
  border-radius: 999px;
  background: linear-gradient(180deg, #2f3fbf, #3a4bd6);
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.35),
    0 1px 0 rgba(255, 255, 255, 0.3);
}
.port {
  --collar: #eef2f7;
  min-height: 44px;
  padding: 2px 6px 2px 2px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: max(8px, calc(var(--u) * 1.1));
  font-size: max(12px, calc(var(--u) * 1.7));
  font-weight: 700;
  letter-spacing: 0.03em;
}
.port:hover .port__socket {
  filter: brightness(1.08);
}
.port--spo2 {
  --collar: var(--amber);
}
.port--pni {
  --collar: var(--blue-soft);
}
.port__socket {
  position: relative;
  width: max(36px, calc(var(--u) * 5.8));
  height: max(36px, calc(var(--u) * 5.8));
  flex: none;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    #0d111b 0 26%,
    #5a637b 27% 33%,
    #e9eef4 34% 52%,
    var(--collar) 53% 100%
  );
  box-shadow:
    inset 0 -2px 3px rgba(0, 0, 0, 0.35),
    0 2px 4px rgba(0, 0, 0, 0.35);
}
/* Fiche branchée et son câble, qui sort par le bas de l'appareil. */
.port__plug,
.port__cable {
  position: absolute;
  opacity: 0;
  transition:
    opacity 0.2s ease,
    transform 0.3s var(--ease-back);
}
.port__plug {
  inset: 12%;
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle, rgba(0, 0, 0, 0.12) 0 1px, transparent 1px 4px),
    radial-gradient(circle at 40% 35%, #f6f8fb, #aab4c2 68%, #7b8698);
  box-shadow:
    0 3px 6px rgba(0, 0, 0, 0.45),
    inset 0 -2px 3px rgba(0, 0, 0, 0.25);
  transform: scale(0.5);
}
.port__cable {
  left: 50%;
  top: 50%;
  width: 26%;
  height: 300%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6f7a8d, #cfd6e0 45%, #6a7487);
  transform: translateX(-50%) translateY(-20%);
}
.port--pni .port__cable {
  width: 34%;
  background: linear-gradient(90deg, #8792a6, #e4e9f0 45%, #7f8a9d);
}
.port[aria-pressed='true'] .port__plug,
.port--pni .port__plug {
  opacity: 1;
  transform: none;
}
.port[aria-pressed='true'] .port__cable,
.port--pni .port__cable {
  opacity: 1;
  transform: translateX(-50%);
}
.port--pni[data-pumping] .port__plug {
  animation: dina-pump 0.8s ease-in-out infinite;
}
@keyframes dina-pump {
  50% {
    transform: scale(1.07);
  }
}

/* ——— Tablette debout (portrait) : écran en haut, touches dessous ——— */
@media (orientation: portrait) {
  .device {
    --u: min(100cqw / 100, 100cqh / 150);
    --key: max(46px, calc(var(--u) * 8.4));
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto var(--base);
    grid-template-areas:
      'screen screen'
      'left right'
      'base base';
  }
  .wing {
    flex-direction: row;
    align-items: flex-end;
    padding: max(10px, calc(var(--u) * 1.8)) max(6px, calc(var(--u) * 1));
  }
  .rocker {
    flex-direction: row-reverse;
    width: calc(var(--key) * 1.7);
    height: var(--key);
  }
  .rocker__half + .rocker__half {
    border-top: 0;
    border-right: 1px solid rgba(50, 57, 78, 0.18);
    box-shadow: none;
  }
  .glass {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    grid-template-rows: auto repeat(3, minmax(0, 1fr));
    grid-template-areas:
      'status status'
      'sys map'
      'dia hist'
      'pulse spo2';
    font-size: clamp(11px, min(2.4cqh, 2.6cqw), 22px);
  }
}

/* Téléphone : les deux rangées de touches l'une sous l'autre. */
@media (orientation: portrait) and (max-width: 640px) {
  .device {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(300px, 1fr) auto auto var(--base);
    grid-template-areas:
      'screen'
      'left'
      'right'
      'base';
  }
  .dina {
    height: auto;
    min-height: 100dvh;
  }
  .dina-stage {
    container-type: inline-size;
    min-height: 760px;
  }
  .device {
    --u: calc(100cqw / 100);
  }
  .base {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .model {
    display: none;
  }
}

/* Bandeau plus compact quand la place manque. */
@media (max-width: 1099px) {
  .dina-name {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    view-transition-name: none;
  }
  .dina-code__label {
    display: none;
  }
  .dina-code {
    padding: 4px 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .status__alarm,
  .device__lightbar[data-level='warning'],
  .field[data-alarm] .seg__digit polygon.on,
  .port--pni[data-pumping] .port__plug {
    animation: none;
  }
  .key,
  .port__plug,
  .port__cable {
    transition: none;
  }
}
