:root {
  color-scheme: light dark;
  font-family: system-ui, sans-serif;
  --background: #f4f6f9;
  --surface: #fff;
  --text: #172236;
  --secondary: #43536b;
  --border: #d3dbe6;
  --accent: #1746ab;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background: #111720;
    --surface: #1a2330;
    --text: #f0f4fb;
    --secondary: #c0cce0;
    --border: #3e4c60;
    --accent: #aac4ff;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
}

main {
  width: min(100%, 40rem);
  margin-inline: auto;
  padding: clamp(1rem, 5vw, 2.5rem);
}

section {
  padding: clamp(1rem, 4vw, 1.5rem);
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--surface);
}

.state, .diagnostics-header {
  display: flex;
  align-items: center;
  gap: .75rem;
}

h1, h2, pre { margin: 0; }
h1 { font-size: clamp(1.35rem, 5vw, 1.8rem); }
h2 { font-size: 1rem; }
p, ol { line-height: 1.5; }
ol { padding-inline-start: 1.4rem; }
li + li { margin-top: .5rem; }
a { color: var(--accent); text-underline-offset: .18em; }

button {
  min-height: 44px;
  margin-top: 1rem;
  padding: .55rem .85rem;
  border: 1px solid var(--accent);
  border-radius: .5rem;
  background: var(--accent);
  color: var(--surface);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.diagnostics { margin-top: 1rem; }
.diagnostics-header { justify-content: space-between; flex-wrap: wrap; }

.diagnostics button {
  margin: 0;
  background: var(--surface);
  color: var(--accent);
}

pre, output {
  color: var(--secondary);
  font: .8125rem/1.6 ui-monospace, Menlo, Consolas, monospace;
}

pre {
  margin-top: .75rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

output:not(:empty) { display: block; margin-top: .5rem; }

.spinner {
  flex: 0 0 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
