:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #16181c;
  --sub: #6b7280;
  --muted: #9aa0aa;
  --line: #ebedf0;
  --up: #df3b30;
  --down: #10a35c;
  --flat: #9aa0aa;
  --accent: #16181c;
  --radius: 14px;
  --tab-h: 56px;
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100%;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar .title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.topbar .spacer {
  flex: 1;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--sub);
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
}

.status.live .dot {
  background: var(--up);
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin: 0 -6px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.icon-btn:active {
  background: #f0f1f3;
}

/* ---------- 返回栏 ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.navbar .back {
  font-size: 15px;
  color: var(--ink);
}

.navbar .nav-title {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  padding-right: 44px;
}

/* ---------- 视图容器 ---------- */
main {
  padding: 12px 12px 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
}

.card-title {
  padding: 14px 16px 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--sub);
}

/* ---------- 主指数 ---------- */
.hero {
  padding: 18px 16px 16px;
}

.hero .name {
  font-size: 14px;
  color: var(--sub);
}

.hero .price {
  font-size: 40px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}

.hero .delta {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.hero .meta {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- 通用行 ---------- */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.row:last-child {
  border-bottom: 0;
}

.row:active {
  background: #f7f8fa;
}

.row .lead {
  flex: 1;
  min-width: 0;
}

.row .lead .name {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row .lead .code {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.row .nums {
  text-align: right;
  min-width: 96px;
}

.row .nums .last {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.row .nums .pct {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.badge {
  min-width: 72px;
  padding: 6px 10px;
  border-radius: 8px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--flat); }

/* 同时声明 color，避免被上面的 .up/.down 文字色覆盖成同色底同色字 */
.badge.up { background: var(--up); color: #fff; }
.badge.down { background: var(--down); color: #fff; }
.badge.flat { background: var(--flat); color: #fff; }

.rank-no {
  width: 22px;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- 市场宽度 ---------- */
.breadth {
  display: flex;
  gap: 10px;
}

.breadth .cell {
  flex: 1;
  padding: 14px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: center;
}

.breadth .cell .v {
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.breadth .cell .k {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.bar {
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  display: flex;
  background: var(--line);
}

.bar i {
  display: block;
  height: 100%;
}

/* ---------- 分段控件 ---------- */
.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 12px;
  background: #e9ebef;
  border-radius: 11px;
}

.seg button {
  flex: 1;
  padding: 8px 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 14px;
  color: var(--sub);
  font-weight: 500;
  cursor: pointer;
}

.seg button[aria-selected="true"] {
  background: #fff;
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* ---------- 详情 ---------- */
.detail-price {
  padding: 20px 16px 16px;
}

.detail-price .price {
  font-size: 44px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}

.detail-price .sub {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 4px;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
}

.stats .kv {
  background: #fff;
  padding: 12px 10px;
}

.stats .kv .k {
  font-size: 12px;
  color: var(--muted);
}

.stats .kv .v {
  margin-top: 3px;
  font-size: 15px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
}

.tabbar button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}

.tabbar button[aria-current="page"] {
  color: var(--ink);
}

.tabbar svg {
  width: 22px;
  height: 22px;
}

/* ---------- 搜索 / 空态 ---------- */
.searchbox {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 12px;
}

.searchbox input {
  flex: 1;
  border: 0;
  outline: 0;
  font-size: 16px;
  background: transparent;
  color: var(--ink);
}

.empty,
.loading,
.error {
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.error {
  color: var(--up);
}

.error button {
  margin-top: 14px;
  padding: 8px 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
}

.add-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px;
  color: var(--sub);
  font-size: 14px;
  cursor: pointer;
}

.hint {
  padding: 10px 4px 16px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.tool-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--sub);
}

.link-btn {
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  padding: 0;
  cursor: pointer;
}

.link-btn.muted {
  color: var(--muted);
}

/* ---------- 资讯 ---------- */
.news {
  display: block;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}

.news:last-child {
  border-bottom: 0;
}

.news:active {
  background: #f7f8fa;
}

.news .t {
  font-size: 15px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news .s {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--sub);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news .m {
  margin-top: 7px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.news .m .brk {
  color: var(--sub);
  font-weight: 500;
}

.tg {
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--sub);
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  padding: 6px 13px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--sub);
  font-size: 13px;
  cursor: pointer;
}

.chip[aria-selected="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

