:root {
  --bg: #0f1218;
  --surface: #171b24;
  --border: #2a3142;
  --text: #e8ecf4;
  --muted: #8b95a8;
  --accent: #5b8cff;
  --accent-dim: #3d5a9e;
  --heat: rgba(255, 80, 40, 0.55);
  --radius: 10px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

.app {
  display: grid;
  grid-template-columns: 300px 1fr 320px;
  min-height: 100vh;
  gap: 0;
}

@media (max-width: 1100px) {
  .app {
    grid-template-columns: 1fr;
  }
}

.panel {
  border-right: 1px solid var(--border);
  padding: 1rem 1.1rem;
  background: var(--surface);
}

.panel:last-child {
  border-right: none;
  border-left: 1px solid var(--border);
}

h1 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  letter-spacing: 0.02em;
}

h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 1rem 0 0.5rem;
  font-weight: 600;
}

label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

input[type="text"],
input[type="url"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
}

textarea {
  min-height: 72px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--accent-dim);
  background: linear-gradient(180deg, #4a6fc4, var(--accent-dim));
  color: #fff;
  font-size: 0.82rem;
  cursor: pointer;
  width: 100%;
  margin-top: 0.5rem;
}

.btn:hover {
  filter: brightness(1.08);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg);
  border-color: var(--border);
  color: var(--text);
}

.btn-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.btn-row .btn {
  flex: 1;
  min-width: 120px;
  margin-top: 0.4rem;
}

.hint {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.45;
  margin-top: 0.35rem;
}

.warn {
  color: #e8a849;
  font-size: 0.72rem;
  margin-top: 0.35rem;
  line-height: 1.4;
}

.viewport-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.preset-chip {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.preset-chip.active {
  border-color: var(--accent);
  background: rgba(91, 140, 255, 0.15);
}

.center-stage {
  display: flex;
  flex-direction: column;
  padding: 0.75rem 1rem;
  overflow: auto;
}

.stage-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-bottom: 0.65rem;
}

.stage-toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  font-size: 0.8rem;
}

.view-wrap {
  position: relative;
  flex: 1;
  min-height: 280px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  background: #0a0c10;
}

.view-inner {
  position: relative;
  display: inline-block;
  min-width: 100%;
}

/* 与底图同宽高的定位参考，避免 canvas 相对过宽的 .view-inner 产生横向偏移 */
.view-stack {
  position: relative;
  display: inline-block;
  line-height: 0;
  vertical-align: top;
}

#baseImg {
  display: block;
  max-width: 100%;
  height: auto;
  vertical-align: top;
  position: relative;
  z-index: 0;
}

#heatLayer {
  display: block;
  max-width: 100%;
  height: auto;
  vertical-align: top;
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1;
  pointer-events: none;
  /* 与常见浅色 UI 截图叠加；透明度由滑块控制 */
  mix-blend-mode: multiply;
}

#flowLayer {
  display: block;
  max-width: 100%;
  height: auto;
  vertical-align: top;
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  pointer-events: none;
  mix-blend-mode: normal;
}

.viewport-overlay {
  position: absolute;
  border: 2px solid rgba(91, 140, 255, 0.85);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  border-radius: 4px;
  z-index: 3;
}

.iframe-shell {
  width: 100%;
  min-height: 400px;
  background: #fff;
}

.iframe-shell iframe {
  width: 100%;
  height: 520px;
  border: none;
  display: block;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  margin-bottom: 0.5rem;
}

.dropzone:hover {
  border-color: var(--accent-dim);
}

.analysis-block {
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.analysis-block h3 {
  font-size: 0.85rem;
  margin: 0.75rem 0 0.35rem;
  color: var(--accent);
}

.status {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

.error {
  color: #f08070;
}

.loading {
  display: inline-block;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.45;
  }
}

.hidden {
  display: none !important;
}

.stage-export-row {
  flex: 1 1 auto;
  min-width: 200px;
  margin-top: 0;
}

.stage-export-row .btn {
  margin-top: 0;
  width: auto;
  flex: 1;
  min-width: 100px;
}

/* ---------- 报告预览 / 打印 PDF ---------- */
.report-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
}

.report-modal.hidden {
  display: none !important;
}

.report-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  cursor: pointer;
}

.report-modal-panel {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.report-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.report-toolbar-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.report-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.report-toolbar-actions .btn {
  margin-top: 0;
  width: auto;
  min-width: 7rem;
}

.report-content {
  overflow: auto;
  padding: 1rem 1.1rem 1.25rem;
  flex: 1;
}

.report-doc {
  max-width: 100%;
}

.report-doc h1 {
  font-size: 1.15rem;
  margin: 0 0 0.5rem;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
}

.report-meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0.2rem 0;
}

.report-figure {
  margin: 1rem 0;
  padding: 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0a0c10;
}

.report-figure img {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: top;
}

.report-section {
  margin-top: 1rem;
}

.report-section h3 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 0.35rem;
  font-weight: 600;
}

.report-section .report-body {
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  color: var(--text);
}

.report-section.report-raw .report-body {
  font-size: 0.72rem;
  max-height: 12rem;
  overflow: auto;
  padding: 0.5rem;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
}

/**
 * 打印/PDF：勿用 visibility:hidden 隐藏主界面——隐藏元素仍占位，会产生大量空白页。
 * 改为仅 display:none 主内容区 .app，报告区单独排版。
 */
@media print {
  @page {
    margin: 12mm;
    size: auto;
  }

  html,
  body {
    height: auto !important;
    min-height: 0 !important;
    background: #fff !important;
    color: #111 !important;
  }

  body > .app {
    display: none !important;
  }

  #reportModal {
    position: static !important;
    inset: auto !important;
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: none !important;
    min-height: 0 !important;
    background: #fff !important;
    box-shadow: none !important;
  }

  #reportModal.hidden {
    display: none !important;
  }

  .report-modal-backdrop,
  .report-toolbar-actions {
    display: none !important;
  }

  .report-modal-panel {
    display: block !important;
    max-height: none !important;
    min-height: 0 !important;
    border: none !important;
    box-shadow: none !important;
    width: 100% !important;
    background: #fff !important;
  }

  .report-toolbar {
    border-bottom: none !important;
    padding: 0 0 0.35rem !important;
    margin: 0 !important;
  }

  .report-toolbar-title {
    color: #111 !important;
    font-size: 11pt !important;
  }

  .report-content {
    overflow: visible !important;
    padding: 0 !important;
    flex: none !important;
  }

  .report-doc {
    max-width: none !important;
  }

  .report-doc h1 {
    font-size: 14pt !important;
    margin: 0 0 0.25rem !important;
    color: #111 !important;
  }

  .report-meta {
    font-size: 9pt !important;
    margin: 0.08rem 0 !important;
    color: #444 !important;
  }

  .report-figure {
    margin: 0.4rem 0 0.6rem !important;
    padding: 0 !important;
    border: 1px solid #ccc !important;
    border-radius: 4px !important;
    background: #fff !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .report-figure img {
    max-width: 100% !important;
    height: auto !important;
  }

  .report-section {
    margin-top: 0.55rem !important;
    page-break-inside: auto;
  }

  .report-section:first-of-type {
    margin-top: 0.45rem !important;
  }

  .report-section h3 {
    font-size: 9pt !important;
    margin: 0 0 0.2rem !important;
    color: #333 !important;
  }

  .report-section .report-body {
    font-size: 9.5pt !important;
    line-height: 1.45 !important;
    white-space: pre-wrap !important;
    color: #111 !important;
  }
}

/* ---------- 多模型详细分析（登录） ---------- */
.advanced-modal {
  position: fixed;
  inset: 0;
  z-index: 1001;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0.75rem;
  box-sizing: border-box;
}

.advanced-modal.hidden {
  display: none !important;
}

.advanced-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  cursor: pointer;
}

.advanced-modal-panel {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  max-height: calc(100vh - 1.5rem);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.advanced-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

.advanced-toolbar h2 {
  margin: 0;
  font-size: 0.95rem;
}

.advanced-content {
  overflow: auto;
  padding: 0.75rem 0.9rem 1rem;
  flex: 1;
}

.advanced-content h3 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0.75rem 0 0.4rem;
}

.adv-intro {
  margin-top: 0;
}

.adv-model-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.35rem 0 0.65rem;
  max-height: 200px;
  overflow: auto;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}

.adv-model-chip {
  font-size: 0.78rem;
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
}

.adv-job-list {
  margin: 0.35rem 0 0.65rem;
  padding-left: 1.1rem;
  font-size: 0.82rem;
}

.adv-job-list a {
  color: var(--accent);
}

.adv-job-detail {
  font-size: 0.8rem;
  margin-bottom: 0.75rem;
}

.adv-result-row {
  margin: 0.35rem 0;
  padding: 0.35rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.adv-result-row .btn {
  margin-top: 0.25rem;
  width: auto;
  display: inline-block;
}

.adv-err {
  font-size: 0.72rem;
  color: #f08070;
  white-space: pre-wrap;
  margin: 0.25rem 0 0;
}

#advSynthModel {
  width: 100%;
  margin: 0.35rem 0;
}
