/* Reserve the scrollbar lane even when a shorter status fits the viewport. */
html { overflow-y: scroll; scrollbar-gutter: stable; }

/* A single fitting rule replaces the old width/height-specific spacers.
   Hardware retains its original aspect ratio; text is outside that scale. */
.connected .utility { min-height: 72px; padding: 16px 32px; }
.connected #entrance {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100svh - 72px);
  padding: 20px 0 24px;
}
.connected .entrance-scene {
  height: 0;
  min-height: 0;
  visibility: hidden;
  transition: none;
}
.connected .device-workspace {
  --hardware-fit-width: calc(max(260px, 100svh - 380px) * 768 / 370);
  width: min(calc(100% - 48px), 1080px, calc(var(--hardware-fit-width) + 32px));
  margin: 0 auto;
  padding: 0 16px;
}
.device-workspace .device-heading { margin: 0 0 14px; }
.device-workspace .hardware-stage {
  width: min(100%, 1024px);
  max-width: none;
  height: auto;
  aspect-ratio: 768 / 370;
}
.device-workspace .device-caption {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 18px;
  align-items: start;
  margin: 16px 0 0;
  padding: 12px 16px;
}
.device-caption-copy { display: contents; }
.device-caption .lamp-legend { grid-column: 1; grid-row: 1; align-self: center; margin: 0; }
.device-caption .attempts { grid-column: 2; grid-row: 1; }
.device-caption #feedback-live {
  grid-column: 1 / -1;
  grid-row: 2;
  min-height: 42px;
  margin: 0;
  font: 14px/1.5 'PT Mono', Consolas, monospace;
}
/* Keep room for a selected result even before the first analysis and after OFF. */
.device-caption #feedback-live[hidden] { display: block !important; visibility: hidden; }
.device-caption #instruction {
  grid-column: 1 / -1;
  grid-row: 3;
  min-height: 63px;
  max-width: none;
  font: 14px/1.5 Onest, Arial, sans-serif;
}
.device-workspace .device-actions { min-height: 40px; padding: 10px 0 0; }

@media (max-width: 760px) {
  .connected .utility { min-height: 64px; padding: 12px 16px; }
  .connected #entrance { min-height: calc(100svh - 64px); padding: 24px 0; }
  .connected .device-workspace { width: min(calc(100% - 28px), 420px); padding: 0; }
  .device-workspace .hardware-stage { width: min(100%, 388px); aspect-ratio: 388 / 680; }
  .device-workspace .device-heading { margin: 0 0 18px; }
  .device-workspace .device-caption { padding: 12px; gap: 8px 12px; }
  .device-caption #feedback-live { min-height: 63px; }
  .device-caption #instruction { min-height: 126px; }
}
