:root {
  --bg: #0d1117;
  --card: #161d27;
  --card2: #1c2432;
  --line: #2a3444;
  --txt: #e6edf3;
  --sub: #8b98a9;
  --gold: #f5c451;
  --gold-deep: #c9930a;
  --up: #ff6b6b;
  --down: #3dd68c;
  --blue: #58a6ff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg); color: var(--txt);
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto;
}

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; position: sticky; top: 0; background: rgba(13,17,23,.92); backdrop-filter: blur(8px); z-index: 10; }
.brand { font-size: 17px; display: flex; align-items: center; gap: 8px; }
.gem { filter: drop-shadow(0 0 6px rgba(245,196,81,.6)); }

.ghost-btn { background: transparent; border: 1px solid var(--line); color: var(--txt); border-radius: 8px; padding: 6px 14px; font-size: 14px; cursor: pointer; }
.ghost-btn:active { background: var(--card2); }
.primary-btn { background: linear-gradient(135deg, var(--gold), var(--gold-deep)); color: #1b1400; border: none; border-radius: 10px; padding: 12px 18px; font-size: 16px; font-weight: 700; cursor: pointer; }
.primary-btn:active { opacity: .85; }
.primary-btn.wide { width: 100%; margin-top: 12px; }
.link { color: var(--blue); text-decoration: none; font-size: 13px; float: right; cursor: pointer; }

.announce { background: #2b2313; color: var(--gold); border-bottom: 1px solid #4a3b17; padding: 8px 16px; font-size: 13px; }
.risk-banner { background: #3a1d1d; color: #f4b8b8; padding: 8px 16px; font-size: 12.5px; line-height: 1.5; border-bottom: 1px solid #5c2b2b; cursor: pointer; }
.risk-banner .more { color: #ff9d9d; margin-left: 4px; white-space: nowrap; }

main { padding: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.card h3 { font-size: 15px; margin-bottom: 10px; }
.hint { color: var(--sub); font-size: 12.5px; line-height: 1.6; margin-bottom: 8px; }

/* 行情价格卡 */
.price-card { background: linear-gradient(160deg, #241d0d, #171408); border: 1px solid #4a3b17; border-radius: 14px; padding: 16px; margin-bottom: 12px; }
.price-card .label { color: var(--sub); font-size: 13px; }
.price-card .big { font-size: 34px; font-weight: 800; color: var(--gold); line-height: 1.2; }
.price-card .big small { font-size: 14px; font-weight: 400; color: var(--sub); }
.price-card .delta { font-size: 13px; margin-top: 2px; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.delta.flat { color: var(--sub); }
.price-card .empty { color: var(--sub); font-size: 14px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.stat-grid .cell { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat-grid .k { color: var(--sub); font-size: 12px; }
.stat-grid .v { font-size: 17px; font-weight: 700; margin-top: 2px; }
.stat-grid .v small { font-size: 11px; color: var(--sub); font-weight: 400; }

/* 走势图 */
#chart svg { width: 100%; height: auto; display: block; }

/* 成交记录 */
.deal-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.deal-row:last-child { border-bottom: none; }
.deal-row .l { color: var(--sub); font-size: 12px; }
.deal-row .u { font-weight: 700; color: var(--gold); white-space: nowrap; }
.deal-row .u em { font-style: normal; font-size: 11px; color: var(--sub); font-weight: 400; margin-left: 4px; }
.tag { display: inline-block; font-size: 11px; border-radius: 6px; padding: 1px 7px; margin-right: 6px; background: var(--card2); color: var(--sub); }
.tag.stock-ok { color: var(--down); }
.tag.stock-low { color: var(--gold); }
.tag.stock-out { color: var(--up); }
.tag.stale { color: var(--up); }
.tag.badge { color: var(--gold); border: 1px solid #4a3b17; }

/* 贡献榜 */
.contrib-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.contrib-row:last-child { border-bottom: none; }
.contrib-row .pts { color: var(--gold); font-weight: 700; }

/* 挂单 */
.listing { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: var(--card2); }
.listing .head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.listing .name { font-weight: 700; font-size: 15px; }
.listing .price { color: var(--gold); font-weight: 800; font-size: 18px; }
.listing .price small { font-size: 11px; color: var(--sub); font-weight: 400; }
.listing .note { color: var(--sub); font-size: 12.5px; margin: 4px 0 8px; }
.listing .ops { display: flex; gap: 8px; flex-wrap: wrap; }
.listing .ops button { flex: 1; min-width: 100px; }
.mini-btn { background: var(--card); border: 1px solid var(--line); color: var(--txt); border-radius: 8px; padding: 8px 10px; font-size: 13.5px; cursor: pointer; }
.mini-btn:active { background: #232d3f; }

/* 表单 */
form label { display: block; font-size: 13px; color: var(--sub); margin: 12px 0 6px; }
form input[type="number"], form input[type="text"], form input[type="password"], form input[type="date"], form input[type="url"] {
  width: 100%; background: var(--card2); border: 1px solid var(--line); color: var(--txt);
  border-radius: 10px; padding: 11px 12px; font-size: 16px; outline: none;
}
form input:focus { border-color: var(--gold-deep); }
.chips { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.chips button { background: var(--card2); border: 1px solid var(--line); color: var(--sub); border-radius: 999px; padding: 7px 14px; font-size: 13px; cursor: pointer; }
.chips button.on { border-color: var(--gold); color: var(--gold); background: #2b2313; }
.unit-preview { background: #10261c; border: 1px solid #1d4a34; border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin-top: 12px; }

/* tabbar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: rgba(13,17,23,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 20; }
.tabbar .tab { flex: 1; background: none; border: none; color: var(--sub); font-size: 11px; padding: 8px 0 6px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabbar .tab i { font-style: normal; font-size: 20px; }
.tabbar .tab.on { color: var(--gold); }

/* 弹层/Toast */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 24px; }
/* 铁律：hidden 属性会被显式 display 覆盖——不写这条，隐藏的弹层仍拦截全屏点击 */
.modal[hidden] { display: none; }
.modal-box { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; max-width: 420px; width: 100%; font-size: 14px; line-height: 1.7; }
.modal-box h4 { margin-bottom: 8px; }
.modal-actions { display: flex; gap: 10px; margin-top: 14px; }
.modal-actions button { flex: 1; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom)); background: #232f43; color: var(--txt); border: 1px solid var(--line); padding: 10px 18px; border-radius: 999px; font-size: 13.5px; z-index: 60; max-width: 86vw; text-align: center; }

/* SSR 快照（JS 接管后移除） */
.ssr-card { font-size: 13px; line-height: 1.8; color: var(--sub); margin-bottom: 12px; }
.ssr-card strong { color: var(--gold); font-size: 16px; }
.ssr-card table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.ssr-card td, .ssr-card caption { padding: 3px 4px; font-size: 12px; color: var(--txt); text-align: left; }
.ssr-card caption { color: var(--sub); text-align: left; }

.empty { color: var(--sub); font-size: 13px; padding: 14px 0; text-align: center; }
.me-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.me-head .pts { color: var(--gold); font-weight: 800; font-size: 20px; }
