/* SPSA parameter panel (Tune pages).

   One row per parameter. The track is the parameter's allowed range, the hollow
   tick is where tuning started, the dot is where it is now, and the bar between
   them is how far it has travelled. A parameter pressed against its limit gets
   a warm dot, because that usually means the range is too tight. */

.spsa-panel {
    --spsa-line: var(--line, #2a303a);
    --spsa-muted: var(--muted, var(--color-font3, #8b95a7));
    --spsa-ink: var(--color-font1, #e6e9ef);
    --spsa-fill: var(--accent, #4c8dff);
    --spsa-limit: #e8955a;
    --spsa-mono: var(--font-mono, 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
}

/* ---------- Progress ---------- */

.spsa-summary {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: end;
    gap: 8px 28px;
    padding: 4px 0 18px;
}

.spsa-iter { display: flex; flex-direction: column; gap: 2px; }

.spsa-big {
    font-family: var(--spsa-mono);
    font-size: 30px;
    font-weight: 600;
    line-height: 1;
    color: var(--spsa-ink);
    font-variant-numeric: tabular-nums;
}

.spsa-of { font-size: 13px; color: var(--spsa-muted); }

.spsa-bar {
    height: 6px;
    margin-bottom: 7px;
    background: var(--spsa-line);
    border-radius: 3px;
    overflow: hidden;
}

.spsa-bar > span {
    display: block;
    height: 100%;
    background: var(--spsa-fill);
    border-radius: 3px;
}

.spsa-facts { display: flex; gap: 22px; margin: 0; }
.spsa-facts div { text-align: right; }
.spsa-facts dt { font-size: 12.5px; color: var(--spsa-muted); }
.spsa-facts dd {
    margin: 0;
    font-family: var(--spsa-mono);
    font-size: 15px;
    color: var(--spsa-ink);
    font-variant-numeric: tabular-nums;
}

/* ---------- Tools ---------- */

.spsa-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 0;
    border-top: 1px solid var(--spsa-line);
}

.spsa-tools input[type=search],
.spsa-tools select {
    min-height: 36px;
    padding: 0 10px;
    color: var(--spsa-ink);
    background: transparent;
    border: 1px solid var(--spsa-line);
    border-radius: 4px;
    font: inherit;
    font-size: 14px;
}

.spsa-tools input[type=search] { flex: 1 1 200px; max-width: 320px; }

.spsa-tools :focus-visible,
.spsa-row:focus-visible {
    outline: 2px solid var(--spsa-fill);
    outline-offset: 2px;
}

/* ---------- Rows ---------- */

.spsa-rows { list-style: none; margin: 0; padding: 0; }

.spsa-row {
    display: grid;
    grid-template-columns: minmax(8ch, 18ch) minmax(140px, 1fr) 10ch 9ch;
    align-items: center;
    gap: 4px 18px;
    padding: 11px 0;
    border-top: 1px solid var(--spsa-line);
}

.spsa-row[hidden] { display: none; }

.spsa-name {
    font-family: var(--spsa-mono);
    font-size: 13.5px;
    color: var(--spsa-ink);
    overflow-wrap: anywhere;
}

.spsa-track-wrap { min-width: 0; }

.spsa-track {
    position: relative;
    height: 4px;
    margin: 8px 6px 6px;
    background: var(--spsa-line);
    border-radius: 2px;
}

.spsa-drift {
    position: absolute;
    top: 0;
    bottom: 0;
    background: var(--spsa-fill);
    opacity: .55;
}

.spsa-start {
    position: absolute;
    top: -5px;
    width: 2px;
    height: 14px;
    margin-left: -1px;
    background: var(--spsa-muted);
}

.spsa-now {
    position: absolute;
    top: 50%;
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    background: var(--spsa-fill);
    border: 2px solid var(--color2, #1a1d22);
    border-radius: 50%;
    box-sizing: border-box;
}

.spsa-row.at-bound .spsa-now { background: var(--spsa-limit); }

.spsa-scale {
    display: flex;
    justify-content: space-between;
    font-family: var(--spsa-mono);
    font-size: 11px;
    color: var(--spsa-muted);
    font-variant-numeric: tabular-nums;
}

.spsa-value {
    font-family: var(--spsa-mono);
    font-size: 15px;
    font-weight: 600;
    text-align: right;
    color: var(--spsa-ink);
    font-variant-numeric: tabular-nums;
}

.spsa-delta {
    font-family: var(--spsa-mono);
    font-size: 13px;
    text-align: right;
    color: var(--spsa-muted);
    font-variant-numeric: tabular-nums;
}

.spsa-row.at-bound .spsa-delta { color: var(--spsa-limit); }

.spsa-empty { padding: 18px 0; color: var(--spsa-muted); }

.spsa-key {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 20px;
    padding-top: 12px;
    border-top: 1px solid var(--spsa-line);
    font-size: 12.5px;
    color: var(--spsa-muted);
}

.spsa-key i {
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
}

.spsa-key .k-start { width: 2px; height: 12px; background: var(--spsa-muted); }
.spsa-key .k-now { width: 10px; height: 10px; border-radius: 50%; background: var(--spsa-fill); }
.spsa-key .k-limit { width: 10px; height: 10px; border-radius: 50%; background: var(--spsa-limit); }

/* ---------- Narrow screens ---------- */

@media (max-width: 720px) {

    .spsa-summary { grid-template-columns: 1fr; }
    .spsa-facts div { text-align: left; }

    .spsa-row {
        grid-template-columns: 1fr auto auto;
        gap: 6px 12px;
    }

    .spsa-name { grid-column: 1; }
    .spsa-value { grid-column: 2; }
    .spsa-delta { grid-column: 3; min-width: 7ch; }
    .spsa-track-wrap { grid-column: 1 / -1; }
}
