/* ============ 主题变量 ============ */
:root {
  --bg: #f3f4f8;
  --bg-grad: radial-gradient(1100px 600px at 15% -10%, rgba(99, 102, 241, .14), transparent 60%),
             radial-gradient(900px 500px at 110% 0%, rgba(168, 85, 247, .12), transparent 55%);
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --surface-glass: rgba(255, 255, 255, .78);
  --text: #17181c;
  --muted: #71717a;
  --border: #e7e8ef;
  --border-strong: #d7d9e2;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-soft: rgba(99, 102, 241, .12);
  --accent-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --danger: #e11d48;
  --danger-soft: #fff1f2;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --shadow-sm: 0 1px 2px rgba(16, 18, 27, .05);
  --shadow: 0 1px 3px rgba(16, 18, 27, .05), 0 6px 20px rgba(16, 18, 27, .06);
  --shadow-lg: 0 24px 70px rgba(16, 18, 27, .16);
  --ring: rgba(99, 102, 241, .20);
  --radius: 14px;
  --radius-sm: 9px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #0b0d11;
  --bg-grad: radial-gradient(1100px 600px at 15% -10%, rgba(99, 102, 241, .16), transparent 60%),
             radial-gradient(900px 500px at 110% 0%, rgba(168, 85, 247, .14), transparent 55%);
  --surface: #14171e;
  --surface-2: #1b1f28;
  --surface-glass: rgba(20, 23, 30, .72);
  --text: #e8eaf0;
  --muted: #8b919c;
  --border: #262b36;
  --border-strong: #343b49;
  --accent: #818cf8;
  --accent-hover: #6366f1;
  --accent-soft: rgba(99, 102, 241, .18);
  --accent-grad: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  --danger: #fb7185;
  --danger-soft: rgba(225, 29, 72, .16);
  --success: #4ade80;
  --success-soft: rgba(22, 163, 74, .16);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 8px 26px rgba(0, 0, 0, .4);
  --shadow-lg: 0 28px 80px rgba(0, 0, 0, .6);
  --ring: rgba(129, 140, 248, .32);
}

/* ============ 基础 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .25s ease, color .25s ease;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ============ 主题切换按钮 ============ */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-glass);
  color: var(--muted);
  cursor: pointer;
  transition: color .18s, border-color .18s, background .18s, transform .12s;
  backdrop-filter: saturate(180%) blur(10px);
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }
.theme-toggle:active { transform: scale(.94); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
.theme-toggle.fixed { position: fixed; top: 20px; right: 20px; z-index: 50; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: 10px;
  padding: 10px 18px; font-size: 14px; font-weight: 550; cursor: pointer;
  font-family: inherit; line-height: 1.2; white-space: nowrap;
  transition: transform .12s, box-shadow .18s, background .18s, border-color .18s, color .18s;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent-grad); color: #fff;
  box-shadow: 0 6px 18px rgba(99, 102, 241, .28);
}
.btn-primary:hover { color: #fff; filter: brightness(1.05); box-shadow: 0 8px 22px rgba(99, 102, 241, .36); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 13px; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; }
.linkbtn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; font-family: inherit; }
.linkbtn:hover { color: var(--text); }

/* ============ 输入框 ============ */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 7px; }
.input {
  width: 100%; border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 14px; font-size: 15px; font-family: inherit; color: var(--text);
  background: var(--surface-2);
  transition: border-color .16s, box-shadow .16s, background .16s;
}
.input::placeholder { color: var(--muted); opacity: .7; }
.input:hover { border-color: var(--border-strong); }
.input:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 4px var(--ring); }
.input-sm { padding: 8px 11px; font-size: 13px; width: auto; }
label.inline-label { display: inline-block; margin: 0; }
.inline-form { display: inline; }
.inline-row { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }

/* ============ 悬浮通知 toast ============ */
.toast-wrap {
  position: fixed; top: 84px; left: 20px; z-index: 2000;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.toast {
  min-width: 200px; max-width: 340px;
  padding: 12px 16px; border-radius: 10px; font-size: 14px;
  border: 1px solid transparent;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .14);
  pointer-events: auto;
  animation: toast-in .28s cubic-bezier(.21, 1.02, .73, 1);
  transition: opacity .35s ease, transform .35s ease;
}
.toast.hide { opacity: 0; transform: translateX(-24px); }
.toast.success { background: var(--success-soft); color: var(--success); border-color: rgba(22, 163, 74, .2); }
.toast.error { background: var(--danger-soft); color: var(--danger); border-color: rgba(225, 29, 72, .2); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-24px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ============ 认证页 ============ */
.auth-body {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  position: relative;
}
.auth-card {
  width: 100%; max-width: 410px;
  background: var(--surface-glass);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 42px 38px 38px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: saturate(180%) blur(22px);
  animation: rise .5s cubic-bezier(.22, .9, .3, 1) both;
}
.auth-head { text-align: center; margin-bottom: 26px; }
.auth-logo {
  width: 54px; height: 54px; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 16px; background: var(--accent-grad); color: #fff;
  box-shadow: 0 10px 26px rgba(99, 102, 241, .35);
}
.auth-logo .logo-glyph { width: 26px; height: 26px; }
.auth-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.auth-head p { color: var(--muted); font-size: 14px; margin-top: 6px; }
.auth-form { margin-top: 4px; }
.auth-form .btn { margin-top: 8px; }
.auth-foot { text-align: center; margin-top: 24px; color: var(--muted); font-size: 14px; }
.auth-foot a { font-weight: 550; }
.auth-card.center { text-align: center; }
.error-code { font-size: 64px; font-weight: 800; letter-spacing: -.03em; background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; line-height: 1; }
.error-msg { color: var(--muted); margin: 14px 0 26px; }
.share-title { text-align: center; font-size: 21px; margin: 16px 0 24px; font-weight: 700; }
.share-file { text-align: center; margin-bottom: 22px; }
.share-file .file-icon.big { margin: 0 auto 14px; }

/* ============ 应用顶栏 ============ */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 30px; height: 64px;
  background: var(--surface-glass);
  backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: var(--text); letter-spacing: -.01em; }
.brand:hover { color: var(--text); }
.brand-dot {
  width: 20px; height: 20px; border-radius: 7px;
  background: var(--accent-grad); display: inline-block; flex: none;
  box-shadow: 0 4px 12px rgba(99, 102, 241, .35);
}
.topnav { display: flex; align-items: center; gap: 18px; }
.nav-link { color: var(--muted); font-size: 14px; font-weight: 500; }
.nav-link:hover { color: var(--text); }
.usermenu { display: flex; align-items: center; gap: 13px; }
.username { font-size: 14px; color: var(--muted); font-weight: 500; }

/* ============ 容器 ============ */
.container { max-width: 1280px; margin: 0 auto; padding: 34px 24px 72px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; }
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 5px; }

/* ============ 拖拽上传区 ============ */
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--surface); padding: 24px 18px; text-align: center; cursor: pointer;
  transition: border-color .18s, background .18s, box-shadow .18s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); box-shadow: var(--shadow); }
.dz-inner { pointer-events: none; }
.dz-icon {
  width: 56px; height: 56px; margin: 0 auto 14px; display: flex; align-items: center; justify-content: center;
  border-radius: 16px; background: var(--accent-grad); color: #fff; box-shadow: 0 8px 20px rgba(99, 102, 241, .3);
}
.dz-text { font-size: 15px; font-weight: 500; }
.dz-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 15px; font-weight: 600; font-family: inherit; pointer-events: auto; }
.dz-btn:hover { text-decoration: underline; }
.dz-hint { color: var(--muted); font-size: 12px; margin-top: 7px; }

/* ============ 文件列表 ============ */
.filelist { display: flex; flex-direction: column; gap: 12px; }
.filerow {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 18px; box-shadow: var(--shadow-sm);
  transition: box-shadow .18s, border-color .18s, transform .18s;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.filerow:hover { box-shadow: var(--shadow); border-color: var(--border-strong); transform: translateY(-1px); }
.file-main { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.file-icon {
  width: 44px; height: 44px; flex: none; display: flex; align-items: center; justify-content: center;
  border-radius: 12px; background: var(--accent-soft); color: var(--accent);
}
.file-icon.big { width: 62px; height: 62px; border-radius: 16px; margin: 0 auto 14px; }
.file-icon.folder { background: rgba(245, 158, 11, .14); color: #d97706; }
.file-icon.folder[data-folder-open],
.file-name[data-folder-open] { cursor: pointer; }
.file-name[data-folder-open]:hover { color: var(--accent); }
.file-meta { min-width: 0; flex: 1; }
.file-name { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta a.file-name:hover { color: var(--accent); }
.file-sub { color: var(--muted); font-size: 12px; }
.file-actions { display: flex; align-items: center; gap: 7px; flex: none; flex-wrap: wrap; }
.filerow .panel { flex-basis: 100%; }

/* ============ 面包屑 ============ */
.crumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 18px; flex-wrap: wrap; }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--accent); }
.crumb-sep { color: var(--border-strong); }
.crumb-cur { color: var(--text); font-weight: 500; }

.panel { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.share-list { display: flex; flex-direction: column; gap: 9px; margin-bottom: 12px; }
.share-item { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.share-url {
  flex: 1; min-width: 200px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 11px; color: var(--accent);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px;
}
.share-tags { color: var(--muted); font-size: 12px; }
.share-tags i { font-style: normal; margin-right: 8px; }

.empty { text-align: center; padding: 72px 0; color: var(--muted); }
.empty svg { color: var(--border-strong); margin-bottom: 16px; }

/* ============ 工具栏 / 多选 ============ */
.toolbar { display: flex; gap: 8px; align-items: center; }

.batch-bar {
  display: flex; align-items: center; gap: 12px;
  background: var(--accent-soft); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 16px; font-size: 14px;
}
.batch-bar b { color: var(--accent); }

.file-check {
  display: none; flex: none; width: 17px; height: 17px;
  accent-color: var(--accent); cursor: pointer;
}
.filelist.selecting .file-check { display: inline-block; }

/* ============ 卡片 / 表格 ============ */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow-sm); margin-bottom: 20px; overflow-x: auto;
}
.card-narrow { max-width: 540px; }
.card-title { font-size: 16px; font-weight: 650; margin-bottom: 16px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 12px 13px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 550; font-size: 12.5px; text-transform: none; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table td.nowrap { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ops { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.empty-cell { text-align: center; color: var(--muted); padding: 26px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.panel-row td { background: var(--surface-2); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 550; background: var(--accent-soft); color: var(--accent); }
.badge.muted { background: var(--surface-2); color: var(--muted); }

/* ============ 管理后台布局 ============ */
.admin-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex: none; background: var(--surface-glass);
  backdrop-filter: saturate(180%) blur(16px);
  border-right: 1px solid var(--border); padding: 20px 14px;
  display: flex; flex-direction: column;
}
.sidebar .brand { padding: 4px 10px 20px; }
.side-nav { display: flex; flex-direction: column; gap: 3px; }
.side-nav a { padding: 10px 13px; border-radius: 10px; color: var(--muted); font-size: 14px; font-weight: 500; }
.side-nav a:hover { color: var(--text); background: var(--surface-2); }
.side-nav a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 14px 12px 4px; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.admin-main { flex: 1; padding: 34px 38px 72px; max-width: 1120px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 8px;
  transition: box-shadow .18s, transform .18s;
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-num { font-size: 30px; font-weight: 750; letter-spacing: -.02em; }
.stat-label { color: var(--muted); font-size: 13px; }

.settings-form { display: flex; flex-direction: column; gap: 6px; }
.settings-form .btn { align-self: flex-start; margin-top: 10px; }
.check-label { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--text); cursor: pointer; margin: 8px 0 16px; }
.check-label input { width: 17px; height: 17px; accent-color: var(--accent); }

/* ============ 上传面板 / 进度 ============ */
.upload-panel { margin-bottom: 24px; }
.upload-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.upload-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.upload-name {
  font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-bottom: 8px;
}
.progress {
  height: 6px; border-radius: 999px; background: var(--surface-2);
  overflow: hidden; margin-bottom: 6px;
}
.progress-fill {
  height: 100%; width: 0; border-radius: 999px; background: var(--accent-grad);
  transition: width .2s ease;
}
.upload-status { font-size: 12px; color: var(--muted); }
.upload-item.ok .upload-status { color: #16a34a; }
.upload-item.err .upload-status { color: var(--danger); }

.share-form .check-label { margin: 0; }

[hidden] { display: none !important; }

/* ============ 网盘布局 ============ */
.drive-layout { display: flex; gap: 24px; align-items: flex-start; }
.drive-sidebar {
  width: 200px; flex: none; position: sticky; top: 24px;
  display: flex; flex-direction: column; gap: 18px;
}
.drive-nav { display: flex; flex-direction: column; gap: 2px; }
.drive-nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; font-size: 14px; color: var(--text);
  text-decoration: none;
}
.drive-nav-link:hover { background: var(--surface-2); color: var(--text); }
.drive-nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.drive-storage {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px;
}
.drive-storage-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.drive-storage-num { font-size: 13px; font-weight: 600; }
.drive-storage-num span { color: var(--muted); font-weight: 400; }
.storage-bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 10px; }
.storage-fill { height: 100%; border-radius: 999px; background: var(--accent-grad); }

.drive-main { flex: 1; min-width: 0; }
.drive-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

.file-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.file-table thead th {
  text-align: left; padding: 12px 16px; font-size: 12px; font-weight: 500; color: var(--muted);
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.file-row { transition: background .12s ease; }
.file-row:hover { background: var(--surface-2); }
.file-table td { padding: 11px 16px; border-bottom: 1px solid var(--border); font-size: 14px; }
.file-row:last-of-type td { border-bottom: none; }
.cell-name { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cell-name .file-check { flex: none; }
.cell-name .file-icon { width: 34px; height: 34px; border-radius: 8px; flex: none; }
.cell-name .file-name { min-width: 0; }
.cell-size { color: var(--muted); font-size: 13px; white-space: nowrap; width: 90px; }
.cell-time { color: var(--muted); font-size: 13px; white-space: nowrap; width: 150px; }
.cell-actions { text-align: right; white-space: nowrap; opacity: 0; transition: opacity .15s ease; }
.file-row:hover .cell-actions { opacity: 1; }
.cell-actions .btn { margin-left: 4px; }
.panel-row td { background: var(--surface-2); border-bottom: 1px solid var(--border); }
.panel-row .panel { margin-top: 0; padding-top: 0; border-top: none; }
.th-size { width: 90px; }
.th-time { width: 150px; }
.th-actions { width: 240px; }

/* ============ 动画 ============ */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

/* ============ 响应式 ============ */
@media (max-width: 720px) {
  .topbar { padding: 0 16px; }
  .admin-layout { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 4px; }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { margin-top: 0; margin-left: auto; }
  .admin-main { padding: 20px 16px 48px; }
  .auth-card { padding: 34px 24px 30px; }
}
