:root {
  color-scheme: dark;
  --bg: #0f1117;
  --card: #181b24;
  --border: #2a2f3d;
  --text: #e6e8ef;
  --muted: #9aa1b2;
  --accent: #7c9cff;
  --accent-2: #f4a261;
  --error: #ff6b6b;
  --ok: #5fd39a;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

header { padding-top: 40px; padding-bottom: 8px; }
h1 { margin: 0 0 8px; font-size: clamp(1.6rem, 4vw, 2.3rem); }
h2 { margin: 0 0 14px; font-size: 1.1rem; }
h3 { margin: 0 0 4px; font-size: 1rem; color: var(--accent); }
.lead { margin: 0; color: var(--muted); max-width: 70ch; }
code { background: #232838; padding: 1px 5px; border-radius: 4px; font-size: .9em; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin: 16px 0;
}

.explain summary { cursor: pointer; font-weight: 600; }
.explain p { color: var(--muted); }
.two { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.sources { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.field > span { color: var(--muted); font-size: .9rem; }
.row { display: flex; align-items: center; gap: 8px; }
.row input { width: 5.5em; }

select, input, button { font: inherit; color: inherit; }
select, input[type=number], input[type=file] {
  background: #11141b;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 0;
}
input[type=file] { padding: 6px; }

button {
  border: 0;
  border-radius: 8px;
  padding: 9px 16px;
  background: var(--accent);
  color: #0b0d12;
  font-weight: 600;
  cursor: pointer;
}
button.accent { background: var(--accent-2); }
button.secondary { background: #262b39; color: var(--text); border: 1px solid var(--border); }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, select:focus-visible, input:focus-visible, .segmented input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: block; padding: 8px 14px; cursor: pointer; color: var(--muted); }
.segmented input:checked + span { background: #262b39; color: var(--text); }

.status { min-height: 1.5em; margin: 14px 0 0; color: var(--muted); }
.status.error { color: var(--error); white-space: pre-line; }
.status.busy::before {
  content: "";
  display: inline-block;
  width: 14px; height: 14px;
  margin-right: 8px;
  vertical-align: -2px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.timings { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-top: 12px; }
.timing {
  text-align: left;
  background: #11141b;
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 400;
  padding: 12px 14px;
}
.timing[aria-pressed=true] { border-color: var(--accent); }
.timing strong { display: block; font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.timing small { color: var(--muted); }
.timing .bar { height: 6px; border-radius: 3px; background: var(--accent); margin-top: 8px; }
.verdict { grid-column: 1 / -1; margin: 0; color: var(--muted); }
.verdict .ok { color: var(--ok); }
.verdict .ko { color: var(--error); }

.images { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.images .card { margin: 0; }
figcaption { font-weight: 600; margin-bottom: 10px; }
figcaption span { color: var(--muted); font-weight: 400; }
.canvas-box {
  display: grid;
  place-items: center;
  min-height: 200px;
  background: repeating-conic-gradient(#14171f 0 25%, #1a1e28 0 50%) 0 0 / 20px 20px;
  border-radius: 8px;
  overflow: hidden;
}
canvas { display: block; width: 100%; height: auto; max-height: 70vh; object-fit: contain; image-rendering: pixelated; }
.downloads { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

footer { padding-top: 8px; padding-bottom: 40px; color: var(--muted); }
footer a { color: var(--accent); }
