:root {
    --header-offset: 88px;
    --radius: 24px;
    --max: 1180px;
}

[data-theme="light"] {
    color-scheme: light;
    --bg: #f4f7fb;
    --bg-elevated: rgba(255, 255, 255, 0.82);
    --panel: rgba(255, 255, 255, 0.86);
    --text: #0f172a;
    --muted: #55657d;
    --border: rgba(15, 23, 42, 0.08);
    --shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
    --accent: #2563eb;
    --accent2: #0ea5e9;
    --accent-soft: rgba(37, 99, 235, 0.08);
    --hero-gradient-start: rgba(255, 255, 255, 0.9);
    --hero-gradient-end: rgba(255, 255, 255, 0.76);
    --stat-block-bg: rgba(15, 23, 42, 0.02);
    --contrib-0: rgba(15, 23, 42, 0.06);
    --contrib-1: rgba(37, 99, 235, 0.25);
    --contrib-2: rgba(37, 99, 235, 0.45);
    --contrib-3: rgba(37, 99, 235, 0.7);
    --contrib-4: #0ea5e9;
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #07111f;
    --bg-elevated: rgba(15, 23, 42, 0.78);
    --panel: rgba(15, 23, 42, 0.72);
    --text: #e2e8f0;
    --muted: #a3b4c8;
    --border: rgba(148, 163, 184, 0.18);
    --shadow: 0 18px 40px rgba(2, 6, 23, 0.18);
    --accent: #5b8cff;
    --accent2: #7dd3fc;
    --accent-soft: rgba(91, 140, 255, 0.14);
    --hero-gradient-start: rgba(15, 23, 42, 0.72);
    --hero-gradient-end: rgba(15, 23, 42, 0.82);
    --stat-block-bg: rgba(255, 255, 255, 0.04);
    --contrib-0: rgba(148, 163, 184, 0.1);
    --contrib-1: rgba(91, 140, 255, 0.3);
    --contrib-2: rgba(91, 140, 255, 0.55);
    --contrib-3: rgba(91, 140, 255, 0.8);
    --contrib-4: #7dd3fc;
}

* { box-sizing: border-box; }

html {
    height: 100%;
    scroll-padding-top: var(--header-offset);
    scroll-behavior: smooth;
}

[id] {
    scroll-margin-top: var(--header-offset);
}

body {
    position: relative;
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
}

.aurora-canvas {
    position: fixed;
    inset: 0;
    z-index: -1;
    width: 100%;
    height: 100%;
    display: block;
    filter: blur(6px);
}

a {
    color: inherit;
    text-decoration: none;
}

.container {
    max-width: var(--max);
    margin: 0 auto;
    padding: 32px 22px 72px;
}

header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-elevated);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
    transition: box-shadow 220ms ease;
}

header.scrolled {
    box-shadow: 0 12px 28px rgba(2, 6, 23, 0.14);
}

.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    max-width: var(--max);
    margin: 0 auto;
    padding: 16px 20px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    box-shadow: 0 14px 34px rgba(91, 140, 255, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.brand strong {
    display: block;
    font-size: 0.98rem;
    letter-spacing: 0.2px;
}

.brand span {
    display: block;
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: -2px;
}

.navlinks {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.chip {
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
    font-size: 0.92rem;
    color: var(--muted);
    transition: transform 180ms ease, background 180ms ease, color 180ms ease, border-color 180ms ease;
}

.chip:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    border-color: rgba(148, 163, 184, 0.28);
}

.chip.active {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-soft);
}

.btn {
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text);
    padding: 10px 14px;
    border-radius: 14px;
    cursor: pointer;
    font: inherit;
    transition: transform 180ms ease, filter 180ms ease, background 180ms ease, border-color 180ms ease;
}

.btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(148, 163, 184, 0.28);
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(220px, 0.9fr);
    gap: 18px;
    margin-top: 28px;
    padding: 30px 28px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: linear-gradient(180deg, var(--hero-gradient-start), var(--hero-gradient-end));
    box-shadow: var(--shadow);
}

.hero-copy {
    align-self: center;
}

h1 {
    margin: 0 0 14px;
    font-size: clamp(2.2rem, 3.2vw, 3.4rem);
    line-height: 1.06;
    letter-spacing: -0.05em;
    font-weight: 800;
}

.subtitle {
    margin: 0 0 20px;
    color: var(--muted);
    font-size: 1.08rem;
    max-width: 700px;
    line-height: 1.55;
}

.cta-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    padding: 12px 16px;
    border-radius: 14px;
    border: 1px solid transparent;
    background: linear-gradient(135deg, rgba(91, 140, 255, 0.18), rgba(125, 211, 252, 0.18));
    font-weight: 600;
    transition: transform 180ms ease, filter 180ms ease, border-color 180ms ease;
}

.primary:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
    border-color: rgba(91, 140, 255, 0.34);
}

.hero-panel {
    display: grid;
    gap: 12px;
    align-content: center;
}

.stat-block {
    padding: 18px 18px 16px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: var(--stat-block-bg);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.stat-label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.stat-block strong {
    font-size: 1rem;
}

section {
    margin-top: 28px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-flow: row dense;
    gap: 16px;
}

.card {
    position: relative;
    grid-column: span 12;
    padding: 22px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--panel);
    transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.card:hover,
.card:focus-within {
    transform: translateY(-2px);
    border-color: rgba(148, 163, 184, 0.24);
    box-shadow: var(--shadow);
    z-index: 5;
}

.card.full {
    grid-column: span 12;
}

.card.tall {
    display: flex;
    flex-direction: column;
    grid-row: span 2;
}

.card-media {
    margin-top: 14px;
    flex: 1 1 auto;
    min-height: 220px;
    border-radius: calc(var(--radius) / 2);
    overflow: hidden;
}

.card-media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 420ms ease;
}

.card:hover .card-media img {
    transform: scale(1.05);
}

@media (min-width: 760px) {
    .card.half {
        grid-column: span 6;
    }
    .card.third {
        grid-column: span 4;
    }
}

.card h2 {
    margin: 0 0 10px;
    font-size: 1.22rem;
    letter-spacing: -0.01em;
}

.card p {
    margin: 0;
    color: var(--muted);
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.meta-row .tags,
.meta-row .project-meta {
    margin-top: 0;
}

.tag {
    font-size: 0.85rem;
    color: var(--muted);
    border: 1px solid var(--border);
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .tag {
    background: rgba(15, 23, 42, 0.04);
}

.project-meta {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.project-meta a:not(.tag-link) {
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.28);
    transition: opacity 180ms ease;
}

.project-meta a:not(.tag-link):hover {
    opacity: 0.82;
}

[data-theme="light"] .project-meta a:not(.tag-link) {
    border-bottom-color: rgba(15, 23, 42, 0.28);
}

a.tag-link {
    display: inline-flex;
    align-items: center;
    font-size: 0.85rem;
    color: var(--accent);
    border: 1px solid var(--accent);
    padding: 7px 12px;
    border-radius: 999px;
    background: var(--accent-soft);
    transition: background 180ms ease, color 180ms ease;
}

a.tag-link:hover {
    background: var(--accent);
    color: #fff;
}

.inline-link {
    font-weight: 700;
    color: var(--accent);
    border-bottom: 1px dashed var(--accent);
    transition: color 180ms ease;
}

.inline-link:hover,
.inline-link:focus-visible {
    color: var(--accent2);
    outline: none;
}

.book-wrap {
    position: relative;
    display: inline-block;
}

.book-wrap.no-books .book-popover {
    display: none;
}

.book-trigger {
    font-weight: 700;
    color: var(--accent);
    border-bottom: 1px dashed var(--accent);
    transition: color 180ms ease;
}

.book-trigger:hover,
.book-trigger:focus-visible {
    color: var(--accent2);
    outline: none;
}

.book-popover {
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    transform: translateY(4px);
    z-index: 30;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 0;
    width: max-content;
    max-width: min(88vw, 400px);
    padding: 12px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
    text-align: left;
    visibility: hidden;
    opacity: 0;
    transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
}

.book-wrap:hover .book-popover,
.book-wrap:focus-within .book-popover {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

.book-popover-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 160px;
    max-width: 220px;
}

.book-popover-column + .book-popover-column {
    margin-left: 16px;
    padding-left: 16px;
    border-left: 1px solid var(--border);
}

.book-popover-label {
    font-size: 0.66rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 700;
}

.book-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.book-item {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text);
    transition: opacity 150ms ease;
}

.book-item:hover,
.book-item:focus-visible {
    opacity: 0.78;
    outline: none;
}

.book-list .book-item:not(:first-child) {
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.book-cover {
    flex: none;
    width: 42px;
    height: 63px;
    object-fit: cover;
    border-radius: 6px;
    box-shadow: 0 10px 22px rgba(2, 6, 23, 0.28);
}

.book-cover-placeholder {
    background: var(--stat-block-bg);
    border: 1px dashed var(--border);
    box-shadow: none;
}

.book-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.book-title {
    font-size: 0.86rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text);
}

.book-author {
    font-size: 0.78rem;
    color: var(--muted);
}

.recently-finished-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    text-decoration: none;
    color: inherit;
    transition: opacity 150ms ease;
}

.recently-finished-column[hidden] {
    display: none;
}

.recently-finished-column:hover,
.recently-finished-column:focus-visible {
    opacity: 0.82;
    outline: none;
}

.recently-finished-cover-slot {
    display: block;
}

.recently-finished-cover-slot .book-cover,
.recently-finished-cover-slot .book-cover-placeholder {
    width: 72px;
    height: 108px;
}

.recently-finished-title {
    display: block;
    margin-top: 4px;
    font-size: 0.86rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text);
}

.recently-finished-author {
    display: block;
    font-size: 0.78rem;
    color: var(--muted);
}

@media (max-width: 480px) {
    .book-popover {
        flex-direction: column;
        width: 260px;
    }

    .book-popover-column + .book-popover-column {
        margin-left: 0;
        margin-top: 14px;
        padding-left: 0;
        padding-top: 14px;
        border-left: none;
        border-top: 1px solid var(--border);
    }

    .recently-finished-column {
        align-items: flex-start;
        text-align: left;
    }
}

.contact-form {
    margin-top: 16px;
    display: grid;
    gap: 14px;
    width: 100%;
}

.contact-form label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 0.95rem;
}

.contact-form input,
.contact-form textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    font: inherit;
    transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.contact-form input:focus,
.contact-form textarea:focus {
    outline: none;
    border-color: rgba(91, 140, 255, 0.45);
    box-shadow: 0 0 0 4px rgba(91, 140, 255, 0.12);
}

[data-theme="light"] .contact-form input,
[data-theme="light"] .contact-form textarea {
    background: rgba(15, 23, 42, 0.04);
}

.contact-form textarea {
    resize: vertical;
    min-height: 140px;
}

.chart-scroll {
    width: 100%;
    margin-top: 16px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.contrib-chart svg {
    display: block;
    width: 100%;
    height: auto;
}

@media (max-width: 760px) {
    .contrib-chart svg {
        width: 640px;
        min-width: 640px;
    }
}

.contrib-chart rect {
    transition: fill 180ms ease;
}

.contrib-chart .level-0 { fill: var(--contrib-0); }
.contrib-chart .level-1 { fill: var(--contrib-1); }
.contrib-chart .level-2 { fill: var(--contrib-2); }
.contrib-chart .level-3 { fill: var(--contrib-3); }
.contrib-chart .level-4 { fill: var(--contrib-4); }

.contrib-chart .contrib-month,
.contrib-chart .contrib-weekday {
    fill: var(--muted);
    font-size: 9px;
    font-family: inherit;
}

footer {
    margin-top: 32px;
    color: var(--muted);
    font-size: 0.94rem;
}


.reveal {
    opacity: 0;
    transform: translateY(18px);
    transition: opacity 620ms ease, transform 620ms ease;
}

.reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.back-to-top {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 20;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    backdrop-filter: blur(18px);
    color: var(--text);
    box-shadow: var(--shadow);
    cursor: pointer;
    opacity: 0;
    transform: translateY(10px) scale(0.9);
    pointer-events: none;
    transition: opacity 220ms ease, transform 220ms ease, border-color 180ms ease;
}

.back-to-top.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.back-to-top:hover {
    border-color: var(--accent);
    color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .reveal {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .card:hover .card-media img {
        transform: none;
    }

    .back-to-top {
        transition: opacity 120ms ease;
    }
}

@media (max-width: 760px) {
    .nav {
        align-items: flex-start;
        flex-direction: column;
        padding: 14px 16px;
    }

    .navlinks {
        width: 100%;
        justify-content: space-between;
    }

    .hero {
        grid-template-columns: 1fr;
        padding: 22px 18px;
    }
}