:root {
    --post-background: #f4f7fb;
    --post-surface: #ffffff;
    --post-text: #182230;
    --post-muted: #667085;
    --post-border: #e4e7ec;
    --post-primary: #3157d5;
    --post-primary-dark: #2446ba;
    --post-primary-soft: #eef2ff;
    --post-danger: #b42318;
    --post-danger-dark: #912018;
    --post-danger-soft: #fef3f2;
}

* {
    box-sizing: border-box;
}

.post-page {
    margin: 0;
    min-width: 320px;
    background: var(--post-background);
    color: var(--post-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.post-page button,
.post-page input,
.post-page textarea {
    font: inherit;
}

.post-shell {
    width: min(100% - 40px, 960px);
    margin: 0 auto;
    padding: 24px 0 56px;
}

.post-site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 8px 0 24px;
    border-bottom: 1px solid var(--post-border);
}

.post-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--post-text);
    font-size: 19px;
    font-weight: 700;
    text-decoration: none;
}

.post-brand-mark {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--post-primary);
    box-shadow: 0 0 0 5px var(--post-primary-soft);
}

.post-header-actions,
.owner-controls,
.guest-action-forms {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.owner-controls form,
.guest-action-forms form {
    margin: 0;
}

.post-card,
.comment-card {
    margin-top: 32px;
    padding: 32px;
    border: 1px solid var(--post-border);
    border-radius: 16px;
    background: var(--post-surface);
    box-shadow: 0 14px 40px rgba(24, 34, 48, 0.07);
}

.post-heading {
    padding-bottom: 24px;
    border-bottom: 1px solid var(--post-border);
}

.post-kicker,
.comment-kicker {
    display: block;
    margin-bottom: 10px;
    color: var(--post-primary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.1em;
}

.post-heading h1 {
    margin: 0 0 16px;
    font-size: clamp(28px, 5vw, 38px);
    line-height: 1.25;
    letter-spacing: -0.04em;
    overflow-wrap: anywhere;
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 10px 16px;
    flex-wrap: wrap;
    color: var(--post-muted);
    font-size: 14px;
}

.post-author {
    color: var(--post-text);
    font-weight: 700;
}

.withdrawn-badge,
.comment-count {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--post-primary-soft);
    color: var(--post-primary-dark);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.article-content {
    min-height: 240px;
    padding: 32px 0;
    line-height: 1.75;
    overflow-wrap: anywhere;
}

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

.article-content pre {
    overflow-x: auto;
    white-space: pre-wrap;
}

.post-controls {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    padding-top: 20px;
    border-top: 1px solid var(--post-border);
}

.guest-controls {
    display: grid;
    justify-items: end;
    gap: 8px;
}

.compact-action-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.compact-action-form input,
.comment-delete-form input,
.comment-form input,
.comment-form textarea {
    border: 1px solid var(--post-border);
    border-radius: 9px;
    background: var(--post-surface);
    color: var(--post-text);
}

.compact-action-form input {
    width: 140px;
    min-height: 42px;
    padding: 9px 11px;
}

.primary-button,
.secondary-button,
.danger-button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: 9px;
    cursor: pointer;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
}

.primary-button {
    border-color: var(--post-primary);
    background: var(--post-primary);
    color: #ffffff;
}

.primary-button:hover {
    border-color: var(--post-primary-dark);
    background: var(--post-primary-dark);
}

.secondary-button {
    border-color: var(--post-border);
    background: var(--post-surface);
    color: var(--post-text);
}

.secondary-button:hover {
    border-color: #c8ced8;
    background: #f9fafb;
}

.danger-button {
    border-color: var(--post-danger);
    background: var(--post-danger);
    color: #ffffff;
}

.danger-button:hover {
    border-color: var(--post-danger-dark);
    background: var(--post-danger-dark);
}

.action-error,
.comment-message-error {
    margin: 0;
    padding: 10px 12px;
    border-radius: 9px;
    background: var(--post-danger-soft);
    color: var(--post-danger);
    font-size: 13px;
}

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

.comment-heading h2 {
    margin: 0;
    font-size: 24px;
}

.comment-list {
    border-top: 1px solid var(--post-border);
}

.comment-empty {
    margin: 0;
    padding: 42px 16px;
    color: var(--post-muted);
    text-align: center;
}

.comment-row {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr) auto;
    gap: 18px;
    align-items: center;
    padding: 18px 0;
    border-bottom: 1px solid var(--post-border);
}

.comment-author {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.comment-author strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.comment-content {
    margin: 0;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.comment-delete-form {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.comment-password-input {
    width: 100px;
    min-height: 36px;
    padding: 7px 9px;
}

.text-danger-button {
    border: 0;
    background: transparent;
    color: var(--post-danger);
    cursor: pointer;
    font-weight: 700;
}

.text-danger-button:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.comment-form {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr) 150px auto;
    gap: 10px;
    align-items: stretch;
    margin-top: 22px;
}

.comment-writer {
    grid-column: 1;
}

.comment-body {
    grid-column: 2;
}

.comment-password {
    grid-column: 3;
}

.comment-submit {
    grid-column: 4;
}

.comment-form input,
.comment-form textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    resize: vertical;
}

.comment-member {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--post-border);
    border-radius: 9px;
    background: #f9fafb;
    color: var(--post-muted);
    font-size: 14px;
    font-weight: 700;
}

.primary-button:focus-visible,
.secondary-button:focus-visible,
.danger-button:focus-visible,
.text-danger-button:focus-visible,
.post-brand:focus-visible,
.post-page input:focus-visible,
.post-page textarea:focus-visible {
    outline: 3px solid rgba(49, 87, 213, 0.25);
    outline-offset: 2px;
}

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

@media (max-width: 820px) {
    .post-controls {
        align-items: stretch;
        flex-direction: column;
    }

    .guest-controls {
        justify-items: stretch;
    }

    .guest-action-forms {
        align-items: stretch;
        flex-direction: column;
    }

    .compact-action-form input {
        flex: 1;
        width: auto;
    }

    .comment-row {
        grid-template-columns: 120px minmax(0, 1fr);
    }

    .comment-delete-form {
        grid-column: 1 / -1;
    }

    .comment-form {
        grid-template-columns: 130px minmax(0, 1fr);
    }

    .comment-writer,
    .comment-body,
    .comment-password,
    .comment-submit {
        grid-column: auto;
    }

    .comment-password {
        grid-column: 1;
    }

    .comment-submit {
        grid-column: 2;
    }
}

@media (max-width: 600px) {
    .post-shell {
        width: min(100% - 24px, 960px);
        padding-top: 14px;
    }

    .post-site-header,
    .post-controls {
        align-items: stretch;
        flex-direction: column;
    }

    .post-header-actions,
    .owner-controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .post-header-actions .primary-button,
    .post-header-actions .secondary-button,
    .owner-controls .secondary-button,
    .owner-controls .danger-button {
        width: 100%;
    }

    .post-card,
    .comment-card {
        margin-top: 22px;
        padding: 22px 16px;
        border-radius: 12px;
    }

    .article-content {
        min-height: 180px;
        padding: 24px 0;
    }

    .compact-action-form {
        align-items: stretch;
        flex-direction: column;
    }

    .compact-action-form input,
    .compact-action-form .secondary-button,
    .compact-action-form .danger-button {
        width: 100%;
    }

    .comment-row,
    .comment-form {
        grid-template-columns: 1fr;
    }

    .comment-author,
    .comment-content,
    .comment-delete-form,
    .comment-writer,
    .comment-body,
    .comment-password,
    .comment-submit {
        grid-column: 1;
    }

    .comment-delete-form {
        align-items: stretch;
        flex-direction: column;
    }

    .comment-password-input,
    .comment-submit {
        width: 100%;
    }
}
