/* ==========================================================================
   Copen 钱包 · 样式
   设计基调沿用原原型：主色 #1F8A70、大圆角、浅色底。
   但这一版是「真产品」而不是「放在手机壳里的原型」，所以改成
   自适应全宽布局：手机上就是全屏 App，电脑上居中成一张卡片。
   ========================================================================== */

:root {
  --primary: #1F8A70;
  --primary-dark: #176B57;
  --primary-soft: #E8F5F0;
  --primary-line: #C7E5DA;

  --ink: #14161F;
  --ink-2: #3D4152;
  --muted: #6E7385;
  --muted-2: #9AA0B1;

  --bg: #EFF1F5;
  --surface: #FFFFFF;
  --surface-2: #F7F8FA;
  --line: #E6E8EE;

  --green: #17A673;
  --red: #D6453D;
  --red-soft: #FDECEB;
  --amber: #B7791F;
  --amber-soft: #FEF6E7;
  --blue: #2F6FE0;
  --blue-soft: #EAF1FE;

  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 22, 31, .05), 0 8px 24px -12px rgba(20, 22, 31, .14);
  --shadow-lg: 0 24px 60px -20px rgba(20, 22, 31, .3);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p { margin: 0; }
button { font: inherit; border: 0; background: none; color: inherit; cursor: pointer; padding: 0; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 3px solid #7FBFAE; outline-offset: 2px; border-radius: 6px; }

/* ── 外壳 ───────────────────────────────────────────────────────── */
.shell {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 0 1px rgba(20, 22, 31, .05);
  position: relative;
}

@media (min-width: 720px) {
  body { padding: 28px 0; }
  .shell {
    min-height: calc(100vh - 56px);
    border-radius: 26px;
    overflow: hidden;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(20, 22, 31, .06);
  }
}

/* ── 顶栏 ───────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
  padding: 12px 18px;
  display: flex; align-items: center; gap: 10px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -.3px; font-size: 17px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px;
  background: linear-gradient(150deg, #26A183, var(--primary-dark));
  color: #fff; display: grid; place-items: center; font-size: 18px;
  box-shadow: 0 4px 12px -4px rgba(31, 138, 112, .7);
}
.brand small { display: block; font-size: 10px; font-weight: 600; color: var(--primary); letter-spacing: .5px; }
.topbar-spacer { flex: 1; }

.net-pill {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 12px; font-size: 13px; font-weight: 600;
  transition: .15s;
}
.net-pill:hover { border-color: var(--primary-line); background: var(--primary-soft); }
.net-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.net-pill .chev { font-size: 10px; color: var(--muted); }

/* ── 网络身份条（很关键：一眼看出是真钱还是练手） ────────────────── */
.tier-banner {
  padding: 9px 18px; font-size: 12.5px; font-weight: 600;
  display: flex; align-items: center; gap: 8px; line-height: 1.45;
}
.tier-banner.test { background: var(--blue-soft); color: #1B4DA8; }
.tier-banner.main { background: var(--red-soft); color: #A62922; }
.tier-banner code { font-family: var(--mono); font-size: 11px; }

/* ── 主体 ───────────────────────────────────────────────────────── */
.main { flex: 1; padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.page { display: none; flex-direction: column; gap: 16px; }
.page.active { display: flex; }

.title-lg { font-size: 22px; font-weight: 700; letter-spacing: -.5px; }
.sub { color: var(--muted); font-size: 13.5px; line-height: 1.7; }

/* ── 卡片 ───────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
}
.card.tint { background: var(--surface-2); }
.card.flat { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h3 { font-size: 15px; font-weight: 700; }

/* ── 按钮 ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--r-md); padding: 13px 18px; font-size: 15px; font-weight: 650;
  transition: .15s; min-height: 48px; text-align: center;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px -8px rgba(31, 138, 112, .9); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-ghost { background: var(--surface-2); border: 1px solid var(--line); }
.btn-ghost:hover:not(:disabled) { background: #EFF1F5; border-color: var(--muted-2); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #B93A33; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-sm { padding: 9px 13px; font-size: 13px; min-height: 38px; border-radius: var(--r-sm); }

/* ── 资产行 ─────────────────────────────────────────────────────── */
.asset-list { display: flex; flex-direction: column; }
.asset {
  display: flex; align-items: center; gap: 13px; padding: 13px 18px;
  border-bottom: 1px solid var(--line); width: 100%; text-align: left; transition: .12s;
}
.asset:last-child { border-bottom: 0; }
.asset:hover { background: var(--surface-2); }
.badge {
  width: 40px; height: 40px; border-radius: 13px; flex-shrink: 0;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px;
  letter-spacing: -.5px;
}
.asset-meta { flex: 1; min-width: 0; }
.asset-meta b { display: block; font-size: 14.5px; font-weight: 650; }
.asset-meta span { font-size: 12px; color: var(--muted); }
.asset-amt { text-align: right; }
.asset-amt b { display: block; font-family: var(--mono); font-size: 14px; font-weight: 600; }
.asset-amt span { font-size: 11.5px; color: var(--muted); }

/* ── 表单 ───────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label { font-size: 12.5px; font-weight: 650; color: var(--ink-2); }
.input, .select {
  width: 100%;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 13px 14px; font-size: 15px;
  transition: .15s; min-height: 48px;
}
.input:focus, .select:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-soft); }
.input.mono { font-family: var(--mono); font-size: 13.5px; }
.input.err { border-color: var(--red); background: #FFF9F9; }
select.select { appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236E7385' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px;
}
.hint { font-size: 12px; color: var(--muted); line-height: 1.6; }
.hint.err { color: var(--red); font-weight: 600; }
.hint.ok { color: var(--green); font-weight: 600; }
.row { display: flex; gap: 10px; align-items: flex-end; }
.row > * { flex: 1; min-width: 0; }
.row.tight { gap: 8px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--surface-2);
  border-radius: 999px; padding: 6px 12px; font-size: 12.5px; font-weight: 600; transition: .13s;
}
.chip:hover { border-color: var(--primary-line); }
.chip.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-dark); }

/* ── 键值表 ─────────────────────────────────────────────────────── */
.kv { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; font-size: 13.5px; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); flex-shrink: 0; }
.kv strong { font-weight: 600; text-align: right; font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.kv strong.plain { font-family: var(--font); font-size: 13.5px; }

/* ── 提示条 ─────────────────────────────────────────────────────── */
.note {
  border-radius: var(--r-md); padding: 12px 14px; font-size: 12.5px; line-height: 1.7;
  display: flex; gap: 10px; align-items: flex-start;
}
.note .ni { flex-shrink: 0; font-size: 15px; line-height: 1.3; }
.note.info { background: var(--blue-soft); color: #1B4DA8; }
.note.warn { background: var(--amber-soft); color: #7A5410; }
.note.danger { background: var(--red-soft); color: #A62922; }
.note.good { background: var(--primary-soft); color: #11554A; }
.note b { font-weight: 700; }

/* ── 地址展示 ───────────────────────────────────────────────────── */
.addr-box {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 12px 14px;
  font-family: var(--mono); font-size: 12.5px; word-break: break-all;
  display: flex; gap: 10px; align-items: center;
}
.addr-box code { flex: 1; min-width: 0; }

.qr-wrap { display: grid; place-items: center; padding: 20px; }
.qr-wrap img, .qr-wrap canvas { border-radius: 12px; }

/* ── 底部导航 ───────────────────────────────────────────────────── */
.tabs {
  position: sticky; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(160%) blur(14px);
  border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 2px; border-radius: var(--r-sm); font-size: 11px; font-weight: 600;
  color: var(--muted); transition: .15s;
}
.tab:hover { background: var(--surface-2); }
.tab.on { color: var(--primary); background: var(--primary-soft); }
.tab .ic { font-size: 17px; line-height: 1; }

/* ── 弹层 ───────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20, 22, 31, .48);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0; animation: fade .18s ease;
}
@media (min-width: 720px) { .overlay { align-items: center; padding: 24px; } }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes rise { from { transform: translateY(24px); opacity: 0 } to { transform: none; opacity: 1 } }
.sheet {
  background: var(--surface); width: 100%; max-width: 540px;
  border-radius: 22px 22px 0 0; max-height: 92vh; overflow: auto;
  padding: 20px; animation: rise .22s cubic-bezier(.2, .8, .3, 1);
}
@media (min-width: 720px) { .sheet { border-radius: 22px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.sheet-head h3 { font-size: 18px; font-weight: 700; }
.x-btn { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); font-size: 15px; }
.x-btn:hover { background: var(--line); }

/* ── 进度步骤 ───────────────────────────────────────────────────── */
.steps { display: flex; flex-direction: column; gap: 2px; }
.step { display: flex; gap: 12px; align-items: flex-start; padding: 9px 0; font-size: 13.5px; color: var(--muted); }
.step .bullet {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted-2);
}
.step.done .bullet { background: var(--primary); border-color: var(--primary); color: #fff; }
.step.done { color: var(--ink); font-weight: 600; }
.step.now .bullet { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-dark); animation: pulse 1.2s infinite; }
.step.now { color: var(--primary-dark); font-weight: 650; }
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .45 } }

.spin {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: sp .7s linear infinite; display: inline-block; vertical-align: -2px;
}
@keyframes sp { to { transform: rotate(360deg) } }

/* ── 钱包选择 ───────────────────────────────────────────────────── */
.wallet-item {
  display: flex; align-items: center; gap: 13px; width: 100%; text-align: left;
  padding: 13px 14px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); transition: .14s; margin-bottom: 8px;
}
.wallet-item:hover { border-color: var(--primary); background: var(--primary-soft); }
.wallet-item img { width: 34px; height: 34px; border-radius: 9px; }
.wallet-item .ph { width: 34px; height: 34px; border-radius: 9px; background: var(--surface-2); display: grid; place-items: center; font-size: 16px; }
.wallet-item b { flex: 1; font-size: 14.5px; font-weight: 650; }
.wallet-item .go { color: var(--muted-2); font-size: 15px; }

/* ── 交易记录 ───────────────────────────────────────────────────── */
.tx-item { display: flex; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--line); align-items: center; }
.tx-item:last-child { border-bottom: 0; }
.tx-ic { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; font-size: 15px; flex-shrink: 0; }
.tx-ic.out { background: var(--red-soft); color: var(--red); }
.tx-ic.in { background: var(--primary-soft); color: var(--primary-dark); }
.tx-ic.swap { background: var(--blue-soft); color: var(--blue); }
.tx-body { flex: 1; min-width: 0; }
.tx-body b { display: block; font-size: 13.5px; font-weight: 650; }
.tx-body span { font-size: 11.5px; color: var(--muted); font-family: var(--mono); }
.tx-state { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; flex-shrink: 0; }
.tx-state.ok { background: var(--primary-soft); color: var(--primary-dark); }
.tx-state.pending { background: var(--amber-soft); color: var(--amber); }
.tx-state.fail { background: var(--red-soft); color: var(--red); }

/* ── 空状态 ─────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 10px; }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 5px; }

/* ── 结果页 ─────────────────────────────────────────────────────── */
.result-hero { text-align: center; padding: 14px 0 6px; }
.result-hero .ring {
  width: 62px; height: 62px; border-radius: 50%; margin: 0 auto 14px;
  display: grid; place-items: center; font-size: 28px;
}
.result-hero .ring.ok { background: var(--primary-soft); color: var(--primary-dark); }
.result-hero .ring.err { background: var(--red-soft); color: var(--red); }
.result-hero h3 { font-size: 18px; font-weight: 700; }
.result-hero p { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ── Toast ──────────────────────────────────────────────────────── */
.toasts { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: 92vw; }
.toast {
  background: #1B1E28; color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg); animation: rise .2s ease;
}
.toast.err { background: var(--red); }
.toast.ok { background: var(--primary-dark); }

/* ── 工具类 ─────────────────────────────────────────────────────── */
.mono { font-family: var(--mono); }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.mt { margin-top: 12px; } .mt-lg { margin-top: 20px; }
.gap-sm { display: flex; flex-direction: column; gap: 8px; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
details.acc { border: 1px solid var(--line); border-radius: var(--r-md); padding: 0; overflow: hidden; }
details.acc > summary { padding: 13px 15px; font-size: 13.5px; font-weight: 650; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::after { content: '＋'; color: var(--muted); font-weight: 400; }
details.acc[open] > summary::after { content: '－'; }
details.acc[open] > summary { border-bottom: 1px solid var(--line); background: var(--surface-2); }
details.acc .acc-body { padding: 15px; font-size: 13px; line-height: 1.8; color: var(--ink-2); }

.demo-tag {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--amber-soft); color: var(--amber);
  font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
}
.real-tag {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--primary-soft); color: var(--primary-dark);
  font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
}
