:root {
    --bg: #030712;
    --surface: #111828;
    --surface-2: rgba(255, 255, 255, 0.05);
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #38bdf8;
    --accent-2: #a855f7;
    --border: rgba(255, 255, 255, 0.08);
    --radius: 18px;
    font-size: 16px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Space Grotesk", "Helvetica Neue", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: radial-gradient(circle at top, rgba(56, 189, 248, 0.25), rgba(8, 47, 73, 0)) fixed,
        radial-gradient(circle at 20% 20%, rgba(168, 85, 247, 0.2), rgba(15, 23, 42, 0)), var(--bg);
    color: var(--text);
    min-height: 100vh;
}

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

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

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

.site-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 0 16px 40px;
}

.site-main {
    flex: 1;
    width: 100%;
    margin: 64px auto 0;
}

.site-header {
    position: sticky;
    top: 8px;
    z-index: 10;
    margin: 8px auto 0;
    width: calc(100% - 24px);
    border-radius: 999px;
    background: rgba(2, 6, 23, 0.8);
    border: 1px solid var(--border);
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(18px);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.site-header.is-hidden {
    transform: translateY(-120%);
    opacity: 0;
}

.site-header.is-open .nav-menu {
    display: block;
}

.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    gap: 12px;
    position: relative;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    font-weight: 600;
    max-width: 320px;
    min-width: 0;
}

.brand-title {
    font-size: 0.95rem;
    letter-spacing: 0.01em;
}

.brand img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    flex-shrink: 0;
    display: block;
}

.brand-tagline {
    display: block;
    font-size: 0.875rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-search,
.nav-cta {
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.nav-cta {
    background: linear-gradient(120deg, var(--accent), var(--accent-2));
    font-weight: 600;
}

.nav-search:hover,
.nav-cta:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.4);
}

.nav-search {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    font-family: inherit;
}

.nav-toggle {
    border: none;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
}

.nav-toggle span {
    width: 20px;
    height: 2px;
    background: var(--text);
    display: block;
    border-radius: 999px;
}

.nav-menu {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    display: none;
    background: rgba(8, 12, 28, 0.95);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 10px;
    box-shadow: 0 20px 40px rgba(2, 6, 23, 0.6);
}

.nav-menu .nav {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 8px;
}

.nav-menu .nav a {
    padding: 10px 14px;
    border-radius: 12px;
    color: var(--text-muted);
    border: 1px solid transparent;
    display: block;
}

.nav-menu .nav a:hover,
.nav-menu .nav-current a {
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--text);
}

.hero {
    margin-top: 16px;
    padding: 32px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.15), rgba(168, 85, 247, 0.15));
    border: 1px solid var(--border);
}

.hero-inner {
    max-width: 720px;
}

.hero h1 {
    font-size: clamp(2rem, 6vw, 3rem);
    margin: 0 0 16px;
}

.hero .intro {
    color: var(--text-muted);
    font-size: 1.075rem;
}

.hero-actions {
    margin-top: 24px;
    display: flex;
    gap: 12px;
}

.btn {
    border-radius: 999px;
    padding: 10px 22px;
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 0.95rem;
}

.btn.primary {
    background: var(--text);
    color: var(--bg);
}

.btn.ghost {
    border-color: var(--border);
    color: var(--text);
}

.post-feed {
    margin-top: 48px;
    display: grid;
    gap: 32px;
}

.post-card {
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
    padding: 24px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
}

.post-card .cover {
    overflow: hidden;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.05);
    min-height: 180px;
}

.post-card .cover img {
    height: 100%;
    width: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.post-card .cover:hover img {
    transform: scale(1.06);
}

.post-card h2 {
    margin: 0 0 10px;
    font-size: 1.6rem;
}

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

.meta {
    display: flex;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.reading-time {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.post,
.page {
    background: var(--surface);
    padding: clamp(24px, 6vw, 64px);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.post-header h1,
.page-header h1 {
    font-size: clamp(2rem, 4vw, 3rem);
    margin-bottom: 6px;
}

.post .lead,
.page .lead {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.post-content,
.page-content {
    margin-top: 32px;
    line-height: 1.7;
}

.post-content h2,
.post-content h3,
.page-content h2,
.page-content h3 {
    margin-top: 32px;
}

.post-meta,
.post-nav,
.post-comments {
    margin-top: 32px;
}

.post-meta {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.post-nav {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.post-comments {
    padding: 24px;
    border-radius: var(--radius);
    border: 1px dashed rgba(56, 189, 248, 0.4);
    background: rgba(56, 189, 248, 0.06);
}

.post-comments.disabled {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.03);
}

.wiki-hero,
.wiki-content,
.wiki-list {
    margin-top: 20px;
}

.wiki-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
    margin-top: 24px;
}

.wiki-sidenav {
    position: sticky;
    top: 140px;
    align-self: start;
}

.wiki-sidenav-inner {
    background: rgba(8, 12, 28, 0.75);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.wiki-sidenav summary {
    margin: 0;
    font-size: 1rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    cursor: pointer;
    list-style: none;
}

.wiki-sidenav summary::-webkit-details-marker {
    display: none;
}

.wiki-sidenav summary::after {
    content: "▾";
    float: right;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.wiki-sidenav details:not([open]) summary::after {
    transform: rotate(-90deg);
}

.wiki-sidenav .wiki-tree {
    margin-top: 16px;
}

.wiki-tree-list,
.wiki-leaf-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
    display: grid;
    gap: 6px;
}

.wiki-folder {
    border-radius: 14px;
    background: rgba(10, 16, 34, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.15);
    padding: 6px 10px;
}

.wiki-folder summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text);
    outline: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    border-radius: 10px;
    transition: background 0.2s ease;
}

.wiki-folder summary:hover {
    background: rgba(56, 189, 248, 0.12);
}

.wiki-folder summary::before {
    content: "▾";
    font-size: 0.8rem;
    color: var(--text-muted);
    transform: rotate(0deg);
    transition: transform 0.2s ease;
}

.wiki-folder:not([open]) summary::before {
    transform: rotate(-90deg);
}

.wiki-leaf-list {
    padding: 6px 0 6px 18px;
    display: grid;
    gap: 4px;
}

.wiki-leaf a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s ease, color 0.2s ease;
}

.wiki-leaf a::before {
    content: "•";
    color: var(--accent);
}

.wiki-leaf a:hover {
    color: var(--text);
    background: rgba(56, 189, 248, 0.12);
}

.wiki-tree-item {
    margin-bottom: 8px;
}

.wiki-empty-state {
    display: none;
    margin-top: 16px;
    color: var(--text-muted);
}

.wiki-list-title {
    margin: 0 0 16px;
    font-size: 1.1rem;
    color: var(--text);
}

.wiki-browser-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    margin-bottom: 16px;
}

.wiki-breadcrumb {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.wiki-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 140px));
    gap: 16px;
    margin-bottom: 24px;
    justify-content: start;
}

.wiki-tile {
    border-radius: 16px;
    background: rgba(10, 16, 34, 0.7);
    border: 1px solid rgba(148, 163, 184, 0.18);
    padding: 14px;
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    aspect-ratio: 2 / 3;
    min-height: 220px;
    justify-content: flex-end;
}

.wiki-tile img {
    width: 100%;
    height: 70%;
    object-fit: cover;
    border-radius: 12px;
}

.wiki-tile.is-folder span {
    font-weight: 600;
}

.wiki-tile.is-post {
    text-decoration: none;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.wiki-tile.is-back {
    background: rgba(56, 189, 248, 0.12);
    border-color: rgba(56, 189, 248, 0.35);
    font-weight: 600;
    aspect-ratio: auto;
    align-items: center;
    justify-content: center;
}

.wiki-tile.is-missing-image img {
    display: none;
}

.wiki-tile:hover {
    transform: translateY(-2px);
    border-color: rgba(56, 189, 248, 0.5);
    background: rgba(56, 189, 248, 0.12);
}

.wiki-hidden {
    display: none;
}

.wiki-empty {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.wiki-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
}

.wiki-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    background: rgba(15, 23, 42, 0.8);
}

.footer-inner {
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 16px;
    justify-content: space-between;
    color: var(--text-muted);
}

.footer-nav .nav {
    display: flex;
    gap: 12px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.pagination {
    margin-top: 48px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.pagination a,
.pagination span {
    padding: 10px 18px;
    border-radius: 999px;
    border: 1px solid var(--border);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.kg-width-wide,
.kg-width-full {
    margin: 32px 0;
}

.kg-width-wide > *,
.kg-width-full > * {
    width: 100%;
    border-radius: var(--radius);
    display: block;
}

.kg-width-wide {
    width: min(1200px, 90vw);
    margin-left: calc(50% - min(1200px, 90vw) / 2);
}

.kg-width-full {
    width: 100vw;
    margin-left: calc(50% - 50vw);
}

.kg-width-full img,
.kg-width-wide img {
    width: 100%;
    height: auto;
    object-fit: contain;
}

@media (max-width: 900px) {
    .site-main {
        margin-top: 84px;
    }

    .nav-menu {
        width: 100%;
    }

    .site-header.is-open .nav-menu {
        display: block;
    }

    .post-card {
        grid-template-columns: 1fr;
    }

    .wiki-layout {
        grid-template-columns: 1fr;
    }

    .wiki-sidenav {
        position: static;
    }

    .wiki-sidenav-inner {
        position: relative;
    }

    .kg-width-wide,
    .kg-width-full {
        width: 100%;
        margin-left: 0;
    }
}

@media (max-width: 600px) {
    .site-shell {
        padding: 0 12px 32px;
    }

    .hero {
        padding: 24px;
    }

    .site-header {
        width: calc(100% - 16px);
        margin-top: 6px;
    }

    .nav-inner {
        padding: 8px 12px;
    }

    .brand-title {
        font-size: 0.85rem;
        line-height: 1.1;
    }

    .nav-search {
        display: none;
    }

    .nav-cta {
        padding: 6px 10px;
        font-size: 0.85rem;
    }

    .nav-actions .label {
        display: none;
    }

    .brand {
        gap: 8px;
    }

    .brand img {
        width: 36px;
        height: 36px;
    }

    .wiki-tiles {
        grid-template-columns: repeat(auto-fill, minmax(120px, 120px));
        justify-content: center;
    }

    .wiki-tile {
        min-height: 180px;
    }
}

@media (min-width: 900px) {
    .site-shell {
        padding: 0 24px 48px;
    }

    .site-main {
        width: min(1100px, 100%);
        margin-top: 88px;
    }

    .site-header {
        top: 12px;
        margin-top: 16px;
        width: min(1100px, calc(100% - 48px));
    }

    .brand-title {
        font-size: 1rem;
    }

    .nav-search,
    .nav-cta {
        padding: 8px 16px;
    }

    .nav-menu {
        position: static;
        display: flex;
        background: transparent;
        border: none;
        box-shadow: none;
        padding: 0;
    }

    .nav-menu .nav {
        display: flex;
        gap: 16px;
        align-items: center;
    }

    .nav-toggle {
        display: none;
    }

    .wiki-layout {
        grid-template-columns: 260px 1fr;
    }

    .wiki-tiles {
        grid-template-columns: repeat(auto-fill, minmax(180px, 180px));
        justify-content: start;
    }

    .post-card {
        grid-template-columns: 240px 1fr;
    }

    .footer-inner {
        flex-direction: row;
        align-items: center;
    }
}
