:root {
  --bg: #0e1013;
  --panel: #171a1f;
  --panel-2: #1e222a;
  --line: #2a2f38;
  --text: #e6e9ef;
  --muted: #9aa3b2;
  --accent: #5b9dff;
  --ok: #3fbf7f;
  --warn: #e0a53a;
  --bad: #ef5f6b;
  --radius: 10px;
  --rail: 340px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f9;
    --panel: #ffffff;
    --panel-2: #f0f2f6;
    --line: #dfe3ea;
    --text: #171a1f;
    --muted: #5f6875;
    --accent: #1f6feb;
  }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 ui-sans-serif, -apple-system, "SF Pro Text", Inter, system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: none;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand .mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .02em;
}

.brand h1 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.brand p { margin: 0; font-size: 12px; color: var(--muted); }

.topbar-actions { display: flex; gap: 8px; }

/* ---------- layout ---------- */

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr var(--rail);
}

.stage-wrap {
  position: relative;
  min-width: 0;
  background:
    repeating-conic-gradient(var(--panel-2) 0% 25%, transparent 0% 50%) 50% / 24px 24px;
  overflow: hidden;
}

#stage { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#stage.dragging { cursor: grabbing; }

.stage-hint {
  position: absolute;
  left: 50%; bottom: 14px;
  transform: translateX(-50%);
  background: rgba(0,0,0,.62);
  color: #fff;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  pointer-events: none;
  backdrop-filter: blur(6px);
}

.stage-hint kbd {
  background: rgba(255,255,255,.16);
  border-radius: 4px;
  padding: 0 4px;
  font: inherit;
}

/* ---------- dropzone ---------- */

.dropzone {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  z-index: 5;
}

.dropzone[hidden] { display: none; }
.dropzone.over .dz-inner { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }

.dz-inner {
  text-align: center;
  padding: 44px 52px;
  border: 2px dashed var(--line);
  border-radius: 16px;
  max-width: 460px;
  transition: border-color .15s, background .15s;
}

.dz-inner svg {
  width: 44px; height: 44px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dz-inner h2 { margin: 12px 0 4px; font-size: 17px; font-weight: 620; }
.dz-inner p { margin: 0 0 18px; color: var(--muted); font-size: 13px; }

/* ---------- rail ---------- */

.rail {
  border-left: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.panel h3 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}

.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.panel-head h3 { margin: 0; }

.detect-status {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--muted);
  min-height: 18px;
}
.detect-status.ok { color: var(--ok); }
.detect-status.bad { color: var(--bad); }

/* ---------- fields ---------- */

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 560;
  margin-bottom: 6px;
}

.field .hint { color: var(--muted); font-weight: 400; }

.field .row { display: flex; align-items: center; gap: 10px; }
.field .row.nudge { justify-content: space-between; }

.field output {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text);
  min-width: 62px;
  text-align: right;
}

.field.inline { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.field.inline label { margin: 0; }

.scale-note { font-size: 11px; color: var(--muted); margin-top: 5px; }

input[type=range] {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent);
}

input[type=range]:disabled { opacity: .4; }

select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 8px;
  font: inherit;
  font-size: 12px;
}

/* ---------- checks ---------- */

.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.checks .empty { color: var(--muted); font-size: 12px; }

.checks li.check-row {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  gap: 8px;
  align-items: baseline;
  font-size: 12px;
}

.checks .dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  align-self: center;
  background: var(--muted);
}
.checks .ok .dot { background: var(--ok); }
.checks .warn .dot { background: var(--warn); }
.checks .bad .dot { background: var(--bad); }

.checks .label { color: var(--text); }
.checks .req { grid-column: 2; font-size: 11px; color: var(--muted); }
.checks .value { font-variant-numeric: tabular-nums; color: var(--muted); }
.checks .ok .value { color: var(--ok); }
.checks .warn .value { color: var(--warn); }
.checks .bad .value { color: var(--bad); }

.disclaimer { font-size: 11px; color: var(--muted); margin: 12px 0 0; }
.disclaimer a { color: var(--accent); }

/* ---------- output ---------- */

.sheet-preview {
  background: #6b7280;
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 10px;
}
.sheet-preview canvas { display: block; width: 100%; height: auto; border-radius: 2px; }

.opts { display: flex; gap: 14px; margin-bottom: 12px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 12px; cursor: pointer; }
.check input { accent-color: var(--accent); }

.exports { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.export-note { font-size: 11px; color: var(--muted); margin: 8px 0 0; }

/* ---------- buttons ---------- */

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  padding: 7px 13px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s, border-color .12s, opacity .12s;
  text-align: center;
}

.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: .42; cursor: default; }

.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }

.btn.small { font-size: 12px; padding: 5px 10px; }
.btn.tiny { font-size: 11px; padding: 4px 9px; }
.btn.ghost { background: transparent; }

label.btn { display: inline-block; }

@media (max-width: 900px) {
  body { overflow: auto; }
  .layout { grid-template-columns: 1fr; }
  .stage-wrap { height: 60vh; }
  .rail { border-left: none; border-top: 1px solid var(--line); overflow: visible; }
}
