/* 灵枢 Creator OS 2.0 shell and responsive surface.
   Business widgets keep their existing hooks; this layer owns the workspace frame,
   navigation hierarchy, responsive sizing, and the shared visual language. */

body.ui-v2 {
  --v2-bg: #f5f7fa;
  --v2-surface: #ffffff;
  --v2-surface-muted: #f8fafc;
  --v2-line: #e5e9ef;
  --v2-line-strong: #d5dce5;
  --v2-ink: #202936;
  --v2-muted: #6d7785;
  --v2-faint: #98a2af;
  --v2-brand: #3262b8;
  --v2-brand-strong: #234d94;
  --v2-brand-soft: #edf3fc;
  --v2-brand-line: #cbdaf0;
  --v2-accent-gradient: linear-gradient(115deg, #436bc0 0%, #3159a7 52%, #257b88 100%);
  --v2-selection-gradient: linear-gradient(115deg, #ffffff 0%, #eaf0ff 55%, #e3f2f3 100%);
  /* Shared light surfaces: static gradients, without extra filters or animation. */
  --v2-canvas-gradient: radial-gradient(ellipse at 4% 0%, #e7edfc 0%, transparent 48%), radial-gradient(ellipse at 100% 88%, #e6f2f1 0%, transparent 42%), linear-gradient(145deg, #f7f8fc, #f0f4fa 58%, #f4f8f8);
  --v2-panel-gradient: linear-gradient(145deg, #ffffff 0%, #ffffff 58%, #f5f8fd 100%);
  --v2-heading-gradient: linear-gradient(110deg, #f2f5fe 0%, #fafbff 52%, #f0f8f7 100%);
  --blue: var(--v2-brand);
  --blue-soft: var(--v2-brand-soft);
  --v2-green: #2f8d61;
  --v2-green-soft: #e8f5ee;
  --v2-gold: #b67813;
  --v2-gold-soft: #fff5df;
  --v2-danger: #c94d4d;
  --v2-danger-soft: #fceded;
  --v2-shadow-sm: 0 1px 2px rgba(20, 30, 44, 0.03), 0 8px 24px rgba(20, 30, 44, 0.04);
  --v2-shadow-md: 0 12px 32px rgba(20, 30, 44, 0.08);
  color: var(--v2-ink);
  background: var(--v2-bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
}

body.ui-v2,
body.ui-v2 .app-shell {
  min-width: 0;
}

body.ui-v2 .app-shell {
  width: 100%;
  max-width: none;
  height: 100dvh;
  min-height: 0;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-rows: 68px minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--v2-bg);
}

body.ui-v2 .hero {
  z-index: 300;
  min-height: 0;
  height: 68px;
  margin: 0;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--v2-line);
  background: linear-gradient(110deg, #ffffff 8%, #edf2ff 56%, #e8f5f2 100%);
  box-shadow: 0 2px 14px rgba(43, 65, 108, 0.04), inset 0 1px 0 #fff;
}

body.ui-v2 .brand-lockup {
  flex: 0 0 auto;
  min-width: 0;
  height: 42px;
  display: inline-flex;
  align-items: center;
}

body.ui-v2 .brand-logo {
  width: auto;
  height: 38px;
}

body.ui-v2 .header-version-switch {
  display: none !important;
}

body.ui-v2 .header-feedback-btn {
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--v2-line);
  border-radius: 8px;
  color: var(--v2-muted);
  background: var(--v2-surface-muted);
  font-size: 12px;
  font-weight: 750;
}

body.ui-v2 .header-feedback-btn:hover {
  border-color: var(--v2-line-strong);
  color: var(--v2-ink);
  background: var(--v2-surface);
}

body.ui-v2 .header-actions {
  flex: 0 0 auto;
  min-width: 0;
  margin-left: auto;
  gap: 12px;
}

body.ui-v2 .header-stats {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--v2-line);
  border-radius: 7px;
  color: var(--v2-muted);
  background: var(--v2-surface-muted);
  font-size: 11px;
  font-weight: 700;
}

body.ui-v2 #accountMenuButton.user-name-btn {
  min-height: 40px;
  padding: 0 3px;
  color: var(--v2-ink);
}

body.ui-v2 #accountMenuButton .account-avatar {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
}

body.ui-v2 #accountMenuButton .account-button-copy b {
  color: var(--v2-ink);
  font-size: 13px;
}

body.ui-v2 #accountMenuButton .account-button-copy small {
  color: var(--v2-faint);
  font-size: 10px;
}

body.ui-v2 .workspace-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  overflow: hidden;
}

body.ui-v2 .workspace-rail {
  position: relative;
  z-index: 220;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid var(--v2-line);
  background: linear-gradient(168deg, #ffffff 20%, #f4f7fe 72%, #eef6f5);
}

body.ui-v2 .workspace-rail-heading {
  padding: 22px 18px 10px;
  color: var(--v2-faint);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

body.ui-v2 #stepNav {
  z-index: 220;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0 12px 18px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body.ui-v2 #stepNav > .grouped-nav-item,
body.ui-v2 #stepNav > .top-nav-button {
  width: 100%;
  min-width: 0;
}

body.ui-v2 #stepNav > .grouped-nav-item {
  position: relative;
}

body.ui-v2 #stepNav > button,
body.ui-v2 #stepNav .grouped-nav-main {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #48566c;
  background: transparent;
  box-shadow: none;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.5;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .8);
  text-align: left;
}

body.ui-v2 #stepNav > button:hover,
body.ui-v2 #stepNav .grouped-nav-main:hover,
body.ui-v2 #stepNav .grouped-nav-main[aria-expanded="true"] {
  color: var(--v2-ink);
  background: var(--v2-surface-muted);
}

body.ui-v2 #stepNav > button.active,
body.ui-v2 #stepNav .grouped-nav-main.active {
  color: var(--v2-brand-strong);
  border-color: var(--v2-brand-line);
  background: var(--v2-selection-gradient);
  box-shadow: 0 4px 12px rgba(49, 89, 167, 0.08), inset 0 1px 0 #fff;
}

body.ui-v2 #stepNav > button.active::before,
body.ui-v2 #stepNav .grouped-nav-main.active::before,
body.ui-v2 #stepNav > button.active::after,
body.ui-v2 #stepNav .grouped-nav-main.active::after {
  content: none;
}

body.ui-v2 #stepNav .grouped-nav-caret {
  margin-left: auto;
  border-color: currentColor;
}

/* Keep expanded navigation in the rail's flow, clear of adjacent sections. */
body.ui-v2 #stepNav .grouped-nav-menu {
  position: static;
  width: auto;
  min-width: 0;
  margin: 5px 0 8px 12px;
  padding: 0 0 0 8px;
  display: grid;
  gap: 3px;
  border: 0;
  border-left: 1px solid var(--v2-line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  transform: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body.ui-v2 #stepNav .grouped-nav-menu::before {
  content: none;
}

/* Flat single-line rows that match the nav rail rhythm. */
body.ui-v2 #stepNav .grouped-nav-menu button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 1px;
  width: 100%;
  min-height: 38px;
  padding: 5px 10px;
  border: 0;
  border-radius: 7px;
  color: var(--v2-muted);
  background: transparent;
  text-align: left;
  line-height: 1.5;
  box-shadow: none;
  white-space: normal;
  transform: none;
}

body.ui-v2 #stepNav .grouped-nav-menu button span {
  font-size: 13px;
  font-weight: 500;
  color: inherit;
  line-height: 1.5;
}

body.ui-v2 #stepNav .grouped-nav-menu button small {
  display: none;
}

body.ui-v2 #stepNav .grouped-nav-menu button:hover,
body.ui-v2 #stepNav .grouped-nav-menu button.active {
  color: var(--v2-ink);
  background: var(--v2-surface-muted);
}

body.ui-v2 #stepNav .grouped-nav-menu button:hover span,
body.ui-v2 #stepNav .grouped-nav-menu button.active span {
  color: var(--v2-brand-strong);
}

body.ui-v2 #stepNav .grouped-nav-menu button.active {
  background: var(--v2-selection-gradient);
}

body.ui-v2 #stepNav button:focus-visible {
  outline: 2px solid var(--v2-brand);
  outline-offset: -2px;
}

body.ui-v2 .workspace-rail .legacy-step-nav {
  display: none !important;
}

body.ui-v2 .workspace-content {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--v2-canvas-gradient);
}

body.ui-v2 .mobile-workspace-nav {
  position: relative;
  z-index: 100;
  min-height: 56px;
  margin: 0;
  padding: 0 24px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--v2-line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

body.ui-v2 .mobile-workspace-nav[hidden] {
  display: none;
}

body.ui-v2 .mobile-workspace-nav > div {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

body.ui-v2 .mobile-workspace-nav button {
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--v2-muted);
  background: transparent;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

body.ui-v2 .mobile-workspace-nav button:hover,
body.ui-v2 .mobile-workspace-nav button.active {
  color: var(--v2-brand-strong);
  border-color: var(--v2-brand-line);
  background: var(--v2-selection-gradient);
}

body.ui-v2 .workspace-content > main {
  width: 100%;
  max-width: none;
  margin: 0;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

/* No fill-mode: the transform disappears after entry, preserving fixed overlays.
   The existing active class starts this once per switch, not on stream updates. */
@keyframes lingshu-stage-enter {
  from { transform: translateX(10px); }
  to { transform: none; }
}

@media (prefers-reduced-motion: no-preference) {
  body.ui-v2 .stage.active {
    animation: lingshu-stage-enter 200ms cubic-bezier(.22, 1, .36, 1);
  }

  /* Do not create a transformed containing block while an in-stage modal is open. */
  body.ui-v2 .stage.active:has(dialog[open], :is(.digital-human-modal, .auto-edit-modal, .account-editor-overlay, .account-detail-overlay, .competitor-preview-overlay, .competitor-comments-overlay):not([hidden])) {
    animation: none;
  }

  body.ui-v2 #stepNav > button,
  body.ui-v2 #stepNav .grouped-nav-main,
  body.ui-v2 section[data-stage="ai-chat"] :is(.ai-chat-plaza-row, .ai-chat-new-thread-row) {
    transition: color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
  }
}

body.ui-v2 .stage.active {
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 24px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

/* 桌面端由主内容区承接整页滚动：stage 只负责内容布局、不再作为滚动容器，
   这样就避免了鼠标停在面板/卡片上时滚轮事件被内部 overflow 链吃掉。 */
@media (min-width: 861px) {
  body.ui-v2 .workspace-content > main {
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }

  body.ui-v2 .stage.active {
    overflow: visible;
  }

  body.ui-v2 section[data-stage="source"] .source-grid > .panel {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  /* 成片卡审是长列表，桌面端统一交给主内容区滚动。原来的
     #cloudVideoList / .tencent-material-table-wrap 双层 100% 高度链在
     内容变多后会把表格撑出视口，同时 overscroll-behavior: contain
     又阻止滚轮传给 main，导致同步后鼠标滚轮完全失效。 */
  body.ui-v2 section[data-stage="cloud-video"] .panel {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  body.ui-v2 section[data-stage="cloud-video"] .cloud-video-results,
  body.ui-v2 section[data-stage="cloud-video"] #cloudVideoList,
  body.ui-v2 section[data-stage="cloud-video"] .tencent-material-table-wrap {
    flex: none;
    height: auto;
    max-height: none;
    overflow: visible;
    overscroll-behavior: auto;
  }
}

/* Narrow desktop widths need a local horizontal table rail, while vertical
   wheel input must continue bubbling to the workbench's main scroller. */
@media (min-width: 721px) {
  body.ui-v2 section[data-stage="cloud-video"] .tencent-material-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior: auto;
  }
}

/* 素材转文案的面板沿用了旧版「自己滚动 + overscroll-behavior: contain」写法。
   现在整页滚动由 main / stage 承担，面板本身不溢出，contain 会把滚轮吞掉，
   导致鼠标停在卡片上时完全滚不动。放开内容传递，滚轮即可正常滚动。 */
body.ui-v2 section[data-stage="source"] .source-grid > .panel {
  overscroll-behavior: auto;
}

body.ui-v2 .stage-grid {
  width: 100%;
  min-height: 100%;
  height: auto;
  overflow: visible;
}

body.ui-v2 .stage-grid,
body.ui-v2 .source-grid,
body.ui-v2 .chat-grid,
body.ui-v2 .knowledge-grid,
body.ui-v2 .rewrite-grid,
body.ui-v2 .review-grid {
  gap: 18px;
}

body.ui-v2 .source-grid,
body.ui-v2 .chat-grid,
body.ui-v2 .knowledge-grid,
body.ui-v2 .rewrite-grid,
body.ui-v2 .review-grid {
  grid-template-columns: minmax(280px, 0.82fr) minmax(0, 1.18fr);
}

body.ui-v2 .panel,
body.ui-v2 .chanmama-collector-panel {
  border: 1px solid var(--v2-line);
  border-radius: 8px;
  background: var(--v2-panel-gradient);
  box-shadow: 0 8px 24px rgba(43, 65, 108, 0.045), inset 0 1px 0 #fff;
}

body.ui-v2 .panel-head {
  min-height: 58px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--v2-line);
  background: var(--v2-heading-gradient);
}

body.ui-v2 .panel-head h2,
body.ui-v2 .panel-head h3 {
  color: var(--v2-ink);
  font-size: 16px;
  font-weight: 850;
}

body.ui-v2 .panel-head p {
  margin-top: 4px;
  color: var(--v2-muted);
  font-size: 12px;
  line-height: 1.55;
}

body.ui-v2 input,
body.ui-v2 textarea,
body.ui-v2 select {
  border-color: var(--v2-line-strong);
  border-radius: 8px;
  color: var(--v2-ink);
  background: var(--v2-surface);
}

body.ui-v2 input:focus,
body.ui-v2 textarea:focus,
body.ui-v2 select:focus {
  border-color: var(--v2-brand);
  box-shadow: 0 0 0 3px rgba(50, 98, 184, 0.12);
}

body.ui-v2 .primary-btn {
  min-height: 40px;
  border-radius: 8px;
  color: #fff;
  background: var(--v2-accent-gradient);
  box-shadow: 0 2px 6px rgba(50, 98, 184, 0.12);
}

body.ui-v2 .primary-btn:hover {
  background: var(--v2-brand-strong);
}

body.ui-v2 .ghost-btn {
  min-height: 38px;
  border: 1px solid var(--v2-line-strong);
  border-radius: 8px;
  color: var(--v2-ink);
  background: var(--v2-surface);
}

body.ui-v2 .ghost-btn:hover {
  border-color: var(--v2-brand-line);
  color: var(--v2-brand-strong);
  background: var(--v2-brand-soft);
}

body.ui-v2 .field-row label,
body.ui-v2 .field label,
body.ui-v2 .rewrite-course-picker > label,
body.ui-v2 .digital-human-field > span {
  color: var(--v2-muted);
  font-size: 12px;
  font-weight: 750;
}

body.ui-v2 section[data-stage="chanmama"] .chanmama-browser {
  height: auto;
  min-height: 100%;
  padding: 0;
  overflow: visible;
}

body.ui-v2 section[data-stage="chanmama"] .chanmama-category-tabs {
  padding: 0 0 12px;
  gap: 6px;
  flex-wrap: wrap;
  overflow: visible;
  border: 0;
}

body.ui-v2 section[data-stage="chanmama"] .chanmama-category-tabs button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  color: var(--v2-muted);
  background: transparent;
  font-size: 12px;
}

body.ui-v2 section[data-stage="chanmama"] .chanmama-category-tabs button.active {
  color: var(--v2-brand-strong);
  background: var(--v2-brand-soft);
  box-shadow: none;
}

body.ui-v2 section[data-stage="chanmama"] .chanmama-category-tabs .category-del,
body.ui-v2 section[data-stage="chanmama"] .chanmama-category-tabs button.active .category-del {
  border-left: 0;
  padding-left: 4px;
}

body.ui-v2 section[data-stage="chanmama"] .chanmama-collector-panel {
  padding: 0;
  border: 0;
  background: transparent;
}

body.ui-v2 section[data-stage="chanmama"] .chanmama-search-action {
  min-height: 48px;
  padding: 0;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) 132px;
  background: transparent;
  border: 0;
  box-shadow: none;
}

body.ui-v2 section[data-stage="chanmama"] .chanmama-search-action .field-row {
  min-width: 0;
}

body.ui-v2 section[data-stage="chanmama"] .chanmama-search-action input {
  min-height: 42px;
  background: var(--v2-surface-muted);
}

body.ui-v2 section[data-stage="chanmama"] .chanmama-search-action button {
  min-height: 42px;
  border-radius: 8px;
}

body.ui-v2 section[data-stage="chanmama"] .chanmama-task-strip {
  margin: 14px 0;
  padding: 8px 0;
  border: 0;
  border-bottom: 1px solid var(--v2-line);
  border-radius: 0;
  color: var(--v2-muted);
  background: transparent;
}

body.ui-v2 section[data-stage="chanmama"] #chanmamaDataList,
body.ui-v2 section[data-stage="chanmama"] #miaosiDataList {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

body.ui-v2 section[data-stage="chanmama"] .chanmama-grid-card {
  border: 1px solid var(--v2-line);
  border-radius: 8px;
  background: var(--v2-surface);
  box-shadow: var(--v2-shadow-sm);
}

body.ui-v2 section[data-stage="chanmama"] .chanmama-grid-card:hover,
body.ui-v2 section[data-stage="chanmama"] .chanmama-grid-card:focus-visible {
  border-color: var(--v2-brand-line);
  box-shadow: var(--v2-shadow-md);
  transform: translateY(-1px);
}

body.ui-v2 section[data-stage="chanmama"] .chanmama-card-media {
  aspect-ratio: 5 / 6;
}

body.ui-v2 .chanmama-card-media.preview-unavailable {
  background: var(--v2-surface-muted);
}

body.ui-v2 .chanmama-card-media img[hidden] {
  display: none;
}

body.ui-v2 .chanmama-cover-unavailable:not([hidden]) {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--v2-muted);
  font-size: 13px;
}

body.ui-v2 section[data-stage="chanmama"] .chanmama-card-body {
  padding: 8px;
}

body.ui-v2 section[data-stage="chanmama"] .chanmama-card-body h3 {
  min-height: 34px;
  color: var(--v2-ink);
  font-size: 13px;
  line-height: 1.35;
}

body.ui-v2 section[data-stage="chanmama"] .chanmama-author {
  margin: 4px 0 5px;
  color: var(--v2-muted);
}

body.ui-v2 section[data-stage="chanmama"] .chanmama-card-save {
  min-height: 28px;
  margin-top: 6px;
  border-color: var(--v2-brand-line);
  border-radius: 8px;
  color: var(--v2-brand-strong);
  background: transparent;
}

body.ui-v2 section[data-stage="chanmama"] .chanmama-card-save:hover {
  border-color: var(--v2-brand);
  color: #fff;
  background: var(--v2-brand);
}

body.ui-v2 section[data-stage="chanmama"] .chanmama-primary-metrics.youshu-metrics {
  padding-block: 4px;
}

body.ui-v2 section[data-stage="chanmama"] .chanmama-primary-metrics.youshu-metrics dt {
  font-size: 9px;
}

body.ui-v2 section[data-stage="chanmama"] .chanmama-primary-metrics.youshu-metrics dd {
  font-size: 12px;
}

body.ui-v2 .ai-chat-workspace {
  min-height: 100%;
  height: auto;
  overflow: hidden;
  border: 1px solid var(--v2-line);
  border-radius: 8px;
  background: var(--v2-surface);
  box-shadow: var(--v2-shadow-sm);
}

body.ui-v2 .ai-chat-sidebar {
  border-right-color: var(--v2-line);
  background: var(--v2-surface-muted);
}

body.ui-v2 .ai-chat-sidebar-head,
body.ui-v2 .ai-chat-main-head {
  border-bottom-color: var(--v2-line);
  background: var(--v2-surface);
}

body.ui-v2 .ai-chat-main-head h2 {
  color: var(--v2-ink);
  font-size: 16px;
}

body.ui-v2 .ai-chat-log {
  background: var(--v2-surface);
}

body.ui-v2 .ai-chat-composer {
  border-top-color: var(--v2-line);
  padding: 12px 18px 16px;
  background: var(--v2-surface-muted);
}

body.ui-v2 .ai-chat-composer-inner,
body.ui-v2 .analysis-chat-composer {
  min-height: 102px;
  border: 1px solid var(--v2-line-strong);
  border-radius: 10px;
  background: var(--v2-surface);
  box-shadow: 0 1px 3px rgba(20, 30, 44, 0.04);
  overflow: visible;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-composer-inner {
  display: grid;
  grid-template-rows: auto auto;
  width: 100%;
  max-width: 980px;
  margin-inline: auto;
  padding: 0 12px 10px;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-composer-inner:focus-within {
  border-color: var(--v2-brand);
  box-shadow: 0 0 0 3px rgba(50, 98, 184, 0.08);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-composer {
  min-height: 0;
  margin: 0;
  padding: 12px 20px 16px;
  border: 0;
  border-radius: 0;
  background: var(--v2-surface);
  box-shadow: none;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-composer textarea {
  min-height: 58px;
  padding: 12px 2px 6px;
  font-size: 14px;
  line-height: 1.55;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-composer-actions {
  position: static;
  min-height: 36px;
  padding-top: 6px;
  border-top: 1px solid var(--v2-line);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-model-picker-button {
  height: 28px;
  width: 156px;
  max-width: 156px;
  border-color: var(--v2-line);
  border-radius: 7px;
  background: var(--v2-surface-muted);
  font-size: 11px;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-model-picker-menu {
  bottom: 34px;
  max-width: min(430px, calc(100vw - 32px));
  border-color: var(--v2-line-strong);
  border-radius: 8px;
  box-shadow: var(--v2-shadow-md);
}

@keyframes aiChatModelPickerFadeIn {
  from { opacity: 0; transform: translateY(4px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes aiChatModelPickerSubmenuFadeIn {
  from { opacity: 0; transform: translateX(8px); }
  to { opacity: 1; transform: translateX(0); }
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-model-picker-menu:not([hidden]) {
  animation: none;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-model-picker-submenu {
  animation: aiChatModelPickerSubmenuFadeIn 160ms ease-out both;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-model-picker-columns {
  animation: none;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-send-btn:disabled {
  color: #fff;
  background: #b6c0cb;
  box-shadow: none;
  cursor: not-allowed;
}

body.ui-v2 section[data-stage="ai-chat"] #aiChatSendBtn:disabled {
  background: #b6c0cb;
  opacity: 1;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-skill-btn {
  width: 28px;
  height: 28px;
  border-color: var(--v2-line);
  border-radius: 7px;
  color: var(--v2-muted);
  background: var(--v2-surface-muted);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-send-btn {
  background: var(--v2-brand);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-send-btn:hover {
  background: var(--v2-brand-strong);
}

body.ui-v2 section[data-stage="rewrite"] .panel,
body.ui-v2 section[data-stage="digital-human"] .panel,
body.ui-v2 section[data-stage="review"] .panel,
body.ui-v2 section[data-stage="cloud-video"] .panel,
body.ui-v2 section[data-stage="accounts"] .panel {
  border-radius: 8px;
  background: var(--v2-panel-gradient);
}

body.ui-v2 section[data-stage="rewrite"] .rewrite-mode-switch,
body.ui-v2 section[data-stage="rewrite"] .rewrite-course-picker,
body.ui-v2 section[data-stage="rewrite"] .rewrite-action-row {
  border-color: var(--v2-line);
}

body.ui-v2 .mobile-bottom-nav {
  display: none;
}

body.ui-v2 .toast {
  z-index: 12000;
}

body.ui-v2 .cloud-video-calendar-days > button.selected {
  color: var(--v2-brand-strong);
  border-color: var(--v2-brand-line);
  background: var(--v2-selection-gradient);
}

body.ui-v2 .cloud-video-date-trigger[aria-expanded="true"] {
  border-color: var(--v2-brand);
}

body.ui-v2 :is(.memory-dialog, .skills-dialog, .prompts-dialog)::backdrop {
  background: rgba(32, 41, 54, 0.28);
  backdrop-filter: blur(5px);
}

body.ui-v2 .digital-human-modal {
  backdrop-filter: blur(5px);
}

body.ui-v2 .digital-human-modal-dialog {
  min-width: 0;
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 32px);
  border-radius: 8px;
}

@media (max-width: 720px) {
  body.ui-v2 .digital-human-modal {
    padding: 12px;
  }

  body.ui-v2 .digital-human-modal-dialog {
    width: 100%;
    max-width: 100%;
    padding: 16px;
  }

  body.ui-v2 .digital-human-modal-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  body.ui-v2 .digital-human-gender-filter {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    min-width: 0;
    gap: 3px;
  }

  body.ui-v2 .digital-human-gender-filter button {
    white-space: nowrap;
    min-height: 32px;
    padding-inline: 8px;
  }

  body.ui-v2 .digital-human-modal-filters input[type="search"] {
    flex: 1 0 100%;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
}

body.ui-v2 :is(.memory-dialog, .skills-dialog, .prompts-dialog) {
  max-height: calc(100dvh - 32px);
  max-width: calc(100vw - 24px);
  border-radius: 8px;
}

/* Shared controls must override the legacy ID-based red button styles. */
body.ui-v2 :is(#startChanmamaBtn, #startMiaosiBtn, #makeRewriteBtn, #ingestLinksBtn, #accountNewBtn) {
  border: 1px solid transparent;
  color: #fff;
  background: var(--v2-accent-gradient);
  box-shadow: none;
}

body.ui-v2 :is(#startChanmamaBtn, #startMiaosiBtn, #makeRewriteBtn, #ingestLinksBtn, #accountNewBtn):hover:not(:disabled) {
  color: #fff;
  background: linear-gradient(115deg, #264c98, #196873);
}

body.ui-v2 .primary-btn:disabled,
body.ui-v2 :is(#startChanmamaBtn, #startMiaosiBtn, #makeRewriteBtn, #ingestLinksBtn, #accountNewBtn):disabled {
  border-color: transparent;
  color: #fff;
  background: #8794a4;
  box-shadow: none;
  cursor: not-allowed;
}

body.ui-v2 section[data-stage="chanmama"] .chanmama-search-action input {
  box-shadow: none;
}

body.ui-v2 section[data-stage="chanmama"] .chanmama-search-action input:focus {
  box-shadow: 0 0 0 3px rgba(50, 98, 184, 0.12);
}

body.ui-v2 .rewrite-framework-card {
  border: 1px solid var(--v2-line);
  border-radius: 8px;
  background: var(--v2-surface);
  box-shadow: none;
}

body.ui-v2 .rewrite-framework-card.active {
  border-color: var(--v2-brand-line);
  background: var(--v2-selection-gradient);
  box-shadow: none;
}

body.ui-v2 .rewrite-framework-card::before,
body.ui-v2 .rewrite-framework-card::after {
  content: none;
}

body.ui-v2 .ai-chat-log {
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  overflow-x: hidden;
}

body.ui-v2 .ai-chat-message,
body.ui-v2 .ai-chat-message > div {
  min-width: 0;
  overflow-wrap: anywhere;
}

body.ui-v2 .ai-chat-message pre {
  max-width: 100%;
  overflow-x: auto;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-web-sources {
  display: grid;
  width: min(680px, 100%);
  gap: 7px;
  margin-top: 10px;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-web-sources-head {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 2px 0;
  border: 0;
  border-radius: 0;
  color: #65738a;
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-web-sources-head:hover,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-web-sources-head:focus-visible {
  color: var(--v2-brand-strong);
  outline: none;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-web-sources-head i {
  width: 6px;
  height: 6px;
  margin: -3px 0 0 2px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform .16s ease;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-web-sources.is-expanded .ai-chat-web-sources-head i {
  margin-top: 3px;
  transform: rotate(225deg);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-web-sources-head svg {
  width: 14px;
  height: 14px;
  color: var(--v2-brand);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-web-source-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 6px;
}


body.ui-v2 .memory-section {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

body.ui-v2 .memory-section-title,
body.ui-v2 .memory-list-head {
  border-top: 0;
  padding-top: 0;
}

body.ui-v2 .memory-section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

body.ui-v2 .memory-section-title small,
body.ui-v2 .memory-guidance p,
body.ui-v2 .memory-list-head small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

body.ui-v2 .memory-guidance p {
  margin: 0;
  line-height: 1.5;
}

body.ui-v2 .memory-facts-section {
  gap: 9px;
  padding-top: 12px;
  border-top: 1px solid var(--v2-line);
}

body.ui-v2 .memory-facts-section .memory-list-head {
  gap: 10px;
}

body.ui-v2 .memory-facts-section .memory-list-head strong {
  margin-right: 0;
}

body.ui-v2 .skills-dialog:not(.has-skill-preview) .skills-body {
  grid-template-columns: minmax(0, 1fr);
}

/* 技能广场默认态以浏览和选择为主，收窄面板并提高可用高度。 */
body.ui-v2 .skills-dialog {
  width: min(680px, calc(100vw - 32px));
  height: min(720px, calc(100dvh - 48px));
  max-height: calc(100dvh - 48px);
  overflow: hidden;
}

body.ui-v2 .skills-dialog.has-skill-preview {
  width: min(860px, calc(100vw - 32px));
}

body.ui-v2 .skills-dialog .skills-body {
  max-height: none;
  height: calc(100% - 105px);
  min-height: 0;
}

body.ui-v2 .skills-dialog:not(.has-skill-preview) .skills-list-pane {
  padding-block: 18px;
}

body.ui-v2 .skills-dialog #aiChatSkillsPreview[hidden] {
  display: none;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-web-source-list[hidden] {
  display: none;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-web-source-list a {
  display: grid;
  min-width: 0;
  grid-template-columns: 20px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 7px;
  padding: 8px 9px;
  border: 1px solid rgba(119, 141, 174, 0.18);
  border-radius: 8px;
  color: #2d3b51;
  background: linear-gradient(135deg, rgba(241, 246, 255, 0.9), rgba(248, 250, 253, 0.96));
  text-decoration: none;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-web-source-list a:hover,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-web-source-list a:focus-visible {
  border-color: rgba(50, 98, 184, 0.32);
  background: linear-gradient(135deg, rgba(233, 241, 255, 0.96), rgba(246, 249, 254, 1));
  outline: none;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-web-source-list b {
  display: grid;
  width: 20px;
  height: 20px;
  grid-row: 1 / 3;
  place-items: center;
  border-radius: 6px;
  color: #315b9a;
  background: rgba(50, 98, 184, 0.10);
  font-size: 10px;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-web-source-list span,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-web-source-list small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-web-source-list span {
  font-size: 11px;
  font-weight: 650;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-web-source-list small {
  color: #7a8798;
  font-size: 10px;
}

body.ui-v2 .ai-chat-new-thread-row,
body.ui-v2 .ai-chat-thread-item.active {
  background: var(--v2-selection-gradient);
  box-shadow: none;
}

body.ui-v2 section[data-stage="ai-chat"] #aiChatSendBtn {
  background: var(--v2-accent-gradient);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-stop-btn {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: var(--v2-accent-gradient, linear-gradient(135deg, #e36b61, #c84f46));
  box-shadow: 0 7px 16px rgba(180, 76, 68, 0.2);
  cursor: pointer;
  transition: transform .15s ease, filter .15s ease;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-stop-btn:hover,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-stop-btn:focus-visible {
  filter: brightness(1.04);
  transform: scale(1.04);
  outline: none;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-stop-btn:active {
  transform: scale(.94);
}

body.ui-v2 section[data-stage="accounts"] .ghost-btn.account-edit-btn,
body.ui-v2 section[data-stage="accounts"] .ghost-btn.account-edit-btn:focus,
body.ui-v2 section[data-stage="accounts"] .ghost-btn.account-edit-btn:focus-visible {
  border: 0;
  outline: 0;
  box-shadow: none;
}

body.ui-v2 section[data-stage="accounts"] .ghost-btn.account-edit-btn:hover {
  background: rgba(50, 98, 184, 0.07);
}

body.ui-v2 section[data-stage="cloud-video"] .cloud-video-reason-filter-trigger,
body.ui-v2 section[data-stage="cloud-video"] .cloud-video-reason-filter-trigger:focus,
body.ui-v2 section[data-stage="cloud-video"] .cloud-video-reason-filter-trigger:focus-visible {
  min-height: 24px;
  padding: 2px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  outline: 0;
}

body.ui-v2 section[data-stage="cloud-video"] .cloud-video-reason-filter-trigger:hover,
body.ui-v2 section[data-stage="cloud-video"] .cloud-video-reason-filter-trigger[aria-expanded="true"] {
  color: var(--v2-brand-strong);
  background: transparent;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-stop-btn[hidden] {
  display: none;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thinking {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #708098;
  font-size: 12px;
  line-height: 1.6;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thinking-star {
  display: inline-grid;
  width: 18px;
  height: 18px;
  place-items: center;
  color: #6d8ed1;
  font-size: 21px;
  line-height: 1;
  animation: aiChatThinkingStar 1.15s ease-in-out infinite;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-stream-text {
  margin-top: 8px;
  color: var(--v2-ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.75;
}

@keyframes aiChatThinkingStar {
  0%, 100% { opacity: .48; transform: rotate(0deg) scale(.88); }
  50% { opacity: 1; transform: rotate(16deg) scale(1.08); }
}

body.ui-v2 .digital-human-card {
  padding: 16px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

body.ui-v2 .digital-human-audio-strip {
  border-color: var(--v2-line);
  background: var(--v2-surface-muted);
}

body.ui-v2 .digital-human-audio-current > span {
  color: var(--v2-muted);
}

body.ui-v2 :is(#digitalHumanChooseAudioBtn, #digitalHumanChooseAvatarBtn) {
  border-color: var(--v2-line-strong);
  color: var(--v2-brand-strong);
  box-shadow: none;
}

@media (min-width: 861px) {
  body.ui-v2 section[data-stage="digital-human"] .digital-human-workflow {
    grid-template-columns: minmax(160px, 0.8fr) minmax(240px, 1.45fr) minmax(190px, 0.95fr);
    gap: 12px;
    margin: 0;
  }

  body.ui-v2 .digital-human-card + .digital-human-card {
    border-left: 1px solid var(--v2-line);
  }

  body.ui-v2 .digital-human-result-column {
    grid-column: auto;
  }
}

@media (min-width: 861px) and (max-width: 1100px) {
  body.ui-v2 .digital-human-audio-strip {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  body.ui-v2 .digital-human-audio-current strong {
    white-space: normal;
  }

  body.ui-v2 .digital-human-result-column .digital-human-card-head {
    flex-wrap: wrap;
    gap: 6px;
  }
}

body.ui-v2 .workspace-rail,
body.ui-v2 .stage,
body.ui-v2 .ai-chat-log,
body.ui-v2 .account-table-wrap,
body.ui-v2 .cloud-video-table-wrap {
  scrollbar-width: thin;
  scrollbar-color: #c8d1dc transparent;
}

@media (max-width: 1180px) {
  body.ui-v2 .workspace-layout {
    grid-template-columns: 196px minmax(0, 1fr);
  }

  body.ui-v2 .stage.active {
    padding: 18px;
  }

  body.ui-v2 .mobile-workspace-nav {
    padding-inline: 18px;
  }

  body.ui-v2 section[data-stage="chanmama"] #chanmamaDataList,
  body.ui-v2 section[data-stage="chanmama"] #miaosiDataList {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
  }
}

@media (max-width: 1020px) and (min-width: 861px) {
  body.ui-v2 section[data-stage="chanmama"] #chanmamaDataList,
  body.ui-v2 section[data-stage="chanmama"] #miaosiDataList {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  body.ui-v2 .app-shell {
    grid-template-rows: 60px minmax(0, 1fr) auto;
  }

  body.ui-v2 .hero {
    height: 60px;
    padding: 0 16px;
  }

  body.ui-v2 .brand-logo {
    height: 32px;
  }

  body.ui-v2 .header-stats {
    display: none;
  }

  body.ui-v2 .workspace-layout {
    grid-template-columns: 1fr;
  }

  body.ui-v2 .workspace-rail {
    display: none;
  }

  body.ui-v2 .workspace-content > main {
    overflow: hidden;
  }

  body.ui-v2 .mobile-workspace-nav {
    min-height: 52px;
    padding: 0 12px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  body.ui-v2 .mobile-workspace-nav::-webkit-scrollbar {
    display: none;
  }

  body.ui-v2 .mobile-workspace-nav > div {
    flex: 0 0 auto;
  }

  body.ui-v2 .stage.active {
    padding: 14px 12px calc(88px + env(safe-area-inset-bottom));
  }

  body.ui-v2 .stage-grid,
  body.ui-v2 .source-grid,
  body.ui-v2 .chat-grid,
  body.ui-v2 .knowledge-grid,
  body.ui-v2 .rewrite-grid,
  body.ui-v2 .review-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  body.ui-v2 .stage-grid .panel,
  body.ui-v2 .ai-chat-workspace {
    min-height: auto;
    max-height: none;
  }

  body.ui-v2 .ai-chat-workspace {
    height: calc(100dvh - 60px - 52px - 88px);
    min-height: 480px;
  }

  body.ui-v2 section[data-stage="ai-chat"].active {
    padding: 10px 10px calc(72px + env(safe-area-inset-bottom));
    overflow: hidden;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-workspace {
    height: 100%;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main {
    height: 100%;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  body.ui-v2 section[data-stage="ai-chat"] #aiChatTitleHost {
    display: none;
  }

  body.ui-v2 section[data-stage="ai-chat"] #aiChatMobileThreadSelect {
    display: block !important;
    width: 100%;
    min-width: 0;
    max-width: 220px;
    height: 34px;
    padding: 0 8px;
    font-size: 13px;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main-head > div:first-child {
    flex: 1;
    min-width: 0;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-composer {
    padding: 8px 10px 10px;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-composer-inner {
    width: 100%;
    padding-inline: 8px;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-composer textarea {
    max-height: min(180px, 28dvh);
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-composer-actions {
    flex-wrap: wrap;
  }

  body.ui-v2 .ai-chat-sidebar {
    display: none;
  }

  body.ui-v2 .ai-chat-main {
    min-width: 0;
  }

  body.ui-v2 .mobile-bottom-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 700;
    min-height: calc(64px + env(safe-area-inset-bottom));
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border-top: 1px solid var(--v2-line);
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 -8px 24px rgba(20, 30, 44, 0.08);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  body.ui-v2 .mobile-bottom-nav button {
    min-height: 48px;
    border: 0;
    border-radius: 9px;
    color: var(--v2-muted);
    background: transparent;
    font-size: 12px;
    font-weight: 750;
  }

  body.ui-v2 .mobile-bottom-nav button.active {
    color: var(--v2-brand-strong);
    background: var(--v2-brand-soft);
  }

  body.ui-v2 .mobile-bottom-nav button.active::after {
    background: var(--v2-brand);
  }

  body.ui-v2 section[data-stage="chanmama"] .chanmama-collector-panel {
    padding: 10px;
  }

  body.ui-v2 section[data-stage="chanmama"] .chanmama-search-action {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  body.ui-v2 section[data-stage="chanmama"] #chanmamaDataList,
  body.ui-v2 section[data-stage="chanmama"] #miaosiDataList {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
}

@media (max-width: 520px) {
  body.ui-v2 .hero {
    padding-inline: 12px;
  }

  body.ui-v2 .header-feedback-btn {
    width: 32px;
    min-width: 32px;
    padding: 0;
    overflow: hidden;
    font-size: 0;
  }

  body.ui-v2 .header-feedback-btn::before {
    content: "?";
    font-size: 13px;
    font-weight: 850;
  }

  body.ui-v2 .stage.active {
    padding-inline: 10px;
  }

  body.ui-v2 .panel,
  body.ui-v2 .chanmama-collector-panel,
  body.ui-v2 .ai-chat-workspace {
    border-radius: 11px;
  }

  body.ui-v2 section[data-stage="chanmama"] #chanmamaDataList,
  body.ui-v2 section[data-stage="chanmama"] #miaosiDataList {
    gap: 8px;
  }

  body.ui-v2 section[data-stage="chanmama"] .chanmama-card-body {
    padding: 9px;
  }

  body.ui-v2 section[data-stage="chanmama"] .chanmama-card-body h3 {
    min-height: 38px;
    font-size: 12px;
  }

  body.ui-v2 section[data-stage="chanmama"] .chanmama-card-save {
    min-height: 34px;
    padding-inline: 6px;
    font-size: 12px;
  }

  body.ui-v2 .ai-chat-workspace {
    height: calc(100dvh - 60px - 52px - 88px);
    min-height: 440px;
  }
}

/* Preserve native [hidden] semantics after the v2 flex/grid layouts. */
body.ui-v2 #stepNav > button[hidden],
body.ui-v2 #stepNav > .grouped-nav-item[hidden],
body.ui-v2 .mobile-workspace-nav > div[hidden],
body.ui-v2 .mobile-workspace-nav button[hidden] {
  display: none !important;
}

@media (max-width: 860px) {
  body.ui-v2 .mobile-bottom-nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

/* Menu items retain native hidden behavior under the higher-specificity rail rules. */
body.ui-v2 #stepNav .grouped-nav-menu[hidden] {
  display: none !important;
}

body.ui-v2 #stepNav .grouped-nav-menu button[hidden] {
  display: none !important;
}

/* Rewrite is a single workspace with a wide editor/result canvas. */
body.ui-v2 section[data-stage="rewrite"] .rewrite-grid {
  grid-template-columns: minmax(0, 1fr);
}

body.ui-v2 section[data-stage="rewrite"] .rewrite-panel {
  min-width: 0;
  min-height: 100%;
}

body.ui-v2 section[data-stage="rewrite"] .rewrite-framework-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  max-height: 340px;
}

/* Material ingestion is a single wide workflow; the queue follows the form. */
body.ui-v2 section[data-stage="source"] .source-grid {
  grid-template-columns: minmax(0, 1fr);
}

@media (max-width: 860px) {
  body.ui-v2 section[data-stage="rewrite"] .rewrite-framework-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 440px;
  }
}

@media (max-width: 520px) {
  body.ui-v2 section[data-stage="rewrite"] .rewrite-framework-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Authentication and content dialogs inherit the same quiet surface language. */
body.ui-v2 .auth-overlay {
  background: rgba(245, 247, 250, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

body.ui-v2 .auth-modal {
  border-color: var(--v2-line);
  border-radius: 14px;
  background: var(--v2-surface);
  box-shadow: 0 24px 80px rgba(20, 30, 44, 0.14);
}

body.ui-v2 .auth-heading h2,
body.ui-v2 .auth-modal h2,
body.ui-v2 .auth-modal h3 {
  color: var(--v2-ink);
}

@media (max-width: 520px) {
  body.ui-v2 .auth-overlay {
    padding: 12px;
  }

  body.ui-v2 .auth-modal {
    padding: 20px;
  }
}

@media (max-width: 860px) {
  body.ui-v2 section[data-stage="accounts"] .account-summary {
    grid-template-columns: minmax(0, 1fr);
    overflow: visible;
  }

  body.ui-v2 section[data-stage="accounts"] .account-summary-scroll {
    width: 100%;
    min-width: 0;
    padding-bottom: 2px;
  }

  body.ui-v2 section[data-stage="accounts"] .account-summary-reminder {
    width: 100%;
    justify-content: flex-start;
    margin-left: 0;
  }
}

@media (max-width: 860px) {
  body.ui-v2 section[data-stage="accounts"] #accountSummary {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    overflow: visible;
  }

  body.ui-v2 section[data-stage="accounts"] #accountSummary .account-summary-scroll {
    flex: 0 0 auto;
    width: 100%;
    min-height: 32px;
    padding-bottom: 2px;
  }

  body.ui-v2 section[data-stage="accounts"] #accountSummary .account-summary-reminder {
    flex: 0 0 auto;
    width: 100%;
    min-height: 40px;
    justify-content: center;
    margin-left: 0;
  }
}

body.ui-v2 .account-summary-reminder svg {
  width: 18px !important;
  height: 18px !important;
  flex: 0 0 18px !important;
}

/* Desktop workspaces: keep the frame stable and move long content into the
   relevant pane so the header, controls, and action area stay available. */
@media (min-width: 861px) {
  body.ui-v2 section[data-stage="ai-chat"] .stage-grid,
  body.ui-v2 section[data-stage="elements"] .stage-grid,
  body.ui-v2 section[data-stage="seedance"] .stage-grid,
  body.ui-v2 section[data-stage="knowledge"] .stage-grid,
  body.ui-v2 section[data-stage="auto-edit"] .stage-grid {
    height: 100%;
    min-height: 0;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-workspace,
  body.ui-v2 section[data-stage="elements"] .ai-chat-workspace,
  body.ui-v2 section[data-stage="seedance"] .ai-chat-workspace {
    height: 100%;
    min-height: 0;
    grid-template-columns: 248px minmax(0, 1fr);
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-workspace.sidebar-collapsed,
  body.ui-v2 section[data-stage="elements"] .ai-chat-workspace.sidebar-collapsed,
  body.ui-v2 section[data-stage="seedance"] .ai-chat-workspace.sidebar-collapsed {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  body.ui-v2 .ai-chat-workspace.sidebar-collapsed .ai-chat-sidebar {
    padding: 12px 8px;
  }

  body.ui-v2 .ai-chat-sidebar {
    padding: 16px;
    background: #f8fafc;
  }

  body.ui-v2 .ai-chat-sidebar-head {
    min-height: 34px;
  }

  body.ui-v2 .ai-chat-main {
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr) auto;
    background: var(--v2-surface);
  }

  body.ui-v2 .ai-chat-main-head {
    min-height: 64px;
    padding: 0 18px;
  }

  body.ui-v2 .ai-chat-log {
    min-height: 0;
    padding: 20px 24px;
    overflow-y: auto;
  }

  body.ui-v2 .ai-chat-composer {
    min-height: 0;
    margin: 0;
    padding: 14px 18px 18px;
    background: #f8fafc;
  }

  body.ui-v2 .ai-chat-composer-inner,
  body.ui-v2 .analysis-chat-composer,
  body.ui-v2 .seedance-composer {
    max-width: none;
  }

  body.ui-v2 section[data-stage="elements"] .ai-analysis-main-head {
    align-items: flex-start;
    min-height: 72px;
    padding-top: 14px;
    padding-bottom: 14px;
  }

  body.ui-v2 section[data-stage="elements"] .ai-analysis-scope-panel {
    max-width: 62%;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  body.ui-v2 section[data-stage="elements"] .ai-analysis-main-head .scope-unified-card {
    width: min(420px, 100%);
  }

  body.ui-v2 section[data-stage="knowledge"] .knowledge-elements-panel {
    padding: 16px 18px;
    overflow: hidden;
  }

  body.ui-v2 section[data-stage="knowledge"] .knowledge-searchbar {
    margin-bottom: 12px;
  }

  body.ui-v2 section[data-stage="knowledge"] .knowledge-searchbar input,
  body.ui-v2 section[data-stage="knowledge"] .knowledge-searchbar span {
    min-height: 40px;
  }

  body.ui-v2 section[data-stage="knowledge"] .knowledge-workbench {
    min-height: 0;
    overflow: hidden;
  }

  body.ui-v2 section[data-stage="knowledge"] #materialTree {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    overflow-y: auto;
  }

  body.ui-v2 section[data-stage="knowledge"] .hit-empty-state {
    padding: 16px;
    border-color: var(--v2-line);
    border-radius: 12px;
    background: var(--v2-surface);
  }

  body.ui-v2 section[data-stage="knowledge"] .hit-stat-grid {
    gap: 8px;
  }

  body.ui-v2 section[data-stage="knowledge"] .hit-stat-grid span {
    min-height: 44px;
    justify-content: space-between;
    padding-inline: 12px;
    background: var(--v2-surface-muted);
  }

  body.ui-v2 section[data-stage="knowledge"] .source-target-section,
  body.ui-v2 section[data-stage="knowledge"] .knowledge-element-directory {
    margin-top: 8px;
    border: 1px solid var(--v2-line);
    border-radius: 11px;
    background: var(--v2-surface);
    overflow: hidden;
  }

  body.ui-v2 section[data-stage="knowledge"] .source-target-section > summary,
  body.ui-v2 section[data-stage="knowledge"] .knowledge-element-directory > summary {
    min-height: 46px;
    padding-inline: 14px;
    background: var(--v2-surface);
  }

  body.ui-v2 section[data-stage="knowledge"] .source-target-section-items,
  body.ui-v2 section[data-stage="knowledge"] .knowledge-element-directory-body {
    border-top-color: var(--v2-line);
    background: var(--v2-surface-muted);
  }

  body.ui-v2 section[data-stage="auto-edit"] .auto-edit-panel {
    height: 100%;
    min-height: 0;
    padding: 18px;
    overflow: hidden;
  }

  body.ui-v2 section[data-stage="auto-edit"] .auto-edit-workspace {
    height: 100%;
    min-height: 0;
    grid-template-columns: minmax(300px, 0.9fr) minmax(0, 1.8fr);
    gap: 18px;
    margin-top: 0;
  }

  body.ui-v2 section[data-stage="auto-edit"] .auto-edit-preview-column,
  body.ui-v2 section[data-stage="auto-edit"] .auto-edit-editor-column {
    min-height: 0;
    height: 100%;
    border-color: var(--v2-line);
    border-radius: 12px;
    background: var(--v2-surface);
  }

  body.ui-v2 section[data-stage="auto-edit"] .auto-edit-preview-column {
    padding: 14px;
  }

  body.ui-v2 section[data-stage="auto-edit"] .auto-edit-preview-stage {
    min-height: 0;
    border-radius: 9px;
    background: #eef1f4;
  }

  body.ui-v2 section[data-stage="auto-edit"] .auto-edit-preview-stage.is-empty {
    border-color: var(--v2-line-strong);
    background: #fbfcfd;
  }

  body.ui-v2 section[data-stage="auto-edit"] .auto-edit-preview-empty strong {
    color: var(--v2-ink);
    font-size: 18px;
  }

  body.ui-v2 section[data-stage="auto-edit"] .auto-edit-editor-column {
    padding: 0 16px 16px;
    overflow: hidden;
  }

  body.ui-v2 section[data-stage="auto-edit"] .auto-edit-tabs {
    flex: 0 0 auto;
  }

  body.ui-v2 section[data-stage="auto-edit"] .auto-edit-tabs button {
    min-height: 54px;
    color: var(--v2-muted);
    font-size: 15px;
  }

  body.ui-v2 section[data-stage="auto-edit"] .auto-edit-tab-panel {
    min-height: 0;
    overflow-y: auto;
  }

  body.ui-v2 section[data-stage="auto-edit"] .auto-edit-template-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
  }

  body.ui-v2 section[data-stage="auto-edit"] .auto-edit-footer {
    flex: 0 0 auto;
    padding-top: 12px;
    border-top-color: var(--v2-line);
  }
}

/* Agent 2.0 polish — 2026-09-20 */
body.ui-v2 #stepNav .workspace-nav-icon {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  color: color-mix(in srgb, currentColor 82%, var(--v2-muted));
}

body.ui-v2 #stepNav > button.active .workspace-nav-icon,
body.ui-v2 #stepNav .grouped-nav-main.active .workspace-nav-icon {
  color: var(--v2-brand-strong);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-workspace {
  border: 0;
  border-radius: 0;
  background: var(--v2-canvas-gradient);
  box-shadow: none;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-sidebar {
  border-right: 1px solid rgba(202, 211, 222, 0.64);
  background: linear-gradient(170deg, rgba(255, 255, 255, 0.62), rgba(243, 247, 255, 0.4));
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-sidebar-head,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main-head {
  border-bottom: 0;
  background: transparent;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-plaza-row,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-new-thread-row,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-memory-btn,
body.ui-v2 section[data-stage="ai-chat"] .ai-sidebar-collapse-button {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-plaza-row:hover,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-new-thread-row:hover,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-memory-btn:hover,
body.ui-v2 section[data-stage="ai-chat"] .ai-sidebar-collapse-button:hover {
  border-color: transparent;
  background: rgba(65, 100, 155, 0.075);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-log,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main {
  background: transparent;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-composer {
  padding: 10px 22px 18px;
  background: transparent;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-composer-inner {
  min-height: 112px;
  padding: 7px 12px 9px;
  border: 0;
  border-radius: 15px;
  background: linear-gradient(125deg, #ffffff 35%, #f6f8ff 76%, #f0f8f7);
  box-shadow: 0 12px 32px rgba(49, 78, 129, 0.1), 0 0 0 1px rgba(135, 158, 203, 0.24), inset 0 1px 0 #fff;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-composer-inner:focus-within {
  border-color: transparent;
  box-shadow: 0 14px 34px rgba(49, 78, 129, 0.12), 0 0 0 2px rgba(69, 105, 187, 0.32), inset 0 1px 0 #fff;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-composer-actions {
  min-height: 32px;
  padding-top: 3px;
  border-top: 0;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-skill-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  color: #7b8796;
  background: transparent;
  box-shadow: none;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-skill-btn:hover,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-skill-btn:focus-visible {
  color: var(--v2-brand-strong);
  background: rgba(50, 98, 184, 0.08);
  outline: none;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-model-picker-button {
  width: auto;
  min-width: 72px;
  max-width: 180px;
  height: 28px;
  padding: 0 24px 0 8px;
  border: 0;
  border-radius: 7px;
  color: #596678;
  background: transparent;
  box-shadow: none;
  text-align: right;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-model-picker-button:hover,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-model-picker-button:focus-visible {
  color: var(--v2-brand-strong);
  border-color: transparent;
  background: rgba(50, 98, 184, 0.07);
  outline: none;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-model-picker-button:disabled {
  border: 0;
  background: transparent;
  opacity: 0.56;
}

body.ui-v2 section[data-stage="ai-chat"] #aiChatSendBtn {
  display: none;
}

/* 空闲时隐藏发送按钮，生成中仍由停止按钮占据这个位置。 */
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-composer-right:has(#aiChatStopBtn:not([hidden])) #aiChatSendBtn {
  display: none;
}

body.ui-v2 section[data-stage="ai-chat"] #aiChatStopBtn {
  display: none;
}

body.ui-v2 section[data-stage="ai-chat"] #aiChatStopBtn:not([hidden]) {
  display: inline-grid;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-welcome {
  max-width: 620px;
  padding: 18px 24px;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-welcome strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  color: #172033;
  font-size: clamp(24px, 2.25vw, 34px);
  font-weight: 680;
  letter-spacing: -0.035em;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-welcome strong svg {
  width: 25px;
  height: 25px;
  color: var(--v2-brand);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-welcome p {
  margin-top: 10px;
  color: #7a8594;
  font-size: 14px;
}

body.ui-v2 .skills-toolbar .skills-new-button {
  display: inline-grid;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 8px;
  color: var(--v2-muted);
  background: transparent;
  cursor: pointer;
}

body.ui-v2 .skills-toolbar .skills-new-button:hover,
body.ui-v2 .skills-toolbar .skills-new-button:focus-visible {
  color: var(--v2-brand-strong);
  background: rgba(50, 98, 184, 0.08);
  outline: none;
}

body.ui-v2 .skills-toolbar .skills-new-button svg {
  width: 18px;
  height: 18px;
}

body.ui-v2 .skills-toolbar .skills-new-button:disabled {
  opacity: 0.4;
  cursor: wait;
}

@media (min-width: 861px) {
  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main.is-landing .ai-chat-log {
    align-content: end;
    padding-bottom: 10px;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main.is-landing .ai-chat-composer {
    padding-inline: clamp(34px, 8vw, 130px);
    padding-bottom: clamp(190px, 38vh, 260px);
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main.is-landing .ai-chat-composer-inner {
    max-width: 720px;
  }
}

@media (max-width: 860px) {
  body.ui-v2 #stepNav .workspace-nav-icon {
    width: 16px;
    height: 16px;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-composer {
    padding: 8px 10px 12px;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-composer-inner {
    min-height: 104px;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-welcome strong {
    font-size: 23px;
  }
}

@media (min-width: 861px) and (min-height: 700px) {
  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main.is-landing {
    position: relative;
    display: block;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main.is-landing .ai-chat-main-head {
    position: relative;
    z-index: 2;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main.is-landing .ai-chat-log {
    position: absolute;
    top: 34%;
    right: 0;
    left: 0;
    height: auto;
    min-height: 0;
    padding: 0 24px;
    overflow: visible;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main.is-landing .ai-chat-composer {
    position: absolute;
    top: 49%;
    right: 0;
    left: 0;
    padding: 0 clamp(34px, 8vw, 130px);
  }
}

/* Keep header geometry stable while the empty new conversation has no title. */
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main.is-landing #aiChatTitle {
  visibility: hidden;
}

/* Agent uses a single writing surface, including when the textarea is focused. */
body.ui-v2 section[data-stage="ai-chat"] #aiChatInput,
body.ui-v2 section[data-stage="ai-chat"] #aiChatInput:focus,
body.ui-v2 section[data-stage="ai-chat"] #aiChatInput:focus-visible {
  border: 0;
  outline: none;
  box-shadow: none;
  background: transparent;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-model-picker-button {
  position: relative;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-model-picker-button::after {
  content: "";
  top: 50%;
  right: 10px;
  width: 6px;
  height: 6px;
  margin-top: -2px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-50%) rotate(45deg);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-memory-btn[hidden] {
  display: none;
}

/* Sidebar hierarchy: larger entry labels, quiet secondary text, crisp highlights. */
body.ui-v2 section[data-stage="ai-chat"] :is(.ai-chat-plaza-row, .ai-chat-new-thread-row) {
  min-height: 36px;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.5;
  color: #294467;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .8);
}

body.ui-v2 section[data-stage="ai-chat"] :is(.ai-chat-plaza-row, .ai-chat-new-thread-row) svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--v2-brand);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-button strong {
  font-size: 14px;
  line-height: 1.5;
  font-weight: 650;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-empty {
  color: #68758a;
  font-size: 13px;
  line-height: 1.6;
}

/* Agent conversation management */
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-sidebar-label-row {
  display: flex;
  min-height: 28px;
  align-items: center;
  justify-content: space-between;
  padding: 0 3px 0 2px;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-sidebar-label {
  padding: 0;
  color: #5d6b80;
  font-size: 13px;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-link,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-back,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-new {
  display: inline-grid;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  place-items: center;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-link:hover,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-link.active,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-back:hover,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-new:hover {
  color: var(--blue);
  background: rgba(32, 104, 226, 0.08);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-link svg,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-back svg,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-new svg {
  width: 16px;
  height: 16px;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-row {
  position: relative;
  grid-template-columns: minmax(0, 1fr) 30px;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-button {
  grid-template-columns: 18px minmax(0, 1fr) auto auto;
  gap: 7px;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-icon,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-icon {
  display: inline-grid;
  color: #667085;
  place-items: center;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-icon svg,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-icon svg {
  width: 16px;
  height: 16px;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-pin-icon {
  width: 13px;
  height: 13px;
  color: #7b8798;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-unread-dot {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2070e8;
  box-shadow: 0 0 0 2px rgba(32, 112, 232, 0.12);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-row.unread .ai-chat-thread-button strong,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-row.unread strong {
  font-weight: 800;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-actions {
  position: relative;
  display: grid;
  place-items: center;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-more {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  opacity: 0;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-more svg {
  width: 16px;
  height: 16px;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-row:hover .ai-chat-thread-more,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-row:hover .ai-chat-thread-more,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-more:focus-visible,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-more[aria-expanded="true"] {
  opacity: 1;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-more:hover,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-more[aria-expanded="true"] {
  color: var(--ink);
  background: rgba(107, 119, 140, 0.10);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-more:disabled {
  cursor: wait;
  opacity: 0.45;
}

@keyframes aiChatThreadMenuFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes aiChatThreadMenuFadeOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(2px) scale(0.985);
  }
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-menu {
  position: absolute;
  z-index: 40;
  top: calc(100% - 2px);
  right: 0;
  width: 144px;
  padding: 5px;
  border: 1px solid rgba(142, 155, 177, 0.20);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 10px 24px rgba(35, 48, 68, 0.13);
  transform-origin: top right;
  animation: aiChatThreadMenuFadeIn 140ms cubic-bezier(0.22, 1, 0.36, 1);
}

body.ui-v2 .ai-chat-thread-menu.is-portal {
  position: fixed;
  z-index: 1200;
  top: 0;
  right: auto;
  bottom: auto;
  width: 144px;
  padding: 5px;
  border: 1px solid rgba(142, 155, 177, 0.20);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.99);
  box-shadow: 0 12px 28px rgba(35, 48, 68, 0.15);
  transform-origin: top right;
  animation: aiChatThreadMenuFadeIn 140ms cubic-bezier(0.22, 1, 0.36, 1);
}

body.ui-v2 .ai-chat-thread-menu.is-closing {
  pointer-events: none;
  animation: aiChatThreadMenuFadeOut 140ms ease forwards;
}

body.ui-v2 .ai-chat-thread-menu.is-portal button {
  display: grid;
  width: 100%;
  min-height: 30px;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  padding: 5px 7px;
  border: 0;
  border-radius: 8px;
  color: #263142;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

body.ui-v2 .ai-chat-thread-menu.is-portal button:hover,
body.ui-v2 .ai-chat-thread-menu.is-portal button:focus-visible {
  background: #f1f4f8;
  outline: none;
}

body.ui-v2 .ai-chat-thread-menu.is-portal button.danger {
  color: #d92d20;
}

body.ui-v2 .ai-chat-thread-menu.is-portal button.danger:hover,
body.ui-v2 .ai-chat-thread-menu.is-portal button.danger:focus-visible {
  background: #fff1f0;
}

body.ui-v2 .ai-chat-thread-menu.is-portal button svg {
  width: 15px;
  height: 15px;
}

body.ui-v2 .ai-chat-thread-menu.is-portal .ai-chat-thread-menu-divider {
  height: 1px;
  margin: 4px -5px;
  background: rgba(142, 155, 177, 0.20);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-row:nth-last-child(-n+3) .ai-chat-thread-menu {
  top: auto;
  bottom: calc(100% - 2px);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-menu button {
  display: grid;
  width: 100%;
  min-height: 30px;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  padding: 5px 7px;
  border: 0;
  border-radius: 8px;
  color: #263142;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-menu button:hover,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-menu button:focus-visible {
  background: #f1f4f8;
  outline: none;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-menu button.danger {
  color: #d92d20;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-menu button.danger:hover,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-menu button.danger:focus-visible {
  background: #fff1f0;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-menu button svg {
  width: 15px;
  height: 15px;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-menu-divider {
  height: 1px;
  margin: 4px -5px;
  background: rgba(142, 155, 177, 0.20);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-panel[hidden] {
  display: none;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main.is-history {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main.is-history > .ai-chat-main-head,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main.is-history > .ai-chat-log,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main.is-history > .ai-chat-composer {
  display: none;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-panel {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 28px clamp(28px, 6vw, 90px);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.72);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-head {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding-bottom: 22px;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 760;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-search {
  display: grid;
  width: min(230px, 24vw);
  min-width: 150px;
  flex: 0 1 230px;
  height: 36px;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid rgba(142, 155, 177, 0.28);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.82);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-search:focus-within {
  border-color: rgba(32, 112, 232, 0.55);
  box-shadow: 0 0 0 3px rgba(32, 112, 232, 0.08);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-search svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  box-shadow: none;
}

body.ui-v2 section[data-stage="ai-chat"] #aiChatHistoryFilter {
  width: 104px;
  flex: 0 0 104px;
  height: 36px;
  padding: 0 28px 0 10px;
  border: 1px solid rgba(142, 155, 177, 0.28);
  border-radius: 7px;
  color: var(--ink);
  background-color: rgba(255, 255, 255, 0.82);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-new {
  color: #fff;
  background: #2769d8;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-new:hover {
  color: #fff;
  background: #1f5fc9;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-list {
  min-height: 0;
  overflow-y: auto;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  min-height: 52px;
  border-bottom: 1px solid rgba(142, 155, 177, 0.14);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-row:hover {
  background: rgba(243, 246, 250, 0.78);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-open {
  display: grid;
  min-width: 0;
  min-height: 52px;
  grid-template-columns: 22px minmax(0, 1fr) auto 74px;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border: 0;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-copy {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 9px;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-copy strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-copy small,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-open time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-open time {
  text-align: right;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-row .ai-chat-thread-title-input {
  margin: 8px;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-empty {
  display: grid;
  min-height: 220px;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 860px) {
  body.ui-v2 .skills-dialog,
  body.ui-v2 .skills-dialog.has-skill-preview {
    width: calc(100vw - 24px);
    height: min(680px, calc(100dvh - 32px));
    max-height: calc(100dvh - 32px);
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-model-picker-submenu {
    max-width: min(214px, calc(100vw - 32px));
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-web-source-list {
    grid-template-columns: 1fr;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-panel {
    padding: 16px 14px;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-head {
    grid-template-columns: 28px minmax(0, 1fr);
    padding-bottom: 14px;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-head h2 {
    font-size: 18px;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-tools {
    grid-column: 1 / -1;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-search {
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
  }

  body.ui-v2 section[data-stage="ai-chat"] #aiChatHistoryFilter {
    width: 96px;
    flex-basis: 96px;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-open {
    grid-template-columns: 20px minmax(0, 1fr) auto;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-copy small {
    display: none;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-history-open time {
    display: none;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-thread-more {
    opacity: 1;
  }
}


/* Agent conversation hierarchy and memory editor refinements. */
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message-auxiliary,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message-status,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-web-sources {
  color: #7a8799;
  font-size: 11px;
  line-height: 1.45;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message-auxiliary {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
  padding-left: 1px;
  font-size: 10px;
  font-weight: 500;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message-auxiliary span {
  color: #8793a4;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message-auxiliary i {
  color: #bcc6d3;
  font-style: normal;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message-status {
  margin: 0 0 2px;
  font-size: 11px;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-model-picker-submenu {
  left: calc(100% - 1px);
  border-left-color: rgba(213, 219, 225, .72);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

body.ui-v2 .memory-dialog-body {
  gap: 16px;
  padding: 16px 18px 18px;
}

body.ui-v2 .memory-switch {
  min-height: 30px;
  color: var(--v2-ink);
  font-size: 13px;
}

body.ui-v2 .memory-form {
  gap: 12px;
}

body.ui-v2 .memory-form textarea {
  min-height: 220px;
  padding: 12px 13px;
  border-color: var(--v2-line);
  border-radius: 8px;
  background: rgba(248, 250, 253, .72);
  line-height: 1.7;
  resize: vertical;
}

body.ui-v2 .memory-form textarea:focus {
  border-color: var(--v2-brand-line);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(50, 98, 184, .10);
  background: #fff;
}

body.ui-v2 .memory-form-row {
  width: 100%;
}

body.ui-v2 .memory-form-row .primary-btn {
  width: 100%;
  min-height: 36px;
}

body.ui-v2 .memory-dialog .memory-dialog-body {
  max-height: calc(100dvh - 92px);
}

@media (min-width: 861px) {
  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-model-picker-menu {
    transform: translateX(calc(-1 * var(--ai-chat-model-picker-shift, 0px)));
  }
}

/* Agent: errors are system status, not conversational content. */
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message.assistant.error > .ai-chat-message-content {
  width: fit-content;
  max-width: min(680px, 100%);
  margin: 4px 0 8px;
  padding: 1px 0 1px 9px;
  border: 0;
  border-left: 2px solid rgba(182, 105, 92, 0.55);
  border-radius: 0;
  background: transparent;
  color: #9a645d;
  font-size: 12px;
  line-height: 1.6;
}


/* Keep the conversation text and composer on the same readable column. */
@media (min-width: 761px) {
  body.ui-v2 section[data-stage="ai-chat"] {
    --ai-chat-content-width: min(980px, 85%);
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-log {
    padding-right: calc((100% - var(--ai-chat-content-width)) / 2);
    padding-left: calc((100% - var(--ai-chat-content-width)) / 2);
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message.assistant {
    width: 100%;
    max-width: none;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message.user {
    max-width: 100%;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-composer-inner {
    width: var(--ai-chat-content-width);
    max-width: none;
  }
}

@media (max-width: 760px) {
  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-composer-inner {
    width: calc(100% - 28px);
    max-width: none;
  }
}

/* Agent：加号只负责选择技能，名称列表保持轻量直接。 */
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-skill-popover {
  width: min(280px, calc(100vw - 32px));
  max-height: min(360px, 50vh);
  padding: 10px;
  gap: 8px;
  border: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 18px 44px rgba(31, 54, 87, .16), 0 2px 8px rgba(31, 54, 87, .06);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-skill-popover-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 1px 2px 2px;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-skill-popover-head strong {
  color: var(--v2-ink);
  font-size: 13px;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-skill-popover-head span {
  color: var(--v2-muted);
  font-size: 10px;
  white-space: nowrap;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-skill-popover input {
  height: 30px;
  border: 0;
  border-radius: 8px;
  color: var(--v2-ink);
  background: var(--v2-surface-muted);
  box-shadow: inset 0 0 0 1px rgba(74, 103, 143, .08);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-skill-popover input:focus {
  outline: 0;
  box-shadow: inset 0 0 0 1px rgba(50, 98, 184, .28), 0 0 0 3px rgba(50, 98, 184, .08);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-skill-popover-list {
  max-height: 250px;
  gap: 2px;
  padding: 1px;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-skill-popover-item {
  min-height: 42px;
  padding: 7px 8px 7px 10px;
  border-radius: 9px;
  color: var(--v2-ink);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-skill-popover-item:hover,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-skill-popover-item:focus-visible {
  background: rgba(50, 98, 184, .07);
  outline: 0;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-skill-popover-item.is-selected {
  color: var(--v2-brand-strong);
  background: rgba(50, 98, 184, .08);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-skill-popover-item-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
  text-align: left;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-skill-popover-item-copy strong {
  overflow: hidden;
  font-size: 12px;
  font-weight: 620;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-skill-popover-item-copy small {
  margin-left: 0;
  overflow: hidden;
  color: var(--v2-muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-skill-popover-check {
  width: 16px;
  flex: 0 0 16px;
  color: var(--v2-brand);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-skill-popover-manage {
  align-self: flex-start;
  padding: 3px 2px;
  border: 0;
  color: var(--v2-muted);
  background: transparent;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-skill-popover-manage:hover,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-skill-popover-manage:focus-visible {
  color: var(--v2-brand-strong);
  outline: 0;
}

/* 技能广场：详情态把阅读区和操作区分开，避免长提示词把按钮挤出视野。 */
body.ui-v2 .skills-dialog.has-skill-preview {
  width: min(900px, calc(100vw - 32px));
  height: min(700px, calc(100dvh - 40px));
  max-height: calc(100dvh - 40px);
}

body.ui-v2 .skills-dialog.has-skill-preview .skills-body {
  grid-template-columns: minmax(300px, .9fr) minmax(360px, 1.1fr);
  grid-template-rows: minmax(0, 1fr);
}

body.ui-v2 .skills-dialog.has-skill-preview .skills-list-pane {
  padding: 18px 20px;
}

body.ui-v2 .skills-dialog.has-skill-preview .skills-grid {
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
}

body.ui-v2 .skills-dialog.has-skill-preview .skill-card {
  min-height: 96px;
  padding: 11px;
  border-color: transparent;
  background: rgba(244, 247, 251, .76);
  box-shadow: inset 0 0 0 1px rgba(84, 111, 148, .08);
}

body.ui-v2 .skills-dialog.has-skill-preview .skill-card:hover {
  border-color: transparent;
  background: rgba(235, 242, 252, .96);
  box-shadow: inset 0 0 0 1px rgba(50, 98, 184, .18);
}

body.ui-v2 .skills-dialog.has-skill-preview .skill-card.is-active {
  border-color: transparent;
  background: linear-gradient(135deg, rgba(235, 243, 255, .98), rgba(240, 249, 248, .96));
  box-shadow: inset 0 0 0 1.5px rgba(50, 98, 184, .72), 0 5px 14px rgba(50, 98, 184, .08);
}

body.ui-v2 .skills-dialog.has-skill-preview .skills-preview {
  min-width: 0;
  min-height: 0;
  padding: 18px 20px 14px;
  gap: 9px;
  border-left-color: rgba(84, 111, 148, .12);
  background: linear-gradient(155deg, rgba(247, 250, 254, .98), rgba(242, 247, 250, .96));
  overflow: hidden;
}

body.ui-v2 .skills-dialog.has-skill-preview .skills-preview-prompt {
  min-height: 0;
  max-height: none;
  flex: 1 1 auto;
  overflow: auto;
  padding: 12px 14px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, .72);
  box-shadow: inset 0 0 0 1px rgba(84, 111, 148, .09);
  font-size: 11px;
  line-height: 1.72;
  overscroll-behavior: contain;
}

body.ui-v2 .skills-dialog.has-skill-preview .skills-preview-actions {
  position: static;
  z-index: 1;
  flex: 0 0 auto;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(84, 111, 148, .14);
  background: transparent;
}

body.ui-v2 .skills-dialog.has-skill-preview .skills-editor {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
}

body.ui-v2 .skills-dialog.has-skill-preview .skills-editor .skills-preview-actions {
  position: sticky;
  bottom: 0;
  margin-top: 0;
  padding-bottom: 2px;
  background: linear-gradient(180deg, rgba(242, 247, 250, 0), rgba(242, 247, 250, .98) 24%);
}

body.ui-v2 .skills-dialog.has-skill-preview .skills-preview-actions .primary-btn,
body.ui-v2 .skills-dialog.has-skill-preview .skills-preview-actions .ghost-btn {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  box-shadow: none;
}

body.ui-v2 .skills-dialog.has-skill-preview .skills-preview-actions .primary-btn {
  color: #fff;
  background: var(--v2-accent-gradient);
}

body.ui-v2 .skills-dialog.has-skill-preview .skills-preview-actions .ghost-btn {
  color: var(--v2-ink);
  background: rgba(255, 255, 255, .78);
  box-shadow: inset 0 0 0 1px rgba(84, 111, 148, .12);
}

body.ui-v2 .skills-dialog.has-skill-preview .skills-preview-actions .ghost-btn:hover,
body.ui-v2 .skills-dialog.has-skill-preview .skills-preview-actions .ghost-btn:focus-visible {
  color: var(--v2-brand-strong);
  background: rgba(235, 243, 255, .96);
  outline: none;
}

@media (max-width: 860px) {
  body.ui-v2 .skills-dialog.has-skill-preview {
    width: calc(100vw - 24px);
    height: min(680px, calc(100dvh - 32px));
    max-height: calc(100dvh - 32px);
  }

  body.ui-v2 .skills-dialog.has-skill-preview .skills-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(190px, .72fr) minmax(280px, 1.28fr);
  }

  body.ui-v2 .skills-dialog.has-skill-preview .skills-preview {
    border-top: 1px solid rgba(84, 111, 148, .12);
    border-left: 0;
  }
}

/* Keep reply actions in the message footer instead of floating beside the text. */
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 14px;
  height: 0;
  min-height: 0;
  margin-top: 0;
  padding: 0;
  overflow: hidden;
  color: #8793a4;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-2px);
  transition: height 140ms ease, margin-top 140ms ease, opacity 140ms ease, transform 140ms ease;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message:hover .ai-chat-message-actions,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message:focus-within .ai-chat-message-actions {
  height: 28px;
  margin-top: 3px;
  overflow: visible;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message-action {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0;
  border: 0;
  color: #7a8799;
  background: transparent;
  font: inherit;
  font-size: 11px;
  line-height: 1.4;
  cursor: pointer;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message-action:hover,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message-action:focus-visible {
  color: #3e608f;
  outline: none;
  text-decoration: underline;
  text-underline-offset: 3px;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message-time {
  color: #a0aaba;
  font-size: 11px;
  line-height: 1.4;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message.assistant.error .ai-chat-message-actions {
  margin-top: 4px;
}

/* 用户气泡按内容宽度收窄，操作条单独靠右，避免短消息被撑宽。 */
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message.user > .ai-chat-message-content {
  justify-self: end;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message.user .ai-chat-message-actions {
  justify-content: flex-end;
}

@media (max-width: 760px) {
  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message-actions {
    gap: 3px 11px;
  }
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message-actions {
  gap: 6px;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message-action {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 7px;
  font-size: 0;
  text-decoration: none;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message-action svg {
  width: 16px;
  height: 16px;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message-action:hover,
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message-action:focus-visible {
  color: #344b68;
  background: rgba(69, 99, 139, .08);
  text-decoration: none;
  outline: none;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message-action:is(:hover, :focus-visible)::after {
  content: attr(data-tooltip);
  position: absolute;
  z-index: 4;
  top: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  padding: 4px 9px;
  border-radius: 7px;
  color: #fff;
  background: #b9523d;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  pointer-events: none;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message-time {
  margin-left: 5px;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-pasted-text:not([hidden]) {
  display: flex;
  position: relative;
  width: 176px;
  min-height: 108px;
  margin: 8px 0 0;
  border: 1px solid rgba(70, 91, 118, .17);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 2px 5px rgba(23, 40, 68, .08);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-pasted-preview {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px 28px 9px 10px;
  border: 0;
  background: transparent;
  color: #334255;
  text-align: left;
  cursor: pointer;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-pasted-excerpt {
  display: -webkit-box;
  max-height: 59px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow-wrap: anywhere;
  font-size: 11px;
  line-height: 1.35;
  white-space: pre-line;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-pasted-preview small {
  align-self: flex-start;
  padding: 2px 5px;
  border: 1px solid rgba(70, 91, 118, .18);
  border-radius: 4px;
  color: #718092;
  font-size: 10px;
  line-height: 1.2;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-pasted-remove {
  position: absolute;
  right: 6px;
  bottom: 5px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #596778;
  cursor: pointer;
}

/* Agent stream feedback: keep transient generation state separate from the final answer. */
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-stream-box {
  width: min(680px, 100%);
  margin-top: 1px;
  padding: 2px 0 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--v2-muted);
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-stream-status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 20px;
  color: #9aa8be;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-stream-status .ai-chat-thinking-star {
  width: 18px;
  height: 18px;
  color: #c4d4f2;
  font-size: 17px;
  animation: aiChatThinkingStar 1.15s ease-in-out infinite;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-stream-text {
  margin-top: 8px;
  color: var(--v2-ink);
  font-size: 14px;
  line-height: 1.58;
  white-space: pre-wrap;
}

/* 已经收到的回答直接以正式文字流式呈现；只有“思考中”状态保持弱化。 */
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message.pending {
  opacity: 1;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-log {
  overscroll-behavior-y: contain;
  scroll-behavior: auto;
  -webkit-overflow-scrolling: touch;
}

/* 全局样式把 p 的 margin 清零了，成稿中的段落因此会黏成一整块。 */
body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message-content p + p {
  margin-top: 0.9em;
}

body.ui-v2 section[data-stage="ai-chat"] .ai-chat-message.assistant > .ai-chat-message-content strong {
  color: var(--v2-ink);
  font-weight: 760;
}

/* 新会话也必须遵循主区域的正常文档流。此前桌面端把消息区和输入区
   分别绝对定位在 34%/49%，长消息会直接覆盖输入框。 */
@media (min-width: 861px) and (min-height: 700px) {
  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main.is-landing {
    position: relative;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main.is-landing .ai-chat-log,
  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main.is-landing .ai-chat-composer {
    position: static;
    top: auto;
    right: auto;
    bottom: auto;
    left: auto;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main.is-landing .ai-chat-log {
    height: auto;
    min-height: 0;
    overflow-y: auto;
    align-content: start;
    padding: 20px max(28px, calc((100% - var(--ai-chat-content-width, 980px)) / 2));
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main.is-landing .ai-chat-log.is-empty {
    align-content: center;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main.is-landing .ai-chat-composer {
    padding: 14px clamp(34px, 8vw, 130px) 18px;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main.is-landing .ai-chat-composer-inner {
    width: min(720px, 100%);
    max-width: none;
  }
}

/* 空白新会话恢复历史版的上方锚点；出现消息后继续走正常文档流，避免回复与输入框重叠。 */
@media (min-width: 861px) and (min-height: 700px) {
  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main.is-landing:has(> .ai-chat-log.is-empty) {
    display: block;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main.is-landing:has(> .ai-chat-log.is-empty) > .ai-chat-log {
    position: absolute;
    top: 31%;
    right: 0;
    left: 0;
    height: auto;
    min-height: 0;
    padding: 0 24px;
    overflow: visible;
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main.is-landing:has(> .ai-chat-log.is-empty) > .ai-chat-composer {
    position: absolute;
    top: 49%;
    right: 0;
    left: 0;
    margin: 0;
    padding: 0 clamp(34px, 8vw, 130px);
  }

  body.ui-v2 section[data-stage="ai-chat"] .ai-chat-main.is-landing:has(> .ai-chat-log.is-empty) > .ai-chat-composer .ai-chat-composer-inner {
    max-width: 720px;
  }
}
