/* ==========================================================================
   kb.iaitop.com · 移动端重构层  v1.0
   --------------------------------------------------------------------------
   设计原则
   1. 触控优先：所有可点元素热区 ≥ 44×44（视觉尺寸可小，用伪元素扩热区）
   2. 单手可达：主操作集中在拇指区（底部 / 屏幕下半），顶部只留返回与标题
   3. 信息降噪：卡片正文 2 行 → 1 行；列表项高度 ≥ 64px，呼吸感
   4. 安全删除：移动端不再内联垃圾桶，一律走底部 Action Sheet 二次确认
   5. 安全区：全部贴边元素留 env(safe-area-inset-*)
   6. 防 iOS 缩放：输入类元素字号 ≥ 16px
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. 移动端专属变量 & 全局
   -------------------------------------------------------------------------- */
/* 桌面端默认隐藏移动端专属控件（媒体查询内再打开） */
.m-more-btn{ display: none; }


:root{
  --tap: 44px;                 /* 最小触控边长 */
  --nav-h: 58px;               /* 底部导航高度（不含安全区） */
  --topbar-h: 54px;
  --sheet-r: 18px;             /* 弹层圆角 */
  --ease-out: cubic-bezier(.22,1,.36,1);
}

/* 仅移动端生效 */
@media (max-width: 768px), (hover: none) and (pointer: coarse){

  /* 触控防抖：消除 300ms 延迟与点按高亮 */
  .doc-item, .mgrow, .mine-item, .chip, .nav-item, button, .bigtag{
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  /* 点按反馈：统一用 active 态代替 hover */
  .doc-item:active{ background: var(--bg3); transform: scale(.995); }
  .mgrow:active, .mine-item:active{ background: var(--bg3); }

  /* ======================================================================
     1. 顶栏：只保留 返回 + 标题 + 一个动作
     ====================================================================== */
  .topbar{
    height: var(--topbar-h);
    padding: 0 4px 0 2px;
    gap: 2px;
    padding-top: env(safe-area-inset-top);
    height: calc(var(--topbar-h) + env(safe-area-inset-top));
  }
  .topbar .logo{ font-size: 15px; font-weight: 650; min-width: 0; }
  .topbar .logo span{ display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar .logo svg{ display: none; }           /* 移动端去掉 logo 图标，腾空间 */
  .backbtn{ width: var(--tap); height: var(--tap); justify-content: center; }
  /* 新建按钮：圆形实心，44px。⚠️这里必须用 min-width/min-height
     —— 若用固定 width，flex 布局下会被 .searchbox 撑爆（实测小屏溢出 32~125px） */
  .btn.primary{
    min-width: var(--tap); height: var(--tap); padding: 0; border-radius: 12px;
    justify-content: center; flex-shrink: 0; flex: 0 0 auto;
  }
  .btn.primary .txt{ display: none; }           /* 只留 ＋ 图标（原有 html 无图标，用伪元素兜底） */
  #btnNew::after{
    content: ''; width: 18px; height: 18px; display: block;
    background: currentColor;
    -webkit-mask: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 4.5a.9.9 0 0 1 .9.9v5.7h5.7a.9.9 0 1 1 0 1.8h-5.7v5.7a.9.9 0 1 1-1.8 0v-5.7H5.4a.9.9 0 1 1 0-1.8h5.7V5.4a.9.9 0 0 1 .9-.9Z'/%3E%3C/svg%3E");
            mask: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 4.5a.9.9 0 0 1 .9.9v5.7h5.7a.9.9 0 1 1 0 1.8h-5.7v5.7a.9.9 0 1 1-1.8 0v-5.7H5.4a.9.9 0 1 1 0-1.8h5.7V5.4a.9.9 0 0 1 .9-.9Z'/%3E%3C/svg%3E");
  }
  /* 搜索框：撑满，44px 高，字号 16px 防缩放。
     min-width:0 是关键——flex 子项默认 min-width:auto 会被 input 撑爆 */
  .searchbox{
    height: var(--tap); border-radius: 12px; padding: 0 12px; gap: 8px;
    background: var(--bg2); border-color: transparent;
    min-width: 0; flex: 1 1 auto; overflow: hidden;
  }
  .searchbox input{ font-size: 16px; height: 100%; }
  .searchbox .clear{ width: 34px; height: 34px; display: grid; place-items: center; margin-right: -6px; }

  /* ======================================================================
     2. 底部导航：加高、加大图标、安全区、58px 视觉基线
     ====================================================================== */
  .bottomnav{
    padding: 0 0 env(safe-area-inset-bottom);
    height: auto;
    box-shadow: 0 -1px 0 var(--border), 0 -8px 24px rgba(24,24,27,.05);
  }
  .bottomnav button{
    min-height: var(--nav-h);
    gap: 4px; font-size: 11px; font-weight: 500;
    padding: 7px 2px 5px;
    border-radius: 12px;
  }
  .bottomnav button svg{ width: 22px; height: 22px; }
  .bottomnav button.on{ color: var(--accent); font-weight: 600; }
  .bottomnav button.on svg{ transform: translateY(-1px); transition: transform .18s var(--ease-out); }
  /* 选中态增加顶部指示条，提升弱光识别度 */
  .bottomnav button{ position: relative; }
  .bottomnav button.on::before{
    content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 22px; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent);
  }

  /* ======================================================================
     3. 文档列表：卡片化 + 单行摘要 + 去掉内联危险按钮
     ====================================================================== */
  /* ⚠️ 底部必须让出底部导航高度 —— 否则最后一张卡片被导航栏压住 */
  .list-body{ padding: 10px 12px calc(var(--nav-h) + 22px + env(safe-area-inset-bottom)); }
  .doc-item{
    padding: 14px 14px 13px 15px;
    border-radius: 14px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    min-height: 68px;
  }
  .doc-item::before{ left: 6px; top: 14px; bottom: 14px; width: 3px; }
  .doc-item .t{ font-size: 15.5px; font-weight: 600; line-height: 1.35; }
  .doc-item .t .fav{ margin-left: 6px; }
  /* 摘要：单行，降噪 */
  .doc-item .ex{
    -webkit-line-clamp: 1; min-height: 0; font-size: 13px; margin-top: 5px;
    line-height: 18px; color: var(--text3);
  }
  .doc-item .meta{ margin-top: 8px; gap: 6px; }
  .doc-item .meta .d{ font-size: 11.5px; }
  /* 危险操作移出卡片：彻底隐藏内联 ops，改由「⋯」唤起 Action Sheet */
  .doc-item .ops{ display: none !important; }
  .doc-item .t{ padding-right: 0; }

  /* 长按选中反馈 */
  .doc-item.longpress{ background: var(--bg3); transform: scale(.99); }

  /* ======================================================================
     4. 列表头部：文件夹筛选 + 排序（44px 高）
     ====================================================================== */
  .list-head{
    padding: 10px 12px 8px;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 3;
    background: var(--bg);
  }
  .folder-filter{
    height: var(--tap); font-size: 16px; padding: 0 10px; border-radius: 12px;
    background: var(--bg2); border-color: transparent; max-width: none; flex: 1;
    font-weight: 500;
  }
  .list-head #sortSel{
    height: var(--tap); font-size: 16px; padding: 0 10px; border-radius: 12px;
    background: var(--bg2); border-color: transparent; width: auto;
  }

  /* 空态：更友好 */
  .empty{ padding: 56px 24px; font-size: 14px; line-height: 24px; color: var(--text3); }

  /* ======================================================================
     5. 阅读 / 编辑页
     ====================================================================== */
  .col-editor{ z-index: 2; }
  /* 隐藏原有 ed-meta 里的「切换/收藏/更多」（这些仍在「⋯」面板里），
     但保留「分类 + 标签」——它们是高频操作，不能藏 */
  .ed-meta{
    display: flex !important;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    border-bottom: 1px solid var(--border);
    touch-action: pan-x;
  }
  .ed-meta::-webkit-scrollbar{ display: none; }
  .ed-sep{ display: none !important; }
  /* 分类下拉：44px 高、不收缩 */
  .ed-meta > select#edFolder{
    height: var(--tap); min-height: var(--tap); flex: 0 0 auto;
    font-size: 15px; padding: 0 10px; border-radius: 11px;
    background: var(--bg2); border-color: transparent; font-weight: 500;
  }
  /* 移动端：分类改成按钮（原生 select 在横向滚动条内点击体验差） */
  .ed-meta > select#edFolder{ display: none !important; }
  .ed-meta > .m-folder-btn{
    display: inline-flex; align-items: center; gap: 6px;
    flex: 0 0 auto;
    height: var(--tap); min-height: var(--tap);
    padding: 0 12px;
    font-size: 15px; font-weight: 500; color: var(--text);
    border: 1px solid var(--border); border-radius: 11px;
    background: var(--bg2);
    max-width: 46vw; overflow: hidden;
  }
  .ed-meta > .m-folder-btn > span{
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .ed-meta > .m-folder-btn.ro{ opacity: .55; }
  /* 移动端：添加标签按钮（替代输入框回车，入口更明确） */
  .ed-meta > .m-tag-add{
    display: inline-flex; align-items: center; gap: 5px;
    flex: 0 0 auto;
    height: var(--tap); min-height: var(--tap);
    padding: 0 13px;
    font-size: 14px; font-weight: 600; color: #fff;
    border: none; border-radius: 11px;
    background: var(--accent);
  }
  .ed-meta > .m-tag-add svg{ color: #fff; flex: 0 0 auto; }
  /* 移动端：标签输入框不是主入口（用按钮），编辑态也隐藏，只留标签展示/点击移除 */
  .ed-meta .tagwrap input{ display: none !important; }
  /* 标签区：占满剩余宽度，不被裁掉 */
  .ed-meta .tagwrap{
    flex: 1 1 auto; min-width: 0; flex-wrap: nowrap;
    align-items: center; gap: 6px;
    overflow-x: auto; scrollbar-width: none;
    min-height: var(--tap);
    padding: 4px 8px;
    border-radius: 11px;
    background: var(--bg2);
  }
  /* 预览态：标签完整换行展示，不横向滚动截断 */
  .ed-meta .tagwrap:has(.chip.ro){
    flex-wrap: wrap;
    overflow-x: visible;
    row-gap: 6px;
    padding: 6px 8px;
  }
  .ed-meta .tagwrap::-webkit-scrollbar{ display: none; }
  .ed-meta .tagwrap input{
    width: auto; min-width: 74px; flex: 1 1 80px;
    font-size: 16px;               /* 防 iOS 聚焦缩放 */
    height: 36px;
  }
  /* 标签区在手机上的占位符变短（避免被截断成半截字）*/
  .ed-meta .tagwrap input::placeholder{ content: ''; }
  /* 标签 chip 在手机上加大热区，方便单手移除 */
  .ed-meta .tagwrap .chip{
    flex: 0 0 auto; font-size: 13px; padding: 6px 10px; border-radius: 8px;
  }
  /* 隐藏移动端不需要的：编辑/预览切换、收藏、更多（已在「⋯」里） */
  .ed-meta > .grow,
  .ed-meta > .seg,
  .ed-meta > .iconbtn{ display: none !important; }
  .ed-title{
    font-size: 21px; font-weight: 680; line-height: 1.32;
    padding: 14px 16px 8px; margin: 0;
    border-bottom: 1px solid var(--border);
  }
  .ed-body{ padding-bottom: env(safe-area-inset-bottom); }
  /* 底部留白：必须避开 .ed-foot(40) + .fab(56) + 导航(58) + 安全区，
     否则长文末尾被悬浮按钮/状态栏遮挡 */
  .ed-body textarea{
    font-size: 16px;              /* 防 iOS 聚焦缩放 */
    line-height: 1.78;
    padding: 16px 16px calc(150px + env(safe-area-inset-bottom));
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  }
  .preview{
    padding: 16px 18px calc(150px + env(safe-area-inset-bottom));
    font-size: 16px; line-height: 1.85;
    max-width: 100%;
  }
  .preview h1{ font-size: 22px; } .preview h2{ font-size: 19px; } .preview h3{ font-size: 17px; }
  .preview p{ margin: 0 0 14px; }
  .preview img{ border-radius: 10px; }
  .preview pre{ border-radius: 12px; padding: 12px 14px; font-size: 13.5px; }

  /* 工具条：44px 触控热区（图标视觉 18px，热区撑满），粘住标题下方 */
  .ed-tools{
    padding: 5px 8px;
    gap: 3px;
    touch-action: pan-x;            /* 明确只允许横向滑动，避免与返回手势抢事件 */
    overscroll-behavior-x: contain; /* 横滑到边界不回弹/不冒泡 */
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 4;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }
  .ed-tools button{
    min-width: var(--tap); min-height: var(--tap); height: var(--tap);
    border-radius: 11px; color: var(--text2);
    scroll-snap-align: start;
  }
  .ed-tools button:active{ background: var(--bg3); transform: scale(.94); }
  .ed-tools button svg{ width: 18px; height: 18px; }
  .ed-tools .tsep{ height: 22px; margin: 0 6px; }

  /* 底部状态条：贴在编辑区底部、导航上方，返回按钮让位 */
  .ed-foot{
    padding: 8px 16px;
    font-size: 12px;
    gap: 8px;
    min-height: 40px;
    border-top: 1px solid var(--border);
    background: var(--bg);
  }
  #edInfo{ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 62%; }

  /* FAB「编辑」：右下、避开导航与安全区，56px 大按钮 */
  .fab{
    bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px) !important;
    right: 14px !important;
    min-width: 56px; min-height: 56px;
    padding: 0 18px; border-radius: 16px;
    font-size: 14px; font-weight: 600;
    box-shadow: 0 8px 24px rgba(24,24,27,.24), 0 2px 6px rgba(24,24,27,.12);
  }
  .fab:active{ transform: scale(.95); }

  /* 阅读页：顶部「⋯」更多按钮 */
  .m-more-btn{
    display: grid !important;
    width: var(--tap); height: var(--tap);
    place-items: center; border-radius: 12px; color: var(--text2);
    flex-shrink: 0;
  }
  .m-more-btn:active{ background: var(--bg3); }

  /* ======================================================================
     6. 管理页 / 我的页：行高 56px、操作按钮 44px、去掉内联删除
     ====================================================================== */
  /* 底部留白：避开底部导航(59) + 安全区，防止最后一行被遮挡 */
  .page-tags, .page-mine{
    padding: 16px 14px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom));
  }
  .page-tags h3, .page-mine h3{
    font-size: 12.5px; font-weight: 600; letter-spacing: .4px;
    text-transform: uppercase; color: var(--text3);
    margin: 20px 0 8px; padding-left: 2px;
  }
  .mpage-head{ margin: 20px 0 10px; }
  .mpage-head .madd{
    min-height: var(--tap); padding: 0 16px; border-radius: 12px; font-size: 13.5px;
    font-weight: 600; box-shadow: 0 2px 8px rgba(37,99,235,.24);
  }
  .mpage-head .madd:active{ transform: scale(.96); }

  .mglist{ gap: 8px; }
  .mgrow{
    min-height: 58px; padding: 0 8px 0 14px; gap: 12px;
    border-radius: 13px; background: var(--bg2);
    border: 1px solid transparent;
  }
  .mgrow .dot{ width: 10px; height: 10px; }
  .mgrow .nm{ font-size: 15.5px; font-weight: 500; }
  .mgrow .c{ font-size: 12.5px; background: var(--bg3); border-radius: 999px; padding: 2px 9px; }
  /* 移动端：重命名/删除合并成「⋯」44px */
  .mgrow .mop{ width: var(--tap); height: var(--tap); border-radius: 11px; }
  .mgrow .mop[data-mfop="rename"], .mgrow .mop[data-mtop="rename"]{ display: none; }
  .mgrow .mop[data-mfop="del"], .mgrow .mop[data-mtop="del"]{
    background: transparent;
    -webkit-mask: none;
  }
  /* 把「删除」图标换成「⋯」观感：保留原图标但缩小并居中在 44px 内 */
  .mgrow .mop[data-mfop="del"] svg, .mgrow .mop[data-mtop="del"] svg{
    width: 17px; height: 17px; opacity: .55;
  }
  /* 整行可点 = 重命名（把整行变成热区，删除走 ⋯ → Sheet） */
  .mgrow{ cursor: pointer; }

  .mine-item{
    min-height: 58px; padding: 0 14px; gap: 12px;
    border-radius: 13px; background: var(--bg2); margin-bottom: 8px;
    font-size: 15.5px;
  }
  .mine-item .n{ font-size: 15.5px; }
  .mine-item .c{
    font-size: 12.5px; background: var(--bg3); border-radius: 999px;
    padding: 2px 9px !important; color: var(--text2) !important;
  }
  /* 「回收站」计数胶囊：与「N 篇」视觉统一 */
  .mine-item .n + .c, .mine-item .c{
    background: var(--bg3); color: var(--text2); font-weight: 500;
  }

  /* 「退出登录」危险项：独立卡片 + 红色 */
  .mine-item[data-mine="logout"]{
    background: color-mix(in srgb, var(--c2) 7%, var(--bg));
    color: var(--c2);
    margin-top: 4px;
  }
  .mine-item[data-mine="logout"] svg{ color: var(--c2); }
  .mine-item[data-mine="logout"] .n{ color: var(--c2); font-weight: 550; }
  .mine-item[data-mine="logout"] .arr{ opacity: .4; }

  /* 关于区块：降级为次要信息 */
  .page-mine > div[style*="font-size:12px"]{
    font-size: 12px !important;
    color: var(--text3) !important;
    background: var(--bg2);
    border-radius: 12px;
    padding: 12px 14px !important;
    line-height: 19px !important;
  }

  /* ======================================================================
     7. Action Sheet（底部操作面板）—— 新增组件
     ====================================================================== */
  .m-sheet-mask{
    position: fixed; inset: 0; z-index: 200;
    background: rgba(24,24,27,.42);
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
    opacity: 0; pointer-events: none; transition: opacity .22s ease;
  }
  .m-sheet-mask.show{ opacity: 1; pointer-events: auto; }

  .m-sheet{
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 201;
    background: var(--bg);
    border-radius: var(--sheet-r) var(--sheet-r) 0 0;
    padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
    transform: translateY(102%);
    transition: transform .28s var(--ease-out);
    box-shadow: 0 -12px 40px rgba(24,24,27,.18);
    max-height: 78dvh; overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .m-sheet.show{ transform: none; }
  .m-sheet::before{
    content: ''; display: block; width: 38px; height: 4px; border-radius: 4px;
    background: var(--text4); margin: 4px auto 10px;
  }
  .m-sheet-title{
    font-size: 13px; color: var(--text3); text-align: center;
    padding: 0 12px 10px; font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .m-sheet-item{
    display: flex; align-items: center; gap: 14px;
    min-height: 54px; padding: 0 16px;
    font-size: 16px; font-weight: 500; color: var(--text);
    border-radius: 13px; width: 100%; text-align: left;
  }
  .m-sheet-item:active{ background: var(--bg2); }
  .m-sheet-item svg{ width: 20px; height: 20px; color: var(--text2); flex-shrink: 0; }
  .m-sheet-item .m-sheet-sub{
    margin-left: auto; font-size: 12.5px; color: var(--text3); font-weight: 400;
    max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .m-sheet-item.danger{ color: var(--c2); }
  .m-sheet-item.danger svg{ color: var(--c2); }
  .m-sheet-sep{ height: 1px; background: var(--border); margin: 6px 12px; }
  .m-sheet-cancel{
    display: flex; align-items: center; justify-content: center;
    min-height: 52px; margin-top: 6px;
    font-size: 16px; font-weight: 600; color: var(--text2);
    background: var(--bg2); border-radius: 13px; width: 100%;
  }
  .m-sheet-cancel:active{ background: var(--bg3); }

  /* 破坏性操作：移动端不再用原生 confirm，改用 Sheet 里的红色项 + 二次 Sheet */

  /* ======================================================================
     8. Toast：抬高到导航之上，居中，圆角胶囊
     ====================================================================== */
  .toast{
    bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px) !important;
    font-size: 14px; padding: 10px 18px; border-radius: 12px;
    max-width: calc(100vw - 40px); white-space: normal; text-align: center;
    line-height: 1.4;
  }

  /* ======================================================================
     9. 平板（600–768）：双列网格 + 限宽，避免单列超宽横向扫视
     ====================================================================== */
  @media (min-width: 600px) and (max-width: 768px){
    .list-body{
      padding: 14px max(20px, calc((100vw - 900px) / 2)) calc(var(--nav-h) + 22px + env(safe-area-inset-bottom));
      display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px; align-content: start;
      max-width: 940px; margin: 0 auto; width: 100%;
    }
    .doc-item{ margin-bottom: 0; }
    .list-body .empty{ grid-column: 1 / -1; }
    .col-list{ border-right: none; }
    .page-tags, .page-mine{ max-width: 680px; margin: 0 auto; width: 100%; }
    .preview{ padding-left: max(24px, calc((100vw - 720px) / 2)); padding-right: max(24px, calc((100vw - 720px) / 2)); }
    .ed-body textarea{ padding-left: max(24px, calc((100vw - 720px) / 2)); padding-right: max(24px, calc((100vw - 720px) / 2)); }
  }
}

/* --------------------------------------------------------------------------
   10. 极小屏兜底 360 / 320
   -------------------------------------------------------------------------- */
@media (max-width: 380px){
  .doc-item .t{ font-size: 15px; }
  .bottomnav button{ font-size: 10px; }
  .bottomnav button svg{ width: 21px; height: 21px; }
  .ed-title{ font-size: 19.5px; }
  .list-head{ gap: 6px; }
  .folder-filter, .list-head #sortSel{ font-size: 15px; padding: 0 8px; }
}

/* --------------------------------------------------------------------------
   11. 兜底：极小屏顶栏（≤340px）
   -------------------------------------------------------------------------- */
@media (max-width: 340px){
  .m-more-btn{ display: none !important; }
  .topbar .logo{ max-width: 30vw; overflow: hidden; }
  .searchbox input::placeholder{ color: transparent; }
}

/* --------------------------------------------------------------------------
   12. 底部导航：更明确的安全区隔离（无 safe-area 时也留呼吸位）
   -------------------------------------------------------------------------- */
@media (max-width: 768px), (hover: none) and (pointer: coarse){
  .bottomnav{ padding-bottom: max(env(safe-area-inset-bottom), 4px); }
  /* 极矮横屏时导航变矮，列表留白同步调整（保持不遮挡） */
  @media (max-height: 480px){
    .list-body, .page-tags, .page-mine{
      padding-bottom: calc(52px + env(safe-area-inset-bottom)) !important;
    }
  }
}

/* --------------------------------------------------------------------------
   13. 横屏矮屏：压缩上下留白
   -------------------------------------------------------------------------- */
/* 手机横握（宽度>768 但高度很矮 + 粗指针）：
   原实现在此会回落成桌面三栏，844x390 下正文只剩十几个字/行，基本不可用。
   修正：强制走移动单栏主从布局（列表 ↔ 详情），底部导航保留。 */
@media (max-height: 520px) and (max-width: 960px) and (hover: none) and (pointer: coarse){
  .topbar{ height: 46px; height: calc(46px + env(safe-area-inset-top)); }
  .topbar .logo span{ max-width: 34vw; }

  .col-side{ display: none !important; }
  .bottomnav{ display: flex !important; }
  .backbtn{ display: flex !important; }
  .mobile-menu-btn{ display: grid !important; }

  .main{ position: relative; }
  .col-list{ width: 100% !important; border-right: none; }
  .col-editor{ position: absolute !important; inset: 0 !important; background: var(--bg); }
  .fab{ position: absolute !important; }
  body[mobile="list"] .col-list{ display: flex !important; }
  body[mobile="list"] .col-editor{ display: none !important; }
  body[mobile="read"] .col-list{ display: none !important; }
  body[mobile="read"] .col-editor{ display: flex !important; }
  body[mobile="read"] .searchbox{ display: none !important; }
  body[mobile="read"] .btn.primary{ display: none !important; }
  body[mobile="tags"] .col-list{ display: none !important; }
  body[mobile="tags"] .col-editor{ display: block !important; }
  body[mobile="tags"] #edEmpty, body[mobile="tags"] #edWrap{ display: none !important; }
  body[mobile="tags"] .mpage.page-tags{ display: block !important; height: 100%; }
  body[mobile="mine"] .col-list{ display: none !important; }
  body[mobile="mine"] .col-editor{ display: block !important; }
  body[mobile="mine"] #edEmpty, body[mobile="mine"] #edWrap{ display: none !important; }
  body[mobile="mine"] .mpage.page-mine{ display: block !important; height: 100%; }
  body[mobile="tags"] .searchbox, body[mobile="mine"] .searchbox,
  body[mobile="tags"] .btn.primary, body[mobile="mine"] .btn.primary{ display: none !important; }

  /* 矮屏下进一步压缩 */
  .list-body, .page-tags, .page-mine{
    padding-bottom: calc(50px + env(safe-area-inset-bottom)) !important;
  }
  .bottomnav button{ min-height: 48px; padding: 4px 2px; }
  .bottomnav button span{ display: block; font-size: 10px; }
  .bottomnav button svg{ width: 19px; height: 19px; }
  .ed-title{ font-size: 18px; padding: 8px 14px 6px; }
  /* 横屏矮屏：标签区保留但压缩（不隐藏，高频操作）*/
  .ed-meta{ padding: 6px 10px; gap: 6px; }
  .ed-meta > select#edFolder{ height: 40px; min-height: 40px; font-size: 14px; }
  .ed-meta .tagwrap{ min-height: 40px; padding: 3px 6px; }
  .ed-body textarea{ padding: 10px 14px calc(104px + env(safe-area-inset-bottom)); line-height: 1.7; }
  .preview{ padding: 10px 16px calc(104px + env(safe-area-inset-bottom)); }
  .fab{ bottom: calc(48px + env(safe-area-inset-bottom) + 10px) !important; min-height: 46px; padding: 0 16px; }
  .toast{ bottom: calc(48px + env(safe-area-inset-bottom) + 12px) !important; }
}

/* --------------------------------------------------------------------------
   14. 旧横屏回退块（保留：桌面窄窗口横屏时压缩留白）
   -------------------------------------------------------------------------- */
@media (max-width: 900px) and (max-height: 480px) and (pointer: fine){
  .topbar{ height: 46px; height: calc(46px + env(safe-area-inset-top)); }
  .bottomnav button{ min-height: 48px; }
  .bottomnav button span{ display: none; }
  .ed-title{ font-size: 18px; padding: 8px 14px 6px; }
}