/* Theme */
:root {
    color-scheme: dark;
    --bg: #07070a;
    --surface: #111116;
    --surface-strong: #191920;
    --border: #2a2a34;
    --text: #f4f4f5;
    --muted: #a8a8b5;
    --accent: #7c5cff;
    --accent-2: #67dff0;
    --radius: 18px;
}

/* Base */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 90px;
}

body {
    position: relative;
    isolation: isolate;
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont,
        "Segoe UI", Arial, sans-serif;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

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

button,
input,
textarea,
select {
    font: inherit;
}

button,
input,
textarea,
select,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    cursor: pointer;
}

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

h1,
h2,
h3,
p {
    overflow-wrap: anywhere;
}

h1,
h2,
h3 {
    line-height: 1.2;
}

:focus-visible {
    outline: 3px solid var(--accent-2);
    outline-offset: 4px;
}

::selection {
    background: #5941b7;
    color: #ffffff;
}

.background-glow {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(
            ellipse at 5% 0%,
            rgba(124, 92, 255, 0.16),
            transparent 45%
        ),
        radial-gradient(
            ellipse at 95% 15%,
            rgba(34, 211, 238, 0.1),
            transparent 45%
        );
}

.container {
    width: min(1120px, calc(100% - 40px));
    margin-inline: auto;
}

/* Header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(7, 7, 10, 0.96);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    padding-block: 18px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    text-decoration: none;
}

.brand-dot {
    flex: 0 0 10px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
}

.nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 22px;
}

.nav a {
    color: var(--muted);
    font-size: 0.94rem;
    font-weight: 500;
    text-decoration: none;
}

.nav a:hover,
.nav a:focus-visible {
    color: var(--text);
}

/* Homepage */
.hero {
    padding-block: clamp(56px, 8vw, 96px) 64px;
    text-align: center;
}

.hero-badge {
    display: inline-block;
    margin: 0;
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero h1 {
    margin: 24px 0 20px;
    font-size: clamp(2.4rem, 6vw, 4.6rem);
    font-weight: 800;
    line-height: 1.08;
    letter-spacing: -0.05em;
}

.gradient-text {
    color: var(--accent-2);
}

@supports (background-clip: text) or (-webkit-background-clip: text) {
    .gradient-text {
        background: linear-gradient(100deg, #a594ff, #67dff0);
        -webkit-background-clip: text;
        background-clip: text;
        color: transparent;
    }
}

.hero-text {
    max-width: 620px;
    margin: 0 auto 30px;
    color: var(--muted);
    font-size: clamp(1rem, 2vw, 1.12rem);
}

.hero-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
}

/* Buttons */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 11px 22px;
    border: 1px solid transparent;
    border-radius: 999px;
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.4;
    text-decoration: none;
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.button.primary {
    background: #6846e6;
    color: #ffffff;
}

.button.primary:hover {
    background: #7958f3;
}

.button.ghost {
    border-color: var(--border);
    background: var(--surface);
}

.button.ghost:hover {
    background: var(--surface-strong);
}

.button.small {
    min-height: 36px;
    padding: 7px 14px;
    font-size: 0.82rem;
}

.button.danger {
    background: #b91c1c;
    color: #ffffff;
}

.button.danger:hover {
    background: #dc2626;
}

/* Sections */
.section {
    padding-block: 36px 64px;
}

.section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 26px;
}

.eyebrow {
    display: block;
    margin: 0 0 9px;
    color: var(--accent-2);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

h2 {
    margin: 0;
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    letter-spacing: -0.035em;
}

/* Article cards */
.article-grid {
    display: grid;
    grid-template-columns: repeat(
        auto-fit,
        minmax(min(100%, 300px), 1fr)
    );
    gap: 18px;
}

.article-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 26px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.article-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
}

.article-date {
    display: block;
    margin-bottom: 14px;
    color: var(--muted);
    font-size: 0.82rem;
}

.article-card h3 {
    margin: 0 0 12px;
    font-size: 1.3rem;
    line-height: 1.3;
    letter-spacing: -0.025em;
}

.article-card p {
    margin: 0 0 24px;
    color: var(--muted);
    font-size: 0.95rem;
}

.read-more {
    margin-top: auto;
    color: var(--accent-2);
    font-size: 0.9rem;
    font-weight: 600;
}

/* Topic cards */
.topic-grid {
    display: grid;
    grid-template-columns: repeat(
        auto-fit,
        minmax(min(100%, 260px), 1fr)
    );
    gap: 18px;
}

.topic-card {
    min-width: 0;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.topic-card h3 {
    margin: 0 0 10px;
    font-size: 1.2rem;
    letter-spacing: -0.02em;
}

.topic-card p {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
}

/* Empty states */
.empty-card {
    padding: 40px 24px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    text-align: center;
}

.empty-card h2,
.empty-card h3 {
    margin: 0 0 10px;
}

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

/* Article and admin panels */
.post {
    width: 100%;
    max-width: 980px;
    min-width: 0;
    margin: 48px auto 64px;
    padding: clamp(20px, 4vw, 40px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow-wrap: anywhere;
}

.post h1 {
    margin: 10px 0 18px;
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 800;
    line-height: 1.12;
    letter-spacing: -0.04em;
}

.post-meta {
    margin: 0 0 28px;
    color: var(--muted);
    font-size: 0.9rem;
}

.post-content {
    max-width: 72ch;
    margin: 0 auto 32px;
    color: #dedee6;
    font-size: 1.05rem;
    line-height: 1.8;
    overflow-wrap: anywhere;
}

.featured-image {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0 0 28px;
    overflow: hidden;
    border-radius: 16px;
}

.featured-image img,
.post-image {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    aspect-ratio: auto;
    margin: 0;
    border-radius: 16px;
}

.post-image {
    margin-bottom: 28px;
}

.featured-image .post-image {
    margin-bottom: 0;
}

/* Admin forms */
.admin-card {
    max-width: 760px;
}

.admin-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.admin-form label {
    margin-top: 12px;
    font-weight: 600;
}

.admin-form input[type="text"],
.admin-form input[type="password"],
.admin-form input[type="url"],
.admin-form input[type="email"],
.admin-form textarea,
.admin-form select {
    width: 100%;
    min-width: 0;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #09090e;
    color: var(--text);
    font-size: 1rem;
}

.admin-form input::placeholder,
.admin-form textarea::placeholder {
    color: #91919f;
}

.admin-form textarea {
    min-height: 280px;
    resize: vertical;
    line-height: 1.7;
}

.admin-form input[type="file"] {
    width: 100%;
    max-width: 100%;
    color: var(--muted);
}

.admin-form input[type="file"]::file-selector-button {
    margin-right: 12px;
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-strong);
    color: var(--text);
    cursor: pointer;
}

.admin-form input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.admin-form .button {
    align-self: flex-start;
    margin-top: 12px;
}

.admin-help {
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
}

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

.admin-error {
    color: #ff9999;
    font-weight: 600;
}

.admin-success {
    color: #8ce8af;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.admin-list {
    margin: 18px 0 0;
    padding: 0;
    list-style: none;
}

.admin-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    padding-block: 16px;
    border-bottom: 1px solid var(--border);
}

.admin-list li > div {
    min-width: 0;
}

.admin-status {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.85rem;
}

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.admin-actions form {
    margin: 0;
}

.admin-preview {
    display: block;
    max-width: 100%;
    max-height: 260px;
    width: auto;
    height: auto;
    margin-top: 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
}

/* Footer */
.site-footer {
    margin-top: 24px;
    padding-block: 28px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 24px;
    color: var(--muted);
    font-size: 0.86rem;
}

.footer-inner p {
    margin: 0;
}

/* Errors */
.error-card {
    max-width: 560px;
    margin: 80px auto;
    padding: 40px 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    text-align: center;
}

.error-card h1 {
    margin: 0 0 14px;
    font-size: clamp(3rem, 10vw, 5rem);
}

.error-card p {
    margin-bottom: 24px;
    color: var(--muted);
}

/* Accessibility */
.skip-link {
    position: absolute;
    top: -100px;
    left: 12px;
    z-index: 100;
    padding: 12px 18px;
    border-radius: 8px;
    background: #ffffff;
    color: #111111;
}

.skip-link:focus {
    top: 12px;
}

/* Mobile */
@media (max-width: 640px) {
    .container {
        width: calc(100% - 28px);
    }

    .header-inner {
        gap: 12px;
        padding-block: 14px;
    }

    .brand {
        font-size: 1.05rem;
    }

    .nav {
        gap: 16px;
    }

    .nav a {
        font-size: 0.85rem;
    }

    .hero {
        padding-block: 48px 36px;
    }

    .section {
        padding-block: 28px 40px;
    }

    .post {
        margin-block: 28px 40px;
        padding: 20px;
    }

    .post-content {
        font-size: 1rem;
    }

    .article-card,
    .topic-card {
        padding: 22px;
    }

    .footer-inner {
        flex-direction: column;
    }
}

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

    *,
    *::before,
    *::after {
        transition: none !important;
        animation: none !important;
    }
}

.post-content a {
    color: #4da3ff;
    text-decoration: underline;
    word-break: break-word;
}

.post-content a:hover {
    color: #7db9ff;
}

.article-card {
    overflow: hidden;
}

.article-thumb {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 14px;
    margin-bottom: 14px;
    background: #101018;
}