:root {
    --font-body: "Source Sans 3", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    --font-display: "Source Serif 4", Georgia, "Times New Roman", serif;

    --bg: #f5f7f8;
    --bg-soft: #eef2f4;
    --surface: #ffffff;
    --surface-2: #f8fbfd;
    --text: #17212b;
    --text-muted: #45505c;
    --line: #d7e0e8;
    --line-strong: #bdcad6;

    --brand: #0f4c5c;
    --brand-2: #1b6d85;
    --brand-ink: #eaf6fa;
    --link: #0b5a8a;
    --link-hover: #083d60;
    --code-bg: #dbe8f4;
    --code-text: #08253a;
    --code-border: #95acc0;
    --code-block-bg: #f2f8ff;
    --code-block-text: #0b1f31;
    --code-block-border: #8fa8bf;
    --tok-comment: #2f6f37;
    --tok-keyword: #7d2ac2;
    --tok-type: #0c4aab;
    --tok-function: #9a4b0a;
    --tok-string: #9c1c4e;
    --tok-number: #005f95;
    --tok-operator: #6a2d9b;
    --tok-identifier: #133f78;
    --tok-constant: #9f3d05;
    --table-frame: #547189;
    --table-cell-line: #547189;
    --block-soft-bg: #e7f1f9;
    --block-soft-border: #98b1c7;

    --shadow-soft: 0 8px 28px rgba(13, 35, 54, 0.08);
    --shadow-card: 0 12px 38px rgba(13, 35, 54, 0.12);
}

:root[data-theme="dark"] {
    --bg: #0f151b;
    --bg-soft: #121b24;
    --surface: #17212b;
    --surface-2: #1d2a36;
    --text: #edf3f8;
    --text-muted: #b5c3d2;
    --line: #2b3a48;
    --line-strong: #3a4c5f;

    --brand: #1f6f8b;
    --brand-2: #2a8dae;
    --brand-ink: #d9f1f7;
    --link: #7bc2ec;
    --link-hover: #a3d8f3;
    --code-bg: #1c3146;
    --code-text: #edf7ff;
    --code-border: #4d6781;
    --code-block-bg: #071a2c;
    --code-block-text: #edf7ff;
    --code-block-border: #43607b;
    --tok-comment: #8fdca2;
    --tok-keyword: #d2a6ff;
    --tok-type: #82d2ff;
    --tok-function: #ffbf80;
    --tok-string: #ff9fcb;
    --tok-number: #7ce9ff;
    --tok-operator: #f0b7ff;
    --tok-identifier: #b6d5ff;
    --tok-constant: #ffc089;
    --table-frame: #86a8c6;
    --table-cell-line: #86a8c6;
    --block-soft-bg: #1c2c3a;
    --block-soft-border: #486078;

    --shadow-soft: 0 12px 32px rgba(0, 0, 0, 0.35);
    --shadow-card: 0 16px 40px rgba(0, 0, 0, 0.42);
}

html,
body {
    background:
        radial-gradient(circle at 2% -8%, rgba(36, 106, 131, 0.14), transparent 32%),
        radial-gradient(circle at 102% 3%, rgba(14, 70, 84, 0.14), transparent 30%),
        linear-gradient(180deg, var(--bg) 0%, var(--bg-soft) 100%);
    color: var(--text);
    font-family: var(--font-body);
}

body {
    letter-spacing: 0.01em;
    line-height: 1.65;
}

.page-header {
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    background:
        linear-gradient(120deg, rgba(8, 43, 55, 0.96), rgba(19, 84, 109, 0.94) 52%, rgba(13, 67, 94, 0.95)),
        linear-gradient(200deg, rgba(255, 255, 255, 0.09), transparent 48%);
    box-shadow: var(--shadow-soft);
}

.page-header::before,
.page-header::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.page-header::before {
    width: 340px;
    height: 340px;
    right: -120px;
    top: -140px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.22), transparent 70%);
}

.page-header::after {
    width: 260px;
    height: 260px;
    left: -120px;
    bottom: -130px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.14), transparent 68%);
}

.project-name,
.project-tagline,
.page-header a {
    color: #f6fbff;
}

.project-name {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 0.01em;
}

.project-tagline {
    font-weight: 500;
    opacity: 0.92;
}

.main-content {
    position: relative;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    background-clip: padding-box;
    isolation: isolate;
    margin-top: -1.5rem;
    margin-bottom: 2.5rem;
    padding: 2.2rem 2.3rem;
    box-shadow: var(--shadow-soft);
}

.main-content h1,
.main-content h2,
.main-content h3,
.main-content h4 {
    color: var(--text);
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 0.01em;
    line-height: 1.25;
}

.main-content h2,
.main-content h3 {
    border-bottom: 1px solid var(--line);
    padding-bottom: 0.4rem;
}

.main-content p,
.main-content li,
.main-content td,
.main-content th {
    color: var(--text);
}

.main-content a {
    color: var(--link);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--link) 45%, transparent);
    text-underline-offset: 0.14em;
    transition: color 180ms ease, text-decoration-color 180ms ease;
}

.main-content a:hover,
.main-content a:focus-visible {
    color: var(--link-hover);
    text-decoration-color: var(--link-hover);
}

.main-content hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 2rem 0;
}

.main-content table {
    display: table;
    width: auto;
    max-width: 100%;
    margin: 1rem 0;
    border-collapse: collapse !important;
    table-layout: auto;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--table-cell-line) !important;
    background: var(--surface);
    background-clip: padding-box;
    clip-path: inset(0 round 10px);
    -webkit-mask-image: -webkit-radial-gradient(white, black);
    box-shadow:
        inset 0 0 0 1px var(--table-cell-line),
        0 4px 14px rgba(5, 20, 38, 0.04);
}

.main-content th {
    background: color-mix(in srgb, var(--brand-ink) 58%, var(--surface));
    font-weight: 700;
}

.main-content th,
.main-content td {
    border: 1px solid var(--table-cell-line) !important;
    padding: 0.62rem 0.72rem;
    vertical-align: top;
}

.main-content table thead th {
    border-bottom: 1px solid var(--table-cell-line) !important;
}

.main-content code,
.main-content pre {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.main-content code {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 6px;
    padding: 0.12rem 0.35rem;
    color: var(--code-text);
    font-weight: 600;
}

.main-content pre {
    background: var(--code-block-bg);
    color: var(--code-block-text);
    border: 1px solid var(--code-block-border);
    border-radius: 10px;
    padding: 0.95rem;
    overflow: hidden;
    overflow-x: auto;
    background-clip: padding-box;
    -webkit-mask-image: -webkit-radial-gradient(white, black);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.main-content .highlighter-rouge {
    background: var(--code-block-bg);
    color: var(--code-block-text);
    border: 1px solid var(--code-block-border);
    border-radius: 10px;
    overflow: hidden;
    background-clip: padding-box;
    -webkit-mask-image: -webkit-radial-gradient(white, black);
}

.main-content .highlighter-rouge .highlight {
    background: transparent;
    border: 0;
    border-radius: 0;
    overflow: visible;
    -webkit-mask-image: none;
}

.main-content .highlight pre,
.main-content .highlighter-rouge pre {
    margin: 0;
    border: 0;
    box-shadow: none;
}

.main-content pre code {
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 0;
    color: var(--code-block-text);
    font-weight: 500;
}

.main-content pre sup,
.main-content pre sub,
.main-content .highlight sup,
.main-content .highlight sub {
    background: transparent;
    color: inherit;
}

/* Rouge syntax palette: strong contrast in both themes. */
.main-content .highlight .c,
.main-content .highlight .cm,
.main-content .highlight .c1,
.main-content .highlight .cs,
.main-content .highlight .cp,
.main-content .highlight .cpf {
    color: var(--tok-comment) !important;
    font-style: italic;
}

.main-content .highlight .k,
.main-content .highlight .kc,
.main-content .highlight .kd,
.main-content .highlight .kn,
.main-content .highlight .kp,
.main-content .highlight .kr,
.main-content .highlight .kt,
.main-content .highlight .ow {
    color: var(--tok-keyword) !important;
    font-weight: 700;
}

.main-content .highlight .kt,
.main-content .highlight .nc,
.main-content .highlight .nt,
.main-content .highlight .nn {
    color: var(--tok-type) !important;
}

.main-content .highlight .nf,
.main-content .highlight .fm {
    color: var(--tok-function) !important;
}

.main-content .highlight .s,
.main-content .highlight .sa,
.main-content .highlight .sb,
.main-content .highlight .sc,
.main-content .highlight .dl,
.main-content .highlight .sd,
.main-content .highlight .s1,
.main-content .highlight .s2,
.main-content .highlight .se,
.main-content .highlight .sh,
.main-content .highlight .si,
.main-content .highlight .sx,
.main-content .highlight .sr,
.main-content .highlight .ss {
    color: var(--tok-string) !important;
}

.main-content .highlight .m,
.main-content .highlight .mb,
.main-content .highlight .mf,
.main-content .highlight .mh,
.main-content .highlight .mi,
.main-content .highlight .il,
.main-content .highlight .mo {
    color: var(--tok-number) !important;
}

.main-content .highlight .o,
.main-content .highlight .p {
    color: var(--tok-operator) !important;
}

.main-content .highlight .n,
.main-content .highlight .na,
.main-content .highlight .nb,
.main-content .highlight .nd,
.main-content .highlight .ne,
.main-content .highlight .nl,
.main-content .highlight .no,
.main-content .highlight .nv,
.main-content .highlight .nx,
.main-content .highlight .py,
.main-content .highlight .bp,
.main-content .highlight .vc,
.main-content .highlight .vg,
.main-content .highlight .vi,
.main-content .highlight .vm {
    color: var(--tok-identifier) !important;
}

.main-content .highlight .no,
.main-content .highlight .bp {
    color: var(--tok-constant) !important;
}

.main-content td code,
.main-content th code {
    color: var(--code-text);
}

.main-content blockquote {
    margin: 1rem 0;
    border-left: 4px solid var(--brand);
    background: var(--block-soft-bg);
    border-top: 1px solid var(--block-soft-border);
    border-right: 1px solid var(--block-soft-border);
    border-bottom: 1px solid var(--block-soft-border);
    border-radius: 0 8px 8px 0;
    overflow: hidden;
    background-clip: padding-box;
    color: var(--text);
}

.main-content blockquote p {
    margin: 0.7rem 0.9rem;
}

.main-content img,
.main-content video,
.main-content iframe {
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    box-shadow: var(--shadow-soft);
}

.corner-menu {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 60;
    display: grid;
    justify-items: end;
}

.corner-menu-toggle {
    width: auto;
    min-width: 5.2rem;
    display: inline-flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.42rem 0.6rem;
    border: 1px solid color-mix(in srgb, var(--line-strong) 82%, transparent);
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 20px rgba(10, 26, 42, 0.14);
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    opacity: 0.84;
    transition:
        opacity 180ms ease,
        border-color 180ms ease,
        color 180ms ease,
        transform 180ms ease;
}

.corner-menu-toggle:hover,
.corner-menu-toggle:focus-visible,
.corner-menu:hover .corner-menu-toggle,
.corner-menu:focus-within .corner-menu-toggle,
.corner-menu[data-pinned="true"] .corner-menu-toggle {
    opacity: 1;
    color: var(--text);
    border-color: var(--brand-2);
    transform: translateY(-1px);
}

.corner-menu-toggle:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--brand) 75%, white 25%);
    outline-offset: 2px;
}

.corner-menu-panel {
    position: absolute;
    top: calc(100% + 2px);
    right: 0;
    width: min(330px, calc(100vw - 20px));
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    padding: 0.78rem;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-card);
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
    transform-origin: top right;
    pointer-events: none;
    max-height: 0;
    overflow: hidden;
    transition:
        opacity 170ms ease,
        transform 170ms ease,
        max-height 170ms ease;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.corner-menu:hover .corner-menu-panel,
.corner-menu:focus-within .corner-menu-panel,
.corner-menu[data-pinned="true"] .corner-menu-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    max-height: min(calc(100vh - 54px), 760px);
    overflow-y: auto;
}

.corner-menu-section--settings {
    position: sticky;
    top: -0.78rem;
    z-index: 1;
    background: color-mix(in srgb, var(--surface) 95%, transparent);
    margin: -0.78rem -0.78rem 0;
    padding: 0.72rem 0.78rem 0.64rem;
    border-bottom: 1px solid var(--line);
}

.corner-menu-section--settings .corner-menu-title {
    margin-bottom: 0.42rem;
}

.corner-menu-section+.corner-menu-section {
    margin-top: 0.9rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--line);
}

.corner-menu-title {
    margin: 0 0 0.45rem;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.corner-menu-nav {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.24rem;
}

.corner-menu-nav a {
    display: block;
    padding: 0.38rem 0.55rem;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.88rem;
    line-height: 1.3;
}

.corner-menu-nav a:hover,
.corner-menu-nav a:focus-visible,
.corner-menu-nav a.is-active {
    background: color-mix(in srgb, var(--surface-2) 74%, var(--brand-ink));
    border-color: color-mix(in srgb, var(--brand-2) 35%, transparent);
    color: var(--link-hover);
}

.corner-menu-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.7rem;
}

.corner-menu-label {
    color: var(--text);
    font-size: 0.84rem;
    font-weight: 600;
}

.corner-menu select {
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--text);
    border-radius: 8px;
    font-size: 0.83rem;
    font-weight: 600;
    padding: 0.28rem 0.5rem;
    cursor: pointer;
}

.corner-menu select:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--brand) 75%, white 25%);
    outline-offset: 1px;
}

@media (max-width: 900px) {
    .main-content {
        margin-top: -1rem;
        padding: 1.5rem 1rem;
        border-radius: 12px;
    }

    .corner-menu {
        top: 10px;
        right: 10px;
    }

    .corner-menu-toggle {
        font-size: 0.72rem;
        padding: 0.38rem 0.52rem;
    }

    .corner-menu-panel {
        width: min(294px, calc(100vw - 16px));
    }
}

@media (prefers-reduced-motion: no-preference) {

    .page-header,
    .main-content,
    .main-content img,
    .main-content video,
    .main-content iframe {
        animation: riseIn 540ms ease-out both;
    }

    .main-content img,
    .main-content video,
    .main-content iframe {
        animation-delay: 120ms;
    }

    .corner-menu-toggle,
    .corner-menu-panel {
        animation: riseIn 380ms ease-out both;
    }
}

html.reduce-motion * {
    animation: none !important;
    transition: none !important;
}

@keyframes riseIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}