/* ===== 陌城论坛 - 休闲风格 ===== */
:root {
    color-scheme: light;
    --bg: #F6FAFF;
    --bg-card: #FFFFFF;
    --bg-nav: rgba(255, 255, 255, 0.86);
    --surface-alt: #EEF6FF;
    --text: #0F2742;
    --text-light: #4B6682;
    --text-muted: #7D90AA;
    --primary: #2563EB;
    --primary-hover: #1D4ED8;
    --primary-contrast: #FFFFFF;
    --secondary: #DCEBFF;
    --secondary-hover: #C8DEFF;
    --secondary-text: #1E4F8F;
    --accent: #38BDF8;
    --border: #D9E7F7;
    --shadow: 0 2px 16px rgba(37, 99, 235, 0.08);
    --shadow-hover: 0 4px 24px rgba(37, 99, 235, 0.14);
    --focus-ring: rgba(37, 99, 235, 0.18);
    --code-bg: #EAF2FF;
    --unread-bg: #EAF2FF;
    --chat-bg: #EEF6FF;
    --danger: #DC2626;
    --danger-hover: #B91C1C;
    --error-bg: #FEE2E2;
    --error-text: #B91C1C;
    --success-bg: #E0F2FE;
    --success-text: #0369A1;
    --info-bg: #DBEAFE;
    --info-text: #1D4ED8;
    --badge-bg: linear-gradient(135deg, #DBEAFE, #93C5FD);
    --badge-text: #1E3A8A;
    --essence-bg: #E0F2FE;
    --essence-text: #0369A1;
    --radius: 14px;
    --radius-sm: 8px;
    --font: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', -apple-system, sans-serif;
    --transition: all 0.25s ease;
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --bg: #050A14;
        --bg-card: #0B1220;
        --bg-nav: rgba(5, 10, 20, 0.88);
        --surface-alt: #101B2F;
        --text: #EAF2FF;
        --text-light: #B4C6E0;
        --text-muted: #7F93B2;
        --primary: #3B82F6;
        --primary-hover: #60A5FA;
        --primary-contrast: #FFFFFF;
        --secondary: #112847;
        --secondary-hover: #17385F;
        --secondary-text: #BFDBFE;
        --accent: #38BDF8;
        --border: #1F3554;
        --shadow: 0 2px 18px rgba(0, 0, 0, 0.36);
        --shadow-hover: 0 6px 28px rgba(37, 99, 235, 0.22);
        --focus-ring: rgba(96, 165, 250, 0.24);
        --code-bg: #101B2F;
        --unread-bg: #102A4D;
        --chat-bg: #08111F;
        --danger: #F87171;
        --danger-hover: #EF4444;
        --error-bg: #3B1218;
        --error-text: #FCA5A5;
        --success-bg: #102A4D;
        --success-text: #93C5FD;
        --info-bg: #102A4D;
        --info-text: #93C5FD;
        --badge-bg: linear-gradient(135deg, #1D4ED8, #38BDF8);
        --badge-text: #EAF2FF;
        --essence-bg: #0C4A6E;
        --essence-text: #BAE6FD;
    }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { overflow-x: hidden; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.8;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-wrap: break-word;
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-hover); }
img { max-width: 100%; }

/* Nav */
.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-nav);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
}
.nav-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    height: 60px;
    gap: 24px;
}
.nav-logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--text) !important;
    letter-spacing: 1px;
}
.nav-logo span { color: var(--primary); }
.nav-links { display: flex; gap: 8px; list-style: none; }
.nav-links a {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-light);
    font-size: 14px;
    font-weight: 500;
}
.nav-links a:hover, .nav-links a.active {
    background: var(--border);
    color: var(--text);
}
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 12px; min-width: 0; }
.nav-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 4px 4px;
    border-radius: 50px;
    transition: var(--transition);
    min-width: 0;
}
.nav-user:hover { background: var(--border); }
.nav-user-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nav-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--secondary);
}
.nav-btn {
    padding: 7px 18px;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}
.nav-btn-primary { background: var(--primary); color: var(--primary-contrast); }
.nav-btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.nav-btn-outline { background: transparent; color: var(--text-light); border: 1.5px solid var(--border); }
.nav-btn-outline:hover { background: var(--border); }

/* Container */
.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 24px; }

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-hover); }
.card-header {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border);
}

/* Grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* Posts */
.post-list { list-style: none; }
.post-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}
.post-item:last-child { border-bottom: none; }
.post-item-avatar img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--secondary);
}
.post-item-body { flex: 1; min-width: 0; }
.post-item-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
    line-height: 1.4;
    overflow-wrap: anywhere;
}
.post-item-title a { color: var(--text); }
.post-item-title a:hover { color: var(--primary); }
.post-item-meta {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.post-item-meta span { display: flex; align-items: center; gap: 3px; }
.tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 600;
    background: var(--secondary);
    color: var(--secondary-text);
}
.tag-essence { background: var(--essence-bg); color: var(--essence-text); }
.tag-top { background: var(--primary); color: var(--primary-contrast); }

/* Categories */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.cat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
}
.cat-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.cat-icon { font-size: 28px; margin-bottom: 8px; }
.cat-name { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.cat-desc { font-size: 13px; color: var(--text-light); margin-bottom: 8px; }
.cat-stat { font-size: 12px; color: var(--text-muted); }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font);
    background: var(--bg-card);
    color: var(--text);
    transition: var(--transition);
    outline: none;
    min-width: 0;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
}
.form-textarea { min-height: 180px; resize: vertical; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.btn {
    padding: 10px 24px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-primary { background: var(--primary); color: var(--primary-contrast); }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-secondary { background: var(--secondary); color: var(--secondary-text); }
.btn-secondary:hover { background: var(--secondary-hover); }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text-light); }
.btn-outline:hover { background: var(--border); }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-danger { background: var(--danger); color: var(--primary-contrast); }
.btn-danger:hover { background: var(--danger-hover); }

/* Auth */
.auth-wrap {
    max-width: 420px;
    margin: 60px auto;
    text-align: center;
}
.auth-title { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.auth-subtitle { color: var(--text-light); margin-bottom: 28px; }
.auth-links { margin-top: 20px; font-size: 14px; color: var(--text-light); }

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
}
.alert-error { background: var(--error-bg); color: var(--error-text); }
.alert-success { background: var(--success-bg); color: var(--success-text); }
.alert-info { background: var(--info-bg); color: var(--info-text); }

/* Profile */
.profile-header {
    display: flex;
    gap: 24px;
    align-items: center;
    padding: 32px;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}
.profile-avatar img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
}
.profile-info { flex: 1; }
.profile-name { font-size: 22px; font-weight: 700; }
.profile-bio { color: var(--text-light); font-size: 14px; margin-top: 4px; }
.profile-stats { display: flex; gap: 24px; margin-top: 12px; }
.profile-stat { text-align: center; }
.profile-stat-num { font-size: 18px; font-weight: 700; }
.profile-stat-label { font-size: 12px; color: var(--text-muted); }

/* Level badge */
.level-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 600;
    background: var(--badge-bg);
    color: var(--badge-text);
}

/* Reply */
.reply-item {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 12px;
}
.reply-item:last-child { border-bottom: none; }
.reply-avatar img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}
.reply-body { flex: 1; min-width: 0; }
.reply-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.reply-content { font-size: 14px; line-height: 1.7; }
.reply-content img,
.reply-content pre,
.reply-content table,
.post-item-body img,
.card pre,
.card table {
    max-width: 100%;
    overflow-x: auto;
}
.reply-content pre,
.card pre {
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--code-bg);
}

/* Message */
.message-list { list-style: none; }
.message-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.message-item:hover { background: var(--border); }
.message-item.unread { background: var(--unread-bg); }
.message-avatar img { width: 40px; height: 40px; border-radius: 50%; }
.message-body { flex: 1; min-width: 0; }
.message-name { font-weight: 600; font-size: 14px; }
.message-preview { font-size: 13px; color: var(--text-light); }
.message-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

.chat-box {
    max-height: 400px;
    overflow-y: auto;
    padding: 16px;
    background: var(--chat-bg);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}
.chat-msg { margin-bottom: 12px; display: flex; }
.chat-msg.me { justify-content: flex-end; }
.chat-msg-content {
    max-width: 70%;
    padding: 10px 16px;
    border-radius: 16px;
    font-size: 14px;
    overflow-wrap: anywhere;
}
.chat-msg .chat-msg-content { background: var(--bg-card); border: 1px solid var(--border); }
.chat-msg.me .chat-msg-content { background: var(--primary); color: var(--primary-contrast); border: none; }

/* Footer */
.footer {
    text-align: center;
    padding: 32px 24px;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid var(--border);
    margin-top: 40px;
}

/* Page title */
.page-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    line-height: 1.35;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 24px;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-light);
    transition: var(--transition);
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .active { background: var(--primary); color: var(--primary-contrast); border-color: var(--primary); }

/* Search */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}
.search-bar input { flex: 1; }
.search-bar button { flex-shrink: 0; }

/* Captcha */
.captcha-wrap {
    user-select: none;
    -webkit-user-select: none;
}
.captcha-track {
    position: relative;
    height: 48px;
    background: var(--surface-alt);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 10px;
    border: 1.5px solid var(--border);
}
.captcha-bg {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        45deg,
        var(--surface-alt),
        var(--surface-alt) 8px,
        var(--border) 8px,
        var(--border) 10px
    );
}
.captcha-gap {
    position: absolute;
    top: -1px;
    bottom: -1px;
    width: 40px;
    background: var(--bg-card);
    border: 2px dashed var(--primary);
    border-radius: 4px;
    z-index: 1;
    transform: translateX(-50%);
}
.captcha-piece {
    position: absolute;
    top: -1px;
    bottom: -1px;
    left: 0;
    width: 40px;
    background: var(--primary);
    border-radius: 4px;
    z-index: 2;
    transform: translateX(-50%);
    opacity: 0.85;
    transition: none;
}
.captcha-slider {
    display: flex;
    align-items: center;
    gap: 10px;
}
.captcha-slider-track {
    flex: 1;
    position: relative;
    height: 36px;
    background: var(--surface-alt);
    border-radius: 50px;
    border: 1.5px solid var(--border);
    cursor: pointer;
}
.captcha-slider-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 100%;
    background: var(--success-bg);
    border-radius: 50px;
    pointer-events: none;
    transition: width 0.05s;
}
.captcha-slider-btn {
    position: absolute;
    top: 50%;
    left: 0;
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    z-index: 3;
    transform: translate(-50%, -50%);
    transition: box-shadow 0.2s;
    touch-action: none;
}
.captcha-slider-btn:hover { box-shadow: 0 0 0 4px var(--focus-ring); }
.captcha-slider-btn:active { cursor: grabbing; }
.captcha-slider-btn.done { background: var(--success-text); cursor: default; }
.captcha-slider-icon {
    color: var(--primary-contrast);
    font-size: 14px;
    font-weight: 700;
}
.captcha-hint {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}
.captcha-pass .captcha-gap { border-color: var(--success-text); }
.captcha-pass .captcha-piece { background: var(--success-text); opacity: 1; }
.captcha-pass .captcha-slider-fill { background: var(--success-bg); }
.captcha-fail .captcha-gap { border-color: var(--danger); }
.captcha-fail .captcha-piece { background: var(--danger); opacity: 1; }
.captcha-fail .captcha-slider-fill { background: var(--error-bg); }
.captcha-fail .captcha-slider-btn { background: var(--danger); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Responsive */
@media (max-width: 768px) {
    body { line-height: 1.7; }

    .nav {
        padding: 0 14px;
    }
    .nav-inner {
        height: auto;
        min-height: 56px;
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 0 8px;
    }
    .nav-logo {
        font-size: 18px;
        letter-spacing: 0;
        white-space: nowrap;
    }
    .nav-right {
        gap: 8px;
    }
    .nav-links {
        order: 3;
        width: 100%;
        display: flex;
        gap: 6px;
        overflow-x: auto;
        padding: 2px 0 6px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .nav-links::-webkit-scrollbar { display: none; }
    .nav-links a {
        display: block;
        white-space: nowrap;
        padding: 7px 12px;
    }
    .nav-btn {
        padding: 7px 13px;
        white-space: nowrap;
    }
    .nav-avatar {
        width: 30px;
        height: 30px;
    }
    .nav-user-name { max-width: 76px; }

    .container { padding: 16px 14px; }
    .footer { padding: 24px 14px; margin-top: 28px; }

    .card { padding: 18px; border-radius: 12px; }
    .card-header {
        font-size: 17px;
        margin-bottom: 14px;
        padding-bottom: 10px;
    }

    .grid-2 { grid-template-columns: 1fr; gap: 16px; }
    .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
    .cat-grid { grid-template-columns: 1fr; gap: 12px; }
    .cat-card { padding: 16px; border-radius: 12px; }
    .cat-icon { font-size: 24px; }

    .page-title { font-size: 20px; margin-bottom: 16px; }

    .post-item {
        gap: 10px;
        padding: 14px 0;
    }
    .post-item-avatar img {
        width: 38px;
        height: 38px;
    }
    .post-item-title { font-size: 15px; }
    .post-item-meta {
        gap: 8px;
        line-height: 1.5;
    }
    .post-item > div[style*="width:60px"],
    .post-item > div[style*="width:80px"] {
        display: none;
    }

    .form-input, .form-select, .form-textarea {
        min-height: 42px;
        font-size: 16px;
    }
    .form-textarea { min-height: 150px; }
    .btn {
        min-height: 40px;
        justify-content: center;
    }

    .auth-wrap {
        margin: 28px auto;
        max-width: 100%;
    }
    .auth-title { font-size: 22px; }
    .auth-subtitle { margin-bottom: 20px; }

    .profile-header {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        padding: 22px 18px;
        text-align: center;
    }
    .profile-avatar img {
        width: 72px;
        height: 72px;
    }
    .profile-name { font-size: 20px; }
    .profile-stats {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 8px;
        margin-top: 14px;
    }

    .reply-item {
        gap: 10px;
        padding: 14px 0;
    }
    .reply-avatar img {
        width: 34px;
        height: 34px;
    }
    .reply-meta .level-badge {
        margin-left: 0 !important;
        margin-top: 4px;
    }

    .message-item {
        align-items: flex-start;
        gap: 10px;
        padding: 12px 0;
    }
    .message-preview {
        display: -webkit-box;
        overflow: hidden;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        line-height: 1.5;
    }
    .message-time { margin-top: 2px; }

    .chat-box {
        max-height: 56vh;
        padding: 12px;
    }
    .chat-msg-content {
        max-width: 86%;
        padding: 9px 12px;
    }

    .search-bar {
        flex-direction: column;
    }
    .search-bar button {
        width: 100%;
    }

    .captcha-track { height: 40px; }
    .captcha-gap, .captcha-piece { width: 32px; }
    .captcha-slider-track { height: 32px; }
    .captcha-slider-btn { width: 32px; height: 32px; }
    .captcha-hint { font-size: 11px; }
}

@media (max-width: 480px) {
    .container { padding: 12px 10px; }
    .nav { padding: 0 10px; }
    .nav-user { padding: 2px; }
    .nav-user-name { display: none; }
    .nav-btn { padding: 7px 11px; font-size: 12px; }

    .card { padding: 15px; }
    .grid-3 { gap: 6px; }
    .grid-3 .card { padding: 12px 8px !important; }

    .profile-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .profile-stat {
        padding: 8px;
        border-radius: var(--radius-sm);
        background: var(--surface-alt);
    }

    .message-item {
        display: grid !important;
        grid-template-columns: 40px minmax(0, 1fr);
    }
    .message-time {
        grid-column: 2;
    }

    .chat-msg-content { max-width: 92%; }

    .captcha-track { height: 36px; }
    .captcha-gap, .captcha-piece { width: 28px; }
    .captcha-slider { gap: 6px; }
    .captcha-hint { display: none; }

    .pagination a, .pagination span {
        padding: 6px 11px;
    }
}
