:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1d232b;
  --muted: #5d6673;
  --line: #dde1e6;
  --accent: #2f7d4f;
  --accent-text: #ffffff;
  --error: #b3261e;
  --error-bg: #fdecea;
  --warn: #8a5a00;
  --warn-bg: #fff4dc;
  --ok: #2f7d4f;
  --ok-bg: #e6f4ea;
  --bed: #e9ecef;
  --grid: #d3d8de;
  --obj: #46a36b;
  --obj-flag: #d6a300;
  --lane: rgba(214, 64, 48, 0.12);
  --strike: #d64030;
  --sweep: #5b7fb8;
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171b;
    --card: #1d2127;
    --text: #e6e9ed;
    --muted: #9aa3ae;
    --line: #333a43;
    --accent: #46a36b;
    --error: #ff8a80;
    --error-bg: #3a1f1d;
    --warn: #ffcc66;
    --warn-bg: #3a2f18;
    --ok: #7fd39b;
    --ok-bg: #1c3324;
    --bed: #2a3038;
    --grid: #39414b;
    --obj: #58b97e;
    --obj-flag: #e8c04a;
    --lane: rgba(255, 110, 90, 0.14);
    --strike: #ff6e5a;
    --sweep: #85a5dc;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

.page-head, main, .page-foot {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 16px;
}

.page-head h1 { margin: 28px 0 4px; font-size: 26px; }
.page-head p { margin: 0 0 20px; color: var(--muted); }

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

.card h2 { margin: 0 0 12px; font-size: 18px; display: flex; align-items: center; gap: 10px; }
.num {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); font-size: 14px;
}

.drop {
  display: flex; flex-direction: column; gap: 6px; align-items: center; justify-content: center;
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 28px 16px; text-align: center; cursor: pointer;
}
.drop:hover, .drop.over { border-color: var(--accent); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.drop-hint { color: var(--muted); font-size: 13px; }

.status { margin: 10px 0 0; min-height: 1.5em; }
.status.error { color: var(--error); }
.status.ok { color: var(--ok); }

.info {
  display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 12px;
}
.info dt { color: var(--muted); }
.info dd { margin: 0; overflow-wrap: anywhere; }
.info dd.ok { color: var(--ok); font-weight: 600; }
.info dd.bad { color: var(--error); font-weight: 600; }

.problems, .changes { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.problems li { padding: 8px 12px; border-radius: 8px; }
.problems li.error { background: var(--error-bg); color: var(--error); }
.problems li.warning { background: var(--warn-bg); color: var(--warn); }
.problems li.ok { background: var(--ok-bg); color: var(--ok); }
.changes li { padding-left: 18px; position: relative; }
.changes li::before { content: "•"; position: absolute; left: 4px; color: var(--accent); }

.preview-box { margin: 0; }
.preview { width: 100%; max-width: 560px; display: block; margin: 0 auto; }
.preview .bed { fill: var(--bed); }
.preview .grid { stroke: var(--grid); stroke-width: 0.3; }
.preview .obj-hull { fill: var(--obj); fill-opacity: 0.75; stroke: var(--obj); stroke-width: 0.6; }
.preview .obj-hull.flagged { fill: var(--obj-flag); stroke: var(--obj-flag); }
.preview .obj-box { fill: none; stroke: var(--muted); stroke-width: 0.4; stroke-dasharray: 2 1.5; }
.preview .obj-label { font-size: 9px; font-weight: 700; fill: var(--card); }
.preview .lane { fill: var(--lane); }
.preview .strike { stroke: var(--strike); stroke-width: 1.2; }
.preview .arrow-head { fill: var(--strike); }
.preview .head-face { stroke: var(--strike); stroke-width: 1.6; stroke-linecap: round; }
.preview .nozzle { fill: var(--strike); }
.preview .sweep { stroke: var(--sweep); stroke-width: 0.6; stroke-dasharray: 3 2; }
.preview .sweep-num { font-size: 5px; fill: var(--sweep); }
.preview .park { fill: var(--muted); }
.preview .nogo { fill: var(--error); fill-opacity: 0.18; stroke: var(--error); stroke-width: 0.4; stroke-dasharray: 1.5 1; }
.preview .edge-label { font-size: 6px; fill: var(--muted); }
.preview .small-label { font-size: 4.5px; fill: var(--muted); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center; font-size: 13px; color: var(--muted); margin-top: 8px; }
.sw { display: inline-block; width: 14px; height: 10px; margin-right: 6px; vertical-align: -1px; border-radius: 2px; }
.sw-obj { background: var(--obj); }
.sw-lane { background: var(--lane); border: 1px solid var(--strike); }
.sw-strike { height: 3px; background: var(--strike); vertical-align: 3px; }
.sw-sweep { height: 0; border-top: 2px dashed var(--sweep); vertical-align: 3px; }

.options fieldset { border: 0; border-top: 1px solid var(--line); margin: 0; padding: 12px 0 10px; }
.options fieldset:first-child { border-top: 0; padding-top: 0; }
.options legend { font-weight: 600; padding: 0; margin-bottom: 6px; }
.check { display: flex; gap: 8px; align-items: baseline; margin: 6px 0; }
.check input { flex: none; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; font-size: 14px; color: var(--muted); }
.field input { width: 140px; }
.row { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0; }
.hint:empty { display: none; }
details { margin-top: 6px; }
summary { cursor: pointer; color: var(--muted); font-size: 14px; }

input[type="number"] {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px;
}
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

button {
  font: inherit; cursor: pointer; border-radius: 8px; padding: 8px 14px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; }

.time { font-weight: 600; }
.acks { margin: 12px 0; }
.blocked .changes, .blocked .time { opacity: 0.5; }

.report { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; justify-content: space-between; }
.report p { margin: 0; }

dialog {
  max-width: 520px; width: calc(100% - 32px);
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--text); padding: 18px 20px;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog h2 { margin-top: 0; font-size: 18px; }
.dialog-buttons { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

.page-foot { color: var(--muted); font-size: 13px; padding-bottom: 28px; }
.page-foot a { color: var(--accent); }

[hidden] { display: none !important; }

@media (max-width: 520px) {
  .info { grid-template-columns: 1fr; }
  .info dd { margin-bottom: 6px; }
}
