:root, html[data-mode="night"] {
  --bg: #0f1117;
  --bg2: #171b24;
  --card: #1e2430;
  --line: #2a3140;
  --text: #f2f4f8;
  --muted: #8b93a7;
  --danger: #e17055;
  --ok: #00b894;
  --radius: 16px;
  --tab: 64px;
  --safe: env(safe-area-inset-bottom, 0px);
  --head-from: #6c5ce7;
  --head-to: #0984e3;
  --ui-font: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --ui-size: 14px;
}
html[data-font="yahei"] {
  --ui-font: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
}
html[data-font="song"] {
  --ui-font: SimSun, "Songti SC", "Noto Serif SC", serif;
}
html[data-font="hei"] {
  --ui-font: SimHei, "Heiti SC", "PingFang SC", sans-serif;
}
html[data-mode="day"] {
  --bg: #f4f6fb;
  --bg2: #ffffff;
  --card: #ffffff;
  --line: #e4e8f0;
  --text: #1c2433;
  --muted: #6b7385;
}
html, html[data-skin="purple"] {
  --accent: #6c5ce7;
  --accent2: #00cec9;
  --head-from: #6c5ce7;
  --head-to: #0984e3;
}
html[data-skin="blue"] {
  --accent: #0984e3;
  --accent2: #74b9ff;
  --head-from: #0984e3;
  --head-to: #00cec9;
}
html[data-skin="green"] {
  --accent: #00b894;
  --accent2: #55efc4;
  --head-from: #00b894;
  --head-to: #0984e3;
}
html[data-skin="orange"] {
  --accent: #e17055;
  --accent2: #fdcb6e;
  --head-from: #e17055;
  --head-to: #fdcb6e;
}
html[data-skin="red"] {
  --accent: #d63031;
  --accent2: #ff7675;
  --head-from: #d63031;
  --head-to: #e17055;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--ui-font);
  font-size: var(--ui-size);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }

#app { min-height: 100%; }

/* Auth */
.auth-wrap {
  min-height: 100vh;
  padding: 48px 24px 32px;
  background: radial-gradient(1200px 500px at 10% -10%, color-mix(in srgb, var(--accent) 20%, transparent), transparent),
              radial-gradient(800px 400px at 110% 10%, color-mix(in srgb, var(--accent2) 20%, transparent), transparent),
              var(--bg);
}
.logo-mark {
  width: 72px; height: 72px; border-radius: 22px;
  background: #fff;
  display: grid; place-items: center;
  overflow: hidden;
  margin-bottom: 18px;
  box-shadow: 0 12px 32px #2ecc7133;
}
.logo-mark img { width: 100%; height: 100%; object-fit: cover; }
.auth-wrap h1 { font-size: 28px; letter-spacing: .04em; }
.auth-wrap p.sub { color: var(--muted); margin: 8px 0 28px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 14px; outline: none;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.field select {
  width: 100%; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 14px; outline: none;
}
.field textarea {
  width: 100%; min-height: 96px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px; outline: none; resize: vertical; line-height: 1.5;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; border: 0; border-radius: 12px; padding: 14px;
  background: linear-gradient(135deg, #6c5ce7, #5b4cdb); color: #fff;
  font-weight: 600; cursor: pointer;
}
.btn:disabled { opacity: .6; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.danger { background: #e17055; }
.btn.dl-lanzou { background: #3b82f6; }
.btn.dl-pan123 { background: #10b981; }
.btn.dl-baidu { background: #06a7ff; }
.btn.dl-telegram { background: #229ed9; }
.btn.dl-aliyun { background: #ff6a00; }
.btn.dl-quark { background: #7c3aed; }
.dl-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px;
}
.dl-grid .btn { width: 100%; min-width: 0; padding: 12px 10px; }
.switch-auth { text-align: center; margin-top: 16px; color: var(--muted); font-size: 14px; }
.switch-auth span { color: var(--accent2); cursor: pointer; }
.err { color: var(--danger); font-size: 13px; min-height: 20px; margin-bottom: 8px; }

/* Shell */
.shell { padding-bottom: calc(var(--tab) + var(--safe) + 12px); }
.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: 14px 16px 10px;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
  display: flex; align-items: center; justify-content: space-between;
}
.topbar h2 { font-size: 20px; }
.topbar .chip {
  font-size: 12px; color: var(--accent2); background: color-mix(in srgb, var(--accent2) 14%, transparent);
  padding: 4px 10px; border-radius: 999px;
}
.notice {
  margin: 0 16px 14px; padding: 12px 14px; border-radius: 12px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 20%, transparent), color-mix(in srgb, var(--accent2) 14%, transparent));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); color: var(--text); font-size: 15px; line-height: 1.6;
}
.notice b { display: block; color: #111111; font-size: 18px; margin-bottom: 6px; letter-spacing: .08em; }
html[data-mode="night"] .notice b { color: #ffffff; }
.notice p { white-space: pre-wrap; word-break: break-word; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 16px 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 0 16px 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 0 16px 16px; }

.section-title {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px 10px; font-size: 16px;
}
.section-title span { color: var(--muted); font-size: 12px; }
.back {
  color: #111111 !important;
  font-size: 18px !important;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: .02em;
}
html[data-mode="night"] .back { color: #ffffff !important; }
.back-row {
  position: sticky; top: 0; z-index: 3;
  padding: 14px 16px 10px;
  background: linear-gradient(180deg, var(--bg) 85%, transparent);
}
.subpage {
  position: fixed; inset: 0; z-index: 40;
  background: var(--bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.subpage.hidden { display: none !important; }
body.sub-on .tabbar,
body.sub-on .topbar { display: none; }
.detail-page, .form-page { padding: 0 16px 32px; }
.detail-head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.detail-page, .detail-page p, .detail-page h3, .detail-page .btn, .detail-page .detail-sec, .detail-page .desc-text, .detail-page .detail-updated, .detail-page .detail-stat span, .detail-page .detail-stat b {
  font-size: 20px !important;
}
.detail-page h3, .form-page h3 { margin: 0 0 8px; }
.detail-page .cover { width: 100%; border-radius: 12px; margin-bottom: 12px; }
.detail-stats { display: flex; gap: 8px; margin: 12px 0 4px; }
.detail-stat {
  flex: 1; min-width: 0; text-align: center;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 6px;
}
.detail-stat span { display: block; color: var(--muted); margin-bottom: 4px; }
.detail-stat b { display: block; word-break: break-all; font-weight: 700; }
.detail-sec { font-weight: 700; margin: 18px 0 8px; }
.detail-page .desc-text, .detail-page .detail-updated { margin: 0; line-height: 1.7; white-space: pre-wrap; }
.lightbox .back { color: #ffffff !important; }
.lightbox .back-row {
  position: absolute; top: 0; left: 0; right: 0;
  background: transparent;
  z-index: 2;
}

.app-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0; overflow: hidden; cursor: pointer;
}
.app-card .cover-wrap {
  width: 100%; height: 110px; background: #151922; position: relative; overflow: hidden;
}
.app-card .cover-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.app-card .cover-wrap .cover-fallback {
  width: 100%; height: 100%; display: grid; place-items: center;
  background: linear-gradient(135deg, #2d2466, #12343a);
}
.app-card .body { padding: 10px 12px 12px; }
.search-box { padding: 0 16px 12px; }
.search-box input {
  width: 100%; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; outline: none;
}
.thumb-lg { width: 56px; height: 36px; border-radius: 8px; object-fit: cover; background: #151922; }
.app-card .icon {
  width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center; font-size: 22px; margin-bottom: 10px;
}
.app-card .icon img, .list-item .icon img, .sheet .icon img {
  width: 100%; height: 100%; object-fit: cover; border-radius: inherit;
}
.sheet .cover {
  width: 100%; height: auto; max-height: 420px; object-fit: contain; border-radius: 12px;
  margin: 0 0 14px; background: #151922; cursor: zoom-in;
}
.sheet .shot-label { font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
.sheet .meta-line { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.sheet .desc-text { color: var(--text); font-size: 14px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; margin-bottom: 14px; }
.app-card h3 { font-size: 14px; margin-bottom: 4px; }
.app-card p { font-size: 12px; color: var(--muted); line-height: 1.4; height: 34px; overflow: hidden; }
.app-card .meta { margin-top: 8px; font-size: 11px; color: var(--accent2); }
.search-box { padding: 0 16px 12px; }
.search-box input {
  width: 100%; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; outline: none;
}
.thumb-lg { width: 56px; height: 36px; border-radius: 8px; object-fit: cover; background: #151922; }

.cat-item, .feat-item {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 8px; text-align: center; cursor: pointer;
}
.cat-item .icon, .feat-item .icon {
  width: 42px; height: 42px; border-radius: 12px; margin: 0 auto 8px;
  display: grid; place-items: center; font-size: 20px;
}
.cat-item b, .feat-item b { font-size: 12px; font-weight: 600; display: block; }

.list {
  padding: 0 16px 16px; display: flex; flex-direction: column; gap: 10px;
}
.list-item {
  display: flex; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px; cursor: pointer;
}
.list-item .icon {
  width: 48px; height: 48px; border-radius: 14px; flex: none;
  display: grid; place-items: center; font-size: 22px;
}
.list-item .grow { flex: 1; min-width: 0; }
.list-item h3 { font-size: 15px; }
.list-item p { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.star { color: #fdcb6e; font-size: 18px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tab) + var(--safe));
  padding-bottom: var(--safe);
  background: color-mix(in srgb, var(--bg2) 93%, transparent); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr);
}
.tabbar button {
  background: none; border: 0; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11px; cursor: pointer;
}
.tabbar button.on { color: var(--text); }
.tabbar .ico { font-size: 18px; }

.page { display: none; }
.page.on { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none;} }

.mine-head {
  margin: 8px 16px 16px; padding: 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--head-from), var(--head-to));
  color: #fff;
  display: flex; gap: 14px; align-items: center;
}
.avatar {
  width: 56px; height: 56px; border-radius: 18px; background: #fff3;
  display: grid; place-items: center; font-size: 22px; font-weight: 700;
}
.mine-head h3 { font-size: 18px; }
.mine-head p { font-size: 12px; opacity: .85; margin-top: 4px; }
.menu {
  margin: 0 16px 8px; padding: 0 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
}
.menu-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 4px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.menu-item:last-child { border-bottom: 0; }
.menu-item .left { display: flex; align-items: center; gap: 10px; }
.menu-item.logout {
  margin: 8px 16px 24px; padding: 16px; justify-content: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  color: var(--danger); font-weight: 600;
}
.vip-card {
  margin: 0 16px 16px; padding: 16px; border-radius: 16px;
  background: linear-gradient(135deg, #2d2108, #5c430e);
  border: 1px solid #fdcb6e55;
}
.vip-card h3 { color: #fdcb6e; }
.vip-card p { color: #e8d5a3; font-size: 13px; margin: 8px 0 12px; }
.vip-open { background: #fdcb6e; color: #2d2108; }
.plan-box { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.plan-box.hidden { display: none; }
.vip-plan { width: 100%; background: #fdcb6e; color: #2d2108; }

.modal {
  position: fixed; inset: 0; z-index: 50; background: #0008;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 560px; background: var(--bg2);
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + var(--safe));
  max-height: 88vh; overflow-y: auto;
}
.sheet h3 { margin-bottom: 8px; }
.sheet p { color: var(--muted); font-size: 13px; line-height: 1.6; margin-bottom: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row .btn { width: auto; min-width: 96px; padding: 12px 14px; }

.lightbox {
  position: fixed; inset: 0; z-index: 80; background: #000d;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  cursor: zoom-out;
}
.lightbox img { max-width: 100%; max-height: 92%; object-fit: contain; border-radius: 8px; }

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

/* Admin */
.admin-layout { display: grid; grid-template-columns: 180px 1fr; min-height: 100vh; }
.mod { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.side { background: var(--bg2); border-right: 1px solid var(--line); padding: 14px 10px; }
.side h1 { font-size: 15px; padding: 4px 10px 12px; }
.side a, .side button.link {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: 8px 10px; border-radius: 8px; color: var(--muted); cursor: pointer; margin-bottom: 2px;
}
.side a.on, .side button.link.on, .side a:hover { background: var(--card); color: var(--text); }
.theme-box { margin: 0 16px 16px; padding: 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); }
.theme-box h4 { font-size: 14px; margin-bottom: 10px; }
.theme-row, .skin-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.theme-chip {
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  border-radius: 999px; padding: 8px 14px; cursor: pointer; font-size: 13px;
}
.theme-chip.on { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.skin-row { margin-top: 12px; }
.skin-dot {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0;
}
.skin-dot.on { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
.side-row { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; }
.side-row .link { flex: 1; margin-bottom: 0; }
.side-sort { display: flex; flex-direction: column; gap: 2px; }
.sort-btn {
  width: 22px; height: 16px; padding: 0; border: 1px solid var(--line); border-radius: 4px;
  background: var(--card); color: var(--muted); font-size: 10px; line-height: 14px; cursor: pointer;
}
.sort-btn:disabled { opacity: .35; cursor: default; }
.main { padding: 12px 16px; }
.main .field { margin-bottom: 8px; }
.main .field input, .main .field select, .main .field textarea {
  padding: 8px 10px; border-radius: 8px;
}
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.stat b { font-size: 22px; display: block; }
.stat span { color: var(--muted); font-size: 12px; }
.table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 12px; overflow: hidden; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; }
.table th { color: var(--muted); font-weight: 500; }
.form-row { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.form-row input, .form-row select {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
.tiny { padding: 6px 10px; width: auto; font-size: 12px; border-radius: 8px; }
.admin-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
}
.admin-card h2 { margin: 0 0 8px; }
.admin-hint { color: var(--muted); font-size: 12px; margin: 0 0 8px; }
.form-section {
  font-size: 12px; color: var(--muted); margin: 8px 0 4px; letter-spacing: .04em;
}
.field-grid, .link-grid, .media-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 10px;
}
.field-grid label, .link-grid label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12px; color: var(--muted);
}
.field-grid input, .field-grid select, .link-grid input {
  width: 100%; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; color: var(--text);
}
.span-2 { grid-column: span 2; }
.media-slot {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
.media-slot > span:first-child { width: 100%; font-size: 12px; color: var(--muted); }
.form-actions {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px;
}
.form-actions .grow { flex: 1; min-width: 8px; }
.chk { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 13px; }
.hint { color: var(--muted); font-size: 12px; margin-left: 6px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.main h2 { font-size: 16px; margin: 12px 0 8px; }
.main h2:first-child { margin-top: 0; }
.pair-thumbs { display: inline-flex; gap: 4px; align-items: center; }
.media-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.side { position: sticky; top: 0; height: 100vh; overflow: auto; }

@media (max-width: 1100px) {
  .field-grid, .link-grid, .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2 { grid-column: span 2; }
}
@media (max-width: 800px) {
  .admin-layout { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .side { display: flex; gap: 8px; overflow: auto; position: static; height: auto; }
  .field-grid, .link-grid, .media-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
}
