/* 数据分析视图专用样式。
   公共部分（:root 变量、主题、头部 .app-header / .top-tabs / .brand / button 等）
   统一由 eq-simulator.css 提供，这里只保留数据分析视图独有的样式，并对
   与 EQ 仿真冲突的选择器（.chart-panel / canvas）加作用域，避免互相覆盖。 */

/* 合并页面：视图与操作组的显示切换 */
[hidden] {
  display: none !important;
}

body.readme-page {
  overflow: auto;
}

.actions-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.lang-button {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 4px;
  background: rgba(37, 99, 235, 0.1);
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}

.lang-button:hover,
.lang-button.active {
  border-color: var(--blue);
  color: var(--blue);
}

/* 数据分析：导入文件按钮 */
.file-button {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  padding: 0 12px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 4px;
  background: rgba(37, 99, 235, 0.1);
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.file-button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

#fileInput,
#dspInput {
  display: none;
}

/* 数据分析：工作区与图表 */
#view-analysis {
  height: calc(100vh - 46px);
  overflow-y: auto;
}

.workspace {
  display: block;
  min-height: calc(100vh - 46px);
  padding: 0;
}

.workspace .chart-panel {
  min-height: calc(100vh - 46px);
  border: 0;
  overflow: hidden;
  background: var(--surface);
}

#curveCanvas {
  display: block;
  width: 100%;
  height: calc(100vh - 46px);
  min-height: 520px;
  background: #ffffff;
  cursor: crosshair;
}

.dark-theme #curveCanvas {
  background: var(--chart-bg);
}

@media (max-width: 900px) {
  .app-header,
  .workspace {
    padding: 0;
  }
}

@media (max-width: 520px) {
  .header-actions {
    width: 100%;
  }

  .header-actions button,
  .file-button {
    flex: 1;
  }
}

/* DSP 存盘文件导入工具 */
.dsp-workspace {
  min-height: calc(100vh - 46px);
  overflow: auto;
  background: var(--surface);
  padding: 22px;
}

.dsp-intro {
  max-width: 980px;
  margin: 0 auto 18px;
}

.dsp-intro h1 {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: 0;
}

.dsp-intro p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.dsp-format-row {
  display: flex;
  max-width: 980px;
  margin: 0 auto 10px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dsp-format {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
}

.dsp-format.is-sce {
  border-color: color-mix(in srgb, var(--blue), var(--line) 45%);
  color: var(--blue);
}

.dsp-format.is-pnp {
  border-color: color-mix(in srgb, var(--green), var(--line) 45%);
  color: var(--green);
}

.dsp-support {
  color: var(--muted);
  font-size: 12px;
}

.dsp-status {
  max-width: 980px;
  margin: 0 auto 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.6;
}

.dsp-status.is-error {
  border-color: color-mix(in srgb, var(--red), var(--line) 45%);
  color: var(--red);
}

.dsp-status.is-ready {
  border-color: color-mix(in srgb, var(--green), var(--line) 55%);
}

.dsp-channel-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  max-width: 980px;
  margin: 0 auto;
}

.dsp-channel-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-bg);
  box-shadow: var(--shadow);
  padding: 12px;
}

.dsp-channel-card h2 {
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.35;
  letter-spacing: 0;
}

.dsp-channel-card p {
  min-height: 36px;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.dsp-channel-card.is-loaded {
  border-color: color-mix(in srgb, var(--blue), var(--line) 45%);
}

.dsp-channel-actions {
  display: flex;
  gap: 6px;
}

.dsp-channel-actions .file-button,
.dsp-channel-actions button {
  flex: 1;
  justify-content: center;
  min-width: 0;
  padding: 0 8px;
}

.dsp-filter-list {
  max-height: 150px;
  overflow: auto;
  margin-top: 10px;
  border-top: 1px solid var(--line-soft);
  padding-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

@media (max-width: 980px) {
  .dsp-channel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .dsp-workspace {
    padding: 14px;
  }

  .dsp-format-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .dsp-channel-grid {
    grid-template-columns: 1fr;
  }
}

/* README 网页版 */
.readme-shell {
  min-height: calc(100vh - 46px);
  background: #ffffff;
  padding: 22px 18px 48px;
}

.readme-content {
  width: min(1060px, 100%);
  margin: 0 auto;
  color: var(--text);
}

.readme-hero {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(320px, 1.05fr);
  gap: 22px;
  align-items: center;
  padding: 18px 0 24px;
  border-bottom: 1px solid var(--line);
}

.readme-kicker {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 750;
}

.readme-hero h1 {
  margin: 0 0 14px;
  font-size: 34px;
  line-height: 1.14;
  letter-spacing: 0;
}

.readme-hero p {
  max-width: 650px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.8;
}

.readme-hero img,
.readme-section img {
  display: block;
  width: 100%;
  height: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.readme-section {
  padding: 26px 0;
  border-bottom: 1px solid var(--line-soft);
}

.readme-section h2 {
  margin: 0 0 14px;
  font-size: 24px;
  line-height: 1.3;
  letter-spacing: 0;
}

.readme-section h3 {
  margin: 18px 0 8px;
  font-size: 17px;
  line-height: 1.45;
}

.readme-section p,
.readme-section li,
.readme-definition dd,
.readme-gallery figcaption {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.8;
}

.readme-section p {
  margin: 0 0 12px;
}

.readme-section ul,
.readme-section ol {
  margin: 8px 0 14px;
  padding-left: 22px;
}

.readme-section code {
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  background: var(--control-bg-muted);
  color: var(--text);
  padding: 1px 5px;
  font-size: 0.92em;
}

.readme-section figure {
  width: min(88%, 880px);
  margin: 18px auto 0;
}

.readme-equations,
.readme-code {
  width: min(88%, 880px);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.readme-equations {
  padding: 14px;
  margin: 14px auto;
}

.readme-equations p {
  margin: 0 0 7px;
  font-size: 14px;
}

.readme-equations pre,
.readme-code {
  overflow-x: auto;
  margin: 0 0 12px;
  padding: 12px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

.readme-equations pre {
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  background: var(--panel);
}

.readme-code {
  margin: 12px auto 16px;
}

.math-block {
  overflow-x: auto;
  margin: 0 0 12px;
  padding: 8px 0;
}

.readme-definition {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 0;
}

.readme-definition div {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 12px;
}

.readme-definition dt {
  margin-bottom: 6px;
  color: var(--text);
  font-size: 14px;
  font-weight: 750;
}

.readme-definition dd {
  margin: 0;
}

.readme-gallery {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
  margin-top: 18px;
}

.readme-gallery figure {
  width: min(88%, 880px);
  margin: 0 auto;
}

.readme-content img {
  cursor: zoom-in;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  border: 0;
  background: rgba(255, 255, 255, 0.94);
  padding: 28px;
}

.image-lightbox[hidden] {
  display: none !important;
}

.image-lightbox img {
  max-width: 96vw;
  max-height: 92vh;
  width: auto;
  height: auto;
  cursor: zoom-out;
}

.image-lightbox-close {
  position: fixed;
  top: 12px;
  right: 14px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  border-color: var(--line);
  background: #ffffff;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}

.readme-gallery figcaption {
  margin-top: 8px;
}

.readme-contact {
  margin-top: 18px !important;
}

.readme-contact a {
  color: var(--blue);
}

@media (max-width: 900px) {
  body.readme-page .app-header {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
  }

  body.readme-page .top-tabs,
  body.readme-page .header-actions {
    justify-self: stretch;
  }

  body.readme-page .top-tabs {
    justify-content: center;
  }

  .readme-hero {
    grid-template-columns: 1fr;
  }

  .readme-definition,
  .readme-gallery {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .readme-shell {
    padding: 14px 12px 38px;
  }

  .readme-hero h1 {
    font-size: 27px;
  }

  .readme-section h2 {
    font-size: 21px;
  }

  .readme-section figure,
  .readme-equations,
  .readme-code {
    width: 100%;
  }

  body.readme-page .tab-link {
    min-width: 0;
    flex: 1;
    padding: 0 8px;
  }
}

/* ---------- Auto EQ Match 原型视图 ---------- */
/* body 设了 overflow:hidden，本视图内容超一屏，需自身成为滚动容器 */
#view-autoMatch {
  height: calc(100vh - 46px);
  overflow-y: auto;
}

.match-workspace {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 16px 24px;
}

/* 固定图表高度，避免 canvas{height:100%} 在自适应高度容器里塌陷 */
.match-workspace .chart-panel {
  flex: 0 0 auto;
  height: 360px;
}

.match-intro h1 {
  margin: 0 0 4px;
  font-size: 18px;
  color: var(--text);
}

.match-intro p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.match-status {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}

.match-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.match-group {
  flex: 1 1 220px;
  min-width: 200px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.match-group legend {
  padding: 0 4px;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
}

.match-group label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text);
}

.match-group input[type="number"] {
  width: 66px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
}

.match-group textarea {
  flex: 1 1 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  resize: vertical;
}

/* 隐藏原生文件框，只保留样式化的按钮触发它 */
#mFile,
#mTargetFile {
  display: none;
}

.match-target-status {
  flex: 1 1 100%;
  font-size: 12px;
  color: var(--muted);
}

.match-check {
  gap: 6px;
}

.match-run {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  justify-content: center;
}

.match-mode {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.match-mode button {
  flex: 1;
  padding: 6px 10px;
  border: none;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.match-mode button.active {
  background: var(--blue);
  color: #fff;
  font-weight: 650;
}

.match-primary {
  padding: 9px 20px;
  border: none;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}

.match-primary:hover {
  filter: brightness(1.05);
}

.match-result {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.match-summary {
  font-size: 13px;
  color: var(--text);
}

.match-empty {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.match-table {
  border-collapse: collapse;
  font-size: 13px;
  min-width: 320px;
}

.match-table th,
.match-table td {
  padding: 5px 14px 5px 4px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}

.match-table th {
  color: var(--muted);
  font-weight: 600;
}
