/* 电脑端访问时的手机外壳：仅宽屏 + 鼠标指针生效，手机/平板触屏访问完全不启用 */
.pshell-frame,
.pshell-screen {
  display: none;
}

@media (min-width: 760px) and (min-height: 700px) and (hover: hover) and (pointer: fine) {
  :root {
    --pshell-w: 390px;
    --pshell-h: clamp(600px, calc(100vh - 64px), 844px);
    --pshell-bezel: 13px;
    --pshell-status: 52px;
    --pshell-radius: 46px;
    --pshell-chrome: #ffffff;
    --pshell-head: 44px;   /* uni-page-head 高度 */
    --pshell-tabbar: 64px; /* uni tabbar 50px + 模拟底部安全区 14px */
  }

  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  html body {
    margin: 0;
    padding: 0;
    background: radial-gradient(120% 92% at 50% 0%, #f8f9fb 0%, #e8ebef 56%, #dee2e8 100%);
  }

  /* 机身 */
  .pshell-frame {
    display: block;
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: calc(var(--pshell-w) + var(--pshell-bezel) * 2);
    height: calc(var(--pshell-h) + var(--pshell-bezel) * 2);
    border-radius: calc(var(--pshell-radius) + var(--pshell-bezel));
    background: linear-gradient(155deg, #45484f 0%, #24272d 38%, #14161a 100%);
    box-shadow:
      0 34px 72px rgba(18, 24, 33, .3),
      0 6px 18px rgba(18, 24, 33, .16),
      inset 0 0 0 1.5px rgba(255, 255, 255, .16);
    pointer-events: none;
    z-index: 0;
  }

  .pshell-frame::after {
    content: '';
    position: absolute;
    inset: calc(var(--pshell-bezel) - 3px);
    border-radius: calc(var(--pshell-radius) + 3px);
    box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .55);
  }

  .pshell-btn {
    position: absolute;
    width: 3px;
    border-radius: 3px;
    background: linear-gradient(180deg, #33363d, #1c1e23);
  }

  .pshell-btn-silent {
    left: -2px;
    top: 13.5%;
    height: 26px;
  }

  .pshell-btn-up {
    left: -2px;
    top: 20.5%;
    height: 54px;
  }

  .pshell-btn-down {
    left: -2px;
    top: 29.5%;
    height: 54px;
  }

  .pshell-btn-power {
    right: -2px;
    top: 24%;
    height: 78px;
  }

  /* 屏幕：状态栏以下交给应用本身 */
  html body #app {
    position: fixed;
    left: 50%;
    top: calc(50% + var(--pshell-status) / 2);
    transform: translate(-50%, -50%);
    width: var(--pshell-w);
    height: calc(var(--pshell-h) - var(--pshell-status));
    overflow: clip;
    background: var(--pshell-chrome);
    border-radius: 0 0 var(--pshell-radius) var(--pshell-radius);
    z-index: 1;
  }

  /* 状态栏、灵动岛与home指示条 */
  .pshell-screen {
    display: block;
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: var(--pshell-w);
    height: var(--pshell-h);
    border-radius: var(--pshell-radius);
    overflow: hidden;
    pointer-events: none;
    z-index: 2;
  }

  .pshell-status {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: var(--pshell-status);
    box-sizing: border-box;
    padding: 6px 26px 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--pshell-chrome);
    color: #111315;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  }

  .pshell-time {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: .2px;
  }

  .pshell-signals {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .pshell-island {
    position: absolute;
    left: 50%;
    top: 11px;
    transform: translateX(-50%);
    width: 112px;
    height: 32px;
    border-radius: 100px;
    background: #0b0c0e;
  }

  .pshell-island::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #15171c;
    box-shadow: inset 0 0 0 1px #2b2f36;
  }

  .pshell-home {
    position: absolute;
    left: 50%;
    bottom: 8px;
    transform: translateX(-50%);
    width: 134px;
    height: 5px;
    border-radius: 100px;
    background: rgba(17, 19, 23, .82);
  }

  /* 外壳内应用布局：整页居中改为外壳约束宽度，滚动收进页面容器 */
  html body uni-page-body {
    max-width: none;
    min-height: 100%;
  }

  html body uni-page-head .uni-page-head {
    max-width: none;
    left: 0;
    right: 0;
    transform: none;
  }

  html body uni-tabbar .uni-tabbar,
  html body uni-tabbar.uni-tabbar-bottom .uni-tabbar {
    max-width: none;
    width: 100%;
    left: 0;
    right: 0;
    transform: none;
    padding-bottom: 14px;
  }

  /* H5 默认滚动整个文档，外壳内改由页面容器滚动，机身与导航才能固定 */
  html body uni-page-wrapper {
    box-sizing: border-box;
    height: calc(100% - var(--pshell-head));
    padding-bottom: 14px; /* 桌面取不到真实安全区，为 home 指示条留位 */
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
  }

  html body uni-app.uni-app--showtabbar uni-page-wrapper {
    height: calc(100% - var(--pshell-head) - var(--pshell-tabbar));
  }

  html body uni-page-wrapper::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
  }

  html body .detail-action-bar {
    padding-bottom: 22px;
  }

  /* uni 的 toast/modal/actionSheet 以及自定义底部抽屉挂在 body/根上，需收回机身屏幕内 */
  .house-modal-root,
  .select-sheet-root,
  html body .uni-mask,
  html body uni-toast,
  html body .uni-picker,
  html body .uni-picker-custom,
  html body uni-picker,
  html body .uni-picker__mask {
    position: fixed !important;
    top: calc(50% + var(--pshell-status) / 2) !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    width: var(--pshell-w) !important;
    height: calc(var(--pshell-h) - var(--pshell-status)) !important;
    transform: translate(-50%, -50%) !important;
    border-radius: 0 0 var(--pshell-radius) var(--pshell-radius) !important;
    overflow: hidden !important;
    z-index: 1000 !important;
  }

  html body .uni-modal,
  html body .uni-actionsheet,
  html body .uni-picker-custom .uni-picker {
    margin-top: calc(var(--pshell-status) / 2);
  }

  .select-sheet-panel,
  .house-modal-sheet {
    padding-bottom: 24px !important;
  }

  /* 房屋切换需要连同导航标题一起遮罩，避免遮罩边界切过文字。 */
  .house-modal-root {
    top: 50% !important;
    height: var(--pshell-h) !important;
    border-radius: var(--pshell-radius) !important;
  }
}
