/* =========================================================
   简易论坛 - 全局样式
   设计：简洁清爽、卡片式布局、移动端自适应
   ========================================================= */

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-soft: #eef2ff;
    --bg: #f5f6fa;
    --card: #ffffff;
    --text: #1f2330;
    --muted: #6b7280;
    --border: #e5e7eb;
    --danger: #dc2626;
    --success: #16a34a;
    --radius: 12px;
    --shadow: 0 4px 16px rgba(17, 24, 39, .06);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
}

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

a:hover {
    text-decoration: underline;
}

.container {
    width: 100%;
    max-width: 880px;
    margin: 0 auto;
    padding: 0 16px;
}

.muted {
    color: var(--muted);
}

/* ---------------- 顶部导航 ---------------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: #fff;
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    min-height: 60px;
    padding-top: 8px;
    padding-bottom: 8px;
}

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

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

.nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    font-size: 14px;
}

.nav a {
    color: #374151;
}

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

.coin-badge {
    padding: 3px 10px;
    font-size: 13px;
    color: #92400e;
    background: #fef3c7;
    border-radius: 999px;
    white-space: nowrap;
}

.user-name {
    color: var(--muted);
}

/* ---------------- 主体 / 页脚 ---------------- */
.main {
    flex: 1;
    padding: 24px 0 48px;
}

.site-footer {
    padding: 20px 0;
    font-size: 13px;
    color: var(--muted);
    text-align: center;
    border-top: 1px solid var(--border);
}

/* ---------------- 通用按钮 ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 8px;
    transition: background .15s, color .15s, border-color .15s;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    color: #fff;
    background: var(--primary);
}

.btn-primary:hover {
    color: #fff;
    background: var(--primary-dark);
}

.btn-ghost {
    color: var(--muted);
    background: transparent;
    border-color: var(--border);
}

.btn-ghost:hover {
    color: var(--text);
    background: #f3f4f6;
}

.btn-danger {
    color: var(--danger);
    background: #fef2f2;
    border-color: #fecaca;
}

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

.btn-sm {
    padding: 5px 12px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: .6;
}

/* ---------------- 卡片 / 标题 ---------------- */
.card {
    padding: 22px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 16px;
}

.page-title {
    margin: 0;
    font-size: 22px;
}

.page-sub {
    margin: -6px 0 18px;
    font-size: 13.5px;
    color: var(--muted);
}

.section-title {
    margin: 0 0 14px;
    font-size: 17px;
}

/* ---------------- 帖子列表 ---------------- */
.post-list {
    display: grid;
    gap: 14px;
}

.post-card {
    padding: 16px 18px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: transform .15s, box-shadow .15s;
}

.post-card:hover {
    box-shadow: 0 8px 22px rgba(17, 24, 39, .08);
    transform: translateY(-2px);
}

.post-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
}

.post-card h2 {
    flex: 1;
    min-width: 200px;
    margin: 0 0 6px;
    font-size: 17px;
    line-height: 1.45;
}

.post-card h2 a {
    color: var(--text);
}

.post-card h2 a:hover {
    color: var(--primary);
    text-decoration: none;
}

.post-excerpt {
    display: -webkit-box;
    margin: 0 0 10px;
    overflow: hidden;
    font-size: 14px;
    color: var(--muted);
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

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

/* ---------------- 标签 / 收藏按钮 ---------------- */
.tag {
    display: inline-block;
    padding: 2px 8px;
    font-size: 12px;
    border-radius: 999px;
    white-space: nowrap;
}

.tag-price {
    color: #4338ca;
    background: var(--primary-soft);
}

.tag-ok {
    color: #15803d;
    background: #f0fdf4;
}

.fav-btn {
    padding: 3px 10px;
    margin-left: auto;
    font-family: inherit;
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
    background: none;
    border: 1px solid var(--border);
    border-radius: 999px;
    transition: .15s;
}

.fav-btn:hover {
    color: var(--primary);
    border-color: #c7d2fe;
}

.fav-btn.active {
    color: #c2410c;
    background: #fff7ed;
    border-color: #fdba74;
}

/* ---------------- 表单 ---------------- */
.form-card {
    max-width: 720px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 600;
}

.input,
.textarea {
    width: 100%;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.input:focus,
.textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}

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

.form-hint {
    margin: 6px 0 0;
    font-size: 12.5px;
    color: var(--muted);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 6px;
}

/* ---------------- 登录 / 注册 ---------------- */
.auth-wrap {
    max-width: 420px;
    margin: 28px auto;
}

.auth-card h1 {
    margin: 0;
    font-size: 20px;
    text-align: center;
}

.auth-sub {
    margin: 6px 0 20px;
    font-size: 13.5px;
    color: var(--muted);
    text-align: center;
}

.auth-switch {
    margin: 16px 0 0;
    font-size: 13.5px;
    color: var(--muted);
    text-align: center;
}

.auth-card .btn-block {
    margin-top: 6px;
}

/* ---------------- 帖子详情 ---------------- */
.post-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
}

.post-title-row h1 {
    flex: 1;
    min-width: 200px;
    margin: 0;
    font-size: 24px;
    line-height: 1.4;
}

.post-view .post-meta {
    margin-top: 8px;
}

.post-content {
    margin: 18px 0;
    font-size: 15px;
    line-height: 1.85;
    color: #252a38;
    word-break: break-word;
    white-space: pre-wrap;
}

.locked-box {
    padding: 20px;
    text-align: center;
    color: var(--muted);
    background: #f9fafb;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

.locked-box p {
    margin: 0 0 12px;
    font-size: 14px;
}

.post-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding-top: 16px;
    margin-top: 18px;
    border-top: 1px solid var(--border);
}

.post-actions .fav-btn {
    margin-left: 0;
}

/* ---------------- 评论区 ---------------- */
.comments-card {
    margin-top: 18px;
}

.comment-form .textarea {
    min-height: 96px;
}

.login-tip {
    padding: 12px 0 4px;
    font-size: 14px;
    color: var(--muted);
}

.comment-list {
    margin-top: 10px;
}

.comment {
    padding: 12px 0;
    border-bottom: 1px solid #f0f1f4;
}

.comment:last-child {
    border-bottom: none;
}

.comment-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 12.5px;
    color: var(--muted);
}

.comment-body {
    margin: 6px 0 0;
    font-size: 14.5px;
    word-break: break-word;
    white-space: pre-wrap;
}

.link-btn {
    padding: 0;
    font-family: inherit;
    font-size: 12.5px;
    color: var(--danger);
    cursor: pointer;
    background: none;
    border: none;
}

.link-btn:hover {
    text-decoration: underline;
}

/* ---------------- 空状态 ---------------- */
.empty {
    padding: 44px 16px;
    color: var(--muted);
    text-align: center;
    background: #fff;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

.empty p {
    margin: 8px 0;
}

/* ---------------- 提示弹窗 ---------------- */
.toast-wrap {
    position: fixed;
    top: 18px;
    left: 50%;
    z-index: 999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: min(90vw, 380px);
    pointer-events: none;
    transform: translateX(-50%);
}

.toast {
    width: 100%;
    padding: 10px 18px;
    font-size: 14px;
    color: #fff;
    text-align: center;
    word-break: break-word;
    background: #374151;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
    animation: toastIn .18s ease-out;
}

.toast-success {
    background: var(--success);
}

.toast-error {
    background: var(--danger);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------------- 移动端适配 ---------------- */
@media (max-width: 640px) {
    body {
        font-size: 14.5px;
    }

    .header-inner {
        min-height: auto;
        padding: 10px 0;
    }

    .nav {
        gap: 10px;
        font-size: 13px;
    }

    .main {
        padding: 16px 0 32px;
    }

    .post-card {
        padding: 14px;
    }

    .post-title-row h1 {
        font-size: 20px;
    }

    .page-title {
        font-size: 19px;
    }

    .card {
        padding: 16px;
    }

    .post-view .post-title-row h1 {
        font-size: 21px;
    }
}
