:root {
  --bg: #0d1117;
  --bg2: #111826;
  --panel: #161d2a;
  --panel2: #1c2536;
  --line: #27324a;
  --text: #dbe4f0;
  --muted: #8b98ab;
  --accent: #3d8bfd;
  --accent2: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(61,139,253,.10), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(34,197,94,.06), transparent 60%),
    var(--bg);
  color: var(--text);
  font-size: 14px;
}
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: rgba(61,139,253,.35); }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
  transition: all .15s ease; user-select: none; font-family: inherit;
}
.btn:hover { border-color: var(--accent); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, #2f7cf0, #2563eb); border-color: transparent; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--line); background: var(--panel2); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  width: 100%; max-width: 360px; background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid var(--line); border-radius: 16px; padding: 34px 30px;
  box-shadow: var(--shadow); animation: rise .4s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.login-logo { font-size: 40px; text-align: center; margin-bottom: 8px; }
.login-title { text-align: center; font-size: 20px; font-weight: 700; letter-spacing: .5px; }
.login-sub { text-align: center; color: var(--muted); font-size: 12px; margin: 6px 0 22px; font-family: var(--mono); }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font-size: 14px; outline: none; font-family: inherit;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(61,139,253,.15); }
.login-error { color: var(--danger); font-size: 12px; min-height: 18px; margin: 2px 0 8px; }
.login-hint { text-align: center; color: var(--muted); font-size: 12px; margin-top: 16px; }
.login-card.shake { animation: shake .35s; }
@keyframes shake {
  0%,100% { transform: translateX(0); } 25% { transform: translateX(-7px); }
  50% { transform: translateX(7px); } 75% { transform: translateX(-4px); }
}

/* ---------- 布局 ---------- */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 260px; min-width: 260px; background: var(--bg2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px;
}
.side-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; padding: 0 4px; }
.side-logo { font-size: 26px; }
.side-title { font-weight: 700; font-size: 15px; }
.side-sub { font-size: 12px; color: var(--muted); font-family: var(--mono); margin-top: 2px; }
.side-search { margin-bottom: 12px; }
.side-search input {
  width: 100%; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 13px; outline: none;
}
.side-search input:focus { border-color: var(--accent); }
.cat-nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.cat-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  cursor: pointer; color: var(--muted); font-size: 13px; transition: all .12s;
  border: 1px solid transparent;
}
.cat-item:hover { background: var(--panel); color: var(--text); }
.cat-item.active { background: var(--panel); color: #fff; border-color: var(--line); }
.cat-item .cat-icon { font-size: 16px; }
.cat-item .cat-count { margin-left: auto; font-size: 11px; background: var(--panel2); padding: 1px 8px; border-radius: 20px; color: var(--muted); }
.cat-item.active .cat-count { background: rgba(61,139,253,.2); color: var(--accent); }
.side-foot { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 8px; }
.disk { height: 6px; background: var(--panel); border-radius: 4px; overflow: hidden; }
.disk > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); }
.disk.danger > i { background: linear-gradient(90deg, var(--warn), var(--danger)); }
.disk-label { font-size: 11px; color: var(--muted); margin: 6px 0 10px; font-family: var(--mono); }

/* ---------- 主区 ---------- */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--line); background: rgba(13,17,23,.6);
  backdrop-filter: blur(6px); gap: 12px; flex-wrap: wrap;
}
.topbar h2 { font-size: 17px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip {
  font-size: 12px; color: var(--muted); border: 1px solid var(--line); background: var(--panel);
  padding: 4px 10px; border-radius: 20px; font-family: var(--mono);
}
.content { flex: 1; overflow-y: auto; padding: 20px 24px 40px; }

/* ---------- 分类区块 ---------- */
.section { margin-bottom: 28px; }
.section-head {
  display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 1px dashed var(--line);
}
.section-head h3 { font-size: 15px; font-weight: 700; }
.section-head .count { font-size: 12px; color: var(--muted); }
.section-head .sub { font-size: 12px; color: var(--muted); margin-left: auto; }

/* ---------- 文件卡片 ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.file-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; transition: all .15s;
}
.file-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.fc-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.fc-icon { font-size: 18px; flex-shrink: 0; }
.fc-name {
  font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer; min-width: 0;
}
.fc-name:hover { color: var(--accent); text-decoration: none; }
.fc-meta { display: flex; gap: 8px; font-size: 11px; color: var(--muted); font-family: var(--mono); flex-wrap: wrap; }
.tag {
  font-size: 10px; padding: 1px 7px; border-radius: 4px; font-family: var(--mono);
  background: var(--panel2); color: var(--muted); border: 1px solid var(--line);
}
.tag.html { color: #f97316; } .tag.md { color: #38bdf8; } .tag.json { color: #a78bfa; }
.tag.png, .tag.jpg { color: #34d399; } .tag.zip { color: #fbbf24; }
.fc-actions { display: flex; gap: 6px; margin-top: auto; }

/* ---------- 图库 ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.g-item {
  position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--line);
  background: var(--panel); cursor: zoom-in; aspect-ratio: 4/3;
}
.g-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.g-item:hover img { transform: scale(1.05); }
.g-item .g-cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 6px 4px;
  background: linear-gradient(transparent, rgba(0,0,0,.75)); font-size: 10px; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 13px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(5,8,13,.7); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 60;
}
.modal {
  width: 100%; max-width: 860px; max-height: 88vh; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column;
  box-shadow: var(--shadow); overflow: hidden; animation: rise .2s ease;
}
.modal-sm { max-width: 380px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 14px;
}
.modal-body { padding: 16px; overflow-y: auto; font-size: 13px; line-height: 1.7; }
.modal-body pre { font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-all; color: var(--text); }
.modal-body .md-body h1, .modal-body .md-body h2, .modal-body .md-body h3 { margin: 14px 0 8px; line-height: 1.4; }
.modal-body .md-body h1 { font-size: 19px; } .modal-body .md-body h2 { font-size: 16px; } .modal-body .md-body h3 { font-size: 14px; }
.modal-body .md-body p { margin: 8px 0; }
.modal-body .md-body ul, .modal-body .md-body ol { margin: 8px 0 8px 22px; }
.modal-body .md-body code { font-family: var(--mono); background: var(--bg); padding: 1px 6px; border-radius: 4px; font-size: 12px; }
.modal-body .md-body pre { background: var(--bg); padding: 12px; border-radius: 8px; overflow-x: auto; margin: 10px 0; }
.modal-body .md-body blockquote { border-left: 3px solid var(--accent); padding-left: 12px; color: var(--muted); margin: 8px 0; }
.modal-body .md-body table { border-collapse: collapse; margin: 10px 0; font-size: 12px; }
.modal-body .md-body th, .modal-body .md-body td { border: 1px solid var(--line); padding: 5px 10px; }
.modal-body .md-body th { background: var(--bg2); }
.modal-body .md-body hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }
.pwd-body { display: flex; flex-direction: column; gap: 4px; }

/* ---------- 灯箱 ---------- */
.lightbox {
  position: fixed; inset: 0; background: rgba(3,5,9,.92); z-index: 80;
  display: flex; align-items: center; justify-content: center; padding: 40px;
}
.lb-img { max-width: 88%; max-height: 82vh; border-radius: 8px; box-shadow: var(--shadow); object-fit: contain; }
.lb-btn {
  position: absolute; border: 1px solid var(--line); background: rgba(13,17,23,.7); color: #fff;
  width: 42px; height: 42px; border-radius: 50%; font-size: 20px; cursor: pointer; z-index: 5;
}
.lb-btn:hover { background: var(--panel2); }
.lb-close { top: 18px; right: 18px; }
.lb-prev { left: 20px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 20px; top: 50%; transform: translateY(-50%); }
.lb-cap { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); color: var(--muted); font-size: 12px; font-family: var(--mono); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 99;
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 20px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px;
  animation: rise .25s ease;
}
.toast.ok { border-color: var(--accent2); color: var(--accent2); }
.toast.err { border-color: var(--danger); color: var(--danger); }

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #374566; }

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; min-width: 0; max-height: 40vh; border-right: none; border-bottom: 1px solid var(--line); }
  .cat-nav { flex-direction: row; flex-wrap: wrap; overflow-x: auto; }
  .cat-item { flex: none; }
  .side-foot { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .topbar { padding: 12px 16px; }
  .content { padding: 14px 14px 30px; }
}
