/* ============================================================
   app.css — Cloud Drive 前端样式（深色 / 浅色双主题）
   ============================================================ */
:root {
  --bg: #0d1117;
  --bg2: #161b22;
  --bg3: #1c2129;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #2f81f7;
  --accent-h: #539bf5;
  --danger: #f85149;
  --danger-h: #ff6b66;
  --ok: #3fb950;
  --warn-bg: #3d2e00;
  --warn-border: #9e6a03;
  --warn-text: #e3b341;
  --hover-bg: #232932;
  --hover-border: #3f4650;
  --row-border: #21262d;
  --row-hover: #171d26;
  --pre-bg: #0a0d12;
  --overlay: rgba(1, 4, 9, .72);
  --shadow: 0 8px 30px rgba(0, 0, 0, .4);
  --radius: 10px;
  color-scheme: dark;
}

/* 浅色主题（html[data-theme="light"]） */
html[data-theme="light"] {
  --bg: #ffffff;
  --bg2: #f6f8fa;
  --bg3: #eff2f5;
  --border: #d0d7de;
  --text: #1f2328;
  --muted: #656d76;
  --accent: #0969da;
  --accent-h: #218bff;
  --danger: #cf222e;
  --danger-h: #a40e26;
  --ok: #1a7f37;
  --warn-bg: #fff8c5;
  --warn-border: #d4a72c;
  --warn-text: #7d4e00;
  --hover-bg: #f3f4f6;
  --hover-border: #afb8c1;
  --row-border: #eaeef2;
  --row-hover: #f6f8fa;
  --pre-bg: #f6f8fa;
  --overlay: rgba(31, 35, 40, .5);
  --shadow: 0 8px 24px rgba(31, 35, 40, .12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
  transition: background .2s, color .2s;
}
a { color: var(--accent-h); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--hover-bg); border-color: var(--hover-border); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-h); }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: rgba(248, 81, 73, .12); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
label.btn { margin: 0; }

/* ---------- 表单 ---------- */
input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
form.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
form.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; align-items: end; }
form.grid2 label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); }
.btn-row { display: flex; gap: 10px; align-items: center; }
.btn-row.wrap { flex-wrap: wrap; }
.form-error {
  margin-top: 10px; padding: 8px 12px;
  background: rgba(248, 81, 73, .12); border: 1px solid rgba(248, 81, 73, .4);
  color: var(--danger); border-radius: var(--radius); font-size: 13px;
}
.hint-box { margin-top: 12px; font-size: 13px; color: var(--muted); min-height: 20px; white-space: pre-wrap; }

/* ---------- 登录页 ---------- */
.center-view {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  width: 360px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 32px;
  text-align: center;
}
.login-card .brand { font-size: 44px; }
.login-card h1 { font-size: 22px; margin: 8px 0 4px; }
.login-card form { margin-top: 22px; display: flex; flex-direction: column; gap: 12px; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; justify-content: flex-start; align-items: center;
  gap: 18px;
  padding: 10px 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.logo { font-weight: 700; font-size: 15px; white-space: nowrap; }
.tabs { display: flex; gap: 4px; }
.tab {
  padding: 6px 14px; background: transparent; border: none; border-radius: 8px;
  color: var(--muted); font-size: 13.5px; cursor: pointer;
}
.tab:hover { color: var(--text); background: var(--bg3); }
.tab.active { color: var(--text); background: var(--bg3); }
.topbar-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }

/* ---------- 工具栏 / 面包屑 ---------- */
.tab-page { max-width: 1100px; margin: 0 auto; padding: 20px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.search-box { display: flex; gap: 6px; flex: 1 1 240px; min-width: 200px; align-items: center; }
.search-box input { max-width: 420px; }
#search-clear { flex: none; }
.search-group {
  background: var(--bg3); color: var(--muted);
  font-size: 12px; letter-spacing: .05em; padding: 5px 14px !important;
}
.search-path { user-select: none; }

.toolbar-actions { display: flex; gap: 10px; }
.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; font-size: 14px; min-height: 32px; }
.breadcrumb a { color: var(--accent-h); padding: 3px 7px; border-radius: 6px; cursor: pointer; }
.breadcrumb a:hover { background: var(--bg3); text-decoration: none; }
.breadcrumb .sep { color: var(--muted); }
.breadcrumb .current { padding: 3px 7px; font-weight: 600; }
.section-title { font-size: 17px; margin: 0; }

/* ---------- 文件表 ---------- */
.table-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.file-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.file-table th {
  text-align: left; padding: 10px 14px;
  background: var(--bg3); color: var(--muted);
  font-weight: 500; font-size: 12.5px;
  border-bottom: 1px solid var(--border);
}
.sort-btn { background: none; border: none; color: inherit; font: inherit; cursor: pointer; padding: 0; }
.sort-btn:hover { color: var(--text); }
.file-table td { padding: 9px 14px; border-bottom: 1px solid var(--row-border); vertical-align: middle; }
.file-table tbody tr:hover { background: var(--row-hover); }
.file-table tbody tr:last-child td { border-bottom: none; }
.fname { display: inline-flex; align-items: center; gap: 9px; max-width: 100%; cursor: pointer; color: var(--text); }
.fname:hover { color: var(--accent-h); }
.fname .icon { flex: none; }
.fname .name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty-row { text-align: center; color: var(--muted); padding: 40px 0 !important; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11.5px; border: 1px solid var(--border); color: var(--muted);
}
.badge.burn { border-color: var(--warn-border); color: var(--warn-text); background: var(--warn-bg); }

/* ---------- 上传进度 ---------- */
.upload-progress {
  margin-bottom: 14px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 8px;
}
.up-item { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.up-item .up-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-item .up-state { flex: none; width: 130px; text-align: right; color: var(--muted); }
.bar { flex: none; width: 160px; height: 6px; background: var(--bg3); border-radius: 4px; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.up-item.done .up-state { color: var(--ok); }
.up-item.failed .up-state { color: var(--danger); }

/* ---------- 卡片（管理区） ---------- */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}
.card h3 { margin: 0 0 6px; font-size: 15px; }
.card.center-narrow { max-width: 420px; margin: 40px auto; text-align: center; }
.card.center-narrow form { text-align: left; margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.admin-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.admin-grid .span2 { grid-column: span 2; }
@media (max-width: 800px) {
  .admin-grid { grid-template-columns: 1fr; }
  .admin-grid .span2 { grid-column: span 1; }
  form.grid2 { grid-template-columns: 1fr; }
}
.compliance { font-size: 13px; margin: 10px 0 14px; }
.compliance ul { margin: 0; padding-left: 18px; }
.compliance li { margin: 4px 0; }
.compliance .pass { color: var(--ok); }
.compliance .fail { color: var(--danger); }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: var(--overlay);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  width: 480px; max-width: 96vw;
  max-height: 88vh; overflow: auto;
}
.modal h3 { margin: 0 0 12px; font-size: 16px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.modal .field { margin: 12px 0; }
.modal .field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.modal pre {
  background: var(--pre-bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; font-size: 12.5px; max-height: 46vh; overflow: auto;
  white-space: pre-wrap; word-break: break-all;
}
.share-link-box {
  display: flex; gap: 8px; margin: 12px 0;
}
.share-link-box input { flex: 1; font-size: 12.5px; }
.radio-line { display: flex; align-items: center; gap: 8px; margin: 8px 0; cursor: pointer; }
.radio-line input { width: auto; }
.mv-list {
  display: flex; flex-wrap: wrap; gap: 6px; max-height: 180px; overflow: auto;
  border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin: 8px 0;
}
.mv-list a { color: var(--accent-h); font-size: 12.5px; padding: 3px 8px; border-radius: 6px; background: var(--bg3); }
.mv-list a:hover { text-decoration: none; background: var(--hover-bg); }
.qr-wrap { display: flex; justify-content: center; margin: 14px 0 4px; }
.qr-wrap svg, .qr-wrap img { background: #fff; border-radius: 8px; }
.burn-note {
  background: var(--warn-bg); border: 1px solid var(--warn-border);
  color: var(--warn-text); border-radius: 8px; padding: 8px 12px;
  font-size: 12.5px; margin: 10px 0;
}

/* ---------- 分享落地页 ---------- */
.share-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.share-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px;
  width: 420px; max-width: 94vw;
  text-align: center;
}
.share-icon { font-size: 42px; }
.share-name {
  font-size: 16px; margin: 10px 0 4px; word-break: break-all;
}
.share-actions { display: flex; justify-content: center; gap: 10px; margin: 18px 0 6px; flex-wrap: wrap; }
.share-card .banner { text-align: left; }
.share-preview {
  display: block; max-width: 100%; max-height: 62vh;
  margin: 0 auto 12px; border-radius: 12px;
  border: 1px solid var(--border);
  background: repeating-conic-gradient(var(--bg3) 0% 25%, transparent 0% 50%) 50% / 22px 22px;
}
.qr-box { margin-top: 18px; }
.qr-box img { background: #fff; border-radius: 10px; padding: 8px; }

/* ---------- 主题切换按钮 ---------- */
.theme-btn {
  background: transparent; border: 1px solid transparent; border-radius: 8px;
  font-size: 16px; line-height: 1; padding: 5px 8px; cursor: pointer;
  color: var(--muted);
}
.theme-btn:hover { color: var(--text); background: var(--bg3); }

/* ---------- 拖拽上传浮层 ---------- */
.dropzone-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: var(--overlay);
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.dropzone-overlay .dz-box {
  border: 3px dashed var(--accent);
  border-radius: 18px;
  background: var(--bg2);
  padding: 48px 72px;
  text-align: center;
  font-size: 18px;
  color: var(--accent);
  box-shadow: var(--shadow);
}
.dropzone-overlay .dz-box .dz-icon { font-size: 44px; display: block; margin-bottom: 10px; }

/* ---------- 分享批量管理 ---------- */
.col-check { width: 36px; text-align: center; }
.file-table:not(.batching) .col-check { display: none; }
.file-table.batching .col-check { display: table-cell; }
.share-check { width: auto; cursor: pointer; accent-color: var(--accent); }
#share-check-all { cursor: pointer; accent-color: var(--accent); }
.btn.active-batch { border-color: var(--accent); color: var(--accent-h); background: var(--bg3); }
.batch-bar {
  position: sticky; bottom: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 12px; padding: 10px 14px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow);
}

/* ---------- 行内操作：平铺按钮组（PC 分享页/移动端） + ⋯ 折叠菜单按钮 ---------- */
.more-btn { display: none; }
/* 文件列表：PC 与移动端统一折叠为单个 ⋯ 按钮，点击弹出全部操作 */
#tab-files .row-actions { display: none; }
#tab-files .more-btn { display: inline-flex; }
#tab-files .file-table td:last-child { text-align: right; white-space: nowrap; }
.action-pop {
  position: fixed; z-index: 400;
  min-width: 132px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  animation: popIn .12s ease-out;
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(4px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.action-pop .btn {
  display: flex; width: 100%; justify-content: flex-start; align-items: center;
  margin: 2px 0; background: transparent; border-color: transparent;
}
.action-pop .btn:hover { background: var(--hover-bg); border-color: transparent; }
.action-pop .btn.danger { color: var(--danger); }

/* ---------- Markdown 预览 / 弹窗工具条 ---------- */
.modal-toolbar { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.md-preview {
  max-height: 52vh; overflow: auto;
  background: var(--pre-bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 16px; font-size: 13.5px; line-height: 1.7; margin: 10px 0;
}
.md-preview h1, .md-preview h2, .md-preview h3, .md-preview h4, .md-preview h5, .md-preview h6 {
  margin: 14px 0 8px; line-height: 1.35;
}
.md-preview h1 { font-size: 20px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.md-preview h2 { font-size: 17px; border-bottom: 1px solid var(--border); padding-bottom: 5px; }
.md-preview h3 { font-size: 15px; }
.md-preview h4, .md-preview h5, .md-preview h6 { font-size: 13.5px; }
.md-preview p { margin: 8px 0; }
.md-preview ul, .md-preview ol { margin: 8px 0; padding-left: 26px; }
.md-preview li { margin: 3px 0; }
.md-preview blockquote {
  margin: 10px 0; padding: 6px 14px;
  border-left: 3px solid var(--accent); background: var(--bg3);
  border-radius: 0 8px 8px 0; color: var(--muted);
}
.md-preview code {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 5px;
  padding: 1px 6px; font-family: Consolas, monospace; font-size: 12.5px;
}
.md-preview pre.md-code {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; overflow: auto; font-size: 12.5px; line-height: 1.55; margin: 10px 0;
}
.md-preview pre.md-code code { background: transparent; border: none; padding: 0; }
.md-preview hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.md-preview table { border-collapse: collapse; margin: 10px 0; font-size: 12.5px; }
.md-preview th, .md-preview td { border: 1px solid var(--border); padding: 5px 10px; text-align: left; }
.md-preview th { background: var(--bg3); }
.md-preview img { max-width: 100%; border-radius: 8px; }

/* ---------- 通用提示 ---------- */
.banner {
  padding: 9px 13px; border-radius: 9px; font-size: 12.5px; margin: 0 0 12px;
}
.banner.warn { background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn-text); }
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  z-index: 200;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px; border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 13px;
  max-width: 80vw;
}
.toast.err { border-color: var(--danger); color: var(--danger); }
.toast.ok { border-color: var(--ok); color: var(--ok); }

/* ---------- 移动端适配 ---------- */
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 6px 12px; padding: 8px 12px; }
  /* 第 1 行：logo + 主题/退出；第 2 行：标签横滑条 */
  .topbar-right { order: 2; margin-left: auto; gap: 8px; }
  #storage-hint { display: none; }
  .tabs {
    order: 3; flex-basis: 100%;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; scroll-snap-type: x proximity;
    justify-content: flex-start;
    justify-content: safe center; /* 页面标签整体居中（内容放不下时自动回退左对齐） */
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; flex: 0 0 auto; scroll-snap-align: center; padding: 8px 14px; }
  .tab.active { outline: 2px solid var(--border); outline-offset: -2px; }

  .tab-page { padding: 12px; }
  .toolbar { flex-direction: column; align-items: stretch; gap: 8px; margin-bottom: 10px; }
  .search-box input { max-width: none; flex: 1; }
  .toolbar-actions { flex-wrap: wrap; gap: 8px; }
  .toolbar-actions .btn { flex: 1 1 auto; justify-content: center; }
  /* 面包屑长路径横向滑动 */
  .breadcrumb { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .breadcrumb::-webkit-scrollbar { display: none; }
  .breadcrumb a, .breadcrumb .current { white-space: nowrap; }

  .file-table { font-size: 13px; }
  /* 文件表（tab-files）：隐藏 大小/修改时间 两列 */
  #tab-files .file-table th:nth-child(2), #tab-files .file-table td:nth-child(2),
  #tab-files .file-table th:nth-child(3), #tab-files .file-table td:nth-child(3) { display: none; }
  /* 分享管理表：隐藏 下载次数/创建时间 两列 */
  #tab-shares .file-table th:nth-child(4), #tab-shares .file-table td:nth-child(4),
  #tab-shares .file-table th:nth-child(5), #tab-shares .file-table td:nth-child(5) { display: none; }
  .file-table th, .file-table td { padding: 8px 10px; }
  .file-table td:first-child .name-text { word-break: break-all; }
  /* 操作列：分享表在移动端同样折叠为单个 ⋯ 按钮（文件表全局已折叠） */
  #tab-shares .row-actions { display: none; }
  #tab-shares .more-btn { display: inline-flex; }

  /* 分享管理：文件卡片内长名称/长路径横向滑动，不再挤压换行 */
  #tab-shares .file-table { table-layout: fixed; }
  #tab-shares .file-table th:nth-child(3), #tab-shares .file-table td:nth-child(3) { width: 76px; }
  #tab-shares .file-table th:nth-child(6), #tab-shares .file-table td:nth-child(6) { width: 52px; }
  #tab-shares .share-file-cell { overflow: hidden; }
  #tab-shares .share-file-scroll {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: thin; padding-bottom: 2px;
  }
  #tab-shares .share-file-scroll::-webkit-scrollbar { height: 4px; }
  #tab-shares .share-file-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
  #tab-shares .share-file-scroll .fname { max-width: none; }
  #tab-shares .share-file-scroll .name-text,
  #tab-shares .share-file-scroll .path-line { white-space: nowrap; word-break: normal; }

  .modal { width: 94vw; padding: 16px; }
  .modal pre { max-height: 38vh; }
  .share-card { padding: 24px 16px; }
  .login-card { padding: 28px 20px; }
  .toast { max-width: 92vw; }
  .dropzone-overlay .dz-box { padding: 32px 40px; font-size: 15px; }
}
