:root {
  --bg: #0b0f14;
  --bg-2: #111826;
  --card: #151d2b;
  --card-2: #1a2436;
  --border: #263349;
  --text: #e6edf5;
  --muted: #8b98ad;
  --green: #22c55e;
  --green-dim: #16a34a;
  --red: #ef4444;
  --blue: #3b82f6;
  --amber: #f59e0b;
  --purple: #a855f7;
  --radius: 14px;
}

* { box-sizing: border-box; }

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

body {
  background: radial-gradient(1200px 600px at 50% -200px, #123326 0%, var(--bg) 55%);
  background-color: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { font-size: 26px; }
.brand-text h1 { font-size: 17px; margin: 0; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--muted); }

.back-link {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 12px; border-radius: 8px;
  color: var(--muted); font-size: 13px; text-decoration: none;
  border: 1px solid var(--border); white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.back-link:hover { color: var(--green); border-color: #166534; }

.wallet-area { display: flex; align-items: center; gap: 8px; }

/* ===== 通用 ===== */
.container { max-width: 640px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.card-head h2 { margin: 0 0 4px; font-size: 16px; }
.section { margin-bottom: 20px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.section-head h2 { margin: 0; font-size: 16px; }

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

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--green-dim); color: #fff; }
.btn-primary:hover { background: var(--green); }
.btn-green { background: #14532d; color: #bbf7d0; border-color: #166534; }
.btn-green:hover { background: #166534; }
.btn-outline { background: transparent; color: var(--green); border-color: #166534; }
.btn-outline:hover { background: #0f2317; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 6px 10px; font-size: 13px; }

/* ===== 徽章 ===== */
.badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
}
.badge-gray { background: #2a3446; color: var(--muted); }
.badge-green { background: #14532d; color: #bbf7d0; }
.badge-red { background: #7f1d1d; color: #fecaca; }

/* ===== 状态横幅 ===== */
.status-banner {
  margin: 12px 16px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  background: #3b2f1a;
  color: #fde68a;
  border: 1px solid #92600a;
}
.status-banner.error { background: #3a1616; color: #fecaca; border-color: #8a2a2a; }

/* ===== 表单 ===== */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select {
  width: 100%;
  padding: 11px 12px;
  font-size: 16px;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--green-dim); }

/* ===== 水龙头 ===== */
.faucet-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.faucet-row .field { flex: 1 1 140px; margin-bottom: 0; }
.faucet-row .btn { flex: 1 1 130px; }

/* ===== 余额 ===== */
.balances { display: grid; gap: 8px; font-size: 14px; }
.balance-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.balance-row b { font-variant-numeric: tabular-nums; }

/* ===== 池列表 ===== */
.pools-list { display: grid; gap: 12px; }

.pool-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.pool-head { display: flex; align-items: center; gap: 10px; }
.pool-title { flex: 1; min-width: 0; }
.pool-title h3 { margin: 0; font-size: 15px; }
.pool-meta { font-size: 12px; color: var(--muted); }
.pool-price { text-align: right; }
.pool-price .num { font-size: 18px; font-weight: 700; color: var(--green); font-variant-numeric: tabular-nums; }
.pool-price .unit { font-size: 11px; color: var(--muted); display: block; }

.tier {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9px;
  font-weight: 800; font-size: 15px;
}
.tier-A { background: #14532d; color: #bbf7d0; }
.tier-B { background: #1e3a5f; color: #bfdbfe; }
.tier-C { background: #5f3a1e; color: #fde68a; }
.tier-D { background: #3a3f4a; color: #cbd5e1; }

.pool-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}
.pool-stat {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  text-align: center;
}
.pool-stat .k { font-size: 11px; color: var(--muted); display: block; }
.pool-stat .v { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

.pool-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pool-actions .btn { flex: 1 1 0; min-width: 64px; padding: 9px 6px; font-size: 13px; }
.act-buy { background: #14532d; color: #bbf7d0; }
.act-sell { background: #3a1616; color: #fecaca; }
.act-add { background: #1e3a5f; color: #bfdbfe; }
.act-remove { background: #3b2f1a; color: #fde68a; }
.act-retire { background: #2b1e3a; color: #e9d5ff; }

/* ===== 退役记录 ===== */
.retirements-list { display: grid; gap: 10px; }
.retire-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  font-size: 13px;
}
.retire-item .r-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.retire-item .r-anchor { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--purple); word-break: break-all; }
.retire-item .r-beneficiary { color: var(--text); font-weight: 600; }

/* ===== 弹窗 ===== */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.modal-dialog {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  padding: 18px;
}
@media (min-width: 520px) {
  .modal { align-items: center; }
  .modal-dialog { border-radius: 18px; }
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-close {
  background: transparent; border: none; color: var(--muted);
  font-size: 26px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal-body { margin-bottom: 16px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; }

.preview {
  margin: 10px 0;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--green);
  min-height: 18px;
  word-break: break-word;
}
.hint { font-size: 12px; color: var(--muted); margin: 6px 0; }

/* ===== 轻提示 ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 60;
  max-width: 90vw;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  background: #1f2937;
  color: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
  word-break: break-all;
}
.toast.success { border-color: #166534; background: #0f2317; color: #bbf7d0; }
.toast.error { border-color: #7f1d1d; background: #2a1212; color: #fecaca; }

/* ===== 页脚 ===== */
.footer { text-align: center; padding: 20px 16px 40px; color: var(--muted); font-size: 12px; }

.hidden { display: none !important; }

/* ===== 预测市场（Predictex-DEX 扩展） ===== */
.market-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.market-card .m-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.market-card .m-question { font-size: 15px; font-weight: 700; margin: 0 0 4px; }
.market-card .m-desc { font-size: 12px; color: var(--muted); margin: 0 0 10px; }
.badge-resolved { background: #5f3a1e; color: #fde68a; }
.badge-open { background: #14532d; color: #bbf7d0; }

.prob-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.prob-side { background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.prob-side .p-label { font-size: 11px; color: var(--muted); display: block; }
.prob-side .p-value { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.prob-yes .p-value { color: var(--green); }
.prob-no .p-value { color: var(--red); }

.prob-bar { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; margin-top: 6px; display: flex; }
.prob-bar .fill-yes { background: var(--green); height: 100%; }
.prob-bar .fill-no { background: var(--red); height: 100%; }

.act-resolve { background: #5f3a1e; color: #fde68a; }
.act-redeem { background: #1e3a5f; color: #bfdbfe; }

.resolutions-list { display: grid; gap: 10px; }
.resolution-item { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; font-size: 13px; }
.resolution-item .r-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
