:root {
  --bg: #0f1419;
  --bg-elev: #171e26;
  --bg-soft: #1e2732;
  --line: #2a3544;
  --text: #e8eef5;
  --muted: #8b9bb0;
  --accent: #2bb673;
  --accent-2: #3d9cf0;
  --warn: #e6a23c;
  --danger: #e35d6a;
  --ok: #2bb673;
  --radius: 14px;
  --font: "DM Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(43, 182, 115, 0.12), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(61, 156, 240, 0.10), transparent 50%),
    var(--bg);
}

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: rgba(15, 20, 25, 0.85);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; gap: 12px; align-items: center; padding: 4px 8px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(34, 160, 180, 0.28);
}
.brand-mark svg { display: block; width: 100%; height: 100%; }
.brand-name { font-weight: 700; letter-spacing: 0.06em; font-size: 17px; }
.brand-sub { font-size: 12px; color: var(--muted); letter-spacing: 0.02em; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  text-align: left; padding: 10px 12px; border-radius: 10px;
  font: inherit; cursor: pointer; transition: 0.15s ease;
}
.nav-item:hover { background: var(--bg-soft); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(43,182,115,0.18), transparent);
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.svc {
  font-size: 12px; padding: 8px 10px; border-radius: 999px; text-align: center;
  border: 1px solid var(--line); color: var(--muted);
}
.svc.active { color: #b8f0d2; border-color: rgba(43,182,115,0.45); background: rgba(43,182,115,0.12); }
.svc.inactive { color: #f0c0c6; border-color: rgba(227,93,106,0.4); background: rgba(227,93,106,0.1); }

.main { padding: 28px 32px 48px; max-width: 1100px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 16px; }
.topbar h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }

.panel { display: none; animation: fade 0.25s ease; }
.panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.stat-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px;
}
.stat {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.card {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 18px 16px; margin-bottom: 14px;
}
.card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-h h2 { margin: 0; font-size: 16px; font-weight: 600; }
.muted { color: var(--muted); font-size: 12px; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--bg-soft); color: var(--text);
  padding: 10px 14px; border-radius: 10px; font: inherit; cursor: pointer; transition: 0.15s ease;
}
.btn:hover { border-color: #3d4d61; }
.btn.primary {
  background: linear-gradient(180deg, #33c67f, #249a5f);
  border-color: transparent; color: #04140c; font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.danger { border-color: rgba(227,93,106,0.45); color: #ffb4bb; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.form-row, .form-grid { display: grid; gap: 12px; }
.form-row { grid-template-columns: 1fr 1fr auto; align-items: end; }
.form-row-post { grid-template-columns: minmax(180px, 1fr) minmax(160px, 1.2fr) auto; align-items: end; }
.form-row-vi-account {
  grid-template-columns: minmax(240px, 1fr) auto;
  align-items: end;
}
.vi-account-label { display: flex; flex-direction: column; gap: 6px; }
.vi-account-label select {
  width: 100%;
  min-height: 42px;
  cursor: pointer;
}
.post-preview {
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px dashed var(--line);
  background: var(--bg);
  display: flex;
  align-items: center;
  font-size: 13px;
}
.post-preview.ok { border-style: solid; border-color: rgba(43,182,115,0.45); color: #b8f0d2; }
.post-preview.err { border-style: solid; border-color: rgba(227,93,106,0.45); color: #ffb4bb; }
.form-grid { grid-template-columns: 1fr 1fr; }
.form-grid .span-2 { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
label span { color: var(--muted); }
label em { font-style: normal; font-size: 11px; color: #6d7d92; }
label.check {
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  color: var(--text);
  cursor: pointer;
  max-width: 100%;
}
label.check span {
  color: var(--text);
  line-height: 1.4;
  flex: 1;
  min-width: 0;
}
label.check input[type="checkbox"] {
  appearance: auto;
  -webkit-appearance: checkbox;
  width: 16px;
  height: 16px;
  min-width: 16px;
  margin-top: 2px;
  padding: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  appearance: none; width: 100%;
  background: var(--bg); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font: inherit;
}
input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
  outline: none; border-color: rgba(43,182,115,0.55);
  box-shadow: 0 0 0 3px rgba(43,182,115,0.15);
}
textarea { font-family: var(--mono); font-size: 13px; line-height: 1.5; resize: vertical; }
.form-actions { display: flex; gap: 8px; margin-top: 8px; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; }
.hint code {
  font-family: var(--mono); font-size: 12px; background: var(--bg);
  padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line);
}

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 500; font-size: 12px; }
.table td code { font-family: var(--mono); font-size: 12px; }

.rank-list, .history-list { display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow: auto; }
.rank-item, .hist-item {
  display: grid; gap: 4px; padding: 10px 12px; border-radius: 10px; background: var(--bg-soft);
  border: 1px solid transparent;
}
.rank-item { grid-template-columns: 1fr auto; align-items: center; }
.rank-item .bar { font-weight: 600; }
.rank-item .pid { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.rank-pill {
  font-variant-numeric: tabular-nums; font-weight: 700; min-width: 52px; text-align: center;
  padding: 6px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line);
}
.rank-pill.good { color: #b8f0d2; border-color: rgba(43,182,115,0.4); }
.rank-pill.mid { color: #ffd59a; border-color: rgba(230,162,60,0.4); }
.rank-pill.bad { color: #ffb4bb; border-color: rgba(227,93,106,0.4); }
.hist-item .meta { font-size: 12px; color: var(--muted); }
.hist-item .text { font-size: 14px; }

.vi-preview-wrap { margin-bottom: 14px; }
.vi-preview-bg {
  width: 100%;
  max-width: 320px;
  aspect-ratio: 1;
  border-radius: 16px;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #1e2732;
}
.vi-preview-bg img {
  width: 86%;
  height: 86%;
  object-fit: contain;
  border-radius: 8px;
}
.vi-preview-empty { font-size: 13px; padding: 16px; text-align: center; }
.vi-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  margin: 0 0 14px;
}
.vi-meta > div { display: flex; gap: 8px; font-size: 13px; }
.vi-meta dt { color: var(--muted); min-width: 64px; }
.vi-meta dd { margin: 0; word-break: break-all; }

.log {
  margin: 0; padding: 12px; background: var(--bg); border-radius: 10px; border: 1px solid var(--line);
  font-family: var(--mono); font-size: 12px; color: #a8bdd4; max-height: 220px; overflow: auto;
  white-space: pre-wrap;
}

.toast {
  background: var(--bg-soft); border: 1px solid var(--line); padding: 8px 12px; border-radius: 10px;
  font-size: 13px; max-width: 420px;
}
.toast.ok { border-color: rgba(43,182,115,0.45); color: #b8f0d2; }
.toast.err { border-color: rgba(227,93,106,0.45); color: #ffb4bb; }

.steps { margin: 0; padding-left: 18px; color: var(--muted); line-height: 1.7; }
.steps strong { color: var(--text); }

.account-check-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.account-check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
}
.account-check-item input { width: 16px; height: 16px; }
.account-check-item .acc-check-name { font-weight: 600; flex: 1; }
.account-check-item .acc-check-meta { font-size: 12px; }

.acc-status-ok { color: #b8f0d2; }
.acc-status-bad { color: #ffb4bb; }
.acc-status-mid { color: #ffd28a; }
.acc-status-detail { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

.captcha-preview {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--bg);
}
.captcha-preview img {
  max-height: 72px;
  image-rendering: pixelated;
  background: #fff;
  border-radius: 4px;
}
.pub-img-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.pub-img-preview img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line, #d8d8d8);
  background: #111;
}

.auth-gate {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 12, 16, 0.82);
  backdrop-filter: blur(10px);
}
.auth-gate[hidden] { display: none !important; }
/* 已有 token：首屏先藏登录层，等校验完再决定，避免刷新闪登录页 */
html.auth-pending #authGate { display: none !important; }
html.auth-pending body::before {
  content: "";
  position: fixed; inset: 0; z-index: 70;
  background: var(--bg, #0f1419);
}
.auth-card {
  width: min(420px, 92vw);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 22px 18px;
}
.auth-tabs { display: flex; gap: 6px; margin: 12px 0 16px; }
.auth-tab {
  appearance: none; border: 1px solid var(--line); background: transparent;
  color: var(--muted); padding: 8px 14px; border-radius: 8px; font: inherit; cursor: pointer;
  flex: 1;
}
.auth-tab.active { color: var(--text); border-color: var(--accent); background: rgba(43,182,115,0.12); }
.auth-pane { display: block; }
.auth-pane[hidden],
.auth-pane:not(.active) { display: none !important; }
.auth-form { grid-template-columns: 1fr; }
.auth-extra { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.buy-card-link { text-align: center; text-decoration: none; }
.plan-buy-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.plan-buy-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
  transition: 0.15s ease;
  text-decoration: none;
}
.plan-buy-btn:hover {
  border-color: var(--accent);
  background: rgba(43, 182, 115, 0.12);
  transform: translateY(-1px);
}
.plan-buy-label { color: var(--muted); font-size: 13px; }
.plan-buy-price {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.plan-buy-cta {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}
@media (max-width: 960px) {
  .plan-buy-row { grid-template-columns: 1fr; }
}
.feature-lock {
  display: none;
  position: sticky;
  top: 0;
  z-index: 20;
  margin-bottom: 14px;
}
.feature-lock.is-on,
.panel.is-locked > .feature-lock {
  display: block !important;
  pointer-events: auto;
  user-select: auto;
  opacity: 1;
}
.feature-lock-card {
  background: rgba(15, 20, 25, 0.88);
  border: 1px solid rgba(230, 162, 60, 0.45);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
}
.feature-lock-card h3 { margin: 0 0 8px; font-size: 16px; }
.feature-lock-card p { margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.panel.is-locked .card,
.panel.is-locked .grid-2 {
  opacity: 0.55;
  pointer-events: none;
  user-select: none;
}

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .stat-row, .grid-2, .form-row, .form-grid { grid-template-columns: 1fr; }
}
