/* Data is replaced inside stable slots; no section is removed while fetching. */
.research-surface { position: relative; min-width: 0; }
.research-surface:not([data-state="ready"]) #researchContent { visibility: hidden; pointer-events: none; }
.research-surface:not([data-state="ready"]) { background: repeating-linear-gradient(180deg, #edf4f5 0 160px, transparent 160px 180px); border-radius: 18px; }
.research-feedback { position: absolute; z-index: 5; top: 18px; left: 18px; right: 18px; margin: 0; background: #f5fafb; color: #365863; border-color: #cbdfe4; }
.research-surface[data-state="error"] .research-feedback { background: var(--alert-bg); color: var(--alert-text); border-color: var(--alert-border); }
.research-feedback[hidden] { display: none; }
.data-status { width: min(380px, 100%); min-height: 44px; white-space: normal; }
#dataStatus { min-height: 2.8em; display: flex; align-items: center; }
/* Reserve loading space without turning summary cards into scroll containers.
   The decorative rings intentionally extend past the cards and must be clipped,
   rather than counted as scrollable content. Real content can grow vertically. */
.hero-grid { grid-template-columns: minmax(0, 1.18fr) minmax(0, 1fr); align-items: stretch; }
.hero-grid .status-panel, .hero-grid .metric-grid { height: auto; min-height: 420px; min-width: 0; }
.hero-grid .status-panel, .hero-grid .metric-panel { overflow: hidden; overflow: clip; overflow-wrap: anywhere; }
.hero-grid .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }
.hero-grid .metric-panel { min-width: 0; min-height: 150px; }
.hero-grid .status-footer { flex-wrap: wrap; row-gap: 8px; }
.hero-grid .absolute-guard-heading { flex-wrap: wrap; }
#pairChartDescription { min-height: 4.6em; overflow: visible; }
#pairLegend { min-height: 28px; overflow: visible; align-content: start; }
#assetRows { min-height: 0; height: auto; overflow: visible; align-content: start; }
#windowCaption { min-width: 138px; flex-shrink: 0; }
.assets-panel .panel-heading { flex-wrap: wrap; }
.assets-panel .panel-heading > div { flex: 1 1 220px; }
#timeline { height: 500px; max-height: none; }
#absoluteEvents { height: 220px; max-height: none; align-content: start; }
#backtestWindow, #backtestSummary, #backtestDetail, #backtestLegend { height: auto; min-height: 0; overflow: visible; }
#backtestLegend { align-content: start; }
.footer-strip { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
#healthText { grid-column: 1 / -1; min-height: 2.8em; overflow: visible; }
.email-capacity-notice { display: block; min-height: 2.8em; height: auto; margin: 0; overflow: visible; background: #f3f8f9; border-color: #dce8ec; color: var(--muted-strong); }
.email-capacity-notice.capacity-full { background: #fff6e5; color: #8c621e; }
.email-status { min-height: 2.8em; height: auto; overflow: visible; }

.metric-explainer { margin: 14px 0; color: var(--muted-strong); font-size: 14px; line-height: 1.8; }
.metric-explainer summary { color: #087d7d; font-weight: 700; cursor: pointer; }
.metric-explainer dl { display: grid; grid-template-columns: minmax(120px, .25fr) minmax(0, 1fr); gap: 10px 18px; padding: 15px; border: 1px solid #dce9eb; border-radius: 12px; background: #f6fbfb; }
.metric-explainer dt { font-weight: 700; color: var(--ink); }
.metric-explainer dd { margin: 0; }
@media (max-width: 640px) {
  .metric-explainer dl { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .metric-explainer dd { margin-bottom: 10px; }
  .backtest-comparison-row .strategy-value::before { content: "含回撤防守"; }
  .backtest-comparison-row .signal-value::before { content: "仅相对状态"; }
  .backtest-comparison-row .benchmark-value::before { content: "持有 QQQ"; }
}

.control-hint { display: block; min-height: 3.2em; max-width: 210px; margin-top: 7px; color: var(--muted-strong); font-size: 12px; line-height: 1.6; }
.voting-guide { margin: 0 0 18px; padding: 17px 20px; border: 1px solid #d7e6e9; border-radius: 15px; background: #f8fcfc; }
.voting-guide-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 18px; margin-bottom: 12px; font-size: 14px; }
.voting-guide-heading strong { color: var(--ink); }
.voting-guide-heading span { color: var(--muted-strong); }
.voting-bands { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 9px; }
.voting-band { display: flex; align-items: center; justify-content: center; min-height: 48px; padding: 8px 10px; border: 1px solid #dde8e9; border-radius: 10px; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: center; }
.voting-band.growth { color: #086f68; background: #e8f6f2; }
.voting-band.neutral { color: #866223; background: #fbf5e8; }
.voting-band.defensive { color: #a24540; background: #fff0ed; }
.voting-details { margin-top: 12px; font-size: 14px; line-height: 1.8; color: var(--muted-strong); }
.voting-details summary { color: #087d7d; font-weight: 700; cursor: pointer; }
.voting-details p { margin: 12px 0; }
#votingRealExample { min-height: 2.8em; height: auto; overflow: visible; padding: 8px 12px; border-left: 3px solid #a98c50; background: #fcf8ee; }
.neutral-swatch { background: var(--amber); }
@media (max-width: 640px) {
  .control-hint { min-height: 0; max-width: none; }
  .voting-guide { padding: 15px 14px; }
  .voting-bands { grid-template-columns: minmax(0, 1fr); }
  .voting-band { min-height: 42px; }
  #votingRealExample { height: 9em; }
}

.research-lab { margin-bottom: 18px; min-width: 0; }
.research-lab .panel-heading { align-items: center; }
.research-lab .inline-link { font-size: 13px; line-height: 1.6; white-space: normal; }
.research-tabs { display: flex; gap: 5px; flex-wrap: wrap; margin: 16px 0; padding: 5px; border-radius: 12px; background: #eff5f7; width: fit-content; }
.research-tabs button { min-height: 40px; padding: 8px 18px; border: 0; border-radius: 9px; font: inherit; font-size: 14px; color: var(--muted-strong); background: transparent; }
.research-tabs button[aria-selected="true"] { background: #fff; color: #096d70; box-shadow: 0 2px 8px #173b4814; font-weight: 700; }
.research-tabs button:focus-visible, .research-button:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.research-lab-body { min-height: 520px; height: auto; overflow: visible; padding-right: 0; }
.research-lab-body [hidden] { display: none; }
.research-note { margin: 0 0 16px; color: var(--muted-strong); font-size: 14px; line-height: 1.8; }
.research-table-wrap { overflow: auto; max-width: 100%; }
.research-table { border-collapse: collapse; width: 100%; min-width: 680px; font-size: 13px; line-height: 1.7; font-variant-numeric: tabular-nums; }
.research-table th, .research-table td { padding: 11px 13px; border-bottom: 1px solid #dce7ea; text-align: left; vertical-align: top; }
.research-table th { background: #eef6f7; color: #365863; font-weight: 700; }
.research-table tbody tr:nth-child(even) { background: #f8fbfc; }
.research-formula { padding: 12px 16px; border-left: 3px solid #218a88; background: #eff8f7; color: #365c63; font-size: 14px; line-height: 1.9; }
.research-actions { display: flex; align-items: start; gap: 12px; flex-wrap: wrap; margin: 16px 0; }
.research-button { border: 1px solid #087d7d; border-radius: 9px; padding: 10px 16px; font: inherit; font-size: 14px; background: #087d7d; color: #fff; cursor: pointer; }
.research-button:disabled { opacity: .65; cursor: wait; }
#recalculationResult { flex: 1 1 400px; min-width: 0; white-space: pre-line; font-size: 13px; line-height: 1.8; overflow-wrap: anywhere; }
.confirmation-proof { font-size: 14px; margin: 16px 0; }
.confirmation-proof summary { cursor: pointer; color: #087d7d; padding: 8px 0; }
#confirmationProof { overflow: visible; }
.research-feedback-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 16px 0; font-size: 13px; }
.research-feedback-actions button { padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; color: #365863; background: #fff; font: inherit; }
#sensitivityResult, #forwardResult { margin-top: 16px; font-size: 14px; line-height: 1.8; }
@media (max-width: 860px) {
  .hero-grid { grid-template-columns: minmax(0, 1fr); }
  .hero-grid .status-panel { min-height: 380px; }
  .hero-grid .metric-grid { min-height: 320px; }
  #pairChartDescription { min-height: 0; }
}
@media (max-width: 520px) {
  .research-feedback { left: 10px; right: 10px; padding: 17px 14px; }
  .hero-grid .status-panel { min-height: 520px; }
  .hero-grid .metric-grid { min-height: 0; grid-template-columns: minmax(0, 1fr); grid-auto-rows: auto; }
  .hero-grid .metric-panel { min-height: 0; }
  #pairLegend, #assetRows, #backtestSummary, #backtestWindow, #backtestDetail, #backtestLegend,
  .email-capacity-notice, .email-status { height: auto; }
  .footer-strip { grid-template-columns: minmax(0, 1fr); }
  .research-tabs { width: 100%; }
  .research-tabs button { flex: 1; padding: 8px 6px; font-size: 13px; }
  .research-lab-body { min-height: 0; height: auto; padding-right: 0; }
  .research-lab .panel-heading .inline-link { display: inline-block; margin-top: 12px; }
}
