/* ============================================================
   网页 PPT · 主题样式
   深色玻璃拟态 + 蓝紫品牌色
   ============================================================ */

:root {
  /* 表面 */
  --bg: #0a0c12;
  --bg-soft: #11141c;
  --card: rgba(255, 255, 255, 0.04);
  --card-hover: rgba(255, 255, 255, 0.075);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);

  /* 文字 */
  --text: #eef1f8;
  --muted: #98a0b3;

  /* 品牌色 */
  --accent: #5b8cff;
  --accent-2: #a06bff;
  --ok: #3ddc97;
  --danger: #e05656;

  /* 形状与阴影 */
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.35);
  --ring: 0 0 0 3px rgba(91, 140, 255, 0.25);

  /* 内联 SVG 图标（用 mask 上色，方便跟随 currentColor） */
  --icon-folder: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 7a2 2 0 0 1 2-2h4l2 2.5h8a2 2 0 0 1 2 2V17a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z'/%3E%3C/svg%3E");
  --icon-library: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 5.5A1.5 1.5 0 0 1 5.5 4H10a2 2 0 0 1 1.6.8l1 1.4a2 2 0 0 0 1.6.8h4.3A1.5 1.5 0 0 1 20 8.5V19a1.5 1.5 0 0 1-1.5 1.5h-13A1.5 1.5 0 0 1 4 19z'/%3E%3Cpath d='M4 10h16'/%3E%3C/svg%3E");

  --icon-file: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5'/%3E%3C/svg%3E");
  --icon-clock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E");

  color-scheme: dark;
}

* { box-sizing: border-box; }

/* 让 hidden 属性始终生效（否则 .loading 这类设置了 display 的元素会盖住页面） */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 背景氛围层 1：缓慢漂移的极光渐变 */
body::before {
  content: "";
  position: fixed;
  inset: -20%;
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(91, 140, 255, 0.20), transparent 60%),
    radial-gradient(820px 520px at 96% 2%, rgba(160, 107, 255, 0.16), transparent 60%),
    radial-gradient(760px 560px at 50% 112%, rgba(61, 220, 151, 0.08), transparent 60%);
  pointer-events: none;
  z-index: 0;
  animation: aurora 36s ease-in-out infinite alternate;
}
@keyframes aurora {
  from { transform: translate3d(-1.5%, -1%, 0) scale(1); }
  to   { transform: translate3d(1.5%, 1.5%, 0) scale(1.06); }
}

/* 背景氛围层 2：顶部隐现的细网格，增加纵深 */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(ellipse 90% 62% at 50% 0%, #000 0%, transparent 72%);
  mask-image: radial-gradient(ellipse 90% 62% at 50% 0%, #000 0%, transparent 72%);
  pointer-events: none;
  z-index: 0;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

::selection { background: rgba(91, 140, 255, 0.35); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 细滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, 0.24); }

/* ---------------- 顶栏 ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  /* 刘海屏：顶栏是 sticky 的，不留出安全区的话会被状态栏压住 */
  padding: calc(15px + env(safe-area-inset-top, 0px)) calc(28px + env(safe-area-inset-right, 0px)) 15px calc(28px + env(safe-area-inset-left, 0px));
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  background: rgba(10, 12, 18, 0.72);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border-radius: 10px;
  padding: 4px 8px;
  margin: -4px -8px; /* 抵消 padding，免得顶栏布局被撑开 */
  transition: background 0.18s, opacity 0.18s;
  /* 窄屏上品牌名要能被压缩：不然整条顶栏被撑宽，
     右侧的「退出」按钮会被挤出屏幕（页面出现横向滚动）。 */
  min-width: 0;
}

.brand-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 顶栏右侧的控件不参与压缩 —— 按钮被挤扁比标题被截断更难看 */
.topbar .btn, .topbar .conn { flex: none; }

.brand:hover { background: rgba(255, 255, 255, 0.08); }

.brand-logo {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  object-fit: cover;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.spacer { flex: 1; }

.conn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 13px;
  color: var(--muted);
  transition: border-color 0.2s, color 0.2s;
}
.conn.online { border-color: rgba(61, 220, 151, 0.35); color: var(--text); }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}
.conn.online .dot { background: var(--ok); animation: pulse 2s infinite; }
.conn.offline .dot { background: var(--danger); }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(61, 220, 151, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(61, 220, 151, 0); }
  100% { box-shadow: 0 0 0 0 rgba(61, 220, 151, 0); }
}

/* ---------------- 按钮 / 输入框 ---------------- */

.btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  transition: background 0.18s, border-color 0.18s, box-shadow 0.18s, transform 0.12s;
}
.btn:hover { background: var(--card-hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(91, 140, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.btn.primary:hover { filter: brightness(1.1); box-shadow: 0 8px 26px rgba(91, 140, 255, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.22); }
.btn.primary:active { filter: brightness(0.98); }

input[type="password"], input[type="text"] {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
input:focus { border-color: var(--accent); box-shadow: var(--ring); }

/* ---------------- 登录页 ---------------- */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  /* 刘海屏：登录卡片不能被状态栏/圆角压住 */
  padding: calc(24px + env(safe-area-inset-top, 0px)) calc(24px + env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) calc(24px + env(safe-area-inset-left, 0px));
  position: relative;
  z-index: 1;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 34px 30px 30px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: rgba(17, 20, 28, 0.85);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  text-align: center;
}

.login-card h1 { margin: 0 0 10px; font-size: 21px; }

.login-logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  object-fit: cover;
  margin-bottom: 14px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.4);
}

.login-card p { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
.login-card .btn { width: 100%; padding: 13px; margin-top: 14px; font-size: 15px; }

.err { color: #ff8080; font-size: 13px; min-height: 18px; margin-top: 10px; }

/* ---------------- 作品库 ---------------- */

.page { position: relative; z-index: 1; }

.hero {
  padding: 34px calc(28px + env(safe-area-inset-right, 0px)) 6px calc(28px + env(safe-area-inset-left, 0px));
}

/* 工具条：搜索 + 右侧按钮
   整条做成一个「工具栏容器」——搜索框撑满剩余宽度，
   按钮贴在右边。之前搜索框只有 420px 宽、按钮推到最右，
   中间空出一大片，看着像没排完。 */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 7px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.22);
  flex-wrap: wrap;
}
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 260px;
  max-width: none;
  min-width: 0;
}
.search-icon {
  position: absolute;
  left: 12px;
  width: 17px;
  height: 17px;
  color: var(--muted);
  pointer-events: none;
}
.search input {
  width: 100%;
  padding: 10px 68px 10px 34px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: rgba(0, 0, 0, 0.32);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
/* 快捷键提示隐藏时（聚焦 / 已有内容），右边让给清除按钮 */
.search.hint-off input { padding-right: 36px; }
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: var(--accent); background: rgba(0, 0, 0, 0.45); box-shadow: var(--ring); }
/* 去掉 Safari/Chrome 自带的搜索清除按钮，用自绘的 */
.search input::-webkit-search-cancel-button { display: none; }
.search-clear {
  position: absolute;
  right: 8px;
  /* 最小点击区 24×24（WCAG 2.2 建议值） */
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.search-clear:hover { background: rgba(255, 255, 255, 0.18); color: var(--text); }

.select-btn {
  padding: 9px 12px;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}
.select-btn option { background: var(--bg-soft); color: var(--text); }

.badge-count {
  display: inline-block;
  margin-left: 7px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(224, 86, 86, 0.2);
  border: 1px solid rgba(224, 86, 86, 0.4);
  color: #ffb3b3;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.5;
}
.btn.danger { color: #ffb3b3; border-color: rgba(224, 86, 86, 0.4); }
.btn.danger:hover { background: rgba(224, 86, 86, 0.16); border-color: rgba(224, 86, 86, 0.65); }

.link-btn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
}

/* 提示条（右下角） */
.toast-host {
  position: fixed;
  right: calc(20px + env(safe-area-inset-right, 0px));
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast-item {
  padding: 11px 16px;
  border-radius: 12px;
  background: rgba(17, 20, 28, 0.94);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-size: 13.5px;
  color: var(--text);
  max-width: 320px;
  animation: toast-in 0.22s cubic-bezier(0.2, 0.7, 0.3, 1);
  transition: opacity 0.25s, transform 0.25s;
}
.toast-item.out { opacity: 0; transform: translateY(8px); }
.toast-item.ok { border-color: rgba(61, 220, 151, 0.45); }
.toast-item.error { border-color: rgba(224, 86, 86, 0.55); color: #ffc9c9; }
/* 提示条被放进弹窗里时（弹窗在顶层，永远盖住页面上的东西），
   它就是弹窗里的普通块级元素，不再是右下角浮层 */
dialog > .toast-item { margin-top: 10px; max-width: none; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
.hero-head {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.hero h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0.5px;
  line-height: 1.2;
}
.count-chip {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(91, 140, 255, 0.3);
  background: rgba(91, 140, 255, 0.1);
  color: #b8ccff;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

/* 树容器 */
.tree {
  /* 左右留出刘海/圆角的安全区，底部留出 Home 指示条的高度 */
  padding: 18px calc(28px + env(safe-area-inset-right, 0px)) calc(72px + env(safe-area-inset-bottom, 0px)) calc(28px + env(safe-area-inset-left, 0px));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* 文件夹 */
.folder-node {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.012));
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.folder-node.drop-hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(91, 140, 255, 0.3), var(--shadow-soft);
  background: rgba(91, 140, 255, 0.07);
}
.folder-node.root {
  border-color: transparent;
  background: transparent;
}
.folder-node.root.drop-hover {
  border-color: var(--accent);
  background: rgba(91, 140, 255, 0.05);
}

/* 根目录只是一节标题（不可折叠），做成弱化的小标题，
   免得跟页面上的大标题「作品库」抢视线 */
.folder-node.root > .folder-head {
  cursor: default;
  padding: 2px 0 10px;
  border-bottom: none;
}
.folder-node.root > .folder-head:hover { background: transparent; }
.folder-node.root-label .folder-name {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 1.4px;
  color: var(--muted);
}

.folder-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid transparent;
  transition: background 0.18s;
  /* 层级引导线：左侧竖线标出「这一层在第几级」 */
  position: relative;
}
.folder-node:not(.root) > .folder-head { border-bottom-color: var(--border); }
.folder-head:hover { background: rgba(255, 255, 255, 0.04); }
.folder-head.dragging { opacity: 0.45; }

/* 用 padding-left 让嵌套层级有视觉阶梯 */
.folder-node .folder-body { padding-left: 0; }
.folder-node .folder-body .folder-node { margin-left: 14px; }
.folder-node .folder-body .folder-node > .folder-head {
  border-left: 1px solid var(--border);
  border-top-left-radius: 8px;
}
.folder-node .folder-body .folder-node > .folder-head::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 50%;
  width: 9px;
  height: 1px;
  background: var(--border);
}

.caret {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  /* 最小点击区 24×24（WCAG 2.2 建议值） */
  width: 24px;
  height: 24px;
  border-radius: 6px;
  flex: none;
  display: grid;
  place-items: center;
  transition: background 0.15s, color 0.15s;
}
.caret:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }

.folder-name {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.2px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 文件夹图标用内联 SVG 而不是 emoji：
   emoji 在不同系统下形状/颜色差异很大（有的渲染成方块），SVG 描边图标更整齐。
   图标描边用 currentColor，跟随标题文字的颜色。 */
.folder-name::before {
  content: "";
  width: 15px;
  height: 15px;
  flex: none;
  background-color: currentColor;
  opacity: 0.75;
  -webkit-mask: var(--icon-folder) center / contain no-repeat;
  mask: var(--icon-folder) center / contain no-repeat;
}
.folder-node.root > .folder-head .folder-name::before {
  -webkit-mask-image: var(--icon-library);
  mask-image: var(--icon-library);
  opacity: 1;
  background-color: var(--accent);
}

.folder-count {
  font-size: 12px;
  color: var(--muted);
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.folder-head .folder-more {
  flex: 0 0 auto;
  width: auto;
  padding: 5px 11px;
  font-size: 14px;
  line-height: 1.2;
}

.folder-body {
  padding: 18px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.folder-node.root > .folder-body { padding: 4px 0 0; }
.folder-node.collapsed > .folder-body { display: none; }

/* 空文件夹的拖放提示区 */
.folder-empty {
  padding: 26px 16px;
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.015);
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.folder-node.drop-hover .folder-empty {
  border-color: var(--accent);
  color: #b8ccff;
  background: rgba(91, 140, 255, 0.06);
}

/* 提示卡 */
.tips {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
}

/* 「关于」弹窗 */
.about-dialog {
  width: min(760px, calc(100vw - 32px));
  padding: 26px 26px 24px;
  border-radius: 20px;
  border: 1px solid var(--border-strong);
  background: rgba(17, 20, 28, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  color: var(--text);
}
.about-dialog::backdrop {
  background: rgba(4, 6, 10, 0.62);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.about-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.about-head h2 {
  margin: 0;
  font-size: 19px;
  letter-spacing: 0.4px;
}
.about-close {
  margin-left: auto;
  padding: 5px 12px;
  font-size: 13px;
  line-height: 1.4;
}
.about-sub {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.8;
}
.about-dialog .tips { margin-top: 20px; }
.tip {
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02));
  transition: border-color 0.2s;
}
.tip:hover { border-color: var(--border-strong); }
.tip > b:first-child { display: block; font-size: 13.5px; margin-bottom: 4px; }
.tip > span { font-size: 12.5px; color: var(--muted); line-height: 1.65; }
.tip span b { color: var(--text); font-weight: 600; }

/* 网格 */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 22px;
}
/* 卡片必须允许被压到轨道宽度以下（min-width:0）：
   .title 是 white-space:nowrap，它的最小内容宽度 = 整行文字宽，
   会顺着 .meta → .card 一路把网格轨道（1fr = minmax(auto,1fr)，
   auto 最小值会被内容撑开）撑到比屏幕还宽 —— 手机上卡片右缘
   超出视口、右侧被裁掉一截。压到 0 后标题由 ellipsis 截断。 */
.grid > .card { min-width: 0; }
/* 网格的内边距由外层容器（.tree / .folder-body）负责，
   否则嵌套文件夹里会叠出 44px 的水平双倍缩进 */
.folder-node.root > .folder-body > .grid { padding: 0; }

/* 卡片 */
.card {
  position: relative;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02));
  overflow: visible;
  cursor: pointer;
  user-select: none;
  display: flex;
  flex-direction: column;
  transition: transform 0.22s cubic-bezier(0.2, 0.7, 0.3, 1), border-color 0.22s, box-shadow 0.22s, background 0.22s;
  animation: card-in 0.55s cubic-bezier(0.2, 0.7, 0.3, 1) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* 悬停时浮现的品牌渐变描边 */
.card::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(91, 140, 255, 0.65), rgba(160, 107, 255, 0.65));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
  z-index: 2;
}
.card:hover:not(.presented) { transform: translateY(-5px); border-color: transparent; box-shadow: var(--shadow); }
.card:hover:not(.presented)::before { opacity: 1; }

/* 正在演示的作品：绿色描边 + 呼吸感 */
.card.presented { border-color: rgba(61, 220, 151, 0.5); box-shadow: 0 0 0 1px rgba(61, 220, 151, 0.18), 0 12px 36px rgba(61, 220, 151, 0.1); }
.card.presented::before { opacity: 0; }

.card:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring), var(--shadow-soft);
}

/* 预览区 */
.preview {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #05070c;
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
  border-bottom: 1px solid var(--border);
}
/* 懒加载占位：iframe 还没加载好时先铺一层微光渐变 */
.preview::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0.04) 30%, rgba(255, 255, 255, 0.09) 50%, rgba(255, 255, 255, 0.04) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  transition: opacity 0.3s;
  z-index: 0;
}
.preview.loaded::before { opacity: 0; animation: none; }
@keyframes shimmer {
  from { background-position: 140% 0; }
  to   { background-position: -40% 0; }
}
.preview iframe {
  position: absolute;
  top: 0;
  left: 0;
  /* 400% x scale(0.25)：按容器实际宽度等比铺满。
     固定 1280px 会在宽卡片右边露出黑边（卡片列宽 310~500px 不等）。 */
  width: 400%;
  height: 400%;
  border: 0;
  transform: scale(0.25);
  transform-origin: 0 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s, filter 0.25s;
  z-index: 1;
}
.preview.loaded iframe { opacity: 0.92; }
.card:hover .preview iframe { filter: brightness(1.08); }

.preview .badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
  border: 1px solid var(--border);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  font-variant-numeric: tabular-nums;
}

/* 「演示中」实时徽标 */
.live-badge {
  position: absolute;
  left: 10px;
  top: 10px;
  display: none;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ok);
  background: rgba(6, 18, 12, 0.72);
  border: 1px solid rgba(61, 220, 151, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 3;
}
.live-badge .dot { width: 6px; height: 6px; background: var(--ok); animation: pulse 2s infinite; }
.card.presented .live-badge { display: inline-flex; }

/* 悬停播放浮层 */
.preview-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(5, 8, 14, 0) 35%, rgba(5, 8, 14, 0.55));
  opacity: 0;
  transition: opacity 0.25s;
  z-index: 2;
}
.card:hover .preview-overlay { opacity: 1; }

/* 悬停时中央浮出的播放按钮 —— 预览区本身也可点击，
   给一个明确的「点这里能放」信号，比纯渐变遮罩好识别。 */
.preview-overlay::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  transform: translate(-50%, -46%) scale(0.82);
  border-radius: 50%;
  background: rgba(10, 12, 18, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.22s, transform 0.22s cubic-bezier(0.2, 0.7, 0.3, 1);
}
/* 按钮里的三角 */
.preview-overlay::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translate(-42%, -50%);
  background-color: #fff;
  opacity: 0;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 5.5v13l11-6.5z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 5.5v13l11-6.5z'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: opacity 0.22s;
}
.card:hover .preview-overlay::before { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.card:hover .preview-overlay::after { opacity: 0.95; }

/* 卡片信息区 */
.card .meta {
  padding: 15px 17px 17px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  flex: 1;
}
/* 搜索结果里标出作品所在的文件夹 */
.card-path {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: -3px;
}
.card-path::before {
  content: "";
  width: 11px;
  height: 11px;
  flex: none;
  background-color: var(--accent);
  opacity: 0.7;
  -webkit-mask: var(--icon-folder) center / contain no-repeat;
  mask: var(--icon-folder) center / contain no-repeat;
}
.card .title {
  font-weight: 600;
  font-size: 15.5px;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card .desc {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
  min-height: 21px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 主操作行：打开 + 投屏 */
.card .actions {
  margin-top: auto;
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.open-btn {
  flex: 1.4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(91, 140, 255, 0.35);
  background: linear-gradient(135deg, rgba(91, 140, 255, 0.16), rgba(160, 107, 255, 0.16));
  color: #cfe0ff;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.open-btn:hover {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 18px rgba(91, 140, 255, 0.4);
}
.cast-btn {
  flex: 1;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  white-space: nowrap;
}
.cast-btn:hover {
  border-color: rgba(61, 220, 151, 0.5);
  background: rgba(61, 220, 151, 0.08);
  color: var(--ok);
}

.mini-btn {
  flex: 1;
  text-align: center;
  padding: 7px 10px;
  font-size: 12.5px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: color 0.16s, border-color 0.16s, background 0.16s;
  white-space: nowrap;
}
.mini-btn:hover { color: var(--text); border-color: var(--border-strong); background: rgba(255, 255, 255, 0.06); }

/* 空状态 */
.empty-state {
  max-width: 640px;
  margin: 30px auto 80px;
  padding: 44px 32px;
  text-align: center;
  color: var(--muted);
  border: 1.5px dashed rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.02);
}
.empty-state p { margin: 8px 0; line-height: 1.8; }
.empty-state code {
  background: var(--card);
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.92em;
}

/* ---------------- 整理：卡片拖拽 / 更多按钮 ---------------- */

.card.dragging { opacity: 0.4; transform: scale(0.98); }
.card[draggable="true"] { cursor: grab; }
.card[draggable="true"]:active { cursor: grabbing; }

/* 拖拽时出现在底部的「移回根目录」投放区 */
.root-drop-zone {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(90px);
  padding: 13px 26px;
  border-radius: 999px;
  border: 1.5px dashed rgba(91, 140, 255, 0.55);
  background: rgba(10, 12, 18, 0.88);
  color: #cfe0ff;
  font-size: 13.5px;
  font-weight: 600;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  z-index: 40;
  pointer-events: none; /* 平时不拦截点击；进入拖拽态才开启 */
  opacity: 0;
  transition: transform 0.25s cubic-bezier(0.2, 0.7, 0.3, 1), opacity 0.25s, border-color 0.15s, background 0.15s;
}
body.dragging-active .root-drop-zone {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.root-drop-zone.drop-hover {
  border-color: var(--accent);
  border-style: solid;
  background: rgba(91, 140, 255, 0.16);
  color: #fff;
}

.more-btn {
  flex: none;
  width: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.16s, background 0.16s, border-color 0.16s;
}
.more-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.09);
}

/* ---------------- 小弹窗（命名 / 移动 / 菜单） ---------------- */

.mini-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border-radius: 18px;
  border: 1px solid var(--border-strong);
  background: rgba(17, 20, 28, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  color: var(--text);
}
.mini-dialog::backdrop {
  background: rgba(4, 6, 10, 0.6);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.mini-form { padding: 22px 22px 18px; }
.mini-form h3 {
  margin: 0 0 16px;
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mini-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}
.mini-actions .btn { padding: 8px 16px; font-size: 13.5px; }

.err { color: #ff8080; font-size: 12.5px; min-height: 16px; margin-top: 8px; }

.folder-picker {
  max-height: 46vh;
  overflow: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.28);
  padding: 6px;
}
.folder-opt {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13.5px;
  transition: background 0.15s;
}
.folder-opt:hover { background: rgba(255, 255, 255, 0.06); }
.folder-opt input { accent-color: var(--accent); margin: 0; cursor: pointer; }

.menu-list { display: flex; flex-direction: column; gap: 4px; }
.menu-item {
  text-align: left;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.menu-item:hover {
  background: rgba(91, 140, 255, 0.14);
  border-color: rgba(91, 140, 255, 0.35);
}
.menu-item:last-child:hover {
  background: rgba(224, 86, 86, 0.16);
  border-color: rgba(224, 86, 86, 0.45);
  color: #ffb3b3;
}

/* ---------------- 回收站 ---------------- */

.trash-list {
  margin-top: 16px;
  max-height: 52vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.trash-empty {
  margin: 0;
  padding: 30px 0;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.trash-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  transition: border-color 0.18s, background 0.18s;
}
.trash-item:hover { border-color: var(--border-strong); background: rgba(255, 255, 255, 0.05); }
.trash-icon { font-size: 17px; flex: none; }
.trash-info { flex: 1; min-width: 0; }
.trash-name {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.trash-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.trash-item .mini-btn {
  flex: none;
  padding: 7px 13px;
}
.trash-item .mini-btn.danger:hover {
  color: #ffb3b3;
  border-color: rgba(224, 86, 86, 0.5);
  background: rgba(224, 86, 86, 0.12);
}

/* ---------------- 播放器 ---------------- */

.player {
  position: fixed;
  inset: 0;
  background: #000;
  overflow: hidden;
}

.stage {
  position: absolute;
  inset: 0;
}
.stage iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.hud {
  position: absolute;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(13, 16, 24, 0.72);
  border: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
  z-index: 10;
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: calc(100vw - 24px);
  /* 放不下就折行（手机横屏 740×360 这类「宽度过了竖屏断点、
     但一行仍放不下全部控件」的尺寸，overflow-x 截断会让
     「跟随同步」少半截）。桌面一行放得下，wrap 不会触发。 */
  flex-wrap: wrap;
  justify-content: center;
  overflow-x: hidden;
}
.hud.hidden { opacity: 0; transform: translateX(-50%) translateY(20px); pointer-events: none; }
/* 隐藏状态下控件仍然能被键盘聚焦（Tab 会走到里面），
   所以聚焦时必须把它显示出来 —— 否则键盘用户会掉进一个看不见的控件里。 */
.hud.hidden:focus-within { opacity: 1; transform: translateX(-50%); pointer-events: auto; }

.hud button {
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: grid;
  place-items: center;
  flex: none;
  transition: background 0.15s, transform 0.12s;
}
.hud button:hover { background: rgba(255, 255, 255, 0.18); }
.hud button:active { transform: scale(0.92); }
.hud .counter {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--muted);
  padding: 0 10px;
  white-space: nowrap;
  min-width: 62px;
  text-align: center;
}
.hud select {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 13px;
  max-width: 180px;
  cursor: pointer;
  outline: none;
}
.hud select option { background: var(--bg-soft); }

.hud .follow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  padding: 0 10px 0 6px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.hud .follow input { accent-color: var(--accent); margin: 0; cursor: pointer; }
.hud .follow.on { color: var(--ok); }

.toast {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(13, 16, 24, 0.85);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 20;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.toast.show { opacity: 1; }

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  background: #000;
  z-index: 5;
}

/* ---------------- 细节优化：快捷键提示 / 时间戳 / 骨架屏 ---------------- */

/* 搜索框右下角的快捷键提示：告诉用户「/ 或 Ctrl+K 就能搜」，
   聚焦或已经输入内容时让位给清除按钮。 */
.search-kbd {
  position: absolute;
  right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 22px;
  padding: 0 7px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  pointer-events: none;
  transition: opacity 0.15s;
}
.search-kbd kbd {
  font-family: inherit;
  font-size: 11px;
  color: var(--text);
  opacity: 0.75;
}
.search.hint-off .search-kbd { opacity: 0; }

/* 卡片上的更新时间 */
.card-time {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--muted);
  opacity: 0.85;
  white-space: nowrap;
}
.card-time::before {
  content: "";
  width: 12px;
  height: 12px;
  flex: none;
  background-color: currentColor;
  -webkit-mask: var(--icon-clock) center / contain no-repeat;
  mask: var(--icon-clock) center / contain no-repeat;
  opacity: 0.8;
}

/* 骨架屏：作品库拉取期间的占位，避免首屏白屏 */
.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 22px;
}
.skeleton-card {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
  overflow: hidden;
}
.skeleton-thumb {
  aspect-ratio: 16 / 9;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0.04) 30%, rgba(255, 255, 255, 0.09) 50%, rgba(255, 255, 255, 0.04) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
}
.skeleton-body { padding: 16px 17px 18px; display: flex; flex-direction: column; gap: 10px; }
.skeleton-line {
  height: 13px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.07);
}
.skeleton-line.short { width: 55%; }
.skeleton-line.long { width: 85%; height: 11px; }
.skeleton-actions { display: flex; gap: 8px; margin-top: 6px; }
.skeleton-actions span {
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
}
.skeleton-actions span:first-child { flex: 1.4; }
.skeleton-actions span:last-child { flex: 1; }

/* 回收站条目图标：与其余界面统一用 SVG 描边图标（emoji 形状/颜色各系统不一） */
.trash-icon {
  width: 18px;
  height: 18px;
  flex: none;
  background-color: var(--muted);
  -webkit-mask: var(--icon-folder) center / contain no-repeat;
  mask: var(--icon-folder) center / contain no-repeat;
}
.trash-icon.file {
  background-color: var(--accent);
  opacity: 0.8;
  -webkit-mask-image: var(--icon-file);
  mask-image: var(--icon-file);
}

/* 播放器底部的进度条：一眼看出当前在第几页 */
.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: env(safe-area-inset-bottom, 0px);
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  z-index: 11;
  pointer-events: none;
}
.progress > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 0 2px 2px 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px rgba(91, 140, 255, 0.55);
  transition: width 0.28s cubic-bezier(0.2, 0.7, 0.3, 1);
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 640px) {
  .topbar {
    padding: calc(13px + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-right, 0px)) 13px calc(16px + env(safe-area-inset-left, 0px));
    gap: 10px;
  }
  .brand { font-size: 16px; }
  .conn { font-size: 12px; padding: 5px 10px; }
  /* 窄屏下按钮文字不要折行（"同步已连接" 被拆成两行很难看） */
  .brand, .conn, .topbar .btn { white-space: nowrap; }
  .topbar .btn { padding: 9px 12px; }
  .hero { padding: 30px calc(16px + env(safe-area-inset-right, 0px)) 4px calc(16px + env(safe-area-inset-left, 0px)); }
  .hero h1 { font-size: 26px; }
  .tips { grid-template-columns: 1fr; margin-top: 18px; }
  .grid { grid-template-columns: 1fr; gap: 16px; }
  /* 同上：单列 1fr 也会被 nowrap 标题的最小内容宽度撑出屏幕 */
  .grid > .card { min-width: 0; }
  /* 窄屏：作品下拉框要留着 —— 手机也是常用设备，
     直接 display:none 的话手机上就没法切换作品了。
     一行放不下就折成两行，而不是把按钮缩小（手机上按钮要够大好按）。
     HUD 原本是 left:50% 绝对定位（宽度只剩一半屏幕），这里改成左右都顶开。 */
  .hud {
    left: 8px;
    right: 8px;
    transform: none;
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 6px;
    padding: 8px 10px;
    border-radius: 22px;
    max-width: calc(100vw - 16px);
  }
  .hud.hidden { transform: translateY(20px); }
  .hud.hidden:focus-within { transform: none; }
  /* 窄屏：作品下拉框独占一行。挤在 96px 里标题会被截成「示例演示 :」，
     根本看不清当前放的是哪份作品。 */
  .hud select { flex: 1 1 100%; max-width: 100%; padding: 7px 6px; font-size: 12px; }
  .hud .counter { min-width: 46px; padding: 0 4px; }
  /* 「跟随同步」允许收窄：手机横屏（如 740×360）时第二行放不下它会溢出 13px,
     overflow-x:auto 把文字截断还得横滑才能看到。允许文字折行后它挤不下就换行。 */
  .hud .follow { font-size: 12px; padding: 0 6px 0 4px; gap: 4px; min-width: 0; white-space: normal; }
  .tree {
    padding: 12px calc(12px + env(safe-area-inset-right, 0px)) calc(56px + env(safe-area-inset-bottom, 0px)) calc(12px + env(safe-area-inset-left, 0px));
    gap: 12px;
  }
  .folder-body { padding: 12px 10px 14px; }
  .folder-head { padding: 10px 12px; }
  /* 窄屏：搜索独占一行，按钮排第二行（都收在工具条容器里） */
  .toolbar { gap: 8px; padding: 6px; }
  .search { flex: 1 1 100%; max-width: none; }
  /* 手机没有实体键盘，快捷键提示只会占地方 */
  .search-kbd { display: none; }
  .search input { padding-right: 36px; }
  .toolbar-right { width: 100%; gap: 6px; margin-left: 0; }
  .toolbar-right .btn, .toolbar-right .select-btn { flex: 1 1 auto; min-width: 0; }
  .toolbar-right .btn { padding: 8px 10px; font-size: 13px; }
  .toast-host {
    left: calc(12px + env(safe-area-inset-left, 0px));
    right: calc(12px + env(safe-area-inset-right, 0px));
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .toast-item { max-width: none; }
  /* 回收站条目在窄屏换行排布，避免按钮被挤到屏幕外 */
  .trash-item { flex-wrap: wrap; }
  .trash-info { flex: 1 1 100%; order: 1; }
  .trash-icon { order: 0; }
  .trash-item .mini-btn { flex: 1 1 0; order: 2; }
}

/* 更窄的手机（<=400px）：顶栏只留品牌和两个按钮，连接状态收成一个小圆点 */
@media (max-width: 400px) {
  .topbar { gap: 8px; }
  .topbar .conn span:last-child { display: none; }
  .topbar .conn { padding: 6px; gap: 0; }
  .brand { font-size: 15px; }
  /* 品牌名先让位：把宽度全留给「关于 / 退出」，
     免得「退出」被挤出屏幕外（页面横向滚动）。 */
  .brand-label { font-size: 0; }
  .brand-label::after {
    content: "Presentation";
    font-size: 15px;
  }
}

/* 减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
