/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 30px;
}

/* 导航栏样式 */
.navbar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

.navbar-nav {
    display: flex;
    list-style: none;
}

.navbar-nav li {
    margin-left: 20px;
}

.navbar-nav a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.navbar-nav a:hover {
    color: #f0f0f0;
    text-decoration: underline;
}

/* 按钮样式 */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

.btn-danger:hover {
    background-color: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

.btn-success {
    background-color: #28a745;
    color: white;
}

.btn-success:hover {
    background-color: #218838;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

.btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

/* 卡片样式 */
.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 20px;
    margin-bottom: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

/* 表单样式 */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 选项卡样式 */
.tabs {
    margin-bottom: 20px;
}

.tab-buttons {
    display: flex;
    border-bottom: 2px solid #e9ecef;
    margin-bottom: 20px;
}

.tab-button {
    padding: 10px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #6c757d;
    position: relative;
    transition: all 0.3s ease;
}

.tab-button:hover {
    color: #667eea;
}

.tab-button.active {
    color: #667eea;
    font-weight: 600;
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* 表格样式 */
table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

table th, table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

table tr:hover {
    background: #f8f9fa;
}

table tr:last-child td {
    border-bottom: none;
}

/* 分类标签 */
.category-tag {
    display: inline-block;
    padding: 2px 8px;
    background: #e9ecef;
    border-radius: 12px;
    font-size: 12px;
    color: #495057;
    margin-right: 10px;
}

/* 帖子列表 */
.post-list {
    margin-top: 20px;
}

.post-item {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    display: block;
    color: #333;
    text-decoration: none;
}

.post-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.post-item h3 {
    margin-bottom: 10px;
    font-size: 1.2rem;
    color: #333;
}

.post-item h3:hover {
    color: #667eea;
}

.post-meta {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 10px;
}

.post-content {
    color: #495057;
    margin-bottom: 15px;
    line-height: 1.6;
}

.post-actions {
    display: flex;
    gap: 10px;
    font-size: 12px;
    color: #6c757d;
}

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

.comment-item {
    background: white;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.comment-meta {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 8px;
}

.comment-content {
    color: #495057;
    line-height: 1.5;
}

/* 页脚 */
.footer {
    background: #343a40;
    color: white;
    padding: 30px 0;
    margin-top: 30px;
}

.footer .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    flex-wrap: wrap;
    gap: 20px;
}

.footer-links a {
    color: #adb5bd;
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-links a:hover {
    color: white;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .navbar .container {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .navbar-nav {
        margin-top: 15px;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .navbar-nav li {
        margin-left: 0;
        margin-right: 15px;
    }
    
    .container {
        padding: 15px;
    }
    
    .footer .container {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    
    .footer-links {
        margin-top: 15px;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    /* 搜索框响应式 */
    .search-box {
        margin: 10px 0;
        max-width: 100%;
    }
    
    /* 卡片响应式 */
    .card {
        padding: 15px;
    }
    
    /* 表单响应式 */
    .form-control {
        padding: 12px;
        font-size: 16px;
    }
    
    /* 按钮响应式 */
    .btn {
        padding: 10px 20px;
        font-size: 16px;
    }
    
    /* 表格响应式 */
    table {
        font-size: 14px;
    }
    
    table th, table td {
        padding: 8px 12px;
    }
    
    /* 帖子列表响应式 */
    .post-item {
        padding: 15px;
    }
    
    .post-item h3 {
        font-size: 1.1rem;
    }
    
    /* 评论响应式 */
    .comment-item {
        padding: 15px;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* 工具类 */
.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 3rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mb-5 { margin-bottom: 3rem; }

.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }
.p-5 { padding: 3rem; }

.bg-white { background-color: white; }
.bg-light { background-color: #f8f9fa; }

.text-primary { color: #667eea; }
.text-danger { color: #dc3545; }
.text-success { color: #28a745; }
.text-muted { color: #6c757d; }

.border { border: 1px solid #dee2e6; }
.border-radius { border-radius: 4px; }

.shadow { box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.shadow-lg { box-shadow: 0 4px 8px rgba(0,0,0,0.15); }

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 表单验证 */
.form-control.is-invalid {
    border-color: #dc3545;
}

.invalid-feedback {
    color: #dc3545;
    font-size: 12px;
    margin-top: 5px;
}

/* 已删除项目样式 */
.deleted {
    opacity: 0.6;
    background-color: #f8d7da;
}

.deleted-tag {
    display: inline-block;
    padding: 2px 8px;
    background: #dc3545;
    color: white;
    border-radius: 12px;
    font-size: 12px;
    margin-right: 10px;
}

/* Grid布局 */
.grid {
    display: grid;
}

.grid-cols-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
}

.grid-cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (min-width: 768px) {
    .md\:grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.gap-4 {
    gap: 1rem;
}

/* AI卡片样式 */
.ai-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    padding: 24px 16px;
    text-align: center;
    transition: all 0.3s ease;
    border: 1px solid rgba(0,0,0,0.04);
}

.ai-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.12);
}

.ai-card a {
    text-decoration: none;
    color: inherit;
}

.ai-card h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 6px;
}

.ai-card p {
    font-size: 12px;
    color: #6b7280;
    margin: 0;
}

/* ========================================
   统一优化样式 (v2.4)
   最后更新: 2026-06-04
   ======================================== */

/* 现代化卡片样式 */
.card-modern {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 20px;
    transition: all 0.3s ease;
    border: 1px solid #e5e7eb;
}

.card-modern:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

/* 渐变背景工具类 */
.bg-gradient-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.bg-gradient-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.bg-gradient-danger {
    background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
}

.bg-gradient-warning {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

/* 响应式文本 */
.text-responsive {
    font-size: clamp(14px, 2vw, 18px);
}

/* 弹性布局工具类 */
.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* 间距工具类 */
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }

/* 圆角工具类 */
.rounded-sm { border-radius: 4px; }
.rounded { border-radius: 8px; }
.rounded-lg { border-radius: 12px; }
.rounded-xl { border-radius: 16px; }
.rounded-full { border-radius: 9999px; }

/* 阴影工具类 */
.shadow-sm { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }
.shadow { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); }
.shadow-lg { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); }
.shadow-xl { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15); }

/* 过渡动画 */
.transition-fast { transition: all 0.15s ease; }
.transition { transition: all 0.3s ease; }
.transition-slow { transition: all 0.5s ease; }

/* 按钮加载状态 */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* 消息提示样式 */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    border-left: 4px solid;
}

.alert-success {
    background-color: #d1fae5;
    border-left-color: #10b981;
    color: #065f46;
}

.alert-error {
    background-color: #fee2e2;
    border-left-color: #ef4444;
    color: #991b1b;
}

.alert-warning {
    background-color: #fef3c7;
    border-left-color: #f59e0b;
    color: #92400e;
}

.alert-info {
    background-color: #dbeafe;
    border-left-color: #3b82f6;
    color: #1e40af;
}

/* 头像样式 */
.avatar {
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.avatar-sm { width: 32px; height: 32px; }
.avatar { width: 48px; height: 48px; }
.avatar-lg { width: 64px; height: 64px; }
.avatar-xl { width: 96px; height: 96px; }

/* 统计卡片 */
.stat-card {
    text-align: center;
    padding: 16px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 标签页样式 */
.tabs {
    display: flex;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 20px;
}

.tab {
    padding: 12px 24px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.3s ease;
    color: #6b7280;
}

.tab:hover {
    color: #667eea;
}

.tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: 600;
}

/* 输入框焦点效果 */
.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 移动端优化 */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
    
    .card-modern {
        padding: 16px;
    }
    
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .tab {
        padding: 10px 16px;
        font-size: 14px;
        white-space: nowrap;
    }
}

/* ========================================
   Frontend polish and mobile ergonomics
   ======================================== */

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    min-width: 320px;
    overflow-x: hidden;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

img,
video,
canvas,
svg {
    max-width: 100%;
}

button,
input,
select,
textarea {
    font: inherit;
}

a,
button,
.btn,
.action-btn,
.tab-button,
.tab {
    -webkit-tap-highlight-color: transparent;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.btn:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.28);
    outline-offset: 2px;
}

.container {
    width: min(1200px, calc(100% - 32px));
    padding-left: 0;
    padding-right: 0;
}

.card,
.post-item,
.comment-item,
.card-modern,
.ai-card,
.stat-card {
    border: 1px solid rgba(226, 232, 240, 0.9);
}

.card:hover,
.post-item:hover,
.card-modern:hover,
.ai-card:hover,
.stat-card:hover {
    transform: translateY(-2px);
}

.btn {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    line-height: 1.25;
    white-space: nowrap;
}

.form-control,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
select,
textarea {
    min-height: 40px;
}

textarea {
    resize: vertical;
}

table {
    table-layout: auto;
}

table th,
table td {
    vertical-align: middle;
}

.post-actions,
.footer-links,
.tab-buttons,
.tabs,
.navbar-nav {
    min-width: 0;
}

.post-content,
.comment-content,
.info-value,
.post-item h3 {
    overflow-wrap: anywhere;
}

@media (max-width: 900px) {
    .container {
        width: min(100% - 24px, 1200px);
    }

    .navbar .container,
    .header .container,
    .admin-header .container {
        width: min(100% - 24px, 1200px);
    }

    .navbar-nav,
    .tab-buttons,
    .tabs,
    .tab-header,
    .tab-nav .container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .navbar-nav a,
    .tab-button,
    .tab {
        white-space: nowrap;
    }

    table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
    }
}

@media (max-width: 640px) {
    body {
        font-size: 15px;
    }

    .container {
        width: min(100% - 20px, 1200px);
    }

    .navbar {
        padding: 12px 0;
    }

    .navbar h1,
    .header h1,
    .admin-header h1 {
        font-size: 1.15rem !important;
        line-height: 1.25;
    }

    .card,
    .post-item,
    .comment-item,
    .content-card,
    .details-card,
    .tabs-container,
    .profile-card {
        border-radius: 12px !important;
    }

    .post-item,
    .card,
    .card-modern,
    .content-card .card-body,
    .details-card {
        padding: 16px !important;
    }

    .post-actions,
    .quick-actions,
    .batch-actions,
    .modal-actions {
        flex-wrap: wrap;
        gap: 8px;
    }

    .post-actions .btn,
    .quick-actions .btn,
    .batch-actions .btn,
    .modal-actions .btn {
        min-height: 42px;
    }

    .btn {
        min-height: 42px;
        padding: 10px 14px;
        font-size: 15px;
    }

    .btn-sm {
        min-height: 34px;
        padding: 7px 10px;
        font-size: 13px;
    }

    .form-control,
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="date"],
    select,
    textarea {
        min-height: 44px;
        font-size: 16px;
    }

    .footer {
        padding: 22px 0;
    }
}

@media (max-width: 420px) {
    .post-actions .btn,
    .quick-actions .btn,
    .batch-actions .btn {
        width: 100%;
    }

    .stats-grid,
    .info-grid,
    .grid-cols-4,
    .md\:grid-cols-4 {
        grid-template-columns: 1fr !important;
    }
}

/* Forum interface refinement */
html {
    scroll-padding-top: 96px;
}

body {
    overflow-x: clip;
}

img,
video,
canvas,
svg {
    max-width: 100%;
}

.header,
.admin-header {
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.header .container,
.admin-header .container,
.header-nav,
.card-header,
.admin-info,
.user-info,
.pagination,
.comment-actions,
.form-actions {
    min-width: 0;
}

.header .container,
.admin-header .container {
    gap: 14px;
}

.nav,
.header .nav,
.admin-info {
    flex-wrap: wrap;
}

.nav a,
.header .nav a,
.admin-info a {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.main-content,
.chat-container,
.profile-container,
.post-form-container,
.login-container,
.register-container,
.admin-panel,
.content-card,
.post-detail,
.ai-container {
    min-width: 0;
}

.post-detail,
.post-form-container,
.profile-container,
.login-container,
.register-container,
.ai-container {
    width: min(100% - 32px, 1100px);
    margin-left: auto;
    margin-right: auto;
}

.modal-content,
.dialog,
.popup {
    max-width: min(96vw, 720px) !important;
}

.post-detail h1,
.post-title,
.card-title,
.section-title {
    overflow-wrap: anywhere;
}

.data-table,
.content-card table {
    min-width: 720px;
}

.table-wrap,
.table-container,
.card-body:has(table) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.flash-messages,
.alert,
.message {
    overflow-wrap: anywhere;
}

@media (max-width: 900px) {
    html {
        scroll-padding-top: 78px;
    }

    .header .container,
    .admin-header .container {
        width: min(100% - 24px, 1400px) !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .header .nav,
    .admin-info {
        gap: 8px !important;
    }

    .header .nav a,
    .admin-info a {
        padding: 7px 10px !important;
        font-size: 13px !important;
    }

    .card-header {
        align-items: flex-start !important;
        flex-direction: column;
        gap: 12px;
    }

    .chat-container {
        padding-top: 64px !important;
        max-width: 100% !important;
    }

    .chat-container .conversation-list {
        height: calc(100dvh - 64px) !important;
    }

    .chat-container .chat-area {
        top: 64px !important;
        height: calc(100dvh - 64px) !important;
    }

    .chat-container .message-content {
        max-width: 82% !important;
    }

    .tab-nav {
        top: 58px !important;
    }

    .tab-nav .container {
        width: 100% !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .tab-button {
        flex: 0 0 auto !important;
        min-width: max-content !important;
        padding: 13px 14px !important;
    }

    .admin-header {
        padding: 12px 0 !important;
    }

    .admin-header h1 {
        font-size: 17px !important;
    }

    .admin-header .container {
        align-items: flex-start !important;
    }

    .admin-info {
        justify-content: flex-end;
    }

    .main-content {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }
}

@media (max-width: 640px) {
    html {
        scroll-padding-top: 116px;
    }

    body .header {
        max-height: 46dvh;
        overflow-y: auto;
    }

    body .header .header-nav {
        padding: 8px 12px !important;
        gap: 8px !important;
    }

    body .header .header-nav h1 {
        width: 100%;
        margin-bottom: 0 !important;
        font-size: 16px !important;
        line-height: 1.2 !important;
        text-align: center;
    }

    body .header .nav {
        width: 100%;
        justify-content: center;
        gap: 6px !important;
    }

    body .header .nav a {
        min-height: 30px;
        padding: 4px 7px !important;
        font-size: 12px !important;
        border-radius: 8px !important;
    }

    body .header .header-search {
        padding: 0 12px 8px !important;
    }

    body .header .search-box {
        min-height: 38px;
    }

    body .header .search-box input {
        height: 38px !important;
        min-height: 38px !important;
        font-size: 15px !important;
    }

    body .main-content {
        padding-top: 118px !important;
    }

    .post-detail,
    .post-form-container,
    .profile-container,
    .login-container,
    .register-container,
    .ai-container {
        width: min(100% - 20px, 1100px) !important;
    }

    .login-container,
    .register-container,
    .post-form-container,
    .profile-container {
        padding-left: 18px !important;
        padding-right: 18px !important;
    }

    .content-card,
    .post-detail,
    .post-form-container,
    .profile-container,
    .login-container,
    .register-container {
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08) !important;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important;
        gap: 12px !important;
    }

    .stat-card {
        padding: 16px !important;
    }

    .stat-value {
        font-size: 26px !important;
    }

    .admin-header .container {
        flex-direction: column !important;
        gap: 8px !important;
    }

    .admin-info {
        width: 100%;
        justify-content: flex-start;
        gap: 8px !important;
    }

    .tab-nav {
        top: 92px !important;
    }

    .admin-header + .tab-nav + .main-content,
    .tab-nav + .main-content {
        padding-top: 150px !important;
    }

    .chat-container .header .container,
    .chat-container {
        width: 100% !important;
    }

    .chat-container .chat-messages {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .chat-container .chat-input-area {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .modal-content,
    .dialog,
    .popup {
        max-width: calc(100vw - 20px) !important;
        max-height: calc(100dvh - 24px);
        overflow-y: auto;
    }
}

@media (max-width: 420px) {
    body .header .header-nav {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    body .header .nav a {
        font-size: 11px !important;
        padding-left: 6px !important;
        padding-right: 6px !important;
    }

    body .main-content {
        padding-top: 112px !important;
    }

    .message-content,
    .comment-content,
    .post-content {
        font-size: 14px;
    }
}
