/* ═══════════════════════════════════════════════════════════
   mobile.css — iOS 风格移动端全面适配（仅 ≤768px 生效，PC 零影响）
   设计语言：iOS 17 — 全屏沉浸窗口 / 大标题导航 / 底部标签栏 /
             安全区适配 / ≥44px 触控目标 / 弹簧动画 / 毛玻璃
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── 基础：字体 / 触控 / 安全区 ─────────────────────────── */
  :root {
    --dock-h: 64px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
  }
  html { -webkit-text-size-adjust: 100%; }
  body {
    font-size: 16px;                 /* 防 iOS 输入框自动缩放 */
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none;
  }
  button, input, select, textarea { font-family: inherit; }
  input, select, textarea { font-size: 16px; }  /* 聚焦时不缩放 */

  /* ── 桌面小组件：压缩为紧凑顶部区 ───────────────────────── */
  .desktop-widgets { top: calc(var(--safe-top) + 12px); gap: 6px; }
  .desktop-brand { font-size: 17px; gap: 8px; }
  .desktop-brand img { width: 30px; height: 30px; border-radius: 8px; }
  .desktop-clock { font-size: 40px; font-weight: 300; }
  .desktop-date { font-size: 12px; }
  .desktop-hint { display: none; }

  /* ── Dock → iOS 底部标签栏 ──────────────────────────────── */
  .dock {
    bottom: 0; left: 0; right: 0;
    transform: none;
    width: 100%;
    justify-content: space-around;
    gap: 0;
    padding: 8px 12px calc(var(--safe-bottom) + 8px);
    border-radius: 0;
    border-left: none; border-right: none; border-bottom: none;
    box-shadow: 0 -1px 0 rgba(255,255,255,.08), 0 -8px 32px rgba(0,0,0,.28);
  }
  :root[data-theme="light"] .dock { box-shadow: 0 -1px 0 rgba(0,0,0,.06), 0 -8px 32px rgba(0,0,0,.08); }
  .dock-icon {
    width: 48px; height: 48px;
    border-radius: 14px;
    font-size: 24px;
    flex: 0 0 auto;
  }
  .dock-icon:hover { transform: none; }          /* 移除 PC 悬浮上移 */
  .dock-icon:active { transform: scale(.9); transition-duration: .08s; }
  .dock-icon .dock-label { display: none; }      /* 移动端隐藏悬浮标签 */
  .dock-icon.active::after { bottom: -6px; }
  .dock-sep { display: none; }

  /* ── 窗口 → iOS 全屏沉浸页 ──────────────────────────────── */
  .window {
    position: fixed !important;
    top: 0 !important; left: 0 !important; right: 0 !important;
    /* 关键：底部止于标签栏上方，Dock 始终可见可点 → 修复移动端无法切换界面 */
    bottom: calc(var(--dock-h) + var(--safe-bottom) + 10px) !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    border-radius: 0;
    border: none;
    box-shadow: none;
    z-index: 600;
  }
  .window.open { animation: iosPageIn .32s cubic-bezier(.32,.72,.28,1); }
  @keyframes iosPageIn {
    from { opacity: 0; transform: translateY(24px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
  }

  /* 标题栏 → iOS 导航栏（毛玻璃 + 大标题感） */
  .window-titlebar {
    height: calc(var(--safe-top) + 52px);
    padding: var(--safe-top) 12px 0;
    border-radius: 0;
    background: rgba(15,17,23,.72);
    backdrop-filter: blur(20px) saturate(1.6);
    -webkit-backdrop-filter: blur(20px) saturate(1.6);
    border-bottom: .5px solid rgba(255,255,255,.1);
    cursor: default;                               /* 移动端不可拖拽 */
  }
  :root[data-theme="light"] .window-titlebar {
    background: rgba(255,255,255,.78);
    border-bottom-color: rgba(0,0,0,.08);
  }
  .traffic-lights { display: none; }              /* 隐藏 macOS 红黄绿 */
  .window-title {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -.01em;
    flex: 1;
    text-align: center;
  }
  .window-titlebar-right {
    font-size: 12px;
    max-width: 72px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  /* 窗口内容区：底部留出标签栏 + 安全区 */
  .window-body {
    padding: 14px 14px calc(var(--dock-h) + var(--safe-bottom) + 20px);
    -webkit-overflow-scrolling: touch;
  }

  /* ── 阅读看板 ───────────────────────────────────────────── */
  /* 统计卡片：横向滚动吸附，单卡更宽更舒展 */
  .board-stats {
    display: flex !important;
    gap: 10px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .board-stats::-webkit-scrollbar { display: none; }
  .board-stat {
    flex: 0 0 44%;
    scroll-snap-align: start;
    padding: 14px 16px;
    border-radius: 16px;
  }
  .board-stat-num { font-size: 26px; }

  /* 筛选栏：横向滑动胶囊，单行不换行挤压 */
  .board-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
  }
  .board-filters::-webkit-scrollbar { display: none; }
  .board-filters select,
  .board-filters input,
  .board-filters button {
    flex: 0 0 auto;
    min-height: 44px;                              /* iOS 触控标准 */
    border-radius: 22px;
    font-size: 14px;
  }

  /* 论文卡片：单列大卡，触控友好 */
  .paper-card {
    border-radius: 18px;
    padding: 16px;
    margin-bottom: 12px;
  }
  .paper-title { font-size: 16px; line-height: 1.4; }
  .paper-meta { font-size: 12px; }
  .paper-actions button,
  .paper-card button {
    min-height: 40px;
    border-radius: 12px;
    font-size: 13px;
  }

  /* ── 论文阅读 ───────────────────────────────────────────── */
  .reader-layout { flex-direction: column; }
  .reader-sidebar, .reader-main {
    width: 100% !important;
    max-width: none !important;
  }
  .reader-actions { grid-template-columns: 1fr 1fr; }
  .reader-actions button { min-height: 44px; font-size: 13px; }

  /* ── 手工搜索 ───────────────────────────────────────────── */
  .search-bar, .search-form {
    flex-direction: column;
    align-items: stretch;
  }
  .search-bar input, .search-bar select,
  .search-form input, .search-form select { width: 100%; min-height: 44px; }
  .search-bar button, .search-form button { min-height: 46px; border-radius: 14px; }

  /* ── 设置页 ─────────────────────────────────────────────── */
  .settings-grid, .settings-section { width: 100% !important; }
  .settings-input, .settings-select, .settings-textarea {
    width: 100%;
    min-height: 44px;
    border-radius: 12px;
    font-size: 16px;
  }
  .settings-btn, .settings-section button {
    min-height: 46px;
    border-radius: 14px;
    width: 100%;
  }

  /* ── 登录覆盖层 → iOS 底部卡片感 ────────────────────────── */
  .login-overlay { align-items: flex-end; background: rgba(0,0,0,.42); }
  .login-card {
    width: 100%;
    max-width: none;
    border-radius: 24px 24px 0 0;
    padding: 28px 24px calc(var(--safe-bottom) + 28px);
    animation: iosSheetIn .38s cubic-bezier(.32,.72,.28,1);
  }
  @keyframes iosSheetIn {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
  .login-field { min-height: 48px; border-radius: 12px; font-size: 16px; }
  .login-btn { min-height: 50px; border-radius: 14px; font-size: 17px; }

  /* ── 全局组件 ───────────────────────────────────────────── */
  .toast {
    left: 16px; right: 16px;
    transform: none;
    bottom: calc(var(--dock-h) + var(--safe-bottom) + 12px);
    border-radius: 14px;
    font-size: 14px;
  }
  .modal, .dialog {
    width: calc(100% - 32px) !important;
    max-width: none !important;
    border-radius: 20px;
  }
  .empty { padding: 40px 16px; }
  .empty-icon { font-size: 40px; }

  /* 翻译全屏覆盖层适配 */
  #trans-fullscreen-overlay .trans-fs-header { padding-top: var(--safe-top); }

  /* 滚动条隐形（iOS 原生覆盖式） */
  ::-webkit-scrollbar { width: 0; height: 0; }

  /* ══════════ 移动端精简优化（降低信息密度 · iOS 导航风格）══════════ */

  /* ── 标题栏：iOS 居中大标题，隐藏被截断的右侧辅助文字 ── */
  .window-titlebar-right { display: none !important; }
  .traffic-lights { display: none !important; }              /* macOS 红绿灯移动端无意义 */
  .window-titlebar { justify-content: center; }
  .window-title { font-size: 17px; font-weight: 600; letter-spacing: .01em; }

  /* ── 看板筛选栏：单行横向滑动，告别拥挤换行 ── */
  .board-filter-bar { padding: 8px 12px; gap: 6px; }
  .bf-row { flex-wrap: nowrap; overflow-x: auto; gap: 6px; -webkit-overflow-scrolling: touch; }
  .bf-row::-webkit-scrollbar { display: none; }
  .bf-row input[type="text"], .bf-row select, .bf-row button { flex: 0 0 auto; min-width: 0; }
  .bf-row label { font-size: 12px; white-space: nowrap; }

  /* ── 看板统计：更紧凑的横向卡片 ── */
  .board-stats-strip { gap: 8px; padding: 0 12px; }

  /* ── 论文卡片：收紧内边距，标题优先 ── */
  .paper-card { margin-bottom: 10px; }

  /* ── 阅读/搜索/设置：内容区统一内边距，避免贴边 ── */
  .window-body { padding-bottom: calc(var(--safe-bottom) + 8px); }
}

/* ── 超小屏（≤380px，iPhone SE / mini）进一步收紧 ─────────── */
@media (max-width: 380px) {
  .desktop-clock { font-size: 34px; }
  .board-stat { flex: 0 0 52%; }
  .window-title { font-size: 16px; }
}

/* ── 横屏手机：压缩垂直空间 ───────────────────────────────── */
@media (max-width: 900px) and (max-height: 500px) and (orientation: landscape) {
  .desktop-widgets { display: none; }
  .window-titlebar { height: calc(var(--safe-top) + 44px); }
  .dock { padding-top: 4px; padding-bottom: calc(var(--safe-bottom) + 4px); }
  .dock-icon { width: 42px; height: 42px; font-size: 21px; }
}
