/* ============================================================
   云盘 · 样式表
   浅色玻璃拟态 + 靛蓝主色，支持深色系统偏好
   ============================================================ */
:root {
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-soft: #eef2ff;
  --danger: #e11d48;
  --success: #059669;
  --warn: #d97706;
  --text: #101828;
  --text-2: #475467;
  --text-3: #98a2b3;
  --line: #eaecf0;
  --bg: #f6f7fb;
  --card: #ffffff;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .08);
  --shadow-lg: 0 24px 48px -12px rgba(16, 24, 40, .22);
  --side-w: 252px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ---------------------------------------------------------- 布局骨架 */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--side-w);
  flex: 0 0 var(--side-w);
  background: linear-gradient(180deg, #fff 0%, #fbfbfe 100%);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.brand-logo {
  width: 38px; height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  display: grid; place-items: center;
  font-size: 20px;
  box-shadow: 0 6px 16px -4px rgba(79, 70, 229, .5);
}
.brand-logo.lg { width: 56px; height: 56px; font-size: 30px; border-radius: 18px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15px; letter-spacing: .2px; }
.brand-text span { font-size: 11px; color: var(--text-3); }

.btn-upload, .btn-primary, .btn-ghost, .btn-danger-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 10px 16px;
  font-weight: 600;
  transition: .18s ease;
  white-space: nowrap;
}

.btn-upload, .btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 8px 18px -8px rgba(79, 70, 229, .8);
}
.btn-primary:hover, .btn-upload:hover { transform: translateY(-1px); filter: brightness(1.06); }
.btn-primary.lg { padding: 13px 18px; font-size: 15px; width: 100%; }

.btn-ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--text-2);
}
.btn-ghost:hover { border-color: #d0d5dd; color: var(--text); background: #fcfcfd; }

.btn-danger-ghost {
  background: #fff1f3;
  color: var(--danger);
  border-color: #fecdd6;
}
.btn-danger-ghost:hover { background: #ffe4e8; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-3);
  padding: 12px 10px 6px;
  font-weight: 700;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 500;
  transition: .15s;
}
.nav-item:hover { background: #f4f5fa; color: var(--text); }
.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
}
.nav-ico { font-size: 15px; width: 20px; text-align: center; }

.quota-card {
  margin-top: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow-sm);
}
.quota-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); font-weight: 600; }
.quota-pct { color: var(--brand); }
.quota-bar { height: 6px; border-radius: 99px; background: #eef0f5; margin: 8px 0 6px; overflow: hidden; }
.quota-bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .4s; }
.quota-text { font-size: 11px; color: var(--text-3); }

.user-box {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: var(--radius-sm);
  background: #fff; border: 1px solid var(--line);
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; flex: 1; }
.user-meta strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta span { font-size: 11px; color: var(--text-3); }

.icon-btn {
  border: none; background: transparent; color: var(--text-3);
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center; font-size: 15px;
}
.icon-btn:hover { background: #f2f4f7; color: var(--text); }

/* ---------------------------------------------------------- 主区域 */
.main {
  flex: 1;
  min-width: 0;
  padding: 18px 26px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.topbar { display: flex; align-items: center; gap: 14px; }
.search {
  flex: 1; max-width: 520px;
  display: flex; align-items: center; gap: 9px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 99px; padding: 9px 16px;
  color: var(--text-3);
  transition: .2s;
}
.search:focus-within { border-color: #c7d2fe; box-shadow: 0 0 0 4px rgba(79, 70, 229, .08); }
.search input { border: none; outline: none; flex: 1; background: transparent; color: var(--text); }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }
.only-mobile { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 2px 0 2px; font-size: 24px; letter-spacing: -.02em; }
.sub { margin: 0; color: var(--text-3); font-size: 12.5px; }
.crumbs { font-size: 12.5px; color: var(--text-3); display: flex; gap: 6px; flex-wrap: wrap; }
.crumbs a:hover { color: var(--brand); }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.view-toggle { display: flex; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 3px; }
.view-btn { border: none; background: transparent; color: var(--text-3); padding: 5px 10px; border-radius: 7px; font-size: 14px; }
.view-btn.active { background: var(--brand-soft); color: var(--brand); }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 11px 14px; display: flex; flex-direction: column; gap: 1px;
  box-shadow: var(--shadow-sm);
}
.stat-card span { font-size: 11.5px; color: var(--text-3); }
.stat-card strong { font-size: 15px; letter-spacing: -.01em; }

/* ---------------------------------------------------------- 文件网格 */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 14px;
}

.file-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: .2s ease;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.file-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: #dbe2f5; }

.file-thumb {
  position: relative;
  height: 118px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #f7f8fc, #eef1fa);
  overflow: hidden;
}
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-folder, .thumb-media {
  font-size: 40px;
  filter: drop-shadow(0 4px 8px rgba(16, 24, 40, .14));
}
.thumb-media.video { background: linear-gradient(135deg, #ede9fe, #ddd6fe); width: 100%; height: 100%; display: grid; place-items: center; }
.thumb-media.audio { background: linear-gradient(135deg, #e0f2fe, #dbeafe); width: 100%; height: 100%; display: grid; place-items: center; }
.thumb-media.doc { background: linear-gradient(135deg, #ecfdf5, #d1fae5); width: 100%; height: 100%; display: grid; place-items: center; }
.thumb-media.other { background: linear-gradient(135deg, #f8fafc, #eef2f6); width: 100%; height: 100%; display: grid; place-items: center; }

.star-badge {
  position: absolute; top: 8px; right: 8px;
  background: rgba(255, 255, 255, .92);
  color: #f59e0b;
  border-radius: 99px;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  font-size: 12px;
  box-shadow: var(--shadow-sm);
}

.file-body { padding: 10px 12px 12px; }
.file-name {
  font-weight: 600; font-size: 13.2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--text-3); margin-top: 3px; }

.file-actions {
  position: absolute; inset: auto 0 0 0;
  display: flex; gap: 2px; justify-content: flex-end;
  padding: 7px 8px;
  background: linear-gradient(0deg, rgba(255, 255, 255, .98), rgba(255, 255, 255, .88));
  border-top: 1px solid var(--line);
  transform: translateY(100%);
  transition: transform .18s ease;
}
.file-card:hover .file-actions { transform: translateY(0); }
.act {
  border: none; background: transparent;
  width: 28px; height: 28px; border-radius: 7px;
  display: grid; place-items: center;
  font-size: 13px; color: var(--text-2);
}
.act:hover { background: var(--brand-soft); color: var(--brand); }
.act.danger:hover { background: #fff1f3; color: var(--danger); }

/* 列表视图 */
.file-grid.list-view { display: flex; flex-direction: column; gap: 6px; }
.file-grid.list-view .file-card { display: flex; align-items: center; gap: 12px; padding: 8px 12px; }
.file-grid.list-view .file-thumb { height: 42px; width: 42px; flex: 0 0 42px; border-radius: 10px; }
.file-grid.list-view .thumb-folder, .file-grid.list-view .thumb-media { font-size: 20px; }
.file-grid.list-view .file-body { padding: 0; flex: 1; min-width: 0; }
.file-grid.list-view .file-actions {
  position: static; transform: none; background: none; border: none; padding: 0; opacity: 0;
}
.file-grid.list-view .file-card:hover .file-actions { opacity: 1; }

/* ---------------------------------------------------------- 空状态 */
.empty { text-align: center; padding: 60px 20px; color: var(--text-2); }
.empty-ico { font-size: 44px; margin-bottom: 10px; }
.empty h3 { margin: 0 0 6px; font-size: 17px; }
.empty p { margin: 0 0 18px; color: var(--text-3); }

/* ---------------------------------------------------------- 上传面板 */
.uploader {
  position: fixed; inset: 0;
  background: rgba(16, 24, 40, .42);
  backdrop-filter: blur(4px);
  display: grid; place-items: center;
  z-index: 60;
  padding: 20px;
}
.uploader[hidden] { display: none; }
.uploader-panel {
  width: min(560px, 100%);
  background: #fff; border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 18px;
}
.uploader-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-size: 16px; }

.dropzone {
  display: grid; place-items: center; gap: 4px;
  border: 2px dashed #d5d9e6;
  border-radius: 14px;
  padding: 26px 16px;
  text-align: center;
  background: #fafbff;
  transition: .18s;
  cursor: pointer;
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background: var(--brand-soft); }
.dropzone-ico { font-size: 30px; color: var(--brand); }
.dropzone p { margin: 2px 0; }
.dropzone small { color: var(--text-3); }

.upload-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; }
.upload-item { display: flex; flex-direction: column; gap: 4px; }
.upload-item-head { display: flex; justify-content: space-between; font-size: 12px; gap: 10px; }
.upload-item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-bar { height: 5px; border-radius: 99px; background: #eef0f5; overflow: hidden; }
.upload-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .2s; }
.upload-item.done .upload-bar i { background: var(--success); }
.upload-item.fail .upload-bar i { background: var(--danger); }
/* 传输完成但服务器仍在写入对象存储 */
.upload-item.processing .upload-bar i {
  background: linear-gradient(90deg, var(--brand), var(--brand-2), var(--brand));
  background-size: 200% 100%;
  animation: upload-flow 1.1s linear infinite;
}
.upload-item.processing .upload-pct { color: var(--brand); font-weight: 600; }
@keyframes upload-flow {
  from { background-position: 0% 0; }
  to   { background-position: 200% 0; }
}

/* ---------------------------------------------------------- Toast / Modal */
.toast-wrap { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast {
  background: #101828; color: #fff;
  padding: 11px 16px; border-radius: 12px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  animation: toast-in .2s ease;
  max-width: 340px;
}
.toast.success { background: #065f46; }
.toast.error { background: #9f1239; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.modal { position: fixed; inset: 0; background: rgba(16, 24, 40, .42); display: grid; place-items: center; z-index: 70; padding: 20px; }
.modal[hidden] { display: none; }
.modal-card { width: min(420px, 100%); background: #fff; border-radius: 18px; padding: 20px; box-shadow: var(--shadow-lg); }
.modal-card h3 { margin: 0 0 8px; font-size: 16px; }
.modal-card p { margin: 0 0 16px; color: var(--text-2); }
.modal-card input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; outline: none; }
.modal-card input:focus { border-color: #c7d2fe; box-shadow: 0 0 0 4px rgba(79, 70, 229, .08); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------------------------------------------------------- Flash */
.flash-stack { display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 10px 14px; border-radius: 12px; font-size: 13px; border: 1px solid transparent; }
.flash-success { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.flash-error { background: #fff1f3; color: #be123c; border-color: #fecdd6; }
.flash-warning { background: #fffbeb; color: #b45309; border-color: #fde68a; }

/* ---------------------------------------------------------- 预览页 */
.preview-page { display: flex; flex-direction: column; gap: 18px; }
.preview-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.preview-head h1 { margin: 2px 0; font-size: 20px; word-break: break-all; }
.preview-stage {
  background: #0b1020;
  border-radius: 18px;
  min-height: 62vh;
  display: grid; place-items: center;
  padding: 18px;
  overflow: auto;
}
.preview-image { max-width: 100%; max-height: 76vh; border-radius: 10px; box-shadow: var(--shadow-lg); }
.preview-video { width: 100%; max-height: 76vh; border-radius: 10px; background: #000; }
.preview-pdf { width: 100%; height: 78vh; border: none; border-radius: 10px; background: #fff; }
.preview-audio { display: grid; gap: 14px; justify-items: center; color: #fff; }
.audio-orb {
  width: 110px; height: 110px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center; font-size: 40px;
  box-shadow: 0 20px 40px -12px rgba(124, 58, 237, .8);
}
.preview-audio audio { width: min(420px, 80vw); }
.preview-text {
  background: #fff;
  color: #101828;
  width: 100%;
  min-height: 62vh;
  margin: 0;
  padding: 18px;
  border-radius: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "JetBrains Mono", Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.7;
}
.preview-none { display: grid; justify-items: center; gap: 8px; color: #e5e7eb; text-align: center; }
.preview-none h3 { color: #fff; margin: 0; }
.preview-none p { color: #9ca3af; margin: 0 0 10px; }

/* ---------------------------------------------------------- 设置页 */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.panel h2 { margin: 0 0 14px; font-size: 15px; }
.stack-form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.field input {
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  transition: .18s;
  background: #fcfcfd;
}
.field input:focus { border-color: #c7d2fe; box-shadow: 0 0 0 4px rgba(79, 70, 229, .08); background: #fff; }
.field input:disabled { background: #f2f4f7; color: var(--text-3); }

.quota-big { display: flex; align-items: center; gap: 18px; }
.quota-ring {
  width: 96px; height: 96px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px; color: var(--brand);
  background: conic-gradient(var(--brand) calc(var(--pct) * 1%), #eef0f5 0);
  position: relative;
}
.quota-ring::before {
  content: ""; position: absolute; inset: 9px; border-radius: 50%; background: #fff;
}
.quota-ring span { position: relative; }
.quota-used { margin: 0; font-size: 19px; font-weight: 700; }
.quota-total { margin: 2px 0 0; color: var(--text-3); font-size: 13px; }
.quota-used small, .quota-total small { color: var(--text-3); font-weight: 400; font-size: 11.5px; }

.info-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.info-list li { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding-bottom: 10px; border-bottom: 1px dashed var(--line); }
.info-list li:last-child { border-bottom: none; padding-bottom: 0; }
.info-list span { color: var(--text-3); }
.info-list a { color: var(--brand); font-weight: 600; }

/* ---------------------------------------------------------- 登录/注册 */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background: #f6f7fb;
}
.auth-aurora {
  position: absolute;
  inset: -20% -10% auto -10%;
  height: 70vh;
  background:
    radial-gradient(45% 55% at 22% 30%, rgba(99, 102, 241, .35), transparent 70%),
    radial-gradient(40% 50% at 78% 20%, rgba(168, 85, 247, .32), transparent 70%),
    radial-gradient(38% 48% at 55% 65%, rgba(56, 189, 248, .28), transparent 70%);
  filter: blur(30px);
  pointer-events: none;
}
.auth-card {
  position: relative;
  width: min(420px, 100%);
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 24px;
  padding: 30px 28px;
  box-shadow: 0 40px 80px -30px rgba(16, 24, 40, .35);
  display: flex; flex-direction: column; gap: 16px;
}
.auth-card.wide { width: min(640px, 100%); }
.auth-brand { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.auth-brand h1 { margin: 6px 0 0; font-size: 21px; letter-spacing: -.02em; }
.auth-brand p { margin: 0; color: var(--text-3); font-size: 12.5px; }
.auth-form { display: flex; flex-direction: column; gap: 13px; }
.auth-foot { text-align: center; margin: 0; font-size: 13px; color: var(--text-3); }
.auth-foot a { color: var(--brand); font-weight: 700; }
.share-stage { display: grid; place-items: center; }

/* ---------------------------------------------------------- 响应式 */
@media (max-width: 960px) {
  .sidebar {
    position: fixed; z-index: 50; left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .only-mobile { display: grid; }
  .main { padding: 14px 16px 32px; }
  .file-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .file-thumb { height: 100px; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #e8eaf2;
    --text-2: #a9b0c3;
    --text-3: #7b839a;
    --line: #262b3d;
    --bg: #0d1017;
    --card: #151a26;
  }
  .sidebar { background: linear-gradient(180deg, #151a26 0%, #111621 100%); }
  .search, .btn-ghost, .quota-card, .user-box, .panel, .stat-card, .view-toggle { background: #171d2b; }
  .file-thumb { background: linear-gradient(135deg, #1b2233, #171d2b); }
  .file-actions { background: linear-gradient(0deg, #151a26, #151a26f0); }
  .dropzone { background: #171d2b; }
  .uploader-panel, .modal-card { background: #151a26; }
  .preview-text { background: #171d2b; color: #e8eaf2; }
  .auth-card { background: rgba(21, 26, 38, .88); border-color: rgba(255, 255, 255, .08); }
  .auth-page { background: #0d1017; }
  .quota-ring::before { background: #151a26; }
  .field input { background: #111621; }
}
