/* ============================================
   移动端样式（≤768px）+ 平板过渡（≤900px）
   ✅ 修复：补全 @media (max-width: 768px) 块的闭合大括号
   ============================================ */

/* ============================================
   平板过渡（≤900px）
   ============================================ */
@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
        padding: 0 16px;
    }
    .sidebar { margin-top: 24px; }
    .article-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
    .article-card.no-cover .article-card-title {
        font-size: 14px;
        min-height: 58px;
    }

    .nav-filter-group {
        margin-left: 4px;
        gap: 6px;
    }
    .nav-search input[type="text"] {
        width: 130px;
        font-size: 12px;
    }
    .nav-search input[type="text"]:focus {
        width: 160px;
    }
    .sort-dropdown-toggle {
        padding: 5px 10px;
        font-size: 12px;
        gap: 4px;
    }
    .sort-dropdown-toggle .sort-label {
        max-width: 60px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* ============================================
   移动端（≤768px）
   ============================================ */
@media (max-width: 768px) {

    .header {
        padding: 0 12px;
        position: sticky;
        top: 0;
        z-index: 100;
        background: #fff;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    }

    .header-inner {
        display: flex;
        justify-content: space-between;
        align-items: center;
        height: 56px;
        padding: 0;
        flex-wrap: nowrap;
        gap: 0;
    }

    .logo {
        font-size: 18px;
        flex-shrink: 0;
    }
    .logo a {
        display: block;
        padding: 4px 0;
    }

    .nav-toggle {
        display: flex;
        flex-shrink: 0;
        margin-left: auto;
    }

    .nav {
        display: none;
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        padding: 8px 14px 16px;
        gap: 0;
        overflow-y: auto;
        z-index: 99;
        border-top: 1px solid #f0f0f0;
        animation: slideDown 0.3s ease;
    }

    .nav.open {
        display: flex;
    }

    @keyframes slideDown {
        from { opacity: 0; transform: translateY(-10px); }
        to   { opacity: 1; transform: translateY(0); }
    }

    .nav > a {
        display: block;
        padding: 10px 12px;
        margin: 0;
        font-size: 15px;
        line-height: 1.4;
        border-radius: 8px;
        text-align: left;
        width: 100%;
        box-sizing: border-box;
        color: #333;
        text-decoration: none;
        transition: background 0.2s;
        border-bottom: 1px solid #f5f7fa;
    }
    .nav > a:last-child {
        border-bottom: none;
    }
    .nav > a:hover {
        background: #f5f7fa;
    }
    .nav > a.active {
        background: #667eea;
        color: #fff;
    }
    .nav > a.active:hover {
        background: #5a6fd6;
    }
    .nav > a.login-link {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: #fff !important;
        padding: 10px 16px !important;
        border-radius: 20px;
        font-weight: 500;
        margin-top: 6px;
        border-bottom: none;
        text-align: center;
    }
    .nav > a.logout-link {
        color: #e74c3c;
        margin-top: 6px;
        border-top: 1px solid #f0f0f0;
        padding-top: 12px;
    }

    .nav-user {
        display: flex;
        width: 100%;
        padding: 10px 12px;
        border-radius: 10px;
        background: #f5f7fa;
        border: 1px solid #e8ecf1;
        justify-content: flex-start;
        margin-top: 8px;
        text-decoration: none;
        color: #333;
        align-items: center;
        gap: 8px;
    }
    .nav-user-avatar {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        object-fit: cover;
        border: 2px solid #fff;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        flex-shrink: 0;
        background: #f0f0f0;
    }
    .nav-user-name {
        max-width: none;
        flex: 1;
        font-size: 14px;
        font-weight: 500;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .nav-user-role {
        font-size: 11px;
        padding: 2px 8px;
        border-radius: 8px;
        font-weight: 500;
        flex-shrink: 0;
    }
    .nav-user-role.role-developer { background: #fff3cd; color: #856404; }
    .nav-user-role.role-author    { background: #d1ecf1; color: #0c5460; }
    .nav-user-role.role-member    { background: #d4edda; color: #155724; }

    .nav-filter-group {
        display: flex;
        align-items: center;
        gap: 8px;
        margin: 0 0 8px 0;
        padding: 0 0 8px 0;
        border-bottom: 1px solid #f0f0f0;
        order: -1;
        width: 100%;
    }

    .nav-search {
        flex: 1;
        min-width: 0;
        position: relative;
    }
    .nav-search input[type="text"] {
        width: 100%;
        padding: 9px 34px 9px 12px;
        font-size: 15px;
        border-radius: 10px;
        border: 2px solid #e8e8e8;
        box-sizing: border-box;
        outline: none;
    }
    .nav-search input[type="text"]:focus {
        width: 100%;
        border-color: #667eea;
    }
    .nav-search button {
        position: absolute;
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
        background: none;
        border: none;
        cursor: pointer;
        font-size: 15px;
        padding: 0;
        line-height: 1;
        color: #888;
    }
    .nav-search-clear {
        position: absolute;
        right: 32px;
        top: 50%;
        transform: translateY(-50%);
        color: #e74c3c;
        font-size: 17px;
        text-decoration: none;
        line-height: 1;
    }

    .sort-dropdown {
        flex-shrink: 0;
    }
    .sort-dropdown-toggle {
        padding: 9px 12px;
        font-size: 14px;
        border-radius: 10px;
        background: #f8f9fa;
    }
    .sort-dropdown-toggle .sort-label {
        max-width: 56px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .sort-dropdown-menu {
        right: 0;
        left: auto;
        min-width: 180px;
    }
    .sort-dropdown-item {
        padding: 11px 14px;
        font-size: 15px;
    }

    .main-content {
        grid-template-columns: 1fr;
        padding: 0 12px;
        gap: 20px;
        display: block;
    }
    .sidebar {
        display: block;
        margin-top: 24px;
    }
    .main-content > .sidebar-widget-featured {
        margin-bottom: 20px;
    }

    .article-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }
    .article-card {
        border-radius: 10px;
    }
    .article-card-cover {
        aspect-ratio: 16 / 10;
    }
    .article-card-title {
        padding: 10px 10px 4px;
        font-size: 13px;
        -webkit-line-clamp: 2;
        word-break: break-word;
        overflow-wrap: break-word;
    }
    .article-card.no-cover .article-card-title {
        font-size: 14px;
        min-height: 56px;
        padding-top: 12px;
    }
    .article-card-footer {
        padding: 4px 10px 10px;
        gap: 6px;
    }
    .article-author {
        font-size: 11px;
        gap: 4px;
    }
    .article-author-avatar {
        width: 16px;
        height: 16px;
    }
    .article-author-name {
        max-width: 55px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .article-stat {
        font-size: 10px;
        gap: 5px;
    }
    .article-tags {
        gap: 3px;
        max-height: 18px;
    }
    .article-tags .tag {
        font-size: 10px;
        padding: 1px 6px;
    }
    .article-card-actions {
        padding: 8px 10px 10px;
        gap: 4px;
    }
    .article-card-actions .btn-sm {
        padding: 2px 8px;
        font-size: 10px;
    }

    .pagination {
        padding: 14px 0;
    }
    .pagination a,
    .pagination span {
        font-size: 13px;
        padding: 5px 12px;
    }

    .container {
        padding: 0 12px;
    }

    .auth-container {
        padding: 30px 20px;
        margin: 10px;
    }
    .auth-container h1 { font-size: 22px; }
    .auth-container .subtitle { font-size: 13px; }
    .form-group input { padding: 10px 14px; font-size: 16px; }
    .btn-primary { padding: 12px; font-size: 15px; }
    .code-group button { padding: 0 14px; font-size: 13px; }

    .profile-page {
        margin: 16px auto;
        padding: 0 12px;
    }
    .profile-card { padding: 20px; }
    .profile-header {
        flex-direction: column;
        text-align: center;
        gap: 16px;
    }
    .profile-avatar { width: 80px; height: 80px; }
    .profile-name { font-size: 20px; }
    .profile-section h3 { font-size: 16px; }

    .article-page {
        margin: 16px auto;
        padding: 0 12px;
        overflow-x: hidden;
    }
    .article-detail {
        padding: 20px;
        overflow-x: hidden;
        max-width: 100%;
    }
    .article-title {
        font-size: 20px;
        word-break: break-word;
        overflow-wrap: break-word;
        line-height: 1.4;
    }
    .article-meta {
        font-size: 13px;
        gap: 8px;
        word-break: break-word;
        overflow-wrap: break-word;
    }

    .article-body {
        font-size: 15px;
        line-height: 1.7;
        word-break: break-word;
        overflow-wrap: break-word;
        max-width: 100%;
    }
    .article-body img,
    .article-body video,
    .article-body iframe {
        max-width: 100% !important;
        height: auto !important;
    }
    .article-body pre {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .article-body pre code {
        word-break: normal;
        white-space: pre;
    }
    .article-body table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .article-body a {
        word-break: break-all;
    }
    .article-body p,
    .article-body li,
    .article-body blockquote {
        word-break: break-word;
        overflow-wrap: break-word;
    }

    .comment-item { padding: 12px 0; }
    .comment-header { flex-wrap: wrap; }
    .comment-header img { width: 28px; height: 28px; }
    .comment-content {
        margin-left: 38px;
        font-size: 14px;
        word-break: break-word;
        overflow-wrap: break-word;
    }
    .comment-user {
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .comment-actions { margin-left: 38px; }
    .sub-comments { margin-left: 20px; padding-left: 12px; }
    .reply-form { margin-left: 20px; }
    .reply-form textarea { min-height: 50px; font-size: 14px; }

    .recycle-page { margin: 16px auto; padding: 0 12px; }
    .recycle-card { padding: 20px; }
    .recycle-item { flex-direction: column; align-items: stretch; }
    .recycle-item .info .title { font-size: 15px; }
    .recycle-item .actions { justify-content: flex-end; }

    .publish-page { margin: 16px auto; padding: 0 12px; }
    .publish-card { padding: 20px; }
    .publish-card h1 { font-size: 20px; }
    .form-row { grid-template-columns: 1fr; gap: 12px; }
    .form-group textarea { min-height: 200px; font-size: 14px; }

    .admin-page { padding: 0 12px; margin: 12px auto; }
    .admin-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 12px 16px;
    }
    .admin-header h1 { font-size: 20px; }
    .admin-tabs {
        flex-wrap: wrap;
        gap: 4px;
        padding: 4px;
    }
    .admin-tabs .tab {
        padding: 6px 12px;
        font-size: 12px;
        flex: 1 1 auto;
        text-align: center;
        min-width: 60px;
    }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 14px 16px; }
    .stat-card .number { font-size: 22px; }
    .admin-table { font-size: 12px; min-width: 600px; }
    .admin-table th,
    .admin-table td { padding: 6px 8px; }
    .admin-table th { font-size: 11px; }
    .admin-table td { font-size: 12px; }
    .admin-table .badge { font-size: 10px; padding: 1px 8px; }
    .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .form-inline { flex-direction: column; align-items: stretch; }
    .form-inline input,
    .form-inline select {
        width: 100%;
        box-sizing: border-box;
        font-size: 16px;
    }
    .form-inline .btn { width: 100%; text-align: center; }
    .profile-item-mini { padding: 10px 12px; }
    .comment-item-mini { padding: 8px 12px; }

    .footer {
        padding: 16px 12px 12px;
        margin: 20px auto 10px;
    }
    .footer-inner p { font-size: 12px; line-height: 2; }
    .footer-inner a { display: inline-block; }

    .tools-page {
        margin: 16px auto;
        padding: 0 12px;
    }
    .tools-header {
        padding: 20px;
        flex-direction: column;
        align-items: flex-start;
    }
    .tools-header .header-left h1 { font-size: 22px; }
    .tools-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    .tool-card { padding: 20px; }
    .tool-icon { font-size: 32px; }
    .tool-name { font-size: 17px; padding-right: 60px; }

    .announcements-page,
    .featured-page {
        margin: 16px auto;
        padding: 0 12px;
    }
    .announcement-item,
    .featured-item { padding: 16px; }
    .announcement-item .title,
    .featured-item .title { font-size: 16px; }

/* ✅ 修复：补全 @media (max-width: 768px) 块的闭合大括号 */
}

/* ============================================
   小屏 ≤480px
   ============================================ */
@media (max-width: 480px) {
    .logo { font-size: 16px; }
    .nav > a { padding: 10px 12px; font-size: 15px; }
    .auth-container { padding: 24px 16px; }
    .auth-container h1 { font-size: 20px; }

    .article-title {
        font-size: 19px;
        word-break: break-word;
        overflow-wrap: break-word;
    }
    .article-detail {
        padding: 14px;
        overflow-x: hidden;
    }
    .article-body {
        font-size: 14px;
        word-break: break-word;
        overflow-wrap: break-word;
    }

    .profile-card { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat-card { padding: 10px 14px; }
    .stat-card .number { font-size: 18px; }
    .stat-card .label { font-size: 12px; }

    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    .toast { font-size: 13px; padding: 10px 16px; }

    .article-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .article-card-title {
        font-size: 12px;
        padding: 8px 8px 2px;
    }
    .article-card.no-cover .article-card-title {
        font-size: 13px;
        min-height: 52px;
    }
    .article-card-footer {
        padding: 4px 8px 8px;
    }
    .article-author-avatar {
        width: 14px;
        height: 14px;
    }
    .article-stat {
        font-size: 9px;
        gap: 4px;
    }
    .article-tags .tag {
        font-size: 9px;
        padding: 1px 5px;
    }
    .sort-dropdown-toggle .sort-label {
        display: none;
    }
    .sort-dropdown-toggle {
        padding: 9px 12px;
    }
}

/* ============================================
   超小屏 ≤380px
   ============================================ */
@media (max-width: 380px) {
    .article-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
    .article-card-title {
        font-size: 11px;
        padding: 6px 6px 2px;
    }
    .article-card.no-cover .article-card-title {
        font-size: 12px;
        min-height: 46px;
    }
    .article-card-footer {
        padding: 3px 6px 6px;
    }
    .article-author-name {
        max-width: 45px;
    }
    .article-stat {
        font-size: 9px;
        gap: 3px;
    }
    .article-tags .tag {
        font-size: 9px;
        padding: 1px 4px;
    }
}