:root {
  color-scheme: light;
  --lab-ceiling: #eef2f4;
  --lab-floor: #cbd3d8;
  --panel: #f7f9fa;
  --panel-muted: #dce3e7;
  --steel: #aeb9c0;
  --steel-dark: #68747c;
  --graphite: #252c31;
  --graphite-deep: #111619;
  --ink: #182026;
  --ink-soft: #44515a;
  --line: #313b42;
  --windows-blue: #0078d4;
  --windows-blue-deep: #0067b8;
  --safety-yellow: #f2c230;
  --safety-yellow-dark: #c99708;
  --emergency-red: #c83b32;
  --emergency-red-dark: #7d211d;
  --ready-green: #54ba73;
  --white: #ffffff;
  --focus: #ffe36b;
  --shadow: #7f8b92;
  --header-height: 70px;
  --z-simulation: 300;
  --z-dialog-backdrop: 400;
  --z-dialog: 410;
  --z-skip: 500;
  font-family: "Segoe UI", Inter, "Noto Sans TC", "PingFang TC",
    "Microsoft JhengHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-synthesis: none;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--lab-floor);
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(
      180deg,
      var(--lab-ceiling) 0,
      #e7ecef 58%,
      var(--lab-floor) 100%
    );
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

body.simulation-running {
  overflow: hidden;
}

button,
select,
input {
  font: inherit;
}

button,
a,
select,
input,
label {
  touch-action: manipulation;
}

button {
  min-height: 44px;
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.45);
  opacity: 0.54;
}

[hidden],
.is-hidden {
  display: none !important;
}

.skip-link {
  position: fixed;
  z-index: var(--z-skip);
  top: 8px;
  left: 8px;
  min-height: 44px;
  padding: 11px 16px;
  border: 3px solid var(--graphite-deep);
  background: var(--white);
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  transform: translateY(-150%);
  transition: transform 160ms ease-out;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  width: min(100%, 1280px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 12px clamp(14px, 2.7vw, 34px) 26px;
}

.lab-header {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto minmax(120px, 1fr);
  align-items: center;
  min-height: var(--header-height);
  margin-bottom: 14px;
  border-bottom: 3px solid var(--line);
}

.home-link {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 6px 8px 6px 2px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 760;
  text-decoration: none;
}

.home-link::before {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 2px solid var(--line);
  background: var(--panel);
  box-shadow: 3px 3px 0 var(--shadow);
  content: "←";
  font-size: 1.15rem;
  font-weight: 900;
  line-height: 1;
}

.brand-lockup {
  display: flex;
  grid-column: 2;
  align-items: center;
  justify-self: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 3px solid var(--graphite-deep);
  background: var(--safety-yellow);
  box-shadow: 3px 3px 0 var(--graphite-deep);
  color: var(--graphite-deep);
  font-family: Bahnschrift, "Arial Narrow", sans-serif;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1;
}

.brand-lockup > div:last-child {
  min-width: 0;
}

.eyebrow,
.app-title {
  margin: 0;
}

.eyebrow {
  color: var(--ink-soft);
  font-family: Bahnschrift, "Arial Narrow", "Segoe UI", sans-serif;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  line-height: 1;
  text-transform: uppercase;
}

.app-title {
  margin-top: 4px;
  font-size: 1.34rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.05;
  text-wrap: balance;
}

.header-tools {
  display: flex;
  grid-column: 3;
  align-items: center;
  justify-self: end;
  gap: 8px;
}

.status-chip {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border: 2px solid var(--line);
  background: var(--graphite);
  color: var(--white);
  font-family: Consolas, "Roboto Mono", monospace;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
}

.status-light {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border: 2px solid #06170d;
  border-radius: 50%;
  background: var(--ready-green);
  box-shadow: 0 0 0 2px rgba(84, 186, 115, 0.24);
}

[data-phase="armed"] .status-light,
[data-phase="running"] .status-light,
[data-phase="collecting"] .status-light,
[data-state="collecting"] .status-light {
  animation: ready-pulse 1.25s steps(2, end) infinite;
}

[data-state="complete"] .status-light {
  background: var(--safety-yellow);
  box-shadow: 0 0 0 2px rgba(242, 194, 48, 0.28);
}

[data-phase="reboot"] .status-light,
[data-state="rebooting"] .status-light {
  background: var(--emergency-red);
  box-shadow: 0 0 0 2px rgba(200, 59, 50, 0.24);
}

.utility-button {
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 12px;
  border: 2px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--shadow);
  font-size: 0.84rem;
  font-weight: 780;
}

.utility-button:hover,
.home-link:hover::before {
  background: var(--white);
}

.utility-button:active,
.home-link:active::before {
  box-shadow: 1px 1px 0 var(--shadow);
  transform: translate(2px, 2px);
}

.utility-button[aria-pressed="true"] {
  background: var(--graphite);
  color: var(--white);
  box-shadow: 1px 1px 0 var(--shadow);
  transform: translate(2px, 2px);
}

.lab-workspace {
  display: grid;
  grid-template-columns: minmax(450px, 1.28fr) minmax(330px, 0.72fr);
  align-items: start;
  gap: clamp(22px, 4vw, 50px);
  min-width: 0;
}

.monitor-bay {
  position: relative;
  min-width: 0;
  padding: 20px clamp(12px, 2vw, 24px) 8px;
}

.station-label {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  padding: 6px 10px;
  border: 2px solid var(--line);
  background: var(--safety-yellow);
  color: var(--graphite-deep);
  font-family: Consolas, "Roboto Mono", monospace;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1;
  text-transform: uppercase;
  transform: rotate(-1deg);
}

.monitor-frame {
  position: relative;
  width: min(100%, 720px);
  margin-inline: auto;
  padding: clamp(14px, 2.4vw, 24px) clamp(14px, 2.4vw, 24px) 10px;
  border: 4px solid var(--graphite-deep);
  border-radius: 9px 9px 4px 4px;
  background: var(--graphite);
  box-shadow: 8px 9px 0 rgba(75, 86, 93, 0.7);
}

.monitor-frame::before,
.monitor-frame::after {
  position: absolute;
  top: 8px;
  width: 6px;
  height: 6px;
  border: 1px solid #080b0d;
  border-radius: 50%;
  background: var(--steel);
  content: "";
}

.monitor-frame::before {
  left: 8px;
}

.monitor-frame::after {
  right: 8px;
}

.monitor-screen {
  position: relative;
  aspect-ratio: 16 / 9;
  min-height: 0;
  overflow: hidden;
  border: 4px solid #080c0f;
  border-radius: 3px;
  background: var(--windows-blue);
  box-shadow:
    0 0 0 2px #67737b,
    inset 0 0 0 1px rgba(255, 255, 255, 0.15);
  isolation: isolate;
}

.screen-shade {
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
}

.screen-shade::before {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    117deg,
    rgba(255, 255, 255, 0.12) 0,
    rgba(255, 255, 255, 0.025) 28%,
    transparent 45%
  );
  content: "";
}

.screen-shade::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    transparent 72%,
    rgba(0, 20, 38, 0.14) 100%
  );
  content: "";
}

.preview-bsod {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(16px, 4.4vw, 46px) clamp(20px, 5.8vw, 64px);
  background: var(--windows-blue);
  color: var(--white);
  font-family: "Segoe UI", "Noto Sans TC", sans-serif;
}

.preview-bsod .bsod-face {
  font-size: clamp(2.5rem, 7.8vw, 5.5rem);
  font-weight: 300;
  letter-spacing: -0.04em;
  line-height: 0.9;
}

.preview-bsod .bsod-message {
  width: min(86%, 38ch);
  margin: clamp(8px, 2vw, 18px) 0 0;
  font-size: clamp(0.68rem, 1.7vw, 1.18rem);
  font-weight: 350;
  line-height: 1.35;
  text-wrap: pretty;
}

.preview-bsod .bsod-progress {
  margin: clamp(7px, 1.7vw, 14px) 0 0;
  font-size: clamp(0.58rem, 1.32vw, 0.9rem);
  font-variant-numeric: tabular-nums;
}

.preview-stamp {
  position: absolute;
  right: 14px;
  bottom: 12px;
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  color: var(--white);
  font-family: Consolas, "Roboto Mono", monospace;
  font-size: clamp(0.48rem, 1vw, 0.64rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
}

.monitor-controls {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 5px 0;
  color: #d7dee2;
}

.monitor-led {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border: 1px solid #06170d;
  border-radius: 50%;
  background: var(--ready-green);
  box-shadow: 0 0 0 2px rgba(84, 186, 115, 0.18);
}

[data-phase="running"] .monitor-led,
[data-phase="collecting"] .monitor-led {
  animation: ready-pulse 1s steps(2, end) infinite;
}

.monitor-model {
  font-family: Consolas, "Roboto Mono", monospace;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.monitor-neck {
  width: 108px;
  height: 48px;
  margin: 0 auto;
  border-right: 4px solid var(--graphite-deep);
  border-left: 4px solid var(--graphite-deep);
  background: linear-gradient(90deg, #69747b, #b3bdc2 46%, #7c878d);
}

.monitor-foot {
  position: relative;
  width: min(46%, 250px);
  height: 22px;
  margin: 0 auto;
  border: 4px solid var(--graphite-deep);
  border-radius: 5px 5px 2px 2px;
  background: var(--steel);
  box-shadow: 5px 5px 0 rgba(75, 86, 93, 0.54);
}

.cable {
  position: absolute;
  z-index: -1;
  right: -8px;
  bottom: 12px;
  width: 40%;
  height: 82px;
  border-right: 9px solid var(--graphite-deep);
  border-bottom: 9px solid var(--graphite-deep);
  border-radius: 0 0 58px;
  transform: rotate(5deg);
}

.control-console {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 4px solid var(--graphite-deep);
  border-radius: 7px 7px 3px 3px;
  background: var(--panel);
  box-shadow: 8px 9px 0 var(--shadow);
}

.control-console::before {
  display: block;
  height: 12px;
  border-bottom: 3px solid var(--graphite-deep);
  background: var(--safety-yellow);
  content: "";
}

.console-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 17px 13px;
  border-bottom: 3px solid var(--line);
  background: var(--graphite);
  color: var(--white);
}

.serial {
  margin: 0;
  color: #c5cfd5;
  font-family: Consolas, "Roboto Mono", monospace;
  font-size: 0.63rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.3;
}

.console-title,
.console-copy {
  margin: 0;
}

.console-title {
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: -0.018em;
  line-height: 1.15;
  text-wrap: balance;
}

.console-copy {
  padding: 12px 17px 4px;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 550;
  line-height: 1.5;
  text-wrap: pretty;
}

.safety-notice {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin: 12px 17px 0;
  padding: 11px 12px;
  border: 2px solid var(--line);
  background: #fff1b8;
  color: #2a2412;
}

.safety-notice p,
.safety-notice > span:last-child {
  margin: 0;
  font-size: 0.76rem;
  font-weight: 650;
  line-height: 1.42;
}

.safety-notice > span:last-child {
  display: grid;
  gap: 2px;
}

.safety-icon {
  display: grid;
  width: 27px;
  height: 27px;
  flex: 0 0 auto;
  place-items: center;
  border: 2px solid var(--graphite-deep);
  background: var(--safety-yellow);
  color: var(--graphite-deep);
  font-family: Consolas, monospace;
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1;
}

.launch-zone {
  display: grid;
  justify-items: center;
  padding: 19px 17px 16px;
  border-bottom: 3px solid var(--line);
}

.launch-button {
  position: relative;
  display: grid;
  width: 124px;
  min-width: 124px;
  height: 124px;
  min-height: 124px;
  place-items: center;
  padding: 13px;
  border: 5px solid var(--graphite-deep);
  border-radius: 50%;
  background: var(--steel);
  box-shadow:
    0 9px 0 #5a656b,
    0 12px 0 var(--graphite-deep);
  color: var(--white);
  transition:
    transform 160ms ease-out,
    box-shadow 160ms ease-out;
}

.launch-cap {
  display: grid;
  width: 86px;
  height: 86px;
  place-items: center;
  border: 4px solid #7a1e19;
  border-radius: 50%;
  background: var(--emergency-red);
  box-shadow:
    inset 0 7px 0 rgba(255, 255, 255, 0.16),
    inset 0 -8px 0 rgba(94, 13, 10, 0.22);
}

.launch-label {
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  max-width: 8ch;
  color: var(--white);
  font-family: Bahnschrift, "Arial Narrow", "Segoe UI", sans-serif;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1.05;
  text-align: center;
  text-transform: uppercase;
  transform: translate(-50%, -50%);
}

.launch-button:hover .launch-cap {
  background: #dc4439;
}

.launch-button:active,
.launch-button[aria-pressed="true"] {
  box-shadow:
    0 2px 0 #5a656b,
    0 5px 0 var(--graphite-deep);
  transform: translateY(7px);
}

.launch-hint {
  margin: 15px 0 0;
  color: var(--ink-soft);
  font-family: Consolas, "Roboto Mono", monospace;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
}

.mode-readout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  padding: 1px;
  background: var(--line);
}

.mode-item {
  display: flex;
  min-width: 0;
  min-height: 48px;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  background: var(--graphite-deep);
  color: #dce4e8;
  font-family: Consolas, "Roboto Mono", monospace;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.25;
}

.mode-item span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mode-led {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border: 2px solid #07120b;
  border-radius: 50%;
  background: var(--ready-green);
}

[data-phase="idle"] .mode-led {
  background: var(--steel-dark);
}

[data-phase="running"] .mode-led,
[data-phase="collecting"] .mode-led {
  animation: ready-pulse 1.1s steps(2, end) infinite;
}

[data-phase="reboot"] .mode-led {
  background: var(--emergency-red);
}

.instruction-panel {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-width: 0;
  margin-top: -2px;
  padding: 12px 15px;
  border-top: 3px solid var(--line);
  border-bottom: 3px solid var(--line);
  background: rgba(247, 249, 250, 0.7);
}

.instruction-panel p {
  max-width: 70ch;
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.45;
  text-wrap: pretty;
}

.version-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  color: var(--ink-soft);
  font-family: Consolas, "Roboto Mono", monospace;
  font-size: 0.63rem;
  font-weight: 700;
  white-space: nowrap;
}

.version-row::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ready-green);
  content: "";
}

.simulation-layer {
  position: fixed;
  z-index: var(--z-simulation);
  inset: 0;
  display: grid;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--windows-blue);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition:
    opacity 180ms ease-out,
    visibility 0s linear 180ms;
}

.simulation-layer[data-active="true"] {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transition:
    opacity 180ms ease-out,
    visibility 0s linear 0s;
}

.sim-safe-rail {
  position: absolute;
  z-index: 4;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 9px 6px 14px;
  background: var(--graphite-deep);
  color: var(--white);
  transform: translateY(calc(-100% + 10px));
  transition: transform 190ms cubic-bezier(0.22, 1, 0.36, 1);
}

.sim-safe-rail::after {
  position: absolute;
  top: 100%;
  left: 50%;
  padding: 4px 9px 5px;
  background: var(--safety-yellow);
  color: var(--graphite-deep);
  content: "ESC";
  font-family: Consolas, monospace;
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1;
  transform: translateX(-50%);
}

.sim-safe-label,
.sim-safe-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.sim-safe-label {
  font-family: Consolas, "Roboto Mono", monospace;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.sim-safe-label > span:first-child {
  color: var(--ready-green);
}

.sim-safe-rail:hover,
.sim-safe-rail:focus-within {
  transform: translateY(0);
}

.sim-control {
  display: inline-flex;
  min-width: 44px;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 12px;
  border: 2px solid #8d9aa2;
  background: var(--graphite);
  color: var(--white);
  font-size: 0.78rem;
  font-weight: 750;
}

.sim-control:hover {
  border-color: var(--white);
  background: #303941;
}

.sim-control:active,
.sim-control[aria-pressed="true"] {
  background: var(--safety-yellow);
  color: var(--graphite-deep);
  transform: translateY(1px);
}

.bsod-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(54px, 8vh, 92px) clamp(24px, 9vw, 150px)
    clamp(26px, 5vh, 64px);
  overflow: auto;
  background: var(--windows-blue);
  color: var(--white);
  transition: opacity 180ms ease-out;
}

.bsod-content {
  width: min(100%, 1080px);
  margin: auto;
  font-family: "Segoe UI", "Noto Sans TC", "PingFang TC", sans-serif;
  font-weight: 350;
}

.bsod-emoticon {
  margin: 0;
  font-size: clamp(5rem, 12vw, 8.5rem);
  font-weight: 300;
  letter-spacing: -0.04em;
  line-height: 0.9;
}

.bsod-message {
  max-width: 46ch;
  margin: clamp(20px, 3.5vh, 38px) 0 0;
  font-size: clamp(1.35rem, 2.6vw, 2.2rem);
  font-weight: 350;
  line-height: 1.34;
  text-wrap: pretty;
}

.bsod-percentage {
  margin: clamp(18px, 3vh, 32px) 0 0;
  font-size: clamp(1.05rem, 1.8vw, 1.45rem);
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}

.bsod-details {
  display: flex;
  align-items: flex-start;
  gap: clamp(18px, 2.6vw, 32px);
  max-width: 850px;
  margin-top: clamp(24px, 4vh, 44px);
}

.qr-link {
  display: block;
  width: clamp(104px, 10vw, 150px);
  flex: 0 0 auto;
  padding: 7px;
  background: var(--white);
  color: var(--windows-blue-deep);
}

.qr-link:hover {
  outline: 3px solid var(--white);
  outline-offset: 4px;
}

.qr-code {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
}

.stop-code-info {
  max-width: 58ch;
  padding-top: 2px;
  font-size: clamp(0.76rem, 1.35vw, 1rem);
  line-height: 1.48;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

.stop-code-info br + span,
.stop-code-info strong {
  font-weight: 600;
}

.reboot-screen {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: grid;
  place-items: center;
  background: #000000;
  color: var(--white);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease-out;
}

.reboot-screen p,
.reboot-screen > span:last-child {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.reboot-mark {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  grid-template-columns: repeat(2, 18px);
  grid-template-rows: repeat(2, 18px);
  gap: 3px;
  margin-top: -42px;
  transform: translate(-50%, -50%) skewY(-4deg);
}

.reboot-mark span {
  display: block;
  background: var(--white);
}

.simulation-layer[data-phase="reboot"] .bsod-stage,
.simulation-layer[data-phase="rebooting"] .bsod-stage {
  opacity: 0;
}

.simulation-layer[data-phase="reboot"] .reboot-screen,
.simulation-layer[data-phase="rebooting"] .reboot-screen {
  opacity: 1;
  pointer-events: auto;
}

.settings-dialog {
  z-index: var(--z-dialog);
  width: min(calc(100% - 28px), 480px);
  max-height: min(720px, calc(100dvh - 28px));
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 4px solid var(--graphite-deep);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 8px 8px 0 rgba(17, 22, 25, 0.86);
}

.settings-dialog::backdrop {
  z-index: var(--z-dialog-backdrop);
  background: rgba(17, 22, 25, 0.76);
}

.settings-dialog[open] {
  animation: dialog-enter 180ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.settings-dialog form {
  margin: 0;
  padding: 20px;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: -20px -20px 20px;
  padding: 16px 18px;
  border-bottom: 4px solid var(--graphite-deep);
  background: var(--safety-yellow);
}

.dialog-head h2,
.dialog-head p {
  margin: 0;
}

.dialog-head h2 {
  margin-top: 3px;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.dialog-head p {
  color: #493a08;
  font-family: Consolas, "Roboto Mono", monospace;
  font-size: 0.63rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  line-height: 1.2;
  text-transform: uppercase;
}

.dialog-close {
  display: grid;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  place-items: center;
  padding: 0;
  border: 3px solid var(--graphite-deep);
  background: var(--panel);
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--graphite-deep);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1;
}

.dialog-close:active {
  box-shadow: 1px 1px 0 var(--graphite-deep);
  transform: translate(2px, 2px);
}

.settings-field {
  margin-top: 18px;
}

.settings-field:first-of-type {
  margin-top: 0;
}

.settings-field > label,
.settings-field > legend {
  display: block;
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 780;
  line-height: 1.3;
}

.settings-field fieldset,
fieldset.settings-field {
  min-width: 0;
  margin-inline: 0;
  padding: 0;
  border: 0;
}

.settings-field select {
  width: 100%;
  min-height: 48px;
  padding: 9px 12px;
  border: 3px solid var(--line);
  border-radius: 2px;
  background: var(--white);
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
}

.speed-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.radio-option {
  display: flex;
  min-width: 0;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 7px;
  border: 2px solid var(--line);
  background: var(--white);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
}

.radio-option:hover {
  background: #edf2f4;
}

.radio-option:has(input:checked) {
  border-color: var(--graphite-deep);
  background: var(--graphite);
  color: var(--white);
}

.radio-option input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--emergency-red);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  padding-top: 17px;
  border-top: 2px solid var(--steel);
}

.secondary-action {
  min-width: 112px;
  min-height: 46px;
  padding: 9px 16px;
  border: 3px solid var(--line);
  background: var(--graphite);
  color: var(--white);
  box-shadow: 4px 4px 0 var(--steel-dark);
  font-weight: 780;
}

.secondary-action:hover {
  background: #343e45;
}

.secondary-action:active {
  box-shadow: 1px 1px 0 var(--steel-dark);
  transform: translate(3px, 3px);
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

:where(a, button, select, input, [tabindex]):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px var(--graphite-deep);
}

.simulation-layer :where(a, button, [tabindex]):focus-visible {
  outline-color: var(--white);
  box-shadow: 0 0 0 6px var(--focus);
}

.settings-dialog :where(button, select, input):focus-visible {
  outline-color: var(--white);
  box-shadow: 0 0 0 6px var(--windows-blue-deep);
}

.launch-button:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 5px;
  box-shadow:
    0 9px 0 #5a656b,
    0 12px 0 var(--graphite-deep),
    0 0 0 10px var(--graphite-deep);
}

.screen-flash {
  animation: screen-flash 420ms ease-out;
}

#fa-help-btn,
.fa-help-button {
  width: 48px !important;
  min-width: 48px !important;
  height: 48px !important;
  min-height: 48px !important;
  border: 3px solid var(--graphite-deep) !important;
  border-radius: 2px !important;
  background: var(--safety-yellow) !important;
  color: var(--graphite-deep) !important;
  box-shadow: 4px 4px 0 var(--graphite-deep) !important;
}

#fa-help-btn:focus-visible,
.fa-help-button:focus-visible {
  outline: 3px solid var(--white) !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 6px var(--windows-blue-deep) !important;
}

@keyframes ready-pulse {
  50% {
    opacity: 0.45;
  }
}

@keyframes screen-flash {
  0% {
    filter: brightness(1);
  }
  28% {
    filter: brightness(1.75);
  }
  100% {
    filter: brightness(1);
  }
}

@keyframes dialog-enter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 940px) {
  .lab-workspace {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }

  .monitor-bay {
    width: min(100%, 720px);
    margin-inline: auto;
  }

  .control-console {
    width: min(100%, 620px);
    margin-inline: auto;
  }

  .instruction-panel {
    width: min(100%, 720px);
    margin-inline: auto;
  }
}

@media (max-width: 640px) {
  :root {
    --header-height: 62px;
  }

  .app-shell {
    padding: 8px 10px 22px;
  }

  .lab-header {
    grid-template-columns: 52px minmax(0, 1fr) auto;
    margin-bottom: 10px;
  }

  .home-link {
    width: 44px;
    min-width: 44px;
    padding: 0;
    overflow: hidden;
    color: transparent;
    font-size: 0;
  }

  .home-link::before {
    width: 40px;
    height: 40px;
    margin: 0;
    color: var(--ink);
    font-size: 1.15rem;
  }

  .brand-lockup {
    justify-self: start;
    gap: 8px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    border-width: 2px;
    font-size: 0.6rem;
  }

  .eyebrow {
    font-size: 0.55rem;
    letter-spacing: 0.1em;
  }

  .app-title {
    max-width: 150px;
    overflow: hidden;
    font-size: 1.03rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .status-chip {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .utility-button {
    width: 44px;
    min-width: 44px;
    padding-inline: 0;
    overflow: hidden;
  }

  .utility-button > span:last-child {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  .lab-workspace {
    gap: 20px;
  }

  .monitor-bay {
    padding: 18px 6px 4px;
  }

  .station-label {
    font-size: 0.56rem;
  }

  .monitor-frame {
    padding: 12px 12px 8px;
    border-width: 3px;
    box-shadow: 5px 6px 0 rgba(75, 86, 93, 0.7);
  }

  .monitor-screen {
    border-width: 3px;
  }

  .monitor-controls {
    min-height: 28px;
    padding-top: 5px;
  }

  .monitor-neck {
    width: 78px;
    height: 34px;
  }

  .monitor-foot {
    height: 17px;
    border-width: 3px;
  }

  .cable {
    display: none;
  }

  .control-console {
    box-shadow: 5px 6px 0 var(--shadow);
  }

  .console-head {
    padding: 13px 14px 11px;
  }

  .console-copy {
    padding: 10px 14px 2px;
  }

  .safety-notice {
    margin: 11px 14px 0;
  }

  .launch-zone {
    padding: 17px 14px 15px;
  }

  .launch-button {
    width: 112px;
    min-width: 112px;
    height: 112px;
    min-height: 112px;
  }

  .launch-cap {
    width: 76px;
    height: 76px;
  }

  .instruction-panel {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 11px 12px;
  }

  .version-row {
    justify-content: flex-start;
  }

  .sim-safe-rail {
    transform: translateY(0);
  }

  .sim-safe-rail::after {
    display: none;
  }

  .sim-control {
    padding-inline: 10px;
  }

  .bsod-stage {
    align-items: flex-start;
    padding: 72px 26px 30px;
  }

  .bsod-content {
    margin-top: 7vh;
  }

  .bsod-emoticon {
    font-size: clamp(4.8rem, 24vw, 6.7rem);
  }

  .bsod-message {
    margin-top: 22px;
    font-size: clamp(1.18rem, 5.8vw, 1.62rem);
  }

  .bsod-percentage {
    margin-top: 18px;
    font-size: 1rem;
  }

  .bsod-details {
    gap: 15px;
    margin-top: 26px;
  }

  .qr-link {
    width: 92px;
    padding: 5px;
  }

  .stop-code-info {
    font-size: 0.68rem;
    line-height: 1.42;
  }

  .settings-dialog form {
    padding: 16px;
  }

  .dialog-head {
    margin: -16px -16px 18px;
    padding: 14px;
  }
}

@media (max-width: 390px) {
  .app-shell {
    padding-inline: 8px;
  }

  .app-title {
    max-width: 128px;
  }

  .brand-mark {
    display: none;
  }

  .preview-bsod {
    padding-inline: 24px;
  }

  .preview-stamp {
    right: 9px;
    bottom: 8px;
  }

  .console-title {
    font-size: 1.02rem;
  }

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

  .mode-item {
    min-height: 42px;
  }

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

  .radio-option {
    justify-content: flex-start;
    padding-inline: 12px;
  }

  .bsod-stage {
    padding-inline: 21px;
  }

  .bsod-content {
    margin-top: 4vh;
  }

  .bsod-details {
    align-items: center;
  }

  .qr-link {
    width: 82px;
  }
}

@media (min-width: 700px) and (max-height: 620px) {
  :root {
    --header-height: 48px;
  }

  body:not(.simulation-running) {
    overflow: hidden;
  }

  .app-shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    width: 100%;
    height: 100vh;
    height: 100dvh;
    padding: 4px 14px 7px;
  }

  .lab-header {
    min-height: var(--header-height);
    margin-bottom: 5px;
  }

  .home-link,
  .utility-button {
    min-height: 42px;
  }

  .home-link::before {
    width: 30px;
    height: 30px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    border-width: 2px;
    font-size: 0.58rem;
  }

  .eyebrow {
    font-size: 0.54rem;
  }

  .app-title {
    font-size: 1.06rem;
  }

  .status-chip {
    min-height: 28px;
    padding-block: 4px;
  }

  .utility-button {
    padding-block: 4px;
  }

  .lab-workspace {
    grid-template-columns: minmax(330px, 1.12fr) minmax(300px, 0.88fr);
    grid-template-rows: minmax(0, 1fr);
    align-items: center;
    gap: clamp(18px, 3vw, 34px);
    min-height: 0;
    overflow: hidden;
  }

  .monitor-bay {
    width: 100%;
    max-height: 100%;
    padding: 13px 7px 2px;
  }

  .station-label {
    padding: 4px 7px;
    font-size: 0.52rem;
  }

  .monitor-frame {
    width: min(100%, 560px);
    padding: 10px 11px 5px;
    border-width: 3px;
    box-shadow: 5px 5px 0 rgba(75, 86, 93, 0.7);
  }

  .monitor-screen {
    border-width: 3px;
  }

  .monitor-controls {
    min-height: 24px;
    padding-top: 3px;
  }

  .monitor-model {
    font-size: 0.5rem;
  }

  .monitor-neck {
    width: 70px;
    height: 25px;
    border-width: 3px;
  }

  .monitor-foot {
    width: min(42%, 190px);
    height: 13px;
    border-width: 3px;
    box-shadow: 3px 3px 0 rgba(75, 86, 93, 0.54);
  }

  .cable {
    display: none;
  }

  .control-console {
    display: block;
    width: 100%;
    max-height: 100%;
    overflow-y: auto;
    border-width: 3px;
    box-shadow: 5px 5px 0 var(--shadow);
  }

  .control-console::before {
    height: 8px;
    border-width: 0 0 2px;
  }

  .console-head {
    padding: 8px 11px;
    border-bottom-width: 2px;
  }

  .console-title {
    padding: 6px 11px 0;
    font-size: 0.92rem;
  }

  .serial {
    font-size: 0.5rem;
  }

  .console-copy {
    display: none;
  }

  .safety-notice {
    align-items: center;
    gap: 7px;
    margin: 6px 11px;
    padding: 6px 8px;
  }

  .safety-notice p,
  .safety-notice > span:last-child {
    font-size: 0.6rem;
    line-height: 1.25;
  }

  .safety-icon {
    width: 22px;
    height: 22px;
    border-width: 1px;
    font-size: 0.72rem;
  }

  .safety-notice > span:last-child > span {
    display: none;
  }

  .launch-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px 7px;
    border-bottom-width: 2px;
  }

  .launch-button {
    grid-row: 1 / -1;
    width: 82px;
    min-width: 82px;
    height: 82px;
    min-height: 82px;
    padding: 8px;
    border-width: 4px;
    box-shadow:
      0 5px 0 #5a656b,
      0 8px 0 var(--graphite-deep);
  }

  .launch-cap {
    width: 58px;
    height: 58px;
    border-width: 3px;
  }

  .launch-label {
    font-size: 0.6rem;
  }

  .launch-hint {
    display: none;
  }

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

  .mode-item {
    min-height: 36px;
    padding: 5px 8px;
    font-size: 0.54rem;
  }

  .instruction-panel {
    display: none;
  }

  .version-row {
    display: none;
  }

  .bsod-stage {
    align-items: flex-start;
    padding: 42px 7vw 18px;
  }

  .bsod-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(210px, 0.68fr);
    grid-template-rows: auto auto auto;
    column-gap: clamp(24px, 5vw, 70px);
    align-items: start;
    width: min(100%, 1050px);
    margin: 2vh auto 0;
  }

  .bsod-emoticon {
    grid-column: 1;
    font-size: clamp(3.8rem, 14vh, 6rem);
  }

  .bsod-message {
    grid-column: 1;
    margin-top: 12px;
    font-size: clamp(1rem, 3.5vh, 1.55rem);
  }

  .bsod-percentage {
    grid-column: 1;
    margin-top: 11px;
    font-size: 0.88rem;
  }

  .bsod-details {
    grid-column: 2;
    grid-row: 1 / -1;
    align-self: center;
    gap: 13px;
    margin-top: 0;
  }

  .qr-link {
    width: clamp(76px, 13vh, 112px);
    padding: 5px;
  }

  .stop-code-info {
    font-size: clamp(0.58rem, 1.8vh, 0.78rem);
    line-height: 1.36;
  }

  .sim-safe-rail {
    min-height: 42px;
    padding-block: 3px;
  }

  .sim-control {
    min-height: 36px;
    padding-block: 4px;
    font-size: 0.68rem;
  }

  .settings-dialog {
    max-height: calc(100dvh - 16px);
  }

  .settings-dialog form {
    padding: 14px;
  }

  .dialog-head {
    margin: -14px -14px 12px;
    padding: 10px 12px;
  }

  .settings-field {
    margin-top: 11px;
  }

  .settings-field select {
    min-height: 44px;
  }

  .radio-option {
    min-height: 42px;
  }

  .dialog-actions {
    margin-top: 12px;
    padding-top: 11px;
  }
}

@media (pointer: coarse), (max-height: 620px) {
  .sim-safe-rail {
    transform: translateY(0);
  }

  .bsod-stage {
    padding-top: max(54px, env(safe-area-inset-top));
  }
}

@media (prefers-contrast: more) {
  :root {
    --ink-soft: #182026;
    --line: #111619;
  }

  .console-copy,
  .instruction-panel p,
  .launch-hint,
  .version-row {
    color: var(--ink);
  }

  .home-link::before,
  .utility-button,
  .control-console,
  .settings-field select,
  .radio-option,
  .secondary-action {
    border-width: 4px;
  }

  .sim-safe-rail {
    border-bottom: 3px solid var(--white);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .status-light,
  .monitor-led,
  .mode-led,
  .screen-flash {
    animation: none !important;
  }

  .sim-safe-rail {
    transition: none;
  }
}
