:root {
    --xp-blue: #1d6ec4;
    --xp-blue-hi: #5aa3ef;
    --xp-blue-deep: #0b3d7a;
    --energy-green: #3ecf7a;
    --glass: rgba(210, 230, 255, 0.55);
    --ink: #10233d;
    --muted: #3d5570;
    --paper: #f8f8ff;
    --panel: #f8f8ff;
    --title-bg: #f8f8ff;
    --line: rgba(80, 130, 190, 0.28);
    --chrome: linear-gradient(180deg, #3a8fe0 0%, #1657a8 55%, #0d3d7a 100%);
    --header: var(--chrome);
    --footer: var(--chrome);
    --page-bg: #2b2b2b;
    --font: "Segoe UI", Tahoma, "Trebuchet MS", Verdana, sans-serif;
    --content: 880px;
    --wide: 1080px;
    --site: 1200px;
}

.mode-sky {
    --xp-blue: #2b86d4;
    --xp-blue-hi: #7ec4ff;
    --chrome: linear-gradient(180deg, #5aa8e8 0%, #2b86d4 60%, #165a9a 100%);
    --header: var(--chrome);
    --footer: var(--chrome);
    --page-bg: #c8c8c8;
    --paper: #f8f8ff;
    --panel: #f8f8ff;
    --title-bg: #f8f8ff;
}

.mode-noir {
    --xp-blue: #4a6a9a;
    --xp-blue-hi: #6f8cb8;
    --xp-blue-deep: #0b1018;
    --energy-green: #2bb36a;
    --glass: rgba(40, 55, 80, 0.62);
    --ink: #e8eef8;
    --muted: #b4c2d6;
    --paper: #10161f;
    --panel: rgba(22, 28, 40, 0.86);
    --title-bg: #1a2230;
    --line: rgba(120, 150, 190, 0.22);
    --chrome: linear-gradient(180deg, #243044 0%, #10161f 100%);
    --header: var(--chrome);
    --footer: var(--chrome);
    --page-bg: #1c1c1c;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { height: 100%; }
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font);
    color: var(--ink);
    background-color: var(--page-bg, #2b2b2b);
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -10%, rgba(90, 150, 220, 0.16), transparent 60%),
        radial-gradient(ellipse 70% 40% at 50% 110%, rgba(0, 0, 0, 0.35), transparent 55%),
        repeating-radial-gradient(circle at 1px 1px, rgba(255,255,255,0.035) 0 1px, transparent 1px 3px);
    background-attachment: fixed;
}
body.mode-sky {
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -10%, rgba(255,255,255,0.28), transparent 60%),
        radial-gradient(ellipse 70% 40% at 50% 110%, rgba(0, 0, 0, 0.08), transparent 55%),
        repeating-radial-gradient(circle at 1px 1px, rgba(0,0,0,0.03) 0 1px, transparent 1px 3px);
}
body.mode-noir {
    background-color: var(--page-bg);
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -10%, rgba(70, 100, 150, 0.18), transparent 60%),
        radial-gradient(ellipse 70% 40% at 50% 110%, rgba(0, 0, 0, 0.45), transparent 55%),
        repeating-radial-gradient(circle at 1px 1px, rgba(255,255,255,0.03) 0 1px, transparent 1px 3px);
}

a { color: var(--xp-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    color: #fff;
    background: var(--header);
    box-shadow: 0 1px 0 rgba(255,255,255,0.35) inset, 0 8px 22px rgba(10,40,90,0.18);
    border-bottom: 1px solid rgba(0,40,90,0.2);
}
.header-inner,
.footer-inner {
    width: 100%;
    max-width: var(--site);
    margin: 0 auto;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 18px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff !important;
    text-decoration: none !important;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-shadow: 0 1px 2px rgba(0,40,90,0.35);
}
.brand img { height: 32px; width: auto; }
.brand-orb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #fff, var(--energy-green) 42%, #167a40);
    box-shadow: 0 0 0 1px rgba(255,255,255,0.5), 0 2px 6px rgba(0,80,40,0.35);
}
.primary-nav { flex: 1; }
.primary-nav .nav,
.footer-nav .nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
}
.primary-nav a {
    display: inline-block;
    padding: 7px 12px;
    border-radius: 7px;
    color: #fff;
    font-size: 13px;
    font-weight: 650;
    text-shadow: 0 1px 1px rgba(0,40,90,0.35);
}
.primary-nav .nav-current a,
.primary-nav a:hover {
    text-decoration: none;
    background: linear-gradient(#fff9, rgba(255,255,255,0.18));
    box-shadow: inset 0 1px 0 #fff, 0 0 0 1px rgba(255,255,255,0.28);
}
.header-tools { display: flex; align-items: center; gap: 8px; }
.search-orb {
    width: auto;
    height: auto;
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.55);
    background:
        linear-gradient(#fff8, #fff0 42%, #0002),
        linear-gradient(180deg, var(--xp-blue-hi), var(--xp-blue));
    color: #fff;
    cursor: pointer;
    font: 650 12px var(--font);
    box-shadow: 0 2px 0 rgba(10,40,90,0.25);
}

.site-main {
    flex: 1 0 auto;
    width: 100%;
    max-width: var(--site);
    margin: 0 auto;
    padding: 28px 20px 72px;
}
@media (min-width: 900px) {
    .site-main,
    .header-inner,
    .footer-inner {
        width: 80vw;
        max-width: 80vw;
        padding-left: 0;
        padding-right: 0;
    }
    .hero-pane,
    .hero-glass,
    .article-window,
    .article-page {
        width: 100%;
        max-width: 100%;
    }
}

.hero-pane {
    margin: 0 0 56px;
    padding-bottom: 8px;
}
.post-grid {
    margin-top: 56px;
}
.hero-glass,
.archive-head,
.article-head {
    background: var(--title-bg, #f8f8ff);
}
.hero-glass {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 22px;
    padding: 28px 32px;
    border-radius: 14px;
    text-align: left;
    box-shadow: inset 0 1px 0 #fff, 0 14px 36px rgba(0,0,0,0.18);
    border: 1px solid rgba(220, 220, 235, 0.9);
}
.hero-glass .site-logo {
    margin: 0;
    max-height: 72px;
    width: auto;
    flex-shrink: 0;
}
.hero-copy { min-width: 0; }
.hero-copy .site-name { margin: 0 0 4px; }
.hero-copy .site-tagline { margin: 0; }
.mode-noir .hero-glass {
    background: linear-gradient(180deg, rgba(50,65,90,0.7), rgba(20,28,40,0.7));
    border-color: rgba(255,255,255,0.12);
}
.site-name {
    margin: 0 0 6px;
    font-size: clamp(28px, 5vw, 44px);
    letter-spacing: -0.03em;
}
.site-tagline { margin: 0; color: var(--muted); font-size: 16px; }
.site-logo { max-height: 56px; width: auto; }

.post-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 28px;
    margin-top: 56px;
}
.post-card {
    border-radius: 12px;
    overflow: hidden;
    background: var(--panel);
    box-shadow: 0 8px 20px rgba(20,50,100,0.1), inset 0 1px 0 #fff;
    border: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(10px);
}
.mode-noir .post-card { box-shadow: 0 8px 20px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.06); }
.card-media img, .card-placeholder {
    width: 100%;
    height: auto;
    max-height: 25vh;
    object-fit: cover;
}
.card-placeholder { height: 25vh; }
.card-placeholder {
    background:
        radial-gradient(circle at 30% 20%, #fff8, transparent 40%),
        linear-gradient(135deg, #4ea3ef, #3ecf7a);
}
.card-body { padding: 14px 14px 16px; }
.card-body h2 { margin: 6px 0 8px; font-size: 18px; line-height: 1.25; }
.card-body h2 a { color: var(--ink); }
.card-body p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.meta { display: flex; gap: 10px; color: var(--muted); font-size: 12px; }

.chip {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #fff;
    background: linear-gradient(#6ec4ff, var(--xp-blue));
    padding: 3px 8px;
    border-radius: 999px;
    text-decoration: none;
}
.mode-noir .chip { background: linear-gradient(#3ecf7a, #167a40); }

.article-window,
.article-page,
.hero-pane {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}
.article-window,
.article-page {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 28px 28px 40px;
    box-shadow: 0 12px 32px rgba(20,50,100,0.1), inset 0 1px 0 #fff;
}
.article-head {
    border-radius: 8px;
    padding: 4px 0 10px;
}
.article-head h1 { margin: 8px 0 10px; font-size: clamp(28px, 4vw, 42px); line-height: 1.15; }
.archive-head {
    border-radius: 12px;
    padding: 20px 24px;
    border: 1px solid var(--line);
}
.feature { margin: 0 0 22px; border-radius: 10px; overflow: hidden; }
.feature img {
    width: 100%;
    height: auto;
    max-height: 25vh;
    object-fit: cover;
    object-position: center;
}
.feature figcaption { color: var(--muted); font-size: 13px; padding-top: 8px; }

.gh-content {
    font-size: 17.5px;
    line-height: 1.7;
}
.gh-content > * + * { margin-top: 1em; }
.gh-content h2, .gh-content h3 { margin-top: 1.4em; }
.gh-content img { max-width: 100%; height: auto; }
.gh-content pre, .gh-content code {
    font-family: Consolas, "Lucida Console", monospace;
    background: rgba(20, 60, 120, 0.08);
    border-radius: 6px;
}
.mode-noir .gh-content pre,
.mode-noir .gh-content code { background: rgba(255,255,255,0.06); }
.gh-content pre { padding: 14px; overflow: auto; }
.gh-content code { padding: 0.1em 0.35em; }
.gh-content blockquote {
    margin-left: 0;
    padding: 8px 16px;
    border-left: 4px solid var(--xp-blue-hi);
    background: rgba(90, 163, 239, 0.12);
}
.gh-content figcaption { color: var(--muted); font-size: 13px; text-align: center; }
.gh-content figure { margin: 1.4em 0; }

/* Required Koenig width classes */
.kg-width-wide {
    position: relative;
    width: min(var(--wide), 92vw);
    max-width: 92vw;
    min-width: 100%;
    margin-left: 50%;
    transform: translateX(-50%);
}
.kg-width-wide img,
.kg-width-wide .kg-image {
    width: 100%;
    max-width: 85vw;
    height: auto;
}
.kg-width-full {
    position: relative;
    width: 100vw;
    max-width: 100vw;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
}
.kg-width-full img,
.kg-width-full .kg-image {
    width: 100%;
    max-width: 100vw;
    height: auto;
}
.kg-image { max-width: 100%; height: auto; }
.kg-card { margin: 1.6em 0; }
.kg-embed-card { display: flex; flex-direction: column; align-items: center; }

.tag-row { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 28px 0 0; }
.tag-row a {
    padding: 4px 10px;
    border-radius: 999px;
    background: #e7f2ff;
    color: var(--xp-blue-deep);
    font-size: 13px;
}
.mode-noir .tag-row a { background: #243044; color: #cfe0f5; }

.post-nav, .pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 28px;
}
.page-number {
    color: #eef3fa;
    font-size: 13px;
    font-weight: 650;
    text-shadow: 0 1px 2px rgba(0,0,0,0.45);
}
.mode-sky .page-number {
    color: #1c1c1c;
    text-shadow: none;
}

.gloss-btn {
    display: inline-block;
    padding: 7px 14px;
    border-radius: 8px;
    color: #fff !important;
    text-decoration: none !important;
    font-weight: 650;
    font-size: 13px;
    border: 1px solid rgba(255,255,255,0.55);
    background:
        linear-gradient(#fff8, #fff0 42%, #0002),
        linear-gradient(180deg, var(--xp-blue-hi), var(--xp-blue));
    box-shadow: 0 2px 0 rgba(10,40,90,0.25);
}
.gloss-btn.small { padding: 5px 10px; font-size: 12px; }
.gloss-btn:hover { filter: brightness(1.08); }

.archive-head { margin-bottom: 22px; }
.archive-head h1 { margin: 0 0 6px; }
.author-head { display: flex; gap: 16px; align-items: center; }
.author-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--xp-blue-hi);
}

.site-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    flex-shrink: 0;
    color: #fff;
    background: var(--footer);
    box-shadow: 0 1px 0 rgba(255,255,255,0.28) inset, 0 -8px 20px rgba(0,0,0,0.25);
}
.footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 10px;
    padding-top: 14px;
    padding-bottom: 14px;
}
.footer-copy,
.footer-nav {
    width: 100%;
    justify-content: center;
}
.footer-copy { margin: 0; font-size: 13px; }
.footer-copy a { color: #fff; }
.sep { opacity: 0.55; padding: 0 6px; }
.footer-nav a {
    color: #fff;
    padding: 4px 8px;
    font-size: 13px;
}

.empty { color: var(--muted); }

@media (max-width: 720px) {
    .header-inner { flex-wrap: wrap; }
    .article-window, .article-page { padding: 18px 16px 28px; }
}

.header-text-link {
    display: inline-block;
    color: #fff !important;
    font-size: 12px;
    font-weight: 650;
    text-decoration: none !important;
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.55);
    background:
        linear-gradient(#fff8, #fff0 42%, #0002),
        linear-gradient(180deg, var(--xp-blue-hi), var(--xp-blue));
    box-shadow: 0 2px 0 rgba(10,40,90,0.25);
}
.header-text-link:hover { text-decoration: underline !important; }

body.no-signup a[href*="portal/signup"],
body.no-signup a[href*="#/portal/signup"],
body.no-signup .nav-signup,
body.no-signup .nav-sign-up,
body.no-signup .nav-subscribe,
body.no-members a[href*="#/portal"],
body.no-members a[data-portal] {
    display: none !important;
}

@media (min-width: 900px) {
    .header-inner,
    .footer-inner,
    .site-main {
        width: 80vw !important;
        max-width: 80vw !important;
        margin-left: auto !important;
        margin-right: auto !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        box-sizing: border-box;
    }
}

.header-inner {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    grid-template-rows: auto;
    align-items: center;
    column-gap: 16px;
}
.header-inner .primary-nav {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    flex: 0 1 auto;
}
.header-inner .brand {
    grid-column: 2;
    grid-row: 1;
    justify-self: center;
}
.header-inner .header-tools {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer-nav a[href*="signup"],
.footer-nav a[href*="subscribe"],
.footer-nav a[href*="portal"],
.footer-nav .nav-signup,
.footer-nav .nav-sign-up,
.footer-nav .nav-subscribe,
.footer-nav .nav-portal {
    display: none !important;
}

.menu-toggle {
    display: none;
    width: 42px;
    height: 34px;
    padding: 0;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.45);
    background:
        linear-gradient(#fff6, #fff0 45%, #0002),
        linear-gradient(180deg, var(--xp-blue-hi), var(--xp-blue));
    cursor: pointer;
}
.menu-toggle span {
    display: block;
    width: 16px;
    height: 2px;
    margin: 3px auto;
    background: #fff;
    border-radius: 1px;
}
.drawer-brand,
.drawer-account {
    display: none;
}

@media (max-width: 800px) {
    .menu-toggle { display: block; }
    .header-inner {
        display: grid !important;
        grid-template-columns: auto 1fr auto !important;
        grid-template-rows: auto;
    }
    .header-inner .menu-toggle {
        grid-column: 1;
        grid-row: 1;
        justify-self: start;
    }
    .header-inner .primary-nav {
        display: none;
    }
    .header-inner .header-brand {
        display: block;
        grid-column: 2;
        grid-row: 1;
        justify-self: center;
    }
    .site-header.is-open .primary-nav {
        display: flex;
        flex-direction: column;
        position: absolute;
        left: 0;
        right: 0;
        top: 100%;
        z-index: 40;
        padding: 16px 18px 20px;
        background: var(--header);
        box-shadow: 0 12px 24px rgba(0,0,0,0.28);
        border-bottom: 1px solid rgba(255,255,255,0.2);
    }
    .site-header.is-open .drawer-brand,
    .site-header.is-open .drawer-account {
        display: block;
        margin-bottom: 12px;
    }
    .site-header.is-open .primary-nav .nav {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
    }
    .site-header.is-open .primary-nav a {
        display: block;
        padding: 10px 12px;
    }
    .header-inner .header-tools {
        grid-column: 3;
        grid-row: 1;
        justify-self: end;
    }
    .header-account { display: none !important; }
    .site-header { position: sticky; }
}

@media (min-width: 801px) {
    .menu-toggle { display: none !important; }
    .drawer-brand,
    .drawer-account { display: none !important; }
}

.portal-switch {
    position: fixed;
    left: 50%;
    bottom: 72px;
    transform: translateX(-50%);
    z-index: 100000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.portal-switch[hidden] { display: none !important; }
.portal-switch-link {
    color: #fff !important;
    background: rgba(16, 35, 61, 0.88);
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 650;
    text-decoration: none !important;
    box-shadow: 0 8px 20px rgba(0,0,0,0.28);
}
.portal-switch-link[hidden] { display: none !important; }

iframe.gh-portal-triggerbtn-iframe,
.gh-portal-triggerbtn-iframe,
.gh-portal-triggerbtn-wrapper,
#ghost-portal-root iframe[title="portal-trigger"] {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    width: 0 !important;
    height: 0 !important;
}

.delete-account-page { max-width: 60vw; }
.delete-account-page .delete-account-confirm {
    background: linear-gradient(#ff8a7a, #c42b1c);
    margin-top: 16px;
}
a.royale-delete {
    display: block;
    text-align: center;
    text-decoration: none !important;
}
@media (max-width: 800px) {
    .delete-account-page { max-width: 100%; }
}

html.on-delete-account #ghost-portal-root,
body.page-delete-account #ghost-portal-root,
body.page-delete-account iframe.gh-portal-popup-iframe {
    display: none !important;
}
