/* 前台 App 体验增强 */
html,body{
  touch-action:manipulation;
  -webkit-text-size-adjust:100%;
}
body.app-shell{
  overscroll-behavior-y:none;
}
.app-offline-bar{
  position:fixed;top:0;left:0;right:0;z-index:200;
  padding:calc(6px + env(safe-area-inset-top,0px)) 12px 6px;
  background:#ff3b30;color:#fff;
  font-size:13px;text-align:center;
  transform:translateY(-100%);transition:transform .28s ease;
  pointer-events:none;
}
.app-offline-bar.is-show{transform:translateY(0)}

.app-toast-wrap{
  position:fixed;left:50%;bottom:calc(24px + env(safe-area-inset-bottom,0px));
  z-index:300;transform:translateX(-50%);
  pointer-events:none;
}
.app-toast{
  padding:10px 18px;border-radius:999px;
  background:rgba(30,30,32,.88);color:#fff;
  font-size:14px;white-space:nowrap;
  box-shadow:0 6px 24px rgba(0,0,0,.22);
  opacity:0;transform:translateY(12px) scale(.96);
  transition:opacity .22s ease,transform .22s ease;
}
.app-toast.is-show{opacity:1;transform:translateY(0) scale(1)}

/* 页面切换：仅首次打开时轻淡入 */
body.app-ui-enter{
  opacity:0;
  transition:opacity .15s ease;
}
body.app-ui-enter.app-ui-enter-active{opacity:1}

/* 边缘滑动返回指示 */
.app-swipe-edge{
  position:fixed;left:0;top:0;bottom:0;width:22px;z-index:150;
  touch-action:pan-y;
}
.app-swipe-ghost{
  position:fixed;top:50%;left:0;z-index:151;
  width:28px;height:28px;margin-top:-14px;
  border-radius:50%;background:rgba(0,0,0,.08);
  transform:translateX(-40px);opacity:0;
  transition:opacity .15s ease;
  pointer-events:none;
}
.app-swipe-ghost.is-active{opacity:1}
.app-swipe-shade{
  position:fixed;inset:0;z-index:149;pointer-events:none;
  background:#000;opacity:0;transition:opacity .12s linear;
}

/* 骨架屏加载态 */
.is-skeleton-loading > :not(.app-skeleton){opacity:0}
.is-skeleton-loading .app-skeleton{opacity:1}
.app-pull-wrap{position:relative}
.app-pull-indicator{
  height:0;overflow:hidden;text-align:center;
  color:var(--text-muted);font-size:13px;
  transition:height .2s ease;
}
.app-pull-indicator span{
  display:inline-block;padding:8px 0;
}
.app-pull-indicator.is-loading span::after{
  content:'刷新中…';
}
.app-skeleton{
  padding:12px 16px;
}
.app-skeleton-row{
  display:flex;align-items:center;gap:12px;
  padding:12px 0;border-bottom:1px solid var(--divider);
}
.app-skeleton-avatar{
  width:48px;height:48px;border-radius:50%;
  background:linear-gradient(90deg,var(--icon-plate,rgba(0,0,0,.06)) 25%,rgba(0,0,0,.1) 50%,var(--icon-plate,rgba(0,0,0,.06)) 75%);
  background-size:200% 100%;animation:appShimmer 1.2s infinite;
}
.app-skeleton-lines{flex:1}
.app-skeleton-line{
  height:12px;border-radius:6px;margin-bottom:8px;
  background:linear-gradient(90deg,var(--icon-plate,rgba(0,0,0,.06)) 25%,rgba(0,0,0,.1) 50%,var(--icon-plate,rgba(0,0,0,.06)) 75%);
  background-size:200% 100%;animation:appShimmer 1.2s infinite;
}
.app-skeleton-line.short{width:42%}
@keyframes appShimmer{
  0%{background-position:200% 0}
  100%{background-position:-200% 0}
}

/* 统一列表点击反馈 */
.app-tap-row.is-pressed,
.msg-row.is-pressed,
.wx-contacts-row.is-pressed,
.ios-set-row.is-pressed,
.contact-detail-btn.is-pressed{
  opacity:.72;
  transform:scale(.985);
}

/* 原生栏首页按钮（全站） */
.ios-nav-home{
  display:inline-flex;align-items:center;justify-content:center;
  width:44px;height:44px;flex-shrink:0;
  color:var(--primary);text-decoration:none;
  border-radius:10px;
  -webkit-tap-highlight-color:transparent;
  transition:opacity .15s ease,transform .15s ease,background .15s ease;
}

/* 各页导航栏背景与页面一致 */
.msg-body .ios-nav{background:#fff}
.chat-body .ios-nav{background:#fff}
.contacts-body .ios-nav{background:#f7f7f7}
.contact-detail-body .ios-nav{background:#f2f2f7}
.ios-set-body .ios-nav{background:#f2f2f7}
html[data-theme="dark"] .msg-body .ios-nav,
html[data-theme="dark"] .chat-body .ios-nav,
html[data-theme="dark"] .contacts-body .ios-nav,
html[data-theme="dark"] .contact-detail-body .ios-nav,
html[data-theme="dark"] .ios-set-body .ios-nav{background:#1c1c1e}

/* 设置分组标题 */
.ios-set-section-title{
  margin:22px 0 7px;padding:0 16px 0 20px;
  font-size:13px;color:rgba(60,60,67,.6);
  text-transform:none;
}
.ios-set-main > .ios-set-section-title:first-child{margin-top:6px}
html[data-theme="dark"] .ios-set-section-title{color:rgba(235,235,245,.55)}

/* 深色模式卡片对比 */
html[data-theme="dark"] .contacts-group,
html[data-theme="dark"] .contact-detail-group,
html[data-theme="dark"] .contact-panel{
  background:var(--panel-bg);
}

/* 锁屏 */
body.app-lock-active{overflow:hidden}
.app-lock-overlay{
  position:fixed;inset:0;z-index:2147483100;
  display:flex;align-items:center;justify-content:center;
  background:var(--overlay-mask,rgba(0,0,0,.65));
  backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);
  padding:20px;
  transition:opacity .28s ease;
}
.app-lock-overlay.hide{opacity:0;pointer-events:none}
.app-lock-sheet{
  width:100%;max-width:340px;
  background:var(--panel-bg,#fff);
  border-radius:20px;padding:28px 20px 20px;
  text-align:center;
  box-shadow:0 20px 60px rgba(0,0,0,.25);
}
html[data-theme="dark"] .app-lock-sheet{background:#1c1c1e}
.app-lock-logo{font-size:40px;margin-bottom:8px}
.app-lock-sheet h2{margin:0 0 6px;font-size:20px;font-weight:600;color:var(--text)}
.app-lock-sub{margin:0 0 20px;font-size:14px;color:var(--text-muted)}
.app-lock-dots{
  display:flex;justify-content:center;gap:14px;margin-bottom:8px;
}
.app-lock-dots.six span:nth-child(5),
.app-lock-dots.six span:nth-child(6){display:inline-block}
.app-lock-dots:not(.six) span:nth-child(5),
.app-lock-dots:not(.six) span:nth-child(6){display:none}
.app-lock-dots span{
  width:12px;height:12px;border-radius:50%;
  border:1.5px solid #c7c7cc;
}
.app-lock-dots span.filled{background:var(--primary);border-color:var(--primary)}
.app-lock-dots.shake{animation:lockShake .4s ease}
@keyframes lockShake{
  0%,100%{transform:translateX(0)}
  25%{transform:translateX(-8px)}
  75%{transform:translateX(8px)}
}
.app-lock-err{color:#ff3b30;font-size:13px;margin:0 0 8px}
.app-lock-pad{
  display:grid;grid-template-columns:repeat(3,1fr);gap:14px 10px;
  margin-top:12px;justify-items:center;
}
.app-lock-key{
  width:72px;height:72px;padding:0;
  border:none;border-radius:50%;
  background:var(--icon-plate,rgba(0,0,0,.05));
  font-size:24px;color:var(--text);cursor:pointer;
  display:inline-flex;align-items:center;justify-content:center;
  flex-shrink:0;-webkit-tap-highlight-color:transparent;
}
.app-lock-key:active{background:rgba(0,0,0,.1)}
.app-lock-key.del{font-size:13px;border-radius:50%}
.app-lock-key.empty{visibility:hidden}
html[data-theme="dark"] .app-lock-key{background:#2c2c2e}

@media(min-width:768px){
  /* 平板/桌面：全宽自适应，取消手机壳窄栏 */
  body.app-shell,
  body.has-tabbar,
  body.go-body #app{
    max-width:none;
    margin-inline:0;
    border:none;
    box-shadow:none;
  }

  body.contact-detail-body.app-shell,
  body.ios-set-body.app-shell{
    background:#f2f2f7;
    border:none;
  }
  html[data-theme="dark"] body.contact-detail-body.app-shell,
  html[data-theme="dark"] body.ios-set-body.app-shell{
    background:#000;
    border:none;
  }

  .ios-nav,
  .container,
  .content-page{
    max-width:none;
    margin-inline:0;
  }

  body.go-body .ios-nav{max-width:none;margin-inline:0}

  .dock-wrap{
    left:0;right:0;transform:none;
    width:100%;
    padding-left:max(24px, env(safe-area-inset-left));
    padding-right:max(24px, env(safe-area-inset-right));
  }

  .contacts-body,
  .contact-detail-body,
  .ios-set-body{background:#f2f2f7}
  .ios-page-body,
  .msg-body,
  .msg-detail-body,
  .chat-body{background:#fff}
  html[data-theme="dark"] .contacts-body,
  html[data-theme="dark"] .contact-detail-body,
  html[data-theme="dark"] .ios-set-body,
  html[data-theme="dark"] .ios-page-body,
  html[data-theme="dark"] .msg-body,
  html[data-theme="dark"] .msg-detail-body,
  html[data-theme="dark"] .chat-body{background:#000}

  /* 底部弹窗居中，宽度适中 */
  .ios-set-sheet{
    left:50%;right:auto;
    width:min(calc(100% - 48px), 480px);
    transform:translateX(-50%) translateY(100%);
  }
  .ios-set-sheet.is-open{transform:translateX(-50%) translateY(0)}

  .app-toast-wrap,
  .a2hs-banner{
    left:50%;right:auto;
    transform:translateX(-50%);
    width:min(calc(100% - 48px), 560px);
  }
  .app-lock-overlay{
    left:0;right:0;width:100%;transform:none;
  }
  .msg-reply-bar{
    left:0;right:0;transform:none;width:100%;
  }
  .app-toast-wrap .app-toast.is-show{transform:translateY(0) scale(1)}
}

/* 应用内 iframe 浏览 */
body.browse-body{
  overflow:hidden;
  height:100vh;
  height:100dvh;
}
.browse-shell{
  display:flex;flex-direction:column;
  height:calc(100vh - var(--ios-nav-inline-h));
  height:calc(100dvh - var(--ios-nav-inline-h));
  min-height:0;
}
.browse-frame{
  flex:1;min-height:0;width:100%;
  border:none;display:block;
  background:#fff;
}
html[data-theme="dark"] .browse-frame{background:#000}
