/* AICHAT chart authority: message bounds and vector fullscreen viewer. */
.doc-content ai-diagram[lang="echarts"],
.doc-content ai-diagram[data-lang="echarts"],
.markdown-body ai-diagram[lang="echarts"],
.markdown-body ai-diagram[data-lang="echarts"],
.msg-bubble ai-diagram[lang="echarts"],
.msg-bubble ai-diagram[data-lang="echarts"] {
  height: clamp(300px, 44vh, 480px) !important;
  min-height: 300px !important;
  overflow: visible !important;
}

.doc-content ai-diagram[lang="echarts"] > div,
.doc-content ai-diagram[data-lang="echarts"] > div,
.markdown-body ai-diagram[lang="echarts"] > div,
.markdown-body ai-diagram[data-lang="echarts"] > div,
.msg-bubble ai-diagram[lang="echarts"] > div,
.msg-bubble ai-diagram[data-lang="echarts"] > div {
  height: 100% !important;
}

.msg-bubble ai-diagram,
.msg-bubble .aid-box,
.msg-bubble .echarts-block,
.msg-bubble .mathplot-block,
.msg-bubble .mermaid-container,
.msg-bubble .echarts-container,
.msg-bubble .chart-render-target,
.msg-bubble .echart-box {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  box-sizing: border-box;
}

.aid-head {
  display: none;
}

.aid-box {
  border-radius: 14px;
}

.aid-body {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 8px;
  box-sizing: border-box;
}

.aid-canvas,
.aid-echarts-wrap,
.aid-echarts,
.aid-mathplot,
.echarts-block,
.mathplot-block,
.mathplot-container {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.aid-echarts-wrap {
  overflow: hidden;
}

.aid-echarts,
.echarts-block {
  height: clamp(300px, 44vh, 480px);
  min-height: 300px;
}

.aid-mathplot,
.mathplot-block,
.mathplot-container {
  max-height: 480px;
  overflow: auto;
}

.aid-mathplot .function-plot,
.mathplot-block .function-plot,
.mathplot-container .function-plot {
  width: 100%;
  max-width: 100%;
}

.aid-mathplot svg,
.mathplot-block svg,
.mathplot-container svg,
.mermaid-container svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: 480px;
  margin: 0 auto;
}

.aid-mathplot svg text,
.mermaid-container svg text {
  text-rendering: geometricPrecision;
}

.chart-fullscreen-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 8;
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid color-mix(in srgb, currentColor 12%, transparent);
  border-radius: 9px;
  background: color-mix(in srgb, var(--bg-primary) 76%, transparent);
  color: var(--text-secondary);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  cursor: pointer;
}

.chart-fullscreen-btn svg,
.srbill-fs-action svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

#srbill-chart-fs-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: grid;
  grid-template-rows: auto 1fr;
  background: rgba(9, 9, 15, 0.96);
  color: #f6f6f8;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

#srbill-chart-fs-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.srbill-fs-toolbar {
  position: relative;
  z-index: 2;
  min-height: 58px;
  padding: max(10px, env(safe-area-inset-top, 0px)) 14px 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  background: rgba(18, 18, 28, 0.72);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
}

.srbill-fs-status {
  min-width: 48px;
  margin-right: auto;
  color: rgba(255, 255, 255, 0.64);
  font: 600 12px/1 system-ui, sans-serif;
  text-align: center;
}

.srbill-fs-action {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
}

.srbill-fs-action:hover,
.srbill-fs-action:focus-visible {
  background: rgba(255, 255, 255, 0.17);
  outline: none;
}

.srbill-fs-content {
  position: relative;
  min-height: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.srbill-fs-content.dragging {
  cursor: grabbing;
}

.srbill-fs-wrap {
  position: relative;
  max-width: none;
  max-height: none;
  transform-origin: center;
  will-change: transform;
}

.srbill-fs-wrap[data-renderer="svg"] > svg {
  display: block;
  width: min(92vw, 1500px);
  height: min(82dvh, 1000px);
  max-width: none;
  max-height: none;
}

.srbill-fs-echarts {
  width: min(94vw, 1600px);
  height: min(82dvh, 980px);
}

.srbill-fs-wrap[data-renderer="raster"] canvas {
  display: block;
  max-width: none;
  image-rendering: auto;
}

.srbill-fs-raster-note {
  position: absolute;
  right: 0;
  bottom: -34px;
  left: 0;
  color: rgba(255, 255, 255, 0.58);
  font: 500 11px/1.4 system-ui, sans-serif;
  text-align: center;
  white-space: nowrap;
}

html.perf-mode .chart-fullscreen-btn,
html.perf-mode .srbill-fs-toolbar,
body.perf-mode .chart-fullscreen-btn {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

@media (max-width: 768px) {
  .aid-body {
    padding: 6px;
  }

  .aid-echarts,
  .echarts-block {
    height: clamp(280px, 46vh, 420px);
    min-height: 280px;
  }

  .aid-mathplot,
  .mathplot-block,
  .mathplot-container {
    max-height: 420px;
  }

  .msg-bubble ai-diagram,
  .msg-bubble .aid-box,
  .msg-bubble .echarts-block,
  .msg-bubble .mathplot-block {
    max-width: calc(100vw - 32px);
  }

  .srbill-fs-toolbar {
    min-height: 54px;
    padding-right: 10px;
    padding-left: 10px;
    gap: 5px;
  }

  .srbill-fs-action {
    width: 38px;
    height: 38px;
    border-radius: 9px;
  }

  .srbill-fs-wrap[data-renderer="svg"] > svg,
  .srbill-fs-echarts {
    width: 94vw;
    height: 76dvh;
  }

  .srbill-fs-raster-note {
    width: 92vw;
    white-space: normal;
  }
}
