/* 策略构建页 — DeepSeek 比例与布局 */

body.page-builder {
  --builder-sidebar-w: clamp(220px, 22vw, 280px);
  --builder-content-max: 46rem;
  --builder-bg: #0d1117;
  --builder-bg-elevated: #161b22;
  --builder-bg-sidebar: #0d1117;
  --builder-bg-main: #0d1117;
  --builder-bg-input: #21262d;
  --builder-border: rgba(240, 246, 252, 0.1);
  --builder-text: #e6edf3;
  --builder-text-muted: #8b949e;
  --builder-accent: #388bfd;
  --builder-accent-hover: #58a6ff;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--builder-bg) !important;
}

body.page-builder .cyber-grid,
body.page-builder .neon-glow {
  display: none !important;
}

body.page-builder [data-xt-partial="footer"] {
  display: none !important;
}

body.page-builder [data-xt-partial="navbar"] .navbar {
  background: var(--builder-bg) !important;
  border-bottom: 1px solid var(--builder-border);
  box-shadow: none !important;
}

.builder-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
}

/* 步骤条：扁平编号 + 连接线，非圆形卡通指示器 */
.builder-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-top: 0.54rem;
  max-width: 36rem;
  margin-left: auto;
  margin-right: auto;
}

.step {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  opacity: 0.42;
  transition: opacity 0.25s ease;
  flex-shrink: 0;
}

.step.active,
.step.completed {
  opacity: 1;
}

.step-num {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 4px;
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.32);
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.step.active .step-num {
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.55);
  color: #7dd3fc;
}

.step.completed .step-num {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.45);
  color: #4ade80;
}

.step-label {
  font-size: 0.82rem;
  color: #94a3b8;
  font-weight: 500;
  white-space: nowrap;
}

.step.active .step-label {
  color: #e2e8f0;
}

.step.completed .step-label {
  color: #b8c7d9;
}

.step-line {
  flex: 1;
  min-width: 2rem;
  max-width: 4.5rem;
  height: 1px;
  margin: 0 0.65rem;
  background: rgba(148, 163, 184, 0.22);
  position: relative;
}

.step-line::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0;
  background: rgba(56, 189, 248, 0.65);
  transition: width 0.35s ease;
}

.step-line.completed::after {
  width: 100%;
}

/* 主工作台卡片 */
.builder-section {
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.builder-workbench {
  /* 工作台高度：按视口扣减顶栏/Hero/内边距，保证底部操作区完整可见 */
  --builder-chrome-offset: calc(var(--xt-navbar-min-height, 3.25rem) + 5.5rem + 2.75rem);
  --builder-workbench-h: max(620px, calc(100dvh - var(--builder-chrome-offset)));
  --editor-height: clamp(240px, 36vh, 320px);
  margin-bottom: 0.5rem;
  padding: 0.85rem;
}

.builder-project-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  margin-bottom: 1.15rem;
  padding: 0.65rem 0.85rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(148, 163, 184, 0.15);
}

.builder-project-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #9fb0c9;
}

.builder-project-id {
  font-weight: 600;
  color: #7dd3fc;
  font-variant-numeric: tabular-nums;
}

.builder-token-usage {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: 0.35rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: rgba(212, 185, 150, 0.95);
  background: rgba(212, 185, 150, 0.1);
  border: 1px solid rgba(212, 185, 150, 0.22);
}

.builder-token-usage.hidden {
  display: none;
}

.builder-token-usage i {
  font-size: 0.72rem;
  opacity: 0.9;
}

.builder-version-switch {
  margin-left: auto;
  flex-shrink: 0;
}

.builder-version-switch.hidden {
  display: none;
}

.builder-version-switch__inner {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.35rem 0.45rem 0.35rem 0.55rem;
  border-radius: 10px;
  border: 1px solid rgba(125, 211, 252, 0.22);
  background: linear-gradient(
    135deg,
    rgba(15, 23, 42, 0.72) 0%,
    rgba(30, 41, 59, 0.55) 100%
  );
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 4px 16px rgba(0, 0, 0, 0.12);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

.builder-version-switch__inner:hover {
  border-color: rgba(125, 211, 252, 0.38);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 6px 20px rgba(0, 0, 0, 0.16);
}

.builder-version-switch__inner:focus-within {
  border-color: rgba(125, 211, 252, 0.55);
  box-shadow:
    0 0 0 3px rgba(56, 189, 248, 0.14),
    0 4px 16px rgba(0, 0, 0, 0.14);
}

.builder-version-switch__head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding-right: 0.55rem;
  border-right: 1px solid rgba(148, 163, 184, 0.18);
  white-space: nowrap;
}

.builder-version-switch__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 7px;
  font-size: 0.72rem;
  color: #7dd3fc;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.2);
}

.builder-version-switch__title {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
}

.builder-version-switch__count {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: #bae6fd;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.22);
}

.builder-version-switch__count.hidden {
  display: none;
}

.builder-version-switch__select-wrap {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 10.5rem;
  max-width: min(18rem, 42vw);
}

.builder-version-switch__select-wrap select {
  width: 100%;
  margin: 0;
  padding: 0.42rem 1.85rem 0.42rem 0.65rem;
  border: none;
  border-radius: 7px;
  background: rgba(15, 23, 42, 0.55);
  color: #f1f5f9;
  font-size: 0.82rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition:
    background 0.2s ease,
    color 0.2s ease;
}

.builder-version-switch__select-wrap select:hover {
  background: rgba(15, 23, 42, 0.72);
}

.builder-version-switch__select-wrap select:focus {
  outline: none;
  background: rgba(15, 23, 42, 0.82);
}

.builder-version-switch__chevron {
  position: absolute;
  right: 0.55rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 0.62rem;
  color: #64748b;
  transition: color 0.2s ease;
}

.builder-version-switch__inner:focus-within .builder-version-switch__chevron,
.builder-version-switch__select-wrap select:hover + .builder-version-switch__chevron {
  color: #94a3b8;
}

@media (max-width: 640px) {
  .builder-project-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .builder-version-switch {
    margin-left: 0;
    width: 100%;
  }

  .builder-version-switch__inner {
    width: 100%;
    justify-content: space-between;
  }

  .builder-version-switch__select-wrap {
    flex: 1;
    max-width: none;
  }
}

.builder-code-panel {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(0, 0, 0, 0.15);
}

.builder-code-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.84rem;
  color: #b0bfd5;
}

.builder-code-panel pre {
  margin: 0;
  max-height: 10rem;
  overflow: auto;
  font-size: 0.78rem;
  color: rgba(226, 232, 240, 0.82);
  background: rgba(0, 0, 0, 0.28);
  border-radius: 6px;
  padding: 0.65rem 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* 左右分栏：收起时第二列 0 宽；展开时 grid 列宽动画 + 右栏滑入 */
.builder-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0fr);
  column-gap: 0;
  row-gap: 0.35rem;
  align-items: stretch;
  min-height: 0;
  transition:
    grid-template-columns 0.52s cubic-bezier(0.22, 1, 0.36, 1),
    column-gap 0.52s cubic-bezier(0.22, 1, 0.36, 1);
}

.builder-split.is-refine-collapsed {
  grid-template-columns: minmax(0, 1fr) minmax(0, 0fr);
  grid-template-rows: auto 0;
}

.builder-split.is-refine-collapsed .builder-pane--left {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.builder-split:not(.is-refine-collapsed) {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  /* 四行与左右栏共享：标题 / 元信息 / 编辑区 / 操作区（不用 1fr，避免撑出大块空白） */
  grid-template-rows: auto auto auto auto;
  column-gap: 0.75rem;
}

.builder-pane {
  min-width: 0;
  min-height: 0;
}

.builder-split:not(.is-refine-collapsed) .builder-pane {
  display: grid;
  grid-template-rows: subgrid;
  grid-row: 1 / -1;
  gap: 0;
  min-height: 0;
}

.builder-pane--left {
  grid-column: 1;
}

.builder-pane--right {
  grid-column: 2;
}

.builder-pane__row {
  min-width: 0;
}

.builder-pane__row--head .section-header {
  margin-bottom: 0;
}

.builder-pane__row--meta,
.builder-pane__row--body,
.builder-pane__row--foot {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.builder-split:not(.is-refine-collapsed) .builder-pane__row--meta {
  justify-content: stretch;
}

.builder-split:not(.is-refine-collapsed) .builder-pane__row--body {
  flex: 0 0 auto;
  min-height: 0;
}

.builder-pane__row--body {
  flex: 0 0 auto;
}

.builder-pane__row--foot {
  padding-top: 0.35rem;
  flex: 0 0 auto;
}

.builder-pane__row--foot .section-actions {
  margin-top: 0;
}

/* 收起时右栏不参与行高计算（0 高行 + 裁剪），保留 DOM 以便展开过渡 */
.builder-split.is-refine-collapsed .builder-pane--right {
  grid-column: 2;
  grid-row: 2;
  min-height: 0;
  max-height: 0;
  height: 0;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(10px);
  padding: 0;
  margin: 0;
  border: 0;
}

.builder-pane__main {
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
  width: 100%;
}

.builder-split:not(.is-refine-collapsed) .builder-pane__main {
  flex: 0 0 auto;
  min-height: 0;
  height: auto;
}

.builder-editor-body {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

.builder-pane--right {
  overflow: hidden;
  max-width: 100%;
  min-width: 0;
  opacity: 1;
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
  transition:
    opacity 0.42s cubic-bezier(0.22, 1, 0.36, 1) 0.12s,
    transform 0.48s cubic-bezier(0.22, 1, 0.36, 1) 0.08s,
    visibility 0s linear 0s;
}

.builder-split:not(.is-refine-collapsed) .builder-pane--right {
  grid-row: 1 / -1;
  max-height: none;
  height: auto;
  padding: 0;
  margin: 0;
}

.builder-split.is-refine-expanding .builder-pane--right {
  transition:
    opacity 0.46s cubic-bezier(0.22, 1, 0.36, 1) 0.14s,
    transform 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.1s,
    visibility 0s linear 0s;
}

/* 右栏内容略滞后于列宽展开 */
.builder-split.is-refine-expanding:not(.is-refine-collapsed) .builder-pane--right .builder-pane__row--head,
.builder-split.is-refine-expanding:not(.is-refine-collapsed) .builder-pane--right .builder-pane__row--body {
  animation: builder-refine-pane-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.2s both;
}

.builder-split.is-refine-expanding:not(.is-refine-collapsed) .builder-pane--right .builder-pane__row--foot {
  animation: builder-refine-pane-in 0.48s cubic-bezier(0.22, 1, 0.36, 1) 0.28s both;
}

.builder-split:not(.is-refine-collapsed):not(.is-refine-expanding) .builder-pane--right .builder-pane__row--head,
.builder-split:not(.is-refine-collapsed):not(.is-refine-expanding) .builder-pane--right .builder-pane__row--body,
.builder-split:not(.is-refine-collapsed):not(.is-refine-expanding) .builder-pane--right .builder-pane__row--foot {
  animation: none;
}

@keyframes builder-refine-pane-in {
  from {
    opacity: 0;
    transform: translateX(8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .builder-split,
  .builder-pane--right,
  .builder-split.is-refine-expanding .builder-pane--right,
  .builder-split.is-refine-expanding:not(.is-refine-collapsed) .builder-pane--right .builder-pane__row--head,
  .builder-split.is-refine-expanding:not(.is-refine-collapsed) .builder-pane--right .builder-pane__row--body,
  .builder-split.is-refine-expanding:not(.is-refine-collapsed) .builder-pane--right .builder-pane__row--foot {
    transition: none !important;
    animation: none !important;
    transform: none !important;
  }
}

.builder-pane--right .result-actions {
  justify-content: flex-end;
  align-items: center;
  flex-wrap: nowrap;
  width: 100%;
}

.builder-pane--right.is-idle {
  background: rgba(0, 0, 0, 0.08);
  border-radius: 6px;
}

.builder-pane--right.is-idle .result-label-done,
.builder-pane--right.is-idle .result-label-running {
  display: none;
}

.builder-pane--right.is-idle .result-label-idle {
  display: flex;
}

.builder-pane--right.is-idle .builder-status-display:has(#refine-waiting.is-visible) .result-label-idle {
  display: none !important;
}

.builder-pane--right.is-idle .builder-status-display:has(#refine-waiting.is-visible) .result-label-running {
  display: flex !important;
}

.builder-pane--right:not(.is-idle) .result-label-idle {
  display: none;
}

.builder-pane--right:not(.is-idle) .result-label-done {
  display: flex;
}

.builder-status-display:has(#refine-waiting.is-visible) .result-label-idle,
.builder-status-display:has(#refine-waiting.is-visible) .result-label-done {
  display: none !important;
}

.builder-status-display:has(#refine-waiting.is-visible) .result-label-running {
  display: flex !important;
}

.builder-pane--right.is-idle .builder-textarea.refined {
  opacity: 0.75;
}

.builder-pane--right.is-idle .result-actions {
  opacity: 0.45;
  pointer-events: none;
}

.builder-pane--right:not(.is-idle) .result-actions {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 991px) {
  .builder-split {
    transition: none;
  }

  .builder-split:not(.is-refine-collapsed) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    row-gap: 0;
  }

  .builder-split.is-refine-collapsed .builder-pane--right {
    display: none;
  }

  .builder-split:not(.is-refine-collapsed) .builder-pane {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    grid-row: auto;
    grid-column: 1;
  }

  .builder-split:not(.is-refine-collapsed) .builder-pane__row--body {
    flex: 0 0 auto;
    height: auto;
  }

  .builder-split:not(.is-refine-collapsed) .builder-pane__main {
    flex: 0 1 auto;
    height: auto;
  }

  .result-area.builder-pane__main {
    min-height: 0;
    height: auto;
  }

  .refined-render.is-visible {
    max-height: min(var(--editor-height), 70vh);
    height: auto;
  }

  .builder-pane--right {
    transform: translateY(10px);
  }

  .builder-split.is-refine-collapsed .builder-pane--right {
    display: none !important;
  }

  .builder-split:not(.is-refine-collapsed) .builder-pane--right {
    display: flex;
    transform: translateY(0);
    padding-top: 1rem;
    border-top: 1px solid rgba(148, 163, 184, 0.15);
  }
}

/* 区块标题 */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.input-section .section-header {
  margin-bottom: 0.65rem;
}

.section-heading {
  font-size: 1.05rem;
  font-weight: 600;
  color: #f1f5f9;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.section-heading i {
  font-size: 0.92rem;
  color: #7dd3fc;
  opacity: 0.9;
}

.section-desc {
  font-size: 0.82rem;
  color: #94a3b8;
  margin: 0;
  text-align: right;
  max-width: 52%;
  line-height: 1.45;
}

@media (max-width: 640px) {
  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .section-desc {
    text-align: left;
    max-width: 100%;
  }
}

/* 输入区 / 结果区主框 */
.input-area.builder-pane__main,
.result-area.builder-pane__main {
  border-radius: 6px;
  margin-bottom: 0;
  box-sizing: border-box;
  width: 100%;
}

.input-area.builder-pane__main {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(148, 163, 184, 0.18);
  padding: 0.85rem;
  flex: 0 0 auto;
  min-height: var(--editor-height);
  height: auto;
}

.result-area.builder-pane__main {
  background: rgba(0, 0, 0, 0.16);
  border: 1px solid rgba(148, 163, 184, 0.18);
  padding: 0.5rem 0.55rem;
  flex: 0 0 auto;
  min-height: var(--editor-height);
  height: auto;
  align-items: stretch;
}

.result-area .refined-render,
.result-area .builder-editor-body {
  flex: 0 0 auto;
  min-height: 0;
}

.input-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
}

.hint-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.65rem;
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 4px;
  font-size: 0.78rem;
  color: #a8b8cc;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.hint-tag:hover {
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.32);
  color: #7dd3fc;
}

.input-hints,
.input-footer,
.result-area .n8n-stream-trace {
  flex-shrink: 0;
}

#strategy-input {
  flex: 0 0 auto;
  min-height: var(--editor-height);
  height: var(--editor-height);
  max-height: var(--editor-height);
}

.builder-split:not(.is-refine-collapsed) #strategy-input {
  flex: 0 0 auto;
  height: var(--editor-height);
  max-height: var(--editor-height);
}

.builder-textarea {
  width: 100%;
  min-height: 0;
  height: auto;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 6px;
  padding: 1rem 1.1rem;
  color: #f1f5f9;
  font-size: 0.95rem;
  line-height: 1.75;
  resize: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
}

.builder-textarea:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.55);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}

.builder-textarea::placeholder {
  color: rgba(148, 163, 184, 0.55);
  font-style: normal;
}

.builder-textarea.refined {
  background: rgba(15, 23, 42, 0.5);
  border-color: rgba(56, 189, 248, 0.28);
}

.builder-textarea.refined.refined-data-hidden {
  display: none;
}

.builder-textarea.refined.is-streaming {
  color: rgba(203, 213, 225, 0.78);
  font-size: 0.88rem;
  line-height: 1.65;
  caret-color: transparent;
}

.input-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.45rem;
}

.char-count {
  font-size: 0.78rem;
  color: #64748b;
}

/* 结果区状态标签 */
.result-label {
  display: none;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
}

.result-label-idle {
  color: #94a3b8;
  font-weight: 400;
}

.result-label-running {
  color: #7dd3fc;
  font-weight: 500;
  display: none;
}

.result-label-done {
  color: #7dd3fc;
  font-weight: 500;
}

.result-label-done > .dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #4ade80;
  flex-shrink: 0;
}

.result-badge {
  margin-left: auto;
  padding: 0.2rem 0.55rem;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.28);
  border-radius: 4px;
  font-size: 0.75rem;
  color: #7dd3fc;
}

.result-area .result-label-idle,
.result-area .result-label-done {
  flex-shrink: 0;
}

.result-area .builder-textarea.refined {
  flex: 0 0 auto;
  min-height: 0;
}

/* 整理等待 / 状态 */
.refine-waiting {
  display: none;
}

.refine-waiting.is-visible {
  display: flex;
}

.refine-waiting-dots::after {
  content: " .";
  animation: builder-dots 1.2s steps(3, end) infinite;
}

@keyframes builder-dots {
  0% { content: " ."; }
  33% { content: " .."; }
  66% { content: " ..."; }
  100% { content: " ."; }
}

.refine-inline-state {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: 0.65rem;
  font-size: 0.82rem;
  color: #94a3b8;
}

.refine-inline-state.hidden {
  display: none;
}

.refine-inline-state .dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.55);
}

.refine-inline-state.is-running .dot {
  background: #7dd3fc;
}

.refine-inline-state.is-done .dot {
  background: #4ade80;
}

.refine-inline-state.is-error .dot {
  background: #f87171;
}

/* Markdown 渲染 */
.refined-render {
  display: none;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(56, 189, 248, 0.28);
  border-radius: 6px;
  padding: 0.75rem 0.8rem;
  color: rgba(241, 245, 249, 0.94);
  line-height: 1.7;
  overflow: auto;
  font-size: 0.92rem;
  box-sizing: border-box;
}

.refined-render.is-visible {
  display: block;
  flex: 0 0 auto;
  width: 100%;
  min-height: 0;
  height: auto;
  max-height: min(var(--editor-height), 70vh);
  overflow: auto;
}

.builder-pane--left .section-actions,
.builder-pane--right .result-actions {
  flex-shrink: 0;
}

.refined-render h1,
.refined-render h2,
.refined-render h3,
.refined-render h4 {
  margin: 0.35em 0 0.25em;
  font-weight: 600;
  line-height: 1.35;
  color: #f1f5f9;
}

.refined-render h1 { font-size: 1.12rem; }
.refined-render h2 { font-size: 1.02rem; }
.refined-render h3 { font-size: 0.96rem; }
.refined-render h4 { font-size: 0.92rem; color: #e2e8f0; }

.refined-render hr {
  border: none;
  height: 1px;
  margin: 0.75em 0;
  background: rgba(148, 163, 184, 0.22);
}

.refined-render table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 0.45em 0 0.75em;
}

.refined-render th,
.refined-render td {
  border: 1px solid rgba(148, 163, 184, 0.2);
  padding: 0.45rem 0.6rem;
  text-align: left;
  vertical-align: top;
}

.refined-render th {
  background: rgba(30, 41, 59, 0.55);
  color: #e2e8f0;
  font-weight: 600;
}

.refined-render td {
  color: rgba(226, 232, 240, 0.92);
}

.refined-render tr:nth-child(even) td {
  background: rgba(0, 0, 0, 0.08);
}

.refined-render th code {
  color: #e2e8f0;
  background: rgba(0, 0, 0, 0.2);
}

.refined-render p { margin: 0 0 0.55em; }
.refined-render ul,
.refined-render ol {
  padding-left: 1.25rem;
  margin: 0 0 0.55em;
}

.refined-render pre {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 6px;
  padding: 0.65rem 0.75rem;
  overflow: auto;
  margin: 0.45em 0 0.65em;
}

.refined-render pre code {
  white-space: pre-wrap;
  word-break: break-word;
  display: block;
  font-size: 0.84rem;
  line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.refined-render p code,
.refined-render li code,
.refined-render td code,
.refined-render th code {
  background: rgba(0, 0, 0, 0.28);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  font-size: 0.88em;
}

.refined-render a {
  color: #7dd3fc;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.refined-render a:hover {
  color: #bae6fd;
}

/* n8n 流式追踪：运行中单行流式输出，完成后显示「已完成：节点」 */
.n8n-stream-trace {
  display: block;
  width: 100%;
  margin-bottom: 0.55rem;
  padding: 0.45rem 0.6rem 0.35rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.12);
  border: 1px dashed rgba(148, 163, 184, 0.22);
  max-height: 7.5rem;
  overflow-x: hidden;
  overflow-y: auto;
}

.n8n-stream-trace.hidden {
  display: none;
}

.n8n-stream-step {
  margin: 0 0 0.3rem;
  font-size: 0.74rem;
  line-height: 1.35;
  color: #94a3b8;
}

.n8n-stream-step:last-child {
  margin-bottom: 0;
}

.n8n-stream-step-line {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.n8n-stream-step-dot {
  flex-shrink: 0;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.5);
}

.n8n-stream-step.is-running .n8n-stream-step-dot {
  background: #7dd3fc;
  box-shadow: 0 0 6px rgba(125, 211, 252, 0.35);
}

.n8n-stream-step.is-done .n8n-stream-step-dot {
  background: #4ade80;
  box-shadow: none;
}

.n8n-stream-step-stream {
  display: block;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  color: rgba(203, 213, 225, 0.82);
  font-variant-numeric: tabular-nums;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.n8n-stream-step-stream::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.n8n-stream-step.is-running .n8n-stream-step-stream:empty::before {
  content: "…";
  color: rgba(148, 163, 184, 0.55);
}

.n8n-stream-step-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #b8c7d9;
}

.n8n-stream-step.is-done .n8n-stream-step-label {
  color: rgba(203, 213, 225, 0.9);
}

.n8n-stream-step.is-running .n8n-stream-step-label {
  display: none !important;
}

.n8n-stream-step.is-done .n8n-stream-step-stream {
  display: none !important;
}

/* cursor 模式：运行中仅尾部片段，完成后合并为紧凑标签 */
.n8n-stream-trace.is-cursor {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: none;
  padding: 0.35rem 0;
  margin-bottom: 0.45rem;
  background: transparent;
  border: none;
}

.n8n-stream-trace.is-cursor.is-collapsed .n8n-stream-step.is-merged .n8n-stream-step-stream {
  display: none !important;
}

.n8n-stream-trace.is-cursor .n8n-stream-step.is-merged {
  margin-bottom: 0;
}

.n8n-stream-trace.is-cursor .n8n-stream-step.is-merged .n8n-stream-step-line {
  gap: 0.35rem;
}

.n8n-stream-trace.is-cursor .n8n-stream-step.is-running .n8n-stream-step-stream {
  font-style: italic;
  color: rgba(148, 163, 184, 0.75);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.n8n-stream-trace.is-cursor.is-collapsed .n8n-stream-step.is-merged .n8n-stream-step-label {
  font-size: 0.72rem;
  color: rgba(148, 163, 184, 0.85);
}

.n8n-stream-trace.is-collapsed .n8n-stream-step.is-running {
  display: none;
}

/* —— DeepSeek 式布局 —— */
.builder-layout {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  gap: 0;
  align-items: stretch;
  border: none;
  border-radius: 0;
  overflow: hidden;
  background: var(--builder-bg);
}

.builder-sidebar {
  flex: 0 0 var(--builder-sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  border-right: 1px solid var(--builder-border);
  padding: 0.85rem 0.75rem 1rem;
  background: var(--builder-bg-sidebar);
}

.builder-sidebar.hidden {
  display: none;
}

.builder-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.15rem 0.35rem 0.85rem;
}

.builder-sidebar-brand__logo {
  border-radius: 6px;
  flex-shrink: 0;
}

.builder-sidebar-brand__text {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--builder-accent);
  letter-spacing: 0.02em;
}

.builder-sidebar-new {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.62rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--builder-border);
  border-radius: 12px;
  background: var(--builder-bg-elevated);
  color: var(--builder-text);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.builder-sidebar-new:hover,
.builder-sidebar-new.is-active {
  background: rgba(56, 139, 253, 0.12);
  border-color: rgba(56, 139, 253, 0.35);
  color: var(--builder-accent-hover);
}

.builder-sidebar-head {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--builder-text-muted);
  padding: 0.65rem 0.4rem 0.35rem;
}

.builder-sidebar-head:first-child {
  padding-top: 0;
}

.builder-sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
}

.builder-sidebar-list {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.builder-sidebar-empty {
  font-size: 0.8rem;
  color: var(--builder-text-muted);
  padding: 0.5rem 0.4rem;
}

.builder-sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  width: 100%;
  padding: 0.15rem 0.2rem 0.15rem 0.15rem;
  border-radius: 8px;
  background: transparent;
  transition: background 0.12s ease;
}

.builder-sidebar-item:hover,
.builder-sidebar-item.is-menu-open {
  background: rgba(240, 246, 252, 0.06);
}

.builder-sidebar-item.is-active {
  background: rgba(56, 139, 253, 0.12);
}

.builder-sidebar-item__main {
  flex: 1;
  min-width: 0;
  display: block;
  padding: 0.35rem 0.4rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--builder-text-muted);
  text-align: left;
  cursor: pointer;
  transition: color 0.12s ease;
}

.builder-sidebar-item:hover .builder-sidebar-item__main,
.builder-sidebar-item.is-menu-open .builder-sidebar-item__main,
.builder-sidebar-item.is-active .builder-sidebar-item__main {
  color: var(--builder-text);
}

.builder-sidebar-item__more {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--builder-text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.builder-sidebar-item:hover .builder-sidebar-item__more,
.builder-sidebar-item.is-menu-open .builder-sidebar-item__more {
  opacity: 1;
}

.builder-sidebar-item__more:hover,
.builder-sidebar-item.is-menu-open .builder-sidebar-item__more {
  background: rgba(240, 246, 252, 0.08);
  color: var(--builder-text);
}

.builder-project-menu {
  position: fixed;
  z-index: 1200;
  min-width: 148px;
  padding: 0.35rem 0;
  background: var(--builder-bg-elevated);
  border: 1px solid var(--builder-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.builder-project-menu.hidden {
  display: none !important;
}

.builder-project-menu__item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.45rem 0.85rem;
  border: none;
  background: transparent;
  color: var(--builder-text);
  font-size: 0.84rem;
  text-align: left;
  cursor: pointer;
}

.builder-project-menu__item:hover {
  background: rgba(240, 246, 252, 0.08);
}

.builder-project-menu__item i {
  width: 0.95rem;
  text-align: center;
  font-size: 0.78rem;
  opacity: 0.85;
}

.builder-project-menu__item--danger {
  color: #f85149;
}

.builder-project-menu__item--danger:hover {
  background: rgba(248, 81, 73, 0.1);
}

.builder-sidebar-item__title {
  display: block;
  font-size: 0.84rem;
  font-weight: 400;
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  color: inherit;
}

.builder-sidebar-item__time {
  display: none;
}

.builder-sidebar-item.is-active .builder-sidebar-item__time {
  display: none;
}

/* 主区 */
.builder-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--builder-bg-main);
  overflow: hidden;
}

.builder-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.5rem 1.5rem;
  min-height: 2.75rem;
  border-bottom: 1px solid var(--builder-border);
  background: var(--builder-bg-main);
  position: relative;
}

.builder-topbar__center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-width: 0;
  max-width: var(--builder-content-max);
  margin: 0 auto;
}

.builder-topbar__center .builder-title-input {
  width: 100%;
  max-width: 20rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--builder-text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  text-align: center;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.builder-topbar__center .builder-title-input:hover,
.builder-topbar__center .builder-title-input:focus {
  background: var(--builder-bg-elevated);
  border-color: var(--builder-border);
  outline: none;
}

.builder-topbar__meta {
  position: absolute;
  right: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.builder-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.builder-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.builder-code-panel {
  flex-shrink: 0;
  margin: 0.5rem auto 0;
  width: min(var(--builder-content-max), calc(100% - 2rem));
  padding: 0.4rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--builder-border);
  background: var(--builder-bg-elevated);
}

.builder-code-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0;
  font-size: 0.78rem;
  color: var(--builder-text-muted);
}

.builder-code-panel__title {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 500;
  color: var(--builder-text-muted);
}

.builder-code-panel__title i {
  font-size: 0.72rem;
  opacity: 0.85;
}

.builder-code-panel.is-collapsed .builder-code-panel__head {
  margin-bottom: 0;
}

.builder-code-panel.is-collapsed .builder-code-panel__body {
  display: none;
}

.builder-code-panel__body {
  margin-top: 0.35rem;
}

.builder-code-panel pre {
  margin: 0;
  max-height: 4.5rem;
  overflow: auto;
  font-size: 0.72rem;
  line-height: 1.45;
  color: rgba(230, 237, 243, 0.82);
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  padding: 0.45rem 0.55rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.builder-chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  padding: 1.5rem 1.25rem 1rem;
  scrollbar-width: thin;
}

.builder-chat-thread {
  width: min(var(--builder-content-max), 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.builder-chat-empty {
  display: none;
}

.builder-welcome {
  text-align: center;
  padding: 0 1rem 1.25rem;
}

.builder-welcome.hidden {
  display: none !important;
}

.builder-welcome__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  color: var(--builder-text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.builder-welcome__brand img {
  border-radius: 8px;
  opacity: 0.92;
}

/* 用户消息 */
.builder-chat-msg {
  word-break: break-word;
}

.builder-chat-msg--user {
  align-self: flex-end;
  max-width: min(88%, 26rem);
  padding: 0.7rem 1rem;
  border-radius: 18px 18px 4px 18px;
  background: rgba(56, 139, 253, 0.15);
  border: 1px solid rgba(56, 139, 253, 0.25);
  color: var(--builder-text);
  font-size: 0.9rem;
  line-height: 1.65;
  white-space: pre-wrap;
}

/* AI 回复 */
.builder-chat-msg--assistant {
  align-self: stretch;
  width: 100%;
  max-width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--builder-text);
  font-size: 0.9375rem;
  line-height: 1.8;
}

.builder-chat-msg--assistant.is-streaming .builder-chat-msg-body {
  border-left: 2px solid var(--builder-accent);
  padding-left: 1rem;
}

.builder-chat-msg--assistant .n8n-stream-trace {
  margin-bottom: 0.65rem;
}

.builder-chat-msg-body {
  white-space: normal;
}

.builder-chat-msg-body > :first-child {
  margin-top: 0;
}

.builder-chat-msg-body > :last-child {
  margin-bottom: 0;
}

.builder-chat-msg-body h1,
.builder-chat-msg-body h2,
.builder-chat-msg-body h3,
.builder-chat-msg-body h4 {
  margin: 1.15em 0 0.5em;
  font-weight: 600;
  line-height: 1.35;
  color: var(--builder-text);
}

.builder-chat-msg-body h1 { font-size: 1.2rem; }
.builder-chat-msg-body h2 { font-size: 1.08rem; }
.builder-chat-msg-body h3 { font-size: 1rem; }
.builder-chat-msg-body h4 { font-size: 0.95rem; }

.builder-chat-msg-body p {
  margin: 0 0 0.8em;
  color: rgba(230, 237, 243, 0.92);
}

.builder-chat-msg-body ul,
.builder-chat-msg-body ol {
  margin: 0 0 0.9em;
  padding-left: 1.4rem;
}

.builder-chat-msg-body li {
  margin: 0.3em 0;
  color: rgba(230, 237, 243, 0.9);
}

.builder-chat-msg-body hr {
  border: none;
  height: 1px;
  margin: 1.25em 0;
  background: var(--builder-border);
}

.builder-chat-msg-body pre {
  margin: 0.85em 0;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  background: var(--builder-bg-elevated);
  border: 1px solid var(--builder-border);
  overflow-x: auto;
  font-size: 0.84rem;
  line-height: 1.55;
}

.builder-chat-msg-body code {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.88em;
}

.builder-chat-msg-body p code,
.builder-chat-msg-body li code,
.builder-chat-msg-body td code,
.builder-chat-msg-body th code {
  background: rgba(240, 246, 252, 0.08);
  padding: 0.12em 0.35em;
  border-radius: 4px;
}

.builder-chat-msg-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.85em 0 1.1em;
  font-size: 0.875rem;
}

.builder-chat-msg-body th,
.builder-chat-msg-body td {
  border: 1px solid var(--builder-border);
  padding: 0.55rem 0.7rem;
  text-align: left;
  vertical-align: top;
}

.builder-chat-msg-body th {
  background: var(--builder-bg-elevated);
  color: var(--builder-text);
  font-weight: 600;
}

.builder-chat-msg-body td {
  color: rgba(230, 237, 243, 0.9);
}

.builder-chat-msg-body tr:nth-child(even) td {
  background: rgba(240, 246, 252, 0.03);
}

.builder-chat-msg-body a {
  color: var(--builder-accent-hover);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.builder-chat-msg-body strong {
  color: var(--builder-text);
  font-weight: 600;
}

/* 底部 dock：居中浮动输入卡 */
.builder-dock {
  flex-shrink: 0;
  padding: 0.5rem 1.25rem 1rem;
  background: transparent;
  border: none;
}

.builder-dock__center {
  width: min(var(--builder-content-max), 100%);
  margin: 0 auto;
}

.builder-compose-card {
  border: 1px solid var(--builder-border);
  border-radius: 20px;
  background: var(--builder-bg-input);
  padding: 0.85rem 1rem 0.65rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.builder-compose-card:focus-within {
  border-color: rgba(56, 139, 253, 0.45);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(56, 139, 253, 0.2);
}

.builder-chat-input {
  display: block;
  width: 100%;
  min-height: 1.6em;
  max-height: 30vh;
  padding: 0;
  margin-bottom: 0.5rem;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--builder-text);
  font-size: 0.9375rem;
  line-height: 1.6;
  resize: none;
  overflow-y: hidden;
  outline: none;
  font-family: inherit;
  box-sizing: border-box;
}

.builder-chat-input::placeholder {
  color: var(--builder-text-muted);
}

.builder-compose-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 0.5rem;
  min-height: 2rem;
}

.builder-compose-toolbar .input-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
}

.builder-compose-toolbar .hint-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--builder-text-muted);
  background: rgba(240, 246, 252, 0.06);
  border: 1px solid var(--builder-border);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.builder-compose-toolbar .hint-tag i {
  font-size: 0.68rem;
  opacity: 0.85;
}

.builder-compose-toolbar .hint-tag:hover {
  background: rgba(56, 139, 253, 0.12);
  border-color: rgba(56, 139, 253, 0.3);
  color: var(--builder-accent-hover);
}

.builder-compose-toolbar__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  flex: 0 0 auto;
  margin-left: auto;
  padding-left: 0.35rem;
}

.builder-compose-toolbar .char-count {
  font-size: 0.72rem;
  color: var(--builder-text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 1rem;
  text-align: right;
  line-height: 2rem;
}

.builder-compose-toolbar .char-count.hidden {
  display: none !important;
}

.builder-btn-generate {
  flex-shrink: 0;
  padding: 0.35rem 0.85rem;
  border: none;
  border-radius: 999px;
  background: var(--builder-accent);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, opacity 0.12s ease, transform 0.1s ease;
}

.builder-btn-generate:hover:not(:disabled) {
  background: var(--builder-accent-hover);
  transform: scale(1.02);
}

.builder-btn-generate:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.builder-btn-generate.hidden {
  display: none !important;
}

.builder-chat-send {
  position: relative;
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  background: var(--builder-accent);
  color: #fff;
  cursor: pointer;
  transition: background 0.12s ease, opacity 0.12s ease, transform 0.1s ease;
}

.builder-chat-send__icon {
  font-size: 0.82rem;
  line-height: 1;
}

.builder-chat-send__loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  background: inherit;
  color: inherit;
  font-size: 0.82rem;
}

.builder-chat-send__loading.hidden {
  display: none !important;
}

.builder-chat-send.is-loading .builder-chat-send__icon {
  visibility: hidden;
}

.builder-chat-send:hover:not(:disabled) {
  background: var(--builder-accent-hover);
  transform: scale(1.05);
}

.builder-chat-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.builder-dock-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

.builder-dock .builder-status {
  margin-top: 0.5rem;
  text-align: center;
}

.builder-dock .builder-status:empty {
  display: none;
}

.builder-dock__hint {
  margin: 0.5rem 0 0;
  font-size: 0.7rem;
  color: var(--builder-text-muted);
  text-align: center;
  line-height: 1.45;
  opacity: 0.85;
}

@media (max-width: 900px) {
  body.page-builder {
    --builder-sidebar-w: 100%;
  }

  .builder-layout {
    flex-direction: column;
  }

  .builder-sidebar {
    flex: 0 0 auto;
    border-right: none;
    border-bottom: 1px solid var(--builder-border);
    max-height: 130px;
    padding: 0.65rem 0.75rem;
  }

  .builder-sidebar-brand {
    padding-bottom: 0.5rem;
  }

  .builder-sidebar-new {
    margin-bottom: 0.5rem;
  }

  .builder-topbar__meta {
    right: 0.75rem;
  }

  .builder-dock {
    padding: 0.5rem 0.75rem 0.85rem;
  }

  .builder-compose-toolbar .hint-tag span:not(.fa):not(.fas) {
    /* 小屏可保留文字 */
  }
}

@media (max-width: 640px) {
  .builder-compose-toolbar .hint-tag {
    padding: 0.28rem 0.5rem;
    font-size: 0.7rem;
  }

  .builder-chat-msg--user {
    max-width: 92%;
  }
}

.builder-title-field,
.builder-status-field {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  width: 100%;
  height: 100%;
}

.builder-field-label,
.builder-title-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #b8c7d9;
  margin-bottom: 0.4rem;
}

.builder-status-display {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 2.35rem;
  padding: 0.5rem 0.65rem;
  font-size: 0.9rem;
  color: #f1f5f9;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 6px;
  box-sizing: border-box;
}

.builder-field-hint,
.builder-title-hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.76rem;
  color: #64748b;
  line-height: 1.45;
  min-height: 2.2rem;
}

.builder-status-hint {
  visibility: hidden;
  min-height: 2.2rem;
}

.builder-title-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
}

.builder-title-input {
  width: 100%;
  max-width: none;
  padding: 0.5rem 0.65rem;
  font-size: 0.9rem;
  color: #f1f5f9;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 6px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.builder-title-input.is-title-streaming {
  border-color: rgba(212, 185, 150, 0.45);
  box-shadow: 0 0 0 2px rgba(212, 185, 150, 0.1);
  animation: builder-title-pulse 1.4s ease-in-out infinite;
}

@keyframes builder-title-pulse {
  0%,
  100% {
    border-color: rgba(212, 185, 150, 0.35);
  }
  50% {
    border-color: rgba(212, 185, 150, 0.65);
  }
}

.strategy-title-streaming {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  font-size: 0.78rem;
  color: rgba(212, 185, 150, 0.92);
  white-space: nowrap;
}

.strategy-title-streaming.hidden {
  display: none;
}

.builder-title-input:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.55);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}

.builder-title-input::placeholder {
  color: #64748b;
}

/* 避免 Chrome 误填账号后黄底；与输入框背景一致 */
.builder-title-input:-webkit-autofill,
.builder-title-input:-webkit-autofill:hover,
.builder-title-input:-webkit-autofill:focus {
  -webkit-text-fill-color: #f1f5f9;
  -webkit-box-shadow: 0 0 0 1000px rgba(15, 23, 42, 0.55) inset;
  box-shadow: 0 0 0 1000px rgba(15, 23, 42, 0.55) inset;
  transition: background-color 99999s ease-out 0s;
}

html.theme-palette-jiguang body.page-builder.cyber-theme .builder-title-input:-webkit-autofill,
html.theme-palette-jiguang body.page-builder.cyber-theme .builder-title-input:-webkit-autofill:hover,
html.theme-palette-jiguang body.page-builder.cyber-theme .builder-title-input:-webkit-autofill:focus {
  -webkit-text-fill-color: #1e293b;
  -webkit-box-shadow: 0 0 0 1000px #ffffff inset;
  box-shadow: 0 0 0 1000px #ffffff inset;
}

.builder-title-hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.76rem;
  color: #64748b;
  line-height: 1.45;
}

html.theme-palette-jiguang body.page-builder.cyber-theme .builder-field-label,
html.theme-palette-jiguang body.page-builder.cyber-theme .builder-title-label {
  color: #64748b !important;
}

html.theme-palette-jiguang body.page-builder.cyber-theme .builder-title-input {
  background: #fff !important;
  border-color: rgba(30, 41, 59, 0.12) !important;
  color: #1e293b !important;
}

html.theme-palette-jiguang body.page-builder.cyber-theme .builder-status-display {
  background: #fff !important;
  border-color: rgba(30, 41, 59, 0.12) !important;
  color: #1e293b !important;
}

html.theme-palette-jiguang body.page-builder.cyber-theme .builder-field-hint,
html.theme-palette-jiguang body.page-builder.cyber-theme .builder-title-hint {
  color: #94a3b8 !important;
}

/* 操作区：左右底栏同一行样式 */
.section-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  align-items: center;
  width: 100%;
}

.result-actions {
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 0.5rem;
}

@media (max-width: 768px) {
  .result-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}

.btn-builder-login {
  border-style: dashed !important;
}

/* 状态提示 */
.builder-status {
  margin-top: 0.55rem;
  padding: 0.55rem 0.75rem;
  border-radius: 6px;
  font-size: 0.88rem;
  background: rgba(148, 163, 184, 0.06);
  border: 1px solid rgba(148, 163, 184, 0.15);
  color: #b0bfd5;
}

.builder-pane__row--foot .builder-status {
  margin-top: 0.55rem;
}

.builder-pane__row--foot .builder-status:empty {
  display: none;
  margin-top: 0;
}

.builder-status.error {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.25);
  color: #f87171;
}

.builder-status.ok {
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.25);
  color: #4ade80;
}

@media (max-width: 768px) {
  .builder-section {
    padding: 1rem;
  }
  .builder-steps {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.35rem;
  }
  .step-line {
    display: none;
  }
  .hint-tag {
    font-size: 0.72rem;
  }
}
