:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --line: #e5e9f2;
  --text: #1b2333;
  --muted: #6b7789;
  --primary: #2f6bff;
  --primary-weak: #eaf0ff;
  --danger: #e5484d;
  --ok: #12a150;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }

button {
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  padding: 7px 12px;
  transition: background .15s, border-color .15s, color .15s;
}

button:disabled { opacity: .5; cursor: not-allowed; }

.btn {
  background: var(--panel);
  border-color: var(--line);
  box-shadow: 0 1px 1px rgba(16, 24, 40, .03);
  white-space: nowrap;
}
.btn:hover { background: #f7f9fd; border-color: #d5dcea; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #245ce0; }
.btn.danger { color: var(--danger); border-color: #f4cfd0; background: #fff; }
.btn.danger:hover { background: #fff5f5; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(16, 24, 40, .05); }
#btnLogoutWeb { color: #e5484d; }
#btnLogoutWeb:hover { background: #fdeaea; }

input[type=text], input[type=password], input[type=search], select {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
  width: 100%;
}
input:focus, select:focus { border-color: #9fb6ee; box-shadow: 0 0 0 3px rgba(47, 107, 255, .12); }

/* ---------------------------------------------------------------- login */
.login-wrap {
  height: 100%;
  display: grid;
  place-items: center;
  background: radial-gradient(1200px 600px at 15% -10%, #e6eeff 0%, transparent 60%),
              radial-gradient(900px 500px at 100% 110%, #eaf4ff 0%, transparent 55%),
              var(--bg);
}
.login-card {
  width: min(380px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #4b84ff, #2456d8);
  display: grid; place-items: center; color: #fff; font-weight: 700;
}
.brand h1 { font-size: 18px; margin: 0; letter-spacing: .2px; }
.login-sub { color: var(--muted); margin: 0 0 22px; font-size: 13px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.login-card .btn.primary { width: 100%; padding: 10px; margin-top: 6px; }
.login-msg { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 10px; }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 248px 1fr; height: 100%; }

.side {
  background: #fbfcfe;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 16px 12px;
  gap: 4px;
  overflow: hidden;
}
.side .brand { padding: 4px 8px 14px; }
.side-title {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: #98a2b3; padding: 10px 10px 6px;
  display: flex; justify-content: space-between; align-items: center;
}
.lib-list { overflow-y: auto; flex: 1; margin: 0 -4px; padding: 0 4px; }
.lib-hint { font-size: 11.5px; color: #aab4c6; padding: 8px 6px 2px; text-align: center; }
.hint-inline { font-size: 12px; color: #a3adbf; margin-left: 6px; }
.lib-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 9px; cursor: pointer;
  color: #33405a; font-size: 13.5px;
}
.lib-item:hover { background: #eef2fa; }
.lib-item.active { background: var(--primary-weak); color: #1e50d0; font-weight: 600; }
.lib-item .dot {
  width: 8px; height: 8px; border-radius: 3px; background: #a9b6cd; flex: none;
}
.lib-item.active .dot { background: var(--primary); }
.lib-item .count { margin-left: auto; font-size: 11.5px; color: #93a0b5; font-weight: 400; }

/* 资料库右键菜单 */
.ctx-menu {
  position: fixed; z-index: 90; display: none;
  min-width: 150px; padding: 6px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 30px rgba(23, 39, 71, .16);
}
.ctx-menu.on { display: block; }
.ctx-menu .ctx-title {
  padding: 5px 9px 7px; font-size: 11.5px; color: #93a0b5;
  border-bottom: 1px solid var(--line); margin-bottom: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 190px;
}
.ctx-menu button {
  display: block; width: 100%; text-align: left;
  border: 0; background: transparent; cursor: pointer;
  padding: 7px 9px; border-radius: 7px;
  font-size: 13px; color: #33405a;
}
.ctx-menu button:hover { background: #eef2fa; }
.ctx-menu button.danger { color: #e5484d; }
.ctx-menu button.danger:hover { background: #fdeaea; }

.side-foot { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 8px; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 9px; }
.user-row:hover { background: #eef2fa; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, #7aa2ff, #3f6be0);
  color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 600;
}
.user-meta { min-width: 0; }
.user-meta b { font-size: 13px; font-weight: 600; display: block; }
.user-meta span { font-size: 11.5px; color: var(--muted); }

/* ---------------------------------------------------------------- main */
.main { display: flex; flex-direction: column; min-width: 0; background: var(--bg); }

.topbar {
  height: 58px; flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px;
  background: rgba(255, 255, 255, .8);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.crumbs { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; overflow: hidden; }

/* 顶栏右侧按钮组：宽屏保持原样，窄屏整组隐藏、收进 ⋯ */
.top-actions { display: flex; align-items: center; gap: 10px; flex: none; }
/* ☰ 与 ⋯ 仅在窄屏出现 */
.nav-btn { display: none; }
/* 行内「⋯」按钮：桌面靠右键，故隐藏；窄屏常显 */
.more-btn { display: none; }
.crumbs button {
  padding: 4px 7px; border-radius: 6px; color: #4a5568; font-size: 13px;
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.crumbs button:hover { background: rgba(16, 24, 40, .05); }
.crumbs span.sep { color: #c2cad8; }
.crumbs b { font-size: 13.5px; padding: 4px 7px; }

.toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 18px;
}
.toolbar .spacer { flex: 1; }
.search { position: relative; width: 220px; }
.search input { padding-left: 30px; height: 34px; background: #fff; }
.search svg { position: absolute; left: 9px; top: 9px; opacity: .45; }

.content { flex: 1; overflow: auto; padding: 0 18px 18px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

table.files { width: 100%; border-collapse: collapse; }
table.files th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fbfcfe;
  position: sticky; top: 0; z-index: 1; white-space: nowrap;
}
table.files td {
  padding: 9px 14px; border-bottom: 1px solid #f1f4f9; font-size: 13.5px;
  vertical-align: middle;
}
table.files tr:last-child td { border-bottom: 0; }
table.files tbody tr:hover { background: #fafbfe; }
table.files tbody tr.sel { background: var(--primary-weak); }
.name-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.name-cell .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.name-cell .label:hover { color: var(--primary); text-decoration: underline; }
.ico { width: 22px; height: 22px; flex: none; display: grid; place-items: center; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.actions-cell { display: flex; gap: 2px; justify-content: flex-end; opacity: 0; }
tr:hover .actions-cell { opacity: 1; }
.icon-btn { padding: 4px 6px; border-radius: 6px; color: #5a6a85; }
.icon-btn:hover { background: rgba(16, 24, 40, .06); color: var(--text); }

.empty {
  padding: 72px 20px; text-align: center; color: var(--muted);
}
.empty h3 { color: #3c4a63; margin: 12px 0 6px; font-size: 15px; font-weight: 600; }
.empty p { margin: 0; font-size: 13px; }

/* upload tray */
.tray {
  position: fixed; right: 20px; bottom: 20px; width: 320px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 12px 40px rgba(16, 24, 40, .16);
  overflow: hidden; z-index: 50;
}
.tray-head {
  padding: 10px 12px; font-size: 12.5px; font-weight: 600;
  border-bottom: 1px solid var(--line); display: flex; justify-content: space-between;
}
.tray-body { max-height: 220px; overflow: auto; }
.up-item { padding: 8px 12px; border-bottom: 1px solid #f4f6fa; }
.up-item:last-child { border-bottom: 0; }
.up-item .n { font-size: 12.5px; display: flex; justify-content: space-between; gap: 8px; }
.up-item .n span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 3px; background: #eef1f7; border-radius: 2px; margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--primary); width: 0; transition: width .2s; }
.bar i.err { background: var(--danger); }

/* dropzone */
.drop-hint {
  position: fixed; inset: 0; z-index: 60; display: none;
  place-items: center; background: rgba(47, 107, 255, .06);
  border: 2px dashed #8fb0ff; border-radius: 0;
  color: #2b5bdc; font-weight: 600; font-size: 15px;
  backdrop-filter: blur(1px);
}
.drop-hint.on { display: grid; }

/* modal + drawer */
.overlay {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .38);
  display: none; z-index: 70;
}
.overlay.on { display: block; }
.modal {
  position: fixed; z-index: 80; left: 50%; top: 14vh; transform: translateX(-50%);
  width: 420px; background: #fff; border-radius: 14px; box-shadow: 0 24px 64px rgba(16, 24, 40, .24);
  display: none; overflow: hidden;
}
.modal.on { display: block; }
.modal h3 { margin: 0; padding: 16px 18px 10px; font-size: 15px; }
.modal .body { padding: 0 18px 14px; }
.modal .foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: #fbfcfe; }
.modal p.tip { color: var(--muted); font-size: 12.5px; margin: 6px 0 12px; }

.drawer {
  position: fixed; right: 0; top: 0; bottom: 0; width: 400px; z-index: 80;
  background: #fff; border-left: 1px solid var(--line); box-shadow: -12px 0 40px rgba(16, 24, 40, .12);
  transform: translateX(100%); transition: transform .2s ease;
  display: flex; flex-direction: column;
}
.drawer.on { transform: none; }
.drawer-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.drawer-head h3 { margin: 0; font-size: 14.5px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-body { padding: 8px 18px 18px; overflow: auto; }
.ver-item { padding: 10px 0; border-bottom: 1px solid #f1f4f9; }
.ver-item:last-child { border-bottom: 0; }
.ver-top { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.tag {
  font-size: 11px; padding: 1px 6px; border-radius: 5px; background: #eef2fa; color: #4a5875;
}
.tag.cur { background: #e7f7ee; color: #0f7a3d; }
.tag.restore { background: #fff3e6; color: #9a5b12; }
.ver-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.ver-actions { display: flex; gap: 6px; margin-top: 6px; }
.ver-actions button { font-size: 12px; padding: 3px 8px; }

.kv { display: grid; grid-template-columns: 88px 1fr; gap: 8px; font-size: 13px; padding: 10px 0; border-bottom: 1px solid #f1f4f9; }
.kv b { color: var(--muted); font-weight: 500; }
.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; background: #f5f7fb; border: 1px solid var(--line);
  padding: 8px 10px; border-radius: 8px; word-break: break-all;
}

.stat-row { display: flex; gap: 10px; padding: 0 18px 14px; }
.stat {
  flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; box-shadow: var(--shadow);
}
.stat span { font-size: 11.5px; color: var(--muted); display: block; }
.stat b { font-size: 17px; font-weight: 600; letter-spacing: -.2px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(10px);
  background: #1b2333; color: #fff; padding: 9px 16px; border-radius: 9px;
  font-size: 13px; opacity: 0; transition: .2s; z-index: 100; pointer-events: none;
  max-width: 80vw;
}
.toast.on { opacity: 1; transform: translateX(-50%); }
.toast.err { background: #b42318; }

.spin {
  width: 15px; height: 15px; border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff; border-radius: 50%; animation: sp .7s linear infinite;
  display: inline-block; vertical-align: -2px;
}
@keyframes sp { to { transform: rotate(360deg); } }

.pill { font-size: 11px; padding: 2px 7px; border-radius: 20px; background: #eef2fa; color: #4a5875; }
.pill.on { background: #e7f7ee; color: #0f7a3d; }

@media (max-width: 860px) {
  .drawer { width: 100%; }
}

/* ---------------------------------------------------------- 预览层 */
.pv {
  position: fixed; inset: 0; z-index: 95; display: none;
  flex-direction: column; background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(2px);
}
.pv.on { display: flex; }
.pv-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line);
  flex: none;
}
.pv-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
#pvName {
  font-size: 14px; font-weight: 600; color: #1b2333;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46vw;
}
.pv-meta { font-size: 12px; color: #98a2b3; flex: none; }
.pv-tools { margin-left: auto; display: flex; gap: 6px; flex: none; }
.pv-tools .btn { font-size: 12.5px; padding: 5px 11px; }
.pv-body {
  flex: 1; min-height: 0; overflow: auto; margin: 18px auto; width: min(1100px, 94vw);
  background: #fff; border-radius: 12px; box-shadow: 0 18px 50px rgba(15, 23, 42, .28);
  display: flex; align-items: center; justify-content: center;
}
.pv.media { background: rgba(8, 12, 20, .9); }
.pv.media .pv-body {
  background: transparent; box-shadow: none; margin: 0; width: 100%; height: 100%;
  padding: 0 0 10px; overflow: hidden;
}
.pv.media .pv-bar { background: rgba(255, 255, 255, .06); border-bottom: 0; backdrop-filter: blur(8px); }
.pv.media #pvName { color: #fff; }
.pv.media .pv-meta { color: #98a2b3; }
.pv.media .pv-tools .btn { color: #e8edf7; }
.pv.media .pv-tools .btn:hover { background: rgba(255, 255, 255, .12); }
.pv img.shot {
  max-width: 94%; max-height: 100%; object-fit: contain;
  border-radius: 6px; box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
}
.pv video { max-width: 96%; max-height: 100%; border-radius: 8px; background: #000; }
.pv audio { width: min(560px, 80%); }
.pv iframe { width: 100%; height: 100%; border: 0; border-radius: 12px; background: #fff; }
.pv .pv-text {
  align-self: stretch; width: 100%; height: 100%; overflow: auto;
  padding: 26px 34px; font-size: 14px; line-height: 1.75; color: #1f2937;
  white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, Menlo, Consolas, monospace;
}
.pv .pv-md { align-self: flex-start; width: 100%; height: auto; overflow: visible;
  padding: 30px 40px; font-size: 14.5px; line-height: 1.8; color: #1f2937;
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif; }
.pv-md h1, .pv-md h2, .pv-md h3 { margin: 1.2em 0 .5em; line-height: 1.35; }
.pv-md h1 { font-size: 22px; border-bottom: 1px solid #eef1f6; padding-bottom: 8px; }
.pv-md h2 { font-size: 18px; }
.pv-md h3 { font-size: 16px; }
.pv-md p { margin: .7em 0; }
.pv-md code { background: #f2f5fa; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.pv-md pre { background: #f7f9fc; border: 1px solid #eef1f6; padding: 12px 14px; border-radius: 8px; overflow: auto; }
.pv-md pre code { background: none; padding: 0; }
.pv-md blockquote { margin: .8em 0; padding: 4px 14px; border-left: 3px solid #cbd5e1; color: #64748b; }
.pv-md ul, .pv-md ol { padding-left: 22px; }
.pv-md a { color: var(--primary); }
.pv-md hr { border: 0; border-top: 1px solid #eef1f6; margin: 1.4em 0; }
.docx-wrap { align-self: stretch; width: 100%; padding: 24px; background: #f4f6fa; overflow: auto; }
.docx-wrap .docx-wrapper { background: transparent; padding: 0; }
.docx-wrap .docx-wrapper > section.docx { box-shadow: 0 4px 18px rgba(15, 23, 42, .12); margin: 0 auto 18px; }
.sheet-tabs { display: flex; gap: 6px; padding: 10px 14px 0; flex-wrap: wrap; width: 100%; }
.sheet-tabs button {
  border: 1px solid var(--line); background: #fff; border-radius: 7px;
  padding: 4px 11px; font-size: 12.5px; color: #475569; cursor: pointer;
}
.sheet-tabs button.on { background: var(--primary-weak); border-color: #c7d7ff; color: #1e50d0; font-weight: 600; }
.sheet-box { align-self: stretch; width: 100%; overflow: auto; padding: 10px 14px 18px; }
.sheet-box table { border-collapse: collapse; font-size: 12.5px; }
.sheet-box td, .sheet-box th { border: 1px solid #e6ebf3; padding: 4px 8px; white-space: nowrap; color: #1f2937; }
.sheet-box tr:first-child td { background: #f7f9fc; font-weight: 600; }
.pv-fallback { text-align: center; padding: 40px 20px; color: #6b7789; }
.pv-fallback svg { margin-bottom: 10px; }
.pv-fallback p { margin: 6px 0 14px; font-size: 13px; }
.side-ver { text-align: right; font-size: 11px; color: #b6c0d0; padding: 6px 10px 2px; }

/* ============================================================================
   手机端适配：窗口宽度 ≤860px 时才生效，桌面端（>860px）样式完全不受影响。
   放在文件最末尾，确保能覆盖前面同优先级的桌面规则。
   ========================================================================= */
@media (max-width: 860px) {
  /* 移动浏览器地址栏收起/展开时，用动态视口高度避免底部被裁 */
  @supports (height: 100dvh) {
    html, body, .shell { height: 100dvh; }
  }

  .shell { grid-template-columns: 1fr; }
  /* 兜底：任何子元素算宽出错时也不出现整页左右晃 */
  html, body { overflow-x: hidden; }

  /* ---------- 侧栏改成「左侧抽屉」，由顶栏 ☰ 打开 ---------- */
  .side {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: 80vw; max-width: 320px; z-index: 85;
    transform: translateX(-100%);
    transition: transform .22s cubic-bezier(.32, .72, .35, 1);
    box-shadow: 12px 0 40px rgba(16, 24, 40, .16);
    padding: calc(14px + env(safe-area-inset-top)) 12px calc(14px + env(safe-area-inset-bottom));
  }
  .side.on { transform: none; }
  .side .brand { padding: 2px 6px 10px; }
  .side-title { padding: 8px 8px 4px; }
  .lib-item { padding: 11px 10px; font-size: 14px; border-radius: 10px; }
  .lib-item:active { background: #eef2fa; }
  .lib-hint { display: none; }
  .user-row { padding: 8px; }

  /* ---------- 顶栏 ---------- */
  .topbar { height: 52px; padding: 0 8px; gap: 6px; }
  .nav-btn {
    display: grid; place-items: center;
    width: 38px; height: 38px; flex: none;
    border-radius: 9px; color: #3c4a63; font-size: 17px; padding: 0;
  }
  .nav-btn:active { background: rgba(16, 24, 40, .07); }
  #btnMore { font-size: 20px; letter-spacing: 1px; padding-bottom: 7px; }
  .top-actions { display: none; }
  .crumbs { overflow-x: auto; overflow-y: hidden; white-space: nowrap; scrollbar-width: none; }
  .crumbs::-webkit-scrollbar { display: none; }
  .crumbs button { max-width: 44vw; padding: 5px 6px; }
  .crumbs b { padding: 5px 6px; }

  /* ---------- 统计：四等分，一行放下 ---------- */
  .stat-row { padding: 10px 12px 0; gap: 8px; }
  .stat { flex: 1 1 0; min-width: 0; padding: 8px 10px; border-radius: 10px; }
  .stat span { font-size: 11px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .stat b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

  /* ---------- 工具条：主按钮占满一行，搜索另起一行 ---------- */
  .toolbar {
    display: grid; grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px; padding: 10px 12px 8px;
  }
  .toolbar .spacer, #btnUploadDir, .hint-inline { display: none; }
  .toolbar .btn { padding: 11px 13px; border-radius: 10px; font-size: 14px; }
  #btnRefresh { padding: 11px 11px; border-color: var(--line); background: #fff; }
  .toolbar .search { grid-column: 1 / -1; width: 100%; }
  .search input { height: 38px; }

  .content { padding: 0 12px 18px; }
  .panel { border-radius: 12px; overflow: visible; }

  /* ---------- 文件列表：表格改成卡片行 ---------- */
  /* 关键：table/tbody 也必须脱离 table 布局，否则 table 会按内容算宽、把整页撑出横向滚动 */
  table.files, table.files tbody { display: block; width: 100%; }
  table.files thead { display: none; }
  table.files tbody tr {
    display: flex; flex-wrap: wrap; align-items: center;
    padding: 12px; border-bottom: 1px solid #f1f4f9;
  }
  table.files tbody tr:first-child { border-top-left-radius: 12px; border-top-right-radius: 12px; }
  table.files tbody tr:last-child { border-bottom: 0; border-bottom-left-radius: 12px; border-bottom-right-radius: 12px; }
  table.files tbody tr:active { background: #f7f9fd; }
  table.files td { display: block; padding: 0; border: 0; font-size: 14.5px; }
  table.files td:nth-child(1) { flex: 1 1 auto; min-width: 0; }
  /* 大小等信息收到名称下方，作为副标题 */
  table.files td:nth-child(2) {
    order: 5; flex: 0 0 100%; width: 100%;
    padding-left: 34px; margin-top: 3px;
    font-size: 11.5px; color: #98a2b3;
  }
  table.files td:nth-child(3), table.files td:nth-child(4) { display: none; }
  /* 文件夹没有大小，副标题整行不占位，行高更紧凑 */
  table.files tr[data-dir="1"] td:nth-child(2) { display: none; }
  table.files td:nth-child(5) { order: 3; flex: none; }
  .name-cell { gap: 12px; }
  .name-cell .label { font-size: 14.5px; }
  table.files .actions-cell { opacity: 1; gap: 0; }

  /* 文件行只留一个 ⋯，下载/版本/重命名/删除都在弹出菜单里 */
  table.files tr[data-path] .actions-cell button:not(.more-btn) { display: none; }
  .more-btn {
    display: grid; place-items: center;
    width: 38px; height: 38px; border-radius: 9px;
    font-size: 19px; color: #7a879c; padding: 0 0 5px;
  }
  .more-btn:active { background: rgba(16, 24, 40, .07); }

  /* 回收站行：恢复 / 彻底删除，做成小按钮便于点 */
  table.files tr[data-id] .actions-cell { gap: 6px; }
  table.files tr[data-id] .actions-cell button {
    font-size: 12.5px; padding: 7px 9px;
    border: 1px solid var(--line); border-radius: 8px;
  }

  .empty { padding: 56px 16px; }
  .empty h3 { font-size: 14.5px; }
  .empty p { font-size: 12.5px; }

  /* ---------- 上传进度贴底 ---------- */
  .tray {
    left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
    width: auto; border-radius: 14px;
  }
  .tray-body { max-height: 38vh; }

  /* ---------- 弹窗 ---------- */
  /* 弹窗改成「贴顶 + 限定在可见高度内」：
     手机软键盘弹出后，页面可点区域只剩上半屏，旧写法（top:9vh 且不限高）
     会让输入框落到键盘后面，看不到自己打的字。
     --vvh 由 app.js 用 visualViewport 实时更新为「真正能看见的高度」，
     内容超出时在卡片内部滚动，标题和输入框始终留在最上方。 */
  .modal {
    width: calc(100vw - 24px); max-width: 440px;
    top: 8px;
    /* 必须高于左侧抽屉（z-index:85），否则从抽屉里点「+ 新建资料库」时，
       弹窗会渲染在抽屉下面，输入框被抽屉挡住看不见。 */
    z-index: 92;
    max-height: calc(var(--vvh, 100vh) - 16px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .modal h3 { padding: 14px 16px 8px; position: sticky; top: 0; background: #fff; z-index: 1; }
  .modal .body { padding: 0 16px 14px; }
  .modal .field input, .modal .field select, .modal .field textarea { font-size: 16px; }
  .modal .foot { padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); }
  .modal .foot .btn { padding: 10px 16px; }

  /* ---------- 版本抽屉改为底部弹出 ---------- */
  .drawer {
    left: 0; right: 0; top: auto; bottom: 0;
    width: 100%; max-height: 76vh;
    border-left: 0; border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    box-shadow: 0 -12px 40px rgba(16, 24, 40, .16);
  }
  .drawer.on { transform: none; }
  .drawer-body { padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); }

  /* ---------- 预览层 ---------- */
  .pv-bar { padding: 8px 10px; gap: 6px; }
  #pvName { max-width: 38vw; font-size: 13.5px; }
  .pv-meta { display: none; }
  .pv-tools { gap: 4px; }
  .pv-tools .btn { padding: 7px 9px; font-size: 12px; }
  .pv-body { margin: 0; width: 100%; border-radius: 0; }
  .pv img.shot { max-width: 100%; max-height: 100%; border-radius: 0; box-shadow: none; }
  .pv .pv-text { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); font-size: 13px; }
  .pv .pv-md { padding: 18px 16px; font-size: 14px; }
  .docx-wrap { padding: 10px; }

  /* ---------- 登录页 ---------- */
  /* 旧写法是「高度 100% + 垂直居中」，手机键盘弹出时可见高度反复变化
     （100dvh 跟着变），卡片就上下来回跳。这里改成顶部对齐的自然文档流：
     卡片位置由固定 padding 决定，键盘弹出只让页面滚动，卡片本身不再移动。 */
  .login-wrap {
    display: block;
    height: auto;
    min-height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: calc(12vh + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
  }
  .login-card { margin: 0 auto; padding: 26px 20px 22px; border-radius: 14px; }
  .login-card .btn.primary { padding: 12px; font-size: 15px; }
  /* 16px 是移动浏览器的分界线：小于它，聚焦时会被自动放大，看起来像在跳 */
  .login-card input { font-size: 16px; height: 44px; }
  .login-card .field { margin-bottom: 14px; }

  /* ---------- 长按菜单：手指更容易点中 ---------- */
  .ctx-menu { min-width: 180px; padding: 8px; }
  .ctx-menu button { padding: 11px 10px; font-size: 14px; }

  .toast { bottom: calc(20px + env(safe-area-inset-bottom)); font-size: 13.5px; }
}
