:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #111111;
  background: #ffffff;
  --surface: #ffffff;
  --surface-subtle: #f6f6f6;
  --border: #d9d9d9;
  --border-strong: #9c9c9c;
  --muted: #686868;
  --success: #0b7657;
  --danger: #b42318;
  --warning: #8a5700;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 20rem;
  min-height: 100%;
  margin: 0;
  background: #ffffff;
}

body {
  padding: clamp(1rem, 3vw, 2.5rem);
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

main {
  display: grid;
  width: min(100%, 76rem);
  margin: 0 auto;
  gap: 1rem;
}

.page-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 2rem;
  padding: 0.2rem 0 0.65rem;
  border-bottom: 1px solid #111111;
}

.eyebrow,
.summary-kicker {
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.4rem;
  font-size: clamp(1.65rem, 4vw, 2.55rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.3;
}

.lede,
.summary-message,
.caption,
.allocation-panel > p,
.allocation-message {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

.back-link {
  flex: none;
  padding: 0.5rem 0;
  font-size: 0.78rem;
  font-weight: 700;
  text-underline-offset: 0.2rem;
}

.summary,
.preview-panel,
.checks-panel,
.allocation-panel,
.details-panel {
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  background: var(--surface);
}

.summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.8rem;
  align-items: start;
  padding: 1rem;
}

.summary-dot {
  width: 0.72rem;
  height: 0.72rem;
  margin-top: 0.18rem;
  border-radius: 50%;
  background: #999999;
  box-shadow: 0 0 0 0.25rem rgba(0, 0, 0, 0.06);
}

.summary-dot[data-state="ready"] {
  background: var(--success);
  box-shadow: 0 0 0 0.25rem rgba(11, 118, 87, 0.11);
}

.summary-dot[data-state="error"],
.summary-dot[data-state="context-lost"] {
  background: var(--danger);
  box-shadow: 0 0 0 0.25rem rgba(180, 35, 24, 0.11);
}

.diagnostic-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(19rem, 0.75fr);
  gap: 1rem;
}

.preview-panel,
.checks-panel,
.allocation-panel {
  padding: 1rem;
}

.section-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.state-pill {
  flex: none;
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: #ffffff;
  color: #4f4f4f;
  font-size: 0.68rem;
  font-weight: 750;
}

.state-pill[data-state="ready"] {
  border-color: var(--success);
  color: var(--success);
}

.state-pill[data-state="error"],
.state-pill[data-state="context-lost"] {
  border-color: var(--danger);
  color: var(--danger);
}

.state-pill[data-state="running"] {
  border-color: var(--warning);
  color: var(--warning);
}

.preview-shell {
  position: relative;
  min-height: 22rem;
  overflow: hidden;
  border: 1px solid #111111;
  border-radius: 0.35rem;
  background: #050505;
}

#gpu-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 22rem;
}

.preview-labels {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  pointer-events: none;
}

.preview-labels span {
  align-self: start;
  justify-self: start;
  margin: 0.45rem;
  padding: 0.18rem 0.32rem;
  border-radius: 0.2rem;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  font-size: 0.62rem;
  font-weight: 700;
}

.caption {
  margin-top: 0.65rem;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 0;
}

.check-card {
  min-width: 0;
  padding: 0.7rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: var(--surface-subtle);
}

.check-card dt {
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
}

.check-card dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.35;
}

.allocation-panel {
  display: grid;
  gap: 0.8rem;
}

.allocation-heading,
.allocation-panel > p {
  margin-bottom: 0;
}

.allocation-controls {
  display: flex;
  align-items: end;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.allocation-controls label {
  display: grid;
  gap: 0.25rem;
  width: 7rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.allocation-controls input,
.allocation-controls button {
  min-height: 2.35rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.35rem;
  background: #ffffff;
  color: #111111;
}

.allocation-controls input {
  width: 100%;
  padding: 0 0.55rem;
  font-variant-numeric: tabular-nums;
}

.allocation-controls button {
  padding: 0.45rem 0.8rem;
  cursor: pointer;
  font-weight: 750;
}

.allocation-controls button:hover:not(:disabled) {
  border-color: #111111;
  background: #f1f1f1;
}

.allocation-controls button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.allocation-controls input:focus-visible,
.allocation-controls button:focus-visible,
.back-link:focus-visible,
summary:focus-visible {
  outline: 2px solid #111111;
  outline-offset: 2px;
}

.dimension-mark {
  padding-bottom: 0.55rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.memory-warning {
  display: flex;
  align-items: baseline;
  gap: 0.5rem 1rem;
  flex-wrap: wrap;
  padding: 0.65rem 0.75rem;
  border-left: 3px solid var(--warning);
  background: #fffaf0;
  color: #4e3900;
  font-size: 0.75rem;
  line-height: 1.45;
}

.memory-warning strong {
  font-variant-numeric: tabular-nums;
}

.allocation-message[data-state="ready"] {
  color: var(--success);
}

.allocation-message[data-state="error"] {
  color: var(--danger);
}

.details-panel {
  overflow: hidden;
}

.details-panel summary {
  padding: 0.8rem 1rem;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 750;
}

.details-panel pre {
  max-height: 28rem;
  margin: 0;
  overflow: auto;
  padding: 1rem;
  border-top: 1px solid var(--border);
  background: #111111;
  color: #f5f5f5;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.72rem;
  line-height: 1.55;
  tab-size: 2;
}

@media (max-width: 880px) {
  .diagnostic-layout {
    grid-template-columns: 1fr;
  }

  .preview-shell,
  #gpu-canvas {
    min-height: 18rem;
  }
}

@media (max-width: 560px) {
  body {
    padding: 0.75rem;
  }

  .page-header {
    display: grid;
    gap: 0.5rem;
  }

  .back-link {
    justify-self: start;
  }

  .check-grid {
    grid-template-columns: 1fr;
  }

  .allocation-controls label {
    width: calc((100% - 2rem) / 3);
  }

  .allocation-controls button {
    width: 100%;
  }

  .preview-shell,
  #gpu-canvas {
    min-height: 15rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}
