/* ==========================================================================
   NABLEIKR // THE NEURAL SINGULARITY & ORBITAL MONOLITHS (CONCEPT A)
   Next-Gen GPU Shader Stage, Spatial Portals, Anchor HUD, & Terminal Tray
   ========================================================================== */

:root {
    /* Physics-Based Spring & Bounce Easing (CSS linear() timing functions) */
    --spring-easing: linear(
        0, 0.016 0.5%, 0.06 1%, 0.226 2%, 1.116 5.4%, 1.375 6.6%,
        1.527 7.7%, 1.565 8.2%, 1.585 8.8%, 1.581 9.3%, 1.559 9.8%,
        1.458 10.9%, 0.937 14.3%, 0.784 15.5%, 0.693 16.6%, 0.67 17.1%,
        0.657 17.7%, 0.671 18.7%, 0.729 19.8%, 1.042 23.3%, 1.13 24.5%,
        1.182 25.6%, 1.201 26.7%, 1.192 27.7%, 1.156 28.8%, 0.977 32.2%,
        0.925 33.4%, 0.894 34.5%, 0.882 35.6%, 0.887 36.6%, 0.907 37.7%,
        1.045 42.4%, 1.069 44.5%, 1.059 46.3%, 0.979 50.9%, 0.96 53.4%,
        0.966 55.3%, 1.013 59.9%, 1.024 62.3%, 0.986 71.2%, 1.008 79.9%,
        0.995 88.9%, 1
    );
    --gentle-spring: linear(
        0, 0.009, 0.035 2.1%, 0.141, 0.281 6.7%, 0.723 12.9%, 0.938 16.7%,
        1.017, 1.077, 1.121, 1.149 24.3%, 1.159, 1.163, 1.161, 1.154 29.9%,
        1.129 32.8%, 1.051 39.6%, 1.017 43.1%, 0.991, 0.977 51%, 0.974 53.8%,
        0.975 57.1%, 0.997 69.8%, 1.003 76.9%, 1.004 83.8%, 1
    );

    /* Dynamic Singularity Biome Tokens (Default: Nocturne Sentinel) */
    --singularity-primary: #ff7a18;
    --singularity-secondary: #0284c7;
    --singularity-hot: #fde047;
    --singularity-glow: rgba(255, 122, 24, 0.34);
    --singularity-surface: rgba(8, 12, 22, 0.72);
    --singularity-border: rgba(255, 122, 24, 0.42);

    /* Terminal Corner Popup Dimensions */
    --tray-docked-width: min(340px, calc(100vw - 32px));
    --tray-docked-height: 118px;
    --tray-open-width: min(680px, calc(100vw - 32px));
    --tray-open-height: min(500px, 68dvh);
    --tray-minimized-height: 30px;
}

/* Biome Theme Overrides Synchronized with Terminal Phosphor Themes */
body.theme-cyan {
    --singularity-primary: #00f0ff;
    --singularity-secondary: #7c3aed;
    --singularity-hot: #38bdf8;
    --singularity-glow: rgba(0, 240, 255, 0.28);
    --singularity-border: rgba(0, 240, 255, 0.34);
}

body.theme-blood {
    --singularity-primary: #ff2244;
    --singularity-secondary: #991b1b;
    --singularity-hot: #fb7185;
    --singularity-glow: rgba(255, 34, 68, 0.32);
    --singularity-border: rgba(255, 34, 68, 0.38);
}

body.theme-amber {
    --singularity-primary: #f59e0b;
    --singularity-secondary: #b45309;
    --singularity-hot: #fde047;
    --singularity-glow: rgba(245, 158, 11, 0.3);
    --singularity-border: rgba(245, 158, 11, 0.38);
}

body.theme-green {
    --singularity-primary: #22c55e;
    --singularity-secondary: #0d9488;
    --singularity-hot: #4ade80;
    --singularity-glow: rgba(34, 197, 94, 0.28);
    --singularity-border: rgba(34, 197, 94, 0.36);
}

body.theme-mono {
    --singularity-primary: #e2e8f0;
    --singularity-secondary: #64748b;
    --singularity-hot: #ffffff;
    --singularity-glow: rgba(226, 232, 240, 0.24);
    --singularity-border: rgba(226, 232, 240, 0.34);
}

body.theme-sentinel {
    --singularity-primary: #ff7a18;
    --singularity-secondary: #0284c7;
    --singularity-hot: #fde047;
    --singularity-glow: rgba(255, 122, 24, 0.34);
    --singularity-border: rgba(255, 122, 24, 0.42);
}

/* ==========================================================================
   1. MASTER SINGULARITY STAGE & HTML-IN-CANVAS / SHADER VIEWPORT
   ========================================================================== */

.singularity-stage {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    overflow: hidden;
    z-index: 5;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding-bottom: 0;
    pointer-events: none;
    user-select: none;
}

#singularity-canvas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    z-index: 1;
    display: block;
    pointer-events: auto;
    cursor: crosshair;
    background: radial-gradient(circle at 50% 44%, #0d1326 0%, #05070c 70%, #020305 100%);
}

/* HTML-in-Canvas descendant stamp element */
.canvas-hud-stamp {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 4px 10px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.14em;
    color: var(--singularity-primary);
    background: rgba(5, 10, 20, 0.75);
    border: 1px solid var(--singularity-border);
    border-radius: 4px;
    pointer-events: none;
    opacity: 0;
}

/* Orbital SVG Vector Overlay (Tether Lines & Accretion Rings) */
.orbital-vector-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    z-index: 2;
    pointer-events: none;
}

.orbital-ring {
    fill: none;
    stroke: var(--singularity-primary);
    stroke-opacity: 0.14;
    stroke-width: 1;
    stroke-dasharray: 6 10;
    transform-origin: 50% 44%;
    animation: orbit-spin 90s linear infinite;
}

.orbital-ring.ring-inner {
    stroke-opacity: 0.22;
    stroke-dasharray: 3 6;
    animation-duration: 55s;
    animation-direction: reverse;
}

.tether-line {
    stroke: var(--singularity-primary);
    stroke-opacity: 0.22;
    stroke-width: 1;
    stroke-dasharray: 4 4;
    transition: stroke-opacity 0.3s ease, stroke-width 0.3s ease;
}

.tether-line.active {
    stroke-opacity: 0.75;
    stroke-width: 1.75;
}

@keyframes orbit-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   2. TOP TELEMETRY HUD BAR & BIOME / PULSE CONTROLS
   ========================================================================== */

.singularity-hud-bar {
    position: relative;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 20px;
    background: linear-gradient(180deg, rgba(6, 9, 16, 0.88) 0%, rgba(6, 9, 16, 0.42) 75%, transparent 100%);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    pointer-events: auto;
    flex-wrap: wrap;
}

.hud-brand-cluster {
    display: flex;
    align-items: center;
    gap: 14px;
}

.hud-core-emblem {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--singularity-primary);
    background: radial-gradient(circle at 50% 50%, var(--singularity-primary) 0%, transparent 68%);
    box-shadow: 0 0 16px var(--singularity-glow);
    display: grid;
    place-items: center;
    position: relative;
}

.hud-core-emblem::after {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #020409;
    box-shadow: 0 0 6px #ffffff;
}

.hud-brand-titles {
    display: flex;
    flex-direction: column;
}

.hud-site-title {
    font-family: 'Syne', var(--font-mono);
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.18em;
    color: #ffffff;
    text-transform: uppercase;
    text-shadow: 0 0 14px var(--singularity-glow);
    line-height: 1.15;
}

.hud-site-subtitle {
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    color: var(--singularity-primary);
    text-transform: uppercase;
    opacity: 0.9;
}

.hud-telemetry-readout {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.telemetry-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(12, 18, 32, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    color: #cbd5e1;
}

.telemetry-chip strong {
    color: var(--singularity-primary);
    font-weight: 700;
}

.telemetry-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--singularity-primary);
    box-shadow: 0 0 8px var(--singularity-primary);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.45; transform: scale(0.8); }
}

.hud-actions-cluster {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Biome Switcher Pills */
.biome-switcher {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px;
    border-radius: 999px;
    background: rgba(9, 13, 24, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.biome-btn {
    appearance: none;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 700;
    padding: 4px 9px;
    border-radius: 999px;
    cursor: pointer;
    letter-spacing: 0.05em;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.3s ease-out;
    transition-timing-function: var(--spring-easing);
}

.biome-btn:hover {
    color: #ffffff;
    transform: scale(1.06);
}

.biome-btn[aria-pressed="true"] {
    background: var(--singularity-primary);
    color: #030712;
    box-shadow: 0 0 12px var(--singularity-glow);
}

.hud-action-btn {
    appearance: none;
    border: 1px solid var(--singularity-border);
    background: rgba(12, 18, 32, 0.78);
    color: #f8fafc;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    backdrop-filter: blur(8px);
    transition: transform 0.45s ease-out, border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    transition-timing-function: var(--spring-easing);
}

.hud-action-btn:hover,
.hud-action-btn:focus-visible {
    transform: translateY(-1px) scale(1.04);
    border-color: var(--singularity-primary);
    box-shadow: 0 0 16px var(--singularity-glow);
    background: rgba(0, 240, 255, 0.12);
    outline: none;
}

.hud-action-btn.btn-accent {
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.2), rgba(124, 58, 237, 0.28));
    border-color: var(--singularity-primary);
}

/* ==========================================================================
   3. CENTRAL SINGULARITY CORE & ORBITAL MONOLITHS CONSTELLATION
   ========================================================================== */

.singularity-arena {
    position: relative;
    z-index: 10;
    flex: 1;
    width: 100%;
    max-width: 1480px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(250px, 320px) 1fr minmax(250px, 320px);
    grid-template-rows: 1fr;
    gap: 16px 24px;
    padding: 8px 24px 14px;
    align-items: center;
    pointer-events: none;
}

/* Center Singularity Interactive Event Horizon Target */
.singularity-core-zone {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    min-height: 210px;
    pointer-events: none;
}

.singularity-horizon-reticle {
    width: clamp(150px, 20vw, 225px);
    height: clamp(150px, 20vw, 225px);
    border-radius: 50%;
    border: 1px dashed rgba(255, 255, 255, 0.18);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    pointer-events: auto;
    cursor: pointer;
    anchor-name: --singularity-core-anchor;
    transition: transform 0.6s ease-out, border-color 0.3s ease;
    transition-timing-function: var(--spring-easing);
}

.singularity-horizon-reticle:hover {
    transform: scale(1.06);
    border-color: var(--singularity-primary);
}

.core-reticle-tag {
    font-size: 0.62rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.88);
    background: rgba(2, 4, 10, 0.82);
    border: 1px solid var(--singularity-border);
    padding: 4px 11px;
    border-radius: 999px;
    backdrop-filter: blur(6px);
    box-shadow: 0 0 16px rgba(0, 0, 0, 0.9);
}

.singularity-hero-caption {
    margin-top: 14px;
    pointer-events: auto;
}

.singularity-hero-kicker {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    color: var(--singularity-primary);
    background: rgba(4, 7, 16, 0.78);
    border: 1px solid var(--singularity-border);
    padding: 3px 12px;
    border-radius: 999px;
    text-transform: uppercase;
    margin-bottom: 6px;
    backdrop-filter: blur(6px);
}

.singularity-hero-heading {
    font-family: 'Syne', sans-serif;
    font-size: clamp(1.35rem, 2.5vw, 2.25rem);
    font-weight: 800;
    letter-spacing: 0.08em;
    color: #ffffff;
    text-transform: uppercase;
    text-shadow: 0 2px 24px rgba(0, 0, 0, 0.9), 0 0 22px var(--singularity-glow);
    text-wrap: balance;
}

/* Monolith Columns */
.monolith-wing-left {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
    justify-content: center;
}

.monolith-wing-right {
    grid-column: 3;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
    justify-content: center;
    padding-bottom: 64px;
}

/* ==========================================================================
   4. ORBITAL MONOLITH CARDS (3D Tilt, Shaped Cutouts, sibling-index() Stagger)
   ========================================================================== */

@keyframes monolith-entry {
    from {
        opacity: 0;
        transform: translateY(22px) scale(0.94);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.orbital-monolith {
    --stagger-time: 0.1s;
    --tilt-x: 0deg;
    --tilt-y: 0deg;
    --glare-x: 50%;
    --glare-y: 50%;
    --monolith-accent: var(--singularity-primary);

    position: relative;
    pointer-events: auto;
    background: linear-gradient(155deg, rgba(11, 16, 29, 0.84) 0%, rgba(5, 8, 16, 0.9) 100%);
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-left: 3px solid var(--monolith-accent);
    border-radius: 14px;
    padding: 13px 15px;
    backdrop-filter: blur(14px);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.62), inset 0 1px 0 rgba(255, 255, 255, 0.08);

    /* Individual transform properties + 3D perspective tilt */
    transform: perspective(900px) rotateX(var(--tilt-x)) rotateY(var(--tilt-y));
    transition:
        transform 0.45s ease-out,
        border-color 0.25s ease,
        box-shadow 0.25s ease;
    transition-timing-function: var(--spring-easing);

    /* Staggered entry animation using sibling-index() with fallback */
    animation: monolith-entry 0.55s cubic-bezier(0.16, 1, 0.3, 1) backwards;
    animation-delay: calc(var(--sibling-index, 1) * var(--stagger-time));
    animation-delay: calc(sibling-index() * var(--stagger-time));
}

/* Explicit CSS Anchor Names for each Monolith */
#monolith-audio   { anchor-name: --monolith-audio;   --monolith-accent: #ff2a55; }
#monolith-eclipse { anchor-name: --monolith-eclipse; --monolith-accent: #38bdf8; }
#monolith-wrench  { anchor-name: --monolith-wrench;  --monolith-accent: #a855f7; }
#monolith-spire   { anchor-name: --monolith-spire;   --monolith-accent: #f59e0b; }
#monolith-vault   { anchor-name: --monolith-vault;   --monolith-accent: #10b981; max-width: 470px; width: 100%; }

.orbital-monolith::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(
        circle at var(--glare-x) var(--glare-y),
        rgba(255, 255, 255, 0.12) 0%,
        transparent 60%
    );
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.orbital-monolith:hover,
.orbital-monolith:focus-within {
    border-color: var(--monolith-accent);
    box-shadow:
        0 18px 42px rgba(0, 0, 0, 0.78),
        0 0 24px color-mix(in srgb, var(--monolith-accent) 32%, transparent);
}

.orbital-monolith:hover::before {
    opacity: 1;
}

/* Shaped decorative corner accent using adjacent element masking so text is never cropped */
.monolith-corner-notch {
    position: absolute;
    top: 0;
    right: 0;
    width: 38px;
    height: 22px;
    background: color-mix(in srgb, var(--monolith-accent) 22%, transparent);
    border-top-right-radius: 13px;
    pointer-events: none;
    -webkit-mask-image: linear-gradient(225deg, black 55%, transparent 56%);
    mask-image: linear-gradient(225deg, black 55%, transparent 56%);
}

.monolith-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.monolith-sector-id {
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--monolith-accent);
}

.monolith-live-Viz {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    height: 14px;
}

.viz-bar {
    width: 3px;
    height: 100%;
    background: var(--monolith-accent);
    border-radius: 2px;
    animation: viz-equalizer 1.1s ease-in-out infinite alternate;
}
.viz-bar:nth-child(2) { animation-delay: 0.2s; height: 60%; }
.viz-bar:nth-child(3) { animation-delay: 0.4s; height: 85%; }
.viz-bar:nth-child(4) { animation-delay: 0.15s; height: 45%; }

@keyframes viz-equalizer {
    0% { transform: scaleY(0.35); opacity: 0.6; }
    100% { transform: scaleY(1); opacity: 1; }
}

.monolith-title {
    font-family: 'Syne', sans-serif;
    font-size: 0.98rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
    width: fit-content;
}

.monolith-desc {
    font-size: 0.74rem;
    line-height: 1.42;
    color: #94a3b8;
    margin-bottom: 10px;
}

/* Quick Tool Pills inside Wrench Lab Monolith */
.monolith-subtools {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 10px;
}

.subtool-chip {
    font-size: 0.65rem;
    color: #e2e8f0;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 2px 7px;
    border-radius: 6px;
    text-decoration: none;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.subtool-chip:hover {
    background: rgba(168, 85, 247, 0.22);
    border-color: #a855f7;
    color: #ffffff;
}

.monolith-actions {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}

.monolith-btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 5px 11px;
    border-radius: 7px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid var(--monolith-accent);
    background: color-mix(in srgb, var(--monolith-accent) 18%, rgba(10, 15, 28, 0.9));
    color: #ffffff;
    transition: transform 0.35s ease-out, background-color 0.2s ease, box-shadow 0.2s ease;
    transition-timing-function: var(--spring-easing);
}

.monolith-btn:hover,
.monolith-btn:focus-visible {
    transform: scale(1.05);
    background: color-mix(in srgb, var(--monolith-accent) 36%, rgba(10, 15, 28, 0.95));
    box-shadow: 0 0 14px color-mix(in srgb, var(--monolith-accent) 45%, transparent);
    outline: none;
}

.monolith-btn.btn-secondary {
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.06);
    color: #cbd5e1;
}

.monolith-btn.btn-secondary:hover {
    border-color: var(--monolith-accent);
    color: #ffffff;
}

/* ==========================================================================
   5. CSS ANCHOR POSITIONING POPOVERS & TOP-LAYER DISCRETE ANIMATIONS
   ========================================================================== */

@supports (anchor-name: --singularity-core-anchor) {
    .anchored-popover[popover] {
        inset: auto;
        margin: unset;
        position: fixed;
        position-anchor: --singularity-core-anchor;
        position-area: block-end;
        position-try-fallbacks: flip-block, flip-inline;
        container-type: anchored;
    }
}

.qualia-popover[popover] {
    width: min(460px, 92vw);
    background: rgba(8, 12, 24, 0.95);
    border: 1px solid var(--singularity-primary);
    border-radius: 14px;
    padding: 18px 20px;
    color: #e2e8f0;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85), 0 0 30px var(--singularity-glow);
    backdrop-filter: blur(18px);

    /* Base closed state for discrete top-layer transition */
    opacity: 0;
    transform: scale(0.92) translateY(8px);
    transition-property: opacity, transform, display, overlay;
    transition-duration: 0.32s;
    transition-timing-function: ease-out;
    transition-behavior: allow-discrete;
}

.qualia-popover[popover]:is(:popover-open, .\:popover-open) {
    opacity: 1;
    transform: scale(1) translateY(0);

    @starting-style {
        opacity: 0;
        transform: scale(0.92) translateY(8px);
    }
}

.qualia-popover::backdrop {
    background-color: rgba(2, 4, 10, 0);
    transition:
        display 0.32s allow-discrete,
        overlay 0.32s allow-discrete,
        background-color 0.32s ease-out;
}

.qualia-popover:is(:popover-open, .\:popover-open)::backdrop {
    background-color: rgba(2, 4, 10, 0.55);

    @starting-style {
        background-color: rgba(2, 4, 10, 0);
    }
}

/* Position-aware arrow using Anchored Container Queries */
@supports (container-type: anchored) {
    .qualia-popover-inner::before {
        content: "▲";
        position: absolute;
        inset-block-start: -14px;
        inset-inline-start: calc(50% - 6px);
        color: var(--singularity-primary);
        font-size: 11px;
    }

    @container anchored(fallback: flip-block) {
        .qualia-popover-inner::before {
            content: "▼";
            inset-block-start: auto;
            inset-block-end: -14px;
        }
    }
}

/* ==========================================================================
   6. VIEW TRANSITIONS API: HOLOGRAPHIC MONOLITH INSPECTOR OVERLAY
   ========================================================================== */

.orbital-monolith.is-transitioning-card {
    view-transition-name: monolith-focus-card;
}

.orbital-monolith.is-transitioning-card .monolith-title {
    view-transition-name: monolith-focus-title;
}

.monolith-inspector-overlay {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: none;
    place-items: center;
    background: rgba(3, 6, 14, 0.76);
    backdrop-filter: blur(12px);
    padding: 20px;
    pointer-events: auto;
}

.monolith-inspector-overlay.open {
    display: grid;
}

.inspector-card {
    view-transition-name: monolith-focus-card;
    width: min(640px, 94vw);
    background: linear-gradient(155deg, rgba(12, 18, 34, 0.96) 0%, rgba(6, 10, 20, 0.98) 100%);
    border: 1px solid var(--singularity-primary);
    border-radius: 18px;
    padding: 24px 28px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.9), 0 0 40px var(--singularity-glow);
    color: #f1f5f9;
}

#inspector-heading {
    view-transition-name: monolith-focus-title;
    width: fit-content;
    font-family: 'Syne', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 8px;
    outline: none;
}

.inspector-sector-badge {
    display: inline-block;
    font-size: 0.7rem;
    letter-spacing: 0.16em;
    color: var(--singularity-primary);
    text-transform: uppercase;
    margin-bottom: 6px;
}

.inspector-body {
    font-size: 0.88rem;
    line-height: 1.65;
    color: #cbd5e1;
    margin-bottom: 18px;
}

.inspector-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.inspector-metric-box {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 10px 12px;
}

.inspector-metric-label {
    font-size: 0.65rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.inspector-metric-val {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--singularity-primary);
    margin-top: 2px;
}

/* 2.5D Depth-Displaced Sentinel Showcase inside Monolith 04 Inspector */
.inspector-sentinel-showcase {
    margin-bottom: 16px;
}

.inspector-sentinel-showcase[hidden] {
    display: none !important;
}

.sentinel-showcase-viewport {
    position: relative;
    width: 100%;
    height: clamp(220px, 34dvh, 290px);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 122, 24, 0.45);
    background: #04070f;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.8), inset 0 0 24px rgba(255, 122, 24, 0.14);
}

#inspector-sentinel-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: crosshair;
}

.sentinel-hud-top {
    position: absolute;
    top: 8px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    flex-wrap: wrap;
}

.sentinel-badge,
.sentinel-probe-readout {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(4, 8, 16, 0.82);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #e2e8f0;
}

.sentinel-badge {
    color: #ff9838;
    border-color: rgba(255, 122, 24, 0.45);
    font-weight: 700;
}

.sentinel-probe-readout {
    color: #38bdf8;
}

.sentinel-hud-bottom {
    position: absolute;
    bottom: 8px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.sentinel-mode-group {
    display: inline-flex;
    gap: 4px;
    background: rgba(4, 8, 16, 0.85);
    padding: 3px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(8px);
}

.sentinel-mode-btn {
    appearance: none;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 5px;
    cursor: pointer;
    letter-spacing: 0.05em;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.sentinel-mode-btn:hover {
    color: #ffffff;
}

.sentinel-mode-btn[aria-pressed="true"] {
    background: #ff7a18;
    color: #030712;
    box-shadow: 0 0 10px rgba(255, 122, 24, 0.45);
}

.sentinel-stage-btn {
    appearance: none;
    border: 1px solid #ff7a18;
    background: rgba(255, 122, 24, 0.22);
    color: #ffffff;
    font-family: var(--font-mono);
    font-size: 0.64rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 7px;
    cursor: pointer;
    letter-spacing: 0.06em;
    backdrop-filter: blur(8px);
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.25s ease;
}

.sentinel-stage-btn:hover {
    background: rgba(255, 122, 24, 0.42);
    box-shadow: 0 0 14px rgba(255, 122, 24, 0.55);
    transform: translateY(-1px);
}

/* ==========================================================================
   7. BOTTOM TELEMETRY BAR (.site-footer) & TERMINAL TRAY (ttyS0)
   ========================================================================== */

.singularity-stage .site-footer {
    position: relative;
    z-index: 15;
    height: auto;
    min-height: 44px;
    padding: 8px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    flex-wrap: wrap;
    background: linear-gradient(0deg, rgba(6, 9, 16, 0.92) 0%, rgba(6, 9, 16, 0.56) 75%, transparent 100%);
    backdrop-filter: blur(10px);
    border-top: 1px solid color-mix(in oklch, var(--singularity-primary) 26%, rgba(255, 255, 255, 0.08));
    pointer-events: auto;
    font-family: var(--font-mono);
}

.singularity-stage .footer-status-tag {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(12, 18, 32, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--singularity-primary);
}

.singularity-stage .footer-status-warn {
    color: #f59e0b;
}

.singularity-stage .footer-links {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 6px;
    border-radius: 999px;
    background: rgba(9, 13, 24, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.12);
    flex-wrap: wrap;
    justify-content: center;
}

.singularity-stage .footer-links a,
.singularity-stage .footer-links .footer-link-btn {
    appearance: none;
    border: 1px solid transparent;
    background: transparent;
    color: #cbd5e1;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-decoration: none;
    padding: 3px 9px;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.3s ease-out;
    transition-timing-function: var(--spring-easing);
}

.singularity-stage .footer-links a:hover,
.singularity-stage .footer-links a:focus-visible,
.singularity-stage .footer-links .footer-link-btn:hover,
.singularity-stage .footer-links .footer-link-btn:focus-visible {
    color: #ffffff;
    background: color-mix(in oklch, var(--singularity-primary) 20%, rgba(12, 18, 32, 0.85));
    border-color: var(--singularity-primary);
    box-shadow: 0 0 12px var(--singularity-glow);
    text-decoration: none;
    transform: scale(1.05);
    outline: none;
}

.singularity-stage .footer-sep {
    color: rgba(148, 163, 184, 0.35);
    font-size: 0.65rem;
    user-select: none;
}

.singularity-stage .footer-credits {
    font-size: 0.66rem;
    letter-spacing: 0.08em;
    color: #94a3b8;
    text-transform: uppercase;
    opacity: 0.9;
}

#terminal-tray.terminal-app-container {
    view-transition-name: terminal-tray-surface;
    position: fixed;
    left: auto;
    right: 16px;
    bottom: 56px;
    width: var(--tray-docked-width);
    height: var(--tray-docked-height);
    z-index: 40;
    background-color: rgba(8, 11, 18, 0.92);
    backdrop-filter: blur(20px);
    border: 1px solid var(--singularity-border);
    border-radius: 12px;
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.88), 0 0 22px var(--singularity-glow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.35s ease-out, height 0.35s ease-out, right 0.3s ease, bottom 0.3s ease, border-radius 0.3s ease;
    transition-timing-function: var(--gentle-spring);
}

/* Expanded Corner Popup Window State */
#terminal-tray.terminal-app-container[data-tray-state="open"] {
    left: auto;
    right: 16px;
    bottom: 56px;
    width: var(--tray-open-width);
    height: var(--tray-open-height);
    border-radius: 14px;
    background-color: rgba(9, 11, 16, 0.97);
    border: 1px solid var(--singularity-primary);
    box-shadow: 0 26px 70px rgba(0, 0, 0, 0.94), 0 0 36px var(--singularity-glow);
}

/* Fullscreen Console State (or when MUD is active) */
#terminal-tray.terminal-app-container[data-tray-state="fullscreen"],
#terminal-tray.terminal-app-container.mud-playing {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    border: none;
    background-color: var(--term-bg);
    z-index: 60;
    transition: none;
}

/* Minimized Corner Pill State */
#terminal-tray.terminal-app-container[data-tray-state="minimized"] {
    left: auto;
    right: 16px;
    bottom: 56px;
    width: min(295px, calc(100vw - 32px));
    height: var(--tray-minimized-height);
    border-radius: 999px;
}

/* Quick-Command & Tray Handle Strip */
.tray-dock-handlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    height: 24px;
    background: linear-gradient(90deg, rgba(0, 240, 255, 0.1), rgba(124, 58, 237, 0.14), rgba(0, 240, 255, 0.1));
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.64rem;
    flex-shrink: 0;
    gap: 6px;
}

.tray-quick-commands {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
}

.tray-quick-label {
    color: #94a3b8;
    font-size: 0.6rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.tray-cmd-chip {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(15, 23, 42, 0.78);
    color: var(--term-accent);
    font-family: var(--font-mono);
    font-size: 0.6rem;
    padding: 1px 5px;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.tray-cmd-chip:hover {
    background: rgba(0, 240, 255, 0.18);
    border-color: var(--term-accent);
    color: #ffffff;
}

.tray-ctrl-btn {
    appearance: none;
    border: 1px solid var(--singularity-border);
    background: rgba(0, 240, 255, 0.14);
    color: #ffffff;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    letter-spacing: 0.04em;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.tray-ctrl-btn:hover {
    background: rgba(0, 240, 255, 0.28);
    border-color: var(--singularity-primary);
}

/* Compact adjustments when tray is a small bottom-right corner popup ("docked" / "open") */
#terminal-tray .window-title,
#terminal-tray .status-pill,
#terminal-tray .tty-param,
#terminal-tray .audio-indicator {
    white-space: nowrap;
}

#terminal-tray .titlebar-left {
    min-width: 0;
    overflow: hidden;
}

#terminal-tray .window-title {
    overflow: hidden;
    text-overflow: ellipsis;
}

#terminal-tray[data-tray-state="docked"] .tray-chip-extra,
#terminal-tray[data-tray-state="minimized"] .tray-chip-extra {
    display: none;
}

#terminal-tray[data-tray-state="docked"] .terminal-titlebar {
    height: 22px;
    padding: 0 8px;
    font-size: 9px;
    gap: 6px;
}

#terminal-tray[data-tray-state="docked"] .terminal-app-icon {
    width: 15px;
    height: 15px;
    font-size: 8.5px;
    flex-shrink: 0;
}

#terminal-tray[data-tray-state="docked"] .tty-param,
#terminal-tray[data-tray-state="docked"] .linux-window-controls,
#terminal-tray[data-tray-state="docked"] .window-app-name {
    display: none;
}

#terminal-tray[data-tray-state="docked"] .window-status {
    gap: 4px;
    flex-shrink: 0;
}

#terminal-tray[data-tray-state="docked"] .status-pill,
#terminal-tray[data-tray-state="docked"] .audio-indicator {
    padding: 1px 4px;
    font-size: 8px;
}

#terminal-tray[data-tray-state="docked"] .terminal-viewport {
    padding: 4px 10px;
    font-size: 11px;
}

#terminal-tray[data-tray-state="docked"] .motd-header {
    font-size: 9.5px;
    line-height: 1.2;
    margin-bottom: 4px;
}

#terminal-tray[data-tray-state="docked"] .ascii-banner {
    font-size: 6.5px;
    line-height: 1.05;
    margin: 2px 0;
}

/* ==========================================================================
   8. RESPONSIVE & ACCESSIBILITY (PREFERS-REDUCED-MOTION) COMPLIANCE
   ========================================================================== */

@media (max-width: 1024px) {
    .singularity-stage {
        overflow-y: auto;
        pointer-events: auto;
    }

    .singularity-arena {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto auto;
    }

    .singularity-core-zone {
        grid-column: 1 / -1;
        grid-row: 1;
        min-height: 170px;
    }

    .monolith-wing-left {
        grid-column: 1;
        grid-row: 2;
    }

    .monolith-wing-right {
        grid-column: 2;
        grid-row: 2;
    }

    .monolith-wing-center-bottom {
        grid-column: 1 / -1;
        grid-row: 3;
    }
}

@media (max-width: 680px) {
    .singularity-arena {
        grid-template-columns: 1fr;
        padding: 8px 14px 16px;
    }

    .monolith-wing-left,
    .monolith-wing-right,
    .monolith-wing-center-bottom {
        grid-column: 1;
        grid-row: auto;
    }

    .hud-telemetry-readout {
        display: none;
    }
}

/* MANDATORY Reduced Motion Compliance for View Transitions, Top Layer, Spring & Stagger */
@media (prefers-reduced-motion: reduce) {
    ::view-transition-group(*),
    ::view-transition-old(*),
    ::view-transition-new(*) {
        animation: none !important;
    }

    .orbital-monolith,
    .hud-action-btn,
    .biome-btn,
    .monolith-btn,
    .singularity-horizon-reticle,
    .orbital-ring,
    .viz-bar,
    .telemetry-dot {
        animation: none !important;
        transition: none !important;
        transform: none !important;
    }

    .qualia-popover[popover] {
        transform: none;
        transition-duration: 0.1s;
    }

    @starting-style {
        .qualia-popover[popover]:is(:popover-open, .\:popover-open) {
            transform: none;
        }
    }
}
