:root {
  --bg: #08090d;
  --bg-soft: #0d1016;
  --panel: #11151d;
  --panel-2: #151a24;
  --line: #222a38;
  --line-soft: #1a212c;
  --text: #e8edf6;
  --muted: #8b95a7;
  --muted-2: #697386;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, .14);
  --pdf: #e5484d;
  --txt: #2ea36b;
  --ebook: #9a6bf0;
  --doc: #e0a52c;
  --comic: #17a2c4;
  --archive: #7c8698;
  --audio: #f07a3e;
  --other: #6b7688;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

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

body {
  background:
    radial-gradient(900px 420px at 12% -10%, rgba(79, 140, 255, .14), transparent 60%),
    radial-gradient(700px 380px at 88% 0%, rgba(154, 107, 240, .1), transparent 55%),
    var(--bg);
  color: var(--text);
  font: 15px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

button, input, select { font: inherit; color: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px clamp(14px, 3vw, 34px);
  background: rgba(8, 9, 13, .82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 21px;
  background: linear-gradient(145deg, #1b2436, #121723);
  border: 1px solid #26314a;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .35);
  flex: none;
}

.brand h1 { margin: 0; font-size: 17px; letter-spacing: .3px; }
.brand p { margin: 0; font-size: 12px; color: var(--muted-2); }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.search-wrap {
  display: flex;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 4px 0 12px;
  transition: border-color .18s;
}

.search-wrap:focus-within { border-color: #3a5793; }

.search-wrap input {
  width: clamp(150px, 26vw, 300px);
  padding: 9px 6px;
  background: transparent;
  border: 0;
  outline: none;
}

.search-wrap input::placeholder { color: var(--muted-2); }

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.icon-btn:hover { color: var(--text); background: var(--panel-2); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  transition: filter .18s, transform .18s, background .18s;
}

.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.ghost:hover { background: var(--panel-2); }
.btn.danger { background: #c8383f; }
.btn.tiny { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }

main {
  padding: 18px clamp(14px, 3vw, 34px) 60px;
  max-width: 1320px;
  margin: 0 auto;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 2px 10px;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(17, 21, 29, .7);
  color: var(--muted);
  cursor: pointer;
  font-size: 13.5px;
  transition: all .16s;
}

.tab:hover { color: var(--text); border-color: #2f3b52; }

.tab.active {
  color: #fff;
  background: linear-gradient(160deg, rgba(79, 140, 255, .22), rgba(79, 140, 255, .08));
  border-color: #3f6fd8;
}

.tab .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--other); }
.tab .n { color: var(--muted-2); font-variant-numeric: tabular-nums; font-size: 12px; }
.tab.active .n { color: #b9cdfb; }

.tagbar {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  max-height: 106px;
  overflow-y: auto;
  padding: 4px 2px 12px;
}

.chip {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, .045);
  color: #aab4c6;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}

.chip:hover { color: #fff; background: rgba(255, 255, 255, .09); }
.chip.on { background: var(--accent-soft); color: #b9cdfb; border-color: #3a5fae; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 2px 14px;
  color: var(--muted);
  font-size: 13px;
}

.toolbar .grow { flex: 1; }

.link-btn {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font-size: 13px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 14px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: linear-gradient(170deg, var(--panel), #0e121a);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform .18s, border-color .18s, box-shadow .18s;
}

.card:hover {
  transform: translateY(-3px);
  border-color: #2e3b55;
  box-shadow: 0 16px 34px rgba(0, 0, 0, .38);
}

.cover {
  position: relative;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #0b0f16;
}

.cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 45%, rgba(6, 8, 12, .85));
}

.cover .ext {
  position: relative;
  z-index: 1;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #fff;
  opacity: .92;
  text-shadow: 0 6px 20px rgba(0, 0, 0, .5);
}

.cover .badge {
  position: absolute;
  top: 9px;
  left: 9px;
  z-index: 2;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  letter-spacing: .4px;
  background: rgba(0, 0, 0, .55);
  border: 1px solid rgba(255, 255, 255, .14);
  color: #fff;
}

.cover .size {
  position: absolute;
  right: 9px;
  bottom: 9px;
  z-index: 2;
  font-size: 11px;
  color: #c7d0e0;
}

.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 5px; }

.card-title {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.8em;
}

.card-meta { font-size: 11.5px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.card-tags { display: flex; gap: 4px; flex-wrap: wrap; max-height: 20px; overflow: hidden; }
.card-tags span {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, .05);
  color: #98a3b7;
}

.empty {
  padding: 64px 20px;
  text-align: center;
  color: var(--muted);
}

.empty .big { font-size: 42px; margin-bottom: 10px; }
.empty h3 { margin: 0 0 6px; font-size: 16px; color: var(--text); }
.empty p { margin: 0 auto; max-width: 440px; font-size: 13px; }

.loading {
  padding: 40px;
  text-align: center;
  color: var(--muted-2);
  font-size: 13px;
}

.sentinel { height: 10px; }

/* ------------------------------------------------------------- 详情抽屉 --- */

.drawer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  justify-content: flex-end;
  background: rgba(3, 5, 9, .6);
  backdrop-filter: blur(3px);
}

.drawer[hidden] { display: none; }

.drawer-panel {
  width: min(92vw, 430px);
  height: 100%;
  background: #0c1017;
  border-left: 1px solid var(--line);
  padding: 22px;
  overflow-y: auto;
  box-shadow: -20px 0 60px rgba(0, 0, 0, .5);
  animation: slidein .22s ease;
}

@keyframes slidein { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }

.drawer-head { display: flex; align-items: flex-start; gap: 12px; }

.cover-lg {
  width: 88px;
  height: 118px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 20px;
  color: #fff;
  text-transform: uppercase;
  flex: none;
  box-shadow: 0 14px 30px rgba(0, 0, 0, .4);
}

.drawer h2 { margin: 0; font-size: 19px; line-height: 1.35; }
.drawer .sub { color: var(--muted); font-size: 12.5px; margin-top: 5px; }

.close-btn { margin-left: auto; flex: none; }

.meta-list { margin: 18px 0 0; display: grid; grid-template-columns: 78px 1fr; gap: 8px 10px; font-size: 13px; }
.meta-list dt { color: var(--muted-2); }
.meta-list dd { margin: 0; word-break: break-all; }

.tag-cloud { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 6px; }

.actions { margin-top: 20px; display: flex; flex-direction: column; gap: 8px; }

.actions .btn { justify-content: center; }
.actions .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.note {
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #101722;
  border: 1px solid #1f2a3a;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.admin-box { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.admin-box h4 { margin: 0 0 10px; font-size: 12px; color: var(--muted-2); letter-spacing: .5px; text-transform: uppercase; }
.admin-box .btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- 登录弹窗 --- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(2, 4, 8, .72);
  backdrop-filter: blur(4px);
  padding: 18px;
}

.modal[hidden] { display: none; }

.modal-card {
  width: min(94vw, 380px);
  padding: 24px;
  border-radius: 18px;
  background: linear-gradient(175deg, #131926, #0b0e14);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.modal-card h2 { margin: 0 0 4px; font-size: 18px; }
.modal-card p { margin: 0 0 16px; color: var(--muted); font-size: 13px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted-2); margin-bottom: 5px; }
.field input {
  width: 100%;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #080b11;
  outline: none;
  letter-spacing: 2px;
}
.field input:focus { border-color: #3a5793; }
.field input::placeholder { letter-spacing: 0; color: var(--muted-2); }

.err { color: #ff7b72; font-size: 12.5px; min-height: 18px; margin: 0 0 6px; }

/* ---------------------------------------------------------------- TXT 阅读 --- */

.reader {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: #07090d;
  display: flex;
  flex-direction: column;
}

.reader[hidden] { display: none; }

.reader-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(10, 13, 19, .95);
}

.reader-head .title { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-head .grow { flex: 1; }

.reader-body {
  flex: 1;
  overflow-y: auto;
  padding: 26px clamp(16px, 6vw, 90px) 90px;
}

.reader-text {
  max-width: 760px;
  margin: 0 auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 17px;
  line-height: 1.95;
  color: #d7deea;
  font-family: "Songti SC", "Noto Serif SC", Georgia, serif;
}

.reader-tip { max-width: 760px; margin: 0 auto 18px; color: var(--muted-2); font-size: 12px; }

/* -------------------------------------------------------------------- 其它 --- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%) translateY(12px);
  background: #1b2230;
  border: 1px solid #2c3950;
  color: #dfe7f5;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all .22s;
  z-index: 100;
  max-width: 86vw;
}

.toast.show { opacity: 1; transform: translateX(-50%); }

footer {
  padding: 26px clamp(14px, 3vw, 34px) 40px;
  color: var(--muted-2);
  font-size: 12px;
  text-align: center;
  border-top: 1px solid var(--line-soft);
}

.setup {
  margin: 0 auto;
  max-width: 760px;
  padding: 22px;
  border-radius: 16px;
  background: #0e131c;
  border: 1px solid #24304a;
  font-size: 13px;
  line-height: 1.8;
  color: #b9c3d4;
}

.setup h3 { margin: 0 0 8px; color: #fff; font-size: 16px; }
.setup ol { margin: 0; padding-left: 20px; }
.setup code { background: #0a0e15; padding: 1px 5px; border-radius: 4px; color: #9db6e8; }

@media (max-width: 760px) {
  .brand h1 { font-size: 15px; }
  .brand p { display: none; }
  .search-wrap input { width: 100%; }
  .top-actions { width: 100%; }
  .search-wrap { flex: 1; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .drawer-panel { width: 100%; border-left: 0; }
  .reader-text { font-size: 16px; }
}
