:root {
  --bg: #0b0d10;
  --card: #14181d;
  --text: #e8ecf1;
  --dim: #8b939e;
  --near: #3ddc97;
  --mid: #e8b86d;
  --far: #e26d5a;
  --overseas: #3ddc97;
  --china: #7eb6ff;
  --metal: #e8b86d;
  --pill: #1c2229;
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: "Segoe UI", "PingFang SC", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}
#app { min-height: 100%; max-width: 480px; margin: 0 auto; }

button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
.screen { min-height: 100dvh; display: flex; flex-direction: column; padding-bottom: var(--safe-bottom); }
.top {
  padding: calc(18px + var(--safe-top)) 8px 10px 20px;
  position: sticky; top: 0; background: var(--bg); z-index: 2;
}
.row { display: flex; align-items: center; }
.grow { flex: 1; min-width: 0; }
.title { font-size: 26px; font-weight: 600; margin: 0; }
.sub { color: var(--dim); font-size: 13px; margin: 4px 0 0; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; color: var(--text);
}
.icon-btn.active { color: var(--accent, var(--overseas)); }
.icon-btn svg { width: 22px; height: 22px; }

.tabs {
  display: flex; gap: 0; margin: 14px 12px 0 0;
  background: var(--pill); border-radius: 14px; padding: 4px;
}
.tab {
  flex: 1; border-radius: 11px; padding: 10px 0; text-align: center;
}
.tab.on { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.tab b { display: block; font-size: 13px; font-weight: 600; color: var(--dim); }
.tab.on b { color: var(--accent); }
.tab span { display: block; font-size: 10px; color: var(--dim); margin-top: 2px; }
.tab.on span { color: var(--text); }

.warn { color: var(--mid); font-size: 12px; margin: 8px 0 0; }
.list { padding: 4px 16px 24px; display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--card); border-radius: 16px; padding: 16px; }
.card. tap, .card.click { cursor: pointer; }
.rule-title { color: var(--accent); font-size: 14px; font-weight: 600; }
.rule-line { font-size: 13px; line-height: 20px; margin-top: 6px; }
.rule-why { color: var(--dim); font-size: 12px; line-height: 18px; margin-top: 8px; }
.idx { padding-bottom: 14px; }
.idx-top { display: flex; align-items: center; gap: 12px; }
.idx .bar { width: 3px; height: 42px; border-radius: 2px; flex-shrink: 0; }
.idx-units { text-align: right; flex-shrink: 0; }
.idx-units .units { font-size: 18px; font-weight: 600; margin-top: 0; }
.ath-track {
  height: 7px; background: #1c2229; border-radius: 99px;
  overflow: hidden; margin: 12px 0 6px;
}
.ath-fill { height: 100%; background: var(--accent); border-radius: 99px; }
.ath-scale {
  display: flex; justify-content: space-between; gap: 8px;
  font-size: 11px; color: var(--dim);
}
.gap-num { font-size: 18px; font-weight: 600; margin-top: 8px; }
.hero-block { margin-bottom: 8px; }
.ladder { margin-top: 10px; }
.ladder .pair.on { color: var(--accent); font-weight: 600; }
.ladder .pair.on .l { color: var(--accent); }
.region { color: var(--dim); font-size: 11px; }
.name { font-size: 17px; font-weight: 500; }
.meta { color: var(--dim); font-size: 12px; margin-top: 4px; }
.right { text-align: right; }
.dd { font-size: 22px; font-weight: 600; }
.units { font-size: 12px; color: var(--accent); margin-top: 2px; }
.foot { color: var(--dim); font-size: 11px; line-height: 16px; padding: 6px 4px 8px; }
.center { flex: 1; display: grid; place-items: center; color: var(--dim); font-size: 13px; padding: 48px 16px; }
.spin {
  width: 22px; height: 22px; border: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.detail-top { padding: calc(8px + var(--safe-top)) 8px 8px; }
.kicker { font-size: 12px; color: var(--accent); }
.h1 { font-size: 20px; font-weight: 600; margin: 0; }
.pad { padding: 8px 16px 28px; }
.lbl { color: var(--dim); font-size: 12px; }
.hero { font-size: 32px; font-weight: 600; line-height: 1.15; }
.pair { display: flex; justify-content: space-between; padding-top: 4px; font-size: 12px; }
.pair .l { color: var(--dim); }
.stats { display: flex; gap: 10px; }
.stats .card { flex: 1; }
.metric { display: flex; justify-content: space-between; padding: 2px 0; font-size: 12px; }
.metric span { color: var(--dim); }
.cta {
  width: 100%; background: var(--card); border-radius: 14px; padding: 14px;
  display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 8px;
}
.trap { background: color-mix(in srgb, var(--far) 12%, var(--card)); }

.chat-log { flex: 1; overflow: auto; padding: 8px 16px 12px; display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 88%; border-radius: 16px; padding: 10px 12px; font-size: 14px; line-height: 22px; white-space: pre-wrap; }
.bubble.user { align-self: flex-end; background: color-mix(in srgb, var(--accent) 22%, var(--card)); }
.bubble.assistant { align-self: flex-start; background: var(--card); }
.chips { display: flex; gap: 8px; overflow: auto; padding: 0 16px 8px; }
.chip { white-space: nowrap; background: var(--pill); border-radius: 999px; padding: 8px 12px; font-size: 12px; color: var(--dim); }
.composer { display: flex; gap: 8px; padding: 8px 16px calc(12px + var(--safe-bottom)); }
.composer input {
  flex: 1; background: var(--card); border: 0; border-radius: 12px; padding: 12px 14px; outline: none;
}
.send { width: 44px; border-radius: 12px; background: var(--card); }

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: grid; place-items: end center; z-index: 10;
}
.sheet {
  width: 100%; max-width: 480px; background: #12161b;
  border-radius: 20px 20px 0 0; padding: 18px 18px calc(18px + var(--safe-bottom));
}
.sheet h2 { margin: 0 0 8px; font-size: 18px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin: 10px 0; }
.pick { text-align: center; border-radius: 8px; padding: 8px 6px; font-size: 12px; background: var(--pill); color: var(--dim); }
.pick.on { color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); }
.field {
  width: 100%; background: var(--bg); border: 1px solid #2a3138; border-radius: 10px;
  padding: 10px 12px; margin-top: 8px; outline: none;
}
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.actions button { padding: 8px 12px; color: var(--accent); }

.near { color: var(--near); }
.mid { color: var(--mid); }
.far { color: var(--far); }
.accent { color: var(--accent); }
.dim { color: var(--dim); }
.hidden { display: none !important; }

.ticker {
  display: flex; align-items: center; gap: 10px;
  margin: 12px 12px 0 0; padding: 10px 12px;
  width: calc(100% - 12px); text-align: left;
  background: var(--card); border-radius: 12px;
}
.ticker-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: #e26d5a;
  box-shadow: 0 0 0 0 color-mix(in srgb, #e26d5a 55%, transparent);
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.ticker-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ticker-k { font-size: 10px; color: var(--dim); letter-spacing: .12em; }
.ticker-t {
  font-size: 13px; line-height: 18px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ticker-go { color: var(--dim); font-size: 18px; line-height: 1; }

.news-feed { padding: 4px 16px 28px; }
.news-ch { margin: 0 0 12px; }
.mover-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; }
.mover {
  background: var(--pill); border-radius: 999px;
  padding: 5px 10px; font-size: 11px; color: var(--dim);
}
.mover.up { color: #e26d5a; }
.mover.down { color: var(--near); }
.news-tl { display: flex; flex-direction: column; }
.news-row {
  display: grid; grid-template-columns: 52px 14px 1fr;
  column-gap: 2px; text-align: left; cursor: pointer; padding-bottom: 14px;
}
.news-time {
  font-size: 11px; color: var(--dim); padding-top: 6px;
  font-variant-numeric: tabular-nums;
}
.news-rail { position: relative; display: flex; justify-content: center; }
.news-rail::before {
  content: ""; position: absolute; top: 16px; bottom: -14px; left: 50%;
  width: 1px; background: #24303a; transform: translateX(-50%);
}
.news-row:last-child .news-rail::before { display: none; }
.news-dot {
  width: 9px; height: 9px; border-radius: 50%; margin-top: 8px;
  border: 2px solid var(--accent); background: var(--bg); z-index: 1;
}
.news-row.on .news-dot { background: var(--accent); }
.news-body {
  background: var(--card); border-radius: 14px; padding: 12px 14px;
}
.news-row.on .news-body { outline: 1px solid color-mix(in srgb, var(--accent) 28%, transparent); }
.news-body p {
  margin: 0; font-size: 14px; line-height: 22px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.news-body p.news-full-inline {
  display: block; -webkit-line-clamp: unset; white-space: pre-wrap;
}
.news-mini {
  display: flex; gap: 10px; width: 100%; text-align: left;
  padding: 8px 0; border-top: 1px solid #1e242c;
}
.news-mini-time { color: var(--dim); font-size: 11px; flex-shrink: 0; padding-top: 2px; }
.news-mini-text {
  font-size: 13px; line-height: 20px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.news-more { color: var(--accent); font-size: 12px; margin-top: 10px; }
.sheet.news-sheet { max-height: 82dvh; overflow: auto; }
.news-full { font-size: 15px; line-height: 24px; white-space: pre-wrap; margin-top: 10px; }
.link { color: var(--accent); font-size: 13px; margin-top: 10px; display: inline-block; }

.chart-wrap { margin-top: 14px; }
.chart-svg { width: 100%; height: 168px; display: block; }
.seg { display: flex; gap: 6px; margin: 8px 0 4px; }
.seg button {
  flex: 1; background: var(--pill); border-radius: 8px; padding: 7px 0;
  font-size: 12px; color: var(--dim);
}
.seg button.on { color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.calc-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid #1e242c; }
.calc-row .name { flex: 1; }
.calc-row input {
  width: 92px; background: var(--bg); border: 1px solid #2a3138; border-radius: 8px;
  padding: 8px 10px; text-align: right;
}
.hero-sm { font-size: 32px; font-weight: 600; line-height: 1.1; }
