/* ==========================================================================
   phone.css — 手机外壳（T3；META-PLAN M1 加了图标角标与 home 指示条）
   负责：舞台/手机边框、状态栏、锁屏、桌面 + dock、home 指示条、
         顶部横幅 toast、头像基础样式
   不负责：微信 app 内部（css/app.css，T4）
   对 T4 的约定：
     - 变量 --sb-h 是状态栏高度，#app-root 已自带 padding-top: var(--sb-h)
     - 变量 --home-bar-h 是底部 home 指示条的高度，#app-root 已自带等高的
       padding-bottom（含安全区）——app 自己不用再为那根横条留位置
     - #app-root 内容区背景默认白，状态栏在 app 态自动转深色文字
     - 头像用 .avatar / .avatar--sm / .avatar--lg（由 js/avatar.js 生成）
   ========================================================================== */

:root {
  --sb-h: 44px;                    /* 状态栏高度（不含安全区） */
  --home-bar-h: 15px;              /* app 态底部 home 指示条的高度（不含安全区） */
  --phone-w: 390px;
  --phone-h: 844px;
  --icon: 60px;                    /* 桌面图标边长（iOS 在 390 宽下就是 60） */
  --home-pad: 27px;                /* 桌面左右留白：27 + 60×4 + 32×3 + 27 = 390 */
  --font-ui: -apple-system, "PingFang SC", "Helvetica Neue", sans-serif;

  /* 锁屏壁纸：深灰蓝夜色 + 右上暖橙暮光。刻意避开 purple/violet/indigo */
  --wall-ink: #0c1319;
  --wall-slate: #1a2530;
  --wall-teal: rgba(56, 122, 120, 0.40);
  --wall-amber: rgba(232, 160, 84, 0.34);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-ui);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: #15181b;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   舞台与手机
   -------------------------------------------------------------------------- */

#stage {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#phone {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--wall-ink);
  color: #fff;
  font-size: 16px;
  line-height: 1.45;
  isolation: isolate;
}

/* 屏幕层叠：桌面在底，app 在中，锁屏在上 */
#screen-home { z-index: 1; }
#app-root    { z-index: 2; }
#screen-lock { z-index: 3; }
#home-bar    { z-index: 4; }
#statusbar   { z-index: 5; }
#toast-layer { z-index: 9; }

#screen-lock, #screen-home, #app-root {
  position: absolute;
  inset: 0;
}

.is-hidden { display: none !important; }

/* 壁纸：iOS 系统壁纸那种多层大光斑，锁屏与桌面各一张（真机也是两张不同的）。
   全部避开靛紫，锁屏走夜色、桌面走暮色。 */
.wallpaper { background-color: var(--wall-ink); }

/* 锁屏：深灰蓝夜色 + 右上暖橙暮光 + 左下青绿 */
.wallpaper--lock {
  background-image:
    radial-gradient(115% 70% at 80% 8%,  var(--wall-amber), transparent 58%),
    radial-gradient(95% 65% at 12% 92%,  var(--wall-teal),  transparent 62%),
    radial-gradient(60% 40% at 62% 62%,  rgba(255, 255, 255, 0.05), transparent 70%),
    linear-gradient(168deg, var(--wall-slate) 0%, #131c25 46%, var(--wall-ink) 100%);
}

/* 桌面：暮色橙粉 + 一角青绿。底子压得比锁屏暗，白色图标标签才读得清 */
.wallpaper--home {
  background-color: #1b1210;
  background-image:
    radial-gradient(84% 54% at 20% 10%, rgba(236, 130, 78, 0.62), transparent 68%),
    radial-gradient(76% 50% at 92% 62%, rgba(214, 88, 108, 0.52), transparent 70%),
    radial-gradient(80% 52% at 2% 96%,  rgba(52, 142, 136, 0.50), transparent 72%),
    radial-gradient(42% 30% at 58% 26%, rgba(246, 198, 148, 0.30), transparent 74%),
    linear-gradient(163deg, #35211b 0%, #241618 50%, #17100f 100%);
}

/* 桌面壁纸再压一层暗角，图标标签更清楚 */
#screen-home.wallpaper::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.16) 0%, rgba(0, 0, 0, 0.02) 34%, rgba(0, 0, 0, 0.3) 100%);
  pointer-events: none;
}

/* clipPath 的容器，只是给 url(#cm-squircle) 一个落脚点，不占位 */
.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   状态栏
   -------------------------------------------------------------------------- */

#statusbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--sb-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 22px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: #fff;
  pointer-events: none;
  user-select: none;
}

.sb-time { font-variant-numeric: tabular-nums; }

.sb-right {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* 信号 / Wi-Fi / 电量：SF 风内联 SVG，一律 currentColor，跟着 #statusbar 的 color 翻面 */
.sb-ico {
  display: block;
  height: 11.5px;
  width: auto;
  color: inherit;
}
.sb-ico--bat { height: 12.5px; }

/* 沉浸态（Shell.setImmersive(true)，看大图时用）：状态栏整条收起来。
   app 的界面在 #app-root（z-index 2）里，压不过这条 z-index 5 的兄弟节点，
   所以「看图时顶上漏出周三 09:00」只能由外壳把它隐掉。home 指示条照旧留着（iOS 也留）。 */
#phone[data-immersive="1"] #statusbar { display: none; }

/* app 态：白底界面下状态栏转深色文字 + 磨砂底 */
#phone[data-screen="app"] #statusbar {
  color: #111214;
  background: rgba(249, 249, 249, 0.86);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
}

/* --------------------------------------------------------------------------
   锁屏
   -------------------------------------------------------------------------- */

#screen-lock {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: calc(var(--sb-h) + env(safe-area-inset-top, 0px) + 30px) 18px 12px;
  touch-action: none;
  cursor: grab;
  transition: transform 0.42s cubic-bezier(0.22, 0.9, 0.24, 1), opacity 0.42s ease;
}
#screen-lock.is-dragging {
  transition: none;
  cursor: grabbing;
}
#screen-lock.is-unlocked {
  transform: translateY(-100%);
  opacity: 0;
}

.lock-clock {
  text-align: center;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.45);
}
.lock-date {
  font-size: 17px;
  font-weight: 600;
  opacity: 0.9;
  letter-spacing: 0.4px;
  margin-bottom: 2px;
}
.lock-time {
  font-size: 88px;
  font-weight: 200;
  line-height: 1;
  letter-spacing: -3px;
  font-variant-numeric: tabular-nums;
}

/* 锁屏下半：通知堆叠 → 手电/上滑/相机 → home 条（iOS 16 起通知就在底部） */
.lock-bottom {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.lock-notes {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 一条通知卡：左边微信小图标、右边粗体发件人 + 一行正文，磨砂底。
   它是个 <button>：点了就解锁进微信（iOS 点通知的行为）。 */
.lock-note {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  text-align: left;
  gap: 10px;
  padding: 11px 13px;
  border-radius: 19px;
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.13);
  border: 0.5px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  transition: transform 0.12s ease, background 0.12s ease;
}
.lock-note:active { transform: scale(0.98); background: rgba(255, 255, 255, 0.2); }
.lock-note:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.85); outline-offset: 2px; }
/* 堆叠：越往下越窄一点、透一点，像压在底下的那几条 */
.lock-note--behind {
  margin: 0 5px;
  opacity: 0.88;
}
/* 堆叠最下面那一线：真锁屏「还有更多通知」的暗示 */
.lock-note-stack {
  height: 5px;
  margin: -3px 12px 0;
  border-radius: 0 0 12px 12px;
  background: rgba(255, 255, 255, 0.10);
}

.lock-note-body { min-width: 0; }
.lock-note-title {
  font-size: 13.5px;
  font-weight: 600;
  opacity: 0.96;
  line-height: 1.3;
}
.lock-note-text {
  font-size: 13px;
  opacity: 0.74;
  line-height: 1.34;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lock-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  width: 100%;
}
/* 手电 / 相机：磨砂圆钮 */
.lock-round {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(255, 255, 255, 0.17);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}
.lock-round:active { transform: scale(0.9); background: rgba(255, 255, 255, 0.3); }
.lock-round svg { width: 21px; height: 21px; display: block; }

.lock-hint {
  flex: 1 1 auto;
  text-align: center;
  font-size: 14px;
  opacity: 0.75;
  letter-spacing: 1px;
  animation: lockHintBreathe 2.4s ease-in-out infinite;
}
.lock-hint-arrow {
  display: block;
  text-align: center;
  font-size: 12px;
  opacity: 0.6;
  margin-bottom: 2px;
}
@keyframes lockHintBreathe {
  0%, 100% { opacity: 0.42; transform: translateY(2px); }
  50%      { opacity: 0.88; transform: translateY(-2px); }
}
@media (prefers-reduced-motion: reduce) {
  .lock-hint { animation: none; opacity: 0.7; }
}
.home-indicator {
  width: 134px;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.85);
}

/* --------------------------------------------------------------------------
   桌面
   -------------------------------------------------------------------------- */

#screen-home {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: calc(var(--sb-h) + env(safe-area-inset-top, 0px) + 12px) var(--home-pad) 10px;
}
#screen-home > * { position: relative; z-index: 1; }

/* 顶部两个 2×2 小组件：宽度与列间距都跟图标网格对齐
   （两个小组件的间距 = 图标之间的间距 = (可用宽 − 4×图标) / 3） */
.home-widgets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: calc((100% - var(--icon) * 4) / 3);
  margin-bottom: 14px;
}
.widget {
  aspect-ratio: 1 / 1;
  border-radius: 22px;
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

/* 天气：城市 + 天气说法 + 太阳云，底下一句给红娘看的提醒。不报温度（外壳只有钟和日历出数字） */
.widget-weather {
  position: relative;
  background: linear-gradient(168deg, #4fa9de 0%, #2f8bc2 48%, #1d6fa8 100%);
  color: #fff;
}
.wg-city { font-size: 15px; font-weight: 600; letter-spacing: 0.3px; }
.wg-cond { font-size: 12.5px; opacity: 0.82; margin-top: 1px; }
.wg-sky {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 48px;
  height: 48px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.18));
}
.wg-note {
  margin-top: auto;
  font-size: 11.5px;
  line-height: 1.36;
  opacity: 0.9;
}

/* 日历：红字星期 + 大号日期 + 今天那件正事 */
.widget-cal {
  background: linear-gradient(180deg, #ffffff, #f4f4f6);
  color: #1b1c1e;
}
.wg-cal-head { display: flex; flex-direction: column; align-items: flex-start; }
.wg-cal-week { font-size: 13px; font-weight: 700; color: #f0453c; letter-spacing: 0.6px; }
.wg-cal-day {
  font-size: 40px;
  font-weight: 300;
  line-height: 1.02;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}
.wg-cal-ev {
  margin-top: auto;
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 12px;
  line-height: 1.35;
  color: #3a3b3f;
  padding-top: 8px;
  border-top: 0.5px solid rgba(0, 0, 0, 0.1);
}
.wg-cal-ev i {
  flex: 0 0 auto;
  width: 3px;
  align-self: stretch;
  min-height: 26px;
  border-radius: 2px;
  background: #f0453c;
}

/* 图标网格：四列，剩下的高度里上下均分 */
.home-grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(4, var(--icon));
  justify-content: space-between;
  align-content: space-evenly;
  row-gap: 6px;
}

.app-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  border: 0;
  padding: 0;
  background: none;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.app-icon:active { transform: scale(0.9); opacity: 0.8; }
.app-icon:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.85); outline-offset: 3px; border-radius: 16px; }

/* 投影挂在外层盒子上：裁切过的元素自己投不出影。
   position: relative 是给右上角那颗角标 pill 当锚点用的（不裁切，允许越界）。 */
.tile-box {
  position: relative;
  width: var(--icon);
  height: var(--icon);
  border-radius: 23%;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}
/* 超椭圆裁切：iOS 图标的角是连续曲率，不是正圆角 */
.app-tile {
  position: relative;
  width: 100%;
  height: 100%;
  clip-path: url(#cm-squircle);
  background: linear-gradient(170deg, #f4f4f6, #e2e2e6);
}
.app-tile > svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* 未读角标：iOS 的红色数字 pill，压在图标右上角、越界一点。
   数字是 UI 部件（iOS/微信本来就这样），是「零阿拉伯数字」那条红线放行的部分。 */
.app-badge {
  position: absolute;
  top: -5px;
  right: -7px;
  display: none;
  min-width: 21px;
  height: 21px;
  padding: 0 6px;
  border-radius: 11px;
  background: #ff3b30;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 21px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.32);
  pointer-events: none;
}
.app-badge.is-on { display: block; }

.app-label {
  font-size: 11.5px;
  font-weight: 400;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
  white-space: nowrap;
  max-width: calc(var(--icon) + 22px);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 各图标的底：内部图形是内联 SVG，底色渐变在这儿。
   色相一律避开靛蓝—紫（220–305 度），最蓝的浏览 / 邮件也只到 205 左右。 */
.tile-files      { background: linear-gradient(170deg, #ffffff, #f1f1f4); }
.tile-messages   { background: linear-gradient(170deg, #6ee47c, #17c64a); }
.tile-phone      { background: linear-gradient(170deg, #6de87f, #16be41); }
.tile-wechat     { background: linear-gradient(170deg, #7ad65c, #3ea02e); }
.tile-safari     { background: linear-gradient(170deg, #f7fafc, #dbe3ea); }
.tile-camera     { background: linear-gradient(170deg, #e0e1e4, #a8aab0); }
.tile-photos     { background: linear-gradient(170deg, #ffffff, #f0f0f3); }
.tile-maps       { background: linear-gradient(170deg, #eef3e7, #dfe8da); }
.tile-weather    { background: linear-gradient(170deg, #62bdf0, #1f7fc4); }
.tile-clock      { background: linear-gradient(170deg, #26262a, #0a0a0c); }
.tile-notes      { background: linear-gradient(180deg, #fffef8, #f5f1e2); }
.tile-reminders  { background: linear-gradient(170deg, #ffffff, #f1f1f4); }
.tile-calculator { background: linear-gradient(170deg, #3a3a3d, #1c1c1e); }
.tile-settings   { background: linear-gradient(170deg, #b8babf, #75777d); }
.tile-calendar   { background: linear-gradient(180deg, #ffffff, #f4f4f6); }
.tile-mail       { background: linear-gradient(170deg, #4fb4f5, #1876c8); }
.tile-music      { background: linear-gradient(170deg, #fc5c63, #e0304f); }
.tile-health     { background: linear-gradient(170deg, #ffffff, #f4f4f7); }
.tile-wallet     { background: linear-gradient(170deg, #2f2f33, #131315); }
.tile-contacts   { background: linear-gradient(170deg, #fdfbf4, #ece5d5); }

/* 页面指示点 */
.home-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
  padding: 10px 0 12px;
}
.home-dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.32);
}
.home-dots i.on { background: rgba(255, 255, 255, 0.95); }

/* dock：毛玻璃，四个图标不带文字 */
.home-dock {
  display: grid;
  grid-template-columns: repeat(4, var(--icon));
  justify-content: space-between;
  padding: 10px 16px;
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.15);
  border: 0.5px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(24px) saturate(170%);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
.home-dock .app-label { display: none; }
.home-dock .app-icon { gap: 0; }

/* 锁屏通知卡里的那颗小图标 */
.tile-box--note {
  width: 34px;
  height: 34px;
  border-radius: 26%;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.22);
}

/* --------------------------------------------------------------------------
   app 容器
   -------------------------------------------------------------------------- */

#app-root {
  padding-top: calc(var(--sb-h) + env(safe-area-inset-top, 0px));
  /* 底部给 home 指示条留一条位置：横条压不到 app 的 tab / 主按钮上 */
  padding-bottom: calc(var(--home-bar-h) + env(safe-area-inset-bottom, 0px));
  background: #f2f2f7;
  color: #111214;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* --------------------------------------------------------------------------
   app 态底部 home 指示条（回桌面：上滑或点它）
   -------------------------------------------------------------------------- */

/* 整条是个悬浮层，但只有中间那根横条收手势——其余部分 pointer-events: none，
   免得挡住 app 底部的按钮。锁屏 / 桌面态整条不显示（桌面自己带 .home-indicator）。 */
#home-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--home-bar-h) + env(safe-area-inset-bottom, 0px));
  display: none;
  align-items: center;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  pointer-events: none;
}
#phone[data-screen="app"] #home-bar { display: flex; }

.home-bar-grip {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  margin: 0;
  padding: 5px 24px;
  background: none;
  line-height: 0;
  cursor: pointer;
  pointer-events: auto;
  touch-action: none;
}
.home-bar-grip i {
  display: block;
  width: 134px;
  height: 5px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.32);
  transition: background 0.14s ease, transform 0.14s ease;
}
.home-bar-grip:active i { background: rgba(0, 0, 0, 0.55); transform: scaleX(0.94); }
.home-bar-grip:focus-visible i { background: rgba(0, 0, 0, 0.6); }
/* 深色 app 底（js/shell.js 采样底色后加的类）：横条翻成浅色 */
#home-bar.home-bar--light .home-bar-grip i { background: rgba(255, 255, 255, 0.82); }
#home-bar.home-bar--light .home-bar-grip:active i { background: #fff; }

/* --------------------------------------------------------------------------
   toast：iOS 顶部横幅
   -------------------------------------------------------------------------- */

#toast-layer {
  position: absolute;
  top: calc(var(--sb-h) + env(safe-area-inset-top, 0px) + 4px);
  left: 0;
  right: 0;
  padding: 0 10px;
  pointer-events: none;
}

.toast {
  padding: 13px 16px;
  border-radius: 20px;
  background: rgba(32, 34, 37, 0.9);
  border: 0.5px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.34);
  color: #f4f4f6;
  font-size: 14.5px;
  line-height: 1.42;
  transform: translateY(-140%);
  opacity: 0;
  transition: transform 0.38s cubic-bezier(0.2, 0.9, 0.25, 1), opacity 0.28s ease;
}
.toast.is-in {
  transform: translateY(0);
  opacity: 1;
}

/* --------------------------------------------------------------------------
   头像基础样式（内容由 js/avatar.js 注入）
   -------------------------------------------------------------------------- */

.avatar {
  --avatar-size: 44px;
  flex: 0 0 auto;
  width: var(--avatar-size);
  height: var(--avatar-size);
  border-radius: 4px;                 /* 微信风方角 */
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 500;
  font-size: calc(var(--avatar-size) * 0.44);
  line-height: 1;
  letter-spacing: 0;
  user-select: none;
  overflow: hidden;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.avatar--sm { --avatar-size: 44px; }
.avatar--md { --avatar-size: 56px; }
.avatar--lg { --avatar-size: 72px; }

/* --------------------------------------------------------------------------
   响应式：≤500px 真手机占满；>500px 居中手机边框
   -------------------------------------------------------------------------- */

@media (min-width: 501px) {
  body {
    /* 低调桌面底色，不用渐变噪点 */
    background:
      radial-gradient(80% 60% at 50% 0%, #23282d 0%, #1a1e22 55%, #141719 100%);
  }

  #stage { padding: 24px; position: relative; }

  /* iPhone 侧键。#phone 自己是 overflow:hidden，边框上画不了东西，所以挂在舞台上，
     按「舞台中心 = 手机中心」定位（手机是被 flex 居中的）。偏移量都压在中心 ±260px
     以内，视口矮到手机被 max-height 压缩时也不会露到机身外面。
     左边一条 4px 宽的竖条上用三层背景画静音拨片 / 音量加 / 音量减，右边一条画电源键。 */
  #stage::before,
  #stage::after {
    content: "";
    position: absolute;
    width: 3.5px;
    background-repeat: no-repeat;
    background-image:
      linear-gradient(#31333799, #2a2c30),
      linear-gradient(#31333799, #2a2c30),
      linear-gradient(#31333799, #2a2c30);
    pointer-events: none;
    z-index: 0;
  }
  /* 左：静音拨片（短）+ 音量加 / 音量减（各一段长的） */
  #stage::before {
    left: calc(50% - 209px);
    top: calc(50% - 258px);
    height: 208px;
    border-radius: 2px 0 0 2px;
    background-size: 3.5px 26px, 3.5px 56px, 3.5px 56px;
    background-position: 0 0, 0 62px, 0 130px;
  }
  /* 右：电源键（一段更长的），只用第一层 */
  #stage::after {
    left: calc(50% + 205.5px);
    top: calc(50% - 170px);
    height: 88px;
    border-radius: 0 2px 2px 0;
    background-size: 3.5px 88px, 0 0, 0 0;
    background-position: 0 0, 0 0, 0 0;
  }

  #phone {
    width: var(--phone-w);
    height: var(--phone-h);
    max-height: calc(100dvh - 48px);
    flex: 0 0 auto;
    border-radius: 52px;
    border: 11px solid #17181a;
    box-shadow:
      0 0 0 2px #35373b,
      0 34px 70px rgba(0, 0, 0, 0.6),
      inset 0 0 2px rgba(255, 255, 255, 0.12);
  }

  /* 灵动岛 */
  #phone::before {
    content: "";
    position: absolute;
    top: 11px;
    left: 50%;
    transform: translateX(-50%);
    width: 104px;
    height: 29px;
    border-radius: 16px;
    background: #000;
    z-index: 20;
    pointer-events: none;
  }

  /* 灵动岛占位：状态栏两侧内容让开中间 */
  #statusbar { padding-left: 30px; padding-right: 30px; }
}

@media (max-width: 500px) {
  #stage { align-items: stretch; }
  #phone { border-radius: 0; }
}

/* 矮屏（375×667 这一档老机型）：图标收小一点、小组件压扁，桌面仍能一屏放下不滚动 */
@media (max-height: 730px) {
  :root { --icon: 54px; --home-pad: 22px; }
  #screen-home { padding-top: calc(var(--sb-h) + env(safe-area-inset-top, 0px) + 8px); }
  .home-widgets { aspect-ratio: auto; margin-bottom: 10px; }
  .widget { aspect-ratio: 3 / 2; border-radius: 18px; padding: 10px 11px; }
  .wg-sky { width: 38px; height: 38px; }
  .wg-cal-day { font-size: 24px; }
  .wg-note, .wg-cal-ev { font-size: 11px; }
  .app-label { font-size: 11px; }
  .home-dots { padding: 6px 0 8px; }
  .home-dock { padding: 8px 14px; }
  .lock-time { font-size: 70px; }
  .lock-note-text, .lock-note-title { font-size: 12.5px; }
}
