:root {
  color-scheme: light;
  --surface-0: #f6f6f4;
  --surface-1: #ffffff;
  --surface-2: #efefef;
  --line: #e2e2e2;
  --grid: #ececec;
  --text-primary: #191919;
  --text-secondary: #5f5f5f;
  --accent: #1b64be;
  --on-accent: #ffffff;
  --series-1: #257de0;
  --critical: #c22f30;
  --warning-bg: #fff5dd;
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface-0: #121212;
    --surface-1: #191919;
    --surface-2: #262626;
    --line: #333333;
    --grid: #2c2c2c;
    --text-primary: #efefef;
    --text-secondary: #a3a3a3;
    --accent: #6aabf1;
    --on-accent: #0b1a2b;
    --series-1: #338ced;
    --critical: #eb6263;
    --warning-bg: #3a2f12;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-family: var(--font); font-size: 16px; line-height: 1.5; }
body { margin: 0; background: var(--surface-0); color: var(--text-primary); }
a { color: var(--accent); }
code { font-family: var(--mono); font-size: 0.9em; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 20px; }
.top { background: var(--surface-1); border-bottom: 1px solid var(--line); padding: 20px 0 14px; }
.top h1 { margin: 0 0 4px; font-size: 1.6rem; letter-spacing: -0.01em; }
.lede { margin: 0 0 10px; max-width: 760px; color: var(--text-secondary); }
.engine { margin: 0; font-size: 0.92rem; }
body[data-engine=loading] .engine::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-secondary); margin-right: 8px; animation: pulse 1.2s infinite; }
body[data-engine=ready] .engine::before { content: "\2713"; margin-right: 6px; }
body[data-engine=failed] .engine { color: var(--critical); }
@keyframes pulse { 50% { opacity: 0.25; } }
.privacy { margin: 4px 0 0; font-size: 0.85rem; color: var(--text-secondary); }
.layout { display: grid; grid-template-columns: minmax(280px, 340px) 1fr; gap: 20px; padding-top: 20px; padding-bottom: 20px; align-items: start; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }
.panel { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
fieldset { border: 0; margin: 0 0 14px; padding: 0; min-width: 0; }
legend { font-weight: 600; font-size: 1rem; margin-bottom: 8px; padding: 0; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; min-width: 0; }
.field label, .label { font-size: 0.88rem; color: var(--text-secondary); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input, select { font: inherit; font-size: 0.95rem; color: var(--text-primary); background: var(--surface-1);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; width: 100%; min-width: 0; }
input[type=radio] { width: auto; }
input[type=file] { padding: 4px; }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field.error input, .field.error select { border-color: var(--critical); }
.field-error { color: var(--critical); font-size: 0.82rem; margin: 0; }
.radios { display: flex; flex-direction: column; gap: 2px; font-size: 0.92rem; }
.radios label { color: var(--text-primary); display: flex; gap: 6px; align-items: center; }
.hint { font-size: 0.82rem; color: var(--text-secondary); margin: 2px 0 8px; }
.hint.warn { background: var(--warning-bg); color: var(--text-primary); padding: 6px 8px; border-radius: 6px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px 0 14px; }
.tabs button { font: inherit; font-size: 0.92rem; background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 8px 10px; color: var(--text-secondary); cursor: pointer; }
.tabs button[aria-selected=true] { color: var(--text-primary); border-bottom-color: var(--accent); font-weight: 600; }
.intro { margin: 0 0 12px; }
.actions { display: flex; align-items: center; gap: 12px; margin: 6px 0 16px; }
button.primary { font: inherit; font-weight: 600; background: var(--accent); color: var(--on-accent); border: 0; border-radius: 6px;
  padding: 8px 18px; cursor: pointer; }
button.primary:disabled { opacity: 0.5; cursor: default; }
#status { font-size: 0.9rem; color: var(--text-secondary); }
.result { border-top: 1px solid var(--line); padding-top: 14px; }
.headline { font-size: 1.05rem; margin: 0 0 6px; }
.big { font-size: 2rem; font-weight: 650; line-height: 1.15; margin: 4px 0; font-variant-numeric: tabular-nums; }
.muted { color: var(--text-secondary); font-size: 0.88rem; }
.errorbox { border: 1px solid var(--critical); border-radius: 6px; padding: 10px 12px; }
.errorbox pre { white-space: pre-wrap; margin: 0; font-family: var(--mono); font-size: 0.85rem; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; margin: 8px 0 12px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th .n { display: block; font-weight: 400; }
th { font-weight: 600; color: var(--text-secondary); font-size: 0.84rem; }
td.num, th.num { text-align: right; }
.tablewrap { overflow-x: auto; }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 8px 0 4px; }
@media (max-width: 640px) { .charts { grid-template-columns: 1fr; } }
figure { margin: 0; }
figcaption { font-weight: 600; font-size: 0.92rem; margin-bottom: 2px; }
figure .sub { font-size: 0.8rem; color: var(--text-secondary); margin: 0 0 4px; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart text { font-family: var(--font); fill: var(--text-secondary); font-size: 11px; }
svg.chart text.value { fill: var(--text-primary); font-weight: 600; }
svg.chart .grid { stroke: var(--grid); stroke-width: 1; }
svg.chart .axis { stroke: var(--line); stroke-width: 1; }
svg.chart .ref { stroke: var(--text-secondary); stroke-width: 1; }
svg.chart .mark { fill: var(--series-1); }
svg.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; }
svg.chart .dot { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; }
svg.chart .hit { fill: transparent; cursor: default; }
svg.chart .hit:focus { outline: none; }
svg.chart .hit:focus-visible, svg.chart .hit.active { fill: var(--text-primary); fill-opacity: 0.05; }
details { margin: 10px 0 0; }
summary { cursor: pointer; font-size: 0.9rem; color: var(--text-secondary); }
pre.out { background: var(--surface-2); border-radius: 6px; padding: 10px 12px; overflow-x: auto; font-family: var(--mono);
  font-size: 0.8rem; line-height: 1.45; margin: 6px 0 0; }
.cmd { display: flex; gap: 8px; align-items: flex-start; margin-top: 6px; }
.cmd pre.out { flex: 1; margin: 0; white-space: pre-wrap; word-break: break-word; }
.cmd button { font: inherit; font-size: 0.82rem; background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--line);
  border-radius: 6px; padding: 5px 10px; cursor: pointer; }
.tag { display: inline-block; font-size: 0.75rem; border: 1px solid var(--line); border-radius: 10px; padding: 0 7px; color: var(--text-secondary); }
td.target { font-weight: 650; }
.tip { position: fixed; z-index: 10; pointer-events: none; background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; font-size: 0.82rem; box-shadow: 0 2px 10px rgba(0,0,0,0.12); max-width: 260px; }
.foot { padding-bottom: 28px; font-size: 0.85rem; color: var(--text-secondary); }
.foot p { margin: 4px 0; }
@media print {
  .top .engine, .top .privacy, .inputs, .tabs, .actions, details, .cmd button { display: none !important; }
  .layout { display: block; }
  .panel { border: 0; padding: 0; }
}
