:root{
  --bg: #ffffff;
  --text: #0b1220;
  --muted: #6b7280;
  --line: rgba(15, 23, 42, 0.14);
  --soft: rgba(15, 23, 42, 0.06);

  --accent: #2563eb;
  --danger: #dc2626;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  padding:14px;
  background:var(--bg);
  color:var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

/* Header */
.topbar{
  display:flex;
  justify-content:space-between;
  align-items:flex-end;
  gap:12px;
  padding-bottom:10px;
  margin-bottom:12px;
  border-bottom:1px solid var(--line);
}

.brand .name{
  font-weight:700;
  font-size:16px;
  letter-spacing:.2px;
}
.brand .sub{
  margin-top:2px;
  font-size:12px;
  color:var(--muted);
}

.stats{
  display:flex;
  gap:12px;
  align-items:center;
  font-size:12px;
  color:var(--muted);
}
.stats strong{
  color:var(--text);
  font-weight:700;
}

/* Layout */
.layout{
  display:grid;
  grid-template-columns: 520px minmax(0, 1fr);
  gap:16px;
  align-items:start;
}

/* Controls: simple “rail” */
.controls{
  padding-right:14px;
  border-right:1px solid var(--line);
}

hr{
  border:none;
  border-top:1px solid var(--line);
  margin:12px 0;
}

.row{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:flex-end;
  margin-bottom:10px;
}

.field{
  display:grid;
  gap:6px;
}
.field span{
  font-size:11px;
  color:var(--muted);
}
.field.grow{
  flex:1;
  min-width:180px;
}

.stats button{
  border:1px solid var(--line);
  background:transparent;
  padding:6px 9px;
  border-radius:6px;
  cursor:pointer;
}
.stats button:hover{ background:var(--soft); }

.runs{ margin-top:12px; }
.runsHeader{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:6px;
  color:var(--muted);
  font-size:12px;
}
.runsList{
  display:grid;
  gap:6px;
}
.runItem{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  padding:6px 8px;
  border:1px solid var(--line);
  border-radius:6px;
}
.runItem button{
  padding:4px 8px;
  border-radius:6px;
}
.runName{
  display:flex;
  gap:8px;
  align-items:baseline;
  min-width:0;
}
.runName strong{ font-size:12px; }
.runMeta{ font-size:11px; color:var(--muted); }

/* Inputs */
input, select, button{
  font: inherit;
  color: var(--text);
}
input[type="text"], input[type="number"], select{
  border:1px solid var(--line);
  background:#fff;
  padding:8px 10px;
  border-radius:8px;
  outline:none;
  min-width:120px;
}
input[type="range"]{
  width:100%;
}

/* Buttons */
.buttons{ align-items:center; }

button{
  border:1px solid var(--line);
  background:transparent;
  padding:8px 10px;
  border-radius:8px;
  cursor:pointer;
}
button:hover{
  background:var(--soft);
}

button.primary{
  border-color: rgba(37, 99, 235, 0.30);
  background: rgba(37, 99, 235, 0.08);
}
button.primary:hover{
  background: rgba(37, 99, 235, 0.12);
}

button.danger{
  border-color: rgba(220, 38, 38, 0.30);
  background: rgba(220, 38, 38, 0.06);
  color: var(--danger);
}
button.danger:hover{
  background: rgba(220, 38, 38, 0.10);
}

button.toggle.active{
  border-color: rgba(37, 99, 235, 0.30);
  background: rgba(37, 99, 235, 0.08);
}

/* Hint */
.hint{
  margin-top:4px;
  font-size:12px;
  color:var(--muted);
}
kbd{
  font-size:11px;
  padding:2px 6px;
  border-radius:6px;
  border:1px solid var(--line);
  background:#fff;
}

/* Plot area: just a canvas, no card */
.plot{
  display: grid;
  justify-items: center;
  gap: 8px;
  align-content: start;
  min-height: 0;
}

canvas{
  width: min(640px, 100%);
  max-height: calc(100vh - 110px);
  height: auto;

  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;

  object-fit: contain;
}

/* Legend */
.legend{
  display:flex;
  gap:14px;
  align-items:center;
  font-size:12px;
  color:var(--muted);
}
.dot{
  display:inline-block;
  width:10px; height:10px;
  border-radius:50%;
  margin-right:6px;
}
.dot.a{ background: var(--accent); }
.dot.b{ background: var(--danger); }

/* Responsive: stack */
@media (max-width: 980px){
  .layout{
    grid-template-columns: 1fr;
  }
  .controls{
    border-right:none;
    padding-right:0;
    border-bottom:1px solid var(--line);
    padding-bottom:12px;
    margin-bottom:12px;
  }
}
