:root, html[data-theme="night"] {
  --bg: #0e1022;
  --bg2: #161833;
  --card: rgba(255, 255, 255, 0.07);
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f5ff;
  --muted: #9aa0c6;
  --brand: #7c6cff;
  --brand2: #ff6aa8;
  --ok: #2ed573;
  --danger: #ff6b6b;
  --glow1: #3a2a6a;
  --glow2: #2a4a7a;
  --topbar: linear-gradient(180deg, rgba(14,16,34,0.92), rgba(14,16,34,0.55));
  --tabs-bg: rgba(16, 18, 40, 0.94);
  --sheet-bg: #151735;
  --player-bg: rgba(28, 22, 58, 0.96);
  --cover-bg: #22254a;
  --poster-bg: #1c1f3d;
  --desc: #d7daf3;
  --user-card: linear-gradient(135deg, rgba(124,108,255,0.25), rgba(255,106,168,0.16));
  --tab-on: #fff;
  --theme-color: #5b4dff;
  --radius: 16px;
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
html[data-theme="day"] {
  --bg: #f4f6fb;
  --bg2: #ffffff;
  --card: #ffffff;
  --line: rgba(30, 40, 80, 0.10);
  --text: #1c2140;
  --muted: #6b7394;
  --brand: #5b4dff;
  --brand2: #e85d9a;
  --ok: #1aa35a;
  --danger: #e24b4b;
  --glow1: #dbe4ff;
  --glow2: #ffe3f0;
  --topbar: linear-gradient(180deg, rgba(244,246,251,0.96), rgba(244,246,251,0.72));
  --tabs-bg: rgba(255, 255, 255, 0.94);
  --sheet-bg: #ffffff;
  --player-bg: rgba(255, 255, 255, 0.96);
  --cover-bg: #e8ecf8;
  --poster-bg: #e8ecf8;
  --desc: #3d4466;
  --user-card: linear-gradient(135deg, rgba(91,77,255,0.12), rgba(232,93,154,0.10));
  --tab-on: #5b4dff;
  --theme-color: #5b4dff;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", sans-serif;
  background: radial-gradient(1200px 600px at 10% -10%, var(--glow1) 0%, transparent 55%),
              radial-gradient(900px 500px at 110% 0%, var(--glow2) 0%, transparent 50%),
              var(--bg);
  color: var(--text);
  overflow: hidden;
  transition: background 0.25s ease, color 0.25s ease;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
#app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  padding: 12px 16px 10px;
  display: flex; align-items: center; gap: 10px;
  background: var(--topbar);
  backdrop-filter: blur(12px);
  z-index: 20;
}
.theme-btn {
  flex: 0 0 auto;
  width: 36px; height: 36px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card);
  display: flex; align-items: center; justify-content: center;
  color: var(--text); cursor: pointer;
}
.theme-btn svg { width: 18px; height: 18px; }
html[data-theme="day"] .icon-moon { display: none; }
html[data-theme="night"] .icon-sun, html:not([data-theme]) .icon-sun { display: none; }
.brand {
  display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0;
}
.brand img { width: 36px; height: 36px; border-radius: 12px; object-fit: cover; }
.brand h1 { font-size: 16px; font-weight: 800; letter-spacing: 0.04em; }
.brand p { font-size: 11px; color: var(--muted); }
.search {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 12px;
}
.search input {
  width: 100%; background: transparent; border: 0; outline: 0;
  font-size: 13px;
}
.content {
  flex: 1; overflow: auto; padding: 8px 14px calc(var(--tab-h) + var(--safe-b) + 18px);
  -webkit-overflow-scrolling: touch;
}
.content.has-player { padding-bottom: calc(var(--tab-h) + var(--safe-b) + 86px); }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: var(--tabs-bg);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
  z-index: 30;
}
.tabs button {
  background: none; border: 0; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 10px;
}
.tabs button.active { color: var(--tab-on); }
.tabs svg { width: 22px; height: 22px; }
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 14px 2px 10px; font-size: 15px; font-weight: 700;
}
.section-title span { color: var(--muted); font-size: 12px; font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; overflow: visible; padding: 4px 0 10px; }
.chips.collapsed { flex-wrap: nowrap; overflow: hidden; }
.chips.collapsed .chip:not([data-all]) { display: none; }
.chip {
  flex: 0 0 auto; padding: 6px 12px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); font-size: 12px; color: var(--muted);
}
.chip.active { color: #fff; background: linear-gradient(135deg, var(--brand), #5b4dff); border-color: transparent; }
.cat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  padding: 2px 4px 10px;
}
.cat-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 8px 3px 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  color: var(--text); text-align: center; cursor: pointer;
}
.cat-card .cat-ico {
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(91, 77, 255, 0.12);
  display: flex; align-items: center; justify-content: center;
}
.cat-card svg { width: 13px; height: 13px; fill: var(--brand); }
.cat-card b { font-size: 11px; font-weight: 600; line-height: 1.2; }
.cat-card.active {
  border-color: transparent;
  background: linear-gradient(180deg, rgba(91,77,255,0.18), var(--card));
}
.cat-card.active .cat-ico { background: linear-gradient(135deg, var(--brand), #5b4dff); }
.cat-card.active svg { fill: #fff; }
html[data-theme="day"] .cat-card { background: #fff; box-shadow: 0 6px 16px rgba(40, 60, 120, 0.06); }
html[data-theme="day"] .cat-card .cat-ico { background: #eaf1ff; }
html[data-theme="day"] .cat-card svg { fill: #2f7bff; }
html[data-theme="day"] .cat-card.active { background: #fff; box-shadow: 0 8px 18px rgba(47,123,255,0.16); }
html[data-theme="day"] .cat-card.active .cat-ico { background: #2f7bff; }
html[data-theme="day"] .cat-card.active svg { fill: #fff; }
.quick {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-top: 6px;
}
.quick a, .quick button {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 0 8px; text-align: center; color: var(--text);
}
.quick i {
  display: block; width: 22px; height: 22px; margin: 0 auto 6px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand2));
}
.quick button:nth-child(2) i, .quick a:nth-child(2) i { background: linear-gradient(135deg, #ff6b6b, #ee5a24); }
.quick button:nth-child(3) i, .quick a:nth-child(3) i { background: linear-gradient(135deg, #1e90ff, #5352ed); }
.quick button:nth-child(4) i, .quick a:nth-child(4) i { background: linear-gradient(135deg, #2ed573, #1e90ff); }
.quick button:nth-child(5) i, .quick a:nth-child(5) i { background: linear-gradient(135deg, #ffa502, #ff6aa8); }
.quick button:nth-child(6) i, .quick a:nth-child(6) i { background: linear-gradient(135deg, #c97b3a, #e0a15a); }
.quick b { display: block; font-size: 11px; font-weight: 600; }
.topbar { flex-wrap: wrap; }
.search { flex: 1 1 100%; }
.app-list, .song-list { display: flex; flex-direction: column; gap: 8px; }
.app-item, .song-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px;
}
.rank {
  flex: 0 0 22px; text-align: center; font-size: 14px; font-weight: 800; color: var(--muted);
}
.song-item:nth-child(-n+3) .rank { color: #ff6aa8; }
.app-item img, .cover {
  width: 52px; height: 52px; border-radius: 14px; object-fit: cover; background: var(--cover-bg);
}
.meta { flex: 1; min-width: 0; }
.meta h3 { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta p { font-size: 11px; color: var(--muted); margin-top: 3px; }
.badge {
  display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 6px;
  font-size: 10px; background: linear-gradient(90deg, #ff4d4f, #ffa940, #52c41a);
  color: #fff; font-weight: 700;
}
.grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.poster {
  background: var(--card); border-radius: 12px; overflow: hidden; border: 1px solid var(--line);
}
.poster img { width: 100%; aspect-ratio: 3/4; object-fit: cover; background: var(--poster-bg); }
.poster .name { font-size: 12px; padding: 6px 6px 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.poster .sub { font-size: 10px; color: var(--muted); padding: 0 6px 8px; }
.game-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.game-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 12px;
}
.game-card h3 { font-size: 14px; margin-bottom: 10px; }
.btn {
  border: 0; border-radius: 999px; padding: 8px 12px; font-size: 12px; font-weight: 700; cursor: pointer;
  background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff;
}
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.block { width: 100%; padding: 12px; border-radius: 12px; font-size: 14px; }
.btn.danger { background: linear-gradient(135deg, #ff6b6b, #ee5a24); }
.sheet {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 50;
  display: none; align-items: flex-end;
}
.sheet.show { display: flex; }
.sheet-body {
  width: 100%; max-height: 88%; overflow: auto;
  background: var(--sheet-bg); border-radius: 20px 20px 0 0; padding: 16px 16px calc(20px + var(--safe-b));
}
.hero { display: flex; gap: 12px; align-items: flex-start; }
.hero img { width: 84px; height: 84px; border-radius: 18px; object-fit: cover; flex-shrink: 0; }
.share-btn {
  flex-shrink: 0; align-self: flex-start;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 8px 12px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.share-btn.block { width: 100%; padding: 12px; border-radius: 12px; font-size: 14px; text-align: center; }
.fuli-hint {
  color: var(--brand2); font-size: 13px; text-align: center; margin: 0 0 14px;
}
.desc { font-size: 13px; line-height: 1.7; color: var(--desc); white-space: pre-wrap; margin: 12px 0; }
.shots { display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.shots img {
  height: 140px; border-radius: 10px; cursor: zoom-in; flex-shrink: 0;
  object-fit: cover; background: var(--cover-bg);
}
.img-viewer {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.92);
  display: none;
}
.img-viewer.show { display: block; }
.img-viewer.single .img-viewer-nav { display: none; }
.img-viewer-stage {
  position: absolute; inset: 52px 0 78px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; touch-action: none;
}
.img-viewer img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  border-radius: 8px; user-select: none; -webkit-user-drag: none;
  transform-origin: center center; will-change: transform;
  cursor: zoom-in;
}
.img-viewer.zoomed img { cursor: grab; }
.img-viewer-close, .img-viewer-nav, .img-viewer-tools button {
  position: absolute; border: 0; color: #fff; background: rgba(255,255,255,0.16);
  cursor: pointer; z-index: 2;
}
.img-viewer-close {
  top: 12px; right: 12px; border-radius: 999px; padding: 8px 14px; font-size: 13px;
}
.img-viewer-nav {
  top: 50%; margin-top: -20px; width: 40px; height: 40px;
  border-radius: 50%; font-size: 22px; line-height: 40px; text-align: center;
}
.img-viewer-nav.prev { left: 8px; }
.img-viewer-nav.next { right: 8px; }
.img-viewer-tools {
  position: absolute; left: 50%; bottom: 38px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; z-index: 2;
}
.img-viewer-tools button {
  position: static; width: 36px; height: 36px; border-radius: 50%;
  font-size: 20px; line-height: 36px;
}
.img-viewer-tools span {
  color: #fff; font-size: 12px; min-width: 44px; text-align: center;
}
.img-viewer-counter {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  color: #fff; font-size: 13px; letter-spacing: 1px;
}
.links { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.empty, .loading, .error {
  text-align: center; color: var(--muted); padding: 40px 10px; font-size: 13px;
}
.form { display: flex; flex-direction: column; gap: 10px; }
.form input {
  width: 100%; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px;
}
.user-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--user-card);
  border: 1px solid var(--line); border-radius: 18px; padding: 14px;
}
.avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand2));
  display: flex; align-items: center; justify-content: center; font-weight: 800;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.player {
  position: fixed; left: 10px; right: 10px; bottom: calc(var(--tab-h) + var(--safe-b) + 8px);
  background: var(--player-bg); border: 1px solid var(--line);
  border-radius: 16px; padding: 8px 10px; display: none; flex-direction: column; gap: 8px; z-index: 28;
  max-height: 62vh;
}
.player.show { display: flex; }
.player-mini { display: flex; align-items: center; gap: 8px; }
.player img { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.player .meta { flex: 1; min-width: 0; }
.player h4 { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player p { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-acts { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.player-icon {
  width: 32px; height: 32px; border: 0; background: transparent; color: var(--text);
  border-radius: 50%; display: none; align-items: center; justify-content: center; font-size: 11px; font-weight: 700;
}
.player.book-mode .player-icon { display: flex; }
.player-progress {
  display: flex; align-items: center; gap: 8px; font-size: 10px; color: var(--muted);
}
.player-bar {
  flex: 1; height: 6px; background: var(--line); border-radius: 99px; position: relative; overflow: hidden;
}
.player-bar i {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, var(--brand), var(--brand2)); border-radius: 99px;
}
.player-eps {
  display: none; overflow: auto; max-height: 36vh; flex-wrap: wrap; gap: 6px; padding-bottom: 4px;
}
.player.open.book-mode .player-eps { display: flex; }
.player-eps button {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; font-size: 12px; color: var(--text);
}
.player-eps button.on { background: var(--brand); border-color: transparent; color: #fff; }
.overlay {
  position: fixed; inset: 0; background: #000; z-index: 80; display: none; flex-direction: column;
}
.overlay.show { display: flex; }
.overlay-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: #111;
}
.overlay video, .overlay iframe { flex: 1; width: 100%; border: 0; background: #000; }
.eps { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.eps button {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; font-size: 12px;
}
.eps button.on { background: var(--brand); border-color: transparent; }
.toast {
  position: fixed; left: 50%; top: 18%; transform: translateX(-50%);
  background: rgba(0,0,0,0.78); color: #fff; padding: 8px 14px; border-radius: 999px;
  font-size: 13px; z-index: 99; display: none;
}
.toast.show { display: block; }
.more { text-align: center; margin: 14px 0; }
.theme-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px;
}
.theme-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 12px; text-align: center; color: var(--text);
}
.theme-card.active { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(91,77,255,0.25); }
.theme-card b { display: block; font-size: 14px; margin-bottom: 4px; }
.theme-card span { font-size: 11px; color: var(--muted); }
