/* ============================================================
   移动端适配(统一响应式入口,加载顺序在 theme.css / extra.css 之后)
   断点:≤1024px 中屏收敛;≤768px 手机端整体布局改造
   手机端布局:左侧图标栏 → 底部 Tab 栏;顶栏压缩为两行 sticky;
   主数据表 → 卡片式列表;各弹层面板全屏化。
   ============================================================ */

/* 仅移动端可见的元素(如底部 Tab 的「志愿表」) */
.mobile-only { display: none; }
/* 卡片模式下的年份标签,桌面端隐藏(表头已有年份) */
.yr-tag { display: none; }
/* 底部 Tab 角标(桌面端隐藏) */
.nav-badge { display: none; }

/* ---------------- ≤1366px:窄桌面收敛 ---------------- */
@media (max-width: 1366px) {
  .legend { display: none; }
}

/* ---------------- ≤1024px:中屏收敛 ---------------- */
@media (max-width: 1024px) {
  .tb-tabs { display: none; }
}

/* ---------------- ≤768px:手机端 ---------------- */
@media (max-width: 768px) {
  :root { --rail-w: 0px; --nav-h: 56px; }

  body {
    padding-left: 0;
    padding-top: 0;
    /* 底部导航 + footer 信息条的空间 */
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 36px);
  }

  /* ===== 左侧图标栏 → 底部 Tab 栏 ===== */
  .rail {
    top: auto; left: 0; right: 0; bottom: 0;
    width: 100%;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    flex-direction: row;
    align-items: stretch;
    border-right: none;
    border-top: 1px solid var(--border);
    padding: 0 0 env(safe-area-inset-bottom);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.04);
    /* 高于院校库/详情/用户面板(150~170),低于志愿表抽屉(190/200):
       打开全屏面板时底部 Tab 仍可用于切换 */
    z-index: 180;
  }
  .rail-logo, .rail-avatar, .rail-spacer { display: none; }
  .rail-nav { flex-direction: row; width: 100%; gap: 0; }
  .rail-item { flex: 1; padding: 8px 0 5px; gap: 2px; font-size: 10px; }
  .rail-item svg { width: 22px; height: 22px; }
  .rail-item.active::before {
    left: 50%; top: 0; bottom: auto;
    transform: translateX(-50%);
    width: 30px; height: 3px;
    border-radius: 0 0 3px 3px;
  }
  .rail-item.mobile-only { display: flex; position: relative; }
  /* 底部 Tab 排序:志愿表(1) 智能填报(2) 工具箱(3) 用户(4) */
  .rail-item[data-action="drawer"] { order: 1; }
  .rail-item:not([data-action]) { order: 2; }
  .rail-item[data-action="lib"] { order: 3; }
  .rail-item[data-action="users"],
  body.role-student .rail-item[data-action="users"] { order: 4; margin-top: 0; }
  .nav-badge {
    display: flex; align-items: center; justify-content: center;
    position: absolute; top: 3px; left: calc(50% + 6px);
    min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 8px; background: var(--primary); color: #fff;
    font-size: 10px; font-weight: 700; line-height: 1;
  }

  /* ===== 顶栏:fixed 单行 → sticky 两行自适应 ===== */
  .topbar {
    position: sticky;
    top: 0; left: 0; right: 0;
    height: auto;
    flex-wrap: wrap;
    padding: 9px 12px;
    gap: 6px 8px;
  }
  .tb-back, .tb-divider { display: none; }
  /* 两行布局:1 标题+志愿表按钮 / 2 姓名+分数+位次+修改资料
     ::after 为宽 100% 的 flex 强制换行符 */
  .topbar::after { content: ""; width: 100%; height: 0; order: 1; }
  .tb-name {
    order: 0; flex: 1; min-width: 0;
    font-size: 14px;
    overflow: hidden; text-overflow: ellipsis;
  }
  .tb-name small { display: none; }
  .tb-right { order: 0; gap: 8px; }
  .tb-score { order: 2; flex: 1; min-width: 0; flex-wrap: wrap; }
  .tb-right .btn-primary { padding: 7px 12px; font-size: 12px; }
  .tb-score { gap: 5px; }
  .tb-score label { font-size: 12px; font-weight: 600; color: var(--fg); }
  .score-input { width: 60px; padding: 4px 4px; font-size: 15px; }
  .tb-rank-sep { margin: 0 2px; }
  #editProfileBtn { font-size: 11px; }

  /* ===== 主体与筛选 ===== */
  .main { padding: 10px 10px 16px; }
  .filter-panel { padding: 10px 12px; }
  .filter-head { gap: 8px; }
  .filter-head .btn-ghost { padding: 6px 10px !important; font-size: 12px; }
  .filter-toggle { font-size: 12px; }
  .search-box { min-width: 0; padding: 6px 10px; }
  .filter-label { min-width: 60px; font-size: 12px; }
  .pill { font-size: 12px; padding: 4px 11px; }

  /* ===== 冲稳保选项卡:横向滑动 ===== */
  .strategy-bar { gap: 0; }
  .strategy-tabs {
    max-width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .strategy-tabs::-webkit-scrollbar { display: none; }
  .stab { padding: 9px 13px; font-size: 13px; flex-shrink: 0; }
  .strategy-hint { flex-basis: 100%; padding: 2px 2px 8px; }

  /* ===== 主数据表 → 卡片式列表 ===== */
  .table-wrap { background: transparent; border: none; border-radius: 0; overflow: visible; }
  .table-scroll { overflow: visible; }
  .data-table { display: block; min-width: 0; }
  .data-table thead { display: none; }
  .data-table tbody { display: block; }
  .data-table tbody tr {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 10px;
    overflow: hidden;
  }
  .data-table tbody tr:hover td { background: transparent; }
.data-table tbody td {
    display: block;
    border-bottom: none;
    padding: 8px 14px;
    width: auto !important;
    min-width: 0 !important;
    white-space: normal;
  }
  .data-table tbody td.col-school { padding-top: 13px; padding-bottom: 4px; }
  /* 计划信息:纵向块 → 单行横排 */
  .data-table tbody td.col-plan26 {
    display: flex; flex-wrap: wrap; align-items: baseline;
    gap: 2px 12px; padding-top: 0; padding-bottom: 10px;
  }
  .p26-num { font-size: 15px; }
  .p26-sub { margin-top: 0; }
  /* 历年标签列隐藏,由每列内的年份标签(.yr-tag)+「位次」前缀代替 */
  .data-table tbody td.col-histlabel { display: none; }
  .data-table tbody td.col-yr {
    display: inline-block;
    width: 33.33% !important;
    vertical-align: top;
    padding: 8px 0 8px 14px;
    border-top: 1px solid var(--border-soft);
  }
  .yr-tag { display: block; color: var(--muted); font-size: 11px; }
  .hcell .r { line-height: 22px; min-height: 22px; }
  .hcell .r.score { font-size: 15px; }
  .hcell .r.rank::before { content: "位次 "; color: var(--muted); font-size: 10px; }
  /* 操作:整行按钮 */
  .data-table tbody td.col-act {
    text-align: left;
    padding: 8px 14px 13px;
    border-top: 1px solid var(--border-soft);
  }
  td.col-act .add-btn { width: 100%; padding: 9px 0; font-size: 13px; border-radius: 8px; }
  .empty-row { border: none !important; background: transparent !important; }
  .empty-row td { padding: 36px 0 !important; text-align: center; }

  /* ===== 底部信息条:上移到底部导航之上 ===== */
  .footer-bar {
    left: 0;
    bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding: 7px 12px;
  }
  .footer-info { font-size: 11px; }

  /* ===== 志愿表抽屉:全宽 ===== */
  .vt-drawer { width: 100%; max-width: 100%; }
  .vt-head { padding: 12px 16px; }
  .vt-list { padding: 8px 12px 12px; }
  .vt-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .vt-tip { padding: 8px 16px 0; }

  /* ===== 院校库面板 ===== */
  .lib-panel { border-radius: 0; }
  .lib-head { padding: 16px 16px 4px; }
  .lib-head h2 { font-size: 17px; }
  .lib-head .lib-count { font-size: 12px; }
  .lib-toolbar { padding: 8px 16px 12px; gap: 8px; }
  .lib-filter { padding: 8px 11px; font-size: 12px; white-space: nowrap; }
  .lib-search { padding: 8px 12px; }
  .lib-panel .filter-body { padding: 0 16px 12px !important; }
  .lib-list { padding: 0 16px calc(var(--nav-h) + 24px); }
  .lib-item { gap: 12px; padding: 14px 0; }
  .lib-logo { width: 42px; height: 42px; font-size: 13px; }
  .lib-name { font-size: 15px; }
  .lib-meta { font-size: 12px; }

  /* ===== 院校详情页 ===== */
  .dt-top { padding: 10px 12px; gap: 10px; flex-wrap: wrap; }
  .dt-divider { display: none; }
  .dt-back { font-size: 13px; }
  .dt-logo { width: 38px; height: 38px; font-size: 13px; }
  .dt-htitle { font-size: 16px; }
  .dt-hmeta { font-size: 12px; }
  .dt-tier { font-size: 12px; padding: 4px 10px; }
  .dt-body { padding: 14px 12px calc(var(--nav-h) + 44px); }
  .dt-hero { gap: 10px; }
  .dt-stat { min-width: calc(50% - 5px); padding: 12px 14px; }
  .dt-stat .v { font-size: 20px; }
  .dt-sec { padding: 14px; overflow-x: auto; }
  .dt-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .dt-table { font-size: 12px; }
  .dt-table th, .dt-table td { padding: 8px 6px; }

  /* ===== 用户管理面板 ===== */
  .um-head { padding: 14px 16px 10px; }
  .um-head h2 { font-size: 17px; }
  .um-body { flex-direction: column; }
  /* 分组侧栏 → 顶部横向胶囊条 */
  .um-groups {
    display: flex; align-items: center;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-shrink: 0;
  }
  .um-groups::-webkit-scrollbar { display: none; }
  .um-groups .gt { display: none; }
  #umGroupList { display: flex; gap: 6px; }
  .um-group {
    white-space: nowrap; margin-bottom: 0;
    padding: 6px 12px; border-radius: 100px;
    background: #F7F8FA;
  }
  .um-group.active { background: var(--primary-dim); }
  .um-newgroup { margin-top: 0; white-space: nowrap; padding: 6px 12px; border-radius: 100px; }
  .um-toolbar { padding: 10px 12px; gap: 8px; }
  .um-toolbar .lib-search { max-width: none; flex-basis: 100%; order: -1; }
  .um-toolbar select { padding: 7px 8px; font-size: 12px; }
  .um-toolbar .btn-ghost, .um-toolbar .btn-primary { padding: 7px 12px; font-size: 12px; }
  .um-batchbar { padding: 8px 12px; flex-wrap: wrap; gap: 10px; }
  /* 表格保留横向滑动(管理场景字段多) */
  .um-tablewrap { padding: 0 12px calc(var(--nav-h) + 20px); }

  /* ===== 弹窗(趋势/考生资料/档案表单/确认框) ===== */
  .chart-modal-content {
    width: calc(100% - 32px);
    max-width: 440px;
    padding: 20px;
    max-height: 84vh;
    overflow-y: auto;
  }
  .mini-chart { gap: 18px; }
  .mini-chart .bar .col { width: 40px; }
  .toast-box { top: 12px; width: calc(100% - 32px); }

  /* 触控目标不小于 40px */
  .lib-close, .vt-close, .chart-modal-close { padding: 8px; }

  /* 学生端弹窗身份行:移动端换行 */
  .pf-identity-row { flex-wrap: wrap; gap: 6px; }
  .pf-identity-row span { width: 100%; }
  .pf-identity-row .btn-ghost { flex: 1; min-width: 0; text-align: center; }
}

/* ---------------- ≤380px:小屏微调 ---------------- */
@media (max-width: 380px) {
  .data-table tbody td.col-yr { padding-left: 10px; }
  .filter-label { min-width: 52px; }
}
