/* ============================================================
   小海电商做图工作室 — 界面样式
   设计原则：克制、整齐、专业。单一靛紫强调色 + 中性画布。
   8px 间距网格，统一圆角与阴影层级，细腻的交互反馈。
   ============================================================ */

:root {
  /* 文字 */
  --ink: #15171c;
  --ink-2: #3d4250;
  --muted: #757c8c;
  --faint: #9aa1b1;

  /* 背景与表面 */
  --canvas: #f5f6f9;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --inset: #f7f8fb;

  /* 线条 */
  --line: #e8eaf0;
  --line-2: #f0f1f5;

  /* 品牌强调色（靛紫，克制使用） */
  --brand: #5350e8;
  --brand-700: #423fcb;
  --brand-50: #eeeefc;
  --brand-100: #e2e1fa;
  --brand-ink: #3a38b6;

  /* 语义色 */
  --ok: #15a34a;
  --ok-50: #e9f8ef;
  --ok-line: #c9ecd6;
  --warn: #c2710c;
  --warn-50: #fbf3e6;
  --danger: #dc2626;
  --danger-50: #fdecec;
  --danger-line: #f6cdcd;

  /* 阴影层级 */
  --sh-sm: 0 1px 2px rgba(20,22,40,.05), 0 1px 3px rgba(20,22,40,.05);
  --sh: 0 4px 14px rgba(28,30,60,.06), 0 2px 6px rgba(28,30,60,.04);
  --sh-lg: 0 14px 36px rgba(28,30,60,.10), 0 4px 12px rgba(28,30,60,.05);
  --sh-pop: 0 28px 70px rgba(13,16,38,.22), 0 8px 24px rgba(13,16,38,.12);

  /* 圆角 */
  --r-sm: 8px;
  --r: 11px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-2xl: 22px;

  /* 字体 */
  --font: "PingFang SC", "Microsoft YaHei", "Source Han Sans CN", "Noto Sans CJK SC", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }
::selection { background: var(--brand-100); color: var(--brand-ink); }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body { overflow: hidden; }
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }

/* 滚动条 */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #d8dbe6; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #c3c7d6; background-clip: content-box; }

/* ====================== 通用按钮 / 控件 ====================== */
.primary {
  border: 0;
  background: var(--brand);
  color: #fff;
  border-radius: var(--r);
  padding: 12px 18px;
  font-weight: 650;
  cursor: pointer;
  transition: background .15s, transform .08s, box-shadow .15s;
  box-shadow: 0 1px 2px rgba(50,46,180,.18);
}
.primary:hover { background: var(--brand-700); }
.primary:active { transform: translateY(1px); }

.ghost, .outline {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: var(--r);
  padding: 10px 15px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.ghost:hover, .outline:hover { border-color: #d6d9e6; background: var(--inset); color: var(--ink); }

.wide { width: 100%; }

/* ====================== 应用骨架 ====================== */
.app { display: flex; height: 100vh; }

.sidebar {
  width: 264px;
  flex: 0 0 264px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

/* 品牌 */
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 6px; }
.brand h1 { font-size: 16px; line-height: 1.25; }
.brand p { margin-top: 2px; color: var(--muted); font-size: 12px; line-height: 1.3; }
.logo {
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: 11px;
  background: linear-gradient(150deg, var(--brand) 0%, #7d6bff 100%);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 18px;
  box-shadow: 0 4px 12px rgba(83,80,232,.32);
}

/* 新建对话 */
.new {
  border: 0;
  background: var(--brand);
  color: #fff;
  border-radius: var(--r-lg);
  height: 46px;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .15s, transform .08s;
  box-shadow: 0 4px 14px rgba(83,80,232,.26);
}
.new:hover { background: var(--brand-700); }
.new:active { transform: translateY(1px); }

/* 导航 */
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--faint); padding: 6px 10px 4px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 11px;
  border-radius: var(--r);
  color: var(--ink-2);
  font-weight: 550;
  cursor: pointer;
  transition: background .14s, color .14s;
  position: relative;
}
.sidebar nav a svg { width: 18px; height: 18px; flex: 0 0 18px; color: var(--faint); transition: color .14s; }
.sidebar nav a:hover { background: var(--inset); color: var(--ink); }
.sidebar nav a:hover svg { color: var(--muted); }
.sidebar nav a.active { background: var(--brand-50); color: var(--brand-ink); font-weight: 650; }
.sidebar nav a.active svg { color: var(--brand); }

/* 时间卡片 */
.time-card {
  margin-top: auto;
  background: linear-gradient(160deg, #f3f2ff 0%, #fbfaff 100%);
  border: 1px solid var(--brand-100);
  border-radius: var(--r-xl);
  padding: 15px;
}
.time-card span { color: var(--muted); font-size: 12px; font-weight: 600; }
.time-card strong { display: block; color: var(--brand-ink); font-size: 22px; font-weight: 750; letter-spacing: -0.02em; margin: 6px 0 12px; font-variant-numeric: tabular-nums; }
.time-card button { width: 100%; padding: 9px; border: 0; border-radius: var(--r); background: var(--brand); color: #fff; font-weight: 650; cursor: pointer; transition: background .15s; }
.time-card button:hover { background: var(--brand-700); }

/* 用户卡片 */
.user-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 11px 13px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.user-card b { display: block; font-size: 14px; margin-bottom: 5px; }
.user-card small { display: block; color: var(--muted); margin-top: 2px; font-size: 12px; }
.user-card button { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-sm); padding: 7px 11px; color: var(--ink-2); font-weight: 600; font-size: 13px; cursor: pointer; transition: border-color .15s, background .15s; }
.user-card button:hover { border-color: var(--danger-line); background: var(--danger-50); color: var(--danger); }

/* ====================== 主区域 ====================== */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--canvas); }

.topbar {
  height: 62px;
  flex: 0 0 62px;
  background: rgba(255,255,255,.82);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
}
.mode { display: flex; align-items: center; gap: 8px; }
.mode > span { color: var(--muted); font-size: 13px; font-weight: 600; }
.segmented { display: inline-flex; background: var(--inset); border: 1px solid var(--line); border-radius: var(--r); padding: 3px; gap: 2px; }
.segmented button { border: 0; background: transparent; border-radius: 8px; padding: 7px 15px; cursor: pointer; color: var(--ink-2); font-weight: 600; font-size: 13.5px; transition: background .15s, color .15s, box-shadow .15s; }
.segmented button:hover { color: var(--ink); }
.segmented button.selected { background: var(--surface); color: var(--brand-ink); box-shadow: var(--sh-sm); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.top-actions .outline { padding: 8px 14px; font-size: 13.5px; }

/* 页面切换 */
.page { display: none; flex: 1; min-height: 0; }
.page.active { display: flex; flex-direction: column; }

/* ====================== 对话 ====================== */
.messages { flex: 1; overflow-y: auto; padding: 28px 0 12px; }
.row { display: flex; gap: 13px; margin: 0 auto 22px; max-width: 820px; padding: 0 24px; }
.row.user { flex-direction: row-reverse; }
.avatar {
  width: 34px; height: 34px; flex: 0 0 34px;
  border-radius: 10px;
  background: linear-gradient(150deg, var(--brand) 0%, #7d6bff 100%);
  color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 15px;
  box-shadow: 0 3px 8px rgba(83,80,232,.28);
}
.bubble { max-width: 100%; border-radius: var(--r-xl); padding: 13px 17px; line-height: 1.72; }
.row.ai .bubble { background: var(--surface); border: 1px solid var(--line); border-top-left-radius: 6px; box-shadow: var(--sh-sm); }
.row.user .bubble { background: var(--brand); color: #fff; border-top-right-radius: 6px; }
.row.user .bubble a { color: #fff; text-decoration: underline; }

/* 打字指示 */
.typing { display: inline-flex; gap: 5px; align-items: center; padding: 4px 2px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); display: inline-block; animation: blink 1.3s infinite ease-in-out both; }
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.cursor { display: inline-block; width: 7px; height: 15px; margin-left: 2px; background: var(--brand); border-radius: 1px; vertical-align: text-bottom; animation: caret 1s steps(2, start) infinite; }
@keyframes caret { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
.status-line { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }

/* AI 消息内的 Markdown 渲染 */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 10px; }
.md h1, .md h2, .md h3 { margin: 16px 0 8px; line-height: 1.35; }
.md h1 { font-size: 19px; } .md h2 { font-size: 17px; } .md h3 { font-size: 15.5px; }
.md ul, .md ol { margin: 8px 0 12px; padding-left: 22px; }
.md li { margin: 4px 0; }
.md li::marker { color: var(--brand); }
.md strong { font-weight: 700; color: var(--ink); }
.md em { font-style: italic; }
.md code { font-family: var(--mono); font-size: 13px; background: var(--inset); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }
.md pre { background: #1a1d27; color: #e6e8f0; border-radius: var(--r); padding: 13px 15px; overflow-x: auto; margin: 10px 0; }
.md pre code { background: transparent; border: 0; padding: 0; color: inherit; font-size: 13px; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.md blockquote { margin: 10px 0; padding: 4px 14px; border-left: 3px solid var(--brand-100); color: var(--muted); }
.md a { text-decoration: underline; }

/* 图片结果网格 */
.image-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.img-card { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 9px; transition: box-shadow .18s, transform .18s; }
.img-card:hover { box-shadow: var(--sh); transform: translateY(-1px); }
.img-card img { width: 100%; display: block; border-radius: 10px; aspect-ratio: 1/1; object-fit: cover; background: var(--inset); }
.img-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 9px; }
.img-actions a {
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 11px;
  color: var(--ink-2); background: var(--surface); font-size: 13px; font-weight: 600;
  transition: border-color .15s, background .15s, color .15s;
}
.img-actions a:hover { border-color: var(--brand-100); background: var(--brand-50); color: var(--brand-ink); }
.batch-download {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 12px;
  color: var(--brand-ink); font-weight: 650; font-size: 13.5px;
  border: 1px solid var(--brand-100); background: var(--brand-50);
  padding: 7px 13px; border-radius: var(--r); transition: background .15s;
}
.batch-download:hover { background: var(--brand-100); }

/* 输入区 */
.composer {
  margin: 0 auto 22px; max-width: 820px; width: calc(100% - 48px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-2xl);
  padding: 11px;
  box-shadow: var(--sh-lg);
  transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: var(--brand-100); box-shadow: 0 0 0 4px var(--brand-50), var(--sh-lg); }
.composer.drag { border: 1.5px dashed var(--brand); background: var(--brand-50); }
.input-line { display: flex; gap: 10px; align-items: flex-end; }
.icon { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); width: 42px; height: 42px; flex: 0 0 42px; cursor: pointer; font-size: 17px; transition: border-color .15s, background .15s; display: grid; place-items: center; }
.icon:hover { border-color: #d6d9e6; background: var(--inset); }
.composer textarea {
  flex: 1; border: 0; resize: none; outline: 0; background: transparent;
  font-size: 15px; line-height: 1.6; min-height: 42px; max-height: 168px; padding: 10px 4px;
}
.composer textarea::placeholder { color: var(--faint); }
.send { width: 44px; height: 44px; flex: 0 0 44px; padding: 0; border: 0; border-radius: var(--r); background: var(--brand); color: #fff; font-size: 18px; cursor: pointer; transition: background .15s, transform .08s; display: grid; place-items: center; }
.send:hover { background: var(--brand-700); }
.send:active { transform: translateY(1px); }
.send.stop { background: var(--ink-2); font-size: 13px; }
.send.stop:hover { background: var(--ink); }
.msg-actions { margin-top: 9px; display: flex; gap: 8px; }
.msg-act { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: var(--r-sm); padding: 3px 10px; font-size: 12px; font-weight: 600; cursor: pointer; transition: border-color .15s, color .15s, background .15s; }
.msg-act:hover { border-color: var(--brand-100); color: var(--brand); background: var(--brand-50); }
.hint { font-size: 12px; color: var(--faint); margin: 9px 0 0 54px; }
.file-preview { display: flex; gap: 8px; flex-wrap: wrap; padding: 4px 0 10px 54px; }
.file-thumb { position: relative; }
.file-thumb img { height: 54px; width: 54px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.file-thumb button { position: absolute; right: -6px; top: -6px; border: 2px solid #fff; background: var(--ink); color: #fff; border-radius: 50%; width: 20px; height: 20px; cursor: pointer; font-size: 12px; line-height: 1; display: grid; place-items: center; }

/* ====================== 内容页通用 ====================== */
.scroll-page { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 26px 28px 40px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 24px; box-shadow: var(--sh-sm); }
.panel h2 { font-size: 18px; }
.page-head { margin-bottom: 18px; }
.page-head h2 { font-size: 18px; }
.page-head p { color: var(--muted); margin-top: 4px; font-size: 13.5px; }
.page-title { display: flex; gap: 13px; align-items: flex-start; margin-bottom: 18px; }
.page-title h2 { font-size: 18px; }
.page-title p { color: var(--muted); margin-top: 4px; font-size: 13.5px; }
.back { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: var(--r); padding: 8px 12px; cursor: pointer; font-size: 15px; transition: border-color .15s, background .15s; }
.back:hover { border-color: #d6d9e6; background: var(--inset); }

/* 专业改字 */
.edit-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.edit-layout .panel { min-width: 0; }
.edit-upload {
  min-height: 240px; max-height: 380px; border: 1.5px dashed #cdd0e2; border-radius: var(--r-xl);
  background: var(--inset); display: grid; place-items: center; margin-bottom: 16px; padding: 14px;
  cursor: pointer; color: var(--muted); overflow: hidden; transition: border-color .15s, background .15s; text-align: center;
}
.edit-upload:hover { border-color: var(--brand); background: var(--brand-50); color: var(--brand-ink); }
.edit-upload img { max-width: 100%; max-height: 348px; width: auto; height: auto; object-fit: contain; display: block; border-radius: var(--r); }
.large-input { width: 100%; min-height: 116px; border: 1px solid var(--line); border-radius: var(--r-lg); padding: 13px; resize: vertical; outline: 0; line-height: 1.6; transition: border-color .15s, box-shadow .15s; background: var(--surface); }
.large-input:focus { border-color: var(--brand-100); box-shadow: 0 0 0 4px var(--brand-50); }
.edit-main .primary, .edit-text-panel .primary { margin-top: 14px; }
.edit-result h3 { font-size: 15px; margin-bottom: 14px; }
.result-empty { height: 380px; border-radius: var(--r-lg); background: var(--inset); border: 1px dashed var(--line); display: grid; place-items: center; color: var(--faint); text-align: center; }

/* 改字：识别出的文字列表 */
.tx-head { display: flex; align-items: center; justify-content: space-between; margin: 2px 0 10px; }
.tx-head-title { font-size: 14px; font-weight: 650; color: var(--ink-2); }
.tx-reocr { border: 1px solid var(--line); background: var(--surface); color: var(--brand-ink); border-radius: var(--r-sm); padding: 5px 11px; font-size: 12.5px; font-weight: 600; cursor: pointer; transition: border-color .15s, background .15s; }
.tx-reocr:hover { border-color: var(--brand-100); background: var(--brand-50); }
.tx-list { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface-2); padding: 8px; max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.tx-hint { color: var(--muted); font-size: 13px; line-height: 1.6; padding: 16px 12px; text-align: center; }
.tx-loading { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-size: 13.5px; padding: 26px 12px; }
.tx-spin { width: 16px; height: 16px; border: 2px solid var(--brand-100); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tx-row { display: grid; grid-template-columns: minmax(0, 1fr) 16px minmax(0, 1.05fr) 26px; align-items: center; gap: 7px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; }
.tx-row.changed { border-color: var(--brand-100); background: var(--brand-50); }
.tx-orig { font-size: 13.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-arrow { color: var(--faint); text-align: center; font-size: 13px; }
.tx-new { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 7px 9px; font-size: 13.5px; outline: 0; background: var(--surface); transition: border-color .15s, box-shadow .15s; width: 100%; }
.tx-new:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.tx-note { width: 100%; min-height: 60px; border: 1px solid var(--line); border-radius: var(--r-lg); padding: 11px 13px; resize: vertical; outline: 0; line-height: 1.6; font-size: 13.5px; margin-top: 14px; background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.tx-note:focus { border-color: var(--brand-100); box-shadow: 0 0 0 4px var(--brand-50); }
.tx-revert { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: var(--r-sm); width: 26px; height: 26px; font-size: 14px; line-height: 1; cursor: pointer; padding: 0; transition: border-color .15s, color .15s, background .15s; }
.tx-revert:hover { border-color: var(--brand-100); color: var(--brand); background: var(--brand-50); }
.tx-head-actions { display: flex; align-items: center; gap: 8px; }
.tx-link { border: 0; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 4px 4px; transition: color .15s; }
.tx-link:hover { color: var(--brand); }

/* 改字：左右双栏 + 前后对比 */
.edit-text-panel { display: flex; flex-direction: column; }
.edit-text-panel .tx-list { flex: 1; max-height: 420px; }
.edit-image-panel .edit-upload { margin-bottom: 0; }
#editResultWrap { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 16px; }
.cmp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cmp-title { font-size: 15px; font-weight: 650; }
.cmp-toggle { display: inline-flex; background: var(--inset); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.cmp-btn { border: 0; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 600; padding: 5px 14px; border-radius: 999px; cursor: pointer; transition: background .15s, color .15s; }
.cmp-btn.active { background: var(--surface); color: var(--brand-ink); box-shadow: var(--sh-sm); }
.cmp-stage { position: relative; width: 100%; border-radius: var(--r-lg); overflow: hidden; background: var(--inset); border: 1px solid var(--line); text-align: center; }
.cmp-img { display: none; max-width: 100%; max-height: 440px; width: auto; height: auto; margin: 0 auto; }
.cmp-img.active { display: block; }

/* 历史 / 作图记录 */
.history-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.history-item { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 9px; background: var(--surface); transition: box-shadow .18s, transform .18s; }
.history-item:hover { box-shadow: var(--sh); transform: translateY(-1px); }
.history-item img { width: 100%; border-radius: 9px; aspect-ratio: 1/1; object-fit: cover; background: var(--inset); display: block; }
.history-item p { font-size: 12.5px; color: var(--muted); margin: 9px 2px; line-height: 1.45; height: 36px; overflow: hidden; }

/* 快捷模板（原“工具箱”重构为可点击的真实模板） */
.tpl-group { margin-bottom: 26px; }
.tpl-group h3 { font-size: 14px; color: var(--ink-2); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.tpl-group h3::before { content: ""; width: 4px; height: 14px; background: var(--brand); border-radius: 3px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: 12px; }
.tpl-card { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-lg); padding: 15px 16px; cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .12s; }
.tpl-card:hover { border-color: var(--brand-100); box-shadow: var(--sh); transform: translateY(-2px); }
.tpl-card b { display: block; font-size: 14.5px; color: var(--ink); }
.tpl-card span { display: block; color: var(--muted); font-size: 12.5px; margin-top: 5px; line-height: 1.5; }
.tpl-card .go { margin-top: 11px; color: var(--brand-ink); font-size: 12.5px; font-weight: 650; }

/* 个人中心 */
.profile { max-width: 560px; }
.info-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line-2); }
.info-row:last-of-type { border-bottom: 0; }
.info-row > span:first-child { color: var(--muted); font-size: 14px; }
.info-row b { font-size: 14px; font-variant-numeric: tabular-nums; }
.profile .primary { margin-top: 18px; }

/* 状态徽标 */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 650; line-height: 1.5; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-50); color: var(--ok); }
.badge.off { background: var(--inset); color: var(--muted); }
.badge.danger { background: var(--danger-50); color: var(--danger); }
.badge.admin { background: var(--brand-50); color: var(--brand-ink); }

/* ====================== 管理后台 ====================== */
.admin-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 18px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat-grid div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px; box-shadow: var(--sh-sm); }
.stat-grid b { display: block; font-size: 26px; font-weight: 750; color: var(--ink); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-grid span { display: block; color: var(--muted); margin-top: 4px; font-size: 12.5px; }

.admin-tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.admin-tabs button { border: 0; background: transparent; border-bottom: 2px solid transparent; border-radius: 0; padding: 9px 4px; margin-bottom: -1px; cursor: pointer; font-weight: 600; color: var(--muted); transition: color .15s, border-color .15s; }
.admin-tabs button:hover { color: var(--ink); }
.admin-tabs button.selected { color: var(--brand-ink); border-bottom-color: var(--brand); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.admin-table th, .admin-table td { border-bottom: 1px solid var(--line-2); padding: 12px 14px; text-align: left; vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table tbody tr { transition: background .12s; }
.admin-table tbody tr:hover { background: var(--inset); }
.admin-table th { background: var(--surface-2); color: var(--muted); font-weight: 650; font-size: 12.5px; letter-spacing: .01em; white-space: nowrap; }
.admin-table td b { font-weight: 650; }
.admin-table small { display: block; color: var(--faint); margin-top: 3px; font-size: 11.5px; }
.admin-table code { font-family: var(--mono); font-size: 12.5px; background: var(--inset); border: 1px solid var(--line); border-radius: 5px; padding: 2px 7px; }

.ops { display: flex; gap: 6px; flex-wrap: wrap; min-width: 320px; }
.ops button { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--ink-2); transition: border-color .15s, background .15s, color .15s; }
.ops button:hover { border-color: var(--brand-100); background: var(--brand-50); color: var(--brand-ink); }
.ops .danger { color: var(--danger); border-color: #f0d2d2; }
.ops .danger:hover { background: var(--danger-50); border-color: var(--danger-line); color: var(--danger); }

.code-maker { display: grid; grid-template-columns: 110px 150px 1fr auto; gap: 10px; margin-bottom: 14px; }
.code-maker input, .code-maker select { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; outline: 0; background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.code-maker input:focus, .code-maker select:focus { border-color: var(--brand-100); box-shadow: 0 0 0 3px var(--brand-50); }
.code-output { width: 100%; min-height: 110px; border: 1px solid var(--line); border-radius: var(--r-lg); padding: 13px; margin-bottom: 16px; font-family: var(--mono); font-size: 13px; line-height: 1.7; outline: 0; resize: vertical; background: var(--inset); }
.code-output:focus { border-color: var(--brand-100); box-shadow: 0 0 0 3px var(--brand-50); }

.storage-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px; }
.storage-card h3 { font-size: 15px; margin-bottom: 8px; }
.storage-card p { color: var(--muted); font-size: 13.5px; line-height: 1.65; margin-bottom: 16px; }
.storage-card pre { background: #1a1d27; color: #cdd2e0; border-radius: var(--r); padding: 14px 16px; overflow-x: auto; min-height: 64px; margin-top: 14px; font-family: var(--mono); font-size: 12.5px; }

/* ====================== 弹窗 ====================== */
.modal { position: fixed; inset: 0; background: rgba(15,18,38,.46); backdrop-filter: blur(3px); z-index: 99; display: grid; place-items: center; padding: 20px; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.auth-card, .activation-card { width: 100%; max-width: 410px; background: var(--surface); border-radius: var(--r-2xl); padding: 28px; box-shadow: var(--sh-pop); position: relative; animation: pop .22s cubic-bezier(.2,.9,.3,1.2); }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.brand.big { margin-bottom: 22px; }
.brand.big h1 { font-size: 18px; }

.tabs { display: flex; background: var(--inset); border-radius: var(--r-lg); padding: 4px; margin-bottom: 16px; gap: 2px; }
.tabs button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 11px; cursor: pointer; font-weight: 600; color: var(--muted); transition: background .15s, color .15s, box-shadow .15s; }
.tabs button:hover { color: var(--ink); }
.tabs button.active { background: var(--surface); color: var(--brand-ink); box-shadow: var(--sh-sm); }

.auth-card input, .activation-card input {
  width: 100%; border: 1px solid var(--line); border-radius: var(--r-lg); padding: 13px 14px; margin: 8px 0; outline: 0;
  transition: border-color .15s, box-shadow .15s; background: var(--surface);
}
.auth-card input:focus, .activation-card input:focus { border-color: var(--brand-100); box-shadow: 0 0 0 4px var(--brand-50); }
.auth-card .primary, .activation-card .primary, .activation-card .ghost { width: 100%; margin-top: 10px; padding: 13px; }
.msg { color: var(--danger); font-size: 13.5px; margin-top: 12px; text-align: center; min-height: 18px; }
.close { position: absolute; right: 16px; top: 14px; border: 0; background: transparent; font-size: 22px; cursor: pointer; color: var(--faint); line-height: 1; transition: color .15s; }
.close:hover { color: var(--ink); }
.gift { text-align: center; font-size: 42px; margin-bottom: 6px; }
.activation-card h2 { text-align: center; font-size: 19px; }
.activation-card > p { text-align: center; color: var(--muted); font-size: 13.5px; margin-top: 6px; line-height: 1.6; }
.contact-box { background: var(--inset); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; margin: 16px 0; }
.contact-box > div { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; font-size: 14px; color: var(--ink-2); }
.contact-box b { color: var(--brand-ink); font-variant-numeric: tabular-nums; }

.reg-success { background: var(--ok-50); color: var(--ok); border: 1px solid var(--ok-line); border-radius: var(--r-sm); padding: 11px 14px; margin: 2px 0 16px; font-size: 14px; font-weight: 650; line-height: 1.5; text-align: center; }
.hidden { display: none !important; }

/* ====================== 响应式 ====================== */
/* 汉堡按钮 + 遮罩：默认（电脑）隐藏 */
.hamburger { display: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); width: 40px; height: 40px; font-size: 20px; line-height: 1; cursor: pointer; color: var(--ink); align-items: center; justify-content: center; flex: 0 0 auto; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(20, 22, 35, .45); z-index: 60; opacity: 0; transition: opacity .25s; }

@media (max-width: 1040px) {
  .sidebar { width: 230px; flex-basis: 230px; }
  .edit-layout { grid-template-columns: 1fr; }
  .edit-image-panel { order: -1; }
}

@media (max-width: 860px) {
  body { overflow: auto; }
  .app { display: block; height: auto; min-height: 100vh; min-height: 100dvh; }
  .sidebar { position: fixed; top: 0; left: 0; height: 100%; height: 100dvh; width: 82%; max-width: 320px; flex-basis: auto; z-index: 70; transform: translateX(-100%); transition: transform .28s cubic-bezier(.22,.61,.36,1); box-shadow: 0 0 40px rgba(0,0,0,.18); overflow-y: auto; flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 0; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; opacity: 1; }
  .hamburger { display: flex; }
  .main { height: auto; }
  .topbar { padding: 8px 12px; height: auto; min-height: 56px; gap: 8px; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .topbar::-webkit-scrollbar { display: none; }
  .mode { gap: 6px; flex: 0 0 auto; }
  .mode > span { display: none; }
  .segmented button { padding: 7px 10px; font-size: 12.5px; }
  .top-actions { flex: 0 0 auto; margin-left: auto; }
  .top-actions .outline { padding: 7px 10px; font-size: 12.5px; white-space: nowrap; }
  .messages { padding: 16px 0 12px; }
  .row { padding: 0 14px; }
  .bubble { max-width: 88%; }
  .composer { width: calc(100% - 24px); margin: 0 12px 12px; padding: 10px; }
  .composer textarea { font-size: 16px; }
  .image-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .scroll-page { padding: 16px 14px 32px; }
  .page-title h2 { font-size: 20px; }
  .edit-layout { grid-template-columns: 1fr; gap: 14px; }
  .edit-image-panel { order: -1; }
  .tx-row { grid-template-columns: minmax(0,1fr) 12px minmax(0,1.05fr) 24px; gap: 5px; padding: 7px 8px; }
  .tx-new, .tx-orig-input { font-size: 16px; }
  .tx-engine button { font-size: 12.5px; padding: 10px 12px; }
  .code-maker { grid-template-columns: 1fr; }
  .table-wrap { overflow-x: auto; }
  .ops { min-width: 0; }
  .history-grid { grid-template-columns: repeat(2, 1fr); }
  .tpl-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 460px) {
  .history-grid, .image-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
  .bubble { max-width: 92%; }
  .segmented button { padding: 6px 8px; font-size: 12px; }
}


@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ===================== 交互动效与整体精修 ===================== */

/* —— 点击波纹 —— */
.primary, .send, nav a, .tpl-card, .icon, .cmp-btn, .tx-reocr, .back, .ghost, .msg-act, .tx-revert, .tx-link, .tabs button, .segmented button, .new { position: relative; overflow: hidden; }
.ripple { position: absolute; border-radius: 50%; background: rgba(40, 42, 70, .14); transform: scale(0); animation: ripple .6s cubic-bezier(.22, .61, .36, 1); pointer-events: none; z-index: 0; }
.primary .ripple, .send .ripple, .new .ripple { background: rgba(255, 255, 255, .45); }
@keyframes ripple { to { transform: scale(2.6); opacity: 0; } }

/* —— 统一按压反馈（点击瞬间轻微下沉/缩放）—— */
.primary:active, .ghost:active, .icon:active, .send:active, .cmp-btn:active, .tx-reocr:active, .back:active, .msg-act:active, .tx-revert:active, .tpl-card:active, nav a:active, .new:active, .tabs button:active, .segmented button:active { transform: scale(.975); }
.primary, .ghost, .icon, .send, .cmp-btn, .tx-reocr, .back, .msg-act, .tx-revert, .new, .tabs button, .segmented button { transition: background .16s ease, color .16s ease, border-color .16s ease, box-shadow .2s ease, transform .1s ease; }

/* —— 侧边栏导航：悬停轻移 + 平滑高亮 —— */
nav a { transition: background .16s ease, color .16s ease, transform .14s ease; }
nav a:hover { transform: translateX(3px); }

/* —— 快捷模板卡片：悬停抬升 —— */
.tpl-card { transition: border-color .16s ease, box-shadow .22s ease, transform .16s ease, background .16s ease; }
.tpl-card:hover { transform: translateY(-3px); box-shadow: var(--sh-lg); }

/* —— 消息：新消息进入动画（只动最新一条，避免重渲染抖动）—— */
.row:last-child { animation: msgIn .34s cubic-bezier(.22, .61, .36, 1); }
@keyframes msgIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* —— 页面切换：淡入上移 —— */
.page.active { animation: pageIn .3s ease; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* —— 图片出现：淡入微放大 —— */
.image-grid img, .img-card, #editResult .cmp-stage { animation: fadeScale .4s ease; }
@keyframes fadeScale { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }

/* —— 弹窗遮罩淡入 —— */
.modal { animation: overlayIn .22s ease; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

/* —— 输入框聚焦：更柔和的光圈过渡 —— */
.tx-new, .tx-note, textarea, input { transition: border-color .16s ease, box-shadow .2s ease, background .16s ease; }

/* —— 主按钮悬停：轻微抬升 + 阴影 —— */
.primary:hover { box-shadow: 0 6px 18px rgba(83, 80, 232, .28); }
.send:hover { box-shadow: 0 6px 16px rgba(83, 80, 232, .26); }

/* —— 头像/品牌轻微呼吸（仅悬停）—— */
.avatar { transition: transform .2s ease; }
.row.ai:hover .avatar { transform: scale(1.06); }

/* —— 滚动条更精致 —— */
.scroll-page::-webkit-scrollbar, .messages::-webkit-scrollbar, .tx-list::-webkit-scrollbar, .table-wrap::-webkit-scrollbar { width: 9px; height: 9px; }
.scroll-page::-webkit-scrollbar-thumb, .messages::-webkit-scrollbar-thumb, .tx-list::-webkit-scrollbar-thumb, .table-wrap::-webkit-scrollbar-thumb { background: rgba(40, 42, 70, .16); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
.scroll-page::-webkit-scrollbar-thumb:hover, .messages::-webkit-scrollbar-thumb:hover { background: rgba(40, 42, 70, .28); background-clip: padding-box; }

/* —— 尊重“减少动画”偏好 —— */
@media (prefers-reduced-motion: reduce) {
  .ripple, .row:last-child, .page.active, .image-grid img, .img-card, #editResult .cmp-stage, .modal { animation: none !important; }
  * { transition-duration: .01ms !important; }
}

/* ===================== 作图实时加载动画 ===================== */
.gen-head { display: flex; align-items: center; gap: 9px; margin-bottom: 13px; color: var(--muted); font-size: 14px; }
.gen-label b { color: var(--brand-ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.gen-grid { display: grid; gap: 10px; }
.gen-grid.gtiles-1 { grid-template-columns: 1fr; max-width: 340px; }
.gen-grid.gtiles-2 { grid-template-columns: repeat(2, 1fr); max-width: 460px; }
.gen-grid.gtiles-3 { grid-template-columns: repeat(3, 1fr); }
.gen-grid.gtiles-4 { grid-template-columns: repeat(4, 1fr); }
.gtile { position: relative; aspect-ratio: 1; border-radius: var(--r); overflow: hidden; background: var(--inset); border: 1px solid var(--line); }
.gtile-shimmer { position: absolute; inset: 0; background: linear-gradient(110deg, var(--inset) 28%, rgba(83, 80, 232, .12) 48%, rgba(120, 118, 240, .06) 58%, var(--inset) 72%); background-size: 220% 100%; animation: shimmer 1.25s linear infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -120% 0; } }
.gtile::after { content: ""; position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; border: 2.5px solid rgba(83, 80, 232, .25); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; opacity: .9; }
.gtile.filled::after { display: none; }
.gtile.filled { border-color: var(--brand-100); animation: tilePop .42s cubic-bezier(.22, .61, .36, 1); }
.gtile.filled img { width: 100%; height: 100%; object-fit: cover; display: block; }
@keyframes tilePop { from { transform: scale(.88); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* 改字/请求中的文字提示加个呼吸感 */
#editMsg:not(:empty) { animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

/* —— 改字：手动添加行的原文输入框 —— */
.tx-orig-input { border: 1px dashed var(--brand-100); border-radius: var(--r-sm); padding: 7px 9px; font-size: 13.5px; outline: 0; background: var(--surface); width: 100%; transition: border-color .15s, box-shadow .15s; }
.tx-orig-input:focus { border-style: solid; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.tx-row.manual { border-color: var(--brand-100); }
.tx-row.manual .tx-revert { color: var(--danger); }
#addRowBtn { color: var(--brand); }

/* —— 语音输入：录音中脉冲 —— */
#micBtn.recording { background: #ffe9e9; border-color: #ffc4c4; color: #e23b3b; animation: micPulse 1s ease-in-out infinite; }
@keyframes micPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(226, 59, 59, .35); } 50% { box-shadow: 0 0 0 7px rgba(226, 59, 59, 0); } }

/* —— 轻提示条 —— */
.mini-toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px); background: #1f2330; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; max-width: 80vw; line-height: 1.5; box-shadow: 0 10px 30px rgba(0,0,0,.25); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 9999; }
.mini-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* —— 改字引擎选择 —— */
.tx-engine { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 12px; }
.tx-engine button { text-align: left; padding: 11px 14px; border: 1.5px solid var(--line); border-radius: var(--r); background: var(--surface); font-size: 13.5px; color: var(--ink-2); cursor: pointer; transition: all .15s; position: relative; }
.tx-engine button::before { content: "○"; margin-right: 8px; color: var(--muted); font-weight: 700; }
.tx-engine button.selected { border-color: var(--brand); background: var(--brand-50); color: var(--brand-ink); font-weight: 600; }
.tx-engine button.selected::before { content: "●"; color: var(--brand); }

/* —— 专线锁定状态：用户选中专线1/2后，界面明确提示“已锁定”，避免误以为仍会自动切线 —— */
.line-mode { gap: 8px; align-items: center; }
.line-state { font-style: normal; font-size: 12px; color: var(--muted); padding: 3px 8px; border-radius: 999px; background: var(--inset); border: 1px solid var(--line); white-space: nowrap; }
.line-state.locked { color: var(--brand-ink); background: var(--brand-50); border-color: var(--brand-100); font-weight: 650; }
.segmented button.selected { transform: translateY(-1px); }
.segmented button:active, .primary:active, .ghost:active, .send:active { filter: brightness(.96); }
.primary[disabled], .send[disabled], .ghost[disabled] { opacity: .65; cursor: not-allowed; transform: none !important; }


/* 中文锁字模式 */
.text-lock-panel{
  margin:8px 4px 0;
  padding:10px 12px;
  border:1px solid rgba(83,80,232,.18);
  border-radius:16px;
  background:linear-gradient(135deg, rgba(83,80,232,.08), rgba(0,190,255,.06));
  display:grid;
  gap:8px;
  transition:.18s ease;
}
.text-lock-panel.active{box-shadow:0 10px 28px rgba(83,80,232,.10);}
.text-lock-toggle{display:flex;align-items:center;gap:8px;font-weight:800;color:var(--text);cursor:pointer;user-select:none;}
.text-lock-toggle input{width:17px;height:17px;accent-color:var(--primary);}
.locked-text-input{
  width:100%;height:38px;border:1px solid rgba(120,130,170,.24);border-radius:12px;
  padding:0 12px;background:rgba(255,255,255,.82);outline:none;color:var(--text);
}
.locked-text-input:focus{border-color:rgba(83,80,232,.55);box-shadow:0 0 0 3px rgba(83,80,232,.10);}
.text-lock-panel small{color:var(--muted);font-size:12px;}

/* v27：用户上传图片直接显示在聊天气泡里，体验更像 ChatGPT */
.user-attach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 138px));
  gap: 9px;
  margin-bottom: 9px;
  justify-content: end;
}
.user-attach {
  position: relative;
  border-radius: 13px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.38);
  background: rgba(255,255,255,.14);
  box-shadow: 0 6px 14px rgba(0,0,0,.08);
}
.user-attach img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
}
.user-attach span {
  display: block;
  max-width: 100%;
  padding: 5px 7px;
  font-size: 11px;
  line-height: 1.2;
  color: rgba(255,255,255,.92);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(0,0,0,.16);
}

/* v27：中文锁字合并到对话输入区，不再要求单独填“标题/产品名” */
.text-lock-panel.compact-lock {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 4px 0 54px;
  padding: 7px 10px;
  border-radius: 12px;
}
.text-lock-panel.compact-lock small {
  flex: 1;
  text-align: right;
}
@media (max-width: 720px) {
  .text-lock-panel.compact-lock { margin-left: 0; flex-direction: column; align-items: flex-start; }
  .text-lock-panel.compact-lock small { text-align: left; }
  .user-attach-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ===================== 语音对话界面（ChatGPT 式） ===================== */
.voice-modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.voice-modal.hidden { display: none; }
.voice-bg { position: absolute; inset: 0; background: radial-gradient(120% 90% at 50% 25%, #2a2c5a 0%, #16182b 55%, #0e0f1d 100%); }
.voice-inner { position: relative; z-index: 1; width: 100%; max-width: 460px; padding: 32px 24px 40px; display: flex; flex-direction: column; align-items: center; text-align: center; color: #fff; }
.voice-title { font-size: 15px; letter-spacing: 2px; color: rgba(255,255,255,.55); margin-bottom: 30px; }
.voice-orb-wrap { width: 220px; height: 220px; display: flex; align-items: center; justify-content: center; margin-bottom: 28px; }
.voice-orb { width: 160px; height: 160px; border-radius: 50%; position: relative; background: radial-gradient(circle at 35% 30%, #8f8dff, #5350e8 60%, #3d3ac0); box-shadow: 0 0 60px rgba(99,96,240,.5); transition: transform .3s; }
.voice-orb-core { position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.55), transparent 55%); }
.voice-orb.listening { animation: orbBreath 2.4s ease-in-out infinite; }
.voice-orb.listening::before, .voice-orb.listening::after { content: ""; position: absolute; inset: -18px; border-radius: 50%; border: 2px solid rgba(143,141,255,.5); animation: orbRing 2s ease-out infinite; }
.voice-orb.listening::after { animation-delay: 1s; }
@keyframes orbRing { 0% { transform: scale(.85); opacity: .8; } 100% { transform: scale(1.5); opacity: 0; } }
@keyframes orbBreath { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.voice-orb.thinking { animation: orbSpin 1.1s linear infinite; }
.voice-orb.thinking::before { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 3px solid transparent; border-top-color: #b9b8ff; }
@keyframes orbSpin { to { transform: rotate(360deg); } }
.voice-orb.speaking { animation: orbSpeak .7s ease-in-out infinite; }
@keyframes orbSpeak { 0%,100% { transform: scale(1); box-shadow: 0 0 50px rgba(99,96,240,.45); } 50% { transform: scale(1.1); box-shadow: 0 0 80px rgba(143,141,255,.7); } }
.voice-orb.idle { filter: grayscale(.4) brightness(.8); }
.voice-status { font-size: 17px; font-weight: 600; margin-bottom: 12px; }
.voice-transcript { font-size: 15px; color: rgba(255,255,255,.72); min-height: 46px; line-height: 1.5; max-width: 360px; margin-bottom: 30px; }
.voice-controls { display: flex; gap: 40px; }
.voice-btn { display: flex; flex-direction: column; align-items: center; gap: 8px; background: none; border: 0; color: #fff; cursor: pointer; }
.voice-btn .vb-ic { width: 64px; height: 64px; border-radius: 50%; background: rgba(255,255,255,.14); display: flex; align-items: center; justify-content: center; font-size: 24px; transition: background .15s, transform .1s; }
.voice-btn:active .vb-ic { transform: scale(.92); }
.voice-btn.muted .vb-ic { background: rgba(255,255,255,.28); }
.voice-btn.hangup .vb-ic { background: #e2483b; }
.voice-btn label { font-size: 13px; color: rgba(255,255,255,.7); cursor: pointer; }
@media (prefers-reduced-motion: reduce) { .voice-orb, .voice-orb::before, .voice-orb::after { animation: none !important; } }


/* v50 集成：专业改字模型小框 */
.text-edit-model-badge { display:inline-flex; align-items:center; margin-left:8px; padding:4px 10px; border-radius:999px; font-size:12px; font-weight:750; color:var(--brand-ink); background:var(--brand-50); border:1px solid var(--brand-100); vertical-align:middle; }
.text-edit-model-badge::before { content:"AI"; display:inline-flex; align-items:center; justify-content:center; min-width:18px; height:16px; margin-right:5px; padding:0 4px; border-radius:999px; color:#fff; background:var(--brand); font-size:10px; line-height:1; }
/* v50 集成：作图记录批量删除 */
.history-toolbar { grid-column:1/-1; display:flex; align-items:center; gap:12px; margin-bottom:2px; padding:12px 14px; border:1px solid var(--line); border-radius:var(--r-lg); background:var(--surface); box-shadow:var(--sh-sm); }
.history-toolbar label { display:inline-flex; align-items:center; gap:6px; font-weight:650; color:var(--ink-2); }
.history-toolbar input, .history-check input { accent-color:var(--brand); }
.history-delete { border:0; border-radius:10px; padding:8px 13px; background:linear-gradient(135deg,#ef4444,#dc2626); color:#fff; font-weight:750; cursor:pointer; }
#historySelectCount { color:var(--muted); font-size:13px; }
.history-grid-inner { grid-column:1/-1; display:grid; grid-template-columns:repeat(auto-fill,minmax(190px,1fr)); gap:14px; }
.history-item { position:relative; }
.history-check { position:absolute; left:16px; top:16px; z-index:3; display:inline-flex; align-items:center; gap:5px; padding:6px 9px; border-radius:999px; background:rgba(255,255,255,.95); border:1px solid rgba(83,80,232,.18); color:var(--brand-ink); font-size:12px; font-weight:750; box-shadow:0 8px 20px rgba(15,23,42,.10); }
.history-actions { display:flex; align-items:center; gap:8px; }
/* v50 集成：双击图片放大 */
.image-preview-modal { position:fixed; inset:0; z-index:99999; display:block; }
.image-preview-modal.hidden { display:none; }
.image-preview-mask { position:absolute; inset:0; background:rgba(15,23,42,.72); backdrop-filter:blur(4px); }
.image-preview-panel { position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); max-width:92vw; max-height:92vh; padding:12px; border-radius:20px; background:#fff; box-shadow:0 30px 90px rgba(0,0,0,.35); }
.image-preview-panel img { display:block; max-width:88vw; max-height:84vh; object-fit:contain; border-radius:14px; }
.image-preview-close { position:absolute; right:-14px; top:-14px; width:36px; height:36px; border:0; border-radius:999px; background:var(--brand); color:#fff; font-size:24px; cursor:pointer; box-shadow:0 10px 26px rgba(83,80,232,.35); }
.img-card img, .history-item img, .cmp-img { cursor:zoom-in; }


/* v51 retry circle + edit loading */
.retry-circle{
  width:28px;
  height:28px;
  border-radius:999px !important;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:0 !important;
  font-size:16px;
  line-height:1;
}
.msg-actions{
  display:flex;
  align-items:center;
  gap:8px;
  margin-top:10px;
}
#editMsg .tx-spin{
  display:inline-block;
  width:14px;
  height:14px;
  border:2px solid rgba(99,102,241,.25);
  border-top-color:#6366f1;
  border-radius:50%;
  animation:xhspin .8s linear infinite;
  vertical-align:-2px;
  margin-right:6px;
}
@keyframes xhspin{
  from{transform:rotate(0)}
  to{transform:rotate(360deg)}
}

.v53-ecom-templates{
  margin:0 0 28px;
}
.v53-ecom-templates h3{
  margin:18px 0 12px;
  font-size:18px;
  font-weight:900;
}
.v53-ecom-templates h3:before{
  content:'';
  display:inline-block;
  width:4px;
  height:18px;
  background:#5b5cf6;
  border-radius:4px;
  margin-right:10px;
  vertical-align:-3px;
}
.v53-ecom-templates .tpl-card{
  cursor:pointer;
}

/* v54 强制新增电商模板 */
.v54-force-section {
  margin: 0 0 30px 0;
  padding: 4px 0 8px;
}
.v54-force-section h3 {
  margin: 18px 0 14px;
  font-size: 19px;
  font-weight: 900;
  color: #111827;
}
.v54-force-section h3:before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 19px;
  background: #5755f6;
  border-radius: 5px;
  margin-right: 10px;
  vertical-align: -3px;
}
.v54-force-card {
  cursor: pointer;
  border: 1px solid #dfe3ef !important;
  box-shadow: 0 12px 28px rgba(15, 23, 42, .06);
}
.v54-force-card h4 {
  font-size: 18px;
  font-weight: 900;
  margin-bottom: 8px;
}
.v54-force-card p {
  color: #667085;
  margin-bottom: 14px;
}
.v54-force-card b {
  color: #3937e8;
}

/* v56 移动端 / 平板 / 桌面自适应 */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}

img, video, canvas {
  max-width: 100%;
}

.xh-table-scroll {
  width: 100%;
  overflow-x: auto;
}

#xhMobileMenuBtn {
  display: none;
}

@media (max-width: 1024px) {
  .tpl-grid,
  .image-grid,
  .history-grid-inner {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .edit-layout,
  .edit-main,
  .tx-layout {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 768px) {
  body {
    width: 100%;
    overflow-x: hidden;
  }

  #xhMobileMenuBtn {
    display: flex;
    position: fixed;
    left: 12px;
    top: 12px;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 14px;
    align-items: center;
    justify-content: center;
    background: #5956f5;
    color: #fff;
    font-size: 22px;
    z-index: 9999;
    box-shadow: 0 10px 26px rgba(89, 86, 245, .35);
  }

  .sidebar {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    width: 82vw !important;
    max-width: 320px !important;
    z-index: 9998 !important;
    transform: translateX(-105%);
    transition: transform .22s ease;
    background: #fff;
    box-shadow: 20px 0 50px rgba(15, 23, 42, .22);
    overflow-y: auto;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .main,
  .content,
  .page,
  main {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
    box-sizing: border-box !important;
  }

  .topbar,
  header,
  .header {
    padding-left: 58px !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
  }

  .segmented {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    max-width: 100% !important;
    gap: 6px !important;
  }

  .segmented button {
    flex: 0 0 auto !important;
  }

  .tpl-grid,
  .image-grid,
  .history-grid-inner,
  .cards,
  .grid {
    grid-template-columns: 1fr !important;
  }

  .tpl-card,
  .bubble,
  .composer,
  .card,
  .panel,
  .edit-card,
  .edit-panel {
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .row,
  .row.ai,
  .row.user {
    max-width: 100% !important;
  }

  .bubble {
    font-size: 14px !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
  }

  .composer {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 30 !important;
    background: rgba(255,255,255,.96) !important;
    backdrop-filter: blur(12px);
    padding: 10px !important;
  }

  textarea,
  input,
  select {
    font-size: 16px !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  button,
  .primary,
  .send {
    min-height: 42px;
  }

  .tx-row {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .tx-arrow {
    display: none !important;
  }

  #editPreview,
  #editResult img,
  .cmp-img,
  .img-card img {
    max-width: 100% !important;
    height: auto !important;
  }

  .img-card {
    width: 100% !important;
  }

  .auth-card,
  .modal-card,
  .activate-card {
    width: calc(100vw - 28px) !important;
    max-width: calc(100vw - 28px) !important;
  }
}

@media (max-width: 480px) {
  .page {
    padding: 10px !important;
  }

  .tpl-card {
    padding: 15px !important;
    border-radius: 16px !important;
  }

  .bubble {
    padding: 12px !important;
    border-radius: 14px !important;
  }

  .topbar,
  header,
  .header {
    gap: 6px !important;
  }
}

/* v66 专线提示弹窗 */
.xh-line-notice-v66.hidden {
  display: none;
}

.xh-line-notice-v66 {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.xh-line-mask {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .48);
  backdrop-filter: blur(10px);
}

.xh-line-card {
  position: relative;
  width: min(520px, calc(100vw - 28px));
  background: #fff;
  border-radius: 24px;
  padding: 26px;
  box-shadow: 0 30px 90px rgba(15, 23, 42, .28);
  border: 1px solid rgba(226, 232, 240, .9);
  animation: xhLinePop .22s ease-out;
}

@keyframes xhLinePop {
  from {
    opacity: 0;
    transform: translateY(12px) scale(.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.xh-line-close {
  position: absolute;
  right: 16px;
  top: 14px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: #f3f4f6;
  color: #667085;
  font-size: 22px;
  cursor: pointer;
}

.xh-line-icon {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  background: linear-gradient(135deg, #5755f6, #7c3aed);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  box-shadow: 0 14px 28px rgba(87, 85, 246, .26);
  margin-bottom: 14px;
}

.xh-line-card h2 {
  margin: 0 0 10px;
  font-size: 24px;
  font-weight: 900;
  color: #111827;
}

.xh-line-desc {
  margin: 0 0 18px;
  color: #475467;
  line-height: 1.7;
  font-size: 15px;
}

.xh-line-desc b {
  color: #3937e8;
}

.xh-line-list {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.xh-line-item {
  padding: 13px 14px;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
}

.xh-line-item b {
  display: block;
  font-size: 16px;
  margin-bottom: 5px;
  color: #111827;
}

.xh-line-item span {
  color: #667085;
  font-size: 14px;
  line-height: 1.55;
}

.xh-line-item.good {
  border-color: rgba(34, 197, 94, .25);
  background: rgba(240, 253, 244, .75);
}

.xh-line-item.warn {
  border-color: rgba(245, 158, 11, .32);
  background: rgba(255, 251, 235, .85);
}

.xh-line-tip {
  margin: 14px 0 18px;
  padding: 12px 13px;
  border-radius: 14px;
  background: #f5f7ff;
  color: #4f46e5;
  font-size: 14px;
  line-height: 1.6;
}

.xh-line-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.xh-line-actions button,
.xh-line-know {
  border: 0;
  border-radius: 14px;
  height: 42px;
  cursor: pointer;
  font-weight: 800;
  background: #eef2ff;
  color: #3730a3;
}

.xh-line-actions button.primary {
  background: linear-gradient(135deg, #5755f6, #7c3aed);
  color: #fff;
}

.xh-line-know {
  width: 100%;
  margin-top: 12px;
  background: #f3f4f6;
  color: #344054;
}

@media (max-width: 640px) {
  .xh-line-card {
    padding: 22px 18px;
    border-radius: 22px;
  }

  .xh-line-actions {
    grid-template-columns: 1fr;
  }

  .xh-line-card h2 {
    font-size: 21px;
  }
}

/* v67 流畅运行优化 */
* {
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
}

body {
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

.messages,
#messages,
.history-list,
#historyList,
#editTextList {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.img-card img,
.file-thumb img,
.user-attach img,
#editPreview,
#editResult img {
  content-visibility: auto;
}

button,
.tpl-card,
.nav a,
.segmented button {
  will-change: transform;
}

@media (max-width: 768px) {
  body {
    overscroll-behavior-y: none;
  }

  .bubble,
  .tpl-card,
  .img-card {
    contain: layout paint;
  }
}

/* v69 语音通话模式 */
.xh-voice-float-v69 {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 99990;
  border: 0;
  border-radius: 999px;
  padding: 13px 18px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 18px 45px rgba(79, 70, 229, .34);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
}

.xh-voice-float-v69.listening {
  animation: xhVoicePulse 1.1s infinite;
  background: linear-gradient(135deg, #16a34a, #22c55e);
}

.xh-voice-float-v69.thinking {
  background: linear-gradient(135deg, #f97316, #f59e0b);
}

.xh-voice-float-v69.speaking {
  background: linear-gradient(135deg, #0891b2, #06b6d4);
}

@keyframes xhVoicePulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, .45);
  }

  70% {
    transform: scale(1.03);
    box-shadow: 0 0 0 14px rgba(34, 197, 94, 0);
  }

  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

.xh-voice-panel-v69.hidden {
  display: none;
}

.xh-voice-panel-v69 {
  position: fixed;
  right: 22px;
  bottom: 82px;
  z-index: 99991;
  width: min(430px, calc(100vw - 28px));
}

.xh-voice-card-v69 {
  position: relative;
  border-radius: 24px;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(14px);
  box-shadow: 0 26px 80px rgba(15, 23, 42, .28);
  border: 1px solid rgba(226, 232, 240, .95);
  padding: 20px;
}

.xh-voice-close-v69 {
  position: absolute;
  right: 14px;
  top: 12px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: #f3f4f6;
  color: #475467;
  font-size: 22px;
  cursor: pointer;
}

.xh-voice-head-v69 {
  display: flex;
  gap: 13px;
  align-items: center;
  margin-bottom: 14px;
}

.xh-voice-orb-v69 {
  width: 52px;
  height: 52px;
  border-radius: 19px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 14px 32px rgba(79, 70, 229, .25);
}

.xh-voice-head-v69 h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 900;
  color: #111827;
}

.xh-voice-head-v69 p {
  margin: 4px 0 0;
  color: #667085;
  font-size: 14px;
}

.xh-voice-live-v69 {
  min-height: 82px;
  padding: 14px;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  color: #344054;
  line-height: 1.65;
  font-size: 15px;
}

.xh-voice-live-v69 b {
  color: #111827;
}

.xh-voice-live-v69 span {
  color: #667085;
  margin-left: 4px;
}

.xh-voice-options-v69 {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  color: #475467;
  font-size: 14px;
}

.xh-voice-options-v69 label {
  display: flex;
  gap: 8px;
  align-items: center;
}

.xh-voice-actions-v69 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 9px;
}

.xh-voice-actions-v69 button {
  height: 42px;
  border: 0;
  border-radius: 14px;
  background: #eef2ff;
  color: #3730a3;
  font-weight: 900;
  cursor: pointer;
}

.xh-voice-actions-v69 button.primary {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
}

.xh-voice-note-v69 {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 13px;
  line-height: 1.55;
}

.xh-v69-toast {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(-18px);
  z-index: 100001;
  background: #111827;
  color: #fff;
  padding: 11px 16px;
  border-radius: 999px;
  box-shadow: 0 16px 42px rgba(15, 23, 42, .25);
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition: .22s ease;
  max-width: min(680px, calc(100vw - 28px));
  text-align: center;
}

.xh-v69-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.xh-v69-toast.error {
  background: #dc2626;
}

.xh-v69-toast.warn {
  background: #ea580c;
}

@media (max-width: 640px) {
  .xh-voice-float-v69 {
    right: 16px;
    bottom: 16px;
  }

  .xh-voice-panel-v69 {
    left: 14px;
    right: 14px;
    bottom: 72px;
    width: auto;
  }

  .xh-voice-actions-v69 {
    grid-template-columns: 1fr;
  }
}
