:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #111314;
  color: #f2f5f3;
}

* {
  box-sizing: border-box;
}

body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: #050606;
}

button,
input {
  font: inherit;
}

.app {
  position: relative;
  width: 100vw;
  min-height: 100dvh;
  overflow: hidden;
  background: #050606;
}

.topbar {
  position: fixed;
  z-index: 20;
  top: 16px;
  left: 16px;
  display: grid;
  gap: 14px;
  width: min(520px, calc(100vw - 32px));
  border: 1px solid rgba(68, 78, 78, 0.78);
  border-radius: 8px;
  background: rgba(11, 13, 13, 0.94);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
  padding: 14px;
}

.eyebrow,
.launch-bar span {
  color: #87d9ca;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 8px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 2rem;
  line-height: 1.08;
}

.launch-bar {
  display: grid;
  gap: 12px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  border: 1px solid #30383b;
  border-radius: 6px;
  background: #101415;
  padding: 4px;
}

.mode-switch button {
  height: 34px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #cfd8d4;
  cursor: pointer;
  font-weight: 800;
  padding: 0 10px;
}

.mode-switch button[aria-pressed="true"] {
  background: #dfc64a;
  color: #111314;
}

.credentials-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.launch-bar label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.launch-bar input:not([type="radio"]) {
  min-width: 0;
  width: 100%;
  height: 42px;
  border: 1px solid #374044;
  border-radius: 6px;
  background: #151a1b;
  color: #f2f5f3;
  padding: 0 11px;
}

.credentials-row button {
  height: 42px;
  border: 0;
  border-radius: 6px;
  background: #dfc64a;
  color: #111314;
  cursor: pointer;
  font-weight: 800;
  padding: 0 22px;
}

.credentials-row button:disabled {
  background: #5f6661;
  color: #c7d0cb;
  cursor: not-allowed;
}

.create-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
  margin: 0;
  border: 1px solid #30383b;
  border-radius: 6px;
  padding: 10px;
}

.create-options[hidden] {
  display: none;
}

.create-options legend {
  padding: 0 4px;
  color: #87d9ca;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.create-options label {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
  border: 1px solid #30383b;
  border-radius: 6px;
  background: #151a1b;
  color: #e2e9e6;
  cursor: pointer;
  font-weight: 750;
  padding: 8px 10px;
}

.create-options input {
  width: 16px;
  height: 16px;
  accent-color: #dfc64a;
}

.form-message {
  color: #b4bfbb;
  font-size: 0.86rem;
  line-height: 1.4;
}

.form-message:empty {
  display: none;
}

.form-message[data-state="error"] {
  color: #ff9c8d;
}

.form-message[data-state="success"] {
  color: #9ae7ad;
}

.connection-details {
  border-top: 1px solid rgba(61, 70, 72, 0.72);
  padding-top: 10px;
}

.connection-details summary {
  color: #b8c2bd;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 750;
  list-style-position: inside;
}

.connection-details label {
  margin-top: 10px;
}

@media (max-width: 620px) {
  .credentials-row {
    grid-template-columns: 1fr;
  }

  .credentials-row button {
    width: 100%;
  }

  .create-options {
    grid-template-columns: 1fr 1fr;
  }
}

.status-grid {
  position: fixed;
  z-index: 20;
  top: 16px;
  right: 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
}

@media (max-width: 940px) {
  .status-grid {
    top: auto;
    right: 16px;
    bottom: 16px;
    left: 16px;
    width: auto;
  }
}

.status-card {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  min-width: 0;
  border: 1px solid #2f383a;
  border-radius: 8px;
  background: rgba(18, 22, 23, 0.94);
  padding: 12px;
}

.status-card[hidden] {
  display: none;
}

.status-card-with-action {
  grid-template-columns: 14px minmax(0, 1fr) auto;
  align-items: center;
}

.status-card-with-action .status-light {
  align-self: start;
}

.status-card-with-action button {
  min-height: 34px;
  border: 1px solid #4b575b;
  border-radius: 6px;
  background: #22282a;
  color: #f2f5f3;
  cursor: pointer;
  font-weight: 800;
  padding: 0 12px;
  white-space: nowrap;
}

.status-card-with-action button:disabled {
  color: #9aa5a0;
  cursor: default;
}

@media (max-width: 520px) {
  .status-card-with-action {
    grid-template-columns: 14px minmax(0, 1fr);
  }

  .status-card-with-action button {
    grid-column: 2;
    justify-self: start;
  }
}

.status-light {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 999px;
  background: #e1c542;
  box-shadow: 0 0 0 4px rgba(225, 197, 66, 0.16);
}

.status-card[data-webgpu-state="available"] .status-light,
.status-card[data-module-state="ready"] .status-light,
.status-card[data-module-state="running"] .status-light,
.status-card[data-audio-state="ready"] .status-light {
  background: #55d17c;
  box-shadow: 0 0 0 4px rgba(85, 209, 124, 0.16);
}

.status-card[data-webgpu-state="unavailable"] .status-light,
.status-card[data-webgpu-state="error"] .status-light,
.status-card[data-module-state="build-required"] .status-light,
.status-card[data-module-state="aborted"] .status-light,
.status-card[data-module-state="error"] .status-light,
.status-card[data-audio-state="unavailable"] .status-light {
  background: #f0745e;
  box-shadow: 0 0 0 4px rgba(240, 116, 94, 0.16);
}

h2 {
  font-size: 0.98rem;
  line-height: 1.35;
}

.status-card p {
  margin-top: 3px;
  color: #b4bfbb;
  font-size: 0.9rem;
  line-height: 1.45;
}

.diagnostics-panel {
  position: fixed;
  z-index: 30;
  right: 12px;
  bottom: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  width: min(780px, calc(100vw - 24px));
  max-height: min(50dvh, 420px);
  overflow: auto;
  border: 1px solid #30383b;
  border-radius: 8px;
  background: #181c1e;
  padding: 12px 14px;
}

.diagnostics-panel[hidden] {
  display: none;
}

.diagnostics-panel pre {
  margin: 6px 0 0;
  overflow: auto;
  color: #cfd8d4;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.diagnostics-panel button {
  min-height: 34px;
  border: 1px solid #4b575b;
  border-radius: 6px;
  background: #22282a;
  color: #f2f5f3;
  cursor: pointer;
  font-weight: 800;
  padding: 0 12px;
  white-space: nowrap;
}

@media (max-width: 620px) {
  .diagnostics-panel {
    grid-template-columns: 1fr;
  }

  .diagnostics-panel button {
    justify-self: start;
  }
}

.client-stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: grid;
  place-items: center;
  min-height: 100dvh;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #020303;
}

.client-stage canvas {
  display: block;
  width: min(100vw, calc(100dvh * 4 / 3));
  height: min(100dvh, calc(100vw * 3 / 4));
  max-width: 100vw;
  max-height: 100dvh;
}

.native-log {
  position: fixed;
  z-index: 20;
  left: 12px;
  bottom: 12px;
  width: min(760px, calc(100vw - 24px));
  min-height: 76px;
  max-height: min(24dvh, 180px);
  overflow: auto;
  border: 1px solid #30383b;
  border-radius: 8px;
  background: #181c1e;
  color: #cfd8d4;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  padding: 10px;
}

.native-log:empty {
  display: none;
}

body[data-module-state="running"] .topbar,
body[data-module-state="running"] .status-grid,
body[data-module-state="running"] .native-log {
  display: none;
}
