/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: #0d1117;
  color: #c9d1d9;
  padding: 20px;
  min-height: 100vh;
}
h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 auto 20px;
  max-width: 1400px;
  color: #58a6ff;
  letter-spacing: 0.3px;
}
h2 {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 10px;
  color: #8b949e;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
h3 {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: #8b949e;
}
/* ===== Layout ===== */
.app-grid {
  display: flex;
  gap: 8px;
  max-width: 1400px;
  margin: 0 auto;
  align-items: flex-start;
}
.left-col {
  width: 320px;
  flex-shrink: 0;
}
.right-col {
  flex: 1;
  min-width: 0;
}
/* ===== Resizer ===== */
.resizer {
  width: 5px;
  cursor: col-resize;
  flex-shrink: 0;
  align-self: stretch;
  background: #30363d;
  border-radius: 2px;
  transition: background 0.15s;
}
.resizer:hover,
.resizer.resizing {
  background: #58a6ff;
}
@media (max-width: 900px) {
  .app-grid { flex-direction: column; }
  .left-col { width: 100% !important; }
  .right-col { width: 100%; }
  .canvas-wrap canvas { width: 100% !important; height: auto !important; }
  .resizer { display: none; }
  body { padding: 16px 10px; }
}
.panel {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 12px;
}
.panel-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 8px;
}
.panel-row:last-child { margin-bottom: 0; }
/* ===== Form Controls ===== */
label {
  font-size: 13px;
  color: #8b949e;
  white-space: nowrap;
}
select, input[type="range"], input[type="number"] {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  color: #c9d1d9;
  padding: 4px 8px;
  font-size: 13px;
}
select { min-width: 120px; }
select:focus { border-color: #58a6ff; outline: none; }
input[type="number"] {
  -moz-appearance: textfield;
  padding: 4px 6px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"]:focus { border-color: #58a6ff; outline: none; }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: #30363d;
  border-radius: 2px;
  border: none;
  padding: 0;
  flex: 1;
  min-width: 80px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #58a6ff;
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #58a6ff;
  cursor: pointer;
  border: none;
}
.range-value {
  font-size: 13px;
  color: #58a6ff;
  min-width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.chk-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  cursor: pointer;
  color: #c9d1d9;
}
.chk-label input[type="checkbox"] {
  accent-color: #58a6ff;
}
/* ===== Buttons ===== */
.btn {
  border: none;
  border-radius: 6px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  color: #fff;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: #238636; }
.btn-primary:hover:not(:disabled) { background: #2ea043; }
.btn-danger { background: #da3633; }
.btn-danger:hover:not(:disabled) { background: #f85149; }
.btn-accent { background: #1f6feb; }
.btn-accent:hover:not(:disabled) { background: #388bfd; }
.btn-secondary { background: #21262d; border: 1px solid #30363d; }
.btn-secondary:hover:not(:disabled) { background: #30363d; }
.btn-sm { padding: 3px 10px; font-size: 12px; }
/* ===== Progress ===== */
.progress-bar {
  height: 6px;
  background: #21262d;
  border-radius: 3px;
  overflow: hidden;
  margin: 6px 0;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #58a6ff, #1f6feb);
  transition: width 0.1s;
}
.progress-text {
  font-size: 12px;
  color: #8b949e;
  text-align: center;
}
/* ===== Canvas ===== */
.canvas-wrap {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}
.canvas-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 1;
  cursor: crosshair;
}
.canvas-legend {
  display: flex;
  gap: 18px;
  padding: 8px 14px;
  flex-wrap: wrap;
  font-size: 12px;
  background: #0d1117;
  border-top: 1px solid #30363d;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend-dot {
  width: 20px;
  height: 3px;
  border-radius: 2px;
}
/* ===== PEQ List ===== */
.peq-list { margin-top: 8px; }
.peq-item {
  display: grid;
  grid-template-columns: auto 1fr 1fr 1fr auto;
  gap: 4px;
  align-items: center;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 14px;
}
.peq-item .peq-params {
  display: contents;
}
.peq-item .param-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.peq-item .param-group label {
  font-size: 11px;
  min-width: 14px;
}
.peq-item .param-group .range-value {
  font-size: 11px;
  min-width: 30px;
}
.peq-summary {
  font-size: 12px;
  color: #8b949e;
  text-align: center;
  padding: 10px 0 4px;
}
/* ===== Status ===== */
.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}
.status-idle { background: #21262d; color: #8b949e; }
.status-active { background: #1f6feb33; color: #58a6ff; animation: pulse 1.5s infinite; }
.status-done { background: #23863633; color: #3fb950; }
.status-error { background: #da363333; color: #f85149; }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:0.5;} }
/* ===== Level Meter ===== */
.meter-track {
  height: 10px;
  background: #0d1117;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid #21262d;
  position: relative;
}
.meter-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.06s ease;
  background: linear-gradient(90deg, #3fb950 0%, #d29922 55%, #da3633 85%, #f85149 100%);
}
/* ===== Left sidebar narrow ===== */
.narrow-input { max-width: 70px; }
.flex-col { display: flex; flex-direction: column; gap: 8px; }
.flex-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }
.mt-6 { margin-top: 6px; }
.mb-6 { margin-bottom: 6px; }

/* ===== Confirm Dialog ===== */
.confirm-overlay {
  position: fixed; top:0; left:0; right:0; bottom:0;
  background: rgba(0,0,0,0.6);
  display:flex; align-items:center; justify-content:center;
  z-index:9999;
}
.confirm-box {
  background:#161b22; border:1px solid #30363d; border-radius:12px;
  padding:28px 32px; min-width:340px; max-width:460px;
  box-shadow:0 16px 48px rgba(0,0,0,0.5);
}
.confirm-box p {
  color:#c9d1d9; font-size:14px; line-height:1.6; margin:0 0 24px;
}
.confirm-actions {
  display:flex; gap:10px; justify-content:flex-end;
}
.confirm-actions .btn { min-width:90px; }
