/* 游资情绪引擎 —— 暗色主题 */
:root {
  --bg: #0d1117;
  --bg2: #131a24;
  --card: #161f2c;
  --card2: #1b2534;
  --line: #243146;
  --txt: #d5dde8;
  --txt2: #8b98ab;
  --up: #ef4444;
  --down: #22c55e;
  --accent: #f0a020;
  --blue: #5b8def;
  --purple: #c026d3;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); color: var(--txt); font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif; font-size: 14px; }
a { color: var(--blue); text-decoration: none; }
b { color: #fff; }

.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 22px; background: var(--bg2);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 100; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.logo { font-size: 26px; }
.brand-name { font-size: 17px; font-weight: 700; color: #fff; letter-spacing: 1px; }
.brand-sub { font-size: 11px; color: var(--txt2); }
.nav { display: flex; gap: 6px; flex: 1; }
.nav a {
  padding: 7px 14px; border-radius: 8px; color: var(--txt2); font-size: 14px; cursor: pointer;
}
.nav a:hover { color: #fff; background: var(--card); }
.nav a.active { color: #fff; background: var(--card2); font-weight: 600; }
.search-wrap { position: relative; }
#searchInput {
  width: 220px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--txt); outline: none; font-size: 13px;
}
#searchInput:focus { border-color: var(--blue); }
.search-drop {
  position: absolute; top: 40px; left: 0; width: 260px; max-height: 320px; overflow: auto;
  background: var(--card2); border: 1px solid var(--line); border-radius: 8px; display: none; z-index: 200;
}
.search-drop .s-item { padding: 8px 12px; cursor: pointer; display: flex; justify-content: space-between; }
.search-drop .s-item:hover { background: var(--line); }
.search-drop .s-item .c { color: var(--txt2); font-size: 12px; }

main { max-width: 1280px; margin: 0 auto; padding: 18px 22px 40px; }
.foot { text-align: center; color: var(--txt2); font-size: 12px; padding: 18px 30px 26px; border-top: 1px solid var(--line); line-height: 1.7; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.card h3 { font-size: 15px; margin-bottom: 12px; color: #fff; display: flex; align-items: center; gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }
@media (max-width: 1200px) { .grid5 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 1000px) { .grid2, .grid4, .grid5 { grid-template-columns: 1fr; } }

/* 情绪徽章 */
.phase-badge {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 16px;
  border-radius: 999px; font-size: 18px; font-weight: 700; color: #fff;
}
.temp-bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin: 10px 0 4px; }
.temp-bar > div { height: 100%; border-radius: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  background: var(--card2); border: 1px solid var(--line); padding: 5px 11px;
  border-radius: 8px; font-size: 13px; color: var(--txt);
}
.chip b { font-size: 14px; }
.chip .lbl { color: var(--txt2); font-size: 12px; margin-right: 5px; }
.up { color: var(--up) !important; }
.down { color: var(--down) !important; }
.muted { color: var(--txt2); }
.small { font-size: 12px; }

/* 天梯 */
.ladder-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.ladder-row:last-child { border-bottom: none; }
.board-tag {
  min-width: 44px; text-align: center; padding: 3px 6px; border-radius: 6px;
  background: linear-gradient(135deg, #e04545, #f0a020); color: #fff; font-weight: 700; font-size: 13px;
}
.stock-chip {
  display: inline-block; padding: 3px 9px; margin: 2px; border-radius: 6px;
  background: var(--card2); border: 1px solid var(--line); cursor: pointer; font-size: 12.5px;
}
.stock-chip:hover { border-color: var(--accent); color: #fff; }
.sector-chip { display: inline-block; padding: 6px 12px; margin: 3px; border-radius: 8px; background: var(--card2); border: 1px solid var(--line); font-size: 13px; cursor: default; }
.sector-chip b { color: var(--accent); }

/* 明日买入推荐榜 */
.top-row { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); cursor: pointer; }
.top-row:hover { background: rgba(91, 141, 239, 0.06); }
.top-row:last-of-type { border-bottom: none; }
.top-row .rank {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; margin-top: 2px; background: var(--card2); color: #8b98ab; border: 1px solid var(--line);
}
.top-row .rank.r1 { background: linear-gradient(135deg, #f5c542, #e04545); color: #fff; border: none; }
.top-row .rank.r2 { background: linear-gradient(135deg, #a8b4c4, #6b7a8f); color: #fff; border: none; }
.top-row .rank.r3 { background: linear-gradient(135deg, #d9925f, #a05a2c); color: #fff; border: none; }
.top-row .top-main { flex: 1; min-width: 0; }
.top-row .l1 { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 14.5px; }
.top-row .l2 { margin: 3px 0; }
.top-row .l3 { line-height: 1.55; }
.style-mini { display: inline-block; padding: 1px 7px; border-radius: 6px; border: 1px solid; font-size: 11px; background: var(--card2); }

/* 游资卡片 */
.style-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; }
.style-card .head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.style-card .emoji { font-size: 26px; }
.style-card .name { font-size: 16px; font-weight: 700; color: #fff; }
.style-card .tagline { font-size: 11.5px; color: var(--txt2); }
.style-card .quote { font-size: 12px; color: #b8a06a; font-style: italic; margin: 6px 0 8px; min-height: 32px; line-height: 1.5; }
.score-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; cursor: pointer; border-radius: 8px; }
.score-row:hover { background: var(--card2); }
.score-row .nm { width: 86px; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score-row .bar { flex: 1; height: 7px; background: var(--line); border-radius: 4px; overflow: hidden; }
.score-row .bar > div { height: 100%; border-radius: 4px; }
.score-row .sc { width: 30px; text-align: right; font-weight: 700; font-size: 13px; }
.stance-tag { display: inline-block; margin-top: 8px; padding: 4px 10px; border-radius: 6px; font-size: 12px; background: var(--card2); border: 1px solid var(--line); }
.reason-snippet { font-size: 11.5px; color: var(--txt2); margin-top: 3px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* 个股页 */
.stock-head { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.stock-head .nm { font-size: 24px; font-weight: 800; color: #fff; }
.stock-head .px { font-size: 24px; font-weight: 700; }
.stock-head .meta { color: var(--txt2); font-size: 13px; }
.toolbar { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; align-items: center; }
.tbtn {
  padding: 5px 12px; border-radius: 7px; border: 1px solid var(--line); background: var(--card2);
  color: var(--txt2); cursor: pointer; font-size: 12.5px;
}
.tbtn:hover { color: #fff; }
.tbtn.on { color: #fff; border-color: var(--accent); background: rgba(240, 160, 32, 0.12); }
.btn {
  display: inline-block; padding: 8px 18px; border-radius: 8px; border: none; cursor: pointer;
  background: var(--accent); color: #1a1a1a; font-weight: 700; font-size: 13.5px;
}
.btn.blue { background: var(--blue); color: #fff; }
.btn.ghost { background: var(--card2); color: var(--txt); border: 1px solid var(--line); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

#kchart { width: 100%; height: 640px; }
.stock-layout { display: grid; grid-template-columns: 1fr 380px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .stock-layout { grid-template-columns: 1fr; } }
.side-tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.side-tabs .t { flex: 1; text-align: center; padding: 8px; border-radius: 8px; background: var(--card2); color: var(--txt2); cursor: pointer; font-size: 13px; }
.side-tabs .t.on { background: var(--card); color: #fff; font-weight: 600; border: 1px solid var(--accent); }
.explain-sec { padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13px; line-height: 1.75; }
.explain-sec:last-child { border-bottom: none; }
.explain-sec .h { color: var(--accent); font-weight: 700; font-size: 12.5px; margin-bottom: 3px; }
.view-card { background: var(--card2); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; margin: 8px 0; font-size: 12.5px; line-height: 1.7; }
.view-card .vh { font-weight: 700; margin-bottom: 4px; }
.style-tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-bottom: 10px; }
.style-tabs .st { text-align: center; padding: 6px 1px; border-radius: 8px; background: var(--card2); cursor: pointer; font-size: 11.5px; white-space: nowrap; }
.style-tabs .st.on { border: 1px solid var(--accent); color: #fff; font-weight: 600; }
.style-tabs .st .sc { display: block; font-size: 15px; font-weight: 800; }
.pz-bar { height: 10px; border-radius: 5px; background: var(--line); margin: 8px 0; overflow: hidden; }
.pz-bar > div { height: 100%; background: linear-gradient(90deg, #f0a020, #e04545); }
.reason-li { padding: 5px 0 5px 14px; position: relative; font-size: 12.5px; line-height: 1.65; color: var(--txt); }
.reason-li::before { content: '•'; position: absolute; left: 2px; color: var(--accent); }
.risk-li { padding: 5px 0 5px 14px; position: relative; font-size: 12.5px; line-height: 1.65; color: #d8a1a1; }
.risk-li::before { content: '⚠'; position: absolute; left: 0; font-size: 11px; }

/* 复盘 */
table.pred { width: 100%; border-collapse: collapse; font-size: 13px; }
table.pred th { text-align: left; color: var(--txt2); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 12px; }
table.pred td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
table.pred tr.rowmain:hover { background: var(--card2); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: 11.5px; font-weight: 600; }
.badge.ok { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.badge.no { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge.pend { background: rgba(91, 141, 239, 0.15); color: #93b4f5; }
.badge.bt { background: rgba(192, 38, 211, 0.15); color: #e879f9; }
.stat-card { text-align: center; padding: 14px; }
.stat-card .v { font-size: 26px; font-weight: 800; color: #fff; }
.stat-card .k { font-size: 12px; color: var(--txt2); margin-top: 4px; }
.detail-box { background: var(--card2); border-radius: 10px; padding: 12px 14px; margin-top: 8px; font-size: 12.5px; line-height: 1.75; }

.loading { text-align: center; color: var(--txt2); padding: 60px 0; font-size: 14px; }
.loading .spin { display: inline-block; width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; margin-bottom: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-box { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.4); border-radius: 10px; padding: 14px; color: #f8b4b4; }
.hero-tip { font-size: 12px; color: var(--txt2); margin-top: 8px; line-height: 1.7; }
.backtest-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
select, input[type=date] {
  padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--txt); font-size: 13px; outline: none;
}
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 12px; }
.section-title h2 { font-size: 18px; color: #fff; }
.disclaimer { font-size: 12px; color: var(--txt2); background: var(--card2); border-radius: 8px; padding: 10px 12px; margin-top: 14px; line-height: 1.7; }

/* ---------- 移动端适配（iOS Safari / 竖屏优先降级，横屏完整双栏） ---------- */
.rotate-hint {
  display: none; align-items: center; gap: 10px; justify-content: center;
  padding: 8px 14px; font-size: 12.5px; color: #ffd54f;
  background: rgba(240, 160, 32, 0.12); border-bottom: 1px solid rgba(240, 160, 32, 0.35);
}
.rotate-hint button { margin-left: 8px; background: none; border: 1px solid var(--line); color: var(--txt2); border-radius: 6px; width: 22px; height: 22px; cursor: pointer; }
@media (max-width: 950px) {
  .topbar { padding: 8px 12px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); gap: 10px; }
  .brand-sub { display: none; }
  .brand-name { font-size: 15px; }
  .logo { font-size: 22px; }
  .nav { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; padding: 6px 10px; font-size: 13px; }
  .search-wrap { order: 10; width: 100%; }
  #searchInput { width: 100%; font-size: 16px; }  /* 16px 防 iOS 聚焦自动放大 */
  main { padding: 12px 12px 30px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .card { padding: 12px; }
  #kchart { height: 440px; }
  .stock-head .nm { font-size: 20px; }
  .stock-head .px { font-size: 18px; }
  .foot { padding: 14px 16px 22px; }
}
@media (max-width: 950px) and (orientation: portrait) {
  .rotate-hint { display: flex; }
}
/* 手机横屏：完整双栏，顶栏压缩为单行 */
@media (max-width: 950px) and (orientation: landscape) {
  .rotate-hint { display: none; }
  .topbar { padding: 6px 10px; gap: 10px; flex-wrap: nowrap; align-items: center; }
  .nav { flex: 0 1 auto; }
  .search-wrap { margin-left: auto; }
  #searchInput { width: 150px; font-size: 16px; padding: 6px 10px; }
  #kchart { height: 375px; }
  .stock-layout { display: grid; grid-template-columns: 1.35fr 1fr; gap: 10px; align-items: start; }
  main { padding: 8px 10px 16px; }
  .card { padding: 10px 12px; margin-bottom: 10px; }
  .grid2 { grid-template-columns: 1fr 1fr; }
  .grid5 { grid-template-columns: repeat(2, 1fr); }
  .side-panel-max { max-height: 60vh; overflow-y: auto; }
}
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table.pred { min-width: 640px; }
