:root {
  --bg: #0f1419;
  --panel: #161d25;
  --panel-2: #1c252f;
  --line: rgba(148, 163, 184, 0.18);
  --text: #e6edf6;
  --muted: #93a4b8;
  --accent: #38bdf8;
  --ok: #34d399;
  --danger: #f87171;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 15% -10%, #172434 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

.hidden {
  display: none !important;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 26px;
  background: rgba(15, 20, 25, 0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
}

.brand-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.7);
}

.brand-name {
  font-weight: 600;
}

.brand-sep {
  color: var(--muted);
}

.brand-page {
  color: var(--muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat {
  font-size: 13px;
  color: var(--muted);
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  white-space: nowrap;
}

.stat.warn {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.35);
}

.btn {
  font: inherit;
  font-size: 14px;
  padding: 7px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.5);
  color: #bae6fd;
}

.btn.primary:hover:not(:disabled) {
  background: rgba(56, 189, 248, 0.24);
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.btn.ghost:hover:not(:disabled) {
  border-color: rgba(148, 163, 184, 0.4);
}

.btn.ok {
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.45);
  color: #a7f3d0;
}

.btn.ok:hover:not(:disabled) {
  background: rgba(52, 211, 153, 0.22);
}

.btn.danger {
  background: transparent;
  border-color: rgba(248, 113, 113, 0.35);
  color: #fca5a5;
}

.btn.danger:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.14);
}

/* ---------- 主体 ---------- */
.wrap {
  max-width: 1440px;
  margin: 0 auto;
  padding: 22px 26px 60px;
}

.hint {
  margin-bottom: 18px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  background: rgba(22, 29, 37, 0.7);
  color: var(--muted);
  font-size: 14px;
}

.hint p {
  margin: 0;
}

.hint strong {
  color: var(--text);
}

/* ---------- 分段页签 ---------- */
.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(22, 29, 37, 0.7);
}

.tab {
  font: inherit;
  font-size: 14px;
  padding: 5px 18px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  background: rgba(56, 189, 248, 0.16);
  color: #bae6fd;
}

/* ---------- 令牌门 ---------- */
.gate {
  max-width: 420px;
  margin: 12vh auto 0;
  padding: 26px 28px 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.gate h1 {
  margin: 0 0 6px;
  font-size: 20px;
}

.gate p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
}

.gate form {
  display: flex;
  gap: 10px;
}

.gate input {
  flex: 1;
  min-width: 0;
  font: inherit;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0c1218;
  color: var(--text);
}

.gate input:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.6);
}

.gate-error {
  margin: 14px 0 0 !important;
  color: #fca5a5 !important;
  font-size: 13px !important;
}

/* ---------- 空态 ---------- */
.empty {
  margin: 12vh auto 0;
  text-align: center;
}

.empty-title {
  margin: 0 0 6px;
  font-size: 18px;
}

.empty-sub {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- 分组 ---------- */
.groups {
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.group-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
  padding: 0 2px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

.group-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.group-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--muted);
}

.group-count {
  margin-left: auto;
  font-size: 13px;
  color: var(--muted);
}

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

.card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.15s ease;
}

.card:hover {
  border-color: rgba(148, 163, 184, 0.32);
}

.card.busy {
  opacity: 0.55;
  pointer-events: none;
}

.card-shot {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  padding: 0;
  border: none;
  background: #fff;
  cursor: zoom-in;
}

.card-shot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.card-shot img.loaded {
  opacity: 1;
}

.card-shot.shot-fail {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #141b23;
}

.shot-fail-text {
  font-size: 13px;
  color: #fca5a5;
}

.card-source {
  position: absolute;
  left: 8px;
  top: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(15, 20, 25, 0.72);
  color: #e2e8f0;
  font-size: 11px;
  letter-spacing: 0.02em;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px 4px;
  font-size: 12.5px;
  color: var(--muted);
}

.card-slug {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: #9fb3cd;
  word-break: break-all;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}

.card-actions {
  display: flex;
  gap: 8px;
  padding: 8px 12px 12px;
}

.card-actions .btn {
  flex: 1;
  padding: 6px 10px;
  font-size: 13px;
}

/* ---------- 大图 ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  background: rgba(6, 9, 12, 0.92);
}

.lightbox img {
  max-width: 100%;
  max-height: calc(100vh - 140px);
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
}

.lightbox-caption {
  max-width: 90vw;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  word-break: break-all;
}

.lightbox-close {
  position: absolute;
  right: 22px;
  top: 16px;
  width: 38px;
  height: 38px;
  font-size: 24px;
  line-height: 1;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}

/* ---------- 提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 50;
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(30, 41, 53, 0.96);
  border: 1px solid var(--line);
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.toast.err {
  border-color: rgba(248, 113, 113, 0.5);
  color: #fca5a5;
}

@media (max-width: 640px) {
  .topbar {
    padding: 12px 16px;
  }

  .wrap {
    padding: 16px 16px 48px;
  }

  .cards {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
  }
}
