:root {
    --bg: #000000;
    --surface: #2d2e31;
    --surface-border: #3c4043;
    --text: #e8eaed;
    --muted: #9aa0a6;
    --shadow: rgba(0, 0, 0, 0.35);
    --shadow-soft: rgba(0, 0, 0, 0.18);
    --blue: #4285f4;
    --red: #ea4335;
    --yellow: #fbbc05;
    --green: #34a853;
}

body[data-theme="light"] {
    --bg: #ffffff;
    --surface: #f1f3f4;
    --surface-border: #dadce0;
    --text: #202124;
    --muted: #5f6368;
    --shadow: rgba(60, 64, 67, 0.2);
    --shadow-soft: rgba(60, 64, 67, 0.12);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.switch {
    font-size: 17px;
    position: fixed;
    top: 20px;
    right: 20px;
    display: inline-block;
    width: 3.5em;
    height: 2em;
    z-index: 10;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #ccc;
    box-shadow: inset 2px 5px 10px rgba(0, 0, 0, 0.3);
    transition: 0.4s;
    border-radius: 5px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 1.4em;
    width: 0.1em;
    left: 0.3em;
    bottom: 0.3em;
    background-color: #fff;
    transition: 0.4s;
}

input:checked + .slider {
    background-color: #171717;
    box-shadow: inset 2px 5px 10px rgb(0, 0, 0);
}

input:checked + .slider:before {
    transform: translateX(2.8em) rotate(360deg);
}

.page-404 {
    width: min(1120px, calc(100% - 64px));
    min-height: 100vh;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(320px, 520px) minmax(260px, 1fr);
    align-items: center;
    gap: 56px;
    padding: 48px 0;
}

.content-404 {
    max-width: 520px;
}

.brand-link {
    display: inline-flex;
    margin-bottom: 28px;
}

.site-logo-stack {
    position: relative;
    display: block;
    width: min(220px, 60vw);
}

.site-logo {
    display: block;
    width: 100%;
    height: auto;
    transition: opacity 0.3s ease;
}

.site-logo-light {
    position: absolute;
    inset: 0;
    opacity: 0;
}

.site-logo-dark {
    opacity: 1;
}

body[data-theme="light"] .site-logo-light {
    opacity: 1;
}

body[data-theme="light"] .site-logo-dark {
    opacity: 0;
}

.error-hero {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 18px;
    font-size: clamp(4.8rem, 16vw, 8.5rem);
    font-weight: 700;
    line-height: 0.9;
    letter-spacing: -0.06em;
}

.digit-blue {
    color: var(--blue);
}

.digit-red {
    color: var(--red);
}

.digit-yellow {
    color: var(--yellow);
}

.error-code,
.error-message {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
}

.error-code {
    margin-bottom: 8px;
}

.error-code strong,
.error-message strong {
    font-weight: 700;
}

.error-code span,
.error-message span {
    color: var(--muted);
}

.tv-scene {
    position: relative;
    height: 360px;
    min-width: 280px;
}

.tv-shadow {
    position: absolute;
    left: 50%;
    bottom: 34px;
    width: 220px;
    height: 28px;
    transform: translateX(-50%);
    border-radius: 50%;
    background: var(--shadow-soft);
    filter: blur(10px);
}

.tv {
    position: absolute;
    left: 50%;
    bottom: 62px;
    width: 270px;
    height: 225px;
    transform: translateX(-50%) rotate(-8deg);
}

.tv-antenna {
    position: absolute;
    top: 4px;
    width: 5px;
    height: 74px;
    border-radius: 999px;
    background: var(--surface-border);
    transform-origin: bottom center;
}

.tv-antenna::before {
    content: "";
    position: absolute;
    top: -8px;
    left: 50%;
    width: 14px;
    height: 14px;
    transform: translateX(-50%);
    border-radius: 50%;
    background: var(--red);
    box-shadow: 0 0 0 5px rgba(234, 67, 53, 0.12);
}

.tv-antenna-left {
    left: 108px;
    transform: rotate(-30deg);
}

.tv-antenna-right {
    right: 108px;
    transform: rotate(30deg);
}

.tv-frame {
    position: absolute;
    inset: 48px 16px 20px;
    display: grid;
    grid-template-columns: 1fr 42px;
    gap: 14px;
    padding: 16px;
    background: linear-gradient(180deg, var(--surface) 0%, color-mix(in srgb, var(--surface) 82%, #000 18%) 100%);
    border: 4px solid var(--surface-border);
    border-radius: 20px;
    box-shadow: 0 22px 34px var(--shadow);
}

.tv-screen {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    border: 3px solid rgba(255, 255, 255, 0.06);
    background: #0f1011;
}

.tv-static {
    position: absolute;
    inset: 0;
    background: url('assets/img/static.gif') center/cover no-repeat;
    opacity: 0.88;
    filter: grayscale(1) contrast(1.08) brightness(0.92);
    animation: tv-static-flicker 1.2s linear infinite;
}

.tv-glow {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgb(0 0 0 / 15%), transparent 35%, #ed040400 65%, rgb(0 0 0 / 8%));
    pointer-events: none;
}

.tv-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.tv-knob {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 3px solid var(--surface-border);
    background: color-mix(in srgb, var(--surface) 70%, #fff 30%);
}

.tv-speaker {
    width: 18px;
    height: 48px;
    border-radius: 999px;
    background: repeating-linear-gradient(180deg, var(--surface-border) 0 4px, transparent 4px 8px);
    opacity: 0.8;
}

.tv-leg {
    position: absolute;
    bottom: 0;
    width: 10px;
    height: 48px;
    border-radius: 999px;
    background: var(--surface-border);
}

.tv-leg-left {
    left: 86px;
    transform: rotate(16deg);
}

.tv-leg-right {
    right: 86px;
    transform: rotate(-16deg);
}

@keyframes tv-static-flicker {
    0%,
    100% {
        opacity: 0.84;
    }
    20% {
        opacity: 0.94;
    }
    40% {
        opacity: 0.8;
    }
    60% {
        opacity: 0.9;
    }
    80% {
        opacity: 0.86;
    }
}

@media (max-width: 900px) {
    .page-404 {
        width: min(100%, calc(100% - 40px));
        grid-template-columns: 1fr;
        gap: 32px;
        padding: 88px 0 40px;
    }

    .content-404 {
        max-width: 100%;
    }

    .tv-scene {
        order: -1;
        height: 280px;
    }

    .tv {
        transform: translateX(-50%) rotate(-7deg) scale(0.88);
        bottom: 28px;
    }

    .tv-shadow {
        bottom: 10px;
    }
}

@media (max-width: 520px) {
    .switch {
        top: 14px;
        right: 14px;
    }

    .page-404 {
        width: min(100%, calc(100% - 24px));
        padding-top: 72px;
    }

    .brand-link {
        margin-bottom: 20px;
    }

    .error-hero {
        gap: 4px;
        margin-bottom: 14px;
    }

    .tv-scene {
        height: 220px;
    }

    .tv {
        transform: translateX(-50%) rotate(-6deg) scale(0.68);
        bottom: -4px;
    }

    .tv-shadow {
        width: 150px;
        bottom: -8px;
    }
}