/* ═══════════════════════════════════════════════════════════
   个人云盘 —— 设计系统

   基调：温润质感。暖米白底、暖灰文字、柔和分层阴影，单一低饱和强调色。
   文件图标是单色线描，颜色只出现在小小的类型标签上。

   几条贯穿全局的规矩：
     · 中性色全部带暖调（同一色系），不混冷暖灰
     · 阴影用暖褐色调而不是纯黑透明，否则在米白底上会发灰发脏
     · 圆角分级：内层元素小、容器大，不是所有地方一个值
     · 字号阶梯是 11 / 12 / 13 / 14 / 15 / 20，不随手写中间值
   ═══════════════════════════════════════════════════════════ */

:root {
  /* ——— 中性色：统一暖调 ——— */
  --bg:            #faf9f7;
  --surface:       #ffffff;
  --surface-2:     #f5f3f0;
  --surface-3:     #ece9e4;
  --border:        #e8e4dd;
  --border-strong: #d9d4cb;

  --text:   #1c1917;
  --text-2: #57534e;
  --text-3: #8b857d;

  /* ——— 唯一强调色：深青 ——— */
  --accent:      #0f766e;
  --accent-hover:#0d665f;
  --accent-soft: #e7f1ef;
  --accent-ring: rgba(15, 118, 110, .28);

  --danger:      #b3261e;
  --danger-soft: #fbeceb;
  --warn:        #9a6700;

  /* ——— 文件类型色：全部低饱和，彼此和谐 ——— */
  --t-doc:     #4a6fa5;
  --t-sheet:   #4a8060;
  --t-slide:   #b06a35;
  --t-pdf:     #a8524a;
  --t-image:   #7a5f9e;
  --t-video:   #9e5a7a;
  --t-audio:   #9a7b3c;
  --t-archive: #7d7059;
  --t-code:    #4f7a86;
  --t-text:    #7a7468;
  --t-plain:   #8b857d;

  /* ——— 阴影：暖调，且统一光源在上方 ——— */
  --shadow-1: 0 1px 2px rgba(41, 37, 36, .05);
  --shadow-2: 0 1px 2px rgba(41, 37, 36, .04), 0 4px 10px rgba(41, 37, 36, .06);
  --shadow-3: 0 2px 4px rgba(41, 37, 36, .04), 0 12px 28px rgba(41, 37, 36, .09);
  --shadow-4: 0 8px 20px rgba(41, 37, 36, .10), 0 32px 64px rgba(41, 37, 36, .12);

  /* ——— 圆角：内小外大 ——— */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 11px;
  --r-xl: 15px;

  --ease: cubic-bezier(.32, .72, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #1a1816;
    --surface:       #232120;
    --surface-2:     #2b2826;
    --surface-3:     #343030;
    --border:        #383431;
    --border-strong: #4a4541;

    --text:   #ece9e4;
    --text-2: #a9a29b;
    --text-3: #7d766e;

    --accent:      #2ea89c;
    --accent-hover:#37bdb0;
    --accent-soft: #1d3330;
    --accent-ring: rgba(46, 168, 156, .35);

    --danger:      #e57067;
    --danger-soft: #38211f;

    /* 深色底上要提亮，否则这些颜色会糊成一团黑 */
    --t-doc:     #7ba0d4;
    --t-sheet:   #79b48e;
    --t-slide:   #d99a68;
    --t-pdf:     #d98279;
    --t-image:   #ab8fd0;
    --t-video:   #cc8aa8;
    --t-audio:   #c9a765;
    --t-archive: #ab9c85;
    --t-code:    #7baab6;
    --t-text:    #a69e94;
    --t-plain:   #8b857d;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-2: 0 1px 2px rgba(0, 0, 0, .25), 0 4px 10px rgba(0, 0, 0, .3);
    --shadow-3: 0 2px 4px rgba(0, 0, 0, .25), 0 12px 28px rgba(0, 0, 0, .38);
    --shadow-4: 0 8px 20px rgba(0, 0, 0, .4), 0 32px 64px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }

/* HTML 的 hidden 属性靠浏览器默认样式表生效，作者样式里任何 display 声明都能压过它
   —— 哪怕只是一条 `.modal { display: flex }`。加这条之后，带 hidden 的元素真的会隐藏。 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100dvh;
  overflow: hidden;   /* 滚动交给列表自己，外层不滚 —— 这是"应用"而不是"文档" */
}

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text",
        "Segoe UI", system-ui, "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input { font: inherit; color: inherit; }

/* 键盘可达性：鼠标点击不显示轮廓，键盘导航必须显示 */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

.skip-link {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translate(-50%, -150%);
  z-index: 200;
  padding: 10px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 var(--r-md) var(--r-md);
  box-shadow: var(--shadow-3);
  font-size: 13px;
  text-decoration: none;
  transition: transform .18s var(--ease);
}
.skip-link:focus { transform: translate(-50%, 0); }

/* ─────────────────────── 顶栏 ─────────────────────── */

.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 24px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 9px; }

.brand-mark {
  width: 21px;
  height: 21px;
  color: var(--accent);
  /* 云朵的视觉重心偏下，往上挪一点才跟文字基线对齐 */
  margin-top: -2px;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
}

/* ─────────────────────── 搜索框 ─────────────────────── */

.search {
  position: relative;
  flex: 1;
  max-width: 420px;
  margin-left: 8px;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 11px;
  width: 15px;
  height: 15px;
  color: var(--text-3);
  pointer-events: none;
  transition: color .15s var(--ease);
}
.search:focus-within .search-icon { color: var(--accent); }

.search-input {
  width: 100%;
  height: 34px;
  padding: 0 34px 0 33px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
  transition: background .16s var(--ease), border-color .16s var(--ease),
              box-shadow .16s var(--ease);
}
.search-input::placeholder { color: var(--text-3); }
.search-input:hover { background: var(--surface-3); }

.search-input:focus {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.search-clear {
  position: absolute;
  right: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--text-3);
  cursor: pointer;
  transition: background .14s var(--ease), color .14s var(--ease);
}
.search-clear svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}
.search-clear:hover { background: var(--surface-3); color: var(--text); }

/* 搜索时藏起面包屑和工具栏 —— 当前位置这个概念在跨目录的结果列表里没有意义 */
body.searching .crumbs,
body.searching .toolbar { display: none; }

/* 配额：做成一个紧凑的整体，而不是孤零零一根进度条 */
.quota {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  transition: background .2s var(--ease);
}
.quota:hover { background: var(--surface-3); }

.quota-track {
  width: 84px;
  height: 5px;
  border-radius: 3px;
  background: var(--border-strong);
  overflow: hidden;
}

.quota-fill {
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: var(--accent);
  transition: width .45s var(--ease), background .3s var(--ease);
}
.quota-fill.warn { background: var(--warn); }
.quota-fill.full { background: var(--danger); }

.quota-text {
  font-size: 12px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ─────────────────────── 面包屑 ─────────────────────── */

.crumbs {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1px;
  padding: 14px 24px 0;
  font-size: 13px;
}

.crumb {
  background: none;
  border: 0;
  padding: 5px 9px;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--text-3);
  transition: color .15s var(--ease), background .15s var(--ease);
}
.crumb:hover { background: var(--surface-2); color: var(--text); }
.crumb.current { color: var(--text); font-weight: 600; }

.crumb-sep {
  width: 14px;
  height: 14px;
  color: var(--text-3);
  opacity: .5;
  flex-shrink: 0;
}

/* ─────────────────────── 工具栏 ─────────────────────── */

.toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px 16px;
}

.toolbar-group { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  box-shadow: var(--shadow-1);
  transition: background .16s var(--ease), border-color .16s var(--ease),
              box-shadow .16s var(--ease), transform .1s var(--ease);
}

.btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); box-shadow: none; }

/*
 * 禁用态。pointer-events: none 一次性掐掉所有 hover/active 效果 ——
 * 否则还得为每种按钮变体各写一遍「禁用时 hover 不要变色」。
 */
.btn:disabled {
  opacity: .4;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(15, 118, 110, .22), 0 2px 8px rgba(15, 118, 110, .16);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-icon { width: 36px; padding: 0; }

.btn-mini {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s var(--ease), color .15s var(--ease),
              border-color .15s var(--ease);
}
.btn-mini svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.btn-mini:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }

/* ─────────────────────── 列表 ─────────────────────── */

.panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 0 24px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}

.panel-head, .row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px 132px 132px;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
}

.panel-head {
  flex-shrink: 0;
  height: 38px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: .06em;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

/* 可点的表头。负外边距让文字跟下面的内容对齐，
   否则加出来的内边距会把整列往右推 */
.sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  justify-self: start;
  padding: 3px 7px;
  margin-left: -7px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--text-3);
  cursor: pointer;
  transition: background .14s var(--ease), color .14s var(--ease);
}
.sort:hover { background: var(--surface-3); color: var(--text-2); }

/*
 * 排序方向的小三角。默认隐藏，哪一列在排序才显示哪一列。
 *
 * 用 border-bottom 画出朝上的三角，对应「升序」——
 * 跟 Windows 资源管理器一致（升序朝上、倒序朝下）。
 * 一开始写成朝下当基底，结果升降序的箭头整个反了。
 */
.sort::after {
  content: '';
  width: 0;
  height: 0;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-bottom: 4px solid currentColor;
  opacity: 0;
  transition: opacity .14s var(--ease), transform .14s var(--ease);
}

.sort[data-dir] { color: var(--text); }
.sort[data-dir='asc']::after { opacity: 1; }
.sort[data-dir='desc']::after { opacity: 1; transform: rotate(180deg); }

.list { flex: 1; overflow-y: auto; overflow-x: hidden; }

.row {
  height: 52px;
  border-bottom: 1px solid var(--border);
  transition: background .13s var(--ease);
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.row.is-dir { cursor: pointer; }

.col-size, .col-time {
  font-size: 12.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.col-act {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  opacity: 0;
  transform: translateX(4px);
  transition: opacity .16s var(--ease), transform .16s var(--ease);
}
.row:hover .col-act, .row:focus-within .col-act { opacity: 1; transform: none; }

.name-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }

.name-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--t-plain);   /* 单色线描：默认中性，文件夹单独着色 */
}
.row.is-dir .name-icon { color: var(--accent); }

.name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
  color: var(--text);
}
.row.is-dir .name-text { font-weight: 500; }

/* 类型标签：全页唯一出现彩色的地方。用当前色混出淡底，就不用为每种类型
   各写一条 background —— 只需给 color 换变量。 */
.tag {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: .04em;
  padding: 3px 5px;
  border-radius: var(--r-xs);
  color: var(--t-plain);
  background: color-mix(in srgb, currentColor 13%, transparent);
}

.tag[data-t="doc"]     { color: var(--t-doc); }
.tag[data-t="sheet"]   { color: var(--t-sheet); }
.tag[data-t="slide"]   { color: var(--t-slide); }
.tag[data-t="pdf"]     { color: var(--t-pdf); }
.tag[data-t="image"]   { color: var(--t-image); }
.tag[data-t="video"]   { color: var(--t-video); }
.tag[data-t="audio"]   { color: var(--t-audio); }
.tag[data-t="archive"] { color: var(--t-archive); }
.tag[data-t="code"]    { color: var(--t-code); }
.tag[data-t="text"]    { color: var(--t-text); }

/* ─────────────────────── 多选 ─────────────────────── */

/*
 * 勾选框**常显**，不是悬停才出现。
 *
 * 一开始做的是「悬停时勾选框盖住文件图标」—— 那是 Google Drive 的做法，
 * 但它依赖用户已经知道这个套路。实际结果是用户根本发现不了多选功能，
 * 直接反馈「没有批量选中」。功能藏起来等于不存在。
 *
 * 现在勾选框和图标并排常驻：多一点左侧留白，换来一眼就能看明白。
 */
.lead {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.pick {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  padding: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  color: #fff;
  cursor: pointer;
  transition: background .12s var(--ease), border-color .12s var(--ease);
}
.pick:hover { border-color: var(--text-3); }

.pick::after {
  content: '';
  width: 4px;
  height: 8px;
  margin-top: -2px;
  border-right: 1.8px solid currentColor;
  border-bottom: 1.8px solid currentColor;
  transform: rotate(45deg);
  opacity: 0;
}

.pick[aria-checked='true'] {
  background: var(--accent);
  border-color: var(--accent);
}
.pick[aria-checked='true']::after { opacity: 1; }

/* 部分选中：一横杠。表头的全选框用得上 */
.pick[aria-checked='mixed'] {
  background: var(--accent);
  border-color: var(--accent);
}
.pick[aria-checked='mixed']::after {
  width: 7px;
  height: 0;
  margin: 0;
  border-right: 0;
  border-bottom: 1.8px solid currentColor;
  transform: none;
  opacity: 1;
}

/* 表头那列：全选框 + 「名称」 */
.panel-head .col-name {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 选中状态下藏掉每行的操作按钮 —— 那会儿能做的操作由工具栏统一给，
   留着它们只会让人分不清「删除」删的是这一行还是选中的那些 */
body.picking .col-act { display: none; }

.pick-count {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding-right: 4px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--text-2);
}
.btn-ghost:hover {
  background: var(--surface-2);
  border-color: transparent;
  color: var(--text);
}

/* ─────────────────────── 搜索结果 ─────────────────────── */

.search-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 38px;
  padding: 0 18px;
  font-size: 12.5px;
  color: var(--text-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.search-head b { color: var(--text); font-weight: 600; }

.search-count {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

/*
 * 搜索结果复用普通的 .row 布局，只在名称后面多挂一个「所在位置」。
 *
 * 跨目录搜索时，东西在哪儿比它多大更有用 —— 用户看到「产品说明书.md」
 * 的第一反应是「它在哪个文件夹里」。
 *
 * 位置不单独占一列，而是跟在文件名后面：这样「大小」列跟文件列表精确对齐，
 * 在两处之间切换不会跳；窄屏下也会先保证文件名够宽，路径自己让位。
 */
.row.result { cursor: pointer; }

.result-path {
  flex: 0 1 auto;
  min-width: 0;
  font-size: 12px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 文件名优先占空间，路径先被压缩 */
.row.result .name-text { flex-shrink: 1; }

mark {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}

/* 从搜索结果跳过去之后，把目标那一行闪一下 —— 否则一屏几十行，
   根本不知道刚点的是哪个 */
@keyframes flash-row {
  0%, 100% { background: transparent; }
  12%, 55% { background: var(--accent-soft); }
}
.row.flash { animation: flash-row 1.5s var(--ease); }

/* 网格里的键盘焦点。用外描边而不是改边框色 ——
   改边框色会跟「已选中」的状态撞在一起分不清 */
.tile.focused {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 正在搜索时把旧结果压暗，看起来像「在更新」而不是「卡住了」 */
.list.stale { opacity: .45; transition: opacity .15s var(--ease); }

/* ─────────────────────── 拖拽移动 ─────────────────────── */

.row.dragging, .tile.dragging { opacity: .4; }

/* 拖到哪个文件夹上，那个文件夹整体亮起来。
   比画一条细线更清楚 —— 尤其是网格视图里格子挨得很近的时候 */
.row.drop-target, .tile.drop-target {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent);
}
.tile.drop-target { box-shadow: 0 0 0 2px var(--accent); }

/* 拖拽时别让浏览器把文字选起来，那会跟拖拽打架 */
.row, .tile { -webkit-user-drag: element; }
.row .name-text, .tile-name { user-select: none; }

/* ─────────────────────── 键盘焦点 ─────────────────────── */

/*
 * 左边一条竖线，而不是整行高亮。
 * 整行高亮跟 hover 效果几乎一样，键盘用户会分不清「光标在哪」和
 * 「鼠标在哪」；竖线是另一套视觉语言，一眼就能区分。
 */
.row.focused {
  background: var(--surface-2);
  box-shadow: inset 3px 0 0 0 var(--accent);
}

/* ─────────────────────── 行内重命名 ─────────────────────── */

.name-input {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  /* 负外边距抵消输入框和文字的高度差，否则整行会往上跳一下 */
  margin: -3px 0;
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-ring);
}

/* 改名时藏掉类型标签和操作按钮 —— 前者跟输入框抢地方，
   后者会在你打字的时候被误点到 */
.row.editing .tag,
.row.editing .col-act { display: none; }

/* ─────────────────────── 网格视图 ─────────────────────── */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 12px;
  padding: 16px;
}

/*
 * 网格视图下，表头退化成一条排序栏。
 *
 * 「名称 / 大小 / 修改时间」这些列标题在网格里没有对应物（格子是等宽平铺的），
 * 留着只会让人以为上面还有一列对不齐的内容。但全选和排序仍然有用，
 * 所以把 grid 布局换成一行 flex，几个按钮自然排开。
 */
body.grid-view .panel-head {
  display: flex;
  align-items: center;
  gap: 2px;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease),
              transform .1s var(--ease);
}
.tile:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.tile:active { transform: translateY(1px); }

/* 选中态用整圈强调色描边，而不是只给勾选框上色 ——
   一屏几十个格子时，光看角落里的小方块很难扫出选了哪些 */
.tile[data-picked='true'] {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-ring);
}

.tile-thumb {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
  overflow: hidden;
}

.tile-thumb img {
  width: 100%;
  height: 100%;
  /* cover 而不是 contain：一排参差不齐的留白比裁掉一点更难看 */
  object-fit: cover;
  display: block;
}

.tile-thumb svg {
  width: 32px;
  height: 32px;
  color: var(--text-3);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tile[data-dir='true'] .tile-thumb svg { color: var(--accent); }

/* 勾选框浮在缩略图左上角 */
.tile .pick {
  position: absolute;
  z-index: 2;
  top: 8px;
  left: 8px;
  /* 缩略图可能很亮，纯白底的勾选框会糊进去 */
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}

.tile-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 9px 11px 11px;
  min-width: 0;
}

.tile-name {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile[data-dir='true'] .tile-name { font-weight: 500; }

.tile-size {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* ─────────────────────── 空状态 ─────────────────────── */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 320px;
  padding: 64px 24px;
  text-align: center;
  color: var(--text-3);
}

.empty-icon {
  width: 44px;
  height: 44px;
  color: var(--border-strong);
  margin-bottom: 6px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-title { font-size: 14px; font-weight: 500; color: var(--text-2); }
.empty-hint { font-size: 12.5px; color: var(--text-3); }

.empty-hint kbd {
  font: inherit;
  font-size: 11.5px;
  padding: 1px 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--r-xs);
  background: var(--surface-2);
  color: var(--text-2);
}

/* ─────────────────────── 上传面板 ─────────────────────── */

.uploads {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 336px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-4);
  z-index: 40;
  overflow: hidden;
}

.uploads-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  font-size: 12.5px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.uploads-body { max-height: 264px; overflow-y: auto; padding: 6px 14px 12px; }
.uploads.collapsed .uploads-body { display: none; }

.up-item { padding: 8px 0; }
.up-name {
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 5px;
}
.up-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-3);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.up-bar {
  height: 3px;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
  margin-top: 6px;
}
.up-fill {
  height: 100%;
  width: 0;
  border-radius: 2px;
  background: var(--accent);
  transition: width .25s var(--ease);
}
.up-item.done .up-fill { background: var(--accent); }
.up-item.fail .up-fill { background: var(--danger); }
.up-item.fail .up-meta { color: var(--danger); }

/* ─────────────────────── 拖拽遮罩 ─────────────────────── */

.dropzone {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  backdrop-filter: blur(3px);
  pointer-events: none;
  animation: fade-in .16s var(--ease);
}

.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 56px;
  border: 2px dashed var(--accent);
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-4);
  font-size: 14px;
  font-weight: 500;
}

.dropzone-inner svg {
  width: 30px;
  height: 30px;
  color: var(--accent);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ─────────────────────── 预览弹窗 ─────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 25, 23, .48);
  backdrop-filter: blur(2px);
  animation: fade-in .2s var(--ease);
}

.modal-box {
  position: relative;
  width: min(1120px, 100%);
  height: min(820px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-4);
  overflow: hidden;
  animation: modal-in .24s var(--ease);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(.99); }
  to   { opacity: 1; transform: none; }
}

.modal-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.modal-title {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-pos {
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.modal-actions { margin-left: auto; display: flex; gap: 8px; flex-shrink: 0; }

.btn-step { width: 28px; padding: 0; justify-content: center; }
.btn-step:disabled { opacity: .35; }

.modal-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--surface-2);
}

/*
 * 图片要真正居中。margin: auto 对块级元素只能水平居中 —— 之前图片一直贴在最上面，
 * 下面留一大片空。改成 flex 才能两个方向都居中。
 *
 * 用 :has() 判断而不是让 JS 额外挂一个状态类：图片是唯一需要这种处理的类型，
 * 为它维护一份和 DOM 同步的 class 不划算。
 */
.modal-body:has(> img) {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
}

.modal-body img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
}

.modal-body video { display: block; width: 100%; height: 100%; background: #000; object-fit: contain; }
.modal-body audio { display: block; margin: 56px auto; width: min(560px, 86%); }
.modal-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }

.modal-body pre {
  margin: 0;
  padding: 20px 22px;
  font: 12.5px/1.7 ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  tab-size: 4;
}

.modal-body pre.plain { white-space: pre; overflow-x: auto; word-break: normal; }

.modal-body .center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 60px 24px;
  text-align: center;
  color: var(--text-3);
}

/* ─────────────────────── 应用内对话框 ─────────────────────── */

/*
 * 层级安排：预览弹窗 80 < 对话框 90 < 提示 100。
 * 对话框必须盖过预览弹窗（删除确认可能是在预览里触发的），
 * 提示要盖过一切。
 */
.dialog {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 25, 23, .48);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity .16s var(--ease);
}

.dialog-box {
  position: relative;
  width: min(420px, 100%);
  padding: 22px 22px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-4);
  opacity: 0;
  transform: translateY(8px) scale(.98);
  transition: opacity .18s var(--ease), transform .18s var(--ease);
}

.dialog.open .dialog-backdrop { opacity: 1; }
.dialog.open .dialog-box { opacity: 1; transform: none; }

/* 退场：比入场快一点，关起来才不拖沓 */
.dialog.closing .dialog-backdrop { opacity: 0; }
.dialog.closing .dialog-box { opacity: 0; transform: translateY(4px) scale(.99); }

.dialog-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
  /* 文件名可能很长，别把对话框撑破 */
  overflow-wrap: anywhere;
}

.dialog-body { margin-top: 8px; }
.dialog-body:empty { margin-top: 0; }

.dialog-hint {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-2);
}

.dialog-input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}

.dialog-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

/* 选择器的列表。限制高度并自己滚动 —— 目录多的时候不能把对话框撑破 */
.dialog-list {
  max-height: min(300px, 46vh);
  overflow-y: auto;
  margin: 0 -6px;
  padding: 2px 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.dialog-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 12px;
  border: 0;
  background: none;
  text-align: left;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: background .12s var(--ease);
}
.dialog-option:hover:not(:disabled) { background: var(--surface-3); }

.dialog-option[aria-selected='true'] {
  background: var(--accent);
  color: #fff;
  font-weight: 500;
}

.dialog-option.is-disabled {
  color: var(--text-3);
  cursor: default;
}

.dialog-option-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-option-note {
  flex-shrink: 0;
  font-size: 11.5px;
  opacity: .7;
}

.dialog-empty {
  padding: 22px 12px;
  text-align: center;
  font-size: 13px;
  color: var(--text-3);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* 空名字时抖一下。比弹个错误提示轻，也不会打断输入 */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.dialog-input.shake {
  animation: shake .38s var(--ease);
  border-color: var(--danger);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  box-shadow: 0 1px 2px rgba(179, 38, 30, .22), 0 2px 8px rgba(179, 38, 30, .16);
}
.btn-danger:hover {
  background: color-mix(in srgb, var(--danger) 85%, #000);
  border-color: transparent;
}

/* ─────────────────────── 提示 ─────────────────────── */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-3);
  animation: toast-in .22s var(--ease);
  max-width: 76vw;
}
.toast.err { background: var(--danger); color: #fff; }
.toast.ok  { background: var(--accent); color: #fff; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

/* ═══════════════════════ Office 预览 ═══════════════════════ */

/*
 * 三种文档一律渲染成「白纸黑字」，不跟随站点主题。
 *
 * docx-preview / SheetJS 产出的内容假定背景是白的 —— Word 默认黑字，
 * Excel 的单元格底色也按白底设计。在深色主题下让它们继承页面文字色，
 * 会变成浅色字配白底（看不见）或者黑字配黑底（也看不见）。
 * 固定成纸张效果反而最忠实。
 */

/*
 * 只有 Excel 和服务端 PDF 需要特殊处理：它们要自己的滚动容器（表头才能吸顶、
 * PDF 阅读器自己滚），所以把弹窗容器固定住、不让它滚。
 *
 * Word 和 PPT 千万别加这个 —— 加了之后长文档超出高度会被直接裁掉，
 * 连滚动条都没有，用户会以为文件内容缺失。
 */
.modal-body.office-sheet {
  position: relative;
  overflow: hidden;
}

.office-note {
  padding: 44px 24px;
  text-align: center;
  color: var(--text-3);
  font-size: 13.5px;
}

.office-note.office-error { color: var(--danger); }

.office-note.office-warn {
  padding: 12px 16px;
  text-align: left;
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 8%, var(--surface));
  border-top: 1px solid color-mix(in srgb, var(--warn) 22%, transparent);
}

.office-loading::after {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 9px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  vertical-align: -1px;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Word ── */

.docx-host { padding: 22px 14px 34px; }

.docx-host .docx-wrapper {
  background: transparent !important;
  padding: 0 !important;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.docx-host .docx-wrapper > section.docx {
  background: #fff;
  color: #1c1917;
  box-shadow: 0 1px 3px rgba(41, 37, 36, .14), 0 10px 28px rgba(41, 37, 36, .12);
  margin: 0 0 18px !important;
  max-width: 100%;
  overflow-x: auto;
}

/* ── Excel ── */

.xlsx-root {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.xlsx-tabs {
  flex-shrink: 0;
  display: flex;
  gap: 3px;
  padding: 8px 10px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.xlsx-tab {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--r-md) var(--r-md) 0 0;
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s var(--ease), background .15s var(--ease);
}
.xlsx-tab:hover { color: var(--text); }

.xlsx-tab.active {
  background: #fff;
  color: #1c1917;
  font-weight: 600;
  margin-bottom: -1px;   /* 盖住标签栏底边，做出「和内容连成一体」的效果 */
  padding-bottom: 7px;
}

.xlsx-panel { flex: 1; min-height: 0; overflow: auto; background: #fff; }

.xlsx-hint {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 11.5px;
  color: var(--text-3);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.xlsx-table {
  border-collapse: separate;   /* sticky 表头需要 separate，collapse 下边框会错位 */
  border-spacing: 0;
  font-size: 13px;
  color: #1c1917;
  font-variant-numeric: tabular-nums;
}

.xlsx-table th, .xlsx-table td {
  border-right: 1px solid #e2ded7;
  border-bottom: 1px solid #e2ded7;
  padding: 4px 8px;
  min-width: 64px;
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.xlsx-rowhead {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #f2efeb;
  color: #8b857d;
  font-weight: 500;
  text-align: center;
  min-width: 44px;
  width: 44px;
}

.xlsx-colhead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f2efeb;
  color: #8b857d;
  font-weight: 500;
  text-align: center;
  min-width: 44px;
}

.xlsx-table thead th:first-child {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 3;
  background: #e9e5df;
  min-width: 44px;
}

.xlsx-table tbody tr:nth-child(even) td { background: #fbfaf9; }
.xlsx-table tbody tr:hover td { background: #f0f6f5; }

/* 有公式但文件里没存计算结果 —— 显示公式原文，弱化处理表示「这不是值」 */
.xlsx-formula {
  color: #8b857d !important;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

/* ── 服务端转换的 PDF ── */

/*
 * 用绝对定位而不是 width/height: 100%。iframe 的高度百分比要求父元素有确定高度，
 * 而弹窗 body 是靠 flex 撑开的，这条链一旦断掉 iframe 会塌成 0 高（一片空白）。
 */
.server-pdf {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

/* ── PowerPoint ── */

.pptx-host {
  padding: 22px 14px 34px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/*
 * pptx-preview 会给它自己的 wrapper 写上内联的
 *   height: <固定值>; overflow-y: auto; background: rgb(0,0,0)
 * 结果是幻灯片区域内部又套一层滚动条，跟弹窗的滚动条打架。
 * 内联样式只能靠 !important 覆盖。
 */
.pptx-host > div {
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  background: transparent !important;
}

.pptx-host > div > div {
  background: #fff;
  box-shadow: 0 1px 3px rgba(41, 37, 36, .14), 0 10px 28px rgba(41, 37, 36, .12);
  margin: 0 auto 18px;
}
.pptx-host > div > div:last-child { margin-bottom: 0; }

/* ── 兜底引导块 ── */

.fallback-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 18px;
}

.office-error-text { color: var(--danger); }

/* ─────────────────────── 窄屏 ─────────────────────── */

@media (max-width: 760px) {
  /* 手机上让整页滚动。固定高度 + 内部滚动在移动浏览器上会因为地址栏
     收放而抖动，得不偿失。 */
  html, body { height: auto; overflow: visible; }

  .topbar { height: auto; flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
  .quota { margin-left: 0; width: 100%; justify-content: space-between; }
  .quota-track { width: auto; flex: 1; }

  .crumbs, .toolbar { padding-left: 16px; padding-right: 16px; }
  .crumbs { padding-top: 12px; }

  /*
   * 手机上让所有按钮一起换行，而不是「组内换行 + 刷新单独飘右边」。
   * display: contents 让分组里的按钮直接参与 toolbar 的 flex 布局 ——
   * 分组的意义在桌面端（把主要操作和刷新分开），窄屏下没有意义。
   */
  .toolbar { flex-wrap: wrap; padding-top: 12px; padding-bottom: 14px; }
  .toolbar-group { display: contents; }

  .panel { margin: 0 16px 20px; }

  /* 手机上只留「名称 + 操作」两列。大小和时间挤在一行里会读不清，
     而列表本身已经够长了，没必要为了塞信息牺牲可读性。 */
  .panel-head, .row { grid-template-columns: minmax(0, 1fr) 108px; gap: 8px; padding: 0 14px; }
  .col-size, .col-time { display: none; }

  /* 只剩一列可见的时候，表头基本是空的，不如把空间让给列表 */
  .panel-head { display: none; }

  /* 操作按钮只留图标 —— 三个带文字的按钮在这个宽度下会把文件名压没。
     32px 是因为手指的触控目标不该小于这个尺寸。 */
  .col-act { opacity: 1; transform: none; gap: 6px; }
  .btn-mini { width: 32px; height: 32px; padding: 0; justify-content: center; }
  .btn-mini-label { display: none; }

  .name-cell { gap: 9px; }
  .tag { display: none; }   /* 窄屏下标签会跟文件名抢空间，图标已经够说明了 */

  /* 搜索结果在手机上只剩一个可见单元（大小列已隐藏），
     还按两列排的话右边会空出一块 */
  .row.result { grid-template-columns: minmax(0, 1fr); }

  .uploads { left: 16px; right: 16px; width: auto; bottom: 16px; }

  .modal { padding: 0; }
  .modal-box { width: 100%; height: 100%; border-radius: 0; border: 0; }
}

/* 触摸设备没有 hover，行内操作按钮必须常驻 —— 否则根本点不到。
   勾选框本来就是常显的，不受影响。 */
@media (hover: none) {
  .col-act { opacity: 1; transform: none; }
}
