/* 研究页（2026-10-16，取代 aimatic-lab）：左 我的研究 · 中 对话 · 右 这次研究里的股票和选股 */
.research-page { overflow: hidden; }
.rs-main {
  display: grid; grid-template-columns: 232px minmax(0, 1fr) 300px; height: calc(100vh - 49px);
  gap: 0; background: var(--bg);
}
.rs-list, .rs-work { background: var(--panel); overflow-y: auto; min-height: 0; }
.rs-list { border-right: 1px solid var(--line); }
.rs-work { border-left: 1px solid var(--line); }
.rs-pad { padding: 12px; line-height: 1.6; }
.grow { flex: 1; }
.rs-only-narrow { display: none; }

/* 我的研究 */
.rs-threads { list-style: none; margin: 0; padding: 6px; }
.rs-threads li {
  padding: 8px 10px; border-radius: 6px; cursor: pointer; display: flex; flex-direction: column; gap: 2px;
  border: 1px solid transparent;
}
.rs-threads li:hover { background: #f2f3f5; }
.rs-threads li.on { background: #e8f3ff; border-color: #bedaff; }
.rs-threads .t-title { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rs-threads .t-sub { font-size: 11px; color: var(--muted); }
.rs-threads .t-lab { color: #8a5a00; }

/* 中间 */
.rs-chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.rs-start { overflow-y: auto; padding: 48px max(24px, calc((100% - 760px) / 2)) 32px; }
.rs-hello h1 { margin: 0 0 8px; font-size: 26px; letter-spacing: .3px; }
.rs-hello p { margin: 0 0 18px; color: #4e5969; line-height: 1.7; }
.rs-ask { display: flex; flex-direction: column; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.rs-ask:focus-within { border-color: #91caff; box-shadow: 0 0 0 3px rgba(28, 111, 214, .08); }
.rs-ask textarea { border: none; padding: 2px 0; resize: none; outline: none; line-height: 1.6; }
.rs-ask.big textarea { font-size: 15px; }
.rs-ask-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.rs-section-head { margin: 26px 0 10px; font-weight: 600; font-size: 13px; color: #4e5969; }
.rs-starters { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.starter {
  text-align: left; white-space: normal; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; line-height: 1.55; display: flex; flex-direction: column; gap: 6px;
}
.starter:hover { border-color: #91caff; background: #fbfdff; }
.starter .from { font-size: 11px; color: var(--muted); }
.starter .from.mine { color: var(--accent); }
.rs-can { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rs-can .can { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #f2f3f5; color: #4e5969; }
.rs-warn { margin-top: 16px; padding: 10px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); }

.rs-thread { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.rs-thread-head {
  display: flex; align-items: baseline; gap: 10px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.rs-thread-head b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
.rs-msgs { flex: 1; overflow-y: auto; padding: 18px max(20px, calc((100% - 780px) / 2)) 8px; display: flex; flex-direction: column; gap: 16px; }
.rs-thread > .rs-ask { margin: 8px max(20px, calc((100% - 780px) / 2)) 14px; }

.msg-q { align-self: flex-end; max-width: 80%; background: #1d2129; color: #fff; padding: 9px 13px; border-radius: 12px 12px 2px 12px; line-height: 1.6; white-space: pre-wrap; }
.msg-a { display: flex; gap: 10px; align-items: flex-start; }
.msg-a .avatar { margin-top: 2px; }
.a-body { flex: 1; min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 2px 12px 12px 12px; padding: 12px 14px; }
.a-text { line-height: 1.75; word-break: break-word; }
.a-text p { margin: 0 0 8px; }
.a-text p:last-child { margin-bottom: 0; }
.a-text ul, .a-text ol { margin: 4px 0 8px; padding-left: 20px; }
.a-text li { margin: 2px 0; }
.a-text .flag { color: var(--warn); font-size: 12px; }
.mention {
  display: inline; padding: 0 4px; margin: 0 1px; border: none; border-radius: 4px; background: #e8f3ff; color: var(--accent);
  font: inherit; cursor: pointer; white-space: nowrap;
}
.mention:hover { background: #d6e8ff; }
.ref { font-size: 11px; color: var(--accent); cursor: pointer; padding: 0 2px; vertical-align: super; }
.a-refs { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 3px; }
.a-refs a { font-size: 12px; color: #4e5969; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.a-refs a:hover { color: var(--accent); }
.a-refs .n { color: var(--accent); margin-right: 4px; }
.a-meta { margin-top: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 12px; color: var(--muted); }
.a-meta details { flex-basis: 100%; }
.a-meta summary { cursor: pointer; list-style: none; }
.a-meta summary::-webkit-details-marker { display: none; }
.a-meta ol { margin: 4px 0 0; padding-left: 18px; }
.a-screens { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.a-screen { display: flex; gap: 8px; align-items: center; font-size: 12px; background: #f7f8fa; border-radius: 6px; padding: 6px 8px; }
.a-screen .s-q { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fb { display: inline-flex; gap: 4px; margin-left: auto; }
.fb button { padding: 1px 8px; font-size: 12px; }
.fb button.on { background: #e8f3ff; border-color: #91caff; color: var(--accent); }
.fb-note { display: flex; gap: 6px; flex-basis: 100%; }
.fb-note input { flex: 1; }
.follow { display: flex; gap: 6px; flex-wrap: wrap; margin: -6px 0 0 34px; }
.follow button { font-size: 12px; padding: 3px 10px; border-radius: 12px; color: #4e5969; }

.pending .a-body { border-style: dashed; }
.steps { list-style: none; margin: 6px 0 0; padding: 0; font-size: 13px; color: #4e5969; display: flex; flex-direction: column; gap: 4px; }
.steps li::before { content: "✓ "; color: var(--ok); }
.steps li.now::before { content: "… "; color: var(--accent); }
.thinking { color: var(--muted); }
.thinking .dots::after { content: ""; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "·"; } 50% { content: "··"; } 75% { content: "···"; } }
.a-err { color: var(--bad); }

/* 右：工作台 */
.work-stocks { padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.card {
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; display: flex; flex-direction: column; gap: 6px;
  background: #fff;
}
.card:hover { border-color: #c4c9d0; }
.card .c-top { display: flex; align-items: baseline; gap: 6px; }
.card .c-name { font-weight: 600; cursor: pointer; }
.card .c-name:hover { color: var(--accent); }
.card .c-px { margin-left: auto; font-variant-numeric: tabular-nums; }
.card .c-sub { font-size: 12px; color: var(--muted); }
.card .c-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.card .c-acts button, .card .c-acts a { font-size: 12px; padding: 2px 8px; }
.btn-link {
  display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; color: var(--text);
  text-decoration: none; background: var(--panel); white-space: nowrap;
}
.btn-link:hover { border-color: #c4c9d0; }
.in-pool { font-size: 11px; color: var(--ok); }
.work-screens { padding: 0 8px 12px; display: flex; flex-direction: column; gap: 8px; }
.work-screens .ws-head { font-size: 12px; color: var(--muted); padding: 6px 2px 0; }
.ws { border: 1px dashed var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; display: flex; flex-direction: column; gap: 4px; }
.ws .ws-q { color: var(--text); line-height: 1.5; }

/* K 线弹窗 */
dialog.kdlg { width: min(920px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
dialog.kdlg::backdrop { background: rgba(0, 0, 0, .3); }
.k-head { display: flex; align-items: baseline; gap: 8px; }
.k-head b { font-size: 17px; }
.k-state { margin: 8px 0 10px; line-height: 1.6; color: #4e5969; font-size: 13px; }
#kchart { display: block; width: 100%; height: 400px; cursor: crosshair; }
.k-actions { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
dialog.help-dlg { width: min(560px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 12px; padding: 20px 24px; line-height: 1.7; }
dialog.help-dlg h3 { margin: 4px 0 6px; font-size: 15px; }
dialog.help-dlg ul { margin: 0 0 12px; padding-left: 18px; }
dialog.help-dlg .row { display: flex; justify-content: flex-end; }
.rs-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1d2129; color: #fff; padding: 8px 14px;
  border-radius: 8px; z-index: 100; font-size: 13px;
}

@media (max-width: 1100px) {
  .rs-main { grid-template-columns: 210px minmax(0, 1fr) 260px; }
}
@media (max-width: 720px) {
  .research-page .top .agent, .research-page #btn-help { display: none; }
  .research-page .top .actions { margin-left: 0; }
}
@media (max-width: 900px) {
  .research-page { overflow: auto; }
  .rs-main { display: block; height: auto; }
  .rs-list { display: none; border-right: none; border-bottom: 1px solid var(--line); max-height: 50vh; }
  .rs-list.open { display: block; }
  .rs-only-narrow { display: inline-block; }
  .rs-start { padding: 24px 16px; }
  .rs-hello h1 { font-size: 21px; }
  .rs-thread { height: auto; }
  .rs-msgs { padding: 14px 16px 6px; overflow: visible; }
  .rs-thread > .rs-ask { margin: 8px 16px 14px; }
  .rs-thread-head { padding: 10px 16px; }
  .msg-q { max-width: 92%; }
  .rs-work { border-left: none; border-top: 1px solid var(--line); }
  .follow { margin-left: 0; }
  #kchart { height: 300px; }
}
