:root {
    --bg-primary: #f0f2f5;
    --bg-secondary: #fff;
    --bg-tertiary: #f8f9fa;
    --bg-hover: #f5f5f5;
    --text-primary: #333;
    --text-secondary: #666;
    --text-muted: #999;
    --border-color: #ddd;
    --border-light: #eee;
    --shadow: rgba(0,0,0,0.1);
    --link-color: #0066cc;
    --link-hover: #0055aa;
    --input-bg: #fff;
    --input-border: #ddd;
    --input-focus: #0066cc;
    --card-bg: #fff;
    --code-bg: #f5f5f5;
    --success-bg: #d4edda;
    --success-text: #155724;
    --success-border: #c3e6cb;
    --danger-bg: #f8d7da;
    --danger-text: #721c24;
    --danger-border: #f5c6cb;
    --warning-bg: #fff3cd;
    --warning-text: #856404;
    --warning-border: #ffeeba;
    --info-bg: #d1ecf1;
    --info-text: #0c5460;
    --info-border: #bee5eb;
}

[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #363636;
    --bg-hover: #363636;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-muted: #888;
    --border-color: #404040;
    --border-light: #333;
    --shadow: rgba(0,0,0,0.3);
    --link-color: #66b3ff;
    --link-hover: #99ccff;
    --input-bg: #2d2d2d;
    --input-border: #404040;
    --input-focus: #66b3ff;
    --card-bg: #2d2d2d;
    --code-bg: #363636;
    --success-bg: #1a3d1a;
    --success-text: #90ee90;
    --success-border: #2d5a2d;
    --danger-bg: #3d1a1a;
    --danger-text: #ff9090;
    --danger-border: #5a2d2d;
    --warning-bg: #3d3d00;
    --warning-text: #ffd700;
    --warning-border: #5d5d00;
    --info-bg: #1a2d3d;
    --info-text: #90d0ff;
    --info-border: #2d4a5a;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    transition: background 0.3s, color 0.3s;
}

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

.navbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 0;
}

.nav-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 15px;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 12px;
    font-size: 14px;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--text-primary);
}

.theme-toggle {
    font-size: 16px;
    cursor: pointer;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 5px;
}

.banned-tag {
    color: #dc3545;
    font-size: 12px;
}

.flash-messages {
    margin: 15px 0;
}

.alert {
    padding: 10px 15px;
    border-radius: 2px;
    margin-bottom: 10px;
    font-size: 14px;
    border-left: 4px solid;
}

.alert-success { background: #f0f9eb; color: #5FB878; border-color: #5FB878; }
.alert-danger { background: #fef0f0; color: #FF5722; border-color: #FF5722; }
.alert-warning { background: #fff8e6; color: #FFB800; border-color: #FFB800; }
.alert-info { background: #ecf5ff; color: #1E9FFF; border-color: #1E9FFF; }

.page-header {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 4px;
    margin: 15px 0;
    border: 1px solid var(--border-color);
}

.page-header h1 {
    font-size: 20px;
    margin-bottom: 8px;
}

.breadcrumb {
    margin-bottom: 10px;
    font-size: 13px;
    color: var(--text-secondary);
}

.breadcrumb a {
    color: var(--link-color);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.content-wrapper {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 15px;
    margin: 15px 0;
}

.main-content {
    min-width: 0;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.sidebar-card {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.sidebar-card h3 {
    font-size: 14px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

.hot-posts {
    list-style: none;
}

.hot-posts li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
}

.hot-posts li:last-child {
    border-bottom: none;
}

.hot-posts a {
    color: var(--text-primary);
    text-decoration: none;
    display: block;
}

.hot-posts a:hover {
    color: var(--link-color);
}

.hot-posts .views {
    font-size: 12px;
    color: var(--text-muted);
}

.section {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
}

.section-title {
    font-size: 16px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

.category-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 10px;
}

.category-card {
    display: flex;
    align-items: center;
    padding: 12px;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
}

.category-card:hover {
    background: var(--bg-hover);
}

.category-icon {
    font-size: 24px;
    margin-right: 12px;
}

.category-info h3 {
    font-size: 14px;
    margin-bottom: 3px;
    color: var(--text-primary);
}

.category-info p {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 3px;
}

.post-count {
    font-size: 11px;
    color: var(--text-muted);
}

.post-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.post-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
}

.post-item:hover {
    background: var(--bg-hover);
}

.post-main h3 {
    font-size: 14px;
    margin-bottom: 5px;
    color: var(--text-primary);
}

.post-meta {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    gap: 10px;
}

.post-stats {
    display: flex;
    gap: 10px;
    font-size: 12px;
    color: var(--text-secondary);
}

.badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    margin-right: 4px;
}

.badge-pinned { background: #ffc107; color: #856404; }
.badge-locked { background: #dc3545; color: white; }
.badge-admin { background: var(--link-color); color: white; }
.badge-banned { background: #dc3545; color: white; }

.post-like-bar {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 15px;
}

.btn-like, .btn-dislike {
    background: var(--bg-tertiary) !important;
    border: 1px solid var(--border-light) !important;
    color: var(--text-primary) !important;
}

.btn-like:hover, .btn-dislike:hover {
    background: var(--bg-hover) !important;
}

.author-title {
    color: var(--link-color);
    font-size: 0.9em;
    margin-right: 5px;
}
.badge-title { background: #6f42c1; color: white; }

.auth-container {
    display: flex;
    justify-content: center;
    padding: 30px 15px;
}

.auth-card {
    width: 100%;
    max-width: 360px;
}

.auth-card h2 {
    text-align: center;
    font-size: 18px;
    margin-bottom: 20px;
    color: var(--text-primary);
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    color: var(--text-primary);
}

/* layui-input 适配暗色主题 */
.layui-input {
    background: var(--input-bg);
    color: var(--text-primary);
    border-color: var(--input-border);
}

.layui-input:focus {
    border-color: var(--input-focus) !important;
}

.layui-input::placeholder {
    color: var(--text-muted);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-checkbox {
    width: 16px;
    height: 16px;
}

.error-message {
    display: block;
    color: #dc3545;
    font-size: 12px;
    margin-top: 4px;
}

.auth-footer {
    text-align: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-light);
    font-size: 13px;
    color: var(--text-secondary);
}

.auth-footer a {
    color: var(--link-color);
    text-decoration: none;
}

.form-container {
    max-width: 960px;
    margin: 20px auto;
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.form-container-wide {
    max-width: 100%;
    width: min(95vw, 1400px);
    margin: 20px auto;
    padding: 24px;
    box-sizing: border-box;
}

/* ===== 发帖/编辑页面全宽布局 ===== */
.post-editor-page {
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
}
.editor-controls {
    max-width: 800px;
    margin: 0 auto 15px;
}
.editor-fullwidth {
    width: 100%;
    margin: 0 0 15px;
    box-sizing: border-box;
}

.form-container h1 {
    font-size: 18px;
    margin-bottom: 20px;
    color: var(--text-primary);
}

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

.profile-container {
    max-width: 800px;
    margin: 20px auto;
}

.profile-header {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
}

.avatar-A { background: #e74c3c; }
.avatar-B { background: #3498db; }
.avatar-C { background: #2ecc71; }
.avatar-D { background: #9b59b6; }
.avatar-E { background: #f39c12; }
.avatar-F { background: #1abc9c; }
.avatar-G { background: #e67e22; }
.avatar-H { background: #34495e; }
.avatar-I { background: #16a085; }
.avatar-J { background: #c0392b; }
.avatar-K { background: #8e44ad; }
.avatar-L { background: #27ae60; }
.avatar-M { background: #d35400; }
.avatar-N { background: #2980b9; }
.avatar-O { background: #c73e1d; }
.avatar-P { background: #f1c40f; }
.avatar-Q { background: #00cec9; }
.avatar-R { background: #6c5ce7; }
.avatar-S { background: #ff7675; }
.avatar-T { background: #74b9ff; }
.avatar-U { background: #a29bfe; }
.avatar-V { background: #fd79a8; }
.avatar-W { background: #55a3ff; }
.avatar-X { background: #ff9ff3; }
.avatar-Y { background: #feca57; }
.avatar-Z { background: #48dbfb; }

.profile-avatar img {
    width: 80px;
    height: 80px;
    border-radius: 4px;
    object-fit: cover;
}

.profile-info h1 {
    font-size: 18px;
    margin-bottom: 5px;
    color: var(--text-primary);
}

.profile-info .signature {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 10px;
}

.profile-meta {
    display: flex;
    gap: 15px;
    font-size: 12px;
    color: var(--text-secondary);
}

.profile-content {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.profile-content h2 {
    font-size: 16px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

.post-container {
    max-width: 800px;
    margin: 20px auto;
}

.post-detail {
    background: var(--bg-secondary);
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.post-header {
    padding: 15px;
    border-bottom: 1px solid var(--border-light);
}

.post-header h1 {
    font-size: 18px;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.post-meta {
    display: flex;
    gap: 15px;
    font-size: 12px;
    color: var(--text-secondary);
}

.post-meta a {
    color: var(--link-color);
    text-decoration: none;
}

.post-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
}

.post-content {
    padding: 15px;
    line-height: 1.7;
    white-space: pre-wrap;
    color: var(--text-primary);
}

.post-content-wrapper {
    max-height: 300px;
    overflow: hidden;
    position: relative;
}

.post-content-wrapper.expanded {
    max-height: none;
}

.post-content-wrapper:not(.expanded)::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(transparent, var(--bg-secondary));
    pointer-events: none;
}

.toggle-content-btn {
    display: block;
    margin: 10px auto;
}

.comment-content-wrapper {
    position: relative;
}

.comment-content-wrapper.collapsed {
    max-height: 100px;
    overflow: hidden;
}

.comment-content-wrapper.collapsed::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(transparent, var(--bg-tertiary));
    pointer-events: none;
}

.toggle-comment-btn {
    background: transparent !important;
    border: none !important;
    color: var(--link-color) !important;
    padding: 2px 8px;
    font-size: 12px;
    margin-top: 5px;
}

.comments-section {
    background: var(--bg-secondary);
    margin-top: 15px;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.comments-section h2 {
    font-size: 16px;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.comment-form {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-light);
}

.comment-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.comment-item {
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 4px;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.comment-author {
    font-size: 13px;
    font-weight: 500;
    color: var(--link-color);
    text-decoration: none;
}

.comment-time {
    font-size: 12px;
    color: var(--text-muted);
}

.comment-content {
    font-size: 13px;
    white-space: pre-wrap;
    color: var(--text-primary);
}

.comment-actions {
    font-size: 12px;
    margin-top: 8px;
}

.comment-reply {
    margin-left: 20px;
    margin-top: 10px;
    padding: 10px;
    background: var(--bg-secondary);
    border-left: 2px solid var(--link-color);
}

.parent-comment {
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 15px;
    border-left: 2px solid var(--link-color);
}

.admin-container {
    max-width: 900px;
    margin: 20px auto;
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    text-align: center;
}

.stat-card h3 {
    font-size: 24px;
    color: var(--link-color);
}

.stat-card p {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 5px;
}

.admin-section {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
}

.admin-section h2 {
    font-size: 16px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

.admin-form {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
}

.admin-form h2 {
    font-size: 16px;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    color: var(--text-primary);
}

.admin-table th {
    background: var(--bg-tertiary);
    font-weight: 500;
}

.admin-actions {
    display: flex;
    gap: 5px;
}

.empty-state {
    text-align: center;
    padding: 30px;
    color: var(--text-secondary);
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
    padding: 15px;
}

.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    text-align: center;
    padding: 15px;
    margin-top: 30px;
    font-size: 13px;
    color: var(--text-secondary);
}

.footer-stats {
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.footer-stat-divider {
    margin: 0 10px;
    color: var(--border-color);
}

.delete-form {
    display: inline;
}

@media (max-width: 768px) {
    .content-wrapper {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        order: -1;
    }
    
    .nav-menu {
        flex-wrap: wrap;
    }
    
    .profile-header {
        flex-direction: column;
        text-align: center;
    }
    
    .post-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .post-stats {
        align-self: flex-end;
    }
}

.loading-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-secondary);
}

.loader-bars {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
    height: 40px;
    margin-bottom: 15px;
}

.loader-bars .bar {
    width: 3px;
    background: var(--link-color);
    animation: barAnim 0.8s ease-in-out infinite;
}

.loader-bars .bar:nth-child(1) { animation-delay: 0s; }
.loader-bars .bar:nth-child(2) { animation-delay: 0.1s; }
.loader-bars .bar:nth-child(3) { animation-delay: 0.2s; }
.loader-bars .bar:nth-child(4) { animation-delay: 0.3s; }
.loader-bars .bar:nth-child(5) { animation-delay: 0.4s; }
.loader-bars .bar:nth-child(6) { animation-delay: 0.5s; }
.loader-bars .bar:nth-child(7) { animation-delay: 0.6s; }
.loader-bars .bar:nth-child(8) { animation-delay: 0.7s; }

@keyframes barAnim {
    0%, 100% { height: 8px; }
    50% { height: 40px; }
}

.error-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--danger-text);
}

.error-state p {
    margin-bottom: 15px;
}

.chat-container {
    display: flex;
    flex-direction: column;
    position: relative;
    height: 100%;
    min-height: 400px;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.chat-sidebar {
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: var(--bg-tertiary);
}

.chat-sidebar-header {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.chat-sidebar-header h2 {
    font-size: 18px;
    margin: 0;
    color: var(--text-primary);
}

.chat-rooms-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.chat-room-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 5px;
}

.chat-room-item:hover {
    background: var(--bg-hover);
}

.chat-room-item.active {
    background: var(--link-color);
    color: white;
}

.chat-room-icon {
    font-size: 24px;
}

.chat-room-info {
    flex: 1;
    min-width: 0;
}

.chat-room-name {
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 2px;
}

.chat-room-desc {
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-room-item.active .chat-room-desc {
    color: rgba(255, 255, 255, 0.8);
}

.chat-room-online {
    font-size: 12px;
    color: var(--text-muted);
}

.chat-room-item.active .chat-room-online {
    color: rgba(255, 255, 255, 0.8);
}

.chat-main {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    height: 100%;
    width: 100%;
    overflow: hidden;
}

.chat-room-header {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    flex-shrink: 0;
}

.chat-room-header h3 {
    font-size: 16px;
    margin: 0 0 5px 0;
    color: var(--text-primary);
}

.chat-room-description {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    scroll-behavior: smooth;
}

.chat-message {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.chat-message.own {
    flex-direction: row-reverse;
}

.chat-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
    background: var(--link-color);
    color: white;
}

.chat-message.own .chat-message-avatar {
    background: #28a745;
}

.chat-message-content-wrapper {
    max-width: 70%;
    background: var(--bg-tertiary);
    padding: 10px 14px;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}

.chat-message.own .chat-message-content-wrapper {
    background: var(--link-color);
    color: white;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 4px;
}

.chat-message-header {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 4px;
}

.chat-message.own .chat-message-header {
    flex-direction: row-reverse;
}

.chat-message-username {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.chat-message.own .chat-message-username {
    color: rgba(255, 255, 255, 0.9);
}

.chat-message-time {
    font-size: 11px;
    color: var(--text-muted);
}

.chat-message.own .chat-message-time {
    color: rgba(255, 255, 255, 0.7);
}

.chat-message-content {
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-message-reply {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
    padding-left: 8px;
    border-left: 2px solid var(--link-color);
}

.chat-message.own .chat-message-reply {
    color: rgba(255, 255, 255, 0.8);
    border-left-color: rgba(255, 255, 255, 0.5);
}

.chat-message-actions {
    margin-top: 8px;
    display: flex;
    gap: 5px;
}

.chat-message.own .chat-message-actions {
    justify-content: flex-end;
}

.chat-input-area {
    padding: 12px 15px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
    min-height: 60px;
}

.chat-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    resize: none;
    font-size: 14px;
    font-family: inherit;
    background: var(--input-bg);
    color: var(--text-primary);
    min-height: 42px;
    max-height: 120px;
    line-height: 1.4;
}

.chat-input:focus {
    outline: none;
    border-color: var(--input-focus);
}

.chat-send-btn {
    padding: 10px 24px;
    background: var(--link-color);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
    height: 42px;
    flex-shrink: 0;
}

.chat-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.chat-send-btn:hover {
    background: var(--link-hover);
}

@media (max-width: 768px) {
    .chat-container {
        height: 100%;
        min-height: auto;
        border-radius: 0;
        margin: 0;
    }

    .chat-sidebar {
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .chat-message-content-wrapper {
        max-width: 85%;
    }
}

/* 404页面样式 */
.error-page {
    text-align: center;
    padding: 60px 20px;
}
.error-code {
    font-size: 120px;
    font-weight: bold;
    color: var(--text-muted);
    line-height: 1;
}
.error-message {
    font-size: 24px;
    color: var(--text-primary);
    margin: 20px 0 10px;
}
.error-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}

/* 手机端适配 */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 10px;
    }
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }
    .admin-stats {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .admin-table {
        font-size: 12px;
    }
    .admin-table th, .admin-table td {
        padding: 6px 4px;
    }
    .post-card {
        padding: 12px;
    }
    .auth-card {
        padding: 15px;
        margin: 10px;
    }
    .forum-container {
        padding: 10px;
    }
    .chat-input-wrapper {
        flex-direction: column !important;
    }
    .chat-send-btn {
        width: 100%;
    }
}

/* 平板适配 */
@media (max-width: 1024px) and (min-width: 769px) {
    .admin-stats {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ===== Markdown 渲染样式 ===== */
.markdown-body {
    line-height: 1.8;
    color: #333;
    word-wrap: break-word;
}
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
    margin: 20px 0 10px;
    font-weight: 600;
    line-height: 1.4;
}
.markdown-body h1 { font-size: 1.8em; border-bottom: 2px solid #eee; padding-bottom: 8px; }
.markdown-body h2 { font-size: 1.5em; border-bottom: 1px solid #eee; padding-bottom: 6px; }
.markdown-body h3 { font-size: 1.3em; }
.markdown-body h4 { font-size: 1.1em; }
.markdown-body p { margin: 10px 0; }
.markdown-body a { color: #0071e3; text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; }
.markdown-body strong { font-weight: 600; }
.markdown-body em { font-style: italic; }
.markdown-body code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.9em;
    font-family: 'SF Mono', Consolas, 'Courier New', monospace;
    color: #e83e8c;
}
.markdown-body pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
    font-size: 0.9em;
    line-height: 1.6;
}
.markdown-body pre code {
    background: none;
    color: inherit;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
}
.markdown-body blockquote {
    border-left: 4px solid #0071e3;
    margin: 12px 0;
    padding: 8px 16px;
    background: #f8f9fa;
    color: #666;
    border-radius: 0 4px 4px 0;
}
.markdown-body ul, .markdown-body ol {
    margin: 10px 0;
    padding-left: 28px;
}
.markdown-body li { margin: 4px 0; }
.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 8px 0;
    cursor: zoom-in;
}
.markdown-body table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
    overflow-x: auto;
    display: block;
}
.markdown-body th, .markdown-body td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: left;
}
.markdown-body th {
    background: #f8f9fa;
    font-weight: 600;
}
.markdown-body tr:nth-child(even) {
    background: #fafafa;
}
.markdown-body hr {
    border: none;
    border-top: 2px solid #eee;
    margin: 20px 0;
}
.markdown-body del { text-decoration: line-through; color: #999; }

/* ===== 工具栏样式 ===== */
.md-toolbar {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    padding: 8px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    overflow-x: auto;
    flex-wrap: nowrap;
}
.md-btn {
    min-width: 36px;
    height: 36px;
    border: 1px solid #d0d0d0;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
}
.md-btn:hover {
    background: #e8e8e8;
    border-color: #b0b0b0;
}
.md-btn:active {
    background: #d0d0d0;
}

/* ===== 编辑器 textarea 样式 ===== */
#post-content, #edit-content {
    min-height: 400px !important;
    resize: vertical;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    tab-size: 4;
}

/* ===== Markdown 预览面板样式 ===== */
.md-preview-panel {
    min-height: 400px;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-secondary);
    overflow-y: auto;
    box-sizing: border-box;
    margin-top: 10px;
}
.md-preview-panel:empty::before {
    content: '在左侧输入内容后将显示预览';
    color: #999;
    font-style: italic;
}

/* ===== 表情面板样式 ===== */
.emoji-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-top: none;
    max-height: 200px;
    overflow-y: auto;
}
.emoji-item {
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.15s;
}
.emoji-item:hover {
    background: #f0f0f0;
}

/* ===== Lightbox 样式 ===== */
#md-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    cursor: zoom-out;
    touch-action: pinch-zoom;
}
#md-lightbox img {
    max-width: 92vw;
    max-height: 92vh;
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(0,0,0,0.6);
}


/* ===== 人机验证（与后台登录界面统一） ===== */
.cf-turnstile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fafafa;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 48px;
}
.cf-turnstile:hover { border-color: #0071e3; background: #f0f7ff; }
.cf-turnstile.loading { cursor: wait; opacity: 0.7; }
.cf-turnstile.verified { border-color: #00a400; background: #f0fff0; cursor: default; }
.cf-checkbox {
    width: 22px;
    height: 22px;
    border: 2px solid #ccc;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: #fff;
}
.cf-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #e0e0e0;
    border-top-color: #0071e3;
    border-radius: 50%;
    animation: cf-spin 0.8s linear infinite;
}
.cf-check {
    color: #00a400;
    font-size: 18px;
    font-weight: bold;
    display: none;
}
.cf-text {
    font-size: 14px;
    color: #333;
}
.cf-status {
    font-size: 12px;
    color: #999;
    margin-top: 4px;
}
.cf-brand {
    font-size: 11px;
    color: #bbb;
    margin-top: 6px;
    text-align: right;
}
[data-theme="dark"] .cf-turnstile { background: #2a2a2a; border-color: #444; }
[data-theme="dark"] .cf-turnstile:hover { background: #1a2030; border-color: #0071e3; }
[data-theme="dark"] .cf-turnstile.verified { background: #1a2a1a; border-color: #00a400; }
[data-theme="dark"] .cf-checkbox { background: #333; border-color: #555; }
[data-theme="dark"] .cf-text { color: #ddd; }
[data-theme="dark"] .cf-brand { color: #666; }

/* ===== 手机端适配（Markdown 相关） ===== */
@media (max-width: 768px) {
    .md-toolbar {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .md-btn { flex-shrink: 0; }
    textarea#post-content, textarea#edit-content {
        font-size: 16px !important;
    }
    .markdown-body { padding: 0 4px; }
    .markdown-body pre { font-size: 0.85em; }
    .markdown-body table { font-size: 0.9em; }
    .emoji-panel { max-height: 150px; }
    .form-container-wide {
        width: 100%;
        padding: 12px;
    }
    .post-editor-page { padding: 10px; }
    .editor-controls { max-width: 100%; }
    #post-content, #edit-content {
        min-height: 300px !important;
    }
    .md-preview-panel {
        min-height: 300px;
        padding: 12px;
    }
}
