:root,
html[data-theme="light"] {
    color-scheme: light;
    --background: #f4f0e8;
    --background-cool-glow: rgba(45, 108, 223, 0.12);
    --background-warm-glow: rgba(225, 83, 58, 0.11);
    --ink: #181716;
    --muted: #69635b;
    --accent: #2d6cdf;
    --accent-strong: #18499f;
    --line: rgba(24, 23, 22, 0.16);
    --surface: rgba(255, 255, 255, 0.58);
    --control-surface: rgba(255, 255, 255, 0.72);
    --control-shadow: rgba(24, 23, 22, 0.08);
    --theme-switcher-thumb-ring: rgba(24, 23, 22, 0.22);
    --theme-switcher-thumb-shadow: rgba(24, 23, 22, 0.16);
    --button-background: #181716;
    --button-border: rgba(24, 23, 22, 0.24);
    --button-text: #ffffff;
    --portrait-border: rgba(24, 23, 22, 0.18);
    --not-found-border: rgba(24, 23, 22, 0.18);
    --not-found-surface: rgba(255, 255, 255, 0.34);
    --shadow-accent: rgba(45, 108, 223, 0.18);
    --shadow-error: rgba(225, 83, 58, 0.18);
}

html[data-theme="dark"] {
    color-scheme: dark;
    --background: #101319;
    --background-cool-glow: rgba(93, 143, 255, 0.16);
    --background-warm-glow: rgba(240, 116, 89, 0.12);
    --ink: #f3eee7;
    --muted: #beb5a9;
    --accent: #80aaff;
    --accent-strong: #a9c3ff;
    --line: rgba(243, 238, 231, 0.16);
    --surface: rgba(22, 27, 36, 0.7);
    --control-surface: rgba(18, 22, 30, 0.82);
    --control-shadow: rgba(0, 0, 0, 0.32);
    --theme-switcher-thumb-ring: rgba(243, 238, 231, 0.36);
    --theme-switcher-thumb-shadow: rgba(0, 0, 0, 0.38);
    --button-background: #f3eee7;
    --button-border: rgba(243, 238, 231, 0.26);
    --button-text: #101319;
    --portrait-border: rgba(243, 238, 231, 0.24);
    --not-found-border: rgba(243, 238, 231, 0.2);
    --not-found-surface: rgba(22, 27, 36, 0.52);
    --shadow-accent: rgba(93, 143, 255, 0.24);
    --shadow-error: rgba(240, 116, 89, 0.22);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --background: #101319;
        --background-cool-glow: rgba(93, 143, 255, 0.16);
        --background-warm-glow: rgba(240, 116, 89, 0.12);
        --ink: #f3eee7;
        --muted: #beb5a9;
        --accent: #80aaff;
        --accent-strong: #a9c3ff;
        --line: rgba(243, 238, 231, 0.16);
        --surface: rgba(22, 27, 36, 0.7);
        --control-surface: rgba(18, 22, 30, 0.82);
        --control-shadow: rgba(0, 0, 0, 0.32);
        --theme-switcher-thumb-ring: rgba(243, 238, 231, 0.36);
        --theme-switcher-thumb-shadow: rgba(0, 0, 0, 0.38);
        --button-background: #f3eee7;
        --button-border: rgba(243, 238, 231, 0.26);
        --button-text: #101319;
        --portrait-border: rgba(243, 238, 231, 0.24);
        --not-found-border: rgba(243, 238, 231, 0.2);
        --not-found-surface: rgba(22, 27, 36, 0.52);
        --shadow-accent: rgba(93, 143, 255, 0.24);
        --shadow-error: rgba(240, 116, 89, 0.22);
    }
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        linear-gradient(120deg, var(--background-cool-glow), transparent 42%),
        linear-gradient(315deg, var(--background-warm-glow), transparent 46%),
        var(--background);
    color: var(--ink);
}

body {
    min-height: 100vh;
    margin: 0;
}

body::before {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    content: "";
    background-image:
        linear-gradient(var(--line) 1px, transparent 1px),
        linear-gradient(90deg, var(--line) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: linear-gradient(120deg, rgba(0, 0, 0, 0.74), transparent 72%);
}

main {
    display: grid;
    min-height: 100vh;
    padding: clamp(74px, 9vw, 96px) clamp(28px, 6vw, 72px) clamp(28px, 6vw, 72px);
    place-items: center;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.theme-switcher {
    position: fixed;
    top: clamp(12px, 3vw, 28px);
    right: clamp(12px, 3vw, 28px);
    z-index: 10;
    display: grid;
    width: auto;
    --theme-switcher-slide-duration: 280ms;
    grid-template-columns: repeat(3, 34px);
    gap: 2px;
    margin: 0;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--control-surface);
    box-shadow: 0 12px 34px var(--control-shadow);
    backdrop-filter: blur(16px);
}

.theme-switcher::before {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 34px;
    height: 34px;
    border-radius: 6px;
    content: "";
    background: var(--button-background);
    box-shadow:
        0 8px 22px var(--theme-switcher-thumb-shadow),
        0 0 0 1px var(--theme-switcher-thumb-ring);
    transform: translateX(0);
    transition:
        background-color 220ms ease,
        box-shadow 220ms ease,
        transform var(--theme-switcher-slide-duration) cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.theme-switcher[data-active-theme="dark"]::before {
    transform: translateX(36px);
}

.theme-switcher[data-active-theme="system"]::before {
    transform: translateX(72px);
}

.theme-switcher__option {
    position: relative;
    z-index: 1;
    min-width: 0;
}

.theme-switcher__input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.theme-switcher__control {
    display: grid;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: var(--muted);
    cursor: pointer;
    line-height: 1;
    transition: color 220ms ease;
}

.theme-switcher__input:checked + .theme-switcher__control {
    color: var(--button-text);
}

.theme-switcher__input:focus-visible + .theme-switcher__control {
    outline: 3px solid rgba(45, 108, 223, 0.35);
    outline-offset: 2px;
}

.theme-switcher__icon {
    display: block;
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.theme-switcher__icon--sun {
    width: 17px;
}

.theme-switcher__icon--moon,
.theme-switcher__icon--display {
    width: 16px;
}

@media (max-width: 640px) {
    .theme-switcher {
        --theme-switcher-slide-duration: 340ms;
    }
}

.page {
    display: grid;
    width: min(100%, 980px);
    gap: clamp(36px, 7vw, 70px);
}

.portrait {
    display: block;
    width: clamp(118px, 15vw, 164px);
    height: auto;
    aspect-ratio: 1;
    border: 1px solid var(--portrait-border);
    border-radius: 50%;
    box-shadow: 0 22px 70px var(--shadow-accent);
    object-fit: cover;
}

.mark {
    width: clamp(72px, 10vw, 112px);
    height: clamp(72px, 10vw, 112px);
    border: 1px solid var(--line);
    border-radius: 50%;
    background:
        linear-gradient(135deg, var(--ink) 0 48%, transparent 48% 52%, var(--accent) 52%),
        var(--surface);
    box-shadow: 0 22px 70px var(--shadow-accent);
}

.content {
    display: grid;
    gap: 28px;
}

.eyebrow {
    margin: 0;
    color: var(--accent-strong);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1 {
    max-width: 100%;
    margin: 0;
    font-size: clamp(2.4rem, 8.4vw, 6.8rem);
    font-weight: 760;
    letter-spacing: 0;
    line-height: 0.9;
    white-space: nowrap;
}

.lead {
    max-width: 620px;
    margin: 0;
    color: var(--muted);
    font-size: clamp(1.2rem, 2.5vw, 1.72rem);
    line-height: 1.42;
}

.quote {
    max-width: 420px;
    padding-left: clamp(12px, 2vw, 16px);
    border-left: 2px solid var(--accent);
    color: var(--muted);
}

.quote__body {
    margin: 0;
}

.quote__text {
    margin: 0;
    color: var(--ink);
    font-size: clamp(0.86rem, 1.05vw, 0.94rem);
    line-height: 1.45;
}

.quote__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin-top: 10px;
    font-size: 0.72rem;
}

.quote__author {
    color: var(--muted);
    font-style: normal;
    font-weight: 700;
}

.quote__source {
    color: var(--accent-strong);
    font-weight: 700;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.error-page h1 {
    max-width: 760px;
    line-height: 1;
    white-space: normal;
}

.error-mark {
    background:
        linear-gradient(135deg, #e1533a 0 48%, transparent 48% 52%, var(--ink) 52%),
        var(--surface);
    box-shadow: 0 22px 70px var(--shadow-error);
}

.actions {
    margin: 0;
}

.button-link {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: 0 18px;
    border: 1px solid var(--button-border);
    border-radius: 8px;
    background: var(--button-background);
    color: var(--button-text);
    font-size: 0.96rem;
    font-weight: 700;
    text-decoration: none;
}

.button-link:focus-visible {
    outline: 3px solid rgba(45, 108, 223, 0.35);
    outline-offset: 3px;
}

.error-page--not-found {
    grid-template-columns: minmax(230px, 0.74fr) minmax(0, 1fr);
    align-items: center;
    gap: clamp(34px, 6vw, 80px);
}

.not-found-visual {
    position: relative;
    display: grid;
    min-height: clamp(180px, 28vw, 330px);
    align-items: center;
}

.not-found-visual::before {
    position: absolute;
    inset: 12% 3% 8% 0;
    z-index: -1;
    border: 1px solid var(--not-found-border);
    content: "";
    background:
        linear-gradient(135deg, rgba(45, 108, 223, 0.14), transparent 52%),
        linear-gradient(315deg, rgba(225, 83, 58, 0.15), transparent 54%),
        var(--not-found-surface);
    transform: skew(-7deg) rotate(-2deg);
}

.error-code {
    margin: 0;
    color: var(--ink);
    font-size: clamp(5.5rem, 19vw, 14rem);
    font-weight: 760;
    letter-spacing: 0;
    line-height: 0.78;
}

.not-found-line {
    width: min(72%, 260px);
    height: 6px;
    margin-top: 18px;
    background: linear-gradient(90deg, var(--accent), #e1533a);
}

.error-page--not-found .content {
    gap: 24px;
}

.error-page--not-found h1 {
    max-width: 680px;
    font-size: clamp(2.25rem, 5.6vw, 5rem);
    line-height: 0.96;
    white-space: normal;
}

@media (max-width: 760px) {
    main {
        align-items: center;
        padding: 76px 28px 28px;
    }

    .page {
        gap: 44px;
    }

    h1 {
        font-size: clamp(2rem, 11vw, 4rem);
    }

    .quote {
        max-width: 280px;
    }

    .error-page--not-found {
        grid-template-columns: 1fr;
        gap: 34px;
    }

    .not-found-visual {
        min-height: 150px;
    }

    .error-code {
        font-size: clamp(5rem, 31vw, 8rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    .theme-switcher::before,
    .theme-switcher__control {
        transition: none;
    }
}
