/* INSIDE THE QPU — Inspector Sidebar, Mobile Bottom Sheet, Cards, Controls & Literature */

/* Desktop Inspector Sidebar Shell */
.lab-sidebar {
    z-index: 20;
    width: 100%;
    flex: 1 1 0%;
    min-height: 0;
    padding: 1rem;
    overflow-y: auto;
    border-top: 1px solid var(--border-subtle);
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    transition: width 0.22s var(--ease-lab), opacity 0.18s ease;
}

.mobile-sheet-toggle,
.mobile-sheet-backdrop {
    display: none;
}

.mobile-sheet-chevron {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform 0.2s var(--ease-lab);
}

.mobile-sheet-toggle[aria-expanded="true"] .mobile-sheet-chevron {
    transform: rotate(180deg);
}

.mobile-sheet-name {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Sidebar Inner Stack */
.sidebar-stack {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.sidebar-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-heading {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.75rem;
    color: var(--text-primary);
}

.sidebar-subtitle {
    margin-top: 0.125rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1rem;
    color: var(--text-muted);
}

/* Panel Cards */
.panel-card-lab {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: 3px;
}

.sidebar-card {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    padding: 0.875rem;
}

.sidebar-card-accent {
    border-top: 2px solid var(--lab-accent);
}

.sidebar-card-controls {
    gap: 0.75rem;
}

.sidebar-card-prose {
    gap: 0.75rem;
    font-size: 0.75rem;
    line-height: 1.625;
}

.sidebar-card-refs {
    font-size: 0.75rem;
    line-height: 1.625;
}

.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.card-kicker {
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-primary);
}

.card-meta {
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
}

/* Hardware Anatomy List & Selected Part Inspector Card */
.anatomy-list-lab {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    max-height: 184px;
    padding-right: 0.125rem;
    overflow-y: auto;
}

.anatomy-pill {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
    text-align: left;
    border-color: var(--border-subtle);
    box-shadow: inset 0 -2px 0 var(--border-subtle);
}

.anatomy-pill:hover,
.anatomy-pill.anatomy-active {
    border-color: var(--lab-accent);
    box-shadow: inset 0 -2px 0 var(--lab-accent);
}

.anatomy-pill-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
    margin-top: 0.125rem;
    border-radius: 9999px;
    background-color: var(--lab-accent);
    color: var(--text-on-accent);
    font-family: var(--font-mono);
    font-size: 9.5px;
    font-weight: 700;
}

.anatomy-pill-name {
    font-weight: 500;
    line-height: 1.375;
    color: var(--text-primary);
}

.selected-part-card {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    padding: 0.625rem;
    border-radius: 2px;
    background-color: var(--bg-elevated);
    border: 1px solid var(--lab-accent);
    font-size: 0.75rem;
}

.selected-part-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.selected-part-title-row {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.selected-part-badge {
    padding: 0.125rem 0.375rem;
    border-radius: 2px;
    background-color: var(--lab-accent);
    color: var(--text-on-accent);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
}

.selected-part-name {
    font-size: 0.75rem;
    line-height: 1.375;
    color: var(--text-primary);
}

.selected-part-stage {
    display: block;
    margin-top: 0.125rem;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
}

.selected-part-clear {
    flex-shrink: 0;
    padding: 0.125rem 0.5rem;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
}

.selected-part-body {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    padding-top: 0.375rem;
    border-top: 1px solid var(--border-subtle);
    line-height: 1.625;
}

.selected-part-copy {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.selected-part-copy strong {
    color: var(--text-primary);
}

.selected-part-copy .accent-label {
    color: var(--lab-accent-text);
}

/* Interactive Physics Sliders */
.control-field {
    display: block;
}

.control-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.375rem;
    font-size: 0.75rem;
}

.control-label-text {
    font-weight: 500;
    color: var(--text-secondary);
}

.control-value {
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text-primary);
}

input[type="range"].lab-slider {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    display: block;
    width: 100%;
    height: 20px;
    margin: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
    outline: none;
    accent-color: var(--lab-accent);
}

input[type="range"].lab-slider::-moz-focus-outer {
    border: 0;
}

input[type="range"].lab-slider::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    border: none;
    border-radius: 9999px;
    background: linear-gradient(
        to right,
        var(--lab-accent) 0%,
        var(--lab-accent) var(--slider-pct, 0%),
        var(--slider-track) var(--slider-pct, 0%),
        var(--slider-track) 100%
    );
}

input[type="range"].lab-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
    width: 16px;
    height: 16px;
    margin-top: -5px;
    border-radius: 9999px;
    background: var(--lab-accent);
    border: 2px solid var(--slider-thumb-border);
    box-shadow: var(--slider-thumb-shadow);
    cursor: pointer;
    transition: transform 0.12s var(--ease-lab), box-shadow 0.12s ease;
}

input[type="range"].lab-slider:hover::-webkit-slider-thumb {
    transform: scale(1.12);
}

input[type="range"].lab-slider:active::-webkit-slider-thumb {
    transform: scale(1.06);
}

input[type="range"].lab-slider:focus-visible::-webkit-slider-thumb {
    outline: 2px solid var(--lab-accent);
    outline-offset: 2px;
}

input[type="range"].lab-slider::-moz-range-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    border: none;
    border-radius: 9999px;
    background: var(--slider-track);
}

input[type="range"].lab-slider::-moz-range-progress {
    height: 6px;
    border: none;
    border-radius: 9999px;
    background: var(--lab-accent);
}

input[type="range"].lab-slider::-moz-range-thumb {
    -moz-appearance: none;
    appearance: none;
    box-sizing: border-box;
    width: 16px;
    height: 16px;
    margin: 0;
    border-radius: 9999px;
    background: var(--lab-accent);
    border: 2px solid var(--slider-thumb-border);
    box-shadow: var(--slider-thumb-shadow);
    cursor: pointer;
    transition: transform 0.12s var(--ease-lab), box-shadow 0.12s ease;
}

input[type="range"].lab-slider:hover::-moz-range-thumb {
    transform: scale(1.12);
}

input[type="range"].lab-slider:active::-moz-range-thumb {
    transform: scale(1.06);
}

input[type="range"].lab-slider:focus-visible::-moz-range-thumb {
    outline: 2px solid var(--lab-accent);
    outline-offset: 2px;
}

/* Governing Physics Equation & Live Telemetry */
.solver-caption-lab {
    padding-left: 0.625rem;
    border-left: 2px solid var(--lab-accent);
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    line-height: 1.45;
    color: var(--text-secondary);
}

.lab-equation-box {
    padding: 0.5rem 0.75rem;
    overflow-x: auto;
    text-align: center;
    color: var(--text-primary);
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 2px;
}

.lab-equation-box .katex {
    font-size: 0.86rem;
    line-height: 1.5;
}

.telemetry-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.375rem;
    font-family: var(--font-mono);
}

.telemetry-cell {
    padding: 0.5rem;
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 2px;
}

.telemetry-label {
    display: block;
    font-size: 9.5px;
    line-height: 1.375;
    color: var(--text-muted);
}

.telemetry-value {
    display: block;
    margin-top: 0.125rem;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-primary);
}

.telemetry-value.is-warn {
    color: var(--text-warn);
}

/* Benchmark Specs 2x2 Grid */
.specs-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    font-family: var(--font-mono);
}

.spec-cell {
    padding: 0.625rem;
}

.spec-label {
    display: block;
    font-size: 9.5px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.spec-value {
    display: block;
    margin-top: 0.125rem;
    font-size: 0.75rem;
    color: var(--text-primary);
}

/* Architecture Overview Sections (How It Works / Advantage / Challenge / QECC) */
.prose-section {
    display: block;
}

.prose-section-divided {
    padding-top: 0.625rem;
    border-top: 1px solid var(--border-subtle);
}

.prose-kicker {
    display: block;
    margin-bottom: 0.125rem;
}

.prose-kicker-advantage {
    color: var(--text-advantage);
}

.prose-kicker-challenge {
    color: var(--text-challenge);
}

.prose-kicker-qecc {
    color: var(--lab-accent-text);
}

.prose-body {
    color: var(--text-secondary);
}

/* IEEE-Style Peer-Reviewed Literature List */
.ref-list-lab {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    font-size: 0.75rem;
    line-height: 1.625;
}

.ref-item-lab {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    column-gap: 0.45rem;
    align-items: baseline;
    font-size: inherit;
    line-height: inherit;
}

.ref-num-lab {
    font-size: inherit;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    user-select: none;
}

.ref-body-lab {
    color: var(--text-secondary);
    min-width: 0;
    overflow-wrap: break-word;
}

.ref-journal-lab {
    font-style: italic;
}

.ref-links-lab {
    display: inline;
}

.ref-token-lab {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    white-space: nowrap;
    color: var(--text-muted);
    margin-right: 2px;
    vertical-align: baseline;
}

.ref-link-lab {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.14s ease;
}

.ref-link-text-lab {
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-color: var(--border-strong);
    transition: color 0.14s ease, text-decoration-color 0.14s ease;
}

.ref-link-lab:hover,
.ref-link-lab:hover .ref-link-text-lab {
    color: var(--lab-accent-text);
    text-decoration-color: var(--lab-accent-text);
}

.ref-icon-lab {
    width: 0.95em;
    height: 0.95em;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: color 0.14s ease;
}

.ref-link-lab:hover .ref-icon-lab {
    color: var(--lab-accent-text);
}

/* Sidebar Footer */
.sidebar-footer-lab {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.5rem;
    padding: 0.25rem 0 0.5rem;
    font-family: var(--font-mono);
    font-size: 10.5px;
    line-height: 1.45;
    color: var(--text-muted);
}

.sidebar-footer-divider {
    width: 100%;
    height: 1px;
    background-color: var(--border-subtle);
}

.sidebar-footer-link {
    color: var(--text-secondary);
    text-decoration: underline;
    text-decoration-color: var(--border-strong);
    text-underline-offset: 2px;
    transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.sidebar-footer-link:hover {
    color: var(--text-primary);
    text-decoration-color: currentColor;
}

/* Desktop Breakpoints */
@media (min-width: 640px) {
    .lab-sidebar {
        padding: 1.25rem;
    }
}

@media (min-width: 1024px) {
    .lab-sidebar {
        flex: none;
        width: 400px;
        flex-shrink: 0;
        border-top: 0;
        border-left: 1px solid var(--border-subtle);
    }
    .lab-sidebar.sidebar-collapsed {
        width: 0px !important;
        padding: 0px !important;
        border-width: 0px !important;
        overflow: hidden !important;
        opacity: 0;
    }
}

@media (min-width: 1280px) {
    .lab-sidebar {
        width: 430px;
    }
}

@media (max-width: 1279px) {
    .lab-equation-box .katex {
        font-size: 0.79rem;
    }
}

/* Mobile Collapsible Bottom Inspector Bar & Sheet (< 1024px) */
@media (max-width: 1023px) {
    .lab-stage-layout {
        padding-bottom: 52px;
    }
    .mobile-sheet-backdrop.mobile-sheet-open {
        display: block;
        position: absolute;
        inset: 0;
        z-index: 30;
        background: rgba(8, 12, 19, 0.45);
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
    }
    .lab-sidebar {
        display: flex;
        flex-direction: column;
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 35;
        width: 100%;
        height: 52px;
        padding: 0;
        overflow: hidden;
        border-left: 0;
        border-right: 0;
        border-bottom: 0;
        border-top: 1px solid var(--border-subtle);
        border-radius: 0;
        background-color: var(--bg-surface);
        transition: height 0.22s var(--ease-lab), border-radius 0.22s var(--ease-lab), box-shadow 0.22s ease;
    }
    .lab-sidebar.mobile-sheet-open {
        height: 74%;
        max-height: calc(100% - 2rem);
        border-top: 1px solid var(--border-strong);
        border-radius: 14px 14px 0 0;
        box-shadow: 0 -14px 36px rgba(0, 0, 0, 0.42);
    }
    .mobile-sheet-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        width: 100%;
        height: 52px;
        padding: 0 1rem;
        flex-shrink: 0;
        background: transparent;
        border: 0;
        text-align: left;
    }
    .mobile-sheet-toggle:hover {
        background-color: var(--bg-panel);
    }
    .lab-sidebar.mobile-sheet-open .mobile-sheet-toggle {
        border-bottom: 1px solid var(--border-subtle);
    }
    .mobile-sheet-title {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        min-width: 0;
    }
    .lab-sidebar-content {
        display: none;
    }
    .lab-sidebar.mobile-sheet-open .lab-sidebar-content {
        display: block;
        flex: 1 1 0%;
        min-height: 0;
        overflow-y: auto;
        padding: 0.75rem 1rem 1.25rem;
        -webkit-overflow-scrolling: touch;
    }
    .lab-sidebar .sidebar-title-row {
        display: none;
    }
}

/* Short Landscape Phone Overrides (placed after mobile sheet block so cascade holds cleanly) */
@media (max-height: 500px) and (min-width: 560px) and (max-width: 1023px) {
    .lab-header {
        padding-top: 0.35rem;
        padding-bottom: 0.35rem;
    }
    .lab-stage-layout {
        padding-bottom: 44px;
    }
    .lab-stage-layout > .lab-sidebar {
        height: 44px;
    }
    .lab-stage-layout > .lab-sidebar .mobile-sheet-toggle {
        height: 44px;
        padding: 0 0.875rem;
    }
    .lab-stage-layout > .lab-sidebar.mobile-sheet-open {
        top: 0;
        left: auto;
        right: 0;
        bottom: 0;
        width: min(360px, 84vw);
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        border-top: 0;
        border-left: 1px solid var(--border-strong);
    }
}
