/* ============================================================
   留言本 - 前台样式
   现代清爽风格，支持深色模式
   ============================================================ */

:root {
    --primary: #6366f1;
    --primary-2: #8b5cf6;
    --primary-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --accent: #f59e0b;
    --bg: #f1f3f9;
    --card-bg: #ffffff;
    --text: #1f2430;
    --text-sub: #6b7280;
    --border: #e5e7f0;
    --shadow: 0 10px 30px rgba(80, 90, 180, 0.10);
    --shadow-hover: 0 16px 40px rgba(80, 90, 180, 0.16);
    --radius: 16px;
    --hero-grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 45%, #a855f7 100%);
}

html.dark {
    --bg: #0f1220;
    --card-bg: #1a1f35;
    --text: #e8eaf6;
    --text-sub: #9aa0b4;
    --border: #2a3050;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --shadow-hover: 0 16px 40px rgba(0, 0, 0, 0.5);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    min-height: 100vh;
    transition: background .3s ease, color .3s ease;
}

/* 背景装饰 */
.bg-decor {
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(600px 300px at 10% -10%, rgba(99, 102, 241, .12), transparent 60%),
        radial-gradient(700px 350px at 95% 10%, rgba(168, 85, 247, .12), transparent 60%);
    pointer-events: none;
}

/* ============ Hero 头部 ============ */
.hero {
    background: var(--hero-grad);
    color: #fff;
    padding: 56px 20px 120px;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.hero::before {
    content: "";
    position: absolute;
    width: 480px; height: 480px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .08);
    top: -240px; right: -120px;
}
.hero::after {
    content: "";
    position: absolute;
    width: 360px; height: 360px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .06);
    bottom: -200px; left: -100px;
}
.hero-inner { position: relative; z-index: 1; max-width: 760px; margin: 0 auto; }
.hero-icon {
    font-size: 44px;
    width: 92px; height: 92px;
    line-height: 92px;
    margin: 0 auto 18px;
    background: rgba(255, 255, 255, .16);
    border: 1px solid rgba(255, 255, 255, .3);
    border-radius: 26px;
    backdrop-filter: blur(8px);
    animation: float 3.2s ease-in-out infinite;
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}
.hero-title { font-size: 40px; font-weight: 800; letter-spacing: 2px; }
.hero-subtitle { margin-top: 10px; font-size: 16px; opacity: .92; }
.hero-stats {
    margin-top: 24px;
    display: flex;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
}
.stat {
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .25);
    padding: 10px 22px;
    border-radius: 999px;
    font-size: 14px;
    backdrop-filter: blur(6px);
}
.stat b { font-size: 18px; margin-right: 4px; }
.hero-actions {
    position: absolute;
    top: 20px; right: 24px;
    display: flex; gap: 10px;
    z-index: 2;
}
.btn-link {
    background: rgba(255, 255, 255, .16);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .3);
    border-radius: 999px;
    padding: 8px 18px;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    transition: all .25s ease;
}
.btn-link:hover { background: rgba(255, 255, 255, .3); transform: translateY(-2px); }

/* ============ 容器 ============ */
.container {
    max-width: 780px;
    margin: -70px auto 40px;
    padding: 0 18px;
    position: relative;
    z-index: 2;
}

/* 公告 */
.motd {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    padding: 14px 20px;
    margin-bottom: 18px;
    display: flex;
    gap: 14px;
    align-items: flex-start;
    box-shadow: var(--shadow);
}
.motd-badge {
    flex-shrink: 0;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    padding: 3px 12px;
    border-radius: 999px;
    margin-top: 3px;
}

/* 提示 */
.flash {
    padding: 14px 20px;
    border-radius: var(--radius);
    margin-bottom: 18px;
    font-size: 14px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    box-shadow: var(--shadow);
}
.flash-ok { border-left: 4px solid #22c55e; }
.flash-err { border-left: 4px solid #ef4444; }
.flash-warn { border-left: 4px solid var(--accent); }

/* ============ 卡片通用 ============ */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: box-shadow .3s ease, transform .3s ease;
}
.card:hover { box-shadow: var(--shadow-hover); }

/* ============ 发布表单 ============ */
.composer { padding: 24px; margin-bottom: 28px; }
.card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}
.card-head h2 { font-size: 19px; }
.hint { font-size: 12px; color: var(--text-sub); background: rgba(99, 102, 241, .1); color: var(--primary); padding: 4px 12px; border-radius: 999px; }
.composer-fields { display: flex; gap: 12px; margin-bottom: 12px; }
.composer-fields input {
    flex: 1;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border .25s ease, box-shadow .25s ease;
}
.composer-fields input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .18);
}
.composer textarea {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: border .25s ease, box-shadow .25s ease;
}
.composer textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .18);
}
.composer-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 14px;
    gap: 12px;
    flex-wrap: wrap;
}
.captcha-box { display: flex; align-items: center; gap: 10px; }
.captcha-box input {
    width: 96px;
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    text-align: center;
    letter-spacing: 2px;
    font-size: 14px;
    outline: none;
}
.captcha-box input:focus { border-color: var(--primary); }
.captcha-box img {
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    border: 1px solid var(--border);
}

/* 按钮 */
.btn {
    display: inline-block;
    padding: 10px 22px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all .25s ease;
}
.btn-primary {
    background: var(--primary-grad);
    color: #fff;
    box-shadow: 0 6px 18px rgba(99, 102, 241, .35);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(99, 102, 241, .45); }
.btn-primary:disabled { opacity: .6; transform: none; cursor: not-allowed; }
.btn-ghost {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text);
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: 10px; }

/* ============ 列表头部 ============ */
.list-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}
.list-head h2 { font-size: 18px; }
.list-head h2 small { font-size: 13px; color: var(--text-sub); margin-left: 6px; font-weight: 400; }
.search-form { display: flex; gap: 8px; }
.search-form input {
    padding: 9px 16px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: var(--card-bg);
    color: var(--text);
    font-size: 13px;
    width: 200px;
    outline: none;
    transition: border .25s ease;
}
.search-form input:focus { border-color: var(--primary); }

/* ============ 留言卡片 ============ */
.messages { display: flex; flex-direction: column; gap: 18px; }
.message { padding: 22px 24px; position: relative; }
.message.is-top {
    border: 1px solid rgba(245, 158, 11, .5);
    box-shadow: 0 10px 30px rgba(245, 158, 11, .12);
}
.top-badge {
    position: absolute;
    top: -11px; left: 22px;
    background: linear-gradient(135deg, #f59e0b, #f97316);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 14px;
    border-radius: 999px;
    box-shadow: 0 4px 12px rgba(245, 158, 11, .4);
}
.msg-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.avatar {
    width: 46px; height: 46px;
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, .12);
}
.msg-meta { display: flex; flex-direction: column; }
.msg-name { font-size: 15px; }
.msg-time { font-size: 12px; color: var(--text-sub); }
.msg-content {
    font-size: 15px;
    word-break: break-word;
    white-space: pre-line;
    padding: 4px 0 12px;
}
.msg-actions { display: flex; gap: 10px; border-top: 1px dashed var(--border); padding-top: 14px; }
.act-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-sub);
    font-size: 13px;
    border-radius: 999px;
    cursor: pointer;
    transition: all .25s ease;
}
.act-btn:hover { border-color: var(--primary); color: var(--primary); background: rgba(99, 102, 241, .06); }
.act-btn.active { border-color: var(--primary); color: var(--primary); background: rgba(99, 102, 241, .1); }
.like-btn.liked { border-color: #ef4444; color: #ef4444; background: rgba(239, 68, 68, .08); }

/* ============ 回复 ============ */
.replies {
    margin-top: 16px;
    background: var(--bg);
    border-radius: 12px;
    padding: 6px 16px;
}
.reply-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--border); }
.reply-item:last-child { border-bottom: none; }
.reply-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}
.reply-body { flex: 1; min-width: 0; }
.reply-meta { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.reply-meta strong { font-size: 13px; color: var(--primary); }
.reply-meta span { color: var(--text-sub); }
.reply-content { font-size: 14px; white-space: pre-line; word-break: break-word; margin-top: 2px; }

/* 回复表单 */
.reply-form { margin-top: 14px; }
.reply-fields { display: flex; gap: 10px; margin-bottom: 10px; }
.reply-fields input {
    flex: 1;
    padding: 9px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    outline: none;
}
.reply-fields input:focus { border-color: var(--primary); }
.reply-form textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
    outline: none;
}
.reply-form textarea:focus { border-color: var(--primary); }
.reply-foot { text-align: right; margin-top: 10px; }

/* ============ 空状态 ============ */
.empty {
    text-align: center;
    padding: 60px 20px;
    background: var(--card-bg);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text-sub);
}
.empty-icon { font-size: 52px; margin-bottom: 10px; }

/* ============ 分页 ============ */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin: 28px 0 10px;
    flex-wrap: wrap;
}
.pagination a, .pagination .current, .pagination .page-info {
    padding: 7px 14px;
    border-radius: 10px;
    font-size: 13px;
    text-decoration: none;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    transition: all .2s ease;
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .current { background: var(--primary-grad); color: #fff; border-color: transparent; font-weight: 600; }
.pagination .page-info { border: none; background: transparent; color: var(--text-sub); }

/* ============ 页脚 ============ */
.footer {
    text-align: center;
    padding: 30px 20px 40px;
    color: var(--text-sub);
    font-size: 13px;
}
.footer a { color: var(--text-sub); }
.footer-sub { margin-top: 6px; opacity: .85; }

/* ============ Toast ============ */
.toast {
    position: fixed;
    top: 24px; left: 50%;
    transform: translate(-50%, -30px);
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 12px 26px;
    border-radius: 12px;
    font-size: 14px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, .18);
    z-index: 999;
    opacity: 0;
    transition: all .3s ease;
    max-width: 90vw;
    text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-ok { border-left: 4px solid #22c55e; }
.toast-err { border-left: 4px solid #ef4444; }

/* ============ 响应式 ============ */
@media (max-width: 640px) {
    .hero { padding: 40px 16px 100px; }
    .hero-title { font-size: 30px; }
    .hero-actions { position: static; justify-content: center; margin-top: 16px; }
    .composer-fields { flex-direction: column; }
    .container { margin-top: -60px; }
    .search-form input { width: 130px; }
    .message { padding: 18px; }
}
