:root {
  --primary: #3d7fff;
  --primary-dark: #2f6ae0;
  --bg: #f5f7fb;
  --sidebar-bg: #ffffff;
  --topbar-bg: #ffffff;
  --border: #e6e9f0;
  --text: #2b3444;
  --text-muted: #8a94a6;
  --danger: #e5484d;
  --shadow: 0 2px 12px rgba(40, 60, 120, 0.06);
  --radius: 12px;
  --font: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ===== Topbar ===== */
.topbar {
  height: 60px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: relative;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-text h1 { font-size: 18px; font-weight: 700; display: flex; align-items: baseline; gap: 8px; }
.brand-sub { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.brand-logo { display: flex; }

.top-actions { display: flex; align-items: center; gap: 12px; }

.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  height: 38px;
  width: 300px;
  color: var(--text-muted);
}
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(61, 127, 255, 0.12); }
.search-box input { border: none; outline: none; background: transparent; flex: 1; font-size: 14px; color: var(--text); }
.clear-search { border: none; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 12px; padding: 2px; }

.btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3d7fff, #7b5cff);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; cursor: pointer; user-select: none;
}

/* ===== Layout ===== */
.layout { display: flex; height: calc(100vh - 60px); }

.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 16px 12px;
  flex-shrink: 0;
}
.side-nav { flex: 1; }
.nav-item {
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  margin-bottom: 4px;
  display: flex; align-items: center; gap: 10px;
  transition: background 0.15s;
}
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: rgba(61, 127, 255, 0.1); color: var(--primary); font-weight: 600; }

.storage { border-top: 1px solid var(--border); padding: 16px 8px 8px; }
.storage-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.storage-bar { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.storage-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #7b5cff); border-radius: 3px; transition: width 0.4s; }
.storage-used { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

.content { flex: 1; overflow-y: auto; padding: 20px 24px; background: var(--bg); }
.content-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }

.breadcrumb { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.crumb-item {
  border: none; background: transparent; color: var(--text-muted);
  cursor: pointer; font-size: 14px; padding: 4px 8px; border-radius: 6px;
}
.crumb-item:hover { color: var(--text); background: rgba(0,0,0,0.04); }
.crumb-item.current { color: var(--text); font-weight: 600; }
.crumb-sep { color: var(--text-muted); font-size: 12px; }

.view-toggle { display: flex; gap: 4px; }
.toggle-btn {
  border: 1px solid var(--border); background: #fff; color: var(--text-muted);
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.toggle-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ===== Selection bar ===== */
.selection-bar {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 16px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.spacer { flex: 1; }
.sel-action {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.sel-action:hover { background: var(--bg); }
.sel-action.danger { color: var(--danger); border-color: rgba(229, 72, 77, 0.4); }
.sel-action.danger:hover { background: rgba(229, 72, 77, 0.06); }

/* ===== Empty state ===== */
.empty-state { text-align: center; padding: 80px 20px; color: var(--text-muted); }
.empty-icon { font-size: 60px; margin-bottom: 12px; }

/* ===== File grid ===== */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}
.grid-item {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 12px; cursor: pointer; transition: box-shadow 0.15s, transform 0.15s;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  position: relative;
}
.grid-item:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.grid-item.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(61, 127, 255, 0.25); }
.grid-item.folder .grid-icon { color: #ffb020; }
.grid-check {
  position: absolute; top: 10px; left: 10px;
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border); background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: transparent;
}
.grid-item.selected .grid-check { background: var(--primary); border-color: var(--primary); color: #fff; }
.grid-icon { font-size: 46px; line-height: 1; }
.grid-name {
  font-size: 13px; text-align: center; width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  word-break: break-all;
}
.grid-meta { font-size: 12px; color: var(--text-muted); }

/* ===== File list ===== */
.file-list {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.list-row { display: flex; align-items: center; gap: 14px; padding: 12px 18px; cursor: pointer; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--bg); }
.list-row.selected { background: rgba(61, 127, 255, 0.08); }
.list-check { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border); background: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; color: transparent; flex-shrink: 0; }
.list-row.selected .list-check { background: var(--primary); border-color: var(--primary); color: #fff; }
.list-icon { font-size: 22px; flex-shrink: 0; }
.list-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-meta { width: 90px; text-align: right; color: var(--text-muted); font-size: 13px; }
.list-meta.wide { width: 150px; }

/* ===== Modals ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20, 30, 50, 0.5); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: #fff; border-radius: 16px; width: 480px; max-width: 92vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2); overflow: hidden;
}
.modal.small { width: 380px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-close { border: none; background: transparent; font-size: 16px; color: var(--text-muted); cursor: pointer; padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--border); }
.modal-body input[type="text"] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; outline: none;
}
.modal-body input[type="text"]:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(61,127,255,0.12); }

.drop-zone {
  margin: 20px; border: 2px dashed var(--border); border-radius: 12px;
  padding: 36px; text-align: center; color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  transition: border-color 0.15s, background 0.15s;
}
.drop-zone.dragover { border-color: var(--primary); background: rgba(61,127,255,0.05); }
.drop-icon { font-size: 40px; }

.up-list { max-height: 200px; overflow-y: auto; padding: 0 20px; }
.up-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.up-item .up-status { margin-left: auto; font-size: 12px; }
.up-item.done .up-status { color: #22a06b; }
.up-item.error .up-status { color: var(--danger); }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #2b3444; color: #fff; padding: 12px 20px; border-radius: 10px;
  font-size: 14px; z-index: 200; opacity: 0; transition: opacity 0.25s;
  pointer-events: none; box-shadow: 0 8px 30px rgba(0,0,0,0.25);
}
.toast.show { opacity: 1; }

/* ===== Context menu ===== */
.context-menu {
  position: fixed; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  padding: 6px; z-index: 300; min-width: 150px;
}
.cm-item { padding: 9px 14px; border-radius: 7px; cursor: pointer; font-size: 13px; display: flex; gap: 8px; }
.cm-item:hover { background: var(--bg); }
.cm-item.danger { color: var(--danger); }

/* ===== Preview ===== */
.modal.preview { width: 560px; }
.preview-body { padding: 20px; min-height: 200px; display: flex; align-items: center; justify-content: center; }
.preview-body pre-word { white-space: pre-wrap; word-break: break-all; font-size: 13px; color: var(--text); }
.preview-body img { max-width: 100%; max-height: 60vh; border-radius: 8px; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cfd6e3; border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #b9c2d4; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .search-box { width: 140px; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .list-meta.wide { display: none; }
  .topbar { padding: 0 12px; }
  .content { padding: 16px; }
}
