/* ── TVET virtual oscilloscope – v1 ── */

/* Ensure hidden attribute works */
[hidden] {
    display: none !important;
}

/* reuse sim-shell, sim-topbar, sim-fieldset, sim-ctrl, sim-metric,
   sim-formula-panel classes from tvet-solar.css */

.scope-page-main {
    width: min(1420px, calc(100vw - 24px));
    margin: 10px auto 24px;
}

.scope-shell {
    max-width: 1420px;
    margin: 0 auto;
    gap: 12px;
}

.scope-shell .sim-topbar,
.scope-shell .sim-formula-panel {
    max-width: 1420px;
    margin-inline: auto;
}

/* ── toolbar buttons ── */
.scope-toolbar {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.scope-btn {
    padding: 0.2rem 0.48rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.71rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.scope-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.3);
}

.scope-btn-run.active {
    background: rgba(0, 200, 83, 0.22);
    border-color: rgba(0, 200, 83, 0.5);
    color: #4cff8a;
}

.scope-btn-run.stopped {
    background: rgba(244, 67, 54, 0.22);
    border-color: rgba(244, 67, 54, 0.5);
    color: #ff6b6b;
}

.scope-btn.active {
    background: rgba(0, 200, 83, 0.22);
    border-color: rgba(0, 200, 83, 0.5);
    color: #4cff8a;
}

/* ── secondary pill for nav ── */
.tvet-pill-secondary {
    opacity: 0.7;
}

.tvet-pill-secondary:hover {
    opacity: 1;
}

/* ── screen col (full width — no sidebar) ── */

.scope-channel-launch,
.scope-inline-btn {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.84);
    font: inherit;
    cursor: pointer;
}

.scope-channel-launch {
    width: 100%;
    min-height: 48px;
    padding: 0.7rem 0.9rem;
    text-align: left;
    font-weight: 700;
}

.scope-channel-panel {
    position: relative;
}

.scope-inline-btn {
    position: absolute;
    top: 0.45rem;
    right: 0.55rem;
    padding: 0.25rem 0.6rem;
    font-size: 0.74rem;
    z-index: 1;
}

/* ── collapsible sections ── */
.scope-section {
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.22);
}

.scope-section > summary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0.42rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.72);
    cursor: pointer;
    user-select: none;
    list-style: none;
}

.scope-section > summary::-webkit-details-marker { display: none; }

.scope-section > summary::before {
    content: '\25B6';
    font-size: 0.52rem;
    opacity: 0.45;
    flex-shrink: 0;
    transition: transform 0.15s;
}

.scope-section[open] > summary::before {
    transform: rotate(90deg);
}

.scope-section[open] > summary {
    color: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.scope-section-body {
    display: grid;
    gap: 6px;
    padding: 0.5rem 0.65rem;
}

/* ✕ buttons sitting inside <summary> — override absolute positioning */
.scope-sum-btn {
    position: static !important;
    top: auto !important;
    right: auto !important;
    margin-left: auto;
    padding: 0.15rem 0.5rem;
    font-size: 0.7rem;
    border-radius: 8px;
}

.scope-channel-launch:hover,
.scope-inline-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.24);
}

.scope-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.scope-toggle-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #00a1de;
    cursor: pointer;
}

/* ── scope screen (full width) ── */
.scope-screen-col {
    width: 100%;
    min-width: 0;
    max-width: 1180px;
    margin: 0 auto;
}

.scope-screen-wrap {
    position: relative;
    border-radius: 18px;
    overflow: hidden;
    background: #001a00;
    border: 2px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 60px rgba(0, 40, 0, 0.5), 0 4px 24px rgba(0, 0, 0, 0.3);
    flex: 1 1 auto;
    min-width: 0;
}

.scope-screen-wrap canvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 10 / 6;
    max-height: 50vh;
}

/* Display settings backdrop (semi-transparent overlay) */
.scope-display-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999998;
}

/* Display settings floating panel - centered dialog */
.scope-display-panel {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(90vw, 380px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 16px;
    background: #1a1a1a;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
    z-index: 999999;
    max-height: 85vh;
    overflow-y: auto;
}

.scope-display-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2px;
}

.scope-display-title {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.55);
    font-family: 'JetBrains Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.scope-display-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.12s;
}
.scope-display-close:hover { color: #fff; }

.scope-display-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.scope-display-lbl {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.65);
    font-family: 'JetBrains Mono', monospace;
    min-width: 90px;
}

.scope-display-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.scope-display-select {
    background: #222;
    color: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.72rem;
}

.scope-axis-footer {
    display: flex;
    justify-content: center;
}

.scope-x-axis-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 112px;
    min-height: 30px;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.36);
    border: 1px solid rgba(0, 220, 0, 0.18);
    color: rgba(190, 255, 190, 0.9);
    font: 700 0.78rem 'JetBrains Mono', monospace;
}

/* status bar */
.scope-status {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0.4rem 0.7rem;
    background: rgba(0, 0, 0, 0.5);
    font-size: 0.72rem;
    font-family: 'JetBrains Mono', monospace;
    color: rgba(255, 255, 255, 0.6);
}

.scope-status-ch.ch1 { color: #ffff00; }
.scope-status-ch.ch2 { color: #00ccff; }

.scope-status-mode {
    margin-left: auto;
    font-weight: 700;
    color: #4cff8a;
}

.scope-status-mode.stopped {
    color: #ff6b6b;
}

/* ── colour labels ── */
.ch1-label { color: #ffff00; }
.ch2-label { color: #00ccff; }
.math-label { color: #cc99ff; }

/* ══════════════════════════════════════════════
   IN-SCREEN MEASUREMENT OVERLAY
   ══════════════════════════════════════════════ */
.scope-screen-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 10px;
}

/* Top measurements row - horizontal at top with active channels/measurements */
.scope-ovl-top-measurements {
    display: none;
}

.scope-ovl-bottom {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: flex-end;
    padding: 0 8px;
}

.scope-ovl-panel {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 5px 8px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-family: 'JetBrains Mono', monospace;
}

.scope-ovl-lbl {
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding-bottom: 3px;
    margin-bottom: 1px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.scope-ovl-kv {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

.scope-ovl-kv em {
    font-style: normal;
    font-size: 0.5rem;
    color: rgba(255, 255, 255, 0.38);
    white-space: nowrap;
}

.scope-ovl-kv strong {
    font-size: 0.58rem;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    text-align: right;
}

/* Channel measurement stack — vertical panel on the right */
.scope-ovl-chinfo {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    align-items: stretch;
    pointer-events: none;
    position: absolute;
    top: 10px;
    right: 10px;
    width: min(180px, 24%);
    max-height: calc(100% - 20px);
    box-sizing: border-box;
    overflow-y: auto;
}

.scope-ovl-chinfo.scope-ovl-chinfo--split {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(330px, 40%);
}

/* When no children are visible the bar should disappear */
.scope-ovl-chinfo:empty,
.scope-ovl-chinfo[data-empty="true"] {
    display: none;
}

.scope-chinfo-item {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.56rem;
    font-weight: 500;
    line-height: 1.22;
    padding: 5px 6px;
    color: rgba(255, 255, 255, 0.82);
    white-space: normal;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    backdrop-filter: blur(1px);
}

.scope-ovl-toprow {
    display: flex;
    justify-content: flex-end;
}

.scope-chinfo-title {
    display: block;
    margin-bottom: 2px;
    font-size: 0.62rem;
    font-weight: 700;
}

@media (max-width: 820px) {
    .scope-ovl-chinfo {
        width: min(150px, 34%);
        top: 8px;
        right: 8px;
        gap: 5px;
    }

    .scope-ovl-chinfo.scope-ovl-chinfo--split {
        width: min(240px, 56%);
    }

    .scope-chinfo-item {
        font-size: 0.52rem;
        padding: 4px 5px;
    }
}

/* Knob-value toast popup */
.scope-knob-toast {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.78);
    color: #fff;
    font: 700 1.4rem 'JetBrains Mono', monospace;
    padding: 0.45em 1.2em;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.12s ease;
    z-index: 20;
    white-space: nowrap;
}

.scope-knob-toast.visible {
    opacity: 1;
}

/* ══════════════════════════════════════════════
   KNOB CONTROL STRIP
   ══════════════════════════════════════════════ */
.scope-knob-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 18px;
    padding: 14px 18px;
    background: #111;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.04);
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    box-sizing: border-box;
}

/* A section inside the strip */
.scope-kns {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

/* Vertical separator */
.knob-sep {
    width: 1px;
    height: 72px;
    background: rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    align-self: center;
}

/* ── Realistic knob ── */
.scope-knob {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: radial-gradient(circle at 38% 33%, #6a6a6a 0%, #2a2a2a 65%, #1a1a1a 100%);
    border: 5px solid #555;
    position: relative;
    cursor: grab;
    flex-shrink: 0;
    box-shadow:
        inset 0 0 14px rgba(0, 0, 0, 0.9),
        0 4px 12px rgba(0, 0, 0, 0.7),
        0 0 0 1px rgba(255, 255, 255, 0.04);
    user-select: none;
    touch-action: none;
    --knob-angle: -135deg;
}

.scope-knob:active { cursor: grabbing; border-color: rgba(0,200,80,0.65); box-shadow: inset 0 0 14px rgba(0,0,0,0.9), 0 0 18px rgba(0,200,80,0.25); }

.scope-knob-sm {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

/* Yellow indicator line rotating from center */
.knob-indicator {
    position: absolute;
    bottom: 50%;      /* bottom of indicator = knob centre */
    left: 50%;
    width: 3px;
    height: 21px;     /* reaches from centre toward top */
    background: #ffdd00;
    border-radius: 2px 2px 0 0;
    transform-origin: 50% 100%;   /* rotate around own bottom = knob centre */
    transform: translateX(-50%) rotate(var(--knob-angle));
    pointer-events: none;
}

.scope-knob-sm .knob-indicator {
    width: 2px;
    height: 14px;
}

/* Caption below knob */
.knob-caption {
    font-size: 0.6rem;
    color: rgba(0, 220, 0, 0.8);
    font-family: 'JetBrains Mono', monospace;
    text-align: center;
    line-height: 1.25;
    letter-spacing: 0.02em;
}

.knob-caption span {
    display: block;
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.7rem;
    font-weight: 700;
}

.knob-group-label {
    font-size: 0.53rem;
    color: rgba(255, 255, 255, 0.25);
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

/* ── Stepper controls for V/div and Time/div ── */
.scope-stepper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 88px;
}

.scope-stepper-label {
    font-size: 0.63rem;
    color: rgba(0, 220, 0, 0.8);
    font-family: 'JetBrains Mono', monospace;
    text-align: center;
    line-height: 1;
    letter-spacing: 0.04em;
}

.scope-stepper-body {
    display: grid;
    grid-template-columns: 26px minmax(52px, auto) 26px;
    align-items: stretch;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03)),
        rgba(5, 8, 10, 0.88);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.06),
        0 6px 14px rgba(0,0,0,0.35);
}

.scope-stepper-btn {
    border: 0;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.03)),
        rgba(18, 22, 24, 0.96);
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    font-size: 0.95rem;
    font-weight: 800;
    line-height: 1;
    transition: background 0.15s, color 0.15s, transform 0.08s;
    user-select: none;
    touch-action: manipulation;
}

.scope-stepper-btn + .scope-stepper-value,
.scope-stepper-value + .scope-stepper-btn {
    border-left: 1px solid rgba(255, 255, 255, 0.08);
}

.scope-stepper-btn:hover {
    background:
        linear-gradient(180deg, rgba(0,200,83,0.18), rgba(0,200,83,0.06)),
        rgba(18, 22, 24, 0.96);
    color: #9bffbd;
}

.scope-stepper-btn:active {
    transform: translateY(1px);
    background:
        linear-gradient(180deg, rgba(0,200,83,0.26), rgba(0,200,83,0.10)),
        rgba(18, 22, 24, 0.96);
    color: #4cff8a;
}

.scope-stepper-btn:disabled {
    cursor: default;
    color: rgba(255, 255, 255, 0.28);
    background: rgba(18, 22, 24, 0.72);
}

.scope-stepper-value {
    min-width: 52px;
    padding: 0 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.96);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.66rem;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
    background: rgba(0, 0, 0, 0.2);
}

.scope-stepper-value span {
    display: block;
}

.scope-stepper-compact {
    gap: 2px;
    min-width: 74px;
}

.scope-stepper-compact .scope-stepper-label {
    font-size: 0.57rem;
    letter-spacing: 0.03em;
}

.scope-stepper-compact .scope-stepper-body {
    grid-template-columns: 20px minmax(44px, auto) 20px;
    border-radius: 8px;
}

.scope-stepper-compact .scope-stepper-btn {
    min-height: 32px;
    font-size: 0.8rem;
}

.scope-stepper-compact .scope-stepper-value {
    min-width: 44px;
    padding: 0 4px;
    font-size: 0.55rem;
}

/* ── CH toggle buttons ── */
.scope-kns-channels { gap: 4px; }

.knob-ch-btn {
    padding: 0.26rem 0.58rem;
    min-width: 46px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.38);
    font-weight: 700;
    font-size: 0.66rem;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: all 0.14s;
    font-family: inherit;
}

.knob-ch-btn.active.ch1-btn  { background: rgba(255,255,0,0.14); border-color: rgba(255,255,0,0.5); color: #ffff00; box-shadow: 0 0 10px rgba(255,255,0,0.18); }
.knob-ch-btn.active.ch2-btn  { background: rgba(0,204,255,0.14); border-color: rgba(0,204,255,0.5); color: #00ccff; box-shadow: 0 0 10px rgba(0,204,255,0.18); }
.knob-ch-btn.active.mth-btn  { background: rgba(204,153,255,0.14); border-color: rgba(204,153,255,0.5); color: #cc99ff; box-shadow: 0 0 10px rgba(204,153,255,0.18); }

/* ── CH tab pills (CH1/CH2 inside signal section) ── */
.knob-ch-tabs {
    display: flex;
    gap: 2px;
    background: rgba(0,0,0,0.45);
    border-radius: 5px;
    padding: 1px;
}

.knob-tab {
    padding: 0.14rem 0.4rem;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: rgba(255,255,255,0.35);
    font-size: 0.62rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.12s;
    font-family: inherit;
}

.knob-tab.active { background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.9); }

/* ── Selects embedded in strip ── */
.knob-select {
    background: #191919;
    color: rgba(0,220,0,0.9);
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 6px;
    padding: 0.25rem 0.38rem;
    font-size: 0.7rem;
    font-family: inherit;
    cursor: pointer;
    width: 120px;
}

.knob-select-sm {
    background: #191919;
    color: rgba(0,220,0,0.9);
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 5px;
    padding: 0.2rem 0.28rem;
    font-size: 0.63rem;
    font-family: inherit;
    cursor: pointer;
    width: 90px;
}

/* ── Signal section ── */
.scope-kns-signal { gap: 4px; }
.scope-kns-mini   { min-width: 0; gap: 3px; }
.knob-mini-row    { display: flex; gap: 6px; }

/* ── Trigger section ── */
.scope-kns-trigger { gap: 4px; }
.scope-kns-math    { gap: 6px; }

/* ── Trigger + Controls combined row (fills remaining strip space) ── */
.scope-kns-trig-ctrl {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 18px;
    flex: 1 1 auto;
    min-width: 0;
}

/* ── Control buttons section ── */
.scope-kns-btns {
    gap: 5px;
    align-items: flex-start;
    flex: 1 1 auto;
}
.scope-btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.scope-kns-btns .scope-btn {
    padding: 0.25rem 0.55rem;
    font-size: 0.75rem;
}

/* ── Outer axis labels (outside canvas) ── */
.scope-axis-outer {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    width: 100%;
}

.scope-y-axis-outer {
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-lr;
    transform: rotate(180deg);
    font-size: 0.68rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: rgba(0, 220, 0, 0.75);
    padding: 0 4px 0 0;
    white-space: nowrap;
    min-width: 22px;
    flex-shrink: 0;
    letter-spacing: 0.04em;
}

.scope-x-axis-outer {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 3px 0 0 22px; /* left-pad to align with canvas (offset by y-label width) */
    font-size: 0.68rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: rgba(0, 220, 0, 0.75);
    letter-spacing: 0.04em;
}

/* FFT options row inside the math section */
.scope-kns-fft-row {
    display: flex;
    gap: 4px;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .scope-page-main { width: calc(100vw - 16px); }
}

@media (max-width: 700px) {
    .scope-knob-strip {
        gap: 8px 12px;
        padding: 10px 12px;
        justify-content: center;
    }
    .knob-sep { display: none; }
    .scope-kns-signal { width: 100%; }
    .knob-mini-row { justify-content: center; }
    .scope-stepper { min-width: 82px; }
    /* Stack trigger + controls vertically */
    .scope-kns-trig-ctrl {
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }
    .scope-kns-trigger { width: 100%; align-items: flex-start; flex-direction: row; flex-wrap: wrap; gap: 6px; }
    .scope-kns-btns { width: 100%; }
    .scope-btn-row { flex-wrap: wrap; }
    .scope-kns-btns .scope-btn { flex: 1 1 60px; min-height: 36px; font-size: 0.72rem; }
    .knob-select { width: 100%; max-width: 180px; }
    .knob-select-sm { width: auto; min-width: 80px; }
    .knob-ch-btn { min-height: 34px; padding: 0 10px; }
}

@media (max-width: 600px) {
    .scope-toolbar { flex-wrap: wrap; width: 100%; }
    .sim-topbar { flex-direction: column; align-items: flex-start; gap: 6px; }
    .scope-btn { flex: 1 1 90px; }
    .scope-meas-card { width: 100%; gap: 6px 8px; }
    .scope-mcard-kv { min-width: 58px; }
    .scope-advanced-body { grid-template-columns: 1fr; }
    .scope-stepper-body {
        grid-template-columns: 24px minmax(48px, auto) 24px;
    }
}

/* ── Phone-specific (≤ 480px) ── */
@media (max-width: 480px) {
    .scope-knob-strip {
        padding: 8px 8px;
        gap: 6px 8px;
    }
    /* Canvas: give more height on portrait phone */
    .scope-screen-wrap canvas {
        aspect-ratio: 10 / 6;
        max-height: 48vw;
    }
    /* Stepper buttons: bigger tap targets */
    .scope-stepper-btn { min-height: 32px; font-size: 1rem; }
    .scope-stepper-compact .scope-stepper-btn { min-height: 30px; }
    .scope-stepper-value { font-size: 0.62rem; }
    .scope-stepper-compact .scope-stepper-value { font-size: 0.58rem; }
    /* Channel toggle buttons */
    .knob-ch-btn { min-height: 36px; font-size: 0.72rem; padding: 0 12px; }
    /* Control buttons */
    .scope-kns-btns .scope-btn { min-height: 38px; font-size: 0.75rem; }
    /* Signal select */
    .knob-select { width: 100%; max-width: 160px; font-size: 0.72rem; }
    .knob-select-sm { font-size: 0.65rem; }
    /* Measurement bar: slightly smaller text so it fits */
    .scope-chinfo-item { font-size: 0.62rem; }
    /* Group label */
    .knob-group-label { font-size: 0.5rem; }
    /* Tab buttons */
    .knob-tab { padding: 4px 10px; min-height: 30px; }
    /* Mini steppers row: wrap onto two lines if needed */
    .knob-mini-row { flex-wrap: wrap; gap: 6px; justify-content: center; }
    .scope-kns-mini { flex: 1 1 auto; min-width: 74px; }
    /* Axis labels */
    .scope-y-axis-outer { font-size: 0.58rem; min-width: 18px; }
    .scope-x-axis-outer { font-size: 0.58rem; }
    /* Display panel is now fixed+centered, responsiveness handled by min(90vw, 380px) */
}

/* ── number stepper fields ── */
.scope-numfield {
    display: flex;
    align-items: center;
    gap: 3px;
    width: 100%;
}

.scope-numfield input[type="number"] {
    flex: 1;
    min-width: 0;
    padding: 0.25rem 0.3rem;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 0.82rem;
    font-family: 'JetBrains Mono', monospace;
    text-align: center;
    appearance: textfield;
    -moz-appearance: textfield;
}

.scope-numfield input[type="number"]::-webkit-inner-spin-button,
.scope-numfield input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
}

.scope-numfield input[type="number"]:focus {
    outline: none;
    border-color: rgba(0, 161, 222, 0.6);
    box-shadow: 0 0 0 2px rgba(0, 161, 222, 0.15);
}

.snf-btn {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, transform 0.08s;
    padding: 0;
    line-height: 1;
    user-select: none;
}

.snf-btn:hover {
    background: rgba(0, 161, 222, 0.28);
    border-color: rgba(0, 161, 222, 0.45);
}

.snf-btn:active {
    background: rgba(0, 161, 222, 0.5);
    transform: scale(0.9);
}

.snf-step {
    flex-shrink: 0;
    padding: 0.18rem 0.2rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.4);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.68rem;
    font-family: inherit;
    cursor: pointer;
    max-width: 50px;
}

/* XY mode active button */
.scope-btn-xymode {
    background: rgba(0, 255, 136, 0.2) !important;
    border-color: rgba(0, 255, 136, 0.5) !important;
    color: #00ff88 !important;
}

/* ── math channel launch button ── */
.scope-math-launch {
    border-color: rgba(255, 68, 255, 0.3) !important;
    color: rgba(255, 160, 255, 0.9) !important;
}
.scope-math-launch:hover {
    background: rgba(255, 68, 255, 0.12) !important;
    border-color: rgba(255, 68, 255, 0.5) !important;
}

/* ── cursor launch button ── */
.scope-cursor-launch {
    border-color: rgba(255, 153, 0, 0.3) !important;
    color: rgba(255, 200, 100, 0.9) !important;
}
.scope-cursor-launch:hover {
    background: rgba(255, 153, 0, 0.12) !important;
    border-color: rgba(255, 153, 0, 0.5) !important;
}

/* ── math label color ── */
.math-label { color: #ff44ff; }
.scope-status-ch.math { color: #ff44ff; }

/* ── hint text inside panels ── */
.scope-cursor-hint {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.45);
    line-height: 1.4;
    margin: 0 0 6px;
}
.scope-cursor-hint code {
    font-family: 'JetBrains Mono', monospace;
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
    padding: 0 3px;
    color: rgba(255,255,255,0.7);
}

/* ── synth textarea ── */
.scope-synth-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.4rem 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    font-size: 0.78rem;
    font-family: 'JetBrains Mono', monospace;
    resize: vertical;
    min-height: 54px;
}
.scope-synth-input:focus {
    outline: none;
    border-color: rgba(0, 161, 222, 0.5);
}
