/* The same circuit controls and department content adapt to compact/touch viewports. */
@media (max-width: 900px), (pointer: coarse) {
    #aurora {
        height: calc(100dvh - var(--circuit-nav-space, 156px));
        bottom: auto;
    }

    .atlas-node-label {
        padding: 4px 6px;
        font-size: 10px;
        letter-spacing: .1em;
    }

    .circuit-navigation,
    .circuit-navigation:not(:focus-within) {
        top: auto;
        bottom: max(12px, env(safe-area-inset-bottom));
        left: max(12px, env(safe-area-inset-left));
        right: max(12px, env(safe-area-inset-right));
        width: auto;
        height: auto;
        max-width: none;
        padding: 12px;
        border: 1px solid var(--reactor);
        overflow: visible;
        clip-path: none;
        gap: 10px;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .circuit-navigation {
        display: grid;
    }

    .circuit-navigation button {
        min-width: 0;
        min-height: 48px;
        padding: 10px;
        font-size: 13px;
        line-height: 1.5;
        overflow-wrap: anywhere;
        touch-action: manipulation;
    }

    #boot-panel {
        box-sizing: border-box;
        width: min(760px, calc(100% - 24px));
        max-height: calc(100dvh - 24px);
        overflow-y: auto;
        padding: 24px 16px;
    }

    #boot-panel h1 {
        font-size: clamp(20px, 6vw, 36px);
        letter-spacing: 2px;
    }

    #departments > .department {
        box-sizing: border-box;
        height: 100dvh;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        padding: 16px;
        overflow-y: auto;
        overflow-x: hidden;
        overscroll-behavior: contain;
        overflow-wrap: anywhere;
    }

    #departments > .department > * {
        flex-shrink: 0;
        min-width: 0;
    }

    #departments .department-header {
        position: static;
        width: 100%;
        margin: 8px 0 24px;
        transform: none;
    }

    #departments > .department.active .department-header {
        transform: none;
    }

    #departments .department-header h1 {
        font-size: clamp(24px, 7vw, 44px);
        letter-spacing: .12em;
    }

    #departments .department-subtitle {
        font-size: 12px;
        line-height: 1.6;
        letter-spacing: 2px;
    }

    .department button {
        min-height: 44px;
        min-width: 44px;
        box-sizing: border-box;
        white-space: normal;
        touch-action: manipulation;
    }

    #departments .department-return {
        position: sticky;
        top: 0;
        left: auto;
        order: -1;
        align-self: flex-start;
        z-index: 10;
        margin-bottom: 16px;
        background: var(--bg-main);
    }

    #departments .orion-projects,
    #departments .archive-navigation,
    #departments .sentinel-systems {
        position: static;
        transform: none;
        width: 100%;
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
        gap: 12px;
    }

    #departments .project-node,
    #departments .sentinel-system {
        min-height: 120px;
        min-width: 0;
        box-sizing: border-box;
    }

    #departments .project-detail,
    #departments .archive-detail,
    #departments .sentinel-status {
        position: static;
        transform: none;
        box-sizing: border-box;
        width: 100%;
        min-height: 0;
        margin: 20px 0;
        padding: 20px;
    }

    .project-detail:not(.active) {
        display: none;
    }

    .orion-prompt,
    .archive-prompt {
        display: none;
    }

    .personnel-identity,
    .personnel-navigation,
    .personnel-content {
        box-sizing: border-box;
        width: 100%;
        margin: 0 0 20px;
    }

    .personnel-section {
        padding: 20px;
    }

    .detail-description,
    .archive-detail-description,
    .personnel-section-description,
    .sentinel-record-content,
    .workspace-description,
    .archive-record-field-value {
        font-size: 14px;
        line-height: 1.7;
        letter-spacing: .03em;
    }

    #departments .project-workspace,
    #departments .archive-record-viewer {
        position: fixed;
        inset: 0;
        box-sizing: border-box;
        width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        padding: 16px;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .workspace-header,
    .workspace-navigation,
    .workspace-content,
    .workspace-controls {
        box-sizing: border-box;
        width: 100%;
        min-width: 0;
    }

    .workspace-title {
        font-size: clamp(24px, 7vw, 36px);
        letter-spacing: 2px;
    }

    .workspace-navigation {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        overflow: visible;
    }

    .workspace-nav-item,
    .personnel-nav-item,
    .sentinel-system-open,
    .archive-record-item {
        font-size: 12px;
    }

    .workspace-controls {
        position: sticky;
        top: 0;
        order: -1;
        z-index: 2;
        margin: 0 0 16px;
        padding: 8px 0;
        background: var(--bg-main);
    }

    .archive-viewer-header {
        position: sticky;
        top: 0;
        z-index: 1;
        background: var(--bg-main);
    }

    .archive-viewer-content {
        flex: 0 0 auto;
        width: 100%;
    }

    #departments .sentinel-system-record {
        position: fixed;
        inset: 12px;
        width: auto;
        max-height: none;
        transform: none;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 20px;
    }
}
