/* ——— Scope (écran patient) ——— */
body.scope-body {
  background: var(--night-deep);
}
.scope-body a {
  color: var(--blue-soft);
}
.scope-body a:hover {
  color: var(--surface);
}
.scope-body :focus-visible {
  outline-color: var(--blue-soft);
}

/*
 * Mise en page « moniteur » : la page occupe exactement la hauteur de l'écran
 * (tablette en paysage ou en portrait), l'ECG et la pléthysmographie se partagent
 * la place restante. Chaque voie est un conteneur CSS (container-type: size) :
 * ses grandes valeurs se dimensionnent d'après la place réelle de la voie.
 * Sur un écran trop petit (téléphone), les voies gardent une hauteur minimale
 * et la page défile.
 */
.scope {
  min-height: 100vh;
  min-height: 100dvh;
  padding: clamp(8px, 2.2vh, 18px) clamp(10px, 2.4vw, 24px) clamp(10px, 2.6vh, 24px);
  padding-top: max(clamp(8px, 2.2vh, 18px), env(safe-area-inset-top));
  padding-right: max(clamp(10px, 2.4vw, 24px), env(safe-area-inset-right));
  padding-bottom: max(clamp(10px, 2.6vh, 24px), env(safe-area-inset-bottom));
  padding-left: max(clamp(10px, 2.4vw, 24px), env(safe-area-inset-left));
  background: var(--night-deep);
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.8vh, 16px);
  color: var(--night-text);

  /* Largeur du bloc des valeurs (commune aux deux voies pour qu'elles s'alignent)
     et tailles maximales des grandes valeurs. La largeur ne dépend pas de la valeur
     affichée : basculer un capteur sur Off ou passer de 2 à 3 chiffres ne déplace
     jamais la courbe. */
  --readout-w: clamp(250px, 34vw, 440px);
  --fc-max: 150px;
  --sp-max: 124px;
  /* Place réservée autour de la valeur dans le bloc (rangée du haut, marges). */
  --readout-chrome-h: 78px;
  --readout-chrome-w: 130px;
}

/* Bandeau supérieur */
.scope-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  min-height: 44px;
}
.scope-top__start {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}
.back-btn--dark {
  width: 44px;
  height: 44px;
  background: var(--night-fill);
  box-shadow: none;
  color: var(--night-muted);
}
.scope-body .back-btn--dark:hover {
  color: var(--surface);
}
.scope-name {
  view-transition-name: scope-title;
  margin: 0;
  font-size: 21px;
  font-weight: 500;
  color: var(--mist);
}
.pill--dark {
  min-height: 44px;
  padding: 4px 18px;
  gap: 10px;
  background: var(--night-fill);
  box-shadow: none;
}
.pill--dark .pill__label {
  font-size: 15px;
  color: var(--night-muted);
}
.pill--dark .pill__code {
  font-size: 21px;
  color: var(--night-text);
}
.link-state {
  font-size: 15px;
  font-weight: 500;
  color: var(--amber);
}
.link-state:empty {
  display: none;
}

.alarm {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  border-radius: 999px;
  background: var(--amber);
  color: var(--night-deep);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.02em;
  animation: blink 1s steps(1) infinite;
}
.alarm[data-level='critical'] {
  background: var(--coral);
}
@keyframes blink {
  0%,
  55% {
    opacity: 1;
  }
  56%,
  100% {
    opacity: 0.35;
  }
}
.clock {
  font-size: 21px;
  font-weight: 400;
  color: var(--mist);
  font-variant-numeric: tabular-nums;
}

/* Voies ECG et SpO₂ */
.channel {
  display: flex;
  background: var(--night);
  border-radius: var(--radius-tile);
  overflow: clip;
  container-type: size;
}
.channel--ecg {
  flex: 55 1 0;
  min-height: 140px;
}
.channel--pleth {
  flex: 45 1 0;
  min-height: 120px;
}
.channel[data-alarm='warning'],
.channel--pni[data-alarm='warning'] {
  box-shadow: inset 0 0 0 3px var(--amber);
}
.channel[data-alarm='critical'] {
  box-shadow: inset 0 0 0 3px var(--coral);
}

.wave {
  /* Hauteurs de la zone de légende et de la marge basse, selon la hauteur de la voie. */
  --wave-top: clamp(32px, 22cqh, 52px);
  --wave-bottom: clamp(8px, 7cqh, 20px);
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
  container-type: size;
}
.wave__label {
  position: absolute;
  top: clamp(8px, 7cqh, 20px);
  left: clamp(18px, 3cqw, 28px);
  z-index: 1;
  display: flex;
  gap: 16px;
  align-items: baseline;
  font-size: 17px;
}
.wave__lead {
  font-weight: 500;
}
.wave__rhythm {
  font-weight: 400;
}
.channel--ecg .wave__label {
  color: var(--teal);
}
.channel--pleth .wave__label {
  color: var(--amber);
}
.wave canvas {
  position: absolute;
  left: 0;
  top: var(--wave-top);
  width: 100%;
  height: calc(100% - var(--wave-top) - var(--wave-bottom));
}
.wave__flat {
  position: absolute;
  left: 28px;
  right: 28px;
  top: 58%;
  border-top: 2px dashed rgba(143, 163, 192, 0.35);
}
.channel--pleth .wave__flat {
  top: 70%;
}

/*
 * Bloc des valeurs, disposé comme sur un moniteur :
 *   nom (FC ♥)      interrupteur
 *   seuils          GRANDE VALEUR
 *   unité           GRANDE VALEUR
 */
.readout {
  flex: 0 0 var(--readout-w);
  min-width: 0;
  min-height: 0;
  padding: clamp(8px, 5cqh, 18px) clamp(18px, 3cqw, 32px) clamp(10px, 6cqh, 20px) clamp(16px, 2.4cqw, 26px);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    'name switch'
    'limits value'
    'unit value';
  column-gap: 14px;
  row-gap: 2px;
  border-left: 1px solid var(--night-line);
}
.readout__top,
.readout__bottom {
  display: contents;
}
.readout__name {
  grid-area: name;
  align-self: center;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 21px;
  font-weight: 500;
}
.readout .switch {
  grid-area: switch;
  justify-self: end;
}
.channel--ecg .readout__name {
  color: var(--teal);
}
.channel--pleth .readout__name {
  color: var(--amber);
}
.readout__limits {
  grid-area: limits;
  align-self: start;
  padding-top: 6px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  font-size: 15px;
  line-height: 1.25;
  font-weight: 400;
  color: var(--night-muted);
  font-variant-numeric: tabular-nums;
}
/*
 * Grande valeur : la plus grande taille qui tient à la fois dans la hauteur de la
 * voie (100cqh) et dans la largeur du bloc, plafonnée. Hauteur fixe (celle d'un
 * chiffre) : le « – – – » plus petit ne change rien autour.
 */
.readout__value {
  grid-area: value;
  align-self: end;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 0.85em;
  --fit-h: calc((100cqh - var(--readout-chrome-h)) / 0.85);
  --fit-w: calc((var(--readout-w) - var(--readout-chrome-w)) / 1.9);
}
.channel--ecg .readout__value {
  font-size: max(32px, min(var(--fc-max), var(--fit-h), var(--fit-w)));
}
.channel--pleth .readout__value {
  font-size: max(32px, min(var(--sp-max), var(--fit-h), var(--fit-w)));
}
.value {
  font-size: 1em;
  line-height: 0.85;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  white-space: nowrap;
}
.value--fc {
  color: var(--teal);
}
.value--sp,
.value--fc[data-source='sp'] {
  /* Sans ECG, le pouls vient de l'oxymètre : il prend la couleur de la SpO₂. */
  color: var(--amber);
}
.value[data-off] {
  font-size: 0.8em;
  color: var(--night-muted);
}
.readout__unit {
  grid-area: unit;
  align-self: end;
  padding-bottom: 4px;
  font-size: 17px;
  font-weight: 400;
  color: var(--night-muted);
}

.heart {
  width: 20px;
  height: 20px;
  fill: var(--teal);
  opacity: 0.55;
  transform-origin: center;
}

/* Interrupteur On/Off */
.switch {
  min-height: 44px;
  border: 0;
  padding: 0 4px;
  background: transparent;
  color: var(--mist);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 500;
}
.switch:hover {
  color: var(--surface);
}
.switch__track {
  width: 48px;
  height: 28px;
  border-radius: 14px;
  padding: 3px;
  display: flex;
  align-items: center;
  background: rgba(199, 213, 224, 0.16);
  transition: background 0.2s ease;
}
.switch__knob {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--night-muted);
  transition:
    transform 0.2s ease,
    background 0.2s ease;
}
.switch[aria-checked='true'] .switch__knob {
  transform: translateX(20px);
  background: var(--night);
}
.switch--ecg[aria-checked='true'] .switch__track {
  background: var(--teal);
}
.switch--sp[aria-checked='true'] .switch__track {
  background: var(--amber);
}

/* Pression artérielle non invasive */
.channel--pni {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px clamp(16px, 3vw, 40px);
  padding: clamp(10px, 2.2vh, 22px) clamp(18px, 3vw, 36px) clamp(10px, 2.4vh, 24px) clamp(16px, 2.6vw, 28px);
  background: var(--night);
  border-radius: var(--radius-tile);
}
.pni__name {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pni__title {
  font-size: 21px;
  font-weight: 500;
  color: var(--blue-soft);
}
.pni__unit {
  font-size: 15px;
  font-weight: 400;
  color: var(--night-muted);
}
.pni__reading {
  flex: 1 1 260px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
}
.pni__value {
  font-size: clamp(40px, min(6.6vw, 9dvh), 96px);
  line-height: 0.9;
  font-weight: 400;
  color: var(--blue-soft);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  white-space: nowrap;
}
.pni__mean {
  font-size: clamp(22px, min(3vw, 4.4dvh), 44px);
  line-height: 0.9;
  font-weight: 400;
  color: var(--blue-soft);
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}
.pni__cuff {
  color: var(--night-muted);
  animation: pulse 1s ease-in-out infinite;
}
.pni__cuff-label {
  font-size: 17px;
  font-weight: 400;
  color: var(--night-muted);
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}
.pni__time {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.pni__clock {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 24px;
  font-weight: 400;
  color: var(--mist);
  font-variant-numeric: tabular-nums;
}
.pni__caption {
  font-size: 15px;
  font-weight: 400;
  color: var(--night-muted);
}
.pni-btn {
  min-width: 132px;
  height: clamp(48px, 8dvh, 56px);
  border: 0;
  border-radius: var(--radius-tab);
  padding: 0 24px;
  background: var(--blue-soft);
  color: var(--night-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 19px;
  font-weight: 700;
  transition:
    transform 0.12s ease,
    filter 0.15s ease;
}
.pni-btn:hover {
  filter: brightness(1.08);
}
.pni-btn:active {
  transform: scale(0.97);
}
.pni-btn[data-running] {
  background: var(--coral);
}

/* ——— Boutons d'outils (Silence, Alarmes) ——— */
.scope-top__end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}
.tool-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 18px 0 6px;
  border: 1px solid rgba(199, 213, 224, 0.2);
  border-radius: 999px;
  background: rgba(199, 213, 224, 0.1);
  /* léger relief : on comprend tout de suite que c'est un bouton */
  box-shadow:
    0 3px 0 rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  color: var(--night-text);
  font-size: 16px;
  font-weight: 600;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.15s ease,
    transform 0.15s var(--ease-out);
}
.tool-btn:hover {
  background: rgba(199, 213, 224, 0.17);
  border-color: rgba(199, 213, 224, 0.32);
}
.tool-btn:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 rgba(0, 0, 0, 0.35);
}
.tool-btn__icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(199, 213, 224, 0.12);
}
.tool-btn--mute .icon-bell-off {
  display: none;
}
.tool-btn--mute[aria-pressed='true'] {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--night-deep);
}
.tool-btn--mute[aria-pressed='true'] .tool-btn__icon {
  background: rgba(6, 18, 46, 0.14);
  animation: tool-pop 0.45s var(--ease-back);
}
.tool-btn--mute[aria-pressed='true'] .icon-bell {
  display: none;
}
.tool-btn--mute[aria-pressed='true'] .icon-bell-off {
  display: block;
}
/* Alarme en cours, son actif : le bouton appelle le geste. */
.tool-btn--mute[data-ringing] {
  border-color: var(--coral);
  animation: tool-halo 1.4s ease-out infinite;
}
.tool-btn--mute[data-ringing] .icon-bell {
  transform-origin: 50% 15%;
  animation: bell-ring 1.4s ease-in-out infinite;
}
@keyframes tool-halo {
  0% {
    box-shadow:
      0 3px 0 rgba(0, 0, 0, 0.35),
      0 0 0 0 rgba(254, 99, 70, 0.55);
  }
  100% {
    box-shadow:
      0 3px 0 rgba(0, 0, 0, 0.35),
      0 0 0 14px rgba(254, 99, 70, 0);
  }
}
@keyframes bell-ring {
  0%,
  50%,
  100% {
    transform: rotate(0);
  }
  10%,
  30% {
    transform: rotate(14deg);
  }
  20%,
  40% {
    transform: rotate(-14deg);
  }
}
@keyframes tool-pop {
  from {
    transform: scale(0.6);
  }
}
.alarm__muted {
  margin-left: 2px;
}
.tool-btn--icon {
  padding: 0 5px;
}

/* ——— Volet de réglage des alarmes ——— */
.drawer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--night-text);
  overflow: hidden;
}
.drawer[open] {
  display: flex;
  justify-content: flex-end;
  align-items: stretch;
}
.drawer::backdrop {
  background: rgba(3, 9, 26, 0.6);
}
.drawer__panel {
  width: min(420px, calc(100% - 24px));
  margin: 12px;
  margin-right: max(12px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #102a60 0%, var(--night) 60%);
  border: 1px solid rgba(199, 213, 224, 0.14);
  border-radius: 32px;
  box-shadow: -30px 0 80px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 20px 14px 24px;
}
.drawer__heading {
  display: flex;
  align-items: center;
  gap: 12px;
}
.drawer__icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(182, 189, 255, 0.16);
  color: var(--blue-soft);
}
.drawer__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
}
.drawer__close {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(199, 213, 224, 0.1);
  color: var(--mist);
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.2s ease,
    transform 0.3s var(--ease-back);
}
.drawer__close:hover {
  background: rgba(199, 213, 224, 0.2);
  transform: rotate(90deg);
}
.drawer__body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 24px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.limit-group {
  --accent: var(--teal);
  padding: 14px 16px 6px;
  border-radius: 22px;
  background: rgba(199, 213, 224, 0.06);
}
.limit-group--sp {
  --accent: var(--amber);
}
.limit-group--bp {
  --accent: var(--blue-soft);
}
.limit-group__title {
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
}
.limit-group__title::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}
.limit-group__unit {
  font-weight: 400;
  color: var(--night-muted);
}
.limit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
}
.limit + .limit {
  border-top: 1px solid var(--night-line);
}
.limit__label {
  font-size: 17px;
  color: var(--mist);
}
.limit__ctrl {
  display: flex;
  align-items: center;
  gap: 8px;
}
.limit__step {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: rgba(199, 213, 224, 0.1);
  color: var(--night-text);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition:
    background 0.15s ease,
    transform 0.12s ease;
}
.limit__step:hover {
  background: rgba(199, 213, 224, 0.2);
}
.limit__step:active {
  transform: scale(0.9);
}
.limit__value {
  display: inline-block;
  min-width: 64px;
  text-align: center;
  font-size: 28px;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.drawer__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px 20px 24px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}
.drawer__reset {
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--night-muted);
  font-size: 15px;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.drawer__reset:hover {
  color: var(--surface);
}
.drawer__done {
  min-height: 52px;
  padding: 0 28px;
  border: 0;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--night-deep);
  font-size: 17px;
  font-weight: 700;
  transition:
    filter 0.15s ease,
    transform 0.12s ease;
}
.drawer__done:hover {
  filter: brightness(1.08);
}
.drawer__done:active {
  transform: scale(0.97);
}

/* Tablette couchée (écran peu haut) : le volet s'élargit sur deux colonnes pour que
   tous les réglages tiennent sans défiler. */
@media (orientation: landscape) and (max-height: 700px) and (min-width: 700px) {
  .drawer__panel {
    width: min(640px, calc(100% - 24px));
  }
  .drawer__head {
    padding: 12px 14px 8px 20px;
  }
  .drawer__icon {
    width: 34px;
    height: 34px;
  }
  .drawer__title {
    font-size: 21px;
  }
  .drawer__body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      'fc bp'
      'sp bp';
    align-content: start;
    align-items: start;
    gap: 10px;
    padding: 4px 20px 6px;
  }
  .limit-group--fc {
    grid-area: fc;
  }
  .limit-group--sp {
    grid-area: sp;
  }
  .limit-group--bp {
    grid-area: bp;
  }
  .limit-group {
    padding: 10px 12px 4px;
  }
  .limit {
    padding: 4px 0;
  }
  .limit__label {
    font-size: 15px;
  }
  .limit__step {
    width: 44px;
    height: 44px;
  }
  .limit__value {
    min-width: 54px;
    font-size: 24px;
  }
  .drawer__foot {
    padding: 8px 14px 12px 20px;
  }
  .drawer__done {
    min-height: 44px;
  }
}

/* Motion design : le panneau glisse avec un léger rebond, le contenu suit en cascade. */
@media (prefers-reduced-motion: no-preference) {
  .drawer[open]::backdrop {
    animation: drawer-fade-in 0.35s ease-out;
  }
  .drawer[open] .drawer__panel {
    animation: drawer-in 0.62s cubic-bezier(0.3, 1.25, 0.45, 1);
  }
  .drawer[open] .drawer__icon {
    animation: drawer-icon 0.7s var(--ease-back) 0.15s backwards;
  }
  .drawer[open] .drawer__title,
  .drawer[open] .drawer__close {
    animation: drawer-item 0.5s var(--ease-out) 0.12s backwards;
  }
  .drawer[open] .limit-group {
    animation: drawer-item 0.55s var(--ease-out) backwards;
    animation-delay: calc(0.16s + var(--g, 0) * 0.07s);
  }
  .drawer[open] .limit {
    animation: drawer-item 0.55s var(--ease-out) backwards;
    animation-delay: calc(0.22s + var(--i, 0) * 0.06s);
  }
  .drawer[open] .drawer__foot {
    animation: drawer-rise 0.5s var(--ease-out) 0.45s backwards;
  }
  .drawer.is-closing::backdrop {
    animation: drawer-fade-out 0.28s ease-in forwards;
  }
  .drawer.is-closing .drawer__panel {
    animation: drawer-out 0.3s cubic-bezier(0.5, 0, 0.75, 0) forwards;
  }
}
@keyframes drawer-in {
  from {
    transform: translateX(calc(100% + 40px)) scale(0.94);
    opacity: 0.4;
  }
}
@keyframes drawer-out {
  to {
    transform: translateX(calc(100% + 40px)) scale(0.96);
    opacity: 0.3;
  }
}
@keyframes drawer-fade-in {
  from {
    opacity: 0;
  }
}
@keyframes drawer-fade-out {
  to {
    opacity: 0;
  }
}
@keyframes drawer-item {
  from {
    opacity: 0;
    transform: translateX(36px);
  }
}
@keyframes drawer-rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
}
@keyframes drawer-icon {
  from {
    opacity: 0;
    transform: scale(0.3) rotate(-35deg);
  }
}

/* ——— En-tête : place gagnée sur les tablettes ——— */
@media (max-width: 1099px) {
  /* Le titre reste lisible par les lecteurs d'écran ; l'onglet indique déjà « Scope ». */
  .scope-name {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    view-transition-name: none;
  }
  .scope-top__start {
    gap: 10px;
  }
  .scope-top__end {
    gap: 8px;
  }
  .pill--dark .pill__label {
    display: none;
  }
  .pill--dark {
    padding: 4px 14px;
  }
  .tool-btn:not(.tool-btn--icon) {
    padding-right: 14px;
  }
  .alarm {
    padding: 7px 14px;
    font-size: 17px;
  }
}

/* ——— Tablette debout (portrait) et écrans étroits : courbe au-dessus, valeurs en dessous ——— */
@media (orientation: portrait), (max-width: 759px) {
  .channel {
    flex-direction: column;
  }
  .channel--ecg {
    min-height: 280px;
  }
  .channel--pleth {
    min-height: 240px;
  }
  .wave {
    min-height: 90px;
  }
  .readout {
    flex: 0 0 auto;
    border-left: 0;
    border-top: 1px solid var(--night-line);
    padding: 12px clamp(18px, 4cqw, 32px) 14px;
  }
  /* Les valeurs occupent au plus la moitié de la voie : la courbe garde sa place. */
  .readout__value {
    --fit-h: calc((min(100cqh - 90px, 52cqh) - var(--readout-chrome-h)) / 0.85);
    --fit-w: calc((100cqw - var(--readout-chrome-w)) / 1.9);
  }
}

/* ——— Téléphones ——— */
@media (max-width: 600px) {
  .scope {
    --fc-max: 110px;
    --sp-max: 96px;
  }
  .channel,
  .channel--pni {
    border-radius: 28px;
  }
  .channel--pni {
    gap: 12px 20px;
  }
  .pni-btn {
    flex: 1 1 100%;
  }
}

/* ——— Très petits écrans : boutons d'outils réduits à leur icône (le nom reste lu) ——— */
@media (max-width: 520px), (max-width: 860px) and (orientation: landscape) {
  .tool-btn__text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .tool-btn:not(.tool-btn--icon) {
    padding: 0 5px;
  }
}

/* ——— Écran très bas (téléphone à l'horizontale) ——— */
@media (max-height: 480px) and (orientation: landscape) {
  .channel--ecg {
    min-height: 104px;
  }
  .channel--pleth {
    min-height: 92px;
  }
  .scope {
    --readout-chrome-h: 70px;
  }
  .readout__limits {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .alarm,
  .pni__cuff,
  .tool-btn--mute[data-ringing],
  .tool-btn--mute[data-ringing] .icon-bell,
  .tool-btn--mute[aria-pressed='true'] .tool-btn__icon {
    animation: none;
  }
  .heart {
    opacity: 1;
  }
  .switch__knob,
  .switch__track,
  .pni-btn {
    transition: none;
  }
}
