*, *::before, *::after { box-sizing: border-box; }

:root {
  color-scheme: light dark;
  --bg: #f4f5fa;
  --panel: #ffffff;
  --panel-2: #f8f9fd;
  --text: #1b1f2a;
  --muted: #6b7280;
  --line: #e5e7f0;
  --brand: #4f46e5;
  --brand-strong: #4338ca;
  --brand-soft: #eef2ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --shadow: 0 12px 32px rgba(23, 25, 45, 0.07);
  --radius: 16px;
  --radius-sm: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --panel: #171a23;
    --panel-2: #1b1f2a;
    --text: #e8eaf2;
    --muted: #98a0b3;
    --line: #262b39;
    --brand: #818cf8;
    --brand-strong: #a5b4fc;
    --brand-soft: #1e2233;
    --danger: #f87171;
    --danger-soft: #2a1b1e;
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  }
}

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 34px;
  height: 34px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), #7c3aed);
  color: #fff;
}
.brand-mark svg { width: 19px; height: 19px; }
.brand-name { font-weight: 650; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 30px 24px 72px;
  flex: 1;
}

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-title { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
.page-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 6px; color: var(--muted); font-size: 13px; }

.hero-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 20px 80px; }
.hero { width: 100%; max-width: 520px; text-align: center; padding: 52px 32px; background: var(--panel); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.hero-mark { width: 64px; height: 64px; margin: 0 auto 20px; display: flex; align-items: center; justify-content: center; border-radius: 18px; background: linear-gradient(135deg, var(--brand), #7c3aed); color: #fff; }
.hero-mark svg { width: 34px; height: 34px; }
.hero h1 { margin: 0 0 10px; font-size: 26px; font-weight: 700; }
.hero p { margin: 0 0 24px; color: var(--muted); font-size: 14.5px; }
.hero-code { font-size: 52px; font-weight: 800; letter-spacing: -0.03em; color: var(--brand); line-height: 1; margin-bottom: 14px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  text-decoration: none;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-strong); }
.btn-ghost { border-color: var(--line); background: var(--panel); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { border-color: var(--line); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { padding: 7px 13px; font-size: 13px; }
.btn-xs { padding: 4px 9px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; }

.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14); }
.input-sm { padding: 7px 10px; font-size: 13px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.list { display: flex; flex-direction: column; overflow: hidden; padding: 6px; }

.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 10px;
  transition: background 0.12s;
}
a.file-row:hover { background: var(--panel-2); }
.file-row.is-disabled { opacity: 0.66; }
.file-icon {
  width: 38px;
  height: 38px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.file-icon svg { width: 21px; height: 21px; }
.file-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.file-name { font-size: 14.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { margin-top: 1px; font-size: 12px; color: var(--muted); }
.file-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.chev { color: var(--muted); font-size: 20px; line-height: 1; }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
}
.pill-muted { background: var(--panel-2); color: var(--muted); }
.badge-soft { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 12px; font-weight: 600; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13.5px; color: var(--muted); min-width: 0; }
.crumbs a { color: var(--brand); }
.crumbs a:hover { text-decoration: underline; }
.crumb-sep { color: var(--line); }
.crumb-here { color: var(--text); font-weight: 600; }
.filter-box { width: 220px; max-width: 100%; }

.empty { padding: 44px 20px; text-align: center; color: var(--muted); font-size: 14px; }
.list-hint { margin: 14px 4px 0; font-size: 12.5px; color: var(--muted); text-align: center; }

.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 18px 20px 26px;
  color: var(--muted);
  font-size: 12.5px;
}
.footer .dot { opacity: 0.5; }
.footer-admin { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.footer-admin:hover { color: var(--brand); }

.file-icon.kind-image { background: rgba(16, 185, 129, 0.13); color: #059669; }
.file-icon.kind-video { background: rgba(139, 92, 246, 0.13); color: #7c3aed; }
.file-icon.kind-audio { background: rgba(236, 72, 153, 0.13); color: #db2777; }
.file-icon.kind-pdf { background: rgba(239, 68, 68, 0.13); color: #dc2626; }
.file-icon.kind-word { background: rgba(59, 130, 246, 0.13); color: #2563eb; }
.file-icon.kind-excel { background: rgba(16, 185, 129, 0.13); color: #047857; }
.file-icon.kind-ppt { background: rgba(249, 115, 22, 0.13); color: #ea580c; }
.file-icon.kind-archive { background: rgba(245, 158, 11, 0.15); color: #b45309; }
.file-icon.kind-code { background: rgba(99, 102, 241, 0.13); color: #4f46e5; }
.file-icon.kind-text { background: rgba(100, 116, 139, 0.15); color: #475569; }
.file-icon.kind-other { background: rgba(100, 116, 139, 0.13); color: #64748b; }
.file-icon.folder { background: rgba(245, 158, 11, 0.14); color: #d97706; }

.auth-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 20px 80px; }
.auth-card { width: 100%; max-width: 390px; padding: 34px 28px; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); }
.auth-icon { width: 50px; height: 50px; margin: 0 auto 14px; display: flex; align-items: center; justify-content: center; border-radius: 14px; background: var(--brand-soft); color: var(--brand); }
.auth-icon svg { width: 25px; height: 25px; }
.auth-title { margin: 0 0 6px; font-size: 20px; font-weight: 700; }
.auth-sub { margin: 0 0 20px; color: var(--muted); font-size: 13.5px; }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.form-error { margin: 0 0 12px; padding: 9px 12px; border-radius: 9px; background: var(--danger-soft); color: var(--danger); font-size: 13px; }

.admin-grid { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 20px; align-items: start; }
.card { padding: 20px; }
.card-title { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; font-size: 16px; font-weight: 700; }
.card-note { margin: 14px 0 0; font-size: 12.5px; color: var(--muted); }
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; font-weight: 600; }
.hint { font-size: 12px; font-weight: 400; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; min-width: 0; }
.count-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 12px; }

.share-list { display: flex; flex-direction: column; gap: 12px; }
.share-item { padding: 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; }
.share-item-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.share-item-name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14.5px; font-weight: 650; }
.share-item-path { margin-top: 3px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--muted); word-break: break-all; }
.share-item-meta { margin-top: 2px; font-size: 12px; color: var(--muted); }
.share-item-link { display: flex; gap: 8px; margin-top: 10px; }
.share-item-link .input { flex: 1; min-width: 0; font-size: 12px; }

.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 12, 20, 0.55); }
.modal-card { position: relative; display: flex; flex-direction: column; width: 100%; max-width: 520px; max-height: 80vh; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 30px 60px rgba(0, 0, 0, 0.3); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 15px; }
.icon-btn { width: 30px; height: 30px; border: none; border-radius: 8px; background: transparent; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.modal-path { padding: 8px 16px; background: var(--panel-2); border-bottom: 1px solid var(--line); font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--muted); word-break: break-all; }
.modal-list { min-height: 180px; overflow: auto; padding: 6px; }
.modal-dir { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: none; border-radius: 9px; background: transparent; color: var(--text); font-size: 14px; text-align: left; cursor: pointer; }
.modal-dir:hover { background: var(--panel-2); }
.modal-dir svg { width: 18px; height: 18px; flex: none; color: #d97706; }
.modal-empty { padding: 26px 12px; text-align: center; font-size: 13px; color: var(--muted); }
.modal-hint { padding: 6px 16px; background: var(--panel-2); border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.modal-file { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: none; border-radius: 9px; background: transparent; color: var(--text); font-size: 14px; text-align: left; cursor: pointer; }
.modal-file:hover { background: var(--panel-2); }
.modal-ext { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 26px; border-radius: 6px; background: rgba(139, 92, 246, 0.13); color: #7c3aed; font-size: 10px; font-weight: 700; }
.modal-ext.is-off { background: rgba(100, 116, 139, 0.14); color: #64748b; }
.modal-file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-file-size { flex: none; font-size: 12px; color: var(--muted); }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); }

.toast { position: fixed; bottom: 28px; left: 50%; z-index: 80; max-width: 80vw; padding: 10px 18px; border-radius: 10px; background: var(--text); color: var(--bg); font-size: 13.5px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2); transform: translateX(-50%); }
.toast.is-error { background: var(--danger); color: #fff; }

.viewer-body { background: #0b0d12; color: #e8eaf2; }
.viewer-body .footer { display: none; }
.viewer { display: flex; flex-direction: column; min-height: 100vh; background: #0b0d12; }
.viewer-bar { display: flex; align-items: center; gap: 16px; padding: 12px 18px; background: #0f1219; border-bottom: 1px solid #20242f; }
.viewer-back { flex: none; padding: 6px 12px; border-radius: 9px; background: #181c26; color: #c7cdfa; font-size: 13.5px; }
.viewer-back:hover { background: #232838; }
.viewer-title { display: flex; flex: 1; align-items: center; gap: 10px; min-width: 0; }
.viewer-name { overflow: hidden; font-size: 14.5px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.viewer-pos { flex: none; font-size: 12px; color: #8b93a7; }
.viewer-navs { display: flex; gap: 8px; flex: none; }
.viewer-switch { display: flex; align-items: center; gap: 6px; flex: none; padding: 3px; border-radius: 10px; background: #181c26; }
.v-switch { display: inline-flex; align-items: center; justify-content: center; padding: 4px 12px; border-radius: 7px; font-size: 12.5px; color: #8b93a7; }
a.v-switch:hover { color: #e8eaf2; background: #232838; }
.v-switch.is-on { background: #2d3348; color: #e8eaf2; font-weight: 600; }
.viewer-nav { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 10px; background: #181c26; color: #e8eaf2; font-size: 22px; line-height: 1; }
.viewer-nav:hover { background: #232838; }
.viewer-nav.is-off { opacity: 0.28; }
.viewer-stage { display: flex; flex: 1; align-items: center; justify-content: center; padding: 18px; min-height: 0; }
.viewer-video { width: auto; max-width: 100%; max-height: calc(100vh - 132px); border-radius: 12px; background: #000; outline: none; }
.viewer-foot { padding: 8px 12px 18px; text-align: center; font-size: 12px; color: #6f778c; }
.viewer-error { margin: 16px 0 0; padding: 10px 14px; border-radius: 9px; background: rgba(220, 38, 38, 0.16); color: #fca5a5; font-size: 13px; }

@media (max-width: 860px) {
  .admin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .container { padding: 20px 14px 56px; }
  .topbar { padding: 10px 14px; }
  .page-head { flex-direction: column; }
  .filter-box { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .share-item-link { flex-wrap: wrap; }
  .viewer-bar { gap: 10px; padding: 10px 12px; }
  .viewer-pos { display: none; }
  .viewer-stage { padding: 10px; }
  .viewer-video { max-height: calc(100vh - 148px); }
}
