.pcb-layout {
    grid-template-columns: minmax(0, 1.7fr) minmax(300px, 0.86fr);
    align-items: stretch;
}

.pcb-stage {
    position: relative;
    padding: 0;
    overflow: hidden;
    min-height: 560px;
    height: calc(100vh - 210px);
    background:
        radial-gradient(circle at 50% 0%, rgba(16, 120, 72, 0.16), transparent 42%),
        #0c0c10;
}

.pcb-stage canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

.pcb-status,
.pcb-badge,
.pcb-legend,
.pcb-scale,
.pcb-live {
    position: absolute;
    z-index: 2;
    pointer-events: none;
}

.pcb-status,
.pcb-badge {
    top: 14px;
    left: 16px;
    color: var(--text-main);
    background: rgba(12, 12, 16, 0.8);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 10px;
    font-size: 0.85rem;
}

.pcb-badge {
    font-weight: 600;
}

.pcb-legend {
    top: 14px;
    right: 16px;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px 12px;
    margin: 0;
    padding: 8px 10px;
    list-style: none;
    background: rgba(12, 12, 16, 0.8);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.78rem;
    font-weight: 600;
}

.pcb-legend li {
    display: flex;
    align-items: center;
    gap: 6px;
}

.swatch {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    display: inline-block;
}

.swatch-vcc { background: #fb7185; }
.swatch-led { background: #fbbf24; }
.swatch-gnd { background: #2dd4bf; }

.pcb-scale,
.pcb-live {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

.pcb-scale {
    left: 16px;
    bottom: 14px;
    max-width: 58%;
}

.pcb-live {
    right: 16px;
    bottom: 14px;
    text-align: right;
    max-width: 46%;
}

.pcb-stage,
.pcb-panel {
    min-height: 0;
}

.pcb-panel {
    max-height: calc(100vh - 180px);
    overflow: auto;
    padding: 16px 16px 12px;
}

.pcb-panel h2 {
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 18px 0 10px;
}

.readout-main {
    font-size: clamp(1.45rem, 2.4vw, 1.9rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    margin: 2px 0;
}

.pcb-sub {
    color: var(--text-muted);
    margin: 0 0 10px;
    line-height: 1.45;
    font-size: 0.9rem;
}

.pcb-panel .result-list {
    grid-template-columns: 1fr 1fr;
    column-gap: 14px;
    row-gap: 0;
    margin-top: 12px;
}

.pcb-panel .result-list div {
    padding-bottom: 4px;
    gap: 6px;
}

.pcb-panel .result-list dt,
.pcb-panel .result-list dd {
    font-size: 0.82rem;
}

.pcb-note {
    margin-top: 8px;
    color: #fde68a;
    background: rgba(62, 42, 8, 0.55);
    border: 1px solid rgba(251, 191, 36, 0.35);
    border-radius: var(--radius-md);
    padding: 8px 10px;
    line-height: 1.45;
    font-size: 0.86rem;
}

.pcb-note:empty {
    display: none;
}

.schematic {
    width: 100%;
    height: auto;
    display: block;
    margin: 0 0 8px;
}

.schematic .wire,
.schematic .sym,
.schematic .body,
.schematic .cap,
.schematic .sym-r,
.schematic .led,
.schematic .led-bar {
    fill: none;
    stroke: #71717a;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.schematic .body,
.schematic .sym-r {
    fill: rgba(255, 255, 255, 0.03);
}

.schematic .led {
    fill: rgba(251, 191, 36, 0.15);
    stroke: #fbbf24;
}

.schematic .sym-r { stroke: #f5c16c; }
.schematic .cap { stroke: #f472b6; }
.schematic .led-bar { stroke: #fbbf24; }

.schematic .net {
    cursor: pointer;
    pointer-events: stroke;
}

.schematic .body,
.schematic .sym-r,
.schematic .led {
    pointer-events: all;
    cursor: pointer;
}

.schematic .net.on {
    stroke-width: 2.6;
}

.schematic text {
    fill: var(--text-muted);
    font-family: Inter, "Segoe UI", sans-serif;
    font-size: 11px;
    font-weight: 600;
    text-anchor: middle;
    pointer-events: none;
}

.seg {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.seg button,
.pcb-actions button,
.net-row button {
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-muted);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
}

.seg button.active,
.pcb-actions button:hover,
.seg button:hover,
.net-row button:hover,
.net-row button.active {
    color: var(--text-main);
    border-color: var(--accent);
    background: var(--accent-soft);
}

.net-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0 8px;
}

.control {
    display: grid;
    gap: 4px;
    margin-top: 8px;
}

.control-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: baseline;
}

.control-head label,
.control-head span {
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
}

.control-head strong {
    font-size: 0.92rem;
    color: var(--text-main);
    text-align: right;
}

.control input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
    touch-action: pan-y;
}

.pcb-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.layer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 10px;
    margin-top: 8px;
}

.layer-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    color: var(--text-main);
    font-size: 0.88rem;
}

.hint {
    margin-top: 16px;
}

@media (max-width: 900px) {
    .pcb-layout {
        grid-template-columns: 1fr;
    }

    .pcb-stage {
        height: 62vh;
        min-height: 320px;
    }

    .pcb-panel {
        max-height: none;
    }

    .pcb-scale,
    .pcb-live {
        max-width: 70%;
    }

    .seg button,
    .pcb-actions button,
    .net-row button {
        min-height: 44px;
    }

    .layer-grid label {
        min-height: 44px;
    }
}

@media (max-width: 720px) {
    .pcb-scale {
        display: none;
    }

    .pcb-live {
        left: 12px;
        right: 12px;
        max-width: none;
        text-align: left;
    }

    .pcb-legend {
        max-width: 46%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pcb-stage {
        scroll-behavior: auto;
    }
}
