:root {
    --bg: #f3f7ff;
    --panel: #ffffff;
    --line: #d8e4f5;
    --text: #172033;
    --muted: #64748b;
    --brand: #2563eb;
    --brand-dark: #1d4ed8;
    --danger: #dc2626;
    --soft: #eff6ff;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.14), transparent 32%),
        linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", Arial, sans-serif;
    font-size: 15px;
}

a {
    color: inherit;
    text-decoration: none;
}

.page {
    min-height: 100vh;
}

.topbar {
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 55%, #60a5fa 100%);
    color: #fff;
    box-shadow: 0 14px 32px rgba(37, 99, 235, 0.24);
}

.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: inline-block;
    font-size: 28px;
    font-weight: 950;
    color: #fff;
    letter-spacing: -1px;
}

.subtitle {
    margin-top: 5px;
    color: rgba(255, 255, 255, 0.82);
    font-size: 13px;
}

.nav-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.logout,
.user-badge,
.admin-badge {
    padding: 9px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 800;
}

.logout {
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.28);
    color: #fff;
}

.logout:hover {
    background: #fff;
    color: var(--brand-dark);
}

.user-badge {
    background: rgba(255, 255, 255, 0.92);
    color: var(--brand-dark);
}

.admin-badge {
    background: #fef3c7;
    color: #92400e;
}

.container {
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 20px;
}

.main-full {
    display: grid;
    gap: 16px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 16px 42px rgba(37, 99, 235, 0.08);
    overflow: hidden;
}

.actionbar {
    padding: 16px;
    display: flex;
    gap: 10px;
    justify-content: space-between;
    align-items: center;
}

.actionbar-left {
    flex: 1;
}

.search-form {
    display: flex;
    gap: 8px;
}

.input,
.textarea,
.file {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 13px;
    font: inherit;
    background: #fff;
}

.textarea {
    min-height: 150px;
    resize: vertical;
    line-height: 1.6;
}

.input:focus,
.textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.btn {
    border: 0;
    border-radius: 12px;
    padding: 12px 16px;
    background: var(--brand);
    color: #fff;
    font-weight: 900;
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:hover {
    background: var(--brand-dark);
}

.btn.full {
    width: 100%;
}

.btn-sub {
    background: #334155;
}

.btn-sub:hover {
    background: #1e293b;
}

.btn-line {
    background: #fff;
    color: var(--brand-dark);
    border: 1px solid var(--line);
}

.btn-line:hover {
    background: var(--soft);
}

.board-head {
    padding: 16px 18px;
    background: #f8fbff;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.board-title {
    font-weight: 950;
}

.count {
    color: var(--muted);
    font-size: 13px;
}

.post {
    padding: 18px;
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 12px;
}

.post.compact {
    padding: 14px 18px;
}

.post:last-child {
    border-bottom: 0;
}

.post:hover {
    background: #fbfdff;
}

.post-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.post-title {
    font-size: 18px;
    font-weight: 950;
}

.meta {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.body {
    line-height: 1.75;
    white-space: normal;
}

.thumb img {
    max-width: 100%;
    width: 560px;
    height: auto;
    border-radius: 14px;
    border: 1px solid var(--line);
    display: block;
}

.thumb.small img {
    width: 260px;
}

.post-actions,
.form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
}

.inline-form {
    display: inline;
    margin: 0;
}

.mini-btn {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--brand-dark);
    border-radius: 10px;
    padding: 8px 11px;
    font-weight: 900;
    font-size: 13px;
    cursor: pointer;
}

.mini-btn:hover {
    background: var(--soft);
    border-color: var(--brand);
}

.mini-btn.danger {
    color: #fff;
    background: #ef4444;
    border-color: #ef4444;
}

.mini-btn.danger:hover {
    background: #dc2626;
}

.empty {
    padding: 42px 18px;
    text-align: center;
    color: var(--muted);
}

.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 430px;
    padding: 32px;
}

.login-logo {
    text-align: center;
    font-size: 34px;
    font-weight: 950;
    color: var(--brand);
    letter-spacing: -1px;
    margin-bottom: 8px;
}

.login-desc {
    text-align: center;
    color: var(--muted);
    margin-bottom: 24px;
}

.alert {
    padding: 12px 14px;
    border-radius: 12px;
    background: #fff1f0;
    color: var(--danger);
    border: 1px solid #fecaca;
    margin-bottom: 14px;
}

.write-page {
    max-width: 780px;
    margin: 24px auto;
    padding: 0 20px;
}

.write-card {
    padding: 24px;
}

.page-title {
    font-size: 24px;
    font-weight: 950;
    margin-bottom: 6px;
}

.page-desc {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 18px;
}

.write-form {
    display: grid;
    gap: 13px;
}

.form-row {
    display: grid;
    gap: 7px;
}

.label {
    font-weight: 900;
    font-size: 13px;
}

.help {
    font-size: 12px;
    color: var(--muted);
}

.readonly-box {
    padding: 12px 13px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f8fbff;
    font-weight: 900;
    color: var(--brand-dark);
}

.check {
    display: inline-flex;
    gap: 7px;
    align-items: center;
    color: var(--muted);
    font-size: 13px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.stat-card {
    padding: 20px;
}

.stat-num {
    font-size: 32px;
    font-weight: 950;
    color: var(--brand);
}

.stat-label {
    color: var(--muted);
    font-weight: 800;
}

.footer {
    text-align: center;
    padding: 32px 20px;
    color: var(--muted);
    font-size: 12px;
}

@media (max-width: 800px) {
    .topbar-inner,
    .actionbar,
    .post-head {
        align-items: stretch;
        flex-direction: column;
    }

    .search-form {
        flex-direction: column;
    }

    .nav-actions {
        justify-content: flex-start;
    }

    .stats {
        grid-template-columns: 1fr;
    }
}

/* Comments */
.comments {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.comments-head {
    font-size: 13px;
    font-weight: 950;
    color: var(--brand-dark);
    margin-bottom: 10px;
}

.comment-list {
    display: grid;
    gap: 10px;
    margin-bottom: 12px;
}

.comment {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #f8fbff;
}

.comment-main {
    min-width: 0;
    flex: 1;
}

.comment-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 6px;
}

.comment-meta strong {
    color: var(--brand-dark);
    font-size: 13px;
}

.comment-body {
    line-height: 1.65;
    word-break: break-word;
}

.comment-actions {
    display: flex;
    gap: 6px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.comment-form {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.comment-form textarea {
    width: 100%;
    min-height: 74px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 11px 12px;
    font: inherit;
}

.comment-form textarea:focus,
.comment-edit-textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.comment-form .btn {
    justify-self: end;
    padding: 9px 13px;
    font-size: 13px;
}

@media (max-width: 800px) {
    .comment {
        flex-direction: column;
    }

    .comment-actions {
        justify-content: flex-end;
    }
}

/* Final admin/comment polish */
.stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.admin-comment-row .post-title,
.comment-admin-title {
    max-width: 720px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.board + .board {
    margin-top: 16px;
}

.post-actions form {
    margin: 0;
}

.nav-actions .logout,
.nav-actions .user-badge,
.nav-actions .admin-badge {
    backdrop-filter: blur(8px);
}

@media (max-width: 800px) {
    .stats {
        grid-template-columns: 1fr;
    }

    .admin-comment-row .post-title,
    .comment-admin-title {
        white-space: normal;
    }
}
