* {
    box-sizing: border-box;
}

:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --success-bg: #dcfce7;
    --success-text: #166534;
    --error-bg: #fee2e2;
    --error-text: #991b1b;
    --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
    --radius: 18px;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: linear-gradient(180deg, #eef4ff 0%, var(--bg) 220px);
    color: var(--text);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: 0.2s ease;
}

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

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

.site-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.site-footer {
    background: #0f172a;
    color: #cbd5e1;
    margin-top: 2rem;
}

.site-header a,
.site-footer a {
    color: inherit;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
}

.brand {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    color: #ffffff !important;
}

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

.nav a {
    color: #e5e7eb;
    padding: 0.55rem 0.8rem;
    border-radius: 10px;
}

.nav a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.user-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    padding: 0.55rem 0.85rem;
    border-radius: 999px;
}

.badge,
.badge-danger {
    display: inline-block;
    padding: 0.18rem 0.5rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: bold;
}

.badge {
    background: #2563eb;
    color: #fff;
}

.badge-danger {
    background: #dc2626;
    color: #fff;
}

main.container {
    padding: 1.6rem 0 2rem;
}

.card {
    background: var(--surface);
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: var(--radius);
    padding: 1.35rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.card h1,
.card h2,
.card h3 {
    margin-top: 0;
}

.narrow {
    max-width: 620px;
    margin-inline: auto;
}

.form {
    display: grid;
    gap: 1rem;
}

.form label {
    display: grid;
    gap: 0.45rem;
    font-weight: 700;
    color: var(--text);
}

input[type="text"],
input[type="password"],
input[type="file"],
textarea {
    width: 100%;
    padding: 0.85rem 0.95rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    font: inherit;
    background: #fff;
    color: var(--text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="file"]:focus,
textarea:focus {
    outline: none;
    border-color: #93c5fd;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

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

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    border: none;
    border-radius: 12px;
    padding: 0.8rem 1.05rem;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 10px 20px rgba(37, 99, 235, 0.18);
}

.button:hover {
    background: var(--primary-hover);
    color: #fff;
    transform: translateY(-1px);
}

.button.small {
    padding: 0.55rem 0.8rem;
    font-size: 0.92rem;
    box-shadow: none;
}

.button.danger {
    background: var(--danger);
    box-shadow: 0 10px 20px rgba(220, 38, 38, 0.16);
}

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

.link-danger {
    color: var(--danger);
    background: transparent;
    border: none;
    padding: 0;
    margin-top: 0.7rem;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.alert {
    padding: 1rem 1.1rem;
    border-radius: 14px;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    box-shadow: var(--shadow);
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: #86efac;
}

.alert-error {
    background: var(--error-bg);
    color: var(--error-text);
    border-color: #fca5a5;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.topic-list {
    display: grid;
    gap: 0.9rem;
}

.topic-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1rem 1.1rem;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.topic-row:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
    border-color: #bfdbfe;
}

.topic-row h3 {
    margin: 0 0 0.35rem 0;
    font-size: 1.08rem;
}

.topic-meta {
    min-width: 230px;
    display: grid;
    gap: 0.35rem;
    text-align: right;
    color: var(--muted);
    font-size: 0.94rem;
}

.posts {
    display: grid;
    gap: 1rem;
}

.post {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1rem 1.1rem;
    background: var(--surface-soft);
}

.post-system {
    border-left: 6px solid var(--danger);
    background: #fff7f7;
}

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

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

.attachment {
    margin-top: 0.9rem;
    padding-top: 0.8rem;
    border-top: 1px dashed #cbd5e1;
}

.muted {
    color: var(--muted);
    line-height: 1.6;
}

.table-wrap {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.table th,
.table td {
    border-bottom: 1px solid var(--border);
    padding: 0.9rem 0.8rem;
    vertical-align: top;
    text-align: left;
}

.table th {
    background: #f8fafc;
}

.admin-actions {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.site-footer {
    padding: 1.2rem 0;
}

.hero-box {
    background: linear-gradient(135deg, #eff6ff 0%, #ffffff 60%);
    border: 1px solid #dbeafe;
}

.hero-box h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.hero-box p {
    max-width: 800px;
    margin: 0;
}

@media (max-width: 760px) {
    .topbar,
    .topic-row,
    .post-meta {
        flex-direction: column;
        align-items: stretch;
    }

    .topic-meta {
        text-align: left;
        min-width: auto;
    }

    .nav {
        width: 100%;
    }
}