/* ==========================================================================
   RESPONSIVE — desktop → tablet → mobile
   ========================================================================== */

@media (max-width: 1360px) {
  .brand__sub, .brand__sep { display: none; }
}

/* ---------- Tablet ---------- */
@media (max-width: 1180px) {
  .nav-toggle { display: grid; }
  .topbar__status { margin-left: auto; }

  .nav {
    position: fixed;
    inset: var(--topbar-h) 0 auto 0;
    margin: 0;
    padding: .5rem var(--gutter) 1.25rem;
    border-bottom: 1px solid var(--border);
    background: rgba(8, 13, 18, .97);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity .2s, transform .2s, visibility 0s .2s;
  }
  .nav.is-open { opacity: 1; visibility: visible; transform: none; transition: opacity .2s, transform .2s; }
  .nav ul { flex-direction: column; gap: 0; }
  .nav a { padding: 1rem .25rem; border-bottom: 1px solid var(--border); border-radius: 0; font-size: .8rem; }
  .nav a[aria-current="true"] { box-shadow: inset 3px 0 0 var(--ecg); padding-left: .9rem; }

  .hero { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .hero__intro { max-width: 720px; }

  .channels { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .profile__id { grid-column: span 5; grid-row: span 1; }
  .profile__notes { grid-column: span 7; }
  .profile__skills { grid-column: span 7; }
  .profile__current { grid-column: span 5; }

  .footer__grid { grid-template-columns: 1fr 1fr; }
  .footer__sys { grid-column: 1 / -1; }

  .tl-body { grid-template-columns: minmax(0, 1fr); }
  .tl-desc { grid-column: 1; grid-row: auto; margin-top: .7rem; }
}

/* ---------- Small tablet / large phone ---------- */
@media (max-width: 760px) {
  .section__head { grid-template-columns: minmax(0, 1fr); }
  .section__meta { grid-column: 1; grid-row: auto; margin-top: .75rem; text-align: left; }

  .profile { grid-template-columns: minmax(0, 1fr); }
  .profile__id, .profile__notes, .profile__skills, .profile__current { grid-column: 1 / -1; grid-row: auto; }

  .tl-item { grid-template-columns: 44px minmax(0, 1fr); column-gap: 1rem; }
  .tl-line { grid-column: 1; grid-row: 1 / span 2; background-size: 44px auto; }
  .tl-node { width: 40px; height: 40px; margin-top: .4rem; }
  .tl-time { grid-column: 2; grid-row: 1; padding-top: .9rem; text-align: left; }
  .tl-body { grid-column: 2; padding-top: .3rem; }
  .tl-title { font-size: 1.45rem; }

  .monitor__screen { aspect-ratio: auto; }
  .monitor__grid { grid-template-columns: minmax(0, 1fr) 118px; grid-template-rows: 112px 86px 86px; }
  .num__limits { display: none; }
  .num { grid-template-areas: "label value" "unit value" ". value"; }
  .num__value { font-size: 2.1rem; }
  .num--hr .num__value { font-size: 2.8rem; }
  .monitor__footer .num__value { font-size: 1.7rem; }
  .wave__scale { display: none; }

  .strip__head { gap: .5rem 1rem; }
  .hide-sm { display: none; }
}

/* ---------- Phone ---------- */
@media (max-width: 640px) {
  :root { --topbar-h: 58px; }
  .topbar { gap: .75rem; }
  .status-item--sys .status-item__text, .status-item--audio, .clock__date { display: none; }
  .clock { padding-left: .75rem; }
  .clock__time { font-size: 1.05rem; }

  .channels { grid-template-columns: minmax(0, 1fr); }

  /* the alarm text takes the patient name's place in the narrow monitor banner */
  html[data-alarm="red"] .monitor__patient, html[data-alarm="yellow"] .monitor__patient { display: none; }

  .hero__actions .btn { flex: 1 1 140px; }

  .footer__grid { grid-template-columns: minmax(0, 1fr); gap: 28px; }

  /* 16px keeps iOS from zooming into the console input */
  .terminal__screen { font-size: 16px; height: 380px; padding: 1rem; }

  .audio-ctrl { left: 10px; right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); justify-content: space-between; }
  .volume { flex: 1; width: auto; min-width: 60px; }
}

@media (max-width: 400px) {
  .monitor__grid { grid-template-columns: minmax(0, 1fr) 100px; }
  .num { padding-inline: 8px; }
  .num__value { font-size: 1.8rem; }
  .num--hr .num__value { font-size: 2.4rem; }
  .monitor__footer { grid-template-columns: 1.4fr 1fr; }
  .monitor__footer .num__value { font-size: 1.4rem; }
  .monitor__banner { gap: .6rem; padding-inline: .6rem; }
  .audio-ctrl__power span { display: none; }
}
