:root {
    --bg: #f2f4f6;
    --card: #ffffff;
    --text: #191f28;
    --sub: #6b7684;
    --faint: #8b95a1;
    --line: #e5e8eb;
    --brand: #3182f6;
    --brand-press: #1b64da;
    --brand-weak: #e8f3ff;
    --danger: #f04452;
    --danger-weak: #ffeeee;
    --header-bg: rgba(255, 255, 255, .82);
    --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .04);
    --av-bg: 92%;
    --av-fg: 34%;
    --radius: 20px;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0e0f12;
        --card: #1a1b20;
        --text: #f2f4f6;
        --sub: #a3acb9;
        --faint: #7d8794;
        --line: #2a2c33;
        --brand: #4593fc;
        --brand-press: #6aa8ff;
        --brand-weak: #162538;
        --danger: #ff6b76;
        --danger-weak: #3a1b1f;
        --header-bg: rgba(14, 15, 18, .82);
        --shadow: 0 1px 2px rgba(0, 0, 0, .3);
        --av-bg: 22%;
        --av-fg: 78%;
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
                 "Noto Sans KR", "Malgun Gothic", sans-serif;
    line-height: 1.5;
    letter-spacing: -0.01em;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ---------- 헤더 ---------- */
.site-header {
    position: sticky; top: 0; z-index: 20;
    background: var(--header-bg);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--line);
}
.nav {
    max-width: 720px; margin: 0 auto; height: 60px; padding: 0 20px;
    display: flex; align-items: center; justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 19px; letter-spacing: -0.03em; }
.logo-dot {
    width: 22px; height: 22px; border-radius: 7px;
    background: linear-gradient(135deg, #3182f6, #6aa8ff);
    box-shadow: 0 2px 8px rgba(49, 130, 246, .35);
}
.nav-right { display: flex; align-items: center; gap: 6px; }
.me { color: var(--faint); font-size: 13px; margin-right: 6px; }

/* ---------- 버튼 ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 40px; padding: 0 16px; border: 0; border-radius: 12px;
    font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
    background: var(--brand-weak); color: var(--brand);
    transition: transform .08s ease, background .15s ease, opacity .15s;
}
.btn:hover { background: color-mix(in srgb, var(--brand) 16%, transparent); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-press); }
.btn-ghost { background: transparent; color: var(--sub); }
.btn-ghost:hover { background: var(--line); }
.btn-danger { background: var(--danger-weak); color: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 18%, transparent); }
.btn-lg { height: 52px; font-size: 16px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
form.inline { display: inline; margin: 0; }

/* ---------- 레이아웃 ---------- */
main { width: 100%; max-width: 720px; margin: 0 auto; padding: 24px 20px 80px; flex: 1; }
.site-footer { text-align: center; color: var(--faint); font-size: 13px; padding: 28px 20px 40px; }

.card {
    background: var(--card); border-radius: var(--radius);
    padding: 24px; margin-bottom: 14px; box-shadow: var(--shadow);
}

.flash {
    background: var(--brand-weak); color: var(--brand);
    padding: 14px 18px; border-radius: 14px; margin-bottom: 12px;
    font-size: 14px; font-weight: 600;
    animation: pop .25s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- 홈 ---------- */
.hero { padding: 8px 4px 22px; }
.hero h1 { margin: 0 0 6px; font-size: 28px; font-weight: 800; letter-spacing: -0.04em; line-height: 1.3; }
.hero p { margin: 0 0 18px; color: var(--sub); }
.search { position: relative; }
.search input {
    width: 100%; height: 50px; padding: 0 90px 0 18px;
    border: 0; border-radius: 14px; background: var(--card);
    box-shadow: var(--shadow); color: var(--text); font: inherit; font-size: 15px;
}
.search input:focus { outline: 2px solid var(--brand); }
.search .btn { position: absolute; right: 7px; top: 7px; height: 36px; }

.list-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px 10px; }
.list-head h2 { margin: 0; font-size: 17px; }
.list-head span { color: var(--faint); font-size: 13px; }

.post-card {
    display: flex; gap: 16px; align-items: stretch; justify-content: space-between;
    background: var(--card); border-radius: var(--radius); padding: 20px;
    margin-bottom: 10px; box-shadow: var(--shadow);
    transition: transform .15s ease;
}
.post-card:hover { transform: translateY(-2px); }
.post-main { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.post-title {
    margin: 0 0 6px; font-size: 17px; font-weight: 700; line-height: 1.4;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.post-preview {
    margin: 0 0 14px; color: var(--sub); font-size: 14px; line-height: 1.55;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.post-meta { margin-top: auto; display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: 12.5px; flex-wrap: wrap; }
.post-meta .dot { opacity: .5; }
.stat { display: inline-flex; align-items: center; gap: 3px; }
.thumb {
    position: relative; flex: none; width: 96px; height: 96px;
    border-radius: 14px; overflow: hidden; background: var(--line);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-count {
    position: absolute; right: 6px; bottom: 6px; padding: 1px 7px;
    background: rgba(0, 0, 0, .55); color: #fff; font-size: 11px; font-weight: 700; border-radius: 8px;
}

.avatar {
    width: 22px; height: 22px; border-radius: 50%; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 800;
    background: hsl(var(--h) 75% var(--av-bg)); color: hsl(var(--h) 55% var(--av-fg));
}
.avatar-lg { width: 40px; height: 40px; font-size: 15px; }

.pager { display: flex; justify-content: center; align-items: center; gap: 14px; padding: 18px 0; color: var(--sub); font-size: 14px; }
.empty { text-align: center; color: var(--faint); padding: 56px 20px; }
.empty .emoji { font-size: 40px; display: block; margin-bottom: 10px; }

/* ---------- 글 상세 ---------- */
.post-head h1 { margin: 0 0 16px; font-size: 25px; font-weight: 800; line-height: 1.4; letter-spacing: -0.03em; word-break: break-word; }
.author { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.author b { display: block; font-size: 15px; }
.author span { color: var(--faint); font-size: 13px; }
.body { white-space: pre-wrap; word-break: break-word; font-size: 16px; line-height: 1.8; }

.gallery { display: grid; gap: 8px; margin: 22px 0 6px; }
.gallery.n1 { grid-template-columns: 1fr; }
.gallery.n2, .gallery.n4 { grid-template-columns: 1fr 1fr; }
.gallery.n3 { grid-template-columns: 1fr 1fr; }
.gallery.n3 button:first-child { grid-column: 1 / -1; }
.gallery button {
    padding: 0; border: 0; border-radius: 14px; overflow: hidden; cursor: zoom-in;
    background: var(--line); aspect-ratio: 4 / 3;
}
.gallery.n1 button { aspect-ratio: auto; max-height: 560px; }
.gallery img { width: 100%; height: 100%; object-fit: cover; }
.gallery.n1 img { object-fit: contain; }

.actions { display: flex; gap: 8px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }

.comments h2 { margin: 0 0 6px; font-size: 17px; }
.comment { display: flex; gap: 12px; padding: 14px 0; }
.comment + .comment { border-top: 1px solid var(--line); }
.comment-body { min-width: 0; flex: 1; }
.comment-top { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--faint); }
.comment-top b { color: var(--text); font-size: 14px; }
.comment-top .del { margin-left: auto; }
.comment p { margin: 4px 0 0; white-space: pre-wrap; word-break: break-word; line-height: 1.6; }
.comment-form { display: flex; gap: 8px; margin-top: 12px; align-items: flex-end; }
.comment-form textarea { flex: 1; min-height: 46px; }

/* ---------- 폼 ---------- */
.form-card { max-width: 440px; margin: 28px auto; }
.form-card h1 { margin: 0 0 6px; font-size: 26px; font-weight: 800; letter-spacing: -0.04em; }
.form-card .sub { margin: 0 0 22px; color: var(--sub); }
.field { margin-bottom: 14px; }
.field label { display: block; margin: 0 0 7px 2px; font-size: 13px; font-weight: 600; color: var(--sub); }
input[type=text], input[type=email], input[type=password], textarea {
    width: 100%; padding: 14px 16px; border: 2px solid transparent; border-radius: 14px;
    background: var(--bg); color: var(--text); font: inherit; font-size: 16px;
    transition: border-color .15s, background .15s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, textarea:focus { outline: 0; border-color: var(--brand); background: var(--card); }
textarea { resize: vertical; line-height: 1.6; }
.code-input { text-align: center; font-size: 28px !important; letter-spacing: .5em; font-weight: 700; padding-left: calc(16px + .5em) !important; }
.stack { display: grid; gap: 10px; margin-top: 8px; }
.form-foot { text-align: center; margin-top: 18px; color: var(--sub); font-size: 14px; }
.form-foot a { color: var(--brand); font-weight: 600; }

.write-card { max-width: none; margin-top: 0; }

/* 사진 업로드 */
.dropzone {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    padding: 22px; border: 2px dashed var(--line); border-radius: 16px;
    color: var(--sub); cursor: pointer; text-align: center; font-size: 14px;
    transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-weak); color: var(--brand); }
.dropzone .icon { font-size: 26px; }
.dropzone small { color: var(--faint); }
.dropzone input { display: none; }
.previews { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.previews:empty { display: none; }
.pv { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--line); }
.pv img { width: 100%; height: 100%; object-fit: cover; }
.pv.removed img { opacity: .25; filter: grayscale(1); }
.pv label {
    position: absolute; inset: auto 6px 6px 6px; display: flex; align-items: center; justify-content: center; gap: 4px;
    padding: 3px 0; background: rgba(0, 0, 0, .6); color: #fff;
    font-size: 11px; font-weight: 600; border-radius: 8px; cursor: pointer; margin: 0;
}
.pv input { display: none; }
.pv .tag { position: absolute; left: 6px; top: 6px; background: var(--brand); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 6px; }
.form-actions { display: flex; gap: 8px; margin-top: 20px; }
.form-actions .btn-primary { flex: 1; }

/* ---------- 라이트박스 ---------- */
dialog#lightbox {
    border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100vh;
    width: 100vw; height: 100vh;
}
dialog#lightbox::backdrop { background: rgba(0, 0, 0, .88); }
.lb-inner { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; }
.lb-inner img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.lb-close {
    position: fixed; top: 16px; right: 16px; width: 40px; height: 40px; border-radius: 50%; border: 0;
    background: rgba(255, 255, 255, .16); color: #fff; font-size: 20px; cursor: pointer;
}

@media (max-width: 520px) {
    main { padding: 16px 14px 80px; }
    .hero h1 { font-size: 24px; }
    .card { padding: 20px; border-radius: 18px; }
    .post-card { padding: 16px; }
    .thumb { width: 80px; height: 80px; }
    .me { display: none; }
    .previews { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- 관리자 / 정지 ---------- */
.flash-ban { background: var(--danger-weak); color: var(--danger); }
.admin-tag { display: inline-block; margin-top: 2px; font-size: 12px; color: var(--brand); font-weight: 600; }
.admin-tag:hover { text-decoration: underline; }
.comment-top .admin-tag { margin: 0; }

.user-card { padding: 18px 20px; }
.user-top { display: flex; align-items: center; gap: 12px; }
.user-info { min-width: 0; flex: 1; }
.user-info b { display: block; font-size: 15px; word-break: break-all; }
.user-info span { color: var(--faint); font-size: 12.5px; }
.pill { flex: none; padding: 4px 10px; border-radius: 999px; background: var(--line); color: var(--sub); font-size: 12px; font-weight: 700; }
.pill-ban { background: var(--danger-weak); color: var(--danger); }
.pill-admin { background: var(--brand-weak); color: var(--brand); }
.ban-reason { margin: 10px 0 0; color: var(--sub); font-size: 13px; }
.ban-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.ban-form select, .ban-form input {
    height: 40px; padding: 0 12px; border: 2px solid transparent; border-radius: 12px;
    background: var(--bg); color: var(--text); font: inherit; font-size: 14px;
}
.ban-form select:focus, .ban-form input:focus { outline: 0; border-color: var(--brand); }
.ban-form input[type=number] { width: 84px; }
.ban-form input[type=text] { flex: 1; min-width: 140px; }
.ban-form .btn { height: 40px; }
.unban-form { margin-top: 8px; }