/* 文件中心样式。设计：浅色、留白、蓝色主色；桌面三栏（侧栏/列表），手机自适应。 */
:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #1d2430;
  --text-2: #5b6575;
  --text-3: #8d96a5;
  --line: #e6e9ef;
  --line-2: #eef0f4;
  --hover: #f1f4f9;
  --primary: #1f4fd8;
  --primary-2: #3a66e6;
  --primary-soft: #e9efff;
  --danger: #d93a3a;
  --danger-soft: #fdeceb;
  --ok: #18915e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .18);
  --sidebar: 232px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); text-decoration: none; }
.ic { width: 18px; height: 18px; flex: none; }
.fi { width: 100%; height: 100%; }
.hidden { display: none !important; }
#app { height: 100%; }
#app.booting { visibility: hidden; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.icon { width: 36px; padding: 0; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon.sm { width: 30px; padding: 0; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100%; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 10% -10%, #dfe8ff 0, transparent 60%),
              radial-gradient(900px 500px at 110% 110%, #e3f3ff 0, transparent 55%), var(--bg);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--panel); border-radius: 16px; box-shadow: var(--shadow-lg);
  padding: 40px 32px 32px; text-align: center;
}
.login-logo {
  width: 56px; height: 56px; border-radius: 14px; margin: 0 auto 18px; display: grid; place-items: center;
  background: var(--primary); color: #fff;
}
.login-logo .ic { width: 28px; height: 28px; }
.login-card h1 { font-size: 22px; margin: 0 0 6px; font-weight: 650; }
.login-card p.sub { margin: 0 0 26px; color: var(--text-3); }
.field { position: relative; margin-bottom: 14px; }
.input {
  width: 100%; height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31, 79, 216, .12); }
.login-card .btn { width: 100%; height: 44px; font-size: 15px; border-radius: 10px; }
.form-error { color: var(--danger); min-height: 20px; margin: 4px 0 10px; font-size: 13px; }
.login-card .remember { color: var(--text-3); font-size: 12px; margin-top: 16px; }

/* ---------- 布局 ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; height: 100%; }
.sidebar {
  background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  padding: 16px 12px; gap: 4px; min-height: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 650; font-size: 16px; }
.brand-logo { width: 32px; height: 32px; border-radius: 9px; background: var(--primary); color: #fff; display: grid; place-items: center; }
.brand-logo .ic { width: 18px; height: 18px; }
.upload-btn { margin: 0 4px 14px; height: 40px; border-radius: 10px; font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 12px; border-radius: 8px; color: var(--text-2);
  border: 0; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-sep { height: 1px; background: var(--line-2); margin: 10px 8px; }
.nav-label { font-size: 12px; color: var(--text-3); padding: 6px 12px 4px; }
.sidebar-foot { margin-top: auto; padding: 12px 8px 4px; }
.storage-bar { height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; margin: 8px 0 6px; }
.storage-bar > i { display: block; height: 100%; background: var(--primary); border-radius: 3px; }
.storage-text { font-size: 12px; color: var(--text-3); }
.sidebar-actions { display: flex; gap: 4px; margin-top: 10px; }
.sidebar-actions .btn { flex: 1; color: var(--text-2); font-size: 13px; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.menu-btn { display: none; }
.search {
  flex: 1; max-width: 560px; position: relative; display: flex; align-items: center;
}
.search .ic { position: absolute; left: 12px; color: var(--text-3); pointer-events: none; }
.search input {
  width: 100%; height: 40px; border-radius: 10px; border: 1px solid transparent; background: var(--bg); padding: 0 36px 0 38px; outline: none;
}
.search input:focus { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31, 79, 216, .1); }
.search .clear { position: absolute; right: 6px; }
.topbar-right { margin-left: auto; display: flex; gap: 6px; align-items: center; }

.toolbar {
  display: flex; align-items: center; gap: 10px; padding: 14px 24px 10px; min-height: 60px; flex-wrap: wrap;
}
.crumbs { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; min-width: 0; font-size: 16px; }
.crumbs button {
  border: 0; background: none; padding: 4px 8px; border-radius: 6px; color: var(--text-2); max-width: 260px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.crumbs button:hover { background: var(--hover); color: var(--text); }
.crumbs button.cur { color: var(--text); font-weight: 650; }
.crumbs .sep { color: var(--text-3); }
.crumbs .sep .ic { width: 14px; height: 14px; }
.toolbar-right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; width: 34px; height: 32px; display: grid; place-items: center; color: var(--text-3); }
.seg button.on { background: var(--primary-soft); color: var(--primary); }
.sort-select { height: 34px; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 0 8px; color: var(--text-2); }

.selbar {
  display: flex; align-items: center; gap: 8px; margin: 0 24px 8px; padding: 8px 12px; background: var(--primary-soft);
  border-radius: 10px; color: var(--primary); flex-wrap: wrap;
}
.selbar .count { font-weight: 600; margin-right: 8px; }
.selbar .btn { background: #fff; border-color: transparent; }

.content { flex: 1; overflow: auto; padding: 4px 24px 40px; position: relative; }
.content.drag::after {
  content: '松开鼠标即可上传到当前文件夹'; position: fixed; inset: 12px; border: 2px dashed var(--primary); border-radius: 16px;
  background: rgba(233, 239, 255, .85); display: grid; place-items: center; font-size: 18px; color: var(--primary); font-weight: 600;
  z-index: 50; pointer-events: none;
}
.section-title { font-size: 13px; color: var(--text-3); margin: 12px 0 10px; }

/* 网格视图 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 14px; }
.card {
  position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  cursor: pointer; transition: box-shadow .15s, border-color .15s, transform .15s; user-select: none;
}
.card:hover { box-shadow: var(--shadow); border-color: #d6dbe4; }
.card.sel { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(31, 79, 216, .25); }
.card .thumb { aspect-ratio: 4 / 3; background: #f7f8fb; display: grid; place-items: center; overflow: hidden; }
.card .thumb .fi { width: 58px; height: 58px; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .thumb img.doc { object-fit: cover; object-position: top; border-bottom: 1px solid var(--line-2); }
.card .meta { padding: 9px 11px 10px; border-top: 1px solid var(--line-2); }
.card .name { font-size: 13px; line-height: 18px; height: 36px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-all; }
.card .sub { font-size: 12px; color: var(--text-3); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .check, .row .check {
  width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid #c4cbd6; background: rgba(255, 255, 255, .92);
  display: grid; place-items: center; color: transparent; padding: 0;
}
.card .check { position: absolute; top: 8px; left: 8px; opacity: 0; transition: opacity .12s; }
.card:hover .check, .card.sel .check, .selecting .card .check { opacity: 1; }
.card.sel .check, .row.sel .check { background: var(--primary); border-color: var(--primary); color: #fff; }
.check .ic { width: 14px; height: 14px; stroke-width: 3; }
.card .more { position: absolute; top: 6px; right: 6px; opacity: 0; background: rgba(255, 255, 255, .92); }
.card:hover .more { opacity: 1; }

/* 列表视图 */
.table { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.row {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) 160px 100px 44px; align-items: center; gap: 8px;
  padding: 0 12px; height: 52px; border-bottom: 1px solid var(--line-2); cursor: pointer; user-select: none;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: #fafbfd; }
.row.sel { background: var(--primary-soft); }
.row.head { height: 40px; color: var(--text-3); font-size: 12px; cursor: default; background: #fafbfc; }
.row.head:hover { background: #fafbfc; }
.row .nm { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row .nm .fi-wrap { width: 32px; height: 32px; flex: none; }
.row .nm .fi-wrap img { width: 32px; height: 32px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line-2); }
.row .nm .t { min-width: 0; }
.row .nm .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .nm .p { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .c { color: var(--text-2); font-size: 13px; white-space: nowrap; }
.row .more { opacity: .6; }
.row:hover .more { opacity: 1; }
.loc-link { color: var(--text-3); }
.loc-link:hover { color: var(--primary); text-decoration: underline; }

.empty { text-align: center; padding: 80px 20px; color: var(--text-3); }
.empty .big { width: 72px; height: 72px; margin: 0 auto 16px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); display: grid; place-items: center; color: var(--text-3); }
.empty .big .ic { width: 32px; height: 32px; }
.empty h3 { color: var(--text); font-weight: 600; margin: 0 0 6px; font-size: 16px; }
.empty .btn { margin-top: 16px; }
.loading { padding: 60px; text-align: center; color: var(--text-3); }
.spinner {
  width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%;
  animation: spin .8s linear infinite; margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.note { font-size: 12px; color: var(--text-3); margin: 10px 2px; }

/* ---------- 菜单 ---------- */
.menu {
  position: fixed; z-index: 200; min-width: 180px; background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-lg); padding: 6px; animation: pop .12s ease-out;
}
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 9px 10px; border-radius: 6px; text-align: left;
}
.menu button:hover { background: var(--hover); }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--line-2); margin: 5px 4px; }
@keyframes pop { from { opacity: 0; transform: scale(.97); } }

/* ---------- 对话框 ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(15, 20, 30, .42); z-index: 300; display: grid; place-items: center; padding: 20px;
  animation: fade .15s;
}
@keyframes fade { from { opacity: 0; } }
.dialog {
  width: 100%; max-width: 420px; background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); padding: 24px;
  animation: pop .15s ease-out; max-height: calc(100vh - 40px); display: flex; flex-direction: column;
}
.dialog.wide { max-width: 560px; }
.dialog h3 { margin: 0 0 8px; font-size: 17px; }
.dialog p { margin: 0 0 16px; color: var(--text-2); line-height: 1.6; word-break: break-all; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.dialog label { display: block; font-size: 13px; color: var(--text-2); margin: 10px 0 6px; }
.folder-tree { border: 1px solid var(--line); border-radius: 10px; overflow: auto; max-height: 340px; min-height: 160px; padding: 4px; }
.folder-tree button {
  display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: none; padding: 7px 8px; border-radius: 6px; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.folder-tree button:hover { background: var(--hover); }
.folder-tree button.on { background: var(--primary-soft); color: var(--primary); }
.folder-tree .fi-mini { width: 18px; height: 18px; flex: none; }

/* ---------- 上传面板 ---------- */
.uploads {
  position: fixed; right: 20px; bottom: 20px; width: 360px; max-width: calc(100vw - 24px); background: #fff; border-radius: 14px;
  box-shadow: var(--shadow-lg); z-index: 150; overflow: hidden; border: 1px solid var(--line);
}
.uploads .uh { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line-2); font-weight: 600; }
.uploads .uh .s { flex: 1; }
.uploads .ul { max-height: 280px; overflow: auto; }
.uploads.min .ul { display: none; }
.up-item { padding: 9px 14px; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.up-item:last-child { border-bottom: 0; }
.up-item .r { display: flex; justify-content: space-between; gap: 10px; }
.up-item .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-item .st { color: var(--text-3); white-space: nowrap; }
.up-item.err .st { color: var(--danger); }
.up-item.done .st { color: var(--ok); }
.up-item .bar { height: 4px; background: var(--line-2); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.up-item .bar i { display: block; height: 100%; background: var(--primary); width: 0; transition: width .2s; }
.up-item.done .bar, .up-item.err .bar { display: none; }

/* ---------- 提示 ---------- */
.toasts { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 500; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #1d2430; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13px;
  animation: pop .15s; max-width: 90vw;
}
.toast.err { background: var(--danger); }

/* ---------- 预览 ---------- */
.viewer { position: fixed; inset: 0; z-index: 400; background: #0f1218; display: flex; flex-direction: column; color: #e8ebf0; animation: fade .15s; }
.viewer .vh { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: rgba(0, 0, 0, .35); min-height: 56px; }
.viewer .vh .title { flex: 1; min-width: 0; }
.viewer .vh .title .n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer .vh .title .s { font-size: 12px; color: #9aa3b2; }
.viewer .btn { background: rgba(255, 255, 255, .08); border-color: transparent; color: #e8ebf0; }
.viewer .btn:hover { background: rgba(255, 255, 255, .16); }
.viewer .vb { flex: 1; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.viewer .nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%; z-index: 5;
  background: rgba(20, 24, 32, .55); box-shadow: 0 2px 10px rgba(0, 0, 0, .2);
}
.viewer .nav:hover { background: rgba(20, 24, 32, .75); }
.viewer .nav.l { left: 16px; }
.viewer .nav.r { right: 16px; }
.viewer .nav .ic { width: 22px; height: 22px; }
.viewer .img-stage { position: absolute; inset: 0; overflow: hidden; cursor: grab; touch-action: none; }
.viewer .img-stage.dragging { cursor: grabbing; }
.viewer .img-stage img {
  position: absolute; left: 50%; top: 50%; max-width: none; user-select: none; -webkit-user-drag: none;
  transform-origin: center; box-shadow: 0 10px 40px rgba(0, 0, 0, .4); background: #fff url() ;
}
.viewer .img-tools {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; padding: 6px;
  background: rgba(20, 24, 32, .85); border-radius: 12px; z-index: 5; align-items: center;
}
.viewer .img-tools .z { min-width: 54px; text-align: center; font-size: 13px; color: #c9cfd9; }
.viewer iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.viewer video { max-width: 100%; max-height: 100%; background: #000; }
.viewer audio { width: min(520px, 90vw); }
.viewer .msg { text-align: center; color: #aab2c0; padding: 30px; max-width: 520px; line-height: 1.7; }
.viewer .msg .fi-big { width: 96px; height: 96px; margin: 0 auto 18px; }
.viewer .msg h3 { color: #fff; font-weight: 600; margin: 0 0 6px; }
.viewer .msg .btn { margin-top: 18px; }
.viewer .spinner { border-color: rgba(255, 255, 255, .15); border-top-color: #fff; }
.viewer .text-view {
  width: 100%; height: 100%; overflow: auto; background: #fff; color: var(--text); padding: 28px max(24px, calc(50% - 440px));
}
.viewer .text-view pre { margin: 0; font: 13px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, "Noto Sans Mono CJK SC", monospace; white-space: pre-wrap; word-break: break-word; }
.md { font-size: 15px; line-height: 1.75; }
.md h1, .md h2, .md h3 { line-height: 1.35; margin: 1.4em 0 .6em; }
.md h1 { font-size: 1.8em; } .md h2 { font-size: 1.45em; border-bottom: 1px solid var(--line); padding-bottom: .3em; } .md h3 { font-size: 1.2em; }
.md code { background: #f1f3f7; padding: .15em .4em; border-radius: 4px; font-size: .9em; }
.md pre { background: #f6f8fa; padding: 14px; border-radius: 8px; overflow: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { margin: 0; padding: 0 1em; color: var(--text-2); border-left: 4px solid var(--line); }
.md table { border-collapse: collapse; } .md td, .md th { border: 1px solid var(--line); padding: 6px 12px; }
.md img { max-width: 100%; }

/* PDF 阅读器 */
.pdf-view { position: absolute; inset: 0; overflow: auto; background: #2a2f38; padding: 20px 0 80px; }
.pdf-view .page { margin: 0 auto 16px; background: #fff; box-shadow: 0 4px 24px rgba(0, 0, 0, .35); position: relative; }
.pdf-view .page canvas { display: block; width: 100%; height: 100%; }
.pdf-view .page .pn { position: absolute; bottom: -18px; right: 0; font-size: 11px; color: #8d96a5; }
.pdf-tools { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; padding: 6px; background: rgba(20, 24, 32, .9); border-radius: 12px; align-items: center; z-index: 5; }
.pdf-tools .pg { font-size: 13px; color: #c9cfd9; padding: 0 8px; white-space: nowrap; }
.pdf-tools .pg input { width: 44px; height: 28px; text-align: center; border-radius: 6px; border: 0; background: rgba(255, 255, 255, .12); color: #fff; }

/* 详情 */
.info-grid { display: grid; grid-template-columns: 80px 1fr; gap: 8px 12px; font-size: 13px; }
.info-grid .k { color: var(--text-3); }
.info-grid .v { word-break: break-all; }

/* ---------- 手机 ---------- */
.backdrop { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 270px; z-index: 250; transform: translateX(-100%); transition: transform .2s;
    box-shadow: var(--shadow-lg);
  }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .3); z-index: 240; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 12px; gap: 8px; }
  .topbar-right .label { display: none; }
  .toolbar { padding: 12px 12px 8px; }
  .selbar { margin: 0 12px 8px; }
  .content { padding: 4px 12px 90px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .row { grid-template-columns: 30px minmax(0, 1fr) 40px; }
  .row .c { display: none; }
  .card .check, .card .more { opacity: 1; }
  .viewer .nav { display: none; }
  .fab {
    position: fixed; right: 18px; bottom: 22px; width: 56px; height: 56px; border-radius: 50%; z-index: 120;
    box-shadow: 0 8px 24px rgba(31, 79, 216, .4);
  }
  .fab .ic { width: 24px; height: 24px; }
  .uploads { right: 12px; bottom: 90px; }
  .crumbs { font-size: 15px; }
}
@media (min-width: 861px) { .fab { display: none; } }
@media (max-width: 480px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .toolbar-right .sort-select { display: none; }
}
