:root {
    --accent: #F3C67A;
    --bg: #0E2F5A;
    --surface: #071B34;
    --surface-2: #0A2342;
    --text: #FAFAF8;
    --muted: #E7D4B2;
    --line: rgba(243, 198, 122, 0.34);
    --soft: rgba(243, 198, 122, 0.12);
    --blue-heart: #2759C8;
    --sand: #E7D4B2;
    --max: 1160px;
    --content: 760px;
    --font-sans: Montserrat, Lato, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-display: "Bebas Neue", "Trade Gothic Condensed", "Arial Narrow", Impact, sans-serif;
    --font-serif: "Playfair Display", "Iowan Old Style", Georgia, serif;
}

* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    background:
        radial-gradient(circle at 18% 0%, rgba(39, 89, 200, 0.22), transparent 28rem),
        linear-gradient(135deg, #061421 0%, var(--bg) 48%, #04101D 100%);
    color: var(--text);
    font-family: var(--font-sans);
    line-height: 1.6;
}

body.theme-serif {
    font-family: var(--font-serif);
}

a {
    color: inherit;
    text-decoration-color: color-mix(in srgb, var(--accent), transparent 55%);
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.18em;
}

img {
    display: block;
    max-width: 100%;
    height: auto;
}

.site-shell {
    min-height: 100vh;
}

.site-header,
.site-footer,
.site-main {
    width: min(var(--max), calc(100% - 40px));
    margin-inline: auto;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 76px;
    border-bottom: 1px solid var(--line);
}

.site-brand {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    color: var(--accent);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.45rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-decoration: none;
}

.site-brand img {
    max-height: 36px;
    width: auto;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 18px;
    color: var(--sand);
    font-size: 0.95rem;
}

.primary-nav {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.primary-nav li {
    position: relative;
}

.site-nav a {
    text-decoration: none;
}

.site-nav a:hover {
    color: var(--accent);
}

.nav-dropdown summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    list-style: none;
}

.nav-dropdown summary::-webkit-details-marker {
    display: none;
}

.nav-dropdown summary::after {
    content: "";
    width: 7px;
    height: 7px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
}

.nav-panel {
    position: absolute;
    top: calc(100% + 14px);
    right: 0;
    z-index: 30;
    display: grid;
    min-width: 230px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: color-mix(in srgb, var(--surface), #000 12%);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
}

.nav-panel-wide {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    min-width: 420px;
}

.nav-panel a {
    display: block;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--muted);
}

.nav-panel a:hover {
    background: var(--soft);
    color: var(--accent);
}

.nav-signup,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: var(--accent);
    color: #071B34;
    font-weight: 700;
    text-decoration: none;
}

.nav-toggle {
    display: none;
    width: 42px;
    height: 42px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: rgba(7, 27, 52, 0.7);
}

.nav-toggle span {
    display: block;
    height: 2px;
    margin: 5px 0;
    background: var(--accent);
}

.archive-hero {
    position: relative;
    max-width: 960px;
    padding: 86px 0 44px;
}

.archive-hero.compact {
    padding-top: 56px;
}

.home-hero {
    padding-bottom: 30px;
}

.home-hero::after,
.site-footer::after {
    content: "♥";
    display: block;
    width: fit-content;
    margin-top: 18px;
    color: var(--blue-heart);
    font-size: 1.1rem;
    line-height: 1;
}

.archive-hero h1,
.article-header h1 {
    margin: 0;
    color: var(--accent);
    font-family: var(--font-display);
    font-size: clamp(3rem, 8vw, 7.2rem);
    font-weight: 700;
    line-height: 0.95;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.archive-hero p,
.article-excerpt {
    max-width: 680px;
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 1.18rem;
}

.eyebrow {
    display: inline-block;
    margin: 0 0 12px;
    color: var(--accent);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    text-decoration: none;
}

.featured-section {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    padding: 26px 0 34px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.section-hub {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    padding: 18px 0 58px;
}

.section-card {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background:
        linear-gradient(180deg, rgba(243, 198, 122, 0.08), transparent 42%),
        var(--surface);
    box-shadow: inset 0 0 0 1px rgba(250, 250, 248, 0.03);
    transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.section-card:hover {
    border-color: color-mix(in srgb, var(--accent), var(--line) 40%);
    transform: translateY(-2px);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.25);
}

.section-card a {
    display: grid;
    min-height: 220px;
    padding: 24px;
    text-decoration: none;
}

.section-card h2 {
    align-self: end;
    margin: 0;
    color: var(--accent);
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 3vw, 2.65rem);
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1;
    text-transform: uppercase;
}

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

.story-library,
.chapter-archive {
    padding: 8px 0 54px;
}

.story-category {
    padding: 18px 0 36px;
    scroll-margin-top: 96px;
}

.story-category-header {
    max-width: 760px;
    margin-bottom: 26px;
}

.story-category-header h2 {
    margin: 0;
    color: var(--accent);
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 4rem);
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1;
    text-transform: uppercase;
}

.story-category-header p:not(.eyebrow) {
    margin: 14px 0 0;
    color: var(--muted);
}

.story-card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    padding-bottom: 28px;
}

.story-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background:
        linear-gradient(180deg, rgba(39, 89, 200, 0.13), transparent 48%),
        var(--surface);
    transition: border-color 180ms ease, transform 180ms ease;
}

.story-card:hover {
    border-color: color-mix(in srgb, var(--accent), var(--line) 40%);
    transform: translateY(-2px);
}

.story-card a {
    display: grid;
    min-height: 150px;
    padding: 22px;
    text-decoration: none;
}

.story-card h3 {
    align-self: end;
    margin: 0;
    color: var(--accent);
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.05;
    text-transform: uppercase;
}

.story-group {
    padding: 28px 0;
    border-top: 1px solid var(--line);
    scroll-margin-top: 96px;
}

.story-group:last-child {
    border-bottom: 1px solid var(--line);
}

.story-group-header {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 28px;
    align-items: start;
    margin-bottom: 18px;
}

.story-group-header h2 {
    margin: 0;
    font-size: clamp(1.9rem, 4vw, 3.4rem);
    line-height: 1;
}

.story-group-header h3 {
    margin: 0;
    color: var(--accent);
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 3vw, 2.6rem);
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1;
    text-transform: uppercase;
}

.story-group-header h2 a,
.story-link,
.chapter-list a {
    text-decoration: none;
}

.story-group-header p:not(.eyebrow) {
    max-width: 660px;
    margin: 12px 0 0;
    color: var(--muted);
}

.story-link {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.9rem;
    white-space: nowrap;
}

.chapter-list {
    display: grid;
    gap: 10px;
    padding: 0;
    margin: 0;
    list-style: none;
    counter-reset: chapter;
}

.chapter-list + .chapter-list {
    margin-top: 10px;
}

.chapter-list li {
    counter-increment: chapter;
}

.chapter-list a {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
    min-height: 68px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: color-mix(in srgb, var(--surface), #000 6%);
}

.chapter-list a::before {
    content: counter(chapter, decimal-leading-zero);
    color: var(--blue-heart);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.chapter-title {
    min-width: 0;
    color: var(--text);
    font-weight: 800;
    line-height: 1.2;
}

.chapter-meta {
    color: var(--muted);
    font-size: 0.9rem;
    white-space: nowrap;
}

.chapter-list.large {
    max-width: 900px;
}

.chapter-list.large a {
    grid-template-columns: 52px minmax(0, 1fr) auto;
}

.chapter-excerpt {
    grid-column: 2 / 4;
    color: var(--muted);
}

.empty-story-note {
    margin: 0;
    color: var(--muted);
}

.tag-card-feed {
    padding-top: 0;
}

.post-feed {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 28px 20px;
    padding: 42px 0;
}

.post-feed-list {
    grid-template-columns: 1fr;
    max-width: 860px;
}

.post-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.post-card-image {
    display: block;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: var(--soft);
}

.post-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 220ms ease;
}

.post-card:hover .post-card-image img {
    transform: scale(1.03);
}

.post-card-content {
    padding: 22px;
}

.post-card h2 {
    margin: 0;
    color: var(--accent);
    font-family: var(--font-display);
    font-size: 1.65rem;
    letter-spacing: 0.04em;
    line-height: 1.15;
    text-transform: uppercase;
}

.post-card h2 a {
    text-decoration: none;
}

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

.post-card footer {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 18px;
    color: var(--muted);
    font-size: 0.88rem;
}

.post-feed-list .post-card {
    display: grid;
    grid-template-columns: minmax(180px, 280px) 1fr;
}

.article {
    max-width: var(--content);
    margin: 0 auto;
    padding: 64px 0;
    color: var(--text);
}

.article-header {
    margin-bottom: 34px;
}

.article-header h1 {
    font-size: clamp(2.4rem, 6vw, 5.2rem);
}

.article-meta {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 20px;
    color: var(--muted);
    font-size: 0.95rem;
}

.article-image {
    width: min(920px, calc(100vw - 40px));
    margin: 0 50% 42px;
    transform: translateX(-50%);
}

.article-image img {
    width: 100%;
    border-radius: 8px;
}

.article-image figcaption {
    margin-top: 10px;
    color: var(--muted);
    font-size: 0.9rem;
    text-align: center;
}

.gh-content {
    font-size: 1.08rem;
}

.gh-content > * {
    margin-block: 0 1.45em;
}

.gh-content h2,
.gh-content h3 {
    color: var(--accent);
    font-family: var(--font-display);
    letter-spacing: 0.04em;
    margin-top: 1.7em;
    line-height: 1.12;
    text-transform: uppercase;
}

.gh-content h2 {
    font-size: 2rem;
}

.gh-content h3 {
    font-size: 1.45rem;
}

.gh-content blockquote {
    margin-inline: 0;
    padding: 4px 0 4px 22px;
    border-left: 4px solid var(--accent);
    color: var(--muted);
    font-size: 1.2rem;
}

.gh-content pre,
.gh-content code {
    font-family: "SFMono-Regular", Consolas, monospace;
}

.gh-content pre {
    overflow-x: auto;
    padding: 18px;
    border-radius: 8px;
    background: #04101D;
    color: var(--text);
}

.gh-content .kg-card {
    margin-block: 2em;
}

.kg-width-wide {
    width: min(920px, calc(100vw - 40px));
    max-width: none;
    margin-inline: 50%;
    transform: translateX(-50%);
}

.kg-width-full {
    width: min(100vw, 1280px);
    max-width: none;
    margin-inline: 50%;
    transform: translateX(-50%);
}

.gh-content .kg-image {
    border-radius: 8px;
}

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

.article-tags a {
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.9rem;
    text-decoration: none;
}

.post-cta {
    margin-top: 48px;
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.post-cta h2 {
    margin: 0 0 16px;
    color: var(--accent);
    font-family: var(--font-display);
    font-size: 1.5rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.related-posts {
    width: min(var(--max), calc(100% - 40px));
    margin: 20px auto 70px;
    padding-top: 34px;
    border-top: 1px solid var(--line);
}

.related-posts h2 {
    margin: 0;
    color: var(--accent);
    font-family: var(--font-display);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.author-hero img {
    width: 86px;
    height: 86px;
    margin-bottom: 18px;
    border-radius: 50%;
    object-fit: cover;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 0 0 54px;
    color: var(--muted);
}

.pagination a {
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
}

.site-footer {
    position: relative;
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 28px 0 44px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.92rem;
}

.site-footer::after {
    position: absolute;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    margin: 0;
}

.site-footer p {
    margin: 0;
}

@media (max-width: 860px) {
    .site-header,
    .site-footer,
    .site-main {
        width: min(100% - 28px, var(--max));
    }

    .nav-toggle {
        display: block;
    }

    .site-nav {
        position: absolute;
        inset: 76px 14px auto;
        z-index: 20;
        display: none;
        align-items: stretch;
        padding: 18px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--surface);
        box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
    }

    .site-nav.is-open,
    .primary-nav {
        display: grid;
        gap: 12px;
    }

    .site-nav.is-open {
        max-height: calc(100vh - 96px);
        overflow: auto;
    }

    .nav-panel,
    .nav-panel-wide {
        position: static;
        min-width: 0;
        margin-top: 8px;
        box-shadow: none;
    }

    .nav-panel-wide {
        grid-template-columns: 1fr;
    }

    .featured-section,
    .section-hub,
    .story-card-grid,
    .post-feed {
        grid-template-columns: 1fr;
    }

    .story-group-header {
        grid-template-columns: 1fr;
    }

    .story-link {
        width: fit-content;
    }

    .chapter-list a,
    .chapter-list.large a {
        grid-template-columns: 38px minmax(0, 1fr);
    }

    .chapter-meta,
    .chapter-excerpt {
        grid-column: 2;
    }

    .chapter-meta {
        white-space: normal;
    }

    .post-feed-list .post-card {
        display: block;
    }

    .archive-hero {
        padding-top: 52px;
    }

    .article {
        padding-top: 46px;
    }

    .article-image {
        width: 100%;
        margin-inline: 0;
        transform: none;
    }

    .kg-width-wide,
    .kg-width-full {
        width: 100%;
        margin-inline: 0;
        transform: none;
    }

    .site-footer {
        display: block;
    }

    .site-footer p + p {
        margin-top: 6px;
    }
}
