:root {
  color-scheme: dark;
  --bg: #07111f;
  --bg-alt: #0f1d33;
  --panel: rgba(8, 20, 38, 0.88);
  --panel-strong: rgba(9, 25, 48, 0.96);
  --line: rgba(143, 205, 255, 0.24);
  --text: #edf7ff;
  --muted: #9cb5ce;
  --accent: #7bf7d4;
  --accent-strong: #2cc6ff;
  --danger: #ff9b7a;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  --radius: 20px;
  --radius-sm: 14px;
  --screen-default-width: 800px;
  --screen-default-height: 600px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(44, 198, 255, 0.15), transparent 28rem),
    radial-gradient(circle at bottom right, rgba(123, 247, 212, 0.12), transparent 24rem),
    linear-gradient(180deg, #08101d 0%, #081523 40%, #09101a 100%);
}

code,
button,
.detail-value,
.eyebrow,
.viewer-label,
.status-banner,
.serial-output {
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

.page-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 32px 20px 40px;
}

.hero {
  margin-bottom: 26px;
}

.eyebrow {
  margin: 0 0 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  font-size: 0.8rem;
}

.hero h1 {
  margin: 0;
  max-width: 14ch;
  font-size: clamp(2.2rem, 5vw, 4.8rem);
  line-height: 0.95;
}

.hero-copy {
  max-width: 56rem;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 22px;
}

.launcher-panel,
.viewer-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.launcher-panel {
  padding: 22px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 120px);
}

.panel-header,
.viewer-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.panel-header h2,
.viewer-header h2 {
  margin: 0;
  font-size: 1.4rem;
}

.panel-header p,
.viewer-header p,
.detail-label {
  margin: 6px 0 0;
  color: var(--muted);
}

.machine-list {
  display: grid;
  flex: 1;
  gap: 14px;
  min-height: 0;
  margin-top: 20px;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
}

.machine-list::-webkit-scrollbar {
  width: 10px;
}

.machine-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(123, 247, 212, 0.28);
}

.machine-card {
  width: 100%;
  text-align: left;
  padding: 18px;
  border: 1px solid rgba(143, 205, 255, 0.18);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(180deg, rgba(23, 49, 86, 0.7), rgba(10, 26, 49, 0.92));
  color: var(--text);
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.machine-card:hover,
.machine-card:focus-visible,
.machine-card.active {
  transform: translateY(-1px);
  border-color: rgba(123, 247, 212, 0.65);
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.28);
  outline: none;
}

.machine-card h3,
.machine-card p {
  margin: 0;
}

.machine-card h3 {
  font-size: 1.15rem;
}

.machine-meta,
.machine-file {
  color: var(--muted);
  font-size: 0.92rem;
}

.machine-summary {
  margin: 10px 0;
  line-height: 1.5;
}

.viewer-panel {
  padding: 22px;
}

.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

button {
  border: 1px solid rgba(123, 247, 212, 0.28);
  border-radius: 999px;
  padding: 11px 16px;
  background: rgba(8, 22, 40, 0.85);
  color: var(--text);
  cursor: pointer;
}

button:hover:enabled,
button:focus-visible:enabled {
  border-color: var(--accent);
  outline: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.status-banner {
  margin-top: 18px;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(143, 205, 255, 0.14);
  background: rgba(7, 17, 31, 0.9);
  color: var(--muted);
}

.status-banner.error {
  border-color: rgba(255, 155, 122, 0.35);
  color: #ffd6c9;
}

.screen-wrap {
  margin-top: 18px;
  width: min(100%, calc(var(--screen-default-width) + 32px));
  min-height: calc(var(--screen-default-height) + 32px);
  padding: 16px;
  margin-inline: auto;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(3, 8, 15, 0.7), rgba(2, 6, 12, 0.96)),
    repeating-linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.015) 0 2px,
      transparent 2px 4px
    );
  border: 1px solid rgba(143, 205, 255, 0.12);
}

.screen {
  width: min(100%, var(--screen-default-width));
  min-height: var(--screen-default-height);
  aspect-ratio: 4 / 3;
  margin: 0 auto;
  display: grid;
  place-items: center;
  background: #000;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  color: var(--muted);
  overflow: hidden;
}

.screen canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.screen-wrap:fullscreen,
.screen-wrap:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  display: grid;
  place-items: center;
  background: #000;
}

.screen-wrap:fullscreen .screen,
.screen-wrap:-webkit-full-screen .screen {
  width: 100vw;
  height: 100vh;
  min-height: 0;
  aspect-ratio: auto;
  display: grid;
  place-items: center;
}

.screen-wrap:fullscreen .screen canvas,
.screen-wrap:-webkit-full-screen .screen canvas {
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: 100vh;
  object-fit: contain;
}

.screen-wrap:fullscreen .screen > div:not(.empty-state),
.screen-wrap:-webkit-full-screen .screen > div:not(.empty-state) {
  width: 100%;
  height: 100%;
  padding: 24px;
  font-size: clamp(16px, 2vw, 24px);
}

.screen > div:not(.empty-state) {
  align-self: start;
  justify-self: start;
  width: 100%;
  padding: 12px;
  background: #000;
  color: #d6e8ff;
  font-family: inherit;
  font-size: 16px;
  line-height: 1;
  white-space: pre;
  overflow: auto;
}

.screen > div:not(.empty-state) > div {
  min-height: 1em;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.detail-card {
  padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--panel-strong);
  border: 1px solid rgba(143, 205, 255, 0.14);
}

.detail-card-wide {
  grid-column: span 1;
}

.detail-value {
  margin: 8px 0 0;
  font-size: 0.95rem;
  line-height: 1.6;
}

.serial-panel {
  margin-top: 18px;
  border-radius: var(--radius-sm);
  background: rgba(6, 14, 25, 0.82);
  border: 1px solid rgba(143, 205, 255, 0.12);
}

.serial-panel summary {
  cursor: pointer;
  padding: 14px 16px;
  color: var(--muted);
}

.serial-output {
  min-height: 180px;
  margin: 0;
  padding: 0 16px 16px;
  overflow: auto;
  color: #bdefff;
  white-space: pre-wrap;
}

.empty-state {
  max-width: 42rem;
  text-align: center;
  line-height: 1.6;
}

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .launcher-panel {
    max-height: none;
  }

  .machine-list {
    max-height: none;
    overflow-y: visible;
    padding-right: 0;
  }
}

@media (max-width: 720px) {
  .page-shell {
    padding-inline: 14px;
  }

  .viewer-header,
  .panel-header {
    flex-direction: column;
  }

  .details-grid {
    grid-template-columns: 1fr;
  }

  .detail-card-wide {
    grid-column: auto;
  }

  .screen-wrap,
  .screen {
    width: 100%;
    min-height: auto;
  }
}
