:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #17191c;
  --muted: #5f6670;
  --line: #e2e5ea;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.14);
  --ok: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --radius: 10px;
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --text: #e8eaed;
    --muted: #9aa1ab;
    --line: #2a2f38;
    --accent: #60a5fa;
    --accent-soft: rgba(96, 165, 250, 0.16);
    --ok: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
code { font: 12px ui-monospace, SFMono-Regular, Consolas, monospace; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 24px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.brand h1 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
.brand p { margin: 2px 0 0; color: var(--muted); }
.status {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: 999px; white-space: nowrap; color: var(--muted);
}
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.status[data-state="ready"] .dot { background: var(--ok); }
.status[data-state="error"] .dot { background: var(--bad); }
.status[data-state="error"] { color: var(--bad); }

.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px;
  padding: 20px 24px; max-width: 1400px; margin: 0 auto;
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.viewport {
  position: relative; display: grid; place-items: center; min-height: 420px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.viewport canvas { display: block; max-width: 100%; max-height: 72vh; touch-action: none; }
.viewport[data-empty="true"] canvas { display: none; }
.viewport[data-empty="false"] .drop { display: none; }
.viewport.dragover { outline: 2px dashed var(--accent); outline-offset: -8px; }
.drop {
  display: grid; gap: 4px; text-align: center; padding: 48px; cursor: pointer; color: var(--muted);
}
.drop strong { color: var(--text); font-size: 16px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.toolbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.toolbar .label { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.hint { color: var(--muted); margin: 8px 2px 0; font-size: 13px; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; padding: 6px 12px; border-radius: 8px; cursor: pointer; line-height: 1.4;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: default; border-color: var(--line); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.small { padding: 3px 10px; font-size: 13px; }
.chip { padding: 3px 10px; font-size: 13px; border-radius: 999px; }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }

.panel { display: grid; gap: 14px; align-content: start; }
.group {
  margin: 0; padding: 14px 16px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.group legend, .group h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 0; padding: 0; }
fieldset.group legend { float: left; width: 100%; margin-bottom: 10px; }
.field { display: grid; gap: 4px; margin-bottom: 10px; clear: both; }
.field span { font-size: 13px; color: var(--muted); }
select {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 8px;
}
.check { display: flex; align-items: center; gap: 8px; }
.progress { height: 4px; margin-top: 12px; background: var(--line); border-radius: 2px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width 0.15s; }

.corners { width: 100%; border-collapse: collapse; margin-top: 8px; font-variant-numeric: tabular-nums; }
.corners th, .corners td { padding: 4px 0; text-align: right; border-bottom: 1px solid var(--line); }
.corners th:first-child { text-align: left; font-weight: 500; }
.corners thead th { color: var(--muted); font-weight: 500; font-size: 12px; }
.corners td.missing { color: var(--warn); }
.timings { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; margin: 12px 0 0; font-variant-numeric: tabular-nums; }
.timings dt { color: var(--muted); }
.timings dd { margin: 0; text-align: right; }
.timings .total { font-weight: 600; color: var(--text); }

.row-head { display: flex; align-items: center; justify-content: space-between; }
.flat-wrap {
  display: grid; place-items: center; min-height: 160px; margin-top: 10px;
  background: var(--bg); border-radius: 8px; overflow: hidden;
}
.flat-wrap canvas { display: block; max-width: 100%; max-height: 420px; }

.site-footer {
  display: flex; justify-content: center; gap: 8px; padding: 8px 24px 28px;
  color: var(--muted); font-size: 13px;
}
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover, .site-footer a[aria-current="page"] { color: var(--text); text-decoration: underline; }

.brand h1 a { color: inherit; text-decoration: none; }
.top > a.btn { text-decoration: none; white-space: nowrap; }
.legal { max-width: 760px; margin: 0 auto; padding: 20px 24px; }
.legal .group { padding: 24px 28px; }
.legal h1 { margin: 0 0 12px; font-size: 22px; letter-spacing: -0.01em; }
.legal h2 { margin: 24px 0 6px; font-size: 15px; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--text); }
.legal p { margin: 0 0 10px; }
.legal a { color: var(--accent); }
