/* ============================================
   MOBILE RESPONSIVE STYLES FOR MAIN APP
   ============================================ */

/* 确保所有页面都有viewport meta标签的效果 */
html {
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 触摸设备优化 */
* {
    -webkit-tap-highlight-color: transparent;
}

/* ============================================
   Tablet View (768px - 1023px)
   ============================================ */
@media (max-width: 1023px) {
    .sidebar {
        width: 240px;
    }

    .main-content {
        margin-left: 240px;
    }

    .header-container {
        padding: 1rem 1.5rem;
        flex-wrap: wrap;
    }

    .search-input {
        max-width: 300px;
    }

    /* 按钮响应式 */
    .header-container>div {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    /* 表格横向滚动 */
    .data-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    .data-table thead,
    .data-table tbody,
    .data-table tr {
        display: table;
        width: 100%;
        table-layout: fixed;
    }
}

/* 移动端专用按钮默认隐藏 */
.mobile-filter-toggle {
    display: none;
}

/* ============================================
   Mobile View (< 768px)
   ============================================ */
@media (max-width: 767px) {

    /* === 移动端筛选切换按钮 === */
    .mobile-filter-toggle {
        display: flex !important;
        align-items: center;
        gap: 0.3rem;
        white-space: nowrap;
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
    }

    /* === 筛选区默认折叠 === */
    .filters-container {
        display: none !important;
    }

    /* 筛选展开状态 */
    .filters-expanded .filters-container {
        display: flex !important;
    }

    /* 分数筛选栏默认折叠，展开后显示 */
    .table-wrapper>div:first-child {
        display: none !important;
    }

    .card.sticky-header.filters-expanded~.table-wrapper>div:first-child {
        display: flex !important;
    }

    /* header 中非核心按钮隐藏 */
    #filterPanelTrigger {
        display: none !important;
    }

    /* === Layout Adjustments === */
    body {
        padding: 0;
        overflow-x: hidden;
    }

    .container {
        padding: 0.5rem;
        max-width: 100%;
    }

    .app-container {
        flex-direction: column;
    }

    /* === 免责声明横幅 === */
    body>div:first-child,
    .disclaimer-banner {
        font-size: 0.75rem !important;
        padding: 6px 10px !important;
    }

    /* === 首页（分类选择页）移动端适配 === */
    .selection-container {
        flex-direction: column;
        padding: 1rem;
        gap: 1.5rem;
    }

    .selection-card {
        width: 100%;
        min-height: auto;
        padding: 2rem 1.5rem;
    }

    .hero-title {
        font-size: 1.75rem;
        padding: 0 1rem;
    }

    .hero-subtitle {
        font-size: 1rem;
        padding: 0 1rem;
    }

    .card-title {
        font-size: 1.5rem;
    }

    .card-desc {
        font-size: 0.9rem;
    }

    /* === Hide desktop sidebar, show mobile hamburger menu === */
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        width: 280px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.3);
    }

    .sidebar.mobile-open {
        left: 0;
    }

    /* Mobile overlay when sidebar is open */
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .mobile-overlay.active {
        display: block;
        opacity: 1;
    }

    /* Main content takes full width */
    .main-content {
        margin-left: 0;
        width: 100%;
    }

    /* === Mobile Header === */
    .header-container {
        padding: 0.5rem;
        flex-wrap: wrap;
        gap: 0.4rem;
        border-radius: 8px;
        margin-bottom: 0.75rem;
    }

    .header-content {
        width: 100%;
        order: 2;
        padding: 0 0.25rem;
    }

    .header-title {
        font-size: 1rem;
        margin-bottom: 0.15rem;
    }

    .header-subtitle {
        font-size: 0.7rem;
    }

    /* 头部按钮组 - 紧凑排列 */
    .header-container>div:last-child {
        width: auto;
        order: 3;
        display: flex;
        flex-wrap: wrap;
        gap: 0.3rem;
        justify-content: flex-end;
    }

    /* 当前用户和学生信息 - 极度压缩 */
    #currentUser {
        font-size: 0.7rem !important;
        padding: 2px 5px !important;
        max-width: 65px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    #currentStudent {
        font-size: 0.7rem !important;
    }

    /* Hamburger Menu Button */
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        background: var(--surface-color);
        border: none;
        border-radius: var(--radius-md);
        color: var(--text-primary);
        cursor: pointer;
        font-size: 1.2rem;
        order: 1;
        flex-shrink: 0;
    }

    .mobile-menu-btn:active {
        background: var(--secondary-hover);
    }

    /* Header中的按钮压缩 */
    .header-container .btn-icon {
        width: 34px;
        height: 34px;
        min-width: 34px;
        padding: 0.3rem;
        font-size: 1rem;
    }

    .header-container .btn-secondary,
    .header-container .btn-primary {
        font-size: 0.75rem;
        padding: 0.3rem 0.5rem;
        min-height: 34px;
        gap: 0.2rem;
    }

    /* 隐藏次要按钮的文字，只显示图标 */
    .header-container .btn-secondary .icon,
    .header-container .btn-primary .icon {
        margin-right: 0;
    }

    /* === Search Bar === */
    .search-container {
        width: 100%;
        order: 10;
    }

    .search-input {
        max-width: none;
        width: 100%;
    }

    /* 搜索输入组 - 压缩 */
    .card.sticky-header {
        padding: 0.75rem;
        margin-bottom: 0.75rem !important;
    }

    .card.sticky-header .input-group {
        margin-bottom: 0 !important;
    }

    /* 筛选展开后恢复间距 */
    .card.sticky-header.filters-expanded .input-group {
        margin-bottom: 0.75rem !important;
    }

    .input-field {
        font-size: 1rem;
        /* 防止iOS自动放大 */
        padding: 0.75rem 0.75rem 0.75rem 2.25rem;
    }

    /* === Navigation Tabs === */
    .navigation-tabs {
        width: 100%;
        order: 5;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .navigation-tabs::-webkit-scrollbar {
        height: 2px;
    }

    /* === Filters 筛选器移动端 === */
    .filters-container {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0;
    }

    .filters-container .select-field {
        width: 100%;
        font-size: 1rem;
        /* 防止iOS缩放 */
        padding: 0.65rem 2rem 0.65rem 1rem;
    }

    .filters-container .btn {
        width: 100%;
        justify-content: center;
    }

    .filter-group {
        width: 100%;
    }

    .filter-group label {
        display: block;
        margin-bottom: 0.5rem;
        font-size: 0.875rem;
    }

    .filter-group select,
    .filter-group input {
        width: 100%;
        font-size: 1rem;
        /* Prevent iOS zoom */
    }

    /* 专业筛选按钮全宽 */
    .major-filter-container {
        width: 100%;
    }

    .major-filter-container .select-field,
    #majorFilterTrigger {
        width: 100% !important;
        min-width: unset !important;
    }

    /* 普通类/预科班 checkbox组 */
    .checkbox-filter-group {
        width: 100%;
        gap: 0.75rem;
        padding: 0.6rem 0.75rem;
        justify-content: center;
    }

    /* 收藏筛选、重置按钮 */
    .filters-container>.btn {
        width: 100%;
    }

    /* === 分数筛选栏移动端 === */
    .table-wrapper>div:first-child {
        padding: 0.75rem !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    .table-wrapper>div:first-child>div {
        width: 100%;
    }

    .table-wrapper>div:first-child>div:first-child strong {
        font-size: 0.85rem !important;
    }

    .table-wrapper>div:first-child .form-input {
        width: 80px !important;
        font-size: 1rem;
    }

    .table-wrapper>div:first-child .btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.85rem;
    }

    /* === Table to Card Layout === */
    .data-container {
        padding: 0.5rem;
    }

    /* === Main Data Table Mobile Optimization (Fixed Rank Column) === */
    /* 隐藏表头 */
    .major-group-table thead {
        display: none;
    }

    .major-group-table tbody {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    /* 卡片容器 - Grid 3 Columns: [Rank(Auto)] [Main(1fr)] [Right(Auto)] */
    .major-group-table tr.major-group-row {
        display: grid;
        grid-template-columns: auto 1fr auto;
        gap: 0.5rem 0.75rem;
        background: var(--surface-color);
        padding: 1rem;
        border-radius: 12px;
        border: 1px solid var(--border-color);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
        position: relative;
    }

    .major-group-table tr.major-group-row>td {
        display: block;
        padding: 0 !important;
        border: none !important;
    }

    /* 1. Rank (序号) - 左上角 */
    .major-group-table tr.major-group-row>td:nth-child(1) {
        grid-column: 1;
        grid-row: 1;
        font-size: 0.9rem;
        color: var(--text-secondary);
        font-family: monospace;
        margin-top: 4px;
        /* Align with Uni Name */
    }

    /* 2. 院校信息 (Logo/Name/Tags) - 占据第一行右侧 */
    .university-info-cell {
        grid-column: 2 / 4;
        grid-row: 1;
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
        padding-right: 2.5rem !important;
        /* Avoid overlap with Favorite btn */
        border-bottom: 1px solid var(--border-color) !important;
        padding-bottom: 0.75rem !important;
        margin-bottom: 0.5rem;
    }

    .university-info-cell>div:first-child {
        font-size: 1.05rem !important;
        font-weight: 700;
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        line-height: 1.3;
    }

    .university-info-cell>div:last-child {
        font-size: 0.8rem !important;
    }

    /* 3. 专业组信息 (组号/选科) - 第二行左侧 */
    .major-group-info-cell {
        grid-column: 1 / 3;
        grid-row: 2;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .major-group-info-cell>div:first-child {
        font-size: 0.95rem !important;
        color: var(--primary-color);
        font-weight: 700 !important;
        display: flex;
        align-items: center;
    }

    .major-group-info-cell>div:last-child {
        font-size: 0.8rem !important;
        color: var(--text-secondary);
        opacity: 0.9;
        margin-top: 2px;
    }

    /* 选科要求前缀 */
    .major-group-info-cell>div:last-child::before {
        content: '选科: ';
        opacity: 0.7;
    }

    /* 4. 系数 - 第二行右侧 */
    .major-group-table tr.major-group-row>td:nth-child(4) {
        grid-column: 3;
        grid-row: 2;
        align-self: end;
        /* Bottom align with group info */
        justify-self: end;
        font-size: 0.9rem;
        font-weight: 700;
        text-align: right;
    }

    .major-group-table tr.major-group-row>td:nth-child(4)::after {
        content: ' (系数)';
        font-size: 0.7rem;
        color: var(--text-secondary);
        font-weight: normal;
        display: block;
    }

    /* 5. 2025数据 - 第三行 (Banner Style) */
    .major-group-table tr.major-group-row>td:nth-child(5) {
        grid-column: 1 / 4;
        grid-row: 3;
        background: rgba(59, 130, 246, 0.08);
        padding: 0.6rem 0.75rem !important;
        border-radius: 8px;
        margin-top: 0.25rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .major-group-table tr.major-group-row>td:nth-child(5)::before {
        content: '2025';
        font-weight: 700;
        color: var(--primary-color);
        font-size: 0.9rem;
    }

    /* 修正年份数据内部 div 排列 */
    .year-data-cell {
        display: flex;
        align-items: center;
        width: 100%;
        justify-content: flex-end;
        /* Align right like others */
        gap: 0.5rem;
    }

    .major-group-table tr.major-group-row>td:nth-child(5) .year-data-cell {
        width: auto;
        /* Let flex handle spacing */
    }

    /* 6. 2024数据 - 第四行左侧 */
    .major-group-table tr.major-group-row>td:nth-child(6) {
        grid-column: 1 / 3;
        grid-row: 4;
        padding-top: 0.5rem !important;
        display: flex;
        align-items: center;
        color: var(--text-secondary);
        font-size: 0.85rem;
    }

    .major-group-table tr.major-group-row>td:nth-child(6)::before {
        content: '2024: ';
        margin-right: 4px;
        font-size: 0.8rem;
    }

    /* 7. 2023数据 - 第四行右侧 */
    .major-group-table tr.major-group-row>td:nth-child(7) {
        grid-column: 3;
        grid-row: 4;
        padding-top: 0.5rem !important;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        color: var(--text-secondary);
        font-size: 0.85rem;
    }

    .major-group-table tr.major-group-row>td:nth-child(7)::before {
        content: '2023: ';
        margin-right: 4px;
        font-size: 0.8rem;
    }

    /* 8. 查询列 - 移动端隐藏(节省空间) */
    .major-group-table tr.major-group-row>td:nth-child(8) {
        display: none !important;
    }

    /* 9. 收藏按钮 - 绝对定位右上角 */
    .major-group-table tr.major-group-row>td:last-child {
        position: absolute;
        top: 0.75rem;
        right: 0.75rem;
        width: auto !important;
        padding: 0 !important;
        z-index: 2;
    }

    .favorite-box {
        padding: 0.3rem 0.5rem !important;
    }

    /* 优化间距和边框 */
    .university-card-header {
        display: none;
        /* 或者是移除旧逻辑 */
    }

    .university-card-title {
        font-size: 1rem;
        font-weight: 600;
        color: var(--text-primary);
        margin-bottom: 0.25rem;
    }

    .university-card-code {
        font-size: 0.75rem;
        color: var(--text-secondary);
        opacity: 0.7;
    }

    .university-card-body {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .card-field {
        display: flex;
        flex-direction: column;
    }

    .card-field-label {
        font-size: 0.7rem;
        color: var(--text-secondary);
        opacity: 0.7;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin-bottom: 0.25rem;
    }

    .card-field-value {
        font-size: 0.95rem;
        color: var(--text-primary);
        font-weight: 500;
    }

    .card-field-value.highlight {
        color: var(--accent-color);
        font-weight: 600;
    }

    /* === Major Details on Mobile - 卡片化 === */
    /* 修复默认展开问题：基于 .expanded 类控制 */
    .major-details-row {
        display: none !important;
    }

    .major-details-row.expanded {
        display: block !important;
    }

    /* 详情行不参与主卡片布局，避免被 nth-child/absolute 定位规则污染 */
    .major-group-table tr.major-details-row {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
    }

    .major-group-table tr.major-details-row>td {
        position: static !important;
        width: 100% !important;
        padding: 0.5rem 0 !important;
    }

    .expanded-details-cell {
        padding: 0.5rem !important;
        background: transparent !important;
    }

    .expanded-details-content {
        padding: 0 !important;
        background: transparent !important;
    }

    /* 标题栏精简 */
    .expanded-details-title {
        font-size: 0.85rem !important;
        margin: 0.5rem 0.25rem;
        color: var(--text-secondary);
        font-weight: normal;
    }

    .inner-major-table tbody {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    /* 使用 Grid 布局重构卡片 (新版) */
    .inner-major-table tr,
    .three-year-table tr {
        display: grid !important;
        grid-template-columns: auto 1fr;
        gap: 0.5rem 1rem;
        padding: 1rem;
        background: var(--surface-color);
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        border: 1px solid var(--border-color);
        margin: 0 0.25rem;
        position: relative;
    }

    .inner-major-table td,
    .three-year-table td {
        display: block;
        padding: 0 !important;
        border: none !important;
    }

    /* 1. 专业代码: 左上角 */
    .inner-major-table td:nth-child(1) {
        grid-column: 1;
        grid-row: 1;
        font-family: monospace;
        color: var(--text-secondary);
        font-size: 0.85rem;
        margin-top: 2px;
    }

    /* 2. 专业名称: 顶部，右侧预留收藏按钮空间 */
    .inner-major-table td:nth-child(2) {
        grid-column: 2;
        grid-row: 1;
        font-weight: 600;
        font-size: 1rem;
        color: var(--text-primary);
        line-height: 1.4;
        margin-bottom: 0.5rem;
        padding-right: 40px !important;
    }

    /* 12. 收藏按钮: 右上角绝对定位/Grid重叠 */
    .inner-major-table td:nth-child(12) {
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
        align-self: start;
        margin-top: -4px;
        margin-right: -4px;
    }

    /* === 数据行通用样式 === */
    /* Stat 列 (录/计) */
    .inner-major-table td:nth-child(3),
    .inner-major-table td:nth-child(5),
    .inner-major-table td:nth-child(7) {
        grid-column: 1;
        font-size: 0.8rem;
        color: var(--text-secondary);
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    /* Score 列 (分/位) */
    .inner-major-table td:nth-child(4),
    .inner-major-table td:nth-child(6),
    .inner-major-table td:nth-child(8) {
        grid-column: 2;
        font-size: 0.9rem;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    /* === 2025年数据 (Row 2) - 高亮 === */
    .inner-major-table td:nth-child(3) {
        grid-row: 2;
    }

    .inner-major-table td:nth-child(4) {
        grid-row: 2;
    }

    .inner-major-table td:nth-child(3)::before {
        content: '2025';
        font-weight: 700;
        color: var(--primary-color);
        margin-bottom: 2px;
    }

    .inner-major-table td:nth-child(4) {
        color: var(--primary-color);
        font-weight: 600;
    }

    /* === 2024年数据 (Row 3) === */
    .inner-major-table td:nth-child(5) {
        grid-row: 3;
    }

    .inner-major-table td:nth-child(6) {
        grid-row: 3;
    }

    .inner-major-table td:nth-child(5)::before {
        content: '2024';
        margin-bottom: 2px;
    }

    /* === 2023年数据 (Row 4) === */
    .inner-major-table td:nth-child(7) {
        grid-row: 4;
    }

    .inner-major-table td:nth-child(8) {
        grid-row: 4;
    }

    .inner-major-table td:nth-child(7)::before {
        content: '2023';
        margin-bottom: 2px;
        opacity: 0.8;
    }

    /* 内部数据微调 */
    .year-cell-stat div,
    .year-cell-score div {
        display: block;
        line-height: 1.4;
    }

    .year-cell-stat div {
        display: inline-block;
        margin-right: 0.4rem;
    }

    .year-cell-score div {
        white-space: normal;
    }

    /* === 底部标签 (Row 5) === */
    .inner-major-table td:nth-child(9),
    .inner-major-table td:nth-child(10),
    .inner-major-table td:nth-child(11) {
        grid-row: 5;
        grid-column: 1 / 3;
        display: inline-block !important;
        width: auto;
        font-size: 0.75rem;
        background: var(--bg-hover);
        /* 使用灰色背景 */
        padding: 2px 8px !important;
        border-radius: 4px;
        margin-right: 0.5rem;
        margin-top: 0.5rem;
        color: var(--text-secondary);
        border: 1px solid var(--border-color);
    }

    .inner-major-table td:nth-child(9) {
        grid-column: 1 / 3;
        justify-self: start;
    }

    .inner-major-table td:nth-child(10) {
        grid-column: 1 / 3;
        justify-self: start;
        margin-left: 3.5rem;
    }

    .inner-major-table td:nth-child(11) {
        display: none !important;
    }

    /* 备注行 */
    .inner-major-table tr:has(td[colspan]) {
        display: block !important;
        padding: 0.75rem;
        margin-top: -0.5rem;
        margin-bottom: 0.75rem;
    }

    /* Three Year Table优化 */
    .three-year-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .three-year-table th,
    .three-year-table td {
        font-size: 0.75rem !important;
        padding: 0.35rem !important;
        white-space: nowrap;
    }

    /* === Stats Overview === */
    .stats-overview {
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem;
    }

    .stat-card {
        width: 100%;
    }

    /* === Action Buttons === */
    .action-buttons {
        padding: 0.75rem;
        gap: 0.4rem;
        position: sticky;
        bottom: 0;
        background: var(--background-color);
        border-top: 1px solid var(--border-color);
        z-index: 10;
        flex-wrap: wrap;
    }

    .btn {
        min-height: 40px;
        /* Touch-friendly */
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
        flex: 1 1 auto;
        min-width: 80px;
    }

    .btn-icon {
        min-width: 40px;
        width: 40px;
        height: 40px;
        padding: 0.5rem;
        font-size: 1.1rem;
        flex: 0 0 auto;
    }

    .btn-primary,
    .btn-secondary {
        white-space: nowrap;
    }

    /* 隐藏一些次要按钮的文字，只显示图标 */
    .btn .icon {
        margin-right: 0;
    }

    /* === 筛选面板移动端优化 === */
    .filter-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1001;
        background: var(--background-color);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .filter-panel-content {
        max-width: 100%;
        margin: 0;
        border-radius: 0;
    }

    /* === 专业分类面板移动端全屏优化 === */
    .major-category-panel {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        min-width: unset !important;
        max-height: 100vh !important;
        margin-top: 0 !important;
        border-radius: 0 !important;
        z-index: 1100 !important;
        transform: none !important;
    }

    .major-category-panel .panel-content {
        flex-direction: column;
        height: calc(100vh - 120px);
        /* 扣除header和footer */
    }

    .major-category-panel .category-list {
        width: 100% !important;
        height: auto !important;
        max-height: 130px;
        border-right: none !important;
        border-bottom: 1px solid var(--border-color);
        display: flex;
        flex-wrap: wrap;
        overflow-y: auto;
    }

    .major-category-panel .category-item {
        flex: 0 0 auto;
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .major-category-panel .major-list {
        flex: 1;
        overflow-y: auto;
    }

    .major-category-panel .panel-footer {
        position: sticky;
        bottom: 0;
        padding: 0.75rem;
    }

    /* === Compare Panel 对比面板移动端 === */
    .compare-panel {
        width: 100% !important;
        max-width: 100% !important;
        bottom: 0 !important;
        left: 0 !important;
        transform: none !important;
        border-radius: 12px 12px 0 0 !important;
        padding: 0.75rem !important;
    }

    .compare-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start !important;
    }

    .compare-header h3 {
        font-size: 0.95rem !important;
    }

    .compare-actions {
        width: 100%;
        justify-content: space-between;
    }

    .compare-items {
        gap: 0.5rem;
    }

    .compare-tag {
        font-size: 0.75rem;
        padding: 0.35rem 0.5rem;
    }

    /* === Charts === */
    #trendChart {
        height: 250px !important;
    }

    /* === Modals 弹窗全屏 === */
    .modal {
        padding: 0;
    }

    .modal-content {
        width: 100%;
        max-width: 100%;
        max-height: 100vh;
        margin: 0;
        padding: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .modal-overlay .modal-content,
    .compare-modal {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
        max-height: 100vh !important;
    }

    .modal-header {
        padding: 0.75rem 1rem;
        position: sticky;
        top: 0;
        background: var(--surface-color);
        z-index: 10;
        border-bottom: 1px solid var(--border-color);
    }

    .modal-header h2 {
        font-size: 1rem;
    }

    .modal-body {
        padding: 1rem;
        max-height: calc(100vh - 80px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-footer {
        padding: 0.75rem 1rem;
        position: sticky;
        bottom: 0;
        background: var(--surface-color);
        border-top: 1px solid var(--border-color);
    }

    /* 关闭按钮 */
    .close-btn,
    .modal-close {
        width: 36px;
        height: 36px;
        font-size: 1.5rem;
    }

    /* 专业介绍弹窗 */
    .major-intro-modal .modal-content {
        padding: 0;
    }

    .major-intro-header {
        font-size: 1rem;
    }

    .major-intro-section {
        padding: 1rem;
    }

    .major-intro-section h3 {
        font-size: 0.95rem;
    }

    .major-intro-text {
        font-size: 0.85rem;
        line-height: 1.6;
    }

    /* === 学生管理模态框 === */
    .student-modal .modal-content {
        max-height: 100vh;
    }

    .student-list {
        gap: 0.75rem;
    }

    .student-card {
        padding: 1rem;
    }

    .student-card-header {
        font-size: 1rem;
    }

    .student-card-info {
        font-size: 0.85rem;
        gap: 0.5rem;
    }

    /* 学生表单 */
    .student-form .form-group {
        margin-bottom: 1rem;
    }

    .student-form input,
    .student-form select {
        font-size: 1rem;
        padding: 0.75rem;
    }

    .student-form label {
        font-size: 0.9rem;
    }

    /* === 登录页面移动端适配 === */
    .login-container {
        padding: 1rem;
        max-width: 100%;
    }

    .login-card {
        padding: 2rem 1.5rem;
        border-radius: 16px;
    }

    .login-title {
        font-size: 1.5rem;
    }

    .login-subtitle {
        font-size: 0.9rem;
    }

    .login-form .form-group {
        margin-bottom: 1.25rem;
    }

    .login-form input {
        font-size: 1rem;
        padding: 0.875rem 1rem;
        height: auto;
    }

    .login-form label {
        font-size: 0.9rem;
    }

    .login-btn {
        height: 48px;
        font-size: 1rem;
    }

    .login-footer {
        font-size: 0.8rem;
        margin-top: 1.5rem;
    }

    /* === 收藏页面移动端适配 === */
    .favorites-container {
        padding: 0.5rem;
    }

    .favorite-item {
        padding: 1rem;
    }

    .favorite-item-header {
        font-size: 0.95rem;
    }

    .favorite-item-info {
        font-size: 0.8rem;
    }

    /* === 统计卡片 === */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    /* === 收藏页 group-header 移动端 === */
    .card[style*="display: flex"] {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    /* 排序控件紧凑布局 */
    .order-input {
        width: 40px !important;
        font-size: 0.85rem !important;
    }

    .order-btn {
        padding: 2px 4px !important;
        font-size: 11px !important;
    }

    /* 收藏页 inner table 横向滚动 */
    .card table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .card table thead,
    .card table tbody {
        display: table;
        width: 100%;
    }

    .card table th,
    .card table td {
        padding: 0.4rem 0.35rem !important;
        font-size: 0.75rem !important;
        white-space: nowrap;
    }

    /* 收藏页操作按钮区域 */
    .export-dropdown {
        position: relative !important;
    }

    /* === students.html 考生管理页 === */
    .students-grid {
        grid-template-columns: 1fr !important;
    }

    /* 表单 form-row 单列排列 */
    .form-row {
        grid-template-columns: 1fr !important;
    }

    /* 考生管理页面标题区域 */
    .card .header-container,
    .students-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start !important;
    }

    /* === Reduce animations on mobile for performance === */
    * {
        animation-duration: 0.2s !important;
        transition-duration: 0.2s !important;
    }

    /* === Touch optimizations === */
    .card,
    .btn,
    .selection-card,
    .category-card {
        -webkit-tap-highlight-color: rgba(96, 165, 250, 0.1);
    }

    /* === Remove hover effects on touch devices === */
    @media (hover: none) {

        .card:hover,
        .btn:hover,
        .stat-card:hover {
            transform: none !important;
            box-shadow: var(--shadow-md);
        }
    }

    /* === 收藏页操作按钮区域移动端 === */
    div[style*="justify-content: center"].no-print {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.5rem !important;
    }

    div[style*="justify-content: center"].no-print .btn {
        width: 100%;
        justify-content: center;
    }

    /* 收藏页 group-header 内部优化 */
    .group-header {
        flex-wrap: wrap !important;
    }

    .group-header>div {
        flex-wrap: wrap !important;
    }

    /* === students.html 考生信息 === */
    .student-info {
        grid-template-columns: 1fr !important;
    }

    .student-card {
        padding: 1rem !important;
    }

    .student-name {
        font-size: 1.1rem !important;
    }

    .student-actions {
        flex-wrap: wrap;
    }

    .student-actions .btn {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
    }

    /* === Footer移动端 === */
    footer {
        padding: 1.5rem 0.75rem !important;
        font-size: 0.8rem;
    }

    footer p {
        font-size: 0.8rem;
    }
}

/* ============================================
   Small Mobile (< 480px)
   ============================================ */
@media (max-width: 479px) {
    .header-title {
        font-size: 0.9rem;
    }

    .header-subtitle {
        font-size: 0.65rem;
    }

    .university-card {
        padding: 0.875rem;
    }

    .university-card-body {
        grid-template-columns: 1fr;
    }

    .card-field-value {
        font-size: 0.9rem;
    }

    .filter-group select,
    .filter-group input {
        padding: 0.625rem;
        font-size: 1rem;
    }

    /* 按钮进一步压缩 */
    .btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
        min-height: 36px;
    }

    .btn-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    /* Header中的按钮更小 */
    .header-container .btn-icon {
        width: 30px;
        height: 30px;
        min-width: 30px;
        font-size: 0.9rem;
    }

    .header-container .btn-secondary,
    .header-container .btn-primary {
        font-size: 0.7rem;
        padding: 0.25rem 0.4rem;
        min-height: 30px;
    }

    /* 表格字体更小 */
    .data-table th,
    .data-table td {
        font-size: 0.75rem;
        padding: 0.4rem 0.3rem;
    }

    .university-info-cell {
        min-width: 160px;
    }

    .major-group-info-cell {
        min-width: 120px;
    }

    .year-data-cell {
        min-width: 90px;
    }

    /* 登录页面 */
    .login-card {
        padding: 1.5rem 1rem;
    }

    .login-title {
        font-size: 1.3rem;
    }

    /* 首页 */
    .hero-title {
        font-size: 1.5rem;
    }

    .hero-subtitle {
        font-size: 0.9rem;
    }

    .card-title {
        font-size: 1.3rem;
    }

    /* 专业分类面板小屏调整 */
    .major-category-panel .category-item {
        font-size: 0.75rem;
        padding: 0.4rem 0.6rem;
    }

    /* 收藏页小屏进一步压缩 */
    .card table th,
    .card table td {
        padding: 0.3rem 0.25rem !important;
        font-size: 0.7rem !important;
    }
}

/* ============================================
   Landscape mode on mobile
   ============================================ */
@media (max-width: 767px) and (orientation: landscape) {
    .modal-content {
        max-height: 95vh;
    }

    .header-container {
        padding: 0.3rem 0.5rem;
    }

    .btn {
        min-height: 34px;
        font-size: 0.8rem;
    }

    /* 横屏模式下专业面板优化 */
    .major-category-panel .panel-content {
        flex-direction: row !important;
        height: calc(100vh - 100px);
    }

    .major-category-panel .category-list {
        width: 160px !important;
        max-height: none !important;
        border-right: 1px solid var(--border-color) !important;
        border-bottom: none !important;
        flex-wrap: nowrap !important;
        flex-direction: column !important;
        overflow-y: auto !important;
    }
}