/* ============================================================
   YouYang Image Studio — 设计令牌
   逆向自 DCAI 生成页的 CSS 变量与计算样式
   ============================================================ */
:root {
  /* 品牌 */
  --brand-50: #f0f8f6;
  --brand-100: #ddefea;
  --brand-600: #0e7c66;
  --brand-700: #096653;
  --brand-800: #074c3f;

  /* 文字 */
  --ink-950: #101217;
  --ink-800: #292d35;
  --ink-600: #5e6572;
  --ink-500: #7a8290;
  --ink-400: #9aa1ad;

  /* 线条 */
  --line-300: #cdd2db;
  --line-200: #e2e5ea;
  --line-100: #eceef2;

  /* 底色 */
  --canvas-100: #f4f6f8;
  --canvas-50: #fafbfc;
  --white: #ffffff;
  --media-950: #0d0f13;

  /* 语义 */
  --background: #fafbfc;
  --foreground: #101217;
  --muted: #f4f6f8;
  --muted-foreground: #5e6572;
  --border: #e2e5ea;
  --primary: #0e7c66;
  --primary-foreground: #fff;

  /* 阴影 */
  --shadow-control: 0 1px 2px #1218280d;
  --shadow-card: 0 6px 18px #121e1c0f;
  --shadow-float: 0 16px 40px #121e1c1f, 0 3px 10px #121e1c0f;

  /* 布局 */
  --container-content: 1280px;
  --container-workbench: 1440px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--canvas-100);
  color: var(--ink-950);
  font-family: "Geist Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "HarmonyOS Sans SC", "Noto Sans SC", "Microsoft YaHei",
    sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ============================================================
   容器
   ============================================================ */
.container-page {
  width: 100%;
  max-width: var(--container-content);
  margin: 0 auto;
  padding: 0 1rem;
}

.container-workbench {
  width: 100%;
  max-width: var(--container-workbench);
  margin: 0 auto;
  padding-inline: 1rem;
}

@media (min-width: 1024px) {
  .container-page {
    padding: 0 2rem;
  }
  .container-workbench {
    padding-inline: 2rem;
  }
}

/* ============================================================
   顶部导航
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--line-100);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  height: 4rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-shrink: 0;
}

.brand__mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  background: var(--brand-600);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand__name {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav__link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-600);
  transition: background 0.16s, color 0.16s;
}

.nav__link:hover {
  background: var(--canvas-100);
  color: var(--ink-950);
}

.nav__link--strong {
  font-weight: 600;
  color: var(--ink-600);
}

.nav__link--strong:hover {
  background: var(--canvas-100);
  color: var(--ink-950);
}

.nav__hint {
  padding: 0.0625rem 0.375rem;
  border-radius: 999px;
  background: var(--brand-50);
  color: var(--brand-700);
  font-size: 0.6875rem;
  font-weight: 600;
}

.nav__chevron {
  width: 0.75rem;
  height: 0.75rem;
  opacity: 0.6;
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.link-quiet {
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-600);
  transition: background 0.16s, color 0.16s;
}

.link-quiet:hover {
  background: var(--canvas-100);
  color: var(--ink-950);
}

/* ============================================================
   主区
   ============================================================ */
.workbench-page {
  min-height: calc(100dvh - 65px);
  padding: 1rem 0;
}

@media (min-width: 1024px) {
  .workbench-page {
    padding: 1.5rem 0;
  }
}

.workbench {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  min-height: 780px;
}

@media (min-width: 1024px) {
  .workbench {
    grid-template-columns: 420px minmax(0, 1fr);
  }
}

/* ============================================================
   卡片
   ============================================================ */
.card {
  background: var(--white);
  border: 1px solid var(--line-200);
  border-radius: 0.75rem;
  overflow: hidden;
}

.card--panel {
  display: flex;
  flex-direction: column;
}

.card--preview {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 620px;
}

/* ============================================================
   左栏：模式切换
   ============================================================ */
.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line-200);
  background: var(--canvas-50);
  padding: 0.375rem;
}

.mode-tab {
  min-height: 2.25rem;
  border-radius: 0.4375rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-600);
  transition: background 0.16s, color 0.16s, box-shadow 0.16s;
}

.mode-tab:hover {
  color: var(--ink-950);
}

.mode-tab[data-active="true"] {
  background: var(--white);
  color: var(--brand-800);
  box-shadow: var(--shadow-control), inset 0 0 0 1px var(--brand-100);
}

/* ============================================================
   左栏：参数区
   ============================================================ */
.panel-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
@media (min-width: 1024px) {
  .panel-body {
    max-height: calc(100dvh - 110px);
    overflow-y: auto;
  }
}

.panel-body::-webkit-scrollbar {
  width: 8px;
}

.panel-body::-webkit-scrollbar-thumb {
  background: var(--line-300);
  border-radius: 999px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.field--divided {
  border-top: 1px solid var(--line-100);
  padding-top: 1rem;
}

.field__label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-800);
  letter-spacing: 0;
}

.field__label--lg {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-950);
}

.field__count {
  font-size: 0.75rem;
  font-weight: 400;
  color: #a1a1a1;
  font-variant-numeric: tabular-nums;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .field-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.field-grid--divided {
  border-top: 1px solid var(--line-100);
  padding-top: 1rem;
}

/* ============================================================
   分段控件
   ============================================================ */
.segmented-control {
  display: grid;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--line-200);
  border-radius: 0.625rem;
  background: var(--canvas-100);
}

.segmented-control--2 {
  grid-template-columns: 1fr 1fr;
}

.segmented-control--3 {
  grid-template-columns: repeat(3, 1fr);
}

.segmented-control--6 {
  grid-template-columns: repeat(6, 1fr);
}

.segmented-option {
  min-height: 2.5rem;
  border-radius: 0.4375rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-600);
  transition: background 0.16s, color 0.16s, box-shadow 0.16s;
}

.segmented-option:hover {
  color: var(--ink-950);
}

.segmented-option[data-active="true"] {
  background: var(--white);
  color: var(--brand-800);
  box-shadow: var(--shadow-control), inset 0 0 0 1px var(--brand-100);
}

.segmented-option--stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.125rem;
  min-height: 3.375rem;
  padding: 0.5rem 0.75rem;
  text-align: left;
  line-height: 1.35;
}

.segmented-option__title {
  font-size: 0.875rem;
  font-weight: 600;
}

.segmented-option__hint {
  font-size: 0.6875rem;
  font-weight: 400;
  color: #a1a1a1;
}

.segmented-option[data-active="true"] .segmented-option__hint {
  color: var(--brand-700);
}

.segmented-option--compact {
  min-height: 2.5rem;
  font-size: 0.8125rem;
  padding: 0.5rem 0.25rem;
}

/* ============================================================
   说明块
   ============================================================ */
.info-block {
  position: relative;
  padding: 0.75rem;
  border-radius: 0.5rem;
  background: var(--canvas-50);
}

.info-block__title {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-950);
}

.info-block__desc {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  line-height: 1.65;
  color: #737373;
}

.info-block__meta {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  margin: 0;
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--ink-500);
}

/* ============================================================
   下拉框
   ============================================================ */
.select-wrap {
  position: relative;
}

.select {
  width: 100%;
  height: 2.75rem;
  padding: 0 2.25rem 0 0.875rem;
  border: 1px solid var(--line-200);
  border-radius: 0.5rem;
  background: var(--white);
  color: var(--ink-950);
  font-size: 0.875rem;
  font-weight: 400;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.16s, box-shadow 0.16s;
  text-overflow: ellipsis;
}

.select--sm {
  height: 2.5rem;
  font-size: 0.875rem;
}

.select:hover {
  border-color: var(--line-300);
}

.select:focus {
  outline: none;
  border-color: var(--brand-600);
  box-shadow: 0 0 0 3px rgba(14, 124, 102, 0.12);
}

.select-wrap__chevron {
  position: absolute;
  top: 50%;
  right: 0.625rem;
  width: 0.875rem;
  height: 0.875rem;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--ink-400);
}

/* ============================================================
   提示词输入
   ============================================================ */
.prompt-area {
  width: 100%;
  min-height: 12rem;
  padding: 0.75rem;
  border: 1px solid var(--line-200);
  border-radius: 0.5rem;
  background: var(--white);
  color: var(--ink-950);
  font-size: 0.875rem;
  line-height: 1.7;
  resize: vertical;
  transition: border-color 0.16s, box-shadow 0.16s;
}

.prompt-area::placeholder {
  color: var(--ink-400);
}

.prompt-area:focus {
  outline: none;
  border-color: var(--brand-600);
  box-shadow: 0 0 0 3px rgba(14, 124, 102, 0.12);
}

.example-btn {
  margin-top: 0.5rem;
  text-align: left;
  font-size: 0.75rem;
  line-height: 1.65;
  color: var(--ink-500);
  text-decoration: underline;
  text-decoration-color: var(--line-300);
  text-underline-offset: 4px;
  transition: color 0.16s;
}

.example-btn:hover {
  color: var(--ink-950);
}

.polish-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.polish-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--brand-700);
  transition: color 0.16s;
}

.polish-btn:hover {
  color: var(--brand-800);
}

.polish-btn svg {
  width: 0.875rem;
  height: 0.875rem;
}

/* ============================================================
   消耗提示 + 主按钮
   ============================================================ */
.cost-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  border: 1px solid #e5e5e5;
  border-radius: 0.5rem;
  background: #fafafa;
  font-size: 0.875rem;
  line-height: 1.45;
}

.cost-box__label {
  color: #737373;
}

.cost-box__value {
  font-weight: 600;
  color: var(--brand-700);
  font-variant-numeric: tabular-nums;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.625rem 1.25rem;
  border-radius: 0.5rem;
  background: var(--brand-600);
  color: var(--primary-foreground);
  font-size: 1rem;
  font-weight: 600;
  box-shadow: var(--shadow-control);
  transition: background 0.16s, box-shadow 0.16s, transform 0.16s;
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-700);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(14, 124, 102, 0.16);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(1px) scale(0.985);
}

.btn-primary:disabled {
  background: var(--line-300);
  color: #fff;
  cursor: not-allowed;
}

.btn-primary--block {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.625rem 1.25rem;
  font-size: 1rem;
}

.btn-primary--sm {
  min-height: 2.25rem;
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
  border-radius: 0.5rem;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  min-height: 2.125rem;
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--line-200);
  border-radius: 0.5rem;
  background: var(--white);
  color: var(--ink-600);
  font-size: 0.8125rem;
  font-weight: 500;
  transition: background 0.16s, border-color 0.16s, color 0.16s;
}

.btn-secondary:hover {
  background: var(--canvas-50);
  border-color: var(--line-300);
  color: var(--ink-950);
}

.btn-secondary[data-active="true"] {
  background: var(--brand-50);
  border-color: var(--brand-100);
  color: var(--brand-700);
  font-weight: 600;
}

.micro-note {
  margin: 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--ink-400);
}

/* ============================================================
   右栏：预览
   ============================================================ */
.preview-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3.5rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--line-200);
}

.preview-head__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  background: var(--brand-50);
  color: var(--brand-700);
  flex-shrink: 0;
}

.preview-head__icon svg {
  width: 1rem;
  height: 1rem;
}

.preview-head__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.preview-head__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.preview-canvas {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 1.25rem;
  background: var(--white);
}

@media (min-width: 640px) {
  .preview-canvas {
    padding: 2rem;
  }
}

.preview-canvas__grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 1;
  background-image: linear-gradient(#d8d9da 1px, transparent 1px),
    linear-gradient(90deg, #d8d9da 1px, transparent 1px);
  background-size: 24px 24px;
}

.preview-empty {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  max-width: 36rem;
  aspect-ratio: 1 / 1;
  padding: 0 1.5rem;
  border: 1px solid #e5e5e5;
  border-radius: 0.5rem;
  background: var(--white);
  text-align: center;
  font-size: 0.875rem;
  color: #a1a1a1;
}

.preview-empty svg {
  width: 1.75rem;
  height: 1.75rem;
  color: #a1a1a1;
}

.preview-strip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--media-950);
  color: #fff;
  font-size: 0.75rem;
  min-height: 2.625rem;
}

.preview-strip__label {
  font-weight: 600;
}

.preview-strip__empty {
  color: rgba(255, 255, 255, 0.5);
}

.preview-strip__link {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: rgba(255, 255, 255, 0.75);
  transition: color 0.16s;
}

.preview-strip__link:hover {
  color: #fff;
}

/* ============================================================
   页脚
   ============================================================ */
.site-footer {
  border-top: 1px solid var(--line-100);
  background: var(--canvas-50);
  color: var(--ink-500);
  font-size: 0.875rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  padding: 3rem 0;
}

@media (min-width: 768px) {
  .footer-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.footer-brand {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--ink-950);
}

.footer-desc {
  margin: 0.75rem 0 0;
  line-height: 1.7;
}

.footer-title {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-950);
}

.footer-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.footer-list a {
  transition: color 0.16s;
}

.footer-list a:hover {
  color: var(--brand-700);
}

.footer-contact {
  margin: 1rem 0 0;
  font-size: 0.75rem;
}

.footer-bottom {
  border-top: 1px solid var(--line-100);
}

.footer-bottom__inner {
  padding: 1rem 0;
  text-align: center;
  font-size: 0.75rem;
}

/* ============================================================
   工具类
   ============================================================ */
.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


/* ============================================================
   工作台新增：参考图 / 结果舞台 / 圈选 / 编辑条 / 加载态
   ============================================================ */
.segmented-control--4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* ---------------- 参考图上传 ---------------- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem 1rem;
  border: 1px dashed var(--line-300);
  border-radius: 0.5rem;
  background: var(--canvas-50);
  cursor: pointer;
  transition: border-color 0.16s, background 0.16s;
}

.dropzone:hover,
.dropzone.is-over {
  border-color: var(--brand-600);
  background: var(--brand-50);
}

.dropzone__icon {
  display: flex;
  color: var(--ink-400);
}

.dropzone__icon svg {
  width: 22px;
  height: 22px;
}

.dropzone__text {
  font-size: 0.75rem;
  color: var(--ink-500);
  text-align: center;
}

.ref-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.ref-thumb {
  position: relative;
  width: 4rem;
  height: 4rem;
  border: 1px solid var(--line-200);
  border-radius: 0.375rem;
  overflow: hidden;
  background: var(--canvas-100);
}

.ref-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ref-thumb__x {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 1.125rem;
  height: 1.125rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(16, 18, 23, 0.72);
  color: #fff;
  font-size: 0.625rem;
  line-height: 1;
}

/* ---------------- 结果舞台 ---------------- */
.stage {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  overflow: auto;
}

.stage[hidden] {
  display: none;
}

.stage__inner {
  position: relative;
  display: inline-block;
  max-width: 100%;
  max-height: 100%;
  line-height: 0;
  border-radius: 0.5rem;
  box-shadow: 0 16px 40px rgba(18, 30, 28, 0.12);
}

.stage__img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border-radius: 0.5rem;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

.stage__marks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.stage__selector {
  position: absolute;
  border: 2px solid rgba(255, 24, 86, 0.95);
  background: rgba(255, 24, 86, 0.34);
  border-radius: 2px;
  pointer-events: none;
}

.stage__selector[hidden] {
  display: none;
}

.stage__hint {
  position: absolute;
  left: 50%;
  bottom: -2rem;
  transform: translateX(-50%);
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  background: rgba(16, 18, 23, 0.82);
  color: #fff;
  font-size: 0.6875rem;
  line-height: 1.6;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s;
}

.stage.is-picking .stage__inner {
  cursor: crosshair;
  /* 手机上没有 touch-action:none，手指拖动会被当成页面滚动，pointermove 直接中断 */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.stage.is-picking .stage__img {
  touch-action: none;
  -webkit-touch-callout: none;
}

.stage.is-picking .stage__hint {
  opacity: 1;
}

/* 圈选态不再给整图描虚线框——会和真正的选区框混淆，只留十字光标 */

/* 已有选区时的小角标 */
.stage__marks::after {
  content: '';
}

/* ---------------- 加载态 ---------------- */
.preview-loading {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(2px);
  font-size: 0.8125rem;
  color: var(--ink-600);
}

.preview-loading[hidden] {
  display: none;
}

.spinner {
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--brand-100);
  border-top-color: var(--brand-600);
  border-radius: 999px;
  animation: yy-spin 0.8s linear infinite;
}

@keyframes yy-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------------- 编辑条 ---------------- */
.editbar {
  border-top: 1px solid var(--line-200);
  background: var(--canvas-50);
  padding: 0.75rem 1rem;
}

.editbar[hidden] {
  display: none;
}

.editbar__row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.editbar__badge {
  flex-shrink: 0;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  background: var(--brand-50);
  color: var(--brand-700);
  font-size: 0.6875rem;
  font-weight: 600;
  white-space: nowrap;
}

.editbar__badge.is-empty {
  background: #fef2f2;
  color: #b91c1c;
}

.editbar__input {
  flex: 1;
  min-width: 12rem;
  height: 2.5rem;
  padding: 0 0.75rem;
  border: 1px solid var(--line-200);
  border-radius: 0.5rem;
  background: var(--white);
  font-size: 0.8125rem;
}

.editbar__input:focus {
  outline: none;
  border-color: var(--brand-600);
  box-shadow: 0 0 0 3px rgba(14, 124, 102, 0.12);
}

.editbar__note {
  margin: 0.5rem 0 0;
  font-size: 0.6875rem;
  color: var(--ink-400);
}

/* ---------------- 生成记录缩略 ---------------- */
.history-rail {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 14;
  display: flex;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  overflow-x: auto;
  background: linear-gradient(transparent, rgba(255, 255, 255, 0.94) 42%);
}

.history-rail__item {
  flex: 0 0 auto;
  width: 3.5rem;
  height: 3.5rem;
  border: 1px solid var(--line-200);
  border-radius: 0.375rem;
  overflow: hidden;
  background: var(--white);
  transition: border-color 0.16s, transform 0.16s;
}

.history-rail__item:hover {
  border-color: var(--brand-600);
  transform: translateY(-2px);
}

.history-rail__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 窄屏：编辑条竖排 */
@media (max-width: 767px) {
  .editbar__row {
    flex-direction: column;
    align-items: stretch;
  }
  .stage {
    padding: 1rem;
  }
}

/* ---------------- 模型说明 / 尺寸读数 ---------------- */
.field__hint {
  margin: 0.375rem 0 0;
  font-size: 0.75rem;
  line-height: 1.6;
  color: #a1a1a1;
}

.size-readout {
  display: flex;
  align-items: center;
  min-height: 2.5rem;
  margin: 0;
  padding: 0 0.875rem;
  border: 1px solid var(--line-100);
  border-radius: 0.5rem;
  background: var(--canvas-50);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-600);
}

/* ---------------- 示例 / 会话记录面板 ---------------- */
.pane-body {
  position: absolute;
  inset: 0;
  z-index: 13;
  padding: 1.5rem;
  overflow-y: auto;
  background: var(--white);
}

.pane-body[hidden] {
  display: none;
}

.example-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  max-width: 44rem;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .example-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.example-card {
  display: flex;
  gap: 0.75rem;
  padding: 0.875rem;
  border: 1px solid var(--line-200);
  border-radius: 0.625rem;
  background: var(--white);
  text-align: left;
  transition: border-color 0.16s, transform 0.16s;
}

.example-card:hover {
  border-color: var(--brand-600);
  transform: translateY(-1px);
}

.example-card__num {
  flex-shrink: 0;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--brand-600);
}

.example-card__text {
  font-size: 0.8125rem;
  line-height: 1.65;
  color: var(--ink-600);
}

.gallery-mini {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .gallery-mini {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .gallery-mini {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.gallery-mini__item {
  position: relative;
  border: 1px solid var(--line-200);
  border-radius: 0.5rem;
  overflow: hidden;
  background: var(--canvas-100);
  transition: border-color 0.16s, transform 0.16s;
}

.gallery-mini__item:hover {
  border-color: var(--brand-600);
  transform: translateY(-2px);
}

.gallery-mini__item img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.gallery-mini__label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.25rem 0.375rem;
  background: rgba(16, 18, 23, 0.68);
  color: #fff;
  font-size: 0.625rem;
  text-align: left;
}

/* workbench.css 里的 .nav{display:flex} 会盖掉 shell.css 的移动端隐藏规则，
   这里补一条同优先级的后置覆盖，窄屏只留汉堡按钮 */
@media (max-width: 1023px) {
  .site-header .nav {
    display: none;
  }
  .site-header .header-actions {
    display: none;
  }
  .header-burger {
    display: flex;
  }
}

/* 手机宽度下预览区工具栏：原来 4 个按钮挤在 56px 高的一行里被压成两行，
   改成标题独占一行、按钮换行排布 */
@media (max-width: 639px) {
  .preview-head {
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: auto;
    padding: 0.75rem 1rem;
  }

  .preview-head__title {
    font-size: 0.9375rem;
  }

  .preview-head__actions {
    width: 100%;
    margin-left: 0;
    flex-wrap: wrap;
    gap: 0.375rem;
  }

  .preview-head__actions .btn-secondary {
    min-height: 2.125rem;
    padding: 0 0.625rem;
    font-size: 0.75rem;
  }

  /* 圈选编辑条在手机上竖排，按钮占满 */
  .editbar__row {
    flex-direction: column;
    align-items: stretch;
  }

  .editbar__row .btn-primary,
  .editbar__row .btn-secondary {
    width: 100%;
  }
}
