/* 手机预览 · 左侧悬浮抽屉
   把成片放进模拟手机里检验真实观看效果：竖屏/横屏摆放、类抖音 UI、上下滑动切换。
   仅作用于 index.html 的 #phonePreview / #phonePreviewTab，不影响站点其他页面。 */

/* ---------- 收起时的悬浮入口（左侧竖向胶囊） ---------- */
.pp-tab {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 89;   /* 高于任务浮条 / 菜单（60、70），低于各类弹窗（1200+） */
  writing-mode: vertical-rl;
  text-orientation: upright;
  letter-spacing: 5px;
  padding: 16px 8px 14px;
  border: 1px solid var(--border, #1f2d3b);
  border-left: 0;
  border-radius: 0 16px 16px 0;
  background: linear-gradient(160deg, var(--shell-card, #0f1922), var(--shell-bg, #070d12));
  color: #cfe3da;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 3px 0 16px rgba(0, 0, 0, .28);
  transition: color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.pp-tab:hover {
  color: #4be3b0;
  transform: translateY(-50%) translateX(2px);
  box-shadow: 5px 0 22px rgba(0, 0, 0, .36), 0 0 12px rgba(45, 212, 167, .22);
}

/* ---------- 抽屉 ---------- */
.pp-drawer {
  --pp-w: min(356px, 88vw);
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--pp-w);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 12px 10px;
  background: linear-gradient(180deg, var(--shell-card, #0f1922), var(--shell-bg, #070d12));
  border-right: 1px solid rgba(255, 255, 255, .07);
  box-shadow: 14px 0 44px rgba(0, 0, 0, .38);
  color: #dce7f0;
  overflow: hidden;
  animation: pp-slide-in .26s ease;
  transition: width .34s cubic-bezier(.5, .05, .2, 1);
}
/* 用户拖拽过的宽度（JS 写入 --pp-custom-w），优先级高于默认值；
   竖/横屏的预设切换由 JS 在拖动值基础上夹取，不再直接改 --pp-w */
.pp-drawer.has-custom-w { --pp-w: var(--pp-custom-w, var(--pp-w)); }
@keyframes pp-slide-in {
  from { transform: translateX(-100%); opacity: .4; }
  to   { transform: translateX(0);     opacity: 1; }
}

.pp-head { display: flex; align-items: center; gap: 8px; flex: none; }
.pp-title {
  font-size: 14px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #eaf4ef;
}
.pp-title::before {
  content: "";
  width: 4px;
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(180deg, #6ee7b7, #10b981);
}
.pp-count {
  margin-left: auto;
  font-size: 11px;
  color: #7f93a4;
  font-variant-numeric: tabular-nums;
}
.pp-icon-btn {
  flex: none;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #9db2c2;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.pp-icon-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }

/* ---------- 工具条：方向切换 + 自动下一条 ---------- */
.pp-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 8px;
  flex: none;
}
.pp-seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .07);
}
.pp-seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #8fa4b4;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.pp-seg-btn:hover { color: #d5e3ee; }
.pp-seg-btn.is-on { background: #1c2c3a; color: #4be3b0; box-shadow: 0 1px 6px rgba(0, 0, 0, .3); }
/* 按钮里的小手机示意图 */
.pp-mock {
  display: inline-block;
  border: 1.5px solid currentColor;
  border-radius: 2.5px;
  opacity: .9;
}
.pp-mock-v { width: 8px; height: 13px; }
.pp-mock-h { width: 13px; height: 8px; }

.pp-loop {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #9db2c2;
  cursor: pointer;
  user-select: none;
}
.pp-loop input { position: absolute; opacity: 0; pointer-events: none; }
.pp-loop-box {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1.5px solid #4a6073;
  background: transparent;
  transition: background .15s ease, border-color .15s ease;
  position: relative;
}
.pp-loop input:checked + .pp-loop-box { background: #10b981; border-color: #10b981; }
.pp-loop input:checked + .pp-loop-box::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 10px;
  color: #04120c;
  font-weight: 800;
}

/* ---------- 舞台：手机 + 侧边导航 ---------- */
.pp-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-right: 32px;   /* 给右侧上/下切换条预留槽位，手机居中不会被压到 */
}

/* ---------- 手机外壳 ---------- */
.pp-phone {
  --pp-screen-w: 286px;
  position: relative;
  width: calc(var(--pp-screen-w) + 24px);
  height: calc(var(--pp-screen-w) * 2.16 + 24px);
  padding: 12px;
  border-radius: 46px;
  background:
    linear-gradient(150deg, #3d4b59 0%, #161d24 22%, #0c1117 50%, #1d252e 78%, #384654 100%);
  box-shadow:
    0 0 0 1.5px #46566554,
    0 18px 44px rgba(0, 0, 0, .55),
    0 4px 12px rgba(0, 0, 0, .4),
    inset 0 1px 1px rgba(255, 255, 255, .12);
  transition: width .38s cubic-bezier(.5, .05, .2, 1),
              height .38s cubic-bezier(.5, .05, .2, 1),
              transform .38s cubic-bezier(.5, .05, .2, 1);
  flex: none;
}
/* 横屏：宽高互换，手机顺时针躺倒（屏幕尺寸同步收窄） */
.pp-phone.is-landscape {
  --pp-screen-w: 190px;
  width: calc(var(--pp-screen-w) * 2.16 + 24px);
  height: calc(var(--pp-screen-w) + 24px);
}
/* 窄视口 / 矮视口自适应缩小 */
@media (max-height: 860px) {
  .pp-phone { --pp-screen-w: 238px; }
}
@media (max-height: 720px) {
  .pp-phone { --pp-screen-w: 206px; }
}
@media (max-width: 1240px) {
  .pp-phone { --pp-screen-w: 224px; }
}

/* 用户拖拽放大的手机：--pp-screen-w 直接由 JS 写入（覆盖媒体查询预设），
   高度仍按 2.16 屏幕比例联动 */
.pp-phone.is-zoom { --pp-screen-w: var(--pp-phone-w, 286px); }

/* 边缘拖拽热区：竖屏拖右缘（横向），横屏拖下缘（纵向），双击恢复自动 */
.pp-phone-edge {
  position: absolute;
  z-index: 5;
  cursor: ew-resize;
  touch-action: none;
  opacity: 0;
  transition: opacity .15s ease;
}
.pp-phone-edge-r { top: 12%; right: -7px; width: 12px; height: 76%; }
.pp-phone-edge-b {
  left: 12%; bottom: -7px; height: 12px; width: 76%;
  cursor: ns-resize;
  display: none;
}
.pp-phone.is-landscape .pp-phone-edge-r { display: none; }
.pp-phone.is-landscape .pp-phone-edge-b { display: block; }
.pp-phone:hover .pp-phone-edge,
.pp-phone-edge.is-dragging { opacity: 1; }
.pp-phone-edge::after {
  content: "";
  position: absolute;
  inset: 25% 40%;
  border-radius: 2px;
  background: #4be3b0;
  clip-path: polygon(0 0, 30% 50%, 0 100%);   /* 右缘：向外三角提示 */
}
.pp-phone-edge-b::after {
  inset: 40% 25%;
  clip-path: polygon(0 0, 100% 0, 50% 100%);  /* 下缘：向下三角提示 */
}
.pp-phone-edge:focus-visible {
  outline: 1px solid rgba(75, 227, 176, .55);
  outline-offset: 1px;
  opacity: 1;
}
/* 拖手机时全局锁定光标与禁止选中，方向跟当前屏幕摆放一致 */
body.is-pp-phone-resizing {
  cursor: ew-resize;
  user-select: none;
}
body.is-pp-phone-resizing.is-pp-landscape {
  cursor: ns-resize;
}
body.is-pp-phone-resizing .pp-drawer { transition: none; }

/* 侧边按键：竖屏在右侧，横屏随外壳一起变换到「上边」 */
.pp-side-btn {
  position: absolute;
  background: linear-gradient(90deg, #2b3743, #4a5a6a);
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .5);
}
.pp-power { right: -3px; top: 26%; width: 3px; height: 11%; }
.pp-vol { right: -3px; top: 16%; width: 3px; height: 7%; }

/* ---------- 屏幕 ---------- */
.pp-screen {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 34px;
  overflow: hidden;
  background: #000;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .05);
}
/* 灵动岛 / 前置摄像头（横屏时移到左侧短边） */
.pp-island {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 54px;
  height: 15px;
  border-radius: 9px;
  background: #000d;
  z-index: 4;
  pointer-events: none;
  transition: top .2s, left .2s, transform .2s, width .2s, height .2s;
}
.pp-island::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #1d2b3a, #05080c 70%);
  box-shadow: inset 0 0 1px #3b556e;
}
.pp-phone.is-landscape .pp-island {
  top: 50%;
  left: 8px;
  transform: translateY(-50%);
  width: 15px;
  height: 54px;
}
.pp-phone.is-landscape .pp-island::after {
  right: auto;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
}
.pp-phone.is-landscape .pp-side-btn { display: none; }

/* 状态栏（叠在视频上，类真实短视频 App） */
.pp-statusbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px 0 calc(var(--pp-screen-w) * 0.06);
  height: 28px;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, .34), transparent);
}
.pp-phone.is-landscape .pp-statusbar { padding-left: 14px; }
.pp-status-time { text-shadow: 0 1px 2px rgba(0, 0, 0, .6); }
.pp-status-right {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding-right: 14px;
}
.pp-status-right svg { fill: #fff; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .5)); }
.pp-battery {
  width: 18px;
  height: 9px;
  border: 1.2px solid rgba(255, 255, 255, .85);
  border-radius: 2.5px;
  padding: 1px;
  position: relative;
}
.pp-battery::after {
  content: "";
  position: absolute;
  right: -3px;
  top: 2.2px;
  width: 1.6px;
  height: 3.4px;
  border-radius: 0 1px 1px 0;
  background: rgba(255, 255, 255, .85);
}
.pp-battery i { display: block; height: 100%; width: 78%; border-radius: 1px; background: #fff; }

/* ---------- 视频流（上下滑动的刷抖音列表） ---------- */
.pp-feed {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  outline: none;
  background: #000;
}
.pp-feed::-webkit-scrollbar { display: none; }

.pp-item {
  position: relative;
  width: 100%;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  overflow: hidden;
  background: #05070a;
}
.pp-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: var(--pp-fit, cover);
  background: #000;
  cursor: pointer;
}
.pp-phone.is-fit-contain { --pp-fit: contain; }
.pp-video.has-controls {
  background: #000;
}

/* 视频上的遮罩与叠层 */
.pp-scrim-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 22%;
  background: linear-gradient(180deg, rgba(0, 0, 0, .4), transparent);
  pointer-events: none;
  z-index: 2;
}
.pp-scrim-bottom {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 34%;
  background: linear-gradient(0deg, rgba(0, 0, 0, .55), transparent);
  pointer-events: none;
  z-index: 2;
}

/* 类抖音右侧操作栏 */
.pp-rail {
  position: absolute;
  right: 8px;
  bottom: 64px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #fff;
}
.pp-avatar-wrap { position: relative; margin-bottom: 2px; }
.pp-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  color: #04120c;
  background: linear-gradient(135deg, #6ee7b7, #10b981);
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .85);
}
.pp-avatar-follow {
  position: absolute;
  left: 50%;
  bottom: -7px;
  transform: translateX(-50%);
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fe2c55;
  color: #fff;
  font-size: 11px;
  line-height: 15px;
  text-align: center;
  font-weight: 800;
}
.pp-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: 0;
  padding: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .55));
}
.pp-action svg { width: 24px; height: 24px; fill: #fff; transition: transform .15s ease; }
.pp-action span { font-size: 10px; font-variant-numeric: tabular-nums; }
.pp-action:hover svg { transform: scale(1.12); }
.pp-action.is-liked svg { fill: #fe2c55; }
.pp-action.is-off svg { opacity: .42; }
.pp-action-num { font-size: 10px; }
/* 旋转唱片 */
.pp-disc {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #1c2733 0 5px, #0b0f14 6px 13px, #22303d 14px 15px, #0b0f14 16px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .5);
  display: grid;
  place-items: center;
  font-size: 11px;
  animation: pp-spin 6s linear infinite;
  animation-play-state: paused;
}
.pp-item.is-playing .pp-disc { animation-play-state: running; }
@keyframes pp-spin { to { transform: rotate(360deg); } }

/* 底部文案区（标题 + 话题 + 作者） */
.pp-caption {
  position: absolute;
  left: 10px;
  right: 52px;
  bottom: 26px;
  z-index: 3;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .65);
}
.pp-author {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}
.pp-author-pill {
  font-size: 9px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .16);
  color: #eafff6;
}
.pp-line2 {
  font-size: 11px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pp-tags { margin-top: 4px; font-size: 11px; color: #bcd6ff; }

/* 中央播放/暂停反馈 */
.pp-play-state {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.pp-play-state span {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .42);
  backdrop-filter: blur(2px);
  color: #fff;
  font-size: 20px;
  display: grid;
  place-items: center;
  animation: pp-pop .55s ease forwards;
}
@keyframes pp-pop {
  0%   { transform: scale(.6); opacity: 0; }
  25%  { transform: scale(1);  opacity: 1; }
  70%  { opacity: 1; }
  100% { transform: scale(1.15); opacity: 0; }
}

/* 首页横条 */
.pp-home-bar {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  width: 32%;
  height: 3.5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .8);
  z-index: 3;
  pointer-events: none;
}

/* 横屏时屏幕矮，图标栏收紧并去掉文字，免得溢出被裁 */
.pp-phone.is-landscape .pp-rail { gap: 6px; bottom: 34px; }
.pp-phone.is-landscape .pp-action span { display: none; }
.pp-phone.is-landscape .pp-action svg { width: 20px; height: 20px; }
.pp-phone.is-landscape .pp-avatar,
.pp-phone.is-landscape .pp-disc { width: 24px; height: 24px; }
.pp-phone.is-landscape .pp-avatar-follow,
.pp-phone.is-landscape .pp-disc { display: none; }
.pp-phone.is-landscape .pp-caption { bottom: 12px; right: 42px; }
.pp-phone.is-landscape .pp-author { margin-bottom: 0; font-size: 11px; }
.pp-phone.is-landscape .pp-line2 { -webkit-line-clamp: 1; }
.pp-phone.is-landscape .pp-tags,
.pp-phone.is-landscape .pp-home-bar { display: none; }

/* 单条视频的错误提示 */
.pp-item-err {
  position: absolute;
  inset: auto 12px 42%;
  z-index: 3;
  margin: 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(239, 68, 68, .18);
  border: 1px solid rgba(239, 68, 68, .45);
  color: #ffd9d9;
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

/* 空态 */
.pp-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #9db2c2;
  font-size: 13px;
}
.pp-empty p { margin: 0; }
.pp-empty-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 15px;
  color: #4be3b0;
  background: rgba(45, 212, 167, .1);
  border: 1px solid rgba(45, 212, 167, .3);
  margin-bottom: 6px;
}
.pp-empty-note { font-size: 11px; color: #6c8093; max-width: 200px; text-align: center; line-height: 1.6; }

/* ---------- 侧边上下切换（浮在舞台右边，不占手机布局宽度） ---------- */
.pp-nav {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: none;
  z-index: 3;
}
.pp-nav-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(255, 255, 255, .06);
  color: #9db2c2;
  font-size: 10px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.pp-nav-btn:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.pp-nav-no {
  font-size: 10px;
  color: #7f93a4;
  font-variant-numeric: tabular-nums;
}

.pp-tip {
  flex: none;
  margin: 0;
  font-size: 10.5px;
  line-height: 1.6;
  color: #6c8093;
  text-align: center;
}

/* ---------- 右边缘拉宽手柄（像拉窗口一样调抽屉宽度） ---------- */
.pp-resize-handle {
  position: absolute;
  top: 0;
  right: -5px;          /* 骑在抽屉右边缘上，外溢 4px 方便命中 */
  width: 9px;
  height: 100%;
  z-index: 6;
  cursor: col-resize;
  background: transparent;
  border: 0;
  padding: 0;
  touch-action: none;   /* 触摸屏上拖拽时不触发页面滚动 */
  opacity: 0;
  transition: opacity .15s ease;
}
.pp-resize-handle::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 50%;
  width: 3px;
  height: 54px;
  border-radius: 3px;
  transform: translateY(-50%);
  background: rgba(126, 200, 168, .38);
  transition: background .15s ease, height .22s ease;
}
.pp-drawer:hover .pp-resize-handle,
.pp-resize-handle:focus-visible,
body.is-pp-resizing .pp-resize-handle { opacity: 1; }
.pp-resize-handle:hover::after,
.pp-resize-handle:focus-visible::after,
.pp-resize-handle.is-dragging::after {
  background: #4be3b0;
  height: 84px;
}
.pp-resize-handle:focus-visible {
  outline: 1px solid rgba(75, 227, 176, .55);
  outline-offset: -3px;
}
/* 拖拽中：压掉宽度过渡动画跟手，并全局保持横向拖拽光标、禁选文字 */
body.is-pp-resizing {
  cursor: col-resize;
  user-select: none;
}
body.is-pp-resizing .pp-drawer {
  transition: none;
  animation: none;
}

/* 手机预览抽屉为悬浮层：始终盖在导演台上方，开合 / 拉宽都不挤压主内容 */
