:root {
  --bg: #0e1116;
  --bg-soft: #161b22;
  --bg-card: #1b212b;
  --border: #2a313c;
  --text: #e6edf3;
  --text-dim: #9aa7b4;
  --accent: #ff4d4f;       /* 涨停红 */
  --accent2: #ffb020;
  --up: #ff4d4f;
  --down: #1ec77d;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
  --radius: 12px;
}
html.light {
  --bg: #f4f6fa;
  --bg-soft: #ffffff;
  --bg-card: #ffffff;
  --border: #e3e8ef;
  --text: #1a2230;
  --text-dim: #6b7785;
  --accent: #e23b3e;
  --accent2: #d98a00;
  --up: #e23b3e;
  --down: #16a36a;
  --shadow: 0 6px 24px rgba(20,40,80,.10);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background .25s, color .25s;
}
a { color: var(--accent2); text-decoration: none; }

/* 顶栏 */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--bg-soft);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30;
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.spacer { flex: 1; }
select, input, button, .btn {
  font: inherit; color: var(--text); background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 11px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
select:focus, input:focus { outline: none; border-color: var(--accent2); }
.btn { display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--accent2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }

/* 回放控制条 */
.replaybar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 16px; background: var(--bg-soft); border-bottom: 1px solid var(--border);
}
.clock {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px;
  padding: 4px 10px; border-radius: 8px; background: var(--bg-card); border: 1px solid var(--border);
  min-width: 92px; text-align: center;
}
.replay-progress { flex: 1; min-width: 160px; height: 6px; background: var(--bg-card); border-radius: 3px; overflow: hidden; border: 1px solid var(--border); }
.replay-progress > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent2), var(--accent)); }
.speed-pills { display: flex; gap: 4px; }
.speed-pills .btn { padding: 5px 9px; font-size: 13px; }
.speed-pills .btn.active { background: var(--accent2); border-color: var(--accent2); color: #1a1a1a; }

/* 布局 */
.layout { display: grid; grid-template-columns: 1fr 340px; gap: 14px; padding: 14px; align-items: start; }
.chart-wrap { position: relative; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; }
#chart { width: 100%; height: 62vh; min-height: 420px; }

/* 侧栏：股票列表 */
.side { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; max-height: 78vh; }
.side h3 { margin: 0; padding: 12px 14px; font-size: 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.side .meta { color: var(--text-dim); font-weight: 400; font-size: 12px; }
.stock-search { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.stock-search input { width: 100%; }
.stock-list { overflow-y: auto; padding: 6px; }
.stock-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 9px; cursor: pointer;
  border: 1px solid transparent;
}
.stock-item:hover { background: var(--bg-soft); }
.stock-item.active { background: var(--bg-soft); border-color: var(--accent); }
.stock-item .nm { font-weight: 600; }
.stock-item .cd { color: var(--text-dim); font-size: 12px; }
.stock-item .tm { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--accent2); font-size: 13px; font-weight: 600; }
.stock-item .bd { font-size: 11px; color: var(--text-dim); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; }
.stock-item .rs { font-size: 11px; color: var(--text-dim); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 详情卡（覆盖在图上） */
.detail {
  position: absolute; right: 22px; bottom: 22px; width: 320px; max-width: calc(100vw - 44px);
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; display: none; z-index: 20;
}
.detail.show { display: block; animation: pop .18s ease; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.detail .close { position: absolute; top: 8px; right: 10px; cursor: pointer; color: var(--text-dim); font-size: 18px; line-height: 1; }
.detail h4 { margin: 0 0 2px; font-size: 16px; }
.detail .sub { color: var(--text-dim); font-size: 12px; margin-bottom: 10px; }
.detail .kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 13px; margin-bottom: 10px; }
.detail .kv b { color: var(--text-dim); font-weight: 500; }
.detail .analysis { font-size: 12.5px; line-height: 1.6; color: var(--text); background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; max-height: 160px; overflow-y: auto; }
.detail .reason-tag { display: inline-block; background: var(--accent); color: #fff; border-radius: 6px; padding: 1px 8px; font-size: 12px; font-weight: 600; }

.empty { color: var(--text-dim); text-align: center; padding: 60px 20px; }

/* 移动端 */
.menu-btn { display: none; }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  #chart { height: 52vh; }
  .menu-btn { display: inline-flex; }
  .side {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; max-height: 70vh;
    border-radius: 16px 16px 0 0; transform: translateY(100%); transition: transform .25s; z-index: 40;
  }
  .side.open { transform: none; }
  .side .handle { display: block; height: 5px; width: 42px; background: var(--border); border-radius: 3px; margin: 8px auto; }
  .detail { right: 10px; bottom: 10px; left: 10px; width: auto; }
  .replaybar .speed-pills { order: 3; }
}
.handle { display: none; }
