:root {
  color-scheme: dark;
  --bg: #000000;
  --bg-elevated: #131316;
  --bg-hover: #1a1a1f;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f4f4f5;
  --muted: #71717a;
  --subtle: #52525b;
  --accent: #ffffff;
  --brand: #ffa8c5;
  --brand-dark: #e889ab;
  --brand-text: #08080a;
  --copy-btn-bg: rgba(20, 20, 22, 0.95);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: -0.01em;
  scroll-behavior: smooth;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: 0; background: none; padding: 0; }

/* ── Topbar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 48px;
  padding: 0 32px;
  height: 60px;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(16px);
}

.brand { display: flex; align-items: center; gap: 8px; }
.brand-logo { width: 28px; height: 28px; flex: 0 0 auto; display: block; }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; }

.primary-nav {
  position: relative;
  display: flex;
  flex: 1;
  align-self: stretch;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.primary-nav::-webkit-scrollbar { display: none; }
.primary-nav button {
  position: relative;
  z-index: 1;
  padding: 6px 12px;
  border-radius: 999px;
  background: transparent;
  color: rgba(244, 244, 245, 0.72);
  font-size: 14px;
  white-space: nowrap;
  transition: color 200ms ease;
}
.primary-nav button:hover { color: var(--text); }
.primary-nav button.active { color: var(--brand-text); font-weight: 600; }

.nav-indicator {
  position: absolute;
  left: 0; top: 50%;
  width: 0; height: 32px;
  background: var(--brand);
  pointer-events: none;
  border-radius: 999px;
  will-change: transform, width;
  transform: translateY(-50%);
}

.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.topbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 999px;
  color: var(--muted);
  transition: color 200ms, background 200ms;
}
.topbar-btn:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.topbar-btn svg { width: 18px; height: 18px; display: block; }

/* Sync status */
.sync-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  font-size: 12px;
  color: var(--muted);
}
.sync-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--muted);
}
.sync-dot.synced { background: #4ade80; }
.sync-dot.syncing { background: #fb923c; animation: pulse 1s infinite; }
.sync-dot.error { background: #f87171; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* ── Search Overlay ── */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 15vh;
}
.search-overlay[hidden] { display: none; }

.search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(680px, 90vw);
  padding: 14px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--bg-elevated);
}
.search-box:focus-within { border-color: var(--brand); }

.search-box input {
  flex: 1;
  background: none;
  border: 0;
  outline: none;
  color: var(--text);
  font-size: 16px;
}
.search-box input::placeholder { color: var(--muted); }

.search-close {
  color: var(--muted);
  transition: color 200ms;
}
.search-close:hover { color: var(--text); }
.search-close svg { width: 18px; height: 18px; display: block; }

.search-results {
  width: min(680px, 90vw);
  margin-top: 8px;
  max-height: 60vh;
  overflow-y: auto;
}

.search-result-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 150ms;
  align-items: center;
}
.search-result-item:hover { background: var(--bg-elevated); }
.search-result-thumb {
  width: 56px; height: 56px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg-elevated);
  flex-shrink: 0;
}
.search-result-text { flex: 1; min-width: 0; }
.search-result-title { font-size: 14px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-cat { font-size: 12px; color: var(--muted); margin-top: 2px; }
.search-result-preview { font-size: 12px; color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Layout ── */
.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  flex: 1 0 auto;
}
.layout[data-view="home"] { grid-template-columns: 1fr; }
.layout[data-view="home"] .sidebar { display: none; }

/* ── Sidebar ── */
.sidebar {
  position: sticky;
  top: 60px;
  align-self: start;
  height: calc(100vh - 60px);
  padding: 18px 12px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { border-radius: 999px; background: rgba(255,255,255,0.08); }

.sub-wrap { position: relative; }
.sub-pill {
  position: absolute; top: 0; left: 0;
  width: 0; height: 0;
  border-radius: 8px;
  background: var(--brand);
  pointer-events: none;
  opacity: 0;
  z-index: 0;
  will-change: transform, width, height;
}
.sub-nav { position: relative; z-index: 1; margin: 0; padding: 0; list-style: none; }
.sub-nav li button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: transparent;
  color: rgba(244, 244, 245, 0.72);
  font-size: 14px;
  text-align: left;
  transition: color 200ms;
}
.sub-nav li button::before {
  content: "";
  display: inline-block;
  width: 4px; height: 4px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.5;
}
.sub-nav li button:hover { color: var(--text); }
.sub-nav li button.active { color: var(--brand-text); font-weight: 600; }

/* ── Content ── */
.content { padding: 24px 32px 80px; }

/* ── Home View ── */
.home { width: min(1560px, 100%); margin: 0 auto; }
.home-hero { padding: 72px 0 56px; text-align: center; }
.home-hero h1 {
  max-width: 820px;
  margin: 0 auto;
  font-size: clamp(28px, 3vw, 40px);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
}
.home-hero p {
  max-width: 520px;
  margin: 18px auto 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.home-sections { display: flex; flex-direction: column; gap: 64px; padding-top: 16px; }
.home-section { display: flex; flex-direction: column; gap: 22px; }
.home-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.home-section-head h2 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.home-view-all { background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; transition: color 200ms; }
.home-view-all:hover { color: var(--text); }
.home-section-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: start; gap: 18px; }

/* Home tiles */
.home-tile {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: var(--bg-elevated);
  cursor: pointer;
  aspect-ratio: 1;
  will-change: transform;
}
.home-tile::before {
  content: "";
  position: absolute; inset: 0; z-index: 0;
  background: linear-gradient(110deg, var(--bg-elevated) 30%, rgba(255,255,255,0.045) 50%, var(--bg-elevated) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
  transition: opacity 0.45s ease;
}
.home-tile.is-loaded::before { opacity: 0; animation: none; }
.home-tile::after {
  content: "";
  position: absolute; inset: 0; z-index: 2;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
  pointer-events: none;
}
.home-tile img {
  position: relative; z-index: 1;
  display: block; width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: transform 320ms ease, opacity 0.45s ease;
}
.home-tile.is-loaded img { opacity: 1; }
.home-tile:hover img { transform: scale(1.04); }

/* ── Category View ── */
.category-header { margin-bottom: 28px; }
.category-header h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 8px; }
.category-header p { color: var(--muted); font-size: 14px; margin: 0; }

/* ── Grid ── */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid[data-sub="KV海报"] { gap: 20px; grid-template-columns: repeat(auto-fill, minmax(500px, 1fr)); }

/* Cards */
.card {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  background: var(--bg-elevated);
  cursor: pointer;
  will-change: transform;
}
.card::before {
  content: "";
  position: absolute; inset: 0; z-index: 0;
  background: linear-gradient(110deg, var(--bg-elevated) 30%, rgba(255,255,255,0.045) 50%, var(--bg-elevated) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
  transition: opacity 0.45s ease;
}
.card.is-loaded::before { opacity: 0; animation: none; }
.card::after {
  content: "";
  position: absolute; inset: 0; z-index: 3;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1.5px rgba(255,255,255,0.08), inset 0 1px 0 rgba(255,255,255,0.02);
  pointer-events: none;
}
.card img {
  position: relative; z-index: 1;
  display: block; width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.45s ease;
}
.card.is-loaded img { opacity: 1; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .home-tile::before, .card::before { animation: none; }
  .home-tile img, .card img, .lightbox-image { transition: none; }
}

/* Card overlay */
.card-overlay {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 16px;
  background: linear-gradient(180deg, transparent 35%, rgba(0,0,0,0.92) 100%);
  opacity: 0;
  transition: opacity 220ms ease;
}
.card:hover .card-overlay, .card:focus-within .card-overlay { opacity: 1; }

.card-prompt {
  display: -webkit-box;
  margin: 0 0 12px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  color: rgba(255,255,255,0.88);
  font-size: 13px;
  line-height: 1.6;
  -webkit-line-clamp: 3;
  line-clamp: 3;
}

.copy-btn {
  align-self: flex-start;
  padding: 7px 12px;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 999px;
  background: rgba(0,0,0,0.4);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  backdrop-filter: blur(8px);
  transition: background 160ms, border-color 160ms;
}
.copy-btn:hover { background: #fff; border-color: #fff; color: #000; }

/* Empty state */
.empty-state {
  grid-column: 1 / -1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; min-height: 320px; padding: 64px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
  background: rgba(255,255,255,0.015);
  text-align: center;
}
.empty-state-text { margin: 0; color: var(--muted); font-size: 14px; }

/* ── Lightbox ── */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 40px 72px;
  background: rgba(0,0,0,0.88);
  backdrop-filter: blur(18px);
  opacity: 0; visibility: hidden;
  will-change: opacity;
}
.lightbox:not([hidden]) { visibility: visible; }
.lightbox[data-open="true"] { opacity: 1; }

.lightbox-stage { position: relative; display: flex; width: 100%; height: 100%; align-items: center; justify-content: center; }

.lightbox-figure {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 360px;
  align-items: stretch;
  gap: 28px;
  margin: 0;
  width: min(1200px, 100%);
  height: min(100%, 90vh);
}

.lightbox-image-wrap {
  position: relative;
  display: flex;
  min-width: 0; min-height: 0;
  align-items: center;
  justify-content: center;
}
.lightbox-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.04);
  user-select: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}
.lightbox-image.is-loaded { opacity: 1; }
.lightbox-image-wrap.is-loading::before {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 36px; height: 36px;
  margin: -18px 0 0 -18px;
  border: 2px solid rgba(255,255,255,0.18);
  border-top-color: rgba(255,255,255,0.85);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.lightbox-caption {
  display: flex; flex-direction: column;
  max-height: 100%;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(20,20,22,0.95);
  overflow: hidden;
}
.lightbox-caption-head {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.lightbox-caption-title { color: var(--text); font-size: 13px; font-weight: 600; }
.lightbox-prompt {
  flex: 1 1 auto;
  margin: 0; padding-right: 8px;
  color: rgba(255,255,255,0.86);
  font-size: 13px; line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.18) transparent;
}
.lightbox-prompt::-webkit-scrollbar { width: 6px; }
.lightbox-prompt::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.16); border-radius: 999px; }

.lightbox-actions {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--line);
}
.lightbox-counter { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.lightbox-copy {
  padding: 7px 14px;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 999px;
  background: rgba(0,0,0,0.4);
  color: #fff;
  font-size: 12px; font-weight: 600;
  backdrop-filter: blur(8px);
  transition: background 160ms, border-color 160ms, color 160ms;
}
.lightbox-copy:hover { background: #fff; border-color: #fff; color: #000; }
.lightbox-source { font-size: 12px; color: var(--muted); }

/* Lightbox nav buttons */
.lightbox-close, .lightbox-nav {
  position: absolute; z-index: 2;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 999px;
  background: rgba(20,20,22,0.7);
  color: rgba(255,255,255,0.85);
  backdrop-filter: blur(10px);
  transition: background 160ms, border-color 160ms, color 160ms, transform 160ms;
}
.lightbox-close { top: 18px; right: 18px; width: 40px; height: 40px; }
.lightbox-nav { top: 50%; width: 44px; height: 44px; transform: translateY(-50%); }
.lightbox-nav:hover { background: #fff; border-color: #fff; color: #000; transform: translateY(-50%) scale(1.04); }
.lightbox-close:hover { background: #fff; border-color: #fff; color: #000; }
.lightbox-close svg, .lightbox-nav svg { width: 18px; height: 18px; display: block; }
.lightbox-prev { left: 18px; }
.lightbox-next { right: 18px; }
.lightbox-nav[disabled] { opacity: 0.3; cursor: not-allowed; }

body.lightbox-open { overflow: hidden; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 28px; left: 50%; z-index: 200;
  padding: 10px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(20,20,22,0.95);
  color: var(--text);
  font-size: 13px;
  opacity: 0; visibility: hidden;
  transform: translate(-50%, 12px);
  pointer-events: none;
  backdrop-filter: blur(12px);
  will-change: transform, opacity;
  transition: opacity 250ms, visibility 250ms, transform 250ms;
}
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }

/* ── Footer ── */
.footer {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  background: var(--bg);
  padding: 56px 32px 28px;
}
.footer-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 56px;
  width: min(1560px, 100%);
  margin: 0 auto;
  padding-bottom: 40px;
}
.footer-brand { display: flex; flex-direction: column; gap: 14px; }
.footer-brand-mark { display: inline-flex; align-items: center; gap: 10px; }
.footer-brand-mark img { display: block; width: 28px; height: 28px; }
.footer-brand-name { color: var(--text); font-size: 16px; font-weight: 700; letter-spacing: -0.02em; }
.footer-tagline { margin: 0; max-width: 380px; color: var(--muted); font-size: 13px; line-height: 1.75; }
.footer-col { display: flex; flex-direction: column; }
.footer-col-title {
  display: block; margin-bottom: 18px;
  color: var(--subtle); font-size: 12px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.footer-links { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 0; list-style: none; }
.footer-links a, .footer-links button {
  display: inline-block;
  color: var(--muted); font-size: 13px;
  text-align: left; transition: color 200ms;
}
.footer-links a:hover, .footer-links button:hover { color: var(--text); }
.footer-bottom {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  width: min(1560px, 100%); margin: 0 auto;
  padding-top: 24px; border-top: 1px solid var(--line);
  color: var(--subtle); font-size: 12px;
}
.footer-meta { color: var(--subtle); }

/* ── Responsive ── */
@media (max-width: 860px) {
  .topbar { gap: 16px; padding: 0 16px; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sub-nav { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
  .sub-nav::-webkit-scrollbar { display: none; }
  .sub-nav li button::before { display: none; }
  .content { padding: 18px 16px 60px; }
  .home-hero { padding: 44px 0 32px; }
  .home-hero h1 { font-size: clamp(24px, 7vw, 36px); }
  .home-sections { gap: 44px; }
  .home-section-head h2 { font-size: 22px; }
  .home-section-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .lightbox { padding: 56px 12px 16px; }
  .lightbox-figure { grid-template-columns: 1fr; gap: 12px; }
  .lightbox-caption { max-height: 35vh; }
  .lightbox-close { top: 10px; right: 10px; width: 36px; height: 36px; }
  .lightbox-nav { width: 36px; height: 36px; }
  .lightbox-prev { left: 8px; }
  .lightbox-next { right: 8px; }
  .footer { padding: 40px 16px 20px; }
  .footer-inner { grid-template-columns: 1fr; gap: 32px; }
  .footer-tagline { max-width: none; }
  .footer-bottom { flex-direction: column; align-items: flex-start; }
}
