@font-face {
  font-family: 'SanJiNengLiangHei';
  src: url('fonts/SanJiNengLiangHei.woff2') format('woff2');
  font-weight: 400 900;
  font-display: swap;
}
:root {
  --navy: #0f172a;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --radius-sm: 8px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 0.2s;
  --dur-slow: 0.4s;
  --dur-enter: 0.6s;
  --danger: #dc2626;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'SanJiNengLiangHei', var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background: #f2f4f8;
  color: var(--text-primary);
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: #f1f5f9; border-radius: 5px; padding: 1px 6px; font-size: 0.92em; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* 顶栏 */
.app-header {
  margin: 14px 16px 0;
  background: rgba(255,255,255,0.85);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid rgba(226,232,240,0.9);
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(15,23,42,0.06);
  padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  animation: header-in var(--dur-enter) var(--ease-spring) both;
}
@keyframes header-in { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
.brand { font-weight: 800; font-size: 22px; letter-spacing: -0.02em; }
.header-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hlink { font-size: 15px; color: var(--text-secondary); padding: 7px 13px; border-radius: 8px; font-weight: 600; transition: background var(--dur) var(--ease), color var(--dur) var(--ease); background: transparent; border: none; }
.hlink:hover { background: #f1f5f9; color: var(--text-primary); }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 6px; border-radius: 999px; background: #f1f5f9; }
.user-chip .av { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; }
.user-chip .nm { font-size: 15px; font-weight: 600; }
.ipv6-badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700;
  color: #15803d; background: #dcfce7; border: 1px solid #bbf7d0; border-radius: 999px; padding: 4px 10px;
}
.ipv6-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #16a34a; }

/* 主体 */
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 18px 16px 150px; }
.panel {
  background: #fff; border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 8px 24px rgba(15,23,42,0.05); overflow: hidden;
  animation: fade-up var(--dur-enter) var(--ease-spring) both;
}
@keyframes fade-up { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.toolbar { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.btn {
  border: 1px solid var(--border); background: #fff; color: var(--text-primary); border-radius: 9px;
  padding: 8px 14px; font-size: 15px; font-weight: 600;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
  display: inline-flex; align-items: center; gap: 7px;
}
.btn:hover { background: #f8fafc; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.spacer { flex: 1; }
.search { display: flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 9px; padding: 6px 10px; background: #fff; }
.search input { border: none; outline: none; font-family: inherit; font-size: 15px; width: 160px; background: transparent; color: var(--text-primary); }

.crumb { display: flex; align-items: center; gap: 4px; padding: 12px 16px; font-size: 15px; flex-wrap: wrap; }
.crumb a { color: var(--accent); font-weight: 600; padding: 3px 6px; border-radius: 6px; cursor: pointer; }
.crumb a:hover { background: #eff6ff; }
.crumb .sep { color: #cbd5e1; }
.crumb .cur { color: var(--text-secondary); padding: 3px 6px; }

.list-head, .row { display: grid; grid-template-columns: 1fr 120px 170px 130px; align-items: center; gap: 8px; padding: 10px 16px; }
.list-head { font-size: 13px; color: var(--text-secondary); border-bottom: 1px solid var(--border); font-weight: 600; }
.row { border-bottom: 1px solid #f1f5f9; transition: background var(--dur) var(--ease); }
.row:last-child { border-bottom: none; }
.row:hover { background: #f8fafc; }
.row .name { display: flex; align-items: center; gap: 10px; min-width: 0; cursor: pointer; }
.row .name .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; font-weight: 600; }
.row .name .thumb { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; background: #eef2f7; flex: 0 0 auto; }
.row .name .fi { width: 24px; height: 24px; flex: 0 0 auto; }
.fi.folder { color: #f59e0b; }
.fi.image { color: #10b981; }
.fi.video { color: #6366f1; }
.fi.audio { color: #ec4899; }
.fi.text { color: #64748b; }
.fi.pdf { color: #dc2626; }
.fi.archive { color: #a855f7; }
.fi.file { color: #94a3b8; }
.row .meta { font-size: 14px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .acts { display: flex; gap: 4px; justify-content: flex-end; opacity: 0; transition: opacity var(--dur) var(--ease); }
.row:hover .acts { opacity: 1; }
.ibtn { border: none; background: transparent; padding: 6px; border-radius: 7px; color: var(--text-secondary); display: inline-flex; }
.ibtn:hover { background: #eef2f7; color: var(--text-primary); }
.ibtn.danger:hover { background: #fef2f2; color: var(--danger); }
.ibtn svg { width: 17px; height: 17px; }

.empty { padding: 60px 20px; text-align: center; color: var(--text-secondary); font-size: 15px; }
.empty svg { width: 54px; height: 54px; color: #cbd5e1; margin-bottom: 12px; }
.loading { padding: 28px; text-align: center; color: var(--text-secondary); font-size: 15px; }

/* 左下角空间 */
.quota {
  position: fixed; left: 18px; bottom: 18px; z-index: 35;
  background: rgba(255,255,255,0.94); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; width: 268px;
  box-shadow: 0 10px 30px rgba(15,23,42,0.12);
}
.quota .qtop { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.quota .qtitle { font-size: 14px; font-weight: 700; }
.quota .qnum { font-size: 13px; color: var(--text-secondary); }
.qvol { margin-bottom: 9px; }
.qvol:last-child { margin-bottom: 0; }
.qvol .qv-top { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.qvol .qv-name { font-weight: 700; color: var(--text-primary); }
.qvol.current .qv-name { color: var(--accent); }
.qbar { height: 7px; border-radius: 99px; background: #e2e8f0; overflow: hidden; }
.qbar > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg,#2563eb,#60a5fa); border-radius: 99px; transition: width var(--dur-slow) var(--ease); }
.qbar.warn > i { background: linear-gradient(90deg,#d97706,#f59e0b); }
.qbar.full > i { background: linear-gradient(90deg,#dc2626,#f87171); }

/* 上传进度 */
.uploads { position: fixed; right: 18px; bottom: 18px; z-index: 36; width: 300px; display: flex; flex-direction: column; gap: 8px; }
.upitem { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; box-shadow: 0 10px 26px rgba(15,23,42,0.12); }
.upitem .un { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; margin-bottom: 6px; gap: 8px; }
.upitem .un span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upitem .up-meta { display: flex; align-items: baseline; gap: 8px; flex-shrink: 0; }
.upitem .up-speed { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.upitem .ub { height: 6px; border-radius: 99px; background: #e2e8f0; overflow: hidden; }
.upitem .ub > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width var(--dur) linear; }
.upitem.done .ub > i { background: #16a34a; }
.upitem.err .ub > i { background: var(--danger); }

/* 拖拽遮罩 */
.drop {
  position: fixed; inset: 0; z-index: 60; background: rgba(37,99,235,0.10);
  border: 3px dashed var(--accent); display: none; align-items: center; justify-content: center;
}
.drop.show { display: flex; }
.drop .box { background: #fff; padding: 26px 34px; border-radius: 16px; font-size: 17px; font-weight: 700; box-shadow: 0 20px 50px rgba(15,23,42,0.2); }

/* 模态 */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.42); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 70; opacity: 0; pointer-events: none; transition: opacity 0.16s ease; }
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 460px; padding: 22px; box-shadow: 0 24px 60px rgba(15,23,42,0.28); transform: translate3d(0,14px,0) scale(0.97); transition: transform 0.22s var(--ease-spring); max-height: 86vh; overflow: auto; }
.modal-overlay.show .modal { transform: none; }
.modal h3 { font-size: 20px; margin-bottom: 14px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 14px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 600; }
.field input { width: 100%; border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; font-size: 16px; font-family: inherit; outline: none; background: #fff; color: var(--text-primary); }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* 预览 */
.preview-overlay { position: fixed; inset: 0; background: rgba(8,12,22,0.94); z-index: 90; display: none; flex-direction: column; }
.preview-overlay.show { display: flex; }
.preview-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; color: #fff; gap: 12px; }
.preview-head .pn { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-acts { display: flex; gap: 8px; flex-shrink: 0; }
.preview-head button { border: none; background: rgba(255,255,255,0.14); color: #fff; border-radius: 9px; padding: 8px 14px; font-size: 14px; font-weight: 600; }
.preview-head button:hover { background: rgba(255,255,255,0.26); }
.preview-body { flex: 1; display: flex; align-items: center; justify-content: center; overflow: auto; padding: 0 20px 24px; }
.preview-body img, .preview-body video { max-width: 100%; max-height: 100%; border-radius: 8px; }
.preview-body audio { width: min(520px, 100%); }
.preview-body pre { color: #e2e8f0; background: #0b1220; padding: 18px; border-radius: 10px; max-width: 960px; width: 100%; white-space: pre-wrap; word-break: break-word; font-size: 14px; line-height: 1.65; font-family: ui-monospace, Menlo, Consolas, monospace; }
.preview-body iframe { width: 100%; height: 100%; border: none; background: #fff; border-radius: 8px; }
.preview-tip { color: #94a3b8; font-size: 14px; text-align: center; line-height: 1.8; }

/* 登录 / IPv6 闸门 */
.gate { position: fixed; inset: 0; z-index: 200; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(15,23,42,0.42); overflow: auto; }
.gate.show { display: flex; }
.gate-card { background: #fff; border-radius: 18px; width: 100%; max-width: 400px; padding: 28px; box-shadow: 0 24px 60px rgba(15,23,42,0.28); transform: translate3d(0,14px,0) scale(0.97); transition: transform 0.22s var(--ease-spring); margin: auto; }
.gate.show .gate-card { transform: none; }
.gate-block { max-width: 480px; }
.gate-logo { font-size: 22px; font-weight: 800; color: var(--accent); margin-bottom: 14px; }
.gate-card h3 { font-size: 22px; margin-bottom: 6px; }
.gate-sub { font-size: 15px; color: var(--text-secondary); margin-bottom: 18px; line-height: 1.6; }
.gate-btn { width: 100%; justify-content: center; margin-top: 8px; }
.gate-err { color: var(--danger); font-size: 14px; margin-bottom: 10px; display: none; }
.gate-err.show { display: block; }
.gate-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; font-size: 14px; }
.gate-foot a { color: var(--accent); font-weight: 600; }
.gate-tips { margin: 0 0 20px 20px; color: var(--text-secondary); font-size: 14px; line-height: 1.9; }
.gate-tips a { color: var(--accent); font-weight: 600; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); background: #0f172a; color: #fff; padding: 11px 20px; border-radius: 10px; font-size: 15px; opacity: 0; pointer-events: none; transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); z-index: 100; max-width: 86vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .list-head { display: none; }
  .row { grid-template-columns: 1fr 100px; gap: 6px; }
  .row .meta.time { display: none; }
  .row .acts { opacity: 1; grid-column: 2; }
  .row .name .txt { font-size: 15px; }
  .quota { width: calc(100% - 36px); left: 18px; bottom: 12px; }
  .uploads { width: calc(100% - 36px); right: 18px; bottom: 132px; }
  .search input { width: 110px; }
  .brand { font-size: 20px; }
  body { font-size: 14px; }
  .hlink { font-size: 13px; }
  .user-chip .nm { font-size: 13px; }
  .btn { font-size: 14px; }
  .crumb { font-size: 13px; }
  .row .name .txt { font-size: 14px; }
  .row .meta { font-size: 12px; }
  .gate-sub { font-size: 13px; }
  .gate-foot { font-size: 13px; }
  .gate-tips { font-size: 13px; }
  .toast { font-size: 13px; }
  .preview-head .pn { font-size: 14px; }
}

/* 内嵌到 NAS 页面时（iframe） */
body.embed { background: #fff; }
body.embed .app-header { display: none; }
body.embed .wrap { padding: 0; max-width: none; padding-bottom: 24px; }
body.embed .panel { border: none; border-radius: 0; box-shadow: none; animation: none; }
body.embed .quota { display: none; }
body.embed .uploads { bottom: 18px; }
