:root {
  --bg: #0d1117;
  --panel: #131722;
  --grid: #1e222d;
  --text: #d1d4dc;
  --muted: #787b86;
  --up: #f23645;     /* 涨 = 红（中国市场习惯） */
  --down: #089981;   /* 跌 = 绿 */
  --ob-bull: #f23645;
  --ob-bear: #089981;
  --fvg-bull: #f23645;
  --fvg-bear: #089981;
  --hh: #f23645;
  --bar: #2a2e39;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden; overscroll-behavior: none;
}

body {
  display: flex; flex-direction: column;
  height: 100dvh;
}

/* 顶部栏 */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--panel); border-bottom: 1px solid var(--grid);
  flex: 0 0 auto;
}
.sym { flex: 0 0 auto; }
.sym-name { font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.sym-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.quote { flex: 1 1 auto; text-align: right; }
.last { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.last.up { color: var(--up); }
.last.down { color: var(--down); }
.last.flat { color: var(--text); }
.ba { font-size: 12px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.ba .ask { color: var(--down); margin-left: 8px; }
.ba .bid { color: var(--up); }
.ba b { font-weight: 600; }

.smc-btn {
  flex: 0 0 auto;
  min-width: 44px; min-height: 36px; padding: 0 12px;
  background: var(--bar); color: var(--text);
  border: 1px solid var(--grid); border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.smc-btn:active { background: #353a45; }

/* 图表 */
.chart-wrap { position: relative; flex: 1 1 auto; min-height: 0; }
#chart { position: absolute; inset: 0; }
#chart canvas { touch-action: none; }

.legend {
  position: absolute; top: 8px; left: 10px; z-index: 4;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  font-size: 12px; font-variant-numeric: tabular-nums;
  background: rgba(13,17,23,.55); padding: 4px 8px; border-radius: 6px;
  pointer-events: none; max-width: 92%;
}
.legend .lg-time { color: var(--muted); }
.legend .lg-item { color: var(--text); }
.legend b { font-weight: 600; }

.status {
  position: absolute; bottom: 8px; left: 10px; z-index: 4;
  font-size: 11px; color: var(--muted);
  background: rgba(13,17,23,.55); padding: 3px 8px; border-radius: 6px;
  pointer-events: none; max-width: 90%;
}
.status.err { color: #ff6b6b; }

/* 底部周期栏 */
.tfbar {
  flex: 0 0 auto; display: flex; gap: 6px;
  padding: 8px 10px; padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--grid);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.tfbar::-webkit-scrollbar { display: none; }
.tfbar button {
  flex: 1 0 auto; min-width: 44px; min-height: 40px;
  background: var(--bar); color: var(--text);
  border: 1px solid transparent; border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.tfbar button.active { background: #2962ff; color: #fff; border-color: #2962ff; }
.tfbar button:active { opacity: .8; }

/* SMC 面板 */
.sheet-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 20; display: none;
}
.sheet-mask.show { display: block; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  background: var(--panel); border-top-left-radius: 14px; border-top-right-radius: 14px;
  padding: 16px 16px max(16px, env(safe-area-inset-bottom));
  transform: translateY(110%); transition: transform .22s ease;
  max-height: 80dvh; overflow-y: auto;
}
.sheet.show { transform: translateY(0); }
.sheet-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 15px; font-weight: 700; margin-bottom: 12px;
}
.sheet-close {
  width: 34px; height: 34px; border-radius: 8px; border: none;
  background: var(--bar); color: var(--text); font-size: 20px; line-height: 1; cursor: pointer;
}
.row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 4px; font-size: 14px; border-bottom: 1px solid var(--grid);
}
.row.master { font-weight: 700; border-bottom: 2px solid var(--grid); }
.row input { width: 44px; height: 24px; }
.group { margin-top: 4px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.dot.ob-bull { background: rgba(242,54,69,.55); }
.dot.fvg-bull { background: rgba(242,54,69,.3); border: 1px dashed var(--fvg-bull); }
.dot.hh { background: var(--hh); border-radius: 50%; }
.hint { margin-top: 14px; font-size: 12px; color: var(--muted); line-height: 1.6; }
.hint span { color: var(--text); }
