:root {
    --void: #0c0a14;
    --panel: #14102a;
    --surface: #1a1228;
    --sapphire: #2d47a8;
    --ruby: #a8312d;
    --emerald: #2da856;
    --topaz: #c4882d;
    --text-primary: #d8d2e4;
    --text-secondary: #8b7fa6;
    --border: #2a1f3d;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--void);
    color: var(--text-primary);
    font-family: 'Source Serif 4', serif;
    font-weight: 400;
    line-height: 1.72;
    font-size: clamp(15px, 1.2vw, 18px);
    overflow-x: hidden;
}

body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        transparent,
        transparent 2px,
        rgba(12, 10, 20, 0.15) 2px,
        rgba(12, 10, 20, 0.15) 4px
    );
    animation: scanline-drift 8s linear infinite;
}

@keyframes scanline-drift {
    from { transform: translateY(0); }
    to { transform: translateY(4px); }
}

/* Navigation */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 48px;
    background: rgba(12, 10, 20, 0.95);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1000;
    border-bottom: 1px solid var(--border);
    opacity: 0;
    transition: opacity 0.6s ease;
}

.top-bar.visible {
    opacity: 1;
}

.site-name {
    font-family: 'Libre Baskerville', serif;
    font-style: italic;
    font-size: 16px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--topaz);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Opening Sequence */
.opening {
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--void);
    position: relative;
    z-index: 100;
}

.typewriter-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(14px, 1.5vw, 20px);
    color: var(--text-primary);
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.typewriter-text::after {
    content: '█';
    animation: blink-cursor 0.8s step-end infinite;
}

@keyframes blink-cursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Ticker Tape */
.ticker-tape {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 32px;
    background: var(--void);
    border-top: 1px solid var(--border);
    overflow: hidden;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.ticker-tape.visible {
    opacity: 1;
}

.ticker-content {
    display: inline-block;
    white-space: nowrap;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: var(--topaz);
    line-height: 32px;
    letter-spacing: 0.04em;
    animation: ticker-scroll 40s linear infinite;
}

@keyframes ticker-scroll {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

/* Dashboard Layout */
.dashboard {
    display: grid;
    grid-template-columns: 280px 1fr 320px;
    gap: 1px;
    padding: 64px 0 48px;
    min-height: 300vh;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1.2s ease, transform 1.2s ease;
    background: var(--border);
}

.dashboard.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Error Index Sidebar */
.error-index {
    background: var(--surface);
    padding: 24px 16px;
    position: sticky;
    top: 48px;
    height: calc(100vh - 80px);
    overflow-y: auto;
}

.sidebar-title {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.error-thumb {
    width: 64px;
    height: 64px;
    border: 1px solid;
    margin-bottom: 12px;
    background: var(--panel);
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    background-image: radial-gradient(circle, var(--border) 1px, transparent 1px);
    background-size: 8px 8px;
}

.error-thumb:hover {
    transform: perspective(800px) rotateY(8deg) rotateX(-4deg);
}

.error-thumb::after {
    content: attr(data-class) ' [' attr(data-severity) ']';
    position: absolute;
    bottom: -24px;
    left: 0;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 9px;
    color: var(--topaz);
    opacity: 0;
    transition: opacity 0.3s;
    white-space: nowrap;
}

.error-thumb:hover::after {
    opacity: 1;
}

/* Observation Deck */
.observation-deck {
    background: var(--void);
    padding: 32px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-content: start;
}

/* Panels */
.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 32px;
    position: relative;
    box-shadow: inset 0 0 40px rgba(90, 40, 120, 0.08);
    opacity: 0;
    transform: translateX(-40px);
    transition: opacity 0.6s ease, transform 0.6s ease, border-color 0.6s ease;
    background-image: radial-gradient(circle, var(--border) 1px, transparent 1px);
    background-size: 8px 8px;
}

.panel[data-direction="right"] {
    transform: translateX(40px);
}

.panel.in-view {
    opacity: 1;
    transform: translateX(0);
}

.panel:hover {
    transform: perspective(800px) rotateY(2deg) rotateX(-1deg);
}

.panel-tall {
    grid-column: span 1;
}

.panel-wide {
    grid-column: span 2;
}

/* Panel Corners */
.panel-corners::before,
.panel-corners::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    border-color: var(--text-secondary);
    border-style: solid;
}

.panel-corners::before {
    top: 8px;
    left: 8px;
    border-width: 1px 0 0 1px;
}

.panel-corners::after {
    top: 8px;
    right: 8px;
    border-width: 1px 1px 0 0;
}

.panel::before,
.panel::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    border-color: var(--text-secondary);
    border-style: solid;
}

.panel::before {
    bottom: 8px;
    left: 8px;
    border-width: 0 0 1px 1px;
}

.panel::after {
    bottom: 8px;
    right: 8px;
    border-width: 0 1px 1px 0;
}

.panel-header {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: clamp(20px, 2.5vw, 36px);
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.panel-bezel {
    height: 2px;
    margin-bottom: 20px;
    background: linear-gradient(90deg, transparent, var(--topaz) 20%, var(--topaz) 80%, transparent);
}

.panel-body {
    color: var(--text-primary);
    margin-bottom: 16px;
}

.panel-timestamp {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(11px, 0.9vw, 14px);
    color: var(--topaz);
    letter-spacing: 0.04em;
}

.corrupted {
    font-family: 'IBM Plex Mono', monospace;
    color: var(--ruby);
    filter: blur(4px);
    transition: filter 0.4s ease;
    cursor: pointer;
}

.corrupted:hover {
    filter: blur(0);
}

/* Status Console */
.status-console {
    background: var(--surface);
    padding: 24px 16px;
    position: sticky;
    top: 48px;
    height: calc(100vh - 80px);
    overflow-y: auto;
}

.gauge-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-bottom: 24px;
}

.gauge {
    width: 80px;
    height: 80px;
}

.gauge-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 6;
}

.gauge-fill {
    fill: none;
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 251.2;
    stroke-dashoffset: 251.2;
    transform: rotate(-90deg);
    transform-origin: center;
    transition: stroke-dashoffset 2s ease-out;
}

.gauge-fill.animated {
    animation: gauge-pulse 1.5s ease-in-out infinite;
}

@keyframes gauge-pulse {
    0%, 100% { transform: rotate(-90deg) scale(1); }
    50% { transform: rotate(-90deg) scale(1.05); }
}

.gauge-sapphire { stroke: var(--sapphire); }
.gauge-ruby { stroke: var(--ruby); }
.gauge-emerald { stroke: var(--emerald); }
.gauge-topaz { stroke: var(--topaz); }

.gauge-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 8px;
    fill: var(--text-secondary);
    text-anchor: middle;
    letter-spacing: 0.04em;
}

.gauge-value {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 10px;
    fill: var(--text-primary);
    text-anchor: middle;
}

.console-readout {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    color: var(--emerald);
    line-height: 2;
}

.console-readout.urgent {
    color: var(--ruby);
}

/* Interludes */
.interlude {
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background: var(--void);
}

.interlude-1 {
    background:
        repeating-linear-gradient(45deg, transparent, transparent 20px, rgba(45, 71, 168, 0.03) 20px, rgba(45, 71, 168, 0.03) 40px),
        repeating-linear-gradient(-45deg, transparent, transparent 30px, rgba(168, 49, 45, 0.03) 30px, rgba(168, 49, 45, 0.03) 60px);
    background-blend-mode: difference;
}

.chromatic-layer {
    position: absolute;
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: clamp(28px, 4vw, 52px);
    letter-spacing: -0.02em;
    text-align: center;
    padding: 0 20px;
    transition: transform 0.1s linear;
}

.chromatic-r {
    color: var(--ruby);
    transform: translate(-2px, -2px);
}

.chromatic-g {
    color: var(--emerald);
    transform: translate(2px, 1px);
}

.chromatic-b {
    color: var(--sapphire);
    transform: translate(0, 2px);
    mix-blend-mode: screen;
}

.interlude-2 {
    background: var(--void);
    filter: contrast(1.1) brightness(0.95);
}

.interlude-2::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        transparent,
        transparent 1px,
        rgba(12, 10, 20, 0.2) 1px,
        rgba(12, 10, 20, 0.2) 2px
    );
    background-size: 100% 2px;
}

.interlude-quote {
    font-family: 'Libre Baskerville', serif;
    font-style: italic;
    font-size: clamp(20px, 3vw, 40px);
    color: var(--text-primary);
    text-align: center;
    max-width: 700px;
    padding: 0 24px;
    position: relative;
    z-index: 1;
}

/* Deep Dashboard */
.deep-dashboard {
    min-height: 200vh;
}

.deep-panel {
    border-color: var(--ruby);
}

.deep-index .error-thumb {
    border-color: var(--ruby);
}

/* Epilogue */
.epilogue {
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--void);
}

.epilogue-prompt {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(14px, 1.2vw, 18px);
    color: var(--text-primary);
    letter-spacing: 0.04em;
    animation: blink-cursor 0.8s step-end infinite;
}

.epilogue-prompt::after {
    content: '';
}

/* Flash effect */
.flash-effect {
    animation: jewel-flash 0.3s ease;
}

@keyframes jewel-flash {
    0% { background: var(--sapphire); }
    20% { background: var(--ruby); }
    40% { background: var(--emerald); }
    60% { background: var(--topaz); }
    80% { background: var(--sapphire); }
    100% { background: var(--void); }
}

/* Mobile */
@media (max-width: 768px) {
    .dashboard {
        grid-template-columns: 1fr;
    }

    .error-index,
    .status-console {
        position: relative;
        height: auto;
        top: 0;
    }

    .error-index {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        padding: 16px;
    }

    .observation-deck {
        grid-template-columns: 1fr;
    }

    .panel-wide {
        grid-column: span 1;
    }

    .sidebar-title {
        width: 100%;
    }
}
