:root {
    --bg: #0b0f19;
    --bg-soft: #111827;
    --panel: #161f2f;
    --panel-light: #1f2937;
    --border: #334155;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --accent: #4169e1;
    --accent-hover: #5b7ff0;
    --danger: #ef4444;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

main {
    flex: 1;
    width: min(1000px, 92%);
    margin: 2rem auto;
}

body > header {
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

footer {
    background: var(--bg-soft);
    border-top: 1px solid var(--border);
    color: var(--muted);
    padding: 1rem 2rem;
    display: flex;
    justify-content: center;
}

body > header nav {
    display: flex;
    gap: 1rem;
    align-items: center;
}

a,
a:visited {
    color: var(--accent-hover);
    text-decoration: none;
    font-weight: 700;
}

a:hover {
    color: #8ea2ff;
    text-decoration: underline;
}

h1,
h2,
h3 {
    color: #ffffff;
}

p {
    color: var(--text);
}

small {
    color: var(--muted);
}

article,
.category-card,
.thread-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    margin: 1rem 0;
}

.form-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    width: 100%;
    max-width: 500px;
}

form div {
    margin-bottom: 1rem;
}

label {
    display: block;
    color: var(--muted);
    margin-bottom: 0.25rem;
}

button,
.button {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.6rem 1rem;
    cursor: pointer;
    font-weight: 700;
}

button.post-moderation-button,
button.thread-moderation-button {
    background: transparent;
    color: var(--accent-hover);
    border: 0;
    border-radius: 0;
    padding: 0;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

button.post-moderation-button:hover,
button.thread-moderation-button:hover {
    background: transparent;
    color: #8ea2ff;
    text-decoration: underline;
}

button:hover,
.button:hover {
    background: var(--accent-hover);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 3px solid #a5b4fc;
    outline-offset: 3px;
}

input,
textarea {
    width: 100%;
    background: #0f172a;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.65rem;
}

textarea {
    min-height: 160px;
    resize: vertical;
}

.post-card {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 1rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.post-user {
    border-right: 1px solid var(--border);
    padding-right: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.post-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.post-permalink {
    color: var(--muted);
}

.post-user h3 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    width: 100%;
}

.avatar-placeholder {
    width: 64px;
    height: 64px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--bg-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0.75rem 0;
}

.user-interests {
    color: var(--muted);
    font-size: 0.9rem;
}


.thread-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin: 1rem 0;
    background: var(--panel);
    border: 1px solid var(--border);
    border-left: 4px solid var(--danger);
    border-radius: 10px;
    padding: 1rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.moderator-tools-label {
    color: var(--text);
}

.post-content {
    min-width: 0;
}

.post-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    padding: 0.35rem 0 0.75rem;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
}

.post-moderation-form,
.thread-moderation-form {
    display: inline;
    width: auto;
    max-width: none;
    background: transparent;
    border: 0;
    padding: 0;
    margin: 0;
}

.post-moderation-button,
.thread-moderation-button,
button.post-moderation-button,
button.thread-moderation-button,
a.post-moderation-button,
a.thread-moderation-button,
a.post-moderation-button:visited,
a.thread-moderation-button:visited {
    appearance: none;
    background: none;
    border: none;
    border-radius: 0;
    color: var(--accent-hover);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    padding: 0;
    text-decoration: none;
}

.post-moderation-button:hover,
.thread-moderation-button:hover,
button.post-moderation-button:hover,
button.thread-moderation-button:hover,
a.post-moderation-button:hover,
a.thread-moderation-button:hover {
    background: none;
    color: #8ea2ff;
    text-decoration: underline;
}

.reply-context {
    color: var(--muted);
    font-size: 0.9rem;
}

.reply-backlinks {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.reply-backlinks ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.post-body {
    background: none;
    border: none;
    border-radius: 0;
    padding: 1rem 0;
    margin: 0;
    word-wrap: break-word;
}

.post-meta,
.thread-meta,
.category-meta,
.breadcrumbs {
    color: var(--muted);
    font-size: 0.9rem;
}

.post-meta {
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
    margin-bottom: 0;
}

.quoted-post {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.quoted-post-header {
    color: var(--muted);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.quoted-post-body {
    color: var(--text);
    font-size: 0.95rem;
    word-wrap: break-word;
}

.quote-preview {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
}

.inline-quote {
    background: var(--bg-soft);
    border-left: 4px solid var(--accent);
    border-radius: 0 8px 8px 0;
    color: var(--muted);
    margin: 0.75rem 0;
    padding: 0.75rem 1rem;
}

.manual-quote {
    color: #b8c2e0;
}

.inline-quote-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.mention {
    font-weight: 700;
}

.invalid-post-mention {
    color: var(--muted);
    font-weight: 700;
}

.reply-box {
    width: 100%;
    margin-top: 2rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 10px;
    padding: 1rem;
}

.reply-box[hidden],
.create-post-button[hidden] {
    display: none;
}

.create-post-button {
    margin-top: 2rem;
}

.reply-box-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.reply-box h3 {
    margin: 0 0 1rem 0;
}

.replying-to-label {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    background: var(--bg-soft);
    border-radius: 8px;
    padding: 0.65rem 0.75rem;
}

.replying-to-label[hidden] {
    display: none;
}

#reply-targets {
    width: 100%;
}

.reply-target {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.reply-target + .reply-target {
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
    padding-top: 0.5rem;
}

.composer-help {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    color: var(--muted);
    font-size: 0.8rem;
    margin-top: 0.35rem;
}

.reply-box textarea {
    min-height: 120px;
}

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
}

.edit-post-form {
    max-width: none;
    margin: 0 0 1rem 0;
}

.edit-post-form textarea {
    min-height: 180px;
}

.edit-post-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-top: 0.75rem;
}

.error {
    color: #fecaca;
    background: #7f1d1d;
    border: 1px solid var(--danger);
    padding: 0.75rem;
    border-radius: 8px;
}

img,
video,
iframe {
    max-width: 100%;
}

@media (max-width: 700px) {
    html {
        font-size: 112.5%;
    }

    body {
        line-height: 1.65;
    }

    main,
    body > header,
    footer {
        width: 100%;
        max-width: none;
    }

    main {
        margin: 0;
        padding: 0.75rem;
    }

    body > header,
    footer {
        padding: 1rem 0.75rem;
    }

    body > header {
        align-items: stretch;
        flex-direction: column;
        gap: 0.75rem;
    }

    body > header h1 {
        margin: 0;
    }

    body > header nav {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.6rem;
        width: 100%;
    }

    body > header nav a,
    body > header nav a:visited {
        display: block;
        background: var(--accent);
        color: #ffffff;
        padding: 0.85rem;
        border-radius: 8px;
        text-align: center;
        text-decoration: none;
        font-weight: 800;
    }

    .post-card {
        display: block;
        width: 100%;
        padding: 0.9rem;
        margin: 0.9rem 0;
    }

    .post-user {
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 0 0 0.75rem 0;
        margin-bottom: 0.75rem;
        align-items: flex-start;
        text-align: left;
    }

    .avatar-placeholder,
    .user-interests {
        display: none;
    }

    .post-actions {
        display: flex;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 0.5rem 1rem;
    }

    .post-moderation-button,
    button.post-moderation-button,
    a.post-moderation-button,
    a.post-moderation-button:visited {
        display: inline-block;
        width: auto;
        background: transparent;
        color: var(--accent-hover);
        border: 0;
        border-radius: 0;
        padding: 0.45rem 0;
        text-decoration: none;
        font-weight: 800;
    }

    .post-moderation-button:hover,
    button.post-moderation-button:hover,
    a.post-moderation-button:hover {
        background: transparent;
        color: #8ea2ff;
        text-decoration: underline;
    }

    .post-body,
    .quoted-post-body {
        font-size: 1.05rem;
        line-height: 1.7;
        overflow-wrap: anywhere;
    }

    .post-meta {
        font-size: 0.95rem;
        line-height: 1.5;
    }

    .reply-box { border-radius: 10px; }

    .post-header { justify-content: flex-start; }

    .composer-help { align-items: flex-end; }

    textarea,
    input {
        font-size: 1rem;
    }
}
