@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
    color-scheme: dark;
    --bg: #030407;
    --ink: #f7f2ea;
    --muted: rgba(247, 242, 234, 0.66);
    --faint: rgba(247, 242, 234, 0.42);
    --line: rgba(255, 255, 255, 0.13);
    --panel: rgba(255, 255, 255, 0.06);
    --panel-strong: rgba(255, 255, 255, 0.1);
    --gold: #f6b35a;
    --coral: #ff6b4a;
    --blue: #7cc9ff;
    --green: #75f0b0;
}

body[data-theme="light"] {
    color-scheme: light;
    --bg: #f7f3ea;
    --ink: #15110d;
    --muted: rgba(21, 17, 13, 0.68);
    --faint: rgba(21, 17, 13, 0.46);
    --line: rgba(21, 17, 13, 0.14);
    --panel: rgba(255, 255, 255, 0.72);
    --panel-strong: rgba(255, 255, 255, 0.92);
    --gold: #b76d16;
    --coral: #c9482c;
    --blue: #176d96;
    --green: #158455;
}

* { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at 78% 12%, rgba(124, 201, 255, 0.18), transparent 30rem),
        radial-gradient(circle at 14% 18%, rgba(246, 179, 90, 0.16), transparent 26rem),
        linear-gradient(180deg, #030407 0%, #060914 48%, #030407 100%);
    -webkit-font-smoothing: antialiased;
}

body[data-theme="light"] {
    background:
        radial-gradient(circle at 78% 12%, rgba(23, 109, 150, 0.14), transparent 30rem),
        radial-gradient(circle at 14% 18%, rgba(183, 109, 22, 0.16), transparent 26rem),
        linear-gradient(180deg, #f7f3ea 0%, #fffaf0 48%, #f7f3ea 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -2;
    pointer-events: none;
    background:
        linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
    background-size: 64px 64px;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,0.78), transparent 78%);
}

body[data-theme="light"]::before {
    background:
        linear-gradient(rgba(21,17,13,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(21,17,13,0.03) 1px, transparent 1px);
}

a { color: inherit; }
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

#starscape {
    position: fixed;
    inset: 0;
    z-index: -3;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.skip-link {
    position: fixed;
    left: 1rem;
    top: 1rem;
    z-index: 100;
    transform: translateY(-150%);
    border-radius: 999px;
    background: var(--ink);
    color: #080604;
    padding: 0.7rem 1rem;
}

.skip-link:focus { transform: translateY(0); }

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: min(1180px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1rem 0;
}

.site-header::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.36);
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(22px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    padding-left: 0.85rem;
    text-decoration: none;
}

.brand img {
    width: 2.45rem;
    height: 2.45rem;
    border-radius: 999px;
    object-fit: contain;
}

.brand span {
    display: grid;
    min-width: 0;
    line-height: 1.1;
}

.brand strong {
    overflow: hidden;
    font-family: "Space Grotesk", Inter, sans-serif;
    font-size: 0.95rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand small {
    margin-top: 0.22rem;
    color: var(--faint);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.24em;
    text-transform: uppercase;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.4rem;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 700;
}

.nav-links a {
    text-decoration: none;
    transition: color 180ms ease;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] { color: var(--ink); }

.icon-button {
    display: grid;
    place-items: center;
    width: 2.55rem;
    height: 2.55rem;
    margin-right: 0.45rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink);
}

.theme-switch {
    position: relative;
    display: inline-flex;
    width: 4.35rem;
    height: 2.45rem;
    flex-shrink: 0;
}

.theme-switch input {
    position: absolute;
    opacity: 0;
}

.theme-switch span {
    position: absolute;
    inset: 0;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    transition: background 180ms ease, border-color 180ms ease;
}

.theme-switch span::before {
    content: "";
    position: absolute;
    left: 0.28rem;
    top: 0.25rem;
    width: 1.85rem;
    height: 1.85rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #fff6df, var(--gold));
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
    transition: transform 180ms ease;
}

.theme-switch span::after {
    content: "☾";
    position: absolute;
    right: 0.72rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 800;
}

.theme-switch input:checked + span {
    background: rgba(255, 255, 255, 0.72);
}

.theme-switch input:checked + span::before {
    transform: translateX(1.84rem);
}

.theme-switch input:checked + span::after {
    content: "☀";
    left: 0.72rem;
    right: auto;
    color: #9a5a0d;
}

main {
    width: min(1180px, calc(100% - 2rem));
    margin: 0 auto;
}

.journal-intro {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    padding: 2.3rem 0 1rem;
}

.journal-intro h1 {
    margin: 0;
    font-family: "Space Grotesk", Inter, sans-serif;
    font-size: clamp(2.3rem, 7vw, 4.8rem);
    line-height: 0.95;
    letter-spacing: 0;
}

.eyebrow {
    margin: 0 0 1rem;
    color: var(--blue);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.3em;
    text-transform: uppercase;
}

menu {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin: 2rem 0 0;
    padding: 0;
}

.primary-link,
.secondary-link,
.danger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.85rem;
    border-radius: 999px;
    padding: 0.8rem 1.15rem;
    border: 0;
    text-decoration: none;
    font-weight: 800;
}

.primary-link {
    background: linear-gradient(135deg, #fff6df 0%, var(--gold) 48%, var(--coral) 100%);
    color: #170d06;
    box-shadow: 0 16px 48px rgba(255, 107, 74, 0.22);
}

.secondary-link {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink);
}

.danger-button {
    background: rgba(255, 107, 74, 0.12);
    color: #ffd1c7;
    border: 1px solid rgba(255, 107, 74, 0.4);
}

body[data-theme="light"] .site-header::before,
body[data-theme="light"] .post-card,
body[data-theme="light"] .dialog-panel,
body[data-theme="light"] .loading,
body[data-theme="light"] .empty-state {
    background: rgba(255, 255, 255, 0.72);
    box-shadow: 0 24px 80px rgba(68, 45, 15, 0.12);
}

body[data-theme="light"] .post-cover-link {
    background:
        linear-gradient(135deg, rgba(183, 109, 22, 0.18), rgba(23, 109, 150, 0.1)),
        rgba(21, 17, 13, 0.04);
}

body[data-theme="light"] input,
body[data-theme="light"] #post-editor,
body[data-theme="light"] .editor-tools button {
    background: rgba(255, 255, 255, 0.64);
}

.toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
    align-items: end;
    border-block: 1px solid var(--line);
    padding: 1rem 0;
}

.search-box label,
.field-grid label {
    display: grid;
    gap: 0.45rem;
    color: var(--faint);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 0.85rem;
    background: rgba(0, 0, 0, 0.3);
    color: var(--ink);
    padding: 0.9rem 1rem;
    outline: none;
}

input:focus,
#post-editor:focus {
    border-color: rgba(124, 201, 255, 0.65);
    box-shadow: 0 0 0 4px rgba(124, 201, 255, 0.12);
}

.view-toggle {
    display: inline-flex;
    gap: 0.35rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.32rem;
    background: rgba(255, 255, 255, 0.05);
}

.view-button {
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    padding: 0.58rem 0.85rem;
    font-weight: 800;
}

.view-button.active {
    background: var(--ink);
    color: #080604;
}

.content-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 12rem;
    gap: 2rem;
    align-items: start;
    padding: 2rem 0 6rem;
}

.blog-feed {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.2rem;
}

.blog-feed.list-view {
    grid-template-columns: 1fr;
}

.loading,
.empty-state {
    grid-column: 1 / -1;
    border: 1px solid var(--line);
    border-radius: 1rem;
    padding: 1.4rem;
    color: var(--muted);
    background: var(--panel);
}

.post-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 1.25rem;
    background: rgba(255, 255, 255, 0.062);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(18px);
    transition: transform 180ms ease, border-color 180ms ease;
}

.post-card:hover {
    transform: translateY(-3px);
    border-color: rgba(246, 179, 90, 0.46);
}

.post-cover-link {
    display: block;
    aspect-ratio: 16 / 9;
    background:
        linear-gradient(135deg, rgba(246, 179, 90, 0.2), rgba(124, 201, 255, 0.12)),
        rgba(255, 255, 255, 0.04);
}

.post-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.post-body {
    display: grid;
    gap: 0.9rem;
    padding: 1.25rem;
}

.post-meta {
    color: var(--faint);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.post-card h2 {
    margin: 0;
    font-family: "Space Grotesk", Inter, sans-serif;
    font-size: clamp(1.4rem, 3vw, 2.25rem);
    line-height: 1.05;
}

.post-card h2 a { text-decoration: none; }
.post-card h2 a:hover { color: var(--gold); }

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.post-tags span {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.32rem 0.55rem;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.04);
    font-size: 0.76rem;
    font-weight: 800;
}

.post-excerpt,
.post-content {
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.75;
}

.post-content { display: none; }
.post-card.expanded .post-excerpt { display: none; }
.post-card.expanded .post-content { display: block; }

.post-content :is(p, ul, ol, blockquote) { margin: 0 0 1rem; }
.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 1rem;
}

.post-content blockquote,
#post-editor blockquote {
    margin: 1rem 0;
    border-left: 3px solid var(--gold);
    border-radius: 0.6rem;
    background: rgba(246, 179, 90, 0.08);
    padding: 0.9rem 1rem;
    color: rgba(247, 242, 234, 0.78);
}

.post-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    padding-top: 0.7rem;
    border-top: 1px solid var(--line);
}

.post-actions button {
    min-height: 2.35rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.055);
    color: var(--ink);
    padding: 0.45rem 0.78rem;
    font-weight: 800;
}

.blog-feed.list-view .post-card {
    display: grid;
    grid-template-columns: minmax(8rem, 14rem) minmax(0, 1fr);
}

.blog-feed.list-view .post-cover-link { aspect-ratio: auto; }
.blog-feed.list-view .post-card h2 { font-size: 1.45rem; }

.timeline {
    position: sticky;
    top: 5.8rem;
    max-height: calc(100vh - 7rem);
    overflow: auto;
    border-left: 1px solid var(--line);
    padding-left: 1.1rem;
}

.timeline h2 {
    margin: 0 0 1rem;
    color: var(--faint);
    font-size: 0.78rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.timeline a {
    display: block;
    position: relative;
    margin: 0 0 0.8rem;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.88rem;
    line-height: 1.35;
}

.timeline a::before {
    content: "";
    position: absolute;
    left: -1.35rem;
    top: 0.32rem;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 999px;
    background: var(--line);
}

.timeline a:hover,
.timeline a.active { color: var(--gold); }
.timeline a.active::before { background: var(--gold); box-shadow: 0 0 0 4px rgba(246, 179, 90, 0.15); }

.dialog {
    width: min(920px, calc(100% - 2rem));
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--ink);
}

.dialog::backdrop {
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(8px);
}

.dialog-panel {
    position: relative;
    display: grid;
    gap: 1rem;
    border: 1px solid var(--line);
    border-radius: 1.2rem;
    background: rgba(5, 7, 13, 0.96);
    padding: 1.3rem;
    box-shadow: 0 30px 120px rgba(0, 0, 0, 0.45);
}

.dialog-panel h2 {
    margin: 0;
    font-family: "Space Grotesk", Inter, sans-serif;
    font-size: 2rem;
}

.dialog-panel p {
    margin: 0;
    color: var(--muted);
    line-height: 1.65;
}

.close-button {
    position: absolute;
    right: 1rem;
    top: 1rem;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink);
    font-size: 1.2rem;
}

.composer-dialog { width: min(1040px, calc(100% - 2rem)); }
.composer-panel { max-height: 88vh; overflow: auto; }

.composer-head {
    display: flex;
    gap: 1rem;
    align-items: start;
    justify-content: space-between;
    padding-right: 3rem;
}

.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.9rem;
}

.field-grid label:last-child { grid-column: 1 / -1; }

.editor-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    border: 1px solid var(--line);
    border-radius: 0.95rem;
    background: rgba(255, 255, 255, 0.045);
    padding: 0.55rem;
}

.editor-tools button {
    border: 1px solid var(--line);
    border-radius: 0.7rem;
    background: rgba(0, 0, 0, 0.26);
    color: var(--ink);
    padding: 0.55rem 0.75rem;
}

#post-editor {
    min-height: 20rem;
    border: 1px solid var(--line);
    border-radius: 1rem;
    background: rgba(0, 0, 0, 0.28);
    color: var(--ink);
    padding: 1rem;
    outline: none;
    line-height: 1.75;
}

#post-editor:empty::before {
    content: attr(data-placeholder);
    color: var(--faint);
}

#post-editor img {
    max-width: 100%;
    height: auto;
    border-radius: 1rem;
}

@media (max-width: 900px) {
    .content-shell {
        grid-template-columns: 1fr;
    }

    .timeline {
        position: static;
        max-height: none;
    }
}

@media (max-width: 680px) {
    .site-header {
        width: calc(100% - 1rem);
        gap: 0.5rem;
    }

    .brand strong { max-width: 9.5rem; }
    .nav-links { display: none; }

    main { width: min(100% - 1rem, 1180px); }

    .toolbar,
    .field-grid,
    .blog-feed {
        grid-template-columns: 1fr;
    }

    .journal-intro {
        align-items: start;
        flex-direction: column;
        padding-top: 1.4rem;
    }

    .blog-feed.list-view .post-card {
        grid-template-columns: 1fr;
    }

    .composer-head {
        display: block;
        padding-right: 2.6rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 1ms !important;
        scroll-behavior: auto !important;
        transition-duration: 1ms !important;
    }
}
