/* ------------------------------------------------------------------
   本地图库主题：仿 OnlyHaven（cum.st）的深色归档站风格
   ------------------------------------------------------------------ */

:root {
  --bg: #08080b;
  --bg-soft: #0e0e13;
  --surface: #14141b;
  --surface-2: #1b1b24;
  --surface-3: #22222d;
  --border: #26262f;
  --border-soft: #1e1e27;
  --text: #ececf2;
  --text-dim: #b9b9c6;
  --muted: #85859a;
  --accent: #f0629a;
  --accent-2: #9b5cff;
  --accent-soft: rgba(240, 98, 154, .14);
  --ok: #48d597;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 40px rgba(0, 0, 0, .45);
  --sidebar-w: 248px;
  --font: "Inter", "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

[data-theme="light"] {
  --bg: #f7f7fa;
  --bg-soft: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f1f6;
  --surface-3: #e7e7ef;
  --border: #e2e2ea;
  --border-soft: #ececf2;
  --text: #17171f;
  --text-dim: #44444f;
  --muted: #71717f;
  --accent-soft: rgba(240, 98, 154, .12);
  --shadow: 0 16px 34px rgba(24, 24, 40, .10);
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
img, video { max-width: 100%; display: block; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--accent); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 99px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ---------------------------------------------------------------- 布局 */

.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 18px;
  padding: 20px 14px;
  background: var(--bg-soft);
  border-right: 1px solid var(--border-soft);
  overflow-y: auto;
  z-index: 40;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 12px; }
.brand-mark { display: grid; place-items: center; filter: drop-shadow(0 6px 14px rgba(240, 98, 154, .35)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 16px; letter-spacing: .2px; }
.brand-text small { color: var(--muted); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 16px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-title {
  font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); padding: 6px 10px 4px;
}
.nav a, .nav-button {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 13.5px;
  background: none; border: 0; text-align: left; width: 100%;
  transition: background .16s ease, color .16s ease;
}
.nav a:hover, .nav-button:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.sidebar-foot {
  margin-top: auto; padding: 12px 10px 4px;
  border-top: 1px solid var(--border-soft);
  color: var(--muted); font-size: 11.5px; line-height: 1.7;
}
.sidebar-foot b { color: var(--text-dim); font-weight: 600; }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}

.menu-btn { display: none; }

.search {
  display: flex; align-items: center; gap: 8px;
  flex: 0 1 420px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px;
  color: var(--muted);
  transition: border-color .16s ease, box-shadow .16s ease;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--text); font-size: 13.5px; }
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { filter: grayscale(1) opacity(.6); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.pill {
  padding: 5px 11px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--muted); font-size: 11.5px; white-space: nowrap;
}
.icon-btn {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-dim);
  transition: color .16s ease, border-color .16s ease;
}
.icon-btn:hover { color: var(--text); border-color: var(--muted); }

.view { flex: 1; width: 100%; max-width: 1440px; margin: 0 auto; padding: 26px 32px 60px; outline: none; }

.foot {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 16px 32px 26px; color: var(--muted); font-size: 11.5px;
  border-top: 1px solid var(--border-soft);
}

/* ---------------------------------------------------------------- 通用 */

h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 26px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0; }
time { font-variant-numeric: tabular-nums; }

.crumbs {
  display: flex; align-items: center; flex-wrap: wrap; gap: 7px;
  margin-bottom: 18px; color: var(--muted); font-size: 12.5px;
}
.crumbs a:hover { color: var(--text); }
.crumbs .sep { opacity: .5; }
.crumbs .current { color: var(--text-dim); max-width: 60ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin: 4px 0 16px;
}
.section-head .count { color: var(--muted); font-size: 12px; margin-left: 8px; font-weight: 400; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 15px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-dim);
  font-size: 13px; transition: background .16s ease, color .16s ease, border-color .16s ease;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; border-color: transparent; font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.07); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 12px;
  transition: border-color .16s ease, color .16s ease;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

.empty {
  display: grid; place-items: center; gap: 10px;
  padding: 70px 20px; text-align: center; color: var(--muted);
  border: 1px dashed var(--border); border-radius: var(--radius);
  background: var(--surface);
}
.empty strong { color: var(--text-dim); font-size: 15px; }
.empty code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  background: var(--surface-2); padding: 2px 7px; border-radius: 6px; font-size: 12px;
}

.loading { display: grid; place-items: center; padding: 90px 0; color: var(--muted); }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- 首页 */

.hero {
  position: relative; overflow: hidden;
  padding: 34px 30px; margin-bottom: 26px;
  border: 1px solid var(--border); border-radius: 20px;
  background:
    radial-gradient(900px 260px at 8% -20%, rgba(240, 98, 154, .28), transparent 70%),
    radial-gradient(700px 240px at 92% 120%, rgba(155, 92, 255, .22), transparent 70%),
    var(--surface);
}
.hero h1 { font-size: clamp(24px, 3vw, 34px); margin-bottom: 8px; }
.hero p { color: var(--text-dim); font-size: 13.5px; }
.hero .hero-stats { display: flex; flex-wrap: wrap; gap: 22px; margin-top: 20px; }
.hero .hero-stats div { display: flex; flex-direction: column; }
.hero .hero-stats b { font-size: 20px; font-weight: 650; letter-spacing: -.02em; }
.hero .hero-stats span { color: var(--muted); font-size: 11.5px; letter-spacing: .04em; }

.creator-grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.creator-card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.creator-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: var(--shadow); }
.cc-media { position: relative; aspect-ratio: 16 / 10; background: var(--surface-2); overflow: hidden; }
.cc-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.creator-card:hover .cc-media img { transform: scale(1.04); }
.cc-empty { width: 100%; height: 100%; background: linear-gradient(135deg, var(--surface-2), var(--surface-3)); }
.cc-count {
  position: absolute; right: 10px; bottom: 10px;
  padding: 3px 9px; border-radius: 999px;
  background: rgba(8, 8, 11, .72); color: #fff; font-size: 11px;
  backdrop-filter: blur(6px);
}
.cc-body { display: flex; align-items: center; gap: 11px; padding: 12px 14px 14px; }
.cc-avatar {
  width: 40px; height: 40px; flex: none; border-radius: 50%;
  display: grid; place-items: center; overflow: hidden;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 700; font-size: 15px;
  border: 2px solid var(--surface);
}
.cc-avatar img { width: 100%; height: 100%; object-fit: cover; }
.cc-text { min-width: 0; display: flex; flex-direction: column; }
.cc-text strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-text small { color: var(--muted); font-size: 11.5px; }

/* ---------------------------------------------------------------- 创作者页 */

.creator-head {
  display: flex; align-items: flex-end; gap: 20px;
  padding: 24px; margin-bottom: 20px;
  border: 1px solid var(--border); border-radius: 20px;
  background:
    radial-gradient(600px 200px at 100% 0%, rgba(155, 92, 255, .18), transparent 70%),
    var(--surface);
}
.creator-avatar {
  width: 96px; height: 96px; flex: none; border-radius: 22px; overflow: hidden;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 34px; font-weight: 700;
  border: 3px solid var(--surface-2);
}
.creator-avatar img { width: 100%; height: 100%; object-fit: cover; }
.creator-info { min-width: 0; flex: 1; }
.creator-info h1 { font-size: 28px; margin-bottom: 6px; overflow-wrap: anywhere; }
.creator-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--muted); font-size: 12.5px; }
.creator-meta b { color: var(--text-dim); font-weight: 600; }
.creator-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 12px 14px; margin-bottom: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.toolbar .field { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.toolbar input[type="search"], .toolbar select {
  padding: 7px 11px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  outline: none; font-size: 13px;
}
.toolbar input[type="search"] { width: 200px; }
.toolbar input[type="search"]:focus, .toolbar select:focus { border-color: var(--accent); }
.seg { display: inline-flex; padding: 3px; gap: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; }
.seg button {
  padding: 5px 12px; border-radius: 999px; border: 0; background: none;
  color: var(--muted); font-size: 12.5px;
}
.seg button.active { background: var(--surface-3); color: var(--text); font-weight: 600; }
.toolbar .spacer { flex: 1; }

/* 帖子网格 */
.post-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.post-card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.post-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: var(--shadow); }
.pc-media { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); overflow: hidden; }
.pc-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.post-card:hover .pc-media img { transform: scale(1.05); }
.pc-media img.broken { opacity: .25; }
.badge {
  position: absolute; top: 9px; right: 9px;
  min-width: 24px; height: 22px; padding: 0 7px; border-radius: 999px;
  display: grid; place-items: center;
  background: rgba(8, 8, 11, .74); color: #fff;
  font-size: 11px; font-weight: 600; backdrop-filter: blur(6px);
}
.kind-badge {
  position: absolute; top: 9px; left: 9px;
  display: flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px;
  background: rgba(8, 8, 11, .74); color: #fff; font-size: 10.5px;
  backdrop-filter: blur(6px);
}
.pc-meta { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; }
.pc-meta time { color: var(--muted); font-size: 11.5px; }
.pc-meta .pc-title {
  color: var(--text-dim); font-size: 12.5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 2.6em;
}

/* ---------------------------------------------------------------- 帖子页 */

.post-page { max-width: 940px; margin: 0 auto; }
.post-nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.post-nav .btn { max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-nav .btn small { color: var(--muted); }

.media-stack { display: flex; flex-direction: column; gap: 12px; }
.media-item {
  position: relative; overflow: hidden; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  cursor: zoom-in;
}
.media-item img { width: 100%; height: auto; }
.media-item.video { cursor: default; }
.media-item video { width: 100%; height: auto; background: #000; }
.media-item .media-index {
  position: absolute; left: 10px; top: 10px;
  padding: 2px 8px; border-radius: 999px;
  background: rgba(8, 8, 11, .7); color: #fff; font-size: 11px;
  backdrop-filter: blur(6px);
}

.post-foot {
  margin-top: 20px; padding: 18px 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.post-foot-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; color: var(--muted); font-size: 12.5px; }
.post-foot-top b { color: var(--text-dim); }
.post-caption { margin-top: 14px; color: var(--text-dim); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.post-caption.empty-text { color: var(--muted); font-style: italic; }

/* ---------------------------------------------------------------- 标签 / 关于 */

.tag-cloud { display: flex; flex-wrap: wrap; gap: 9px; }
.tag-cloud .chip { font-size: 12.5px; padding: 6px 12px; }
.tag-cloud .chip b { color: var(--accent); font-weight: 600; }

.about-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stat-card { padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.stat-card span { color: var(--muted); font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; }
.stat-card b { display: block; margin-top: 6px; font-size: 24px; font-weight: 650; letter-spacing: -.02em; }
.prose { color: var(--text-dim); font-size: 13.5px; line-height: 1.8; }
.prose code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: 12px; }
.prose ul { margin: 8px 0 0; padding-left: 20px; }

/* ---------------------------------------------------------------- 灯箱 */

.scrim {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0, 0, 0, .55); backdrop-filter: blur(2px);
}

.lightbox {
  position: fixed; inset: 0; z-index: 100;
  display: grid; grid-template-rows: auto 1fr auto;
  background: rgba(6, 6, 9, .96);
  color: #fff;
}
.lightbox[hidden] { display: none; }
.lb-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; font-size: 12.5px; color: rgba(255, 255, 255, .72);
}
.lb-actions { display: flex; align-items: center; gap: 8px; }
.lb-btn {
  padding: 6px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .16);
  color: #fff; font-size: 12.5px;
}
.lb-btn:hover { background: rgba(255, 255, 255, .2); }
.lb-stage {
  display: grid; place-items: center; overflow: hidden; padding: 0 60px;
}
.lb-stage img, .lb-stage video { max-width: 100%; max-height: calc(100vh - 150px); object-fit: contain; border-radius: 8px; }
.lb-nav {
  position: fixed; top: 50%; transform: translateY(-50%);
  width: 44px; height: 74px; border-radius: 12px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .12);
  color: #fff; font-size: 26px; line-height: 1;
}
.lb-nav:hover { background: rgba(255, 255, 255, .18); }
.lb-prev { left: 14px; }
.lb-next { right: 14px; }
.lb-caption {
  padding: 12px 20px 18px; text-align: center;
  color: rgba(255, 255, 255, .78); font-size: 12.5px;
  max-height: 90px; overflow: auto; white-space: pre-wrap;
}
.lb-counter { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- 响应式 */

@media (max-width: 980px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; left: 0; top: 0; width: 270px;
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .menu-btn { display: grid; }
  .view { padding: 20px 18px 48px; }
  .topbar { padding: 10px 14px; }
  .foot { padding: 14px 18px 22px; }
  .creator-head { flex-direction: column; align-items: flex-start; gap: 14px; padding: 18px; }
  .creator-avatar { width: 72px; height: 72px; border-radius: 18px; font-size: 26px; }
  .creator-info h1 { font-size: 22px; }
  .lb-stage { padding: 0 10px; }
  .lb-prev { left: 6px; }
  .lb-next { right: 6px; }
  .lb-nav { width: 36px; height: 60px; }
  .pill { display: none; }
}

/* ---------------------------------------------------------------- 分页 */

.pager {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 6px; margin: 26px 0 6px;
}
.pager button {
  min-width: 38px; height: 34px; padding: 0 12px;
  border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-dim);
  font-size: 13px; font-variant-numeric: tabular-nums;
  transition: border-color .16s ease, color .16s ease, background .16s ease;
}
.pager button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pager button.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent; color: #fff; font-weight: 650;
}
.pager button:disabled { opacity: .35; cursor: not-allowed; }
.pager-gap { color: var(--muted); padding: 0 2px; user-select: none; }
.pager-total { color: var(--muted); font-size: 12px; margin-left: 8px; }

@media (max-width: 560px) {
  .post-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .creator-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .hero { padding: 22px 18px; }
  .toolbar input[type="search"] { width: 100%; }
  .pager button { min-width: 34px; height: 32px; padding: 0 9px; }
  .pager-total { width: 100%; margin: 6px 0 0; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
