:root {
  --bg: #0b0d10; --panel: #13161b; --panel2: #1a1e25; --line: #232931; --text: #e6e8eb; --sub: #7d8590;
  --up: #16c784; --down: #ea3943; --acc: #f0b90b; --blue: #6cb6ff;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font: 13px/1.45 -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", sans-serif; overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: var(--text); }
input, select, textarea { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; outline: none; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--acc); }
textarea { width: 100%; resize: vertical; }
button { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer; white-space: nowrap; }
button:hover { border-color: var(--sub); }
button.primary { background: var(--acc); color: #000; border-color: var(--acc); font-weight: 600; }
button.danger { color: var(--down); }
button.mini { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
button.on { color: var(--acc); border-color: var(--acc); }
.up { color: var(--up); } .down { color: var(--down); } .acc { color: var(--acc); } .muted { color: var(--sub); }
[hidden] { display: none !important; }

/* 登录 */
.login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; }
.login-box label { display: flex; flex-direction: column; gap: 4px; color: var(--sub); }
.login-box input { padding: 10px 12px; font-size: 15px; }
.login-box button { padding: 11px; font-size: 15px; }
.brand { font-size: 15px; font-weight: 700; color: var(--acc); white-space: nowrap; }
.brand.big { font-size: 22px; text-align: center; }

/* 布局 */
#app { height: 100%; display: flex; flex-direction: column; }
header { display: flex; align-items: center; gap: 14px; padding: 8px 14px; border-bottom: 1px solid var(--line); flex: none; }
nav { display: flex; gap: 2px; }
nav a { padding: 6px 12px; border-radius: 8px; color: var(--sub); cursor: pointer; position: relative; display: flex; gap: 5px; align-items: center; }
nav a.on { color: var(--text); background: var(--panel2); }
nav .badge { background: var(--down); color: #fff; border-radius: 9px; padding: 0 5px; font-size: 10px; font-weight: 600; line-height: 16px; }
.chains { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.chains::-webkit-scrollbar { display: none; }
.chip { padding: 5px 10px; border-radius: 8px; cursor: pointer; color: var(--sub); border: 1px solid var(--line); white-space: nowrap; flex: none; }
.chip.on { color: #000; background: var(--acc); border-color: var(--acc); }
.chip .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--up); margin-left: 5px; vertical-align: middle; }
.chip .dot.err { background: var(--down); } .chip .dot.idle { background: var(--sub); }
.conn { width: 8px; height: 8px; border-radius: 50%; background: var(--down); flex: none; }
.conn.ok { background: var(--up); }
main { flex: 1; min-height: 0; position: relative; }
.page { position: absolute; inset: 0; overflow-y: auto; padding: 10px; display: none; flex-direction: column; gap: 10px; }
.page.on { display: flex; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; flex: none; }
.toolbar input, .toolbar select { max-width: 180px; }
.tab-btn { padding: 6px 12px; border-radius: 8px; color: var(--sub); border: 1px solid var(--line); cursor: pointer; }
.tab-btn.on { color: var(--acc); border-color: var(--acc); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; min-height: 0; min-width: 0; flex: 1; }
.card-h { font-size: 13px; font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.card-h small { font-weight: normal; }
.list { overflow-y: auto; flex: 1; min-height: 0; }
.empty { color: var(--sub); padding: 40px 16px; text-align: center; line-height: 1.8; }
.feed-wrap { display: grid; grid-template-columns: 1fr 340px; gap: 10px; flex: 1; min-height: 0; }

/* 动态条目 */
.act { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); align-items: center; cursor: pointer; }
.act:hover { background: var(--panel2); }
.act.flash { animation: flash 1.6s; }
@keyframes flash { from { background: #2a2410; } to { background: transparent; } }
.act .l1 { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.act .l2 { color: var(--sub); display: flex; gap: 4px 10px; flex-wrap: wrap; margin-top: 3px; font-size: 12px; }
.act .l2 b { color: var(--text); font-weight: 500; }
.act .amt { text-align: right; white-space: nowrap; }
.act .amt b { font-size: 14px; }
.act .time { color: var(--sub); font-size: 11px; }
.wname { font-weight: 600; }
.sym { font-weight: 600; }
.logo { width: 40px; height: 40px; border-radius: 50%; background: #222 center/cover; display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--sub); position: relative; flex: none; font-size: 12px; }
.logo.sm { width: 28px; height: 28px; font-size: 10px; }
.logo .cb { position: absolute; right: -4px; bottom: -3px; font-size: 8px; background: #000; color: var(--acc); border-radius: 4px; padding: 0 3px; border: 1px solid var(--line); line-height: 12px; }
.tag { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 11px; background: var(--panel2); color: var(--sub); white-space: nowrap; line-height: 16px; }
.tag.buy { background: #0f3d2a; color: var(--up); } .tag.sell { background: #45161a; color: var(--down); }
.tag.in, .tag.native_in { background: #10293f; color: var(--blue); } .tag.out, .tag.native_out { background: #2e2a40; color: #b9a9ff; }
.tag.approve { background: #3a2f0b; color: var(--acc); } .tag.contract { background: #203a3a; color: #5fd0d0; } .tag.failed { background: #333; color: #999; }
.ca { color: var(--sub); cursor: copy; white-space: nowrap; }
.ca:hover { color: var(--text); }
.ca::after { content: ''; display: inline-block; width: 7px; height: 8px; border: 1px solid currentColor; border-radius: 2px; margin-left: 4px; vertical-align: -1px; opacity: .8; }

/* 热门代币 */
.hot { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); align-items: center; cursor: pointer; }
.hot:hover { background: var(--panel2); }

/* 钱包卡片 */
.wallet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.wcard { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.wcard:hover { border-color: #3a414b; }
.wcard .top { display: flex; align-items: center; gap: 8px; }
.wcard .top .wname { font-size: 15px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wcard .val { font-size: 18px; font-weight: 700; }
.wcard .row { display: flex; justify-content: space-between; color: var(--sub); font-size: 12px; gap: 8px; }
.wcard .row b { color: var(--text); font-weight: 500; }
.wcard .actions { display: flex; gap: 6px; margin-top: 4px; }
.status-line { font-size: 12px; }

/* 行情行 */
.row-t { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); align-items: center; cursor: pointer; }
.row-t:hover { background: var(--panel2); }
.star { cursor: pointer; color: var(--sub); font-size: 15px; padding: 0 2px; }
.star.on { color: var(--acc); }

/* 设置 */
.settings { max-width: 760px; display: flex; flex-direction: column; gap: 10px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.panel h3 { font-size: 14px; margin-bottom: 10px; }
.form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chk { display: flex; gap: 5px; align-items: center; color: var(--text); cursor: pointer; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; }
.kv .k { color: var(--sub); }
.line-item { display: flex; justify-content: space-between; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--line); align-items: center; flex-wrap: wrap; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--sub); font-weight: normal; position: sticky; top: 0; background: var(--panel); z-index: 1; }
td.r, th.r { text-align: right; }

/* 底部弹出层 */
.sheet-mask, .modal-mask { position: fixed; inset: 0; background: #000a; z-index: 100; display: none; }
.sheet-mask.on, .modal-mask.on { display: block; }
.sheet { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(480px, 94vw); max-height: 90vh; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; z-index: 101; display: none; flex-direction: column; }
.sheet.on { display: flex; }
.sheet-h { display: flex; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.sheet-b { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.sheet-b label { display: flex; flex-direction: column; gap: 4px; color: var(--sub); }
.sheet-b label.chk { flex-direction: row; }
.kinds { display: flex; flex-wrap: wrap; gap: 6px; }
.kinds label { flex-direction: row !important; align-items: center; gap: 4px !important; background: var(--panel2); padding: 4px 8px; border-radius: 6px; color: var(--text) !important; cursor: pointer; }
.close { cursor: pointer; color: var(--sub); font-size: 18px; line-height: 1; padding: 2px 6px; }

/* 详情（钱包 / 代币） */
.detail { position: fixed; inset: 3vh 3vw; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; z-index: 101; display: none; flex-direction: column; overflow: hidden; }
.detail.on { display: flex; }
.d-head { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; flex: none; }
.d-head .big { font-size: 20px; font-weight: 700; }
.d-head .close { margin-left: auto; }
.d-stats { display: flex; gap: 16px; flex-wrap: wrap; }
.d-stats div { display: flex; flex-direction: column; } .d-stats span { color: var(--sub); font-size: 11px; }
.d-scroll { flex: 1; overflow-y: auto; min-height: 0; }
.d-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 360px; }
.d-left { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.chart-wrap { height: 50%; min-height: 240px; position: relative; border-bottom: 1px solid var(--line); flex: none; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.chart-bar { position: absolute; top: 6px; left: 8px; display: flex; gap: 4px; z-index: 2; }
.chart-tip { position: absolute; top: 34px; left: 10px; color: var(--sub); z-index: 2; font-size: 11px; font-variant-numeric: tabular-nums; pointer-events: none; }
.tabs { display: flex; gap: 2px; padding: 6px 10px; border-bottom: 1px solid var(--line); flex: none; overflow-x: auto; }
.tabs a { padding: 5px 12px; border-radius: 6px; color: var(--sub); cursor: pointer; white-space: nowrap; }
.tabs a.on { color: var(--text); background: var(--panel2); }
.d-tab { flex: 1; min-height: 0; overflow: auto; }
.d-right { overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.links { display: flex; gap: 6px; flex-wrap: wrap; }
.links a { padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px; color: var(--sub); font-size: 12px; }
.links a:hover { color: var(--acc); border-color: var(--acc); }
.mobile-only { display: none; }

#toast { position: fixed; bottom: calc(80px + var(--safe-b)); left: 50%; transform: translateX(-50%); background: #2a2f38; padding: 9px 16px; border-radius: 8px; display: none; z-index: 300; max-width: 90vw; }
.popup { position: fixed; right: 16px; bottom: 16px; width: 360px; display: flex; flex-direction: column; gap: 8px; z-index: 150; }
.popup .act { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 20px #0008; animation: slide .25s; }
@media (max-width: 820px) { .pop-mini { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; display: flex; gap: 6px; align-items: center; box-shadow: 0 6px 20px #000a; animation: slide .25s; font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .pop-mini span:last-child { overflow: hidden; text-overflow: ellipsis; } }
@keyframes slide { from { transform: translateY(20px); opacity: 0; } }

/* ===== 手机 ===== */
@media (max-width: 820px) {
  body { font-size: 14px; }
  header { padding: 8px 10px; gap: 8px; padding-top: max(8px, env(safe-area-inset-top)); }
  header .brand { display: none; }
  nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 90; background: #0f1216f2; backdrop-filter: blur(10px); border-top: 1px solid var(--line); justify-content: space-around; padding: 4px 0 calc(4px + var(--safe-b)); }
  nav a { flex-direction: column; gap: 1px; font-size: 11px; padding: 4px 10px; background: none !important; }
  nav a .ico { font-size: 20px; line-height: 1.1; }
  nav a.on { color: var(--acc); }
  nav .badge { position: absolute; top: 0; right: 4px; }
  main { padding-bottom: calc(58px + var(--safe-b)); }
  .page { padding: 8px; bottom: calc(58px + var(--safe-b)); }
  .toolbar input, .toolbar select { flex: 1 1 40%; max-width: none; }
  .feed-wrap { grid-template-columns: 1fr; }
  .feed-side { display: none; }
  .wallet-grid { grid-template-columns: 1fr; }
  .act { grid-template-columns: 34px minmax(0, 1fr) auto; gap: 8px; padding: 10px; }
  .act .logo { width: 34px; height: 34px; }
  .detail { inset: 0; border-radius: 0; border: none; padding-top: env(safe-area-inset-top); padding-bottom: var(--safe-b); }
  .d-body { grid-template-columns: 1fr; }
  .d-right { display: none; }
  .d-left { border-right: none; }
  .chart-wrap { height: 42vh; min-height: 220px; }
  .mobile-only { display: inline; }
  .d-stats { gap: 10px; font-size: 12px; }
  .sheet { top: auto; bottom: 0; left: 0; transform: none; width: 100%; border-radius: 16px 16px 0 0; max-height: 88vh; padding-bottom: var(--safe-b); }
  .popup { left: 8px; right: 8px; width: auto; bottom: calc(66px + var(--safe-b)); }
  th, td { padding: 7px 6px; font-size: 12px; }
  input, select, textarea { font-size: 16px; } /* 防止 iOS 聚焦时放大 */
}
