.delay-heading { display:flex; flex-wrap:wrap; align-items:center; gap:.25rem .75rem; }
#extension-help {
  display:inline-flex; align-items:center; gap:.4rem; width:auto; min-height:44px; height:auto;
  margin:0; padding:0 .25rem; font:inherit; font-size:.9rem; text-align:left;
  text-decoration:underline; text-underline-offset:3px;
}
#extension-help::before { content:none; }
#extension-help .help-mark {
  display:inline-grid; place-items:center; width:1.4rem; height:1.4rem; flex:none;
  border:1px solid currentColor; border-radius:50%; text-decoration:none;
}
#extension-popup, #notification-popup {
  position:fixed; inset:auto; margin:0; max-width:calc(100vw - 16px);
  max-height:calc(100dvh - 16px); overflow:auto; overscroll-behavior:contain;
}
#extension-popup .extension-actions button { white-space:normal; overflow-wrap:anywhere; }

@media screen and (max-width: 900px) and (pointer: coarse) {
  .explain h2, #options p, .option > span, .mapping-layout nav button { overflow-wrap: anywhere; }
  .option > span, .mapping-layout nav button { min-width: 0; }
  #metadata-support, #copy-signal, #print-guide { min-height: 44px; }

  #review[open] {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    max-height: calc(100dvh - 24px);
    background: var(--panel);
  }
  #review-title, #review > form {
    grid-area: 1 / 1;
    position: sticky;
    top: 0;
    z-index: 1;
    align-self: start;
  }
  #review-title {
    min-height: 52px;
    padding: 2px 52px 8px 0;
    line-height: 1.15;
    background: var(--panel);
  }
  #review-title::before {
    content:""; position:absolute; inset:auto 0 100%; height:1.5rem; background:var(--panel);
  }
  #review > form { z-index: 2; justify-self: end; }

  /* Supporting browsers can wrap the selected value while retaining a native select. */
  @supports (appearance: base-select) {
    #market, #market::picker(select) { appearance:base-select; }
    #market { align-items:center; gap:.75rem; padding-inline:.875rem; white-space:normal; overflow-wrap:anywhere; }
    #market::picker-icon {
      content:""; flex:none; width:.45rem; height:.45rem; border:solid currentColor;
      border-width:0 1.5px 1.5px 0; transform:translateY(-.1em) rotate(45deg);
    }
    .studio-head > label::after { content:none; }
    #market::picker(select) {
      max-width:calc(100vw - 24px); max-height:60dvh; overflow:auto;
      background:var(--panel); border:1px solid var(--line); color:var(--ink);
    }
    #market option { min-height:44px; padding:.5rem .75rem; white-space:normal; }
    .security-choice select, .security-choice select::picker(select) { appearance: base-select; }
    .security-choice select { white-space: normal; overflow-wrap: anywhere; }
    .security-choice select::picker(select) {
      max-width: calc(100vw - 24px);
      max-height: min(60dvh, 24rem);
      overflow: auto;
      background: var(--panel);
      border: 1px solid var(--line);
    }
    .security-choice option { min-height: 44px; padding: 8px 12px; white-space: normal; overflow-wrap: anywhere; }
  }
}

@media screen and (max-height:440px) and (orientation:landscape) {
  #settings-drawer .request-editor .request-field {
    min-height:5rem; max-height:max(5rem,40dvh);
  }
}
@media screen and (max-width: 760px) and (pointer: coarse) {
  .mapping-layout nav {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 7.25rem), 1fr));
  }
}

#landing-contact-slot:empty { display:none; }

@media screen and (max-width:760px), screen and (pointer:coarse) and (orientation:landscape) and (max-width:960px) and (max-height:540px) {
  #landing-contact-slot {
    margin:0 0 1rem; padding:0 clamp(.4rem,2.5vw,1.3rem);
    border-block:1px solid var(--line);
    background:linear-gradient(110deg,#342a433d,transparent 85%);
  }
  #landing-contact-slot .signal-contact {
    padding:.85rem 0 .5rem; border:0; background:none;
  }
  #landing-contact-slot .signal-chat { gap:.65rem; }
  #landing-contact-slot .signal-username { gap:.75rem; }
  #landing-contact-slot #copy-signal { min-height:44px; }
  #landing-contact-slot .contact-alternative { min-height:44px; }
}

/* The header and schematic form the screen reached by the native #studio link. */
@media screen and (max-width:760px), screen and (pointer:coarse) and (orientation:landscape) and (max-width:960px) and (max-height:540px) {
  #studio {
    scroll-margin-block-start:0;
    padding-block-start:max(.875rem,env(safe-area-inset-top));
  }
  #studio .stage {
    display:grid; grid-template-rows:auto minmax(min-content,1fr) auto auto;
    min-block-size:min-content;
  }
  .stage .device { container:handset-screen / size; min-height:12.5rem; padding:0; }
  .device .assembly { width:min(94cqw,calc(100cqh * 320 / 420),23rem); }
  .stage .hint { min-block-size:min-content; }
  /* Keep each side button's hit area inside the gap to its closest neighbour. */
  .node.right[data-control] { height:min(32px,8cqw); }
}

@media screen and (max-width:760px) and (max-height:700px) {
  #studio .studio-head { row-gap:.5rem; }
  .stage .stage-top { padding:.55rem .75rem; }
  .stage .hint { margin-block-end:.45rem; }
  .stage #open-settings { margin-block-end:.65rem; }
}

@media screen and (max-width:360px) and (max-height:700px) {
  .stage .stage-top {
    display:grid; grid-template-columns:minmax(0,1.25fr) minmax(0,1fr); gap:.15rem .45rem;
  }
  .stage-top .device-model { grid-column:1; font-size:.9375rem; }
}

@media screen and (orientation:landscape) and (min-width:560px) and (max-width:760px) and (max-height:540px),
       screen and (pointer:coarse) and (orientation:landscape) and (min-width:761px) and (max-width:960px) and (max-height:540px) {
  #studio .studio-head { grid-template-columns:minmax(0,1fr) minmax(12.75rem,max-content); }
  #studio .studio-head > :first-child { grid-column:auto; }
  #studio .stage {
    grid-template-columns:minmax(0,1fr) minmax(12.75rem, .85fr);
    grid-template-rows:auto 1fr auto;
    grid-template-areas:"phone toolbar" "phone hint" "phone options";
    align-items:center;
  }
  .stage .device { grid-area:phone; align-self:stretch; }
  .stage-top { grid-area:toolbar; }
  .stage .hint { grid-area:hint; margin-block:0; }
  .stage #open-settings { grid-area:options; }
}
