:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --border: #e5e7eb;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    --radius: 12px;
}

* {
    box-sizing: border-box;
}

html {
    height: 100%;
}

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

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.container {
    width: min(1100px, calc(100% - 2rem));
    margin: 0 auto;
}

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    gap: 1rem;
}

.logo {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--text);
}

.nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.nav-user {
    color: var(--muted);
    font-size: 0.95rem;
}

main.container {
    flex: 1;
    padding: 2rem 0 3rem;
}

.site-footer {
    border-top: 1px solid var(--border);
    background: var(--surface);
    padding: 1.5rem 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.hero {
    margin-bottom: 2rem;
}

.hero h1,
.form-page h1,
.auth-card h1 {
    margin: 0 0 0.5rem;
    font-size: 2rem;
}

.subtitle {
    color: var(--muted);
    margin-top: 0;
}

.post-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.post-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.post-card-image img,
.post-detail-image,
.preview-image {
    display: block;
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.post-detail-image {
    height: 360px;
    border-radius: var(--radius);
}

.preview-image {
    max-width: 320px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.post-card-body {
    padding: 1.25rem;
}

.post-card-body h2 {
    margin: 0 0 0.75rem;
    font-size: 1.15rem;
}

.post-excerpt {
    color: var(--muted);
    margin: 0 0 1rem;
}

.post-meta {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    color: var(--muted);
    font-size: 0.875rem;
}

.post-detail {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.post-detail-header {
    margin: 1.5rem 0 1rem;
}

.post-detail-body p {
    font-size: 1.05rem;
}

.post-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.comments-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.comment-list {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0 0;
}

.comment-item {
    padding: 1rem 0;
    border-top: 1px solid var(--border);
}

.comment-meta {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--muted);
}

.auth-card,
.form-page,
.empty-state {
    max-width: 560px;
    margin: 0 auto;
    background: var(--surface);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.empty-state {
    text-align: center;
}

.form,
.comment-form {
    display: grid;
    gap: 1rem;
}

.form-group {
    display: grid;
    gap: 0.4rem;
}

label {
    font-weight: 600;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"],
textarea {
    width: 100%;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    background: #fff;
}

textarea {
    resize: vertical;
}

.btn,
button.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.1rem;
    border: none;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.btn:hover,
button.btn:hover {
    background: var(--primary-dark);
    text-decoration: none;
}

.btn-secondary {
    background: #eef2ff;
    color: var(--primary-dark);
}

.btn-secondary:hover {
    background: #dbeafe;
}

.btn-danger {
    background: var(--danger);
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-small {
    padding: 0.5rem 0.85rem;
}

.btn-full {
    width: 100%;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.inline-form {
    display: inline;
}

.alert {
    padding: 0.875rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.field-error {
    color: var(--danger);
    font-size: 0.875rem;
}

.form-footer,
.comment-login-prompt,
.empty-comments {
    color: var(--muted);
}

@media (max-width: 640px) {
    .header-inner {
        flex-direction: column;
        align-items: flex-start;
        padding: 1rem 0;
    }

    .post-detail-image {
        height: 220px;
    }
}
