[hidden] {
    display: none !important;
}

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

.em-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    min-height: 620px;
    height: calc(100vh - 168px);
    background: #0c0c10;
}

.em-view {
    position: relative;
    flex: 1 1 auto;
    min-height: 280px;
}

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

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

.em-status,
.em-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;
}

.em-badge {
    font-weight: 600;
    max-width: min(420px, 58%);
}

.em-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;
}

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

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

.swatch-e { background: #fb7185; }
.swatch-b { background: #38bdf8; }
.swatch-s { background: #fbbf24; }
.swatch-k { background: #e4e4e7; }

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

.em-scale {
    left: 16px;
    bottom: 14px;
    max-width: 46%;
}

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

.em-colorbar {
    right: 16px;
    bottom: 36px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
}

.em-colorbar i {
    width: 92px;
    height: 8px;
    border-radius: 999px;
    background: linear-gradient(90deg, #1e2a73, #0d74d1, #21b88c, #edc72e, #eb3830);
    border: 1px solid rgba(255, 255, 255, 0.16);
}

.polar-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    height: 210px;
    flex: 0 0 auto;
    padding: 0 8px 8px;
    border-top: 1px solid var(--border-color);
    background: #0c0c10;
}

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

.polar-row figure {
    margin: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.polar-row figcaption {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 6px 4px 0;
}

.polar-row canvas {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    display: block;
}

.em-panel {
    max-height: calc(100vh - 168px);
    overflow: auto;
}

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

.em-sub {
    color: var(--text-muted);
    margin: -6px 0 12px;
    font-weight: 600;
}

.readout-main {
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    margin: 8px 0 8px;
}

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

.seg-gap {
    margin-top: 8px;
}

.seg button,
.em-actions 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,
.seg button:hover,
.em-actions button:hover {
    color: var(--text-main);
    border-color: var(--accent);
    background: var(--accent-soft);
}

.seg button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.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 label span {
    letter-spacing: 0;
    text-transform: none;
    font-weight: 500;
}

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

.control input:disabled {
    opacity: 0.45;
}

.em-num,
.em-text {
    width: 8.4rem;
    background: rgba(10, 10, 12, 0.9);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 8px;
    font: inherit;
    font-size: 16px;
    font-weight: 600;
    text-align: right;
}

.em-text {
    width: 9.4rem;
}

.em-text.bad {
    border-color: #f87171;
}

.check-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin-top: 10px;
}

.check-row label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
    font-size: 0.92rem;
}

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

.em-note {
    margin-top: 8px;
}

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

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

    .em-stage {
        height: auto;
        min-height: 0;
    }

    .em-view {
        flex: none;
        height: 58vh;
        min-height: 280px;
    }

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

    .polar-row {
        height: 190px;
    }

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

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

    .em-live {
        left: 10px;
        right: 10px;
        max-width: none;
        text-align: left;
    }

    .em-colorbar {
        top: 52px;
        right: 10px;
        bottom: auto;
    }

    .polar-row {
        grid-template-columns: 1fr;
        height: auto;
    }

    .polar-row canvas {
        height: 160px;
        flex: none;
    }

    .em-view {
        height: 52vh;
        min-height: 240px;
    }
}
