/* =========================================================================
   响应式适配层（responsive.css）
   加载顺序：app.css 之后，仅做覆盖，不改动原应用样式
   基线：360-599px 手机竖屏（单列）
   断点：<=359 小屏手机 | 600-767 手机横屏/小平板 | 768-1023 平板
        1024-1439 桌面 | >=1440 大屏
   ========================================================================= */

/* ---- 0. 基础归一化：跨浏览器一致、防止横向溢出 ---- */
*,*::before,*::after{box-sizing:border-box}
html{-webkit-text-size-adjust:100%;-moz-text-size-adjust:100%;text-size-adjust:100%}
body{
  margin:0;background:#f5f5f5;color:#333;
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;
  -webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;
}
img,svg,video{max-width:100%}
img{height:auto}
#container{overflow-x:clip}
@supports (height:100dvh){#container,.page-content{min-height:100dvh}}
button,input,select,textarea{font-family:inherit}
button{-webkit-tap-highlight-color:transparent}
:focus-visible{outline:2px solid #1976d2;outline-offset:2px}

/* 桌面顶部导航：移动端隐藏，由底部操作栏承担 */
.top-nav{display:none}

/* ---- 1. 手机端可读性与触控尺寸 ---- */
@media (max-width:767px){
  .keyword-input,.level-select,.password-input,.custom-format-textarea{font-size:16px}
  .pattern-tag{min-height:36px}
  .action-btn{width:42px;height:42px}
  .page-btn{min-height:40px}
}

/* ---- 2. 小屏手机（<=359，如 iPhone SE 320/360） ---- */
@media (max-width:359px){
  .top-bar{padding:10px 12px}
  .app-title{font-size:16px}
  .filter-section{margin:10px;padding:12px}
  .level-info,.result-section{margin-left:10px;margin-right:10px}
  .pattern-tags{gap:6px}
  .pattern-tag{padding:6px 9px;font-size:12px}
  .result-item,.favorite-item{padding:12px;gap:8px}
  .phone-number{font-size:17px}
  .level-info-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}

/* ---- 3. 手机横屏 / 小平板（600-767）：筛选区两列，结果保持单列 ---- */
@media (min-width:600px){
  .filter-section{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:0 14px;align-items:start}
  .filter-group{min-width:0}
  .query-btn{grid-column:1/-1}
  .level-info-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
}

/* ---- 4. 平板（768-1023）：页面居中限宽，结果双列 ---- */
@media (min-width:768px){
  .page-content{max-width:940px;margin:0 auto}
  .top-bar{padding:14px 20px}
  .app-title,.page-title{font-size:20px}
  .filter-section{padding:18px 20px;margin:16px 16px}
  .level-info{margin:0 16px 14px}
  .result-section{margin:0 16px}
  .level-info-grid{grid-template-columns:repeat(4,minmax(0,1fr))}
  .result-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}
  .result-item{align-content:start}
  .favorites-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;padding:16px 16px;align-items:start}
  .admin-section{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;padding:16px;align-items:start}
  .admin-section>.stats-card{grid-column:1/-1}
  .bottom-action-bar,.admin-bottom-bar{left:50%;right:auto;transform:translateX(-50%);width:min(600px,92%);border-radius:14px;bottom:12px}
  .data-source{padding-bottom:104px}
  .modal-content{width:auto;min-width:320px;max-width:440px;max-height:86vh;overflow-y:auto}
  .copy-modal{width:90%;max-width:560px}
  .back-to-top-btn{bottom:104px}
}

/* ---- 5. 桌面（>=1024）：左侧固定筛选栏 + 右侧结果流 ---- */
@media (min-width:1024px){
  .page-content{max-width:1220px;padding:0 24px 40px}
  .page-query{display:grid;grid-template-columns:320px minmax(0,1fr);column-gap:20px;align-items:start}
  .page-query>.top-bar{grid-column:1/-1;border-radius:14px 14px 0 0;box-shadow:0 2px 10px #1a5fb41f;margin-bottom:0}
  .page-query>.contact-bar{grid-column:1/-1;grid-row:2;border-radius:0 0 14px 14px;margin-bottom:20px;box-shadow:0 2px 10px #1a5fb41f}
  .page-query>.filter-section{
    display:block;grid-column:1;grid-row:3/span 2;align-self:start;position:sticky;top:88px;
    max-height:calc(100vh - 112px);overflow-y:auto;margin:0 0 16px;padding:16px;scrollbar-width:thin;
  }
  .page-query>.filter-section .query-btn{grid-column:auto;margin-top:2px}
  .page-query>.filter-section::-webkit-scrollbar{width:6px}
  .page-query>.filter-section::-webkit-scrollbar-thumb{background:#dcdcdc;border-radius:3px}
  .page-query>.result-section{grid-column:2;grid-row:3;margin:0}
  .page-query>.data-source{grid-column:2;grid-row:4;text-align:left;padding:8px 0 0}
  .page-query>.bottom-action-bar{display:none}
  .page-query .result-list{grid-template-columns:repeat(2,minmax(0,1fr))}

  .top-nav{display:flex;align-items:center;gap:8px}
  .top-nav-btn{
    display:flex;align-items:center;gap:6px;padding:8px 14px;border:none;border-radius:20px;
    background:#ffffff2b;color:#fff;font-size:13px;cursor:pointer;white-space:nowrap;transition:background .2s;
  }
  .top-nav-btn .ico{width:18px;height:18px}
  .top-nav-btn:hover{background:#ffffff45}
  .top-nav-btn:active{transform:scale(.97)}
  .top-bar>div[style*="width:40px"]{display:none}
  .app-title,.page-title{text-align:left}
  .help-btn:hover{background:#ffffff40}
  .bottom-action-bar,.admin-bottom-bar{display:none}
  .back-to-top-btn{bottom:32px;right:32px}
  .data-source{padding-bottom:20px}
  .page-fav>.top-bar,.page-admin>.top-bar{margin-bottom:20px}
  .page-fav,.page-admin{max-width:940px}
  .page-fav .batch-actions,.page-fav .favorites-list,.page-fav .data-source,
  .page-admin .admin-section,.page-admin .data-source{padding-left:0;padding-right:0}
  .page-fav .batch-actions{padding-top:0}
  .page-fav .data-source{padding-bottom:8px}
}

/* ---- 6. 横屏矮窗口（高度 <=480）：压缩底栏，避免遮挡内容 ---- */
@media (max-height:480px) and (min-width:480px){
  .bottom-action-bar,.admin-bottom-bar{bottom:8px;padding:8px 12px;width:min(460px,88%)}
  .bottom-action-btn,.admin-bottom-btn{flex-direction:row;gap:6px;padding:9px 12px;font-size:12px;border-radius:10px}
  .bottom-action-btn .ico{width:18px;height:18px}
  .admin-bottom-btn .ico{width:16px;height:16px}
  .data-source{padding-bottom:76px}
  .filter-section{margin-top:10px}
}

/* ---- 7. 大屏（>=1440）：加大留白与字号，保持两列以兼顾可读性 ---- */
@media (min-width:1440px){
  .page-content{max-width:1360px}
  .page-query{grid-template-columns:344px minmax(0,1fr);column-gap:24px}
  .page-query .result-list{gap:16px}
  .result-item{padding:18px 20px}
  .phone-number{font-size:21px}
  .result-section .result-header{padding:14px 0}
}

/* =========================================================================
   8. 手机 / 平板（<=1023）：右上角固定快捷入口
   顶栏本身 sticky top:0，入口随之常驻可见，不随内容滚走
   ========================================================================= */
@media (max-width:1023px){
  .top-bar{gap:6px;padding:10px 12px}
  .top-bar>div[style*="width:40px"]{display:none}

  /* 右上角入口组：收藏 / 后台 */
  .mobile-top-actions{display:flex;align-items:center;gap:6px;flex:0 0 auto;margin-left:auto}
  .mta-btn{
    display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;
    width:48px;min-width:48px;height:44px;padding:0;border:none;border-radius:12px;
    background:#ffffff2e;color:#fff;font-size:10px;line-height:1.15;font-weight:500;
    cursor:pointer;flex-shrink:0;transition:background .18s,transform .12s;
  }
  .mta-btn .ico{width:18px;height:18px}
  .mta-btn:active{transform:scale(.94)}
  .mta-btn.is-active{background:#fff;color:#1a5fb4;box-shadow:0 1px 6px #0b3b7a38}

  /* 收藏页 / 后台页的左上角返回 */
  .mta-back{
    display:flex;align-items:center;justify-content:center;flex:0 0 40px;
    width:40px;height:40px;padding:0;border:none;border-radius:12px;
    background:#ffffff2e;color:#fff;cursor:pointer;
  }
  .mta-back .ico{width:22px;height:22px}
  .mta-back:active{transform:scale(.94)}

  /* 标题单行，超长省略；手机端隐藏副标题，给入口留出空间 */
  .app-title,.page-title{
    text-align:left;min-width:0;font-size:17px;line-height:1.35;
    overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
  }
  .app-title br,.app-title>span{display:none}
  .help-btn{width:34px;height:34px;flex:0 0 34px}
  .help-btn .ico{width:19px;height:19px}

  /* 查询页底部入口已上移，移除底栏并压缩留白 */
  .page-query>.bottom-action-bar{display:none}
  .page-query>.data-source{padding-bottom:28px}

  /* 收藏页已有左上角返回，底栏不再重复占位 */
  .page-fav>.admin-bottom-bar{display:none}
  .page-fav>.data-source{padding-bottom:20px!important}
}

@media (max-width:359px){
  .mta-btn{width:44px;min-width:44px;height:44px}
  .mta-btn .ico{width:17px;height:17px}
  .app-title,.page-title{font-size:15px}
  .help-btn{width:32px;height:32px;flex:0 0 32px}
}
