/* =================================================================
 *  主页（仿手机版 Edge 浏览器）样式
 *  - 顶部：留空
 *  - 中部：空内容（提示信息）OR 自检调试视图（SPA 切换）
 *  - 底部：5 个图标的主导航（后退 / 前进 / 加号 / 标签页 / 菜单）
 *  - 抽屉：底部上拉的菜单面板（账号 + 4 图标 + 2 × 4 操作）
 *
 *  主题：复用 style.css 的 CSS 变量，深 / 浅色自适应
 *  响应式：
 *    - ≥1024px：手机模拟器居中显示（最大宽 420px）
 *    - <1024px：占满全屏
 *  安全区：env(safe-area-inset-*) 适配 iOS 灵动岛 / Home Indicator
 *
 *  图标系统：SVG sprite（Lucide 风格）
 *    - 所有图标都用 <svg class="icon"><use href="#icon-xxx"/></svg> 引用
 *    - 默认尺寸：24×24
 *    - 不同场景通过修饰类调整：.icon-empty-logo / .icon-theme
 * ================================================================= */

.home-body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  /* 禁止 body 自身滚动 → 浏览器无法感知滚动边界 → 根除 Safari 下拉刷新/回弹 */
  overflow: hidden;
}

/* ============= SVG 图标基础规范 ============= */
.icon {
  width: 24px;
  height: 24px;
  display: block;
  flex-shrink: 0;
  /* 让 stroke="currentColor" 跟随父元素 color */
  color: inherit;
  pointer-events: none;
}

/* ============= 主体内容 ============= */
.home-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 24px 96px;
  /* 内部可滚动，不影响 body；隐藏滚动条 */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.home-main::-webkit-scrollbar { display: none; }
.home-empty {
  text-align: center;
  opacity: 0.85;
}
.home-empty-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 96px;
  margin: 0 auto 12px;
  color: var(--muted);
  opacity: 0.85;
}
.home-empty-logo .icon-empty-logo {
  width: 64px;
  height: 64px;
}
/* 默认 Edge Logo 图片（edge-logo.svg 替换之前的 globe icon） */
.home-empty-logo img,
.home-empty-logo > img {
  width: 72px;
  height: 72px;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}
.home-empty-title {
  font-size: 22px;
  margin: 0 0 8px;
  font-weight: 600;
  color: var(--text);
}
.home-empty-tip {
  font-size: 13px;
  max-width: 280px;
  margin: 0 auto;
  line-height: 1.5;
}

/* ============= 底部主导航 ============= */
.home-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  height: calc(56px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--panel);
  border-top: 1px solid var(--border);
  /* 半透明 + 模糊：贴近 Edge 移动端质感 */
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  /* 阴影悬浮：与页面内容形成视觉分层，强调此栏位置固定不变 */
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.12);
}
.home-nav-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
  cursor: pointer;
  transition: color 0.15s, transform 0.1s;
}
.home-nav-btn:hover:not(:disabled) { color: var(--text); }
.home-nav-btn:active:not(:disabled) { transform: scale(0.92); }
.home-nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.home-nav-btn svg {
  width: 24px;
  height: 24px;
  display: block;
}

/* ============= 菜单抽屉 ============= */
.home-menu {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  /* 配合 hidden 属性做淡入淡出 */
  transition: opacity 0.22s ease;
}
.home-menu[hidden] { display: none; }
.home-menu-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: home-fade-in 0.22s ease both;
}
:root.light .home-menu-backdrop { background: rgba(15, 23, 42, 0.35); }

.home-menu-sheet {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 22px 22px 0 0;
  padding: 8px 16px calc(20px + var(--safe-bottom));
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.35);
  animation: home-slide-up 0.26s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
@keyframes home-slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
@keyframes home-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* 抽屉顶部拖动手柄 */
.home-menu-handle {
  width: 40px;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  margin: 6px auto 14px;
}

/* 账号区 */
.home-menu-account {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px 14px;
}
.home-menu-avatar {
  width: 40px !important;
  height: 40px !important;
  border-radius: 50% !important;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  color: #fff;
  background: linear-gradient(135deg, #64748b, #94a3b8);
  flex-shrink: 0;
  overflow: hidden;  /* 关键：圆形裁剪图片溢出 */
  position: relative;
}
.home-menu-avatar img,
.home-menu-avatar > img {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: cover !important;
  display: block;
  border-radius: 50%;
  /* 兼容 PWA / iOS：避免图像渲染时的颜色偏差 */
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}
.home-menu-account-info { flex: 1; min-width: 0; }
.home-menu-account-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.home-menu-account-mail {
  margin-top: 2px;
  word-break: break-all;
}
.home-menu-account-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.home-menu-account-toggle:hover { color: var(--text); border-color: var(--primary); }
.home-menu-account-toggle .icon { width: 16px; height: 16px; }

/* 4 个圆角图标（调试 / 历史记录 / 下载 / 设置） */
.home-menu-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 6px 4px 12px;
}
.home-menu-item {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 4px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s;
}
.home-menu-item:hover { background: var(--panel-2); }
.home-menu-item:active { background: var(--btn-hover); }
.home-menu-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  background: rgba(148, 163, 184, 0.15);
}
.home-menu-icon .icon { width: 20px; height: 20px; }
:root.light .home-menu-icon { background: rgba(100, 116, 139, 0.12); }
.home-menu-label { font-size: 12px; }

/* 分割线 */
.home-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0 12px;
}

/* 横向 4 项行 */
.home-menu-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 4px;
}
.home-menu-tile {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 4px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s;
}
.home-menu-tile:hover { background: var(--panel-2); }
.home-menu-tile:active { background: var(--btn-hover); }
.home-menu-tile-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: var(--muted);
}
.home-menu-tile-icon .icon { width: 22px; height: 22px; }
.home-menu-tile-label {
  font-size: 11px;
  text-align: center;
  line-height: 1.2;
  color: var(--text);
  /* 4 字以内不换行，5+ 字自动换行 */
  word-break: break-all;
}

/* ============= 主题切换按钮特殊态 ============= */
/* 激活态：浅色主题下用琥珀色（暗示"当前是亮色"），深色主题下用蓝色（暗示"当前是暗色"） */
.home-menu-tile-theme .home-menu-tile-icon {
  color: #64748b;
  background: rgba(148, 163, 184, 0.12);
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
}
.home-menu-tile-theme:hover .home-menu-tile-icon {
  background: rgba(148, 163, 184, 0.2);
}
/* 浅色主题下用琥珀色提示"已经是亮色" */
:root.light .home-menu-tile-theme .home-menu-tile-icon {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.15);
}
:root.light .home-menu-tile-theme:hover .home-menu-tile-icon {
  background: rgba(245, 158, 11, 0.25);
}

/* 底部 home indicator 装饰 */
.home-menu-indicator {
  width: 134px;
  height: 5px;
  background: var(--text);
  border-radius: 3px;
  margin: 14px auto 0;
  opacity: 0.4;
}

/* ============= Toast ============= */
.home-toast {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  padding: 10px 16px;
  border-radius: 22px;
  font-size: 13px;
  z-index: 60;
  pointer-events: none;
  animation: home-toast-in 0.2s ease both;
  max-width: 80vw;
  text-align: center;
}
:root.light .home-toast { background: rgba(15, 23, 42, 0.88); }
.home-toast[hidden] { display: none; }
@keyframes home-toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ============= 响应式：≥1024px 居中（手机模拟器） ============= */
@media (min-width: 1024px) {
  .home-body {
    align-items: center;
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  }
  .home-main {
    width: 420px;
    height: 760px;
    max-height: 86vh;
    border: 1px solid var(--border);
    border-radius: 36px;
    background: var(--bg);
    margin: 32px 0 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    padding: 24px 24px 24px;
    align-items: center;
    justify-content: center;
  }
  .home-nav {
    width: 420px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 0 0 36px 36px;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
  .home-menu-sheet { max-width: 420px; }
}

/* ============= 触摸设备 ============= */
@media (hover: none) {
  .home-menu-tile:active,
  .home-menu-item:active { transform: scale(0.97); }
}

/* ============= 减少动画（系统偏好） ============= */
@media (prefers-reduced-motion: reduce) {
  .home-menu-sheet,
  .home-menu-backdrop,
  .home-toast { animation: none; }
}

/* =================================================================
 * SPA 视图切换
 * - 主页（#view-home）和调试页（#view-debug）共用同一套底部导航
 * - 通过 [hidden] 切换：CSS 处理简单，JS 控制语义清晰
 * - 调试视图下，main.content 不再 flex 居中，而是按自己的 .layout 排版
 * ================================================================= */

/* 调试视图：占满整个主区，复用 style.css 的 .layout / .panel / .topbar 等 */
.debug-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* 底部留出固定导航栏空间（56px nav + safe-bottom），避免内容被遮挡 */
  padding-bottom: calc(80px + var(--safe-bottom, 0px));
  /* 调试页内容密度高，移动端默认 zoom:0.7（仅本视图生效） */
}

/* 调试视图的子内容需要继承主题色 */
.debug-view {
  color: var(--text);
}

/* 移动端：调试页内容密度过高，整体缩放 70% */
@media (max-width: 768px) {
  .debug-view {
    zoom: 0.7;
  }
}

/* ============= 权限门控：.gated 组件 ============= */
/* 关键：未授权时 .gated 元素隐藏（display: none）
 *       - JS 通过 window.spaSetPermission(granted) 切换
 *       - 默认情况下，.gated 元素也是 hidden（CSS + JS 双保险）
 *       - .always-on 不受权限影响（日志始终可见）
 * 已授权后：JS 直接移除 .gated 类，元素恢复自然 display
 *       （.gallery → grid，.btn → inline-flex，.gallery-actions → flex）
 *       千万不要用 `display: revert` —— revert 是回到 UA 默认（div → block），
 *       会把 .gallery 变成 block，.gallery-item 100% 宽，每行只能装一个
 *       （这是 v4 → v5 修复的核心 bug）
 */
.debug-view .gated {
  display: none;
}

/* ============= 调试视图在桌面端（≥1024px）的容器 ============= */
@media (min-width: 1024px) {
  /* 桌面端：调试视图与底部 nav 都限制在 420px 居中容器内 */
  .debug-view {
    width: 420px;
    max-height: 86vh;
    border: 1px solid var(--border);
    border-radius: 36px;
    background: var(--bg);
    margin: 32px 0 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow-y: auto;
  }
}

/* 视图切换时的过渡（防止闪烁） */
.debug-view,
.home-main {
  transition: opacity 0.18s ease;
}
.debug-view[hidden],
.home-main[hidden] {
  display: none !important;
}

/* ============= 浏览器容器（全屏 iframe）=============
 * - 加号按钮打开，书签/搜索栏在此 iframe 中加载页面
 * - 底部导航 fixed 固定，容器需留出 padding-bottom 避免 iframe 被遮挡
 * - 底部导航常驻，不受 iframe 内容影响
 * ================================================================ */
.view-browser {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  background: var(--bg);
  overflow: hidden;
  /* 顶部留出安全区，避免与手机状态栏（时间/电量/刘海）冲突 */
  padding-top: max(8px, env(safe-area-inset-top, 0px));
  /* 减去底部固定导航栏高度，避免 iframe 内容被 nav 遮挡 */
  padding-bottom: calc(80px + var(--safe-bottom, 0px));
}
.view-browser[hidden] {
  display: none !important;
}

/* iframe 包裹层：接管 flex 填充，裁剪溢出 */
.browser-iframe-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
  /* 额外底部留白，确保缩放 70% 后的内容不被底部导航遮挡 */
  padding-bottom: 4px;
}

/* iframe 本身：absolute 撑满包裹层，放大尺寸后通过 scale 缩回，实现内容缩放 */
.browser-iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 142.857%;       /* 100% / 0.7 */
  height: 142.857%;      /* 100% / 0.7 */
  border: none;
  background: var(--bg);
  display: block;
  transform: scale(0.7);
  transform-origin: top left;
}

/* 空状态（未加载任何页面时显示） */
.browser-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--muted);
  z-index: 1;
  pointer-events: none;
}
.browser-empty-icon {
  opacity: 0.4;
}
.browser-empty-text {
  font-size: 14px;
  opacity: 0.6;
  text-align: center;
  padding: 0 32px;
}

/* 在 iframe 加载后隐藏空状态 */
.view-browser.loaded .browser-empty {
  display: none;
}

/* ============= 标签页管理器（tab switcher）=============
 * - 全屏遮罩 + 居中卡片面板
 * - 卡片等比缩小显示当前标签页，带关闭按钮
 * - 点击卡片切换回全屏 iframe，点击 X 关闭标签页
 * ================================================================ */
.tab-manager {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.tab-manager[hidden] {
  display: none !important;
}
.tab-manager-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.tab-manager-panel {
  position: relative;
  width: 88%;
  max-width: 380px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tab-manager-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}
.tab-manager-title {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}
.tab-manager-count {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}
.tab-manager-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* 标签页卡片 */
.tab-card {
  position: relative;
  background: var(--panel);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.tab-card:active {
  transform: scale(0.97);
}
/* 卡片预览区：模拟浏览器窗口 */
.tab-card-preview {
  position: relative;
  width: 100%;
  height: 140px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
/* 预览区内的 iframe 微缩（只缩小当前 iframe 的视图） */
.tab-card-preview iframe {
  width: 100%;
  height: 100%;
  border: none;
  pointer-events: none;
}
/* 预览区空状态占位 */
.tab-card-preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  opacity: 0.5;
}
.tab-card-preview-placeholder svg {
  width: 36px;
  height: 36px;
}
.tab-card-preview-placeholder span {
  font-size: 12px;
}
/* 卡片底部信息栏 */
.tab-card-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--panel);
}
.tab-card-favicon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--muted);
  opacity: 0.6;
}
.tab-card-url {
  flex: 1;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
/* 关闭按钮 */
.tab-card-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  transition: background 0.2s;
}
.tab-card-close svg {
  width: 14px;
  height: 14px;
}

/* 桌面端适配 */
@media (min-width: 1024px) {
  .tab-manager-panel {
    max-width: 360px;
  }
}

/* ============= 桌面端（≥1024px）居中容器适配 ============= */
@media (min-width: 1024px) {
  .view-browser {
    width: 420px;
    max-height: 86vh;
    border: 1px solid var(--border);
    border-radius: 36px;
    background: var(--bg);
    margin: 32px 0 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
  }
  .browser-iframe-wrap {
    border-radius: 0 0 36px 36px;
  }
}

/* ============= 占位视图（历史记录 / 下载 / 最近使用的标签页） =============
 * 仿 Edge 移动端：底部抽屉样式（占 3/4 屏幕高度 + 顶部圆角 + 顶部留空）
 * - 标题居中、X 在右上角
 * - 顶部拖动手柄：仿 iOS 底部 sheet 风格
 * - 支持下滑关闭（drag-to-dismiss，threshold = 100px 或 25% 高度）
 * - 背景半透明遮罩：点击背景也能关闭
 * - [hidden] 优先于 display: flex，确保能完全隐藏
 * ================================================================= */

/* 背景遮罩：覆盖在 placeholder 之下、底部 nav / 抽屉菜单之上
 * - 单独成一个 .placeholder-backdrop 元素（不放 placeholder 内部）
 * - placeholder 显示时，遮罩同步淡入
 * - 点击遮罩 = 关闭（比 X 按钮更符合移动端习惯）
 */
.placeholder-backdrop {
  position: fixed;
  inset: 0;
  z-index: 75;  /* 在 placeholder-view (80) 之下，home-menu (50) 之上 */
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}
:root.light .placeholder-backdrop { background: rgba(15, 23, 42, 0.35); }
.placeholder-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* 抽屉主体：
 *   - bottom: 0 + height: 75vh = 占底部 3/4 屏，顶部 25% 露出主页内容
 *   - 顶部圆角（22px），底部贴边（无边角）
 *   - transform: translateY(0) ↔ translateY(100%) 配合打开/关闭动画
 *   - dragging 类：禁用 transition，让 touchmove 跟手
 */
.placeholder-view {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  /* 关键：3/4 屏幕高度（顶部留 25vh 露出主页，便于感知"背景"） */
  height: 75vh;
  max-height: 75vh;
  box-sizing: border-box;
  z-index: 80;
  background: var(--bg);
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  border: 1px solid var(--border);
  border-bottom: none;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.35);
  /* 拖动过渡：默认有 spring 缓动，dragging 时 JS 会加 .dragging 禁用 */
  transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: transform;
  /* 防止 iOS 拖到底继续橡皮筋滚动 */
  overscroll-behavior: contain;
  /* 进入动画：从底部滑上来 */
  animation: placeholder-slide-up 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  /* 安全区预留 + 底部导航留空，避免内容被遮挡 */
  padding-bottom: calc(56px + var(--safe-bottom, 0px));
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}
.placeholder-view[hidden] { display: none !important; }
@keyframes placeholder-slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* 拖动中：禁用 transition，让手指跟手 */
.placeholder-view.dragging {
  transition: none;
}
/* 关闭动画：从当前 translateY 继续下滑到 100%（覆盖整页消失） */
.placeholder-view.closing {
  transition: transform 0.24s cubic-bezier(0.4, 0, 0.6, 1);
}

/* 顶部拖动手柄（仿 iOS 底部 sheet 风格） */
.placeholder-handle {
  width: 40px;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  margin: 8px auto 4px;
  opacity: 0.7;
  flex-shrink: 0;
  /* 暗示可拖动 */
  cursor: grab;
  transition: opacity 0.15s;
}
.placeholder-handle:hover { opacity: 1; }
.placeholder-view.dragging .placeholder-handle {
  opacity: 1;
  cursor: grabbing;
}

/* 标题栏：左 spacer + 居中标题 + 右 X */
.placeholder-header {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 10px;
  padding-top: 2px;  /* 紧贴手柄 */
  padding-top: max(2px, env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}
.placeholder-header-side { width: 36px; height: 36px; }
.placeholder-title {
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  margin: 0;
  color: var(--text);
  /* 防超长标题溢出 */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.placeholder-close {
  justify-self: end;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  padding: 0;
}
.placeholder-close:hover { background: rgba(255, 255, 255, 0.12); }
.placeholder-close:active { transform: scale(0.92); }
.placeholder-close svg { width: 18px; height: 18px; display: block; }
/* 浅色主题：按钮背景用深色 */
html.light .placeholder-close { background: rgba(0, 0, 0, 0.05); }
html.light .placeholder-close:hover { background: rgba(0, 0, 0, 0.1); }

/* 中央空态文案：垂直水平居中 */
.placeholder-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  text-align: center;
  /* 防止被底部 footer 顶上来 */
  min-height: 0;
}
.placeholder-msg {
  font-size: 15px;
  color: var(--text);
  font-weight: 600;
  margin: 0 0 8px;
  line-height: 1.4;
}
.placeholder-sub {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
  max-width: 320px;
}

/* 底部：删除浏览数据按钮 */
.placeholder-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
  flex-shrink: 0;
}
.placeholder-clear-btn {
  background: transparent;
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.45);
  border-radius: 999px;
  padding: 9px 22px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  font-family: inherit;
}
.placeholder-clear-btn:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.7);
}
.placeholder-clear-btn:active { transform: scale(0.97); }
/* 浅色主题：稍微提亮一点红 */
html.light .placeholder-clear-btn { color: #dc2626; }

/* ============= 占位视图：桌面端（≥1024px）=============
 * 桌面端 420px 居中容器：抽屉左右也用 22px 圆角（顶部圆角不动）
 * 高度 75vh 保持不变；只是宽度限制在 420px 居中
 */
@media (min-width: 1024px) {
  .placeholder-view {
    /* 桌面端：左右居中，宽度 420px（同 home-main / debug-view） */
    left: 50%;
    right: auto;
    width: 420px;
    /* 把 left: 50% 的中心拉回 210px，确保居中 */
    transform: translateX(-50%);
    /* 注意：translateX(-50%) 与拖动时的 translateY(dy) 冲突
     * 解决方案：拖动用 .dragging 类时通过 CSS 变量管理位置
     * 详见 home.js 的 drag 处理 */
  }
  /* 桌面端 translateX 中心 + 拖动 translateY 偏移：通过 CSS 变量 */
  .placeholder-view:not(.dragging):not(.closing) {
    transform: translateX(-50%) translateY(0);
  }
  .placeholder-view.dragging {
    transform: translateX(-50%) translateY(var(--drag-y, 0px)) !important;
  }
  .placeholder-view.closing {
    transform: translateX(-50%) translateY(100%) !important;
  }
  .placeholder-backdrop {
    /* 桌面端：背景遮罩不需要 100% 宽（视觉上 placeholder 已经足够聚焦）
     * 但点击事件需要 100% 覆盖，否则空白处点击关闭失效 */
  }
  /* 桌面端高度：仍按 75vh，但视觉上 420px 容器更聚焦 */
  .placeholder-view {
    height: 75vh;
    max-height: 75vh;
  }
}

/* 减少动画（系统偏好） */
@media (prefers-reduced-motion: reduce) {
  .placeholder-view,
  .placeholder-backdrop { animation: none; transition: none; }
}

/* =================================================================
 * 通用确认对话框（home-confirm）
 * - 用于"清除数据"等需要二次确认的操作
 * - 仿 Edge 移动端 Material 风格：居中卡片 + 背景半透明遮罩
 * - z-index 90 > placeholder (80) > 抽屉菜单 (50)
 * - 支持 Promise 风格的 onConfirm / onCancel 回调
 * ================================================================= */
.home-confirm {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.home-confirm[hidden] { display: none !important; }
.home-confirm.visible {
  opacity: 1;
  pointer-events: auto;
}
.home-confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
:root.light .home-confirm-backdrop { background: rgba(15, 23, 42, 0.4); }
.home-confirm-card {
  position: relative;
  width: 100%;
  max-width: 320px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px 20px 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  text-align: center;
  transform: scale(0.92) translateY(8px);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.home-confirm.visible .home-confirm-card {
  transform: scale(1) translateY(0);
}
.home-confirm-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
  line-height: 1.4;
}
.home-confirm-msg {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 18px;
  word-break: break-all;
}
.home-confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.home-confirm-btn {
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  padding: 0 12px;
}
.home-confirm-btn:hover { background: var(--panel-2); }
.home-confirm-btn:active { transform: scale(0.97); }
.home-confirm-btn-ok {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.home-confirm-btn-ok:hover {
  background: var(--primary-hover, #cbd5e1);
  border-color: var(--primary-hover, #cbd5e1);
}
.home-confirm-btn-ok.danger {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
}
.home-confirm-btn-ok.danger:hover {
  background: #dc2626;
  border-color: #dc2626;
}
/* 桌面端（≥1024px）：对话框保持居中卡片风格，但宽度收一点 */
@media (min-width: 1024px) {
  .home-confirm-card { max-width: 340px; }
}

/* =================================================================
 * 悬浮快捷按钮（FAB · Floating Action Button）
 *
 * 尺寸策略（v3 整体缩小约 60%）：
 *   - trigger:  56px → 34px（圆角悬浮按钮）
 *   - item:     48px → 29px（子按钮）
 *   - icon:     32px → 20px（trigger 内的 Copilot logo）
 *   - gap:      10px →  6px（子按钮间距）
 *   - offset:   10px →  6px（trigger 与 menu 间距）
 *   - 缩到 60% 后仍保持可点击区域（最小 29px 满足 iOS 44pt 标准的 65%）
 *
 * 闲置策略（避免遮挡画面）：
 *   - 5 秒无活动 → 自动降低 opacity 到 0.32
 *   - hover / click / 任何活动 → 立即恢复正常（不延迟）
 *   - 用 CSS 变量控制，便于后续调整
 * ================================================================= */
.fab {
  --fab-trigger-size: 34px;     /* trigger 直径 */
  --fab-item-size: 29px;        /* 子按钮直径 */
  --fab-icon-size: 20px;        /* trigger 内图标 */
  --fab-gap: 6px;               /* 子按钮间距 */
  --fab-offset: 6px;            /* trigger ↔ menu 间距 */
  --fab-idle-opacity: 0.32;     /* 闲置时的不透明度 */
  --fab-active-opacity: 1;      /* 正常状态不透明度 */
  position: fixed;
  z-index: 1000;          /* 最高优先级，遮住 placeholder(80) / 抽屉(50) / 底部 nav(20) */
  left: 0;
  top: 0;
  /* 防止文本选择干扰拖动 */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  /* transition 只在"未拖动 / 自动贴边"时启用，拖动时由 JS 关闭 */
  transition: left 0.32s cubic-bezier(0.2, 0.8, 0.2, 1),
              top  0.32s cubic-bezier(0.2, 0.8, 0.2, 1),
              opacity 0.5s ease;
  /* 拖动时关闭 transition（避免跟手卡顿） */
  touch-action: none;
  opacity: var(--fab-active-opacity);
}
.fab.dragging {
  transition: none;
  cursor: grabbing;
}
.fab[hidden] { display: none !important; }

/* 闲置状态：自动降低不透明度，避免长时间遮挡画面
 * 设计原则：idle 是"被动降透明度"，不影响交互性
 *   - hover 不自动恢复（hover 不算"使用"）
 *   - 只有真正的 click / pointerdown（拖动）才恢复
 *   - 通过 .idle:hover 也能点击（pointer-events 不变）
 */
.fab.idle { opacity: var(--fab-idle-opacity); }
/* 拖动中即使在 idle 状态也要正常显示（避免看不清拖动光标位置） */
.fab.idle.dragging { opacity: var(--fab-active-opacity); }

/* 触发按钮：缩小到 60%（原 56px → 34px） */
.fab-trigger {
  width: var(--fab-trigger-size);
  height: var(--fab-trigger-size);
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 100%);
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  box-shadow:
    0 3px 9px rgba(0, 0, 0, 0.32),
    0 1px 2px rgba(0, 0, 0, 0.18),
    inset 0 0 0 1px rgba(255, 255, 255, 0.6);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  padding: 0;
  position: relative;
  z-index: 2;             /* 在菜单之上，确保点击生效 */
}
:root.light .fab-trigger {
  background: linear-gradient(135deg, #ffffff 0%, #e2e8f0 100%);
  box-shadow:
    0 3px 9px rgba(15, 23, 42, 0.16),
    0 1px 2px rgba(15, 23, 42, 0.08),
    inset 0 0 0 1px rgba(255, 255, 255, 0.9);
}
.fab-trigger:hover {
  transform: scale(1.08);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.38),
    0 1px 3px rgba(0, 0, 0, 0.22),
    inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}
.fab-trigger:active {
  transform: scale(0.94);
  cursor: grabbing;
}
.fab-icon {
  width: var(--fab-icon-size);
  height: var(--fab-icon-size);
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}

/* 子按钮菜单：纵向排列，绝对定位在 trigger 旁边
 * 关键：菜单中心 = trigger 中心（视觉居中对齐）
 */
.fab-menu {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: var(--fab-gap);
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  width: max-content;
  max-width: var(--fab-trigger-size);
}
/* 方向：向下展开（FAB 在屏幕上方时） */
.fab[data-direction="down"] .fab-menu {
  top: calc(100% + var(--fab-offset));
  align-items: flex-start;
}
/* 方向：向上展开（FAB 在屏幕下方时） */
.fab[data-direction="up"] .fab-menu {
  bottom: calc(100% + var(--fab-offset));
  align-items: flex-start;
}

/* 单个子按钮：缩小到 60%（原 48px → 29px） */
.fab-item {
  width: var(--fab-item-size);
  height: var(--fab-item-size);
  border-radius: 50%;
  border: none;
  background: rgba(15, 23, 42, 0.85);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.32),
    0 1px 2px rgba(0, 0, 0, 0.18),
    inset 0 0 0 1px rgba(255, 255, 255, 0.15);
  transition: transform 0.18s ease, background 0.18s ease, opacity 0.2s ease;
  padding: 0;
  font-family: inherit;
  opacity: 0;
  transform: scale(0.4) translateY(0);
  pointer-events: none;
  flex-shrink: 0;
  line-height: 1;
}
:root.light .fab-item {
  background: rgba(255, 255, 255, 0.92);
  color: #0f172a;
  box-shadow:
    0 2px 6px rgba(15, 23, 42, 0.16),
    0 1px 2px rgba(15, 23, 42, 0.08),
    inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}
.fab-item:hover {
  background: rgba(148, 163, 184, 0.95);
  color: #fff;
  transform: scale(1.1);
}
.fab-item:active {
  transform: scale(0.9);
}
/* 文字标签 */
.fab-item-label {
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

/* 展开状态：子按钮依次弹出（staggered animation）
 * 用 nth-child 控制每个按钮的 delay，让 1镜 先弹、5存 最后 */
.fab[data-open="true"] .fab-item {
  opacity: 1;
  pointer-events: auto;
  transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) both,
              background 0.18s ease, opacity 0.2s ease;
}
/* 向下展开时，子按钮从 trigger 下方"滑出" */
.fab[data-open="true"][data-direction="down"] .fab-item {
  transform: scale(1) translateY(0);
}
.fab[data-open="true"][data-direction="up"] .fab-item {
  transform: scale(1) translateY(0);
}
/* 收起时反向：依次缩回 trigger */
.fab[data-open="false"] .fab-item {
  opacity: 0;
  transform: scale(0.4);
  pointer-events: none;
}

/* Staggered delay：展开时 1镜 先弹（离 trigger 远的最后弹 → 扇形扩散）
 * 收起时反向：4录 先收，1镜 最后收 */
.fab[data-open="true"] .fab-item:nth-child(1) { transition-delay: 0ms; }
.fab[data-open="true"] .fab-item:nth-child(2) { transition-delay: 30ms; }
.fab[data-open="true"] .fab-item:nth-child(3) { transition-delay: 60ms; }
.fab[data-open="true"] .fab-item:nth-child(4) { transition-delay: 90ms; }

/* 收起时反向 stagger */
.fab[data-open="false"] .fab-item:nth-child(1) { transition-delay: 90ms; }
.fab[data-open="false"] .fab-item:nth-child(2) { transition-delay: 60ms; }
.fab[data-open="false"] .fab-item:nth-child(3) { transition-delay: 30ms; }
.fab[data-open="false"] .fab-item:nth-child(4) { transition-delay: 0ms; }

/* ============= 录制中状态：绿色边框 ============= */
.fab-item.recording {
  box-shadow: 0 0 0 2px #22c55e, 0 0 12px rgba(34, 197, 94, 0.6);
  animation: fab-recording-pulse 1.5s ease-in-out infinite;
}
:root.light .fab-item.recording {
  box-shadow: 0 0 0 2px #16a34a, 0 0 12px rgba(22, 163, 74, 0.4);
}
@keyframes fab-recording-pulse {
  0%, 100% { box-shadow: 0 0 0 2px #22c55e, 0 0 8px rgba(34, 197, 94, 0.4); }
  50% { box-shadow: 0 0 0 3px #22c55e, 0 0 16px rgba(34, 197, 94, 0.7); }
}

/* 桌面端（≥1024px）的容器内：FAB 受限于 420px 容器 */
@media (min-width: 1024px) {
  /* 桌面端是手机模拟器居中（420px 宽），FAB 自然受容器约束 */
  /* 不需要特殊处理，position: fixed 始终相对 viewport */
}

/* ============= 浮动镜头预览窗口 =============
 * 可拖动 + 手动折叠 + 闲置半透明
 *
 * 结构：
 *   .floating-preview    容器（flex row）
 *     .fp-video           视频区（40px 宽，画面按 intrinsic 比例撑高）
 *     .fp-tab              拖拽手柄（~6px 宽，带方向箭头，点击折叠/展开）
 *
 * 关键修复（v1.0.1）：
 *   旧版 align-items: stretch + .fp-video video { height: 100% } 会导致
 *   video 高度被外层 .floating-preview 的"内容最高子元素"（即 .fp-tab 的 ~15px）
 *   强制拉低，从而 video 元素在 40px × 15px 容器内被**严重压扁**。
 *   改为 align-items: flex-start + video { height: auto }，让 video 按
 *   视频帧 intrinsic ratio 自然撑开，比例正确。
 *
 * 默认：展开（显示视频）
 * 折叠：仅显示拖拽手柄
 * ================================================================= */
.floating-preview {
  position: fixed;
  z-index: 950;
  left: 6px;
  bottom: 80px;
  display: flex;
  /* 改：flex-start 让 .fp-video 高度由自身决定（不被 .fp-tab 矮高度拉低） */
  align-items: flex-start;
  transition: left 0.32s cubic-bezier(0.2, 0.8, 0.2, 1),
              bottom 0.32s cubic-bezier(0.2, 0.8, 0.2, 1),
              opacity 0.5s ease;
  opacity: 1;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  /* 0 边框 */
  border: none;
  border-radius: 0;
  /* 无背景/阴影 */
  background: transparent;
  box-shadow: none;
}
.floating-preview[hidden] { display: none !important; }
.floating-preview.dragging { transition: none; cursor: grabbing; }
/* 闲置半透明 */
.floating-preview.idle { opacity: 0.32; }
.floating-preview.idle.dragging { opacity: 1; }

/* ===== 视频区 ===== */
.fp-video {
  width: 40px;
  /* 改：不显式 height，让 video 按 intrinsic ratio 撑高 */
  overflow: hidden;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  /* 默认展开，折叠时隐藏 */
  flex-shrink: 0;
}
.floating-preview[data-open="false"] .fp-video { display: none; }
.floating-preview[data-open="true"] .fp-video { display: block; }
/* 贴右边时视频区自动贴边 */
.floating-preview[data-edge="right"] { flex-direction: row-reverse; }

.fp-video video {
  display: block;
  width: 100%;
  /* 改：height: auto 让 video 按 intrinsic ratio 撑高，保持原始比例不被压扁 */
  height: auto;
  object-fit: cover;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
  /* 0 边框 */
  border: none;
  border-radius: 0;
}

/* ===== 拖拽手柄 ===== */
.fp-tab {
  width: 6px;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  transition: background 0.18s ease;
}
.fp-tab:active { cursor: grabbing; }
.fp-tab:hover { background: rgba(148, 163, 184, 0.25); }
:root.light .fp-tab:hover { background: rgba(100, 116, 139, 0.15); }
.fp-tab-icon {
  width: 10px;
  height: 10px;
  display: block;
  pointer-events: none;
  color: var(--muted);
  opacity: 0.6;
  transition: transform 0.22s ease, opacity 0.22s ease;
}
.fp-tab:hover .fp-tab-icon { opacity: 1; }
/* 展开状态箭头指向外侧，折叠状态箭头反转 */
.floating-preview[data-open="true"] .fp-tab-icon { transform: rotate(0deg); }
.floating-preview[data-open="false"] .fp-tab-icon { transform: rotate(180deg); }
/* 贴右边时箭头镜像 */
.floating-preview[data-edge="right"] .fp-tab-icon { transform: rotate(180deg); }
.floating-preview[data-edge="right"][data-open="false"] .fp-tab-icon { transform: rotate(0deg); }

/* ===== 折叠状态：放大展开按钮（手指友好） ===== */
.floating-preview[data-open="false"] {
  /* 折叠时容器变成一个大按钮 */
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0 8px 8px 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: none;
  box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}
.floating-preview[data-open="false"] .fp-video { display: none; }
.floating-preview[data-open="false"] .fp-tab {
  /* 折叠时 tab 也隐藏，用居中按钮替代 */
  display: none;
}
.floating-preview[data-open="false"]::after {
  content: '';
  display: block;
  width: 14px;
  height: 14px;
  /* 箭头图标: 用 SVG mask（指向展开方向，贴左→箭头朝右） */
  background: var(--muted);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'/%3E%3C/svg%3E") center/contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'/%3E%3C/svg%3E") center/contain no-repeat;
  pointer-events: none;
  opacity: 0.7;
  transition: transform 0.22s ease;
}
.floating-preview[data-open="false"]:hover::after {
  opacity: 1;
}
/* 贴右边时箭头翻转（指向→相反） */
.floating-preview[data-open="false"][data-edge="right"]::after {
  transform: rotate(180deg);
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
  .fab,
  .fab-item,
  .fab-trigger { transition-duration: 0.01s !important; }
  .fab[data-open="true"] .fab-item { transition-delay: 0ms !important; }
  .floating-preview { transition-duration: 0.01s !important; }
}

/* =================================================================
 * 设置页面（settings-view）
 * - 全屏覆盖，z-index 60（在 placeholder 80 之下、nav 20 之上）
 * - 半透明遮罩 + 右侧滑入面板
 * - 分组列表：每项带图标 + 标签 + 箭头/徽标
 * - 纯 UI 模拟，点击不触发真实功能
 * ================================================================= */
.settings-view {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.settings-view.visible {
  opacity: 1;
  pointer-events: auto;
}
.settings-view[hidden] { display: none !important; }

.settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

/* 面板主体：从右侧滑入 */
.settings-sheet {
  position: relative;
  width: 100%;
  max-width: 420px;
  height: 100%;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.25);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.settings-view.visible .settings-sheet {
  transform: translateX(0);
}

/* 标题栏 */
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  padding-top: max(10px, env(safe-area-inset-top, 0px));
}
.settings-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
.settings-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}
.settings-close:hover { background: var(--panel-2); }
.settings-close:active { transform: scale(0.92); }
.settings-close svg { width: 18px; height: 18px; display: block; }

/* 滚动内容区 */
.settings-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

/* 分组 */
.settings-group {
  margin: 0;
  border-bottom: 1px solid var(--border);
  padding: 2px 0;
}
.settings-group:first-child {
  margin-top: 2px;
}

/* 单项 */
.settings-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.12s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.settings-item:hover { background: var(--panel-2); }
.settings-item:active { background: rgba(148, 163, 184, 0.12); }
.settings-item.settings-item-danger:active { background: rgba(239, 68, 68, 0.08); }
/* 危险项文字颜色 */
.settings-item.settings-item-danger .settings-item-label {
  color: #ef4444;
}

/* 图标 — 无彩色，统一中性色 */
.settings-item-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--muted);
  background: var(--panel-2);
}
.settings-item-icon svg {
  width: 14px;
  height: 14px;
  display: block;
}

/* 标签文字 */
.settings-item-label {
  flex: 1;
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 状态徽标（"开"、"Bing" 等） */
.settings-item-badge {
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

/* "新"标签 — 中性灰色，无彩色 */
.settings-item-tag {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  background: var(--panel-2);
  border-radius: 9px;
  padding: 1px 7px;
  line-height: 1.5;
  flex-shrink: 0;
}

/* 箭头图标 */
.settings-item-arrow {
  flex-shrink: 0;
  color: var(--muted);
  opacity: 0.4;
  display: flex;
}
.settings-item-arrow svg {
  width: 14px;
  height: 14px;
  display: block;
}

/* 桌面端（≥1024px）：滑出面板最大 420px */
@media (min-width: 1024px) {
  .settings-view {
    justify-content: center;
    align-items: center;
  }
  .settings-sheet {
    width: 420px;
    height: 86vh;
    border-radius: 36px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1),
                opacity 0.22s ease;
  }
  .settings-view.visible .settings-sheet {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  .settings-backdrop {
    border-radius: 0;
  }
}

/* 减少动画 */
@media (prefers-reduced-motion: reduce) {
  .settings-sheet { transition-duration: 0.01s !important; }
  .settings-view { transition-duration: 0.01s !important; }
}
