:root{
  --bg:#f5f6f8;
  --card:#ffffff;
  --text:#111827;
  --muted:#6b7280;
  --line:#e5e7eb;
  --primary:#2563eb;
  --danger:#dc2626;
  --shadow: 0 10px 30px rgba(17,24,39,0.08);
}
*{ box-sizing:border-box; }
body{ margin:0; font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial; color:var(--text); background:var(--bg); }
a{ color:inherit; text-decoration:none; }
body.noscroll{ overflow:hidden; }

/* Login */
.bg{ display:flex; min-height:100vh; align-items:center; justify-content:center; }
.card{
  width:min(420px,92vw);
  background:var(--card);
  border:1px solid var(--line);
  padding:24px;
  border-radius:16px;
  box-shadow:var(--shadow);
}
.card h2{ margin:0 0 6px; }
.muted{ margin:0 0 14px; color:var(--muted); }
input{
  width:100%;
  padding:12px;
  border-radius:12px;
  border:1px solid var(--line);
  background:#fff;
  color:var(--text);
  outline:none;
}
input:focus{ border-color:#bfdbfe; box-shadow:0 0 0 4px rgba(37,99,235,0.15); }
button{ cursor:pointer; }
.error{ color:var(--danger); margin-top:10px; min-height:18px; }

/* Buttons */
.btn{
  display:inline-flex; align-items:center; justify-content:center;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  background:var(--card);
  color:var(--text);
  font-weight:900;
}
.btn.primary{ background:var(--primary); color:white; border-color:rgba(37,99,235,0.4); }
.btn.ghost{ background:transparent; }
.btn.mini{ padding:8px 10px; font-size:12px; border-radius:10px; }
.btn.danger{ background:#fee2e2; border-color:#fecaca; color:#991b1b; }

/* Selection bar (drive-like) */
.selbar{
  position:sticky; top:0;
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 12px;
  background:#fff;
  border-bottom:1px solid var(--line);
  z-index:50;
}
.selbar.hidden{ display:none; }
.sel-left{ display:flex; align-items:center; gap:10px; }
.sel-count{ font-weight:900; }
.sel-actions{ display:flex; gap:8px; }
.iconbtn{
  width:44px; height:36px;
  border-radius:12px;
  border:1px solid var(--line);
  background:#fff;
  font-weight:900;
}
.iconbtn.danger{ background:#fee2e2; border-color:#fecaca; color:#991b1b; }

/* Topbar */
.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 18px;
  border-bottom:1px solid var(--line);
  position:sticky; top:0;
  background:rgba(245,246,248,0.9);
  backdrop-filter: blur(10px);
  z-index:40;
}
.brand{ display:flex; align-items:center; gap:10px; }
.logo{ width:34px; height:34px; display:flex; align-items:center; justify-content:center; border-radius:10px; background:#eef2ff; }
.title{ font-size:18px; font-weight:900; }
.crumbs{ margin-top:2px; font-size:12px; color:var(--muted); }
.crumbs a{ color:var(--primary); font-weight:900; }
.crumbs .sep{ margin:0 6px; color:#9ca3af; }
.actions{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; }

/* Layout */
.layout{ display:grid; grid-template-columns: 280px 1fr; gap:18px; padding:18px; }
.sidebar{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:16px;
  padding:14px;
  box-shadow:var(--shadow);
  height: calc(100vh - 88px);
  position: sticky; top: 74px;
  overflow:auto;
}

/* Sidebar / Nav (match screenshots) */
.nav-root{
  width:100%;
  display:flex;
  align-items:center;
  gap:10px;
  padding:12px 12px;
  border-radius:999px;
  border:1px solid transparent;
  background:#e0efff;
  color:#0f172a;
  font-weight:900;
}
.nav-root:hover{ filter:brightness(0.98); }
.nav-root[aria-expanded="false"] .nav-caret{ transform: rotate(-90deg); }
.nav-caret{ width:18px; display:inline-flex; justify-content:center; transition:transform .15s ease; color:#334155; }
.nav-home{ width:22px; display:inline-flex; justify-content:center; color:#334155; }
.nav-text{ flex:1; text-align:left; }

.nav-section{ margin-top:10px; }
.nav-section.collapsed{ display:none; }

/* Folder tree can be collapsed independently (filters remain visible) */
.tree-wrap.collapsed{ display:none; }
.nav-filters{ display:flex; flex-direction:column; gap:4px; margin-bottom:10px; }

.side-title{ font-weight:900; margin:12px 6px 10px; color:#111827; }
.side-title.mt{ margin-top:16px; }
.side-item{
  width:100%;
  display:flex; gap:10px; align-items:center;
  padding:10px 10px;
  border-radius:12px;
  border:1px solid transparent;
  background:transparent;
  font-weight:900;
  color:#111827;
  text-align:left;
}
.side-item .ni{ width:22px; display:inline-flex; justify-content:center; color:#64748b; }
.side-item:hover{ background:#f3f4f6; }
.side-item.active{ background:#eef2ff; border-color:#e0e7ff; }

.tree{ margin-bottom:10px; }
.tn{
  display:flex; align-items:center; gap:8px;
  padding:8px 10px;
  border-radius:12px;
  cursor:pointer;
}
.tcaret{ width:14px; text-align:center; color:#64748b; user-select:none; }
.tcaret.spacer{ opacity:0; }
.tchildren.collapsed{ display:none; }
.tn:hover{ background:#f3f4f6; }
.tn.active{ background:#eef2ff; border:1px solid #e0e7ff; }
.ticon{ width:20px; text-align:center; }
.tname{ font-weight:900; font-size:13px; }

.dropzone{
  margin-top:10px;
  border:1px dashed #cbd5e1;
  border-radius:14px;
  padding:14px;
  background:#f8fafc;
}
.dropzone.drag{ outline:2px solid #93c5fd; }
.dz-big{ font-weight:900; }
.dz-small{ margin-top:6px; color:var(--muted); font-size:12px; }

/* Storage space card */
.space-card{
  margin-top:14px;
  background:var(--card);
  border:1px solid var(--line);
  border-radius:18px;
  padding:14px;
  box-shadow:var(--shadow);
}
.space-title{ font-weight:900; }
.space-bar{
  margin-top:10px;
  height:12px;
  background:#e5e7eb;
  border-radius:999px;
  overflow:hidden;
}
.space-bar-fill{
  height:100%;
  background:#cbd5e1;
  border-radius:999px;
  transition:width .25s ease;
}
.space-text{ margin-top:10px; color:#334155; font-weight:900; }

.content{ min-height:60vh; }
.grid-head{ display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:12px; }
.search{ flex:1; }
.hint{ color:var(--muted); font-size:12px; }

.section{ margin-bottom:18px; }
.section-title{ font-weight:900; margin:4px 2px 10px; }

.grid{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap:14px;
}
.grid.folders{ grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

/* Items (no per-card actions) */
.item{
  position:relative;
  background:var(--card);
  border:1px solid var(--line);
  border-radius:16px;
  padding:14px;
  box-shadow:var(--shadow);
  cursor:default;
}
.item.drop{ outline:2px solid #93c5fd; }
.item-top{ display:flex; gap:12px; align-items:center; }
.item-icon{
  width:44px; height:44px;
  border-radius:14px;
  display:flex; align-items:center; justify-content:center;
  background:#f3f4f6;
  font-size:20px;
}
.item-name{
  font-weight:900;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.item-meta{
  margin-top:10px;
  display:flex; justify-content:space-between;
  color:var(--muted);
  font-size:12px;
}

/* checkbox */
.check{
  position:absolute;
  left:10px; top:10px;
  width:22px; height:22px;
  border-radius:999px;
  border:2px solid #cbd5e1;
  background:#fff;
}
.check.on{
  border-color: var(--primary);
  background: var(--primary);
}
.check.on::after{
  content:"✓";
  position:absolute;
  color:#fff;
  left:6px; top:1px;
  font-size:14px;
  font-weight:900;
}

.thumb{
  margin-top:12px;
  width:100%;
  height:180px;
  object-fit:cover;
  border-radius:14px;
  border:1px solid var(--line);
  background:#fff;
}

/* Upload panel (single card; multiple files inside) */
.upload-panel{
  position:fixed; right:14px; bottom:14px;
  width:min(420px, 94vw);
  background:var(--card);
  border:1px solid var(--line);
  border-radius:16px;
  box-shadow:var(--shadow);
  z-index:80;
  overflow:hidden;
}
.upload-panel.hidden{ display:none; }
.upload-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 12px;
  border-bottom:1px solid var(--line);
  background:linear-gradient(180deg,#fff, #fafafa);
}
.upload-title{ display:flex; gap:8px; align-items:center; font-weight:900; }
.upload-title .dot{
  width:10px; height:10px; border-radius:999px;
  background:var(--primary);
  box-shadow:0 0 0 4px rgba(99,102,241,0.12);
}
.upload-actions{ display:flex; gap:8px; }
.uicon{
  width:30px; height:30px;
  border:1px solid var(--line);
  border-radius:10px;
  background:#fff;
  font-weight:900;
}
.uicon:hover{ background:#f3f4f6; }

.upload-body{ max-height: 46vh; overflow:auto; padding:10px 12px; display:flex; flex-direction:column; gap:10px; }
.urow{ border:1px solid var(--line); border-radius:14px; padding:10px; background:#fff; }
.urow-top{ display:flex; align-items:flex-start; justify-content:space-between; gap:10px; }
.urow-name{ font-weight:900; font-size:13px; line-height:1.25; word-break:break-all; }
.urow-meta{ color:var(--muted); font-size:12px; margin-top:4px; }
.urow-actions{ display:flex; gap:8px; align-items:center; }
.urow-del{
  border:1px solid var(--line);
  background:#fff;
  border-radius:10px;
  padding:6px 10px;
  font-weight:900;
  color:#991b1b;
}
.urow-del:hover{ background:#fef2f2; border-color:#fecaca; }
.ubar{ margin-top:8px; height:10px; background:#f3f4f6; border:1px solid var(--line); border-radius:999px; overflow:hidden; }
.ubar > div{ height:100%; width:0%; background:var(--primary); transition:width .15s ease; }

.upload-mini{
  position:fixed; right:14px; bottom:14px;
  display:flex; align-items:center; gap:8px;
  padding:10px 12px;
  border-radius:999px;
  border:1px solid var(--line);
  background:#fff;
  box-shadow:var(--shadow);
  z-index:81;
  font-weight:900;
}
.upload-mini.hidden{ display:none; }
.upload-mini .mini-dot{ width:10px; height:10px; border-radius:999px; background:var(--primary); }
.upload-mini:hover{ background:#f3f4f6; }

/* Context menu */
.ctx{
  position:fixed;
  background:#fff;
  border:1px solid var(--line);
  border-radius:14px;
  box-shadow:var(--shadow);
  padding:8px;
  width:220px;
  z-index:100;
}
.ctx.hidden{ display:none; }
.ctx button{
  width:100%;
  padding:10px 10px;
  border:0;
  background:transparent;
  border-radius:10px;
  text-align:left;
  font-weight:900;
}
.ctx button:hover{ background:#f3f4f6; }
.ctx button.danger{ color:#991b1b; }
.ctx-line{ height:1px; background:var(--line); margin:6px 0; }

/* Modal */
.modal{ position:fixed; inset:0; z-index:120; display:flex; align-items:center; justify-content:center; }
.modal.hidden{ display:none; }
.modal-backdrop{ position:absolute; inset:0; background:rgba(17,24,39,0.65); }
.modal-card{
  position:relative;
  width:min(1100px, 94vw);
  max-height: 92vh;
  background:#fff;
  border-radius:18px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.35);
  overflow:hidden;
}
.modal-top{
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 14px;
  border-bottom:1px solid var(--line);
}
.modal-title{ font-weight:900; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.modal-actions{ display:flex; gap:8px; align-items:center; }
.modal-body{ padding:14px; overflow:auto; max-height: calc(92vh - 56px); }
.modal-img{ max-width:100%; height:auto; display:block; margin:auto; border-radius:14px; }
.modal-media{ width:100%; border-radius:14px; background:#000; }
.modal-frame{ width:100%; height:78vh; border:0; border-radius:14px; background:#fff; }

/* TXT editor */
.txt-editor{
  width:100%;
  height:78vh;
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size:14px;
  outline:none;
}

.empty{ color:var(--muted); padding:20px; }

@media (max-width: 900px){
  .layout{ grid-template-columns: 1fr; }
  .sidebar{ position:relative; top:auto; height:auto; }
}


/* Dialog + Toast (replace system alert/prompt/confirm) */
.dialog{ position:fixed; inset:0; z-index:140; display:flex; align-items:center; justify-content:center; }
.dialog.hidden{ display:none; }
.dialog-backdrop{ position:absolute; inset:0; background:rgba(17,24,39,0.55); }
.dialog-card{
  position:relative;
  width:min(520px, 94vw);
  max-height: 86vh;
  background:#fff;
  border-radius:18px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.28);
  overflow:hidden;
  display:flex;
  flex-direction:column;
}
.dialog-top{ display:flex; align-items:center; justify-content:space-between; padding:12px 14px; border-bottom:1px solid var(--line); }
.dialog-title{ font-weight:900; }
.dialog-body{ padding:14px; overflow:auto; }
.dialog-foot{ padding:12px 14px; border-top:1px solid var(--line); display:flex; gap:10px; justify-content:flex-end; flex-wrap:wrap; }
.dialog-row{ display:flex; flex-direction:column; gap:8px; margin-bottom:12px; }
.dialog-row label{ font-size:12px; color:var(--muted); }
.dialog-actions-left{ margin-right:auto; display:flex; gap:10px; align-items:center; color:var(--muted); font-size:12px; }
.toast-wrap{ position:fixed; right:16px; bottom:16px; z-index:160; display:flex; flex-direction:column; gap:10px; }
.toast{
  background:#111827;
  color:#fff;
  border-radius:14px;
  padding:10px 12px;
  min-width: 220px;
  max-width: 360px;
  box-shadow: var(--shadow);
  opacity:0.98;
  display:flex;
  gap:10px;
  align-items:flex-start;
}
.toast .tmsg{ font-size:13px; line-height:1.4; }
.toast .tclose{ margin-left:auto; background:transparent; border:none; color:#fff; font-size:14px; cursor:pointer; }
.folder-picker{ border:1px solid var(--line); border-radius:14px; padding:10px; max-height: 48vh; overflow:auto; background:#fafafa; }
.fp-item{ display:flex; align-items:center; gap:8px; padding:8px 10px; border-radius:12px; cursor:pointer; }
.fp-item:hover{ background:#fff; }
.fp-item.active{ background:#e0ecff; }
.fp-caret{ width:18px; text-align:center; color:var(--muted); }
.fp-name{ font-weight:700; }


/* Hide drag-upload block on sidebar */
.side-title.mt{display:none !important;}
#dropZone{display:none !important;}

/* Hide "我的文件" text in breadcrumb root, keep clickable icon */
.crumbs a.home-link .home-text{display:none !important;}
