/* Tune view */
.tune-view {
  min-height: 0; display: grid; gap: 12px; padding: 12px;
  grid-template-columns: minmax(0, 1fr) 280px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "bar inspector" "plot inspector" "bands inspector";
}
.tune-bar { grid-area: bar; justify-self: center; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 6px 8px 6px 12px; }
.tune-bar-output { display: flex; align-items: center; gap: 8px; }
.tune-plot { grid-area: plot; min-height: 0; display: grid; }
.tune-bands { grid-area: bands; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; padding: 12px; }
.tune-card { display: grid; gap: 8px; align-content: start; padding: 10px 12px 12px; border: 1px solid var(--line); border-radius: 4px; }
.tune-card.sel { outline: 2px solid var(--accent); outline-offset: 1px; }
.tune-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 24px; }
.tune-card-head .btn { padding: 0 4px; margin-left: -4px; }
.tune-inspector { grid-area: inspector; align-self: start; max-height: 100%; overflow-y: auto; }
.tune-inspector-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.badge { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 4px; background: var(--well); }
.readouts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.readout { display: flex; align-items: center; white-space: nowrap; overflow: hidden; }
.split { display: flex; justify-content: space-between; gap: 8px; }
.pairs, .coefficients { display: grid; gap: 6px 12px; margin: 0; }
.pairs { grid-template-columns: auto 1fr; }
.coefficients { grid-template-columns: auto 1fr auto; }
.pairs dd, .coefficients dd { margin: 0; text-align: right; }
.pairs dd, .coefficients dd:nth-of-type(odd) { color: var(--ink); }

/* Response plots */
.plot {
  display: grid; min-height: 0;
  grid-template-areas: "y area" ". x";
  grid-template-columns: 36px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 22px;
}
.plot-y, .plot-x { position: relative; }
.plot-y { grid-area: y; }
.plot-x { grid-area: x; }
.plot-y span { position: absolute; right: 6px; transform: translateY(-50%); }
.plot-x span { position: absolute; top: 5px; transform: translateX(-50%); white-space: nowrap; }
.plot-area { grid-area: area; display: grid; min-height: 0; }
.plot-area > * { grid-area: 1 / 1; }
.plot-area svg { width: 100%; height: 100%; display: block; overflow: hidden; }
.plot path { fill: none; stroke-width: 1; vector-effect: non-scaling-stroke; }
.plot .plot-grid { stroke: var(--line); }
.plot .plot-zero, .plot .curve-other, .plot .curve-band { stroke: var(--muted); }
.plot .curve-band { stroke-dasharray: 2 3; }
.plot .curve-selected { stroke: var(--accent); stroke-width: 2; }
.plot [data-muted="true"] { stroke-dasharray: 4 3; }

.plot-handles { position: relative; }
.plot-handle {
  position: absolute; width: 24px; height: 24px; padding: 0; transform: translate(-50%, -50%);
  border: 1.5px solid var(--ink); border-radius: 999px; background: var(--panel);
  font: 500 11px/1 var(--mono); cursor: grab; touch-action: none;
}
.plot-handle:active { cursor: grabbing; }
.plot-handle.sel { background: var(--ink); color: var(--ground); outline: 2px solid var(--accent); outline-offset: 2px; }
.plot-tip {
  position: absolute; transform: translate(-50%, calc(-100% - 20px)); padding: 2px 6px; border-radius: 2px;
  background: var(--ink); color: var(--ground); white-space: nowrap; pointer-events: none;
}

/* Knobs and output controls */
.knob-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.knob-cell { display: grid; justify-items: center; gap: 4px; min-width: 0; }
.knob-cell .t-value { white-space: nowrap; }
.knob { display: block; padding: 0; border: 0; border-radius: 999px; background: transparent; cursor: ns-resize; touch-action: none; }
.knob-face { fill: var(--well); stroke: var(--line); }
.knob-track, .knob-value { fill: none; stroke-width: 2; }
.knob-track { stroke: var(--line); }
.knob-value, .knob-pointer { stroke: var(--ink); }
.knob-pointer { stroke-width: 2; stroke-linecap: square; }
.toggle-stack { display: grid; gap: 6px; align-content: center; }
.toggle-stack .btn { justify-content: center; }

/* Channel inspector */
.channel-picker .seg { flex: 1; font-family: var(--mono); }
.crossover-row { display: grid; grid-template-columns: minmax(0, 1fr) 112px; align-items: center; gap: 8px; }
.unit-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px; }
.eq-row { display: grid; grid-template-columns: 28px repeat(3, minmax(0, 1fr)); align-items: center; gap: 4px; }
.channel-inspector .field[type="number"] { padding: 0 4px; }
.channel-inspector .section > .btn { justify-self: start; }

/* Monitor */
.monitor { flex: none; display: grid; overflow: hidden; }
.monitor-head { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 2px 0 12px; overflow: hidden; }
.monitor-chip { display: flex; align-items: baseline; gap: 3px; white-space: nowrap; }
.monitor-body { display: grid; gap: 8px; padding: 8px 12px 10px; border-top: 1px solid var(--line); }
.plot.mini { grid-template-columns: 28px minmax(0, 1fr); grid-template-rows: 72px 18px; }
.plot.mini svg { background: var(--well); border-radius: 2px; }
.monitor-rows { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.monitor-rows .row { padding: 0 6px; }

@media (max-width: 900px) {
  .tune-view {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 360px auto auto;
    grid-template-areas: "bar" "plot" "bands" "inspector";
  }
  .tune-bar { justify-self: stretch; }
  .tune-inspector { max-height: none; }
}
