/* 表情包工作室 · AI 客服页
   颜色、圆角和阴影都走变量；深色模式只改变量。 */
:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f2f2f7;
  --surface-3: #e8e8ed;
  --sidebar: #efeff3;
  --ink: #1d1d1f;
  --ink-2: #3a3a3f;
  --muted: #6e6e73;
  --faint: #8e8e93;
  --line: #e3e3e8;
  --line-strong: #d1d1d6;
  --accent: #0071e3;
  --accent-hover: #0062c4;
  --accent-ink: #0060c0;
  --accent-soft: #eaf3ff;
  --on-accent: #ffffff;
  --user-bubble: #0071e3;
  --green: #1f8a4c;
  --green-soft: #e8f5ec;
  --red: #c4372d;
  --red-soft: #fdeceb;
  --focus: #7db4ff;
  --check-a: #f0f0f2;
  --check-b: #ffffff;
  --scrim: rgba(18, 18, 22, .38);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-md: 0 6px 24px rgba(0, 0, 0, .06);
  --shadow-lg: 0 24px 80px rgba(0, 0, 0, .18);
  --glass: rgba(255, 255, 255, .82);
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 26px;
  --top-h: 60px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --surface-3: #3a3a3c;
    --sidebar: #111113;
    --ink: #f5f5f7;
    --ink-2: #d1d1d6;
    --muted: #a1a1a6;
    --faint: #8e8e93;
    --line: #2c2c2e;
    --line-strong: #3a3a3c;
    --accent: #0a84ff;
    --accent-hover: #3395ff;
    --accent-ink: #5eaaff;
    --accent-soft: #0a2440;
    --user-bubble: #0a84ff;
    --green: #32d74b;
    --green-soft: #0f2b17;
    --red: #ff6961;
    --red-soft: #3a1513;
    --focus: #3d8bff;
    --check-a: #2a2a2d;
    --check-b: #1f1f22;
    --scrim: rgba(0, 0, 0, .6);
    --shadow-md: 0 6px 24px rgba(0, 0, 0, .4);
    --shadow-lg: 0 24px 80px rgba(0, 0, 0, .6);
    --glass: rgba(22, 22, 24, .8);
  }
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; height: 100dvh; overflow: hidden; color: var(--ink); background: var(--bg);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
input, textarea, select { font-size: 16px; } /* iOS 小于 16px 会自动放大 */
a { color: var(--accent-ink); }
[hidden] { display: none !important; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1, h2, h3 { letter-spacing: -.02em; }

button {
  min-height: 44px; padding: 9px 16px; cursor: pointer; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
button:hover:not(:disabled) { background: var(--surface-2); }
button:active:not(:disabled) { transform: scale(.98); }
button:disabled { opacity: .42; cursor: default; }
button:focus-visible, a:focus-visible, textarea:focus-visible, input:focus-visible, select:focus-visible, .chat-scroll:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.primary { color: var(--on-accent); background: var(--accent); border-color: var(--accent); font-weight: 600; }
.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.primary span { font-weight: 400; opacity: .88; }
.secondary { background: var(--surface-2); border-color: transparent; font-size: 14px; }
.secondary:hover:not(:disabled) { background: var(--surface-3); }
.quiet { min-height: 36px; padding: 6px 10px; border: 0; background: transparent; color: var(--muted); font-size: 13px; border-radius: var(--r-sm); }
.quiet:hover:not(:disabled) { color: var(--ink); background: var(--surface-2); }
.quiet svg { width: 17px; height: 17px; }
.icon-button { width: 40px; height: 40px; min-height: 40px; padding: 0; flex: none; border-radius: 50%; }
.danger-text { color: var(--red); }
.danger-button { color: #fff; background: var(--red); border-color: var(--red); font-weight: 600; }
.danger-button:hover:not(:disabled) { background: var(--red); filter: brightness(.94); }
.grow { flex: 1; }
.muted { color: var(--muted); }
.fine-print { font-size: 12px !important; line-height: 1.6; color: var(--muted); margin: 12px 0 0 !important; }
.error-text { color: var(--red); }
.success-text { color: var(--green); }
.checker { background: repeating-conic-gradient(var(--check-a) 0% 25%, var(--check-b) 0% 50%) 50% / 16px 16px; }

/* ---------- 顶栏 ---------- */
.top {
  position: relative; z-index: 20; height: var(--top-h); display: flex; align-items: center; gap: 12px; padding: 0 20px;
  background: var(--glass); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 650; font-size: 16px; letter-spacing: -.02em; }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: #fff; background: linear-gradient(145deg, #2b8cff, #0060df); box-shadow: inset 0 0 0 .5px rgba(255,255,255,.25); }
.brand-mark svg { width: 22px; height: 22px; stroke-width: 1.7; }
.brand-mark.big { width: 64px; height: 64px; border-radius: 18px; }
.brand-mark.big svg { width: 40px; height: 40px; }
.classic-link { font-size: 13px; color: var(--muted); text-decoration: none; padding: 8px 6px; }
.classic-link:hover { color: var(--ink); }
.points { height: 34px; min-height: 34px; line-height: 1; padding: 0 12px; border: 0; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.points b { font-weight: 650; color: var(--ink); }
.points.low b { color: var(--red); }
#history-toggle { display: none; border: 0; background: transparent; }

/* ---------- 布局 ---------- */
.workspace { display: grid; grid-template-columns: 264px minmax(0, 1fr); height: calc(100dvh - var(--top-h)); }
.history-backdrop { display: none; }
aside { display: flex; flex-direction: column; gap: 8px; min-height: 0; padding: 20px 14px 16px; background: var(--sidebar); border-right: 1px solid var(--line); }
aside > button { width: 100%; font-size: 14px; }
aside > button svg { width: 18px; height: 18px; }
#open-projects { background: var(--surface); }
aside h2 { font-size: 12px; font-weight: 600; color: var(--faint); margin: 18px 8px 2px; letter-spacing: 0; }
#sessions { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -6px; padding: 0 6px; scrollbar-width: thin; }
.session-row { position: relative; margin: 2px 0; }
.session {
  width: 100%; min-height: 56px; justify-content: flex-start; gap: 10px; text-align: left; padding: 8px 40px 8px 8px;
  border-color: transparent; background: transparent; border-radius: 12px; font-weight: 400;
}
.session:hover:not(:disabled) { background: rgba(127, 127, 127, .1); }
.session.on { background: var(--surface); box-shadow: var(--shadow-sm); }
.session-thumb { width: 40px; height: 40px; border-radius: 10px; flex: none; object-fit: contain; background: var(--surface); border: 1px solid var(--line); }
.session-thumb.empty { display: grid; place-items: center; color: var(--faint); }
.session-thumb.empty svg { width: 18px; height: 18px; }
.session-text { min-width: 0; display: grid; }
.session-text b { font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-text small { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-text small i { font-style: normal; color: var(--accent-ink); }
.session-text small i.done { color: var(--green); }
.session-delete { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; min-height: 30px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--faint); opacity: 0; }
.session-delete svg { width: 15px; height: 15px; }
.session-row:hover .session-delete, .session-delete:focus-visible { opacity: 1; }
.session-delete:hover:not(:disabled) { color: var(--red); background: var(--red-soft); transform: translateY(-50%); }
.sessions-empty { font-size: 13px; color: var(--muted); padding: 8px; }
.history-classic { font-size: 13px; color: var(--muted); text-decoration: none; padding: 10px 8px 0; border-top: 1px solid var(--line); }
.history-classic:hover { color: var(--ink); }

main { min-height: 0; min-width: 0; display: flex; flex-direction: column; position: relative; }
.conversation-head { display: flex; align-items: center; gap: 4px; width: 100%; max-width: 860px; margin: 0 auto; padding: 18px 28px 10px; }
.conversation-title { flex: 1; min-width: 0; }
.conversation-head h1 { font-size: 20px; font-weight: 650; margin: 0; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-head p { color: var(--muted); font-size: 13px; margin: 2px 0 0; }

/* 流程：一条分段进度，当前步骤带文字 */
.flow-steps { list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; width: 100%; max-width: 860px; margin: 0 auto; padding: 0 28px 14px; border-bottom: 1px solid var(--line); }
.flow-steps li { display: grid; gap: 6px; font-size: 12px; color: var(--faint); min-width: 0; }
.flow-steps li::before { content: ""; height: 4px; border-radius: 4px; background: var(--surface-3); }
.flow-steps li.done { color: var(--muted); }
.flow-steps li.done::before { background: var(--accent); opacity: .45; }
.flow-steps li.current { color: var(--accent-ink); font-weight: 600; }
.flow-steps li.current::before { background: var(--accent); }
.flow-steps span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 对话 ---------- */
.chat-scroll { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.chat-scroll:focus { outline: none; }
.chat-scroll.dragging { outline: 2px dashed var(--accent); outline-offset: -10px; background: var(--accent-soft); }
.chat-content { max-width: 800px; margin: 0 auto; padding: 24px 28px 20px; }
.messages { display: grid; gap: 20px; }
.message { min-width: 0; max-width: 88%; justify-self: start; display: grid; gap: 6px; }
.message.user { justify-self: end; max-width: 78%; }
.message-name { font-size: 12px; color: var(--faint); margin-left: 4px; }
.message.user .message-name { display: none; }
.bubble { padding: 11px 16px; border-radius: 20px 20px 20px 6px; background: var(--surface); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; box-shadow: var(--shadow-sm); }
.user .bubble { background: var(--user-bubble); color: #fff; border-radius: 20px 20px 6px 20px; justify-self: end; }
.message-photos { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.message-photos button { width: 76px; height: 76px; padding: 0; border-radius: 12px; overflow: hidden; border: 0; background: rgba(255,255,255,.9); }
.message-photos img { width: 100%; height: 100%; object-fit: cover; }
.typing { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); animation: typing-dot 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
.typing span { font-size: 13px; margin-left: 8px; }
@keyframes typing-dot { 50% { opacity: .3; transform: translateY(-3px); } }

.quick-replies { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.quick-replies button { min-height: 36px; padding: 6px 14px; font-size: 14px; border-radius: 99px; background: var(--surface); border-color: var(--line); color: var(--accent-ink); }
.quick-replies button:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.inline-recommendations { max-width: 460px; margin-top: 6px; }

/* ---------- 工作卡片 ---------- */
.work-card { margin-top: 22px; padding: 26px; border-radius: var(--r-xl); background: var(--surface); box-shadow: var(--shadow-md); overflow: hidden; animation: card-in .25s ease-out; }
@keyframes card-in { from { opacity: 0; transform: translateY(6px); } }
.work-card h2 { font-size: 20px; line-height: 1.4; margin: 0 0 8px; font-weight: 650; }
.work-card > p, .work-card .lead { font-size: 14px; color: var(--muted); margin: 6px 0 0; line-height: 1.7; }
.card-eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.card-eyebrow.success-text { color: var(--green); }
.card-eyebrow.error-text { color: var(--red); }
.welcome-symbol { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 16px; background: var(--accent-soft); color: var(--accent); margin-bottom: 16px; }
.welcome-symbol svg { width: 28px; height: 28px; }
.welcome-tips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 18px 0 0; padding: 0; list-style: none; counter-reset: tip; }
.welcome-tips li { counter-increment: tip; padding: 12px; border-radius: var(--r-md); background: var(--surface-2); font-size: 13px; line-height: 1.5; color: var(--ink-2); }
.welcome-tips li::before { content: counter(tip); display: grid; place-items: center; width: 20px; height: 20px; margin-bottom: 6px; border-radius: 50%; background: var(--surface); color: var(--accent-ink); font-size: 11px; font-weight: 700; }
.card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 18px; }
.next-action { min-height: 48px; padding: 12px 20px; font-size: 15px; border-radius: var(--r-md); }
.reference-strip { display: flex; align-items: center; gap: 8px; margin: 12px 0; font-size: 13px; color: var(--muted); }
.reference-strip .image-button { width: 52px; height: 52px; flex: none; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); }
.reference-strip .image-button img { object-fit: cover; }
.image-button { min-height: 0; padding: 0; border: 0; background: transparent; display: block; overflow: hidden; }
.image-button:hover:not(:disabled) { background: transparent; }
.image-button img { display: block; width: 100%; height: 100%; object-fit: contain; }
.character-preview { width: 260px; height: 260px; max-width: 100%; margin: 16px auto; border-radius: var(--r-lg); background: repeating-conic-gradient(var(--check-a) 0% 25%, var(--check-b) 0% 50%) 50% / 16px 16px; }
.edit-preview { width: 160px; height: 160px; margin: 14px auto; border-radius: var(--r-md); background: repeating-conic-gradient(var(--check-a) 0% 25%, var(--check-b) 0% 50%) 50% / 14px 14px; }
.cell-preview { width: 320px; height: 320px; max-width: 100%; margin: 0 auto 10px; border-radius: var(--r-lg); background: repeating-conic-gradient(var(--check-a) 0% 25%, var(--check-b) 0% 50%) 50% / 16px 16px; }
.work-card blockquote { margin: 12px 0; padding: 12px 14px; border-radius: var(--r-md); background: var(--accent-soft); font-size: 14px; overflow-wrap: anywhere; }
.brief-summary { margin: 14px 0 0; display: grid; gap: 0; font-size: 14px; border-radius: var(--r-md); background: var(--surface-2); padding: 4px 14px; }
.brief-summary > div { display: flex; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.brief-summary > div:last-child { border-bottom: 0; }
.brief-summary dt { color: var(--muted); flex: none; min-width: 32px; }
.brief-summary dd { margin: 0; overflow-wrap: anywhere; }
.caption-summary { font-size: 13px !important; line-height: 1.9 !important; }
.paid-note { display: flex; align-items: center; gap: 6px; }

/* 完成：九宫格与导出 */
.result-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.result-heading h2 { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-heading select { max-width: 46%; }
.grid9 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; max-width: 440px; margin: 16px auto 4px; }
.cell { position: relative; min-width: 0; min-height: 0; padding: 4px; border-radius: 16px; border: 1px solid var(--line); background: repeating-conic-gradient(var(--check-a) 0% 25%, var(--check-b) 0% 50%) 50% / 14px 14px; display: block; }
.cell:hover:not(:disabled) { border-color: var(--accent); background: repeating-conic-gradient(var(--check-a) 0% 25%, var(--check-b) 0% 50%) 50% / 14px 14px; }
.cell img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; }
.cell .cell-no { position: absolute; top: 6px; left: 6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 11px; line-height: 20px; font-weight: 600; }
.cell .cell-flag { position: absolute; right: 6px; top: 6px; padding: 0 6px; height: 20px; line-height: 20px; border-radius: 10px; font-size: 11px; color: #fff; background: var(--red); }
.cell .cell-flag.busy { background: var(--accent); }
.result-primary { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 18px; }
.result-primary .next-action { width: 100%; }
.export-panel { margin-top: 14px; padding: 14px; border-radius: var(--r-lg); background: var(--surface-2); }
.export-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.export-row + .export-row { margin-top: 10px; }
.export-label { font-size: 13px; color: var(--muted); margin-right: 2px; }
.export-panel .secondary { background: var(--surface); min-height: 40px; padding: 7px 14px; }
.export-panel .secondary:hover:not(:disabled) { background: var(--surface-3); }
.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--surface-3); }
.seg button { min-height: 32px; padding: 4px 12px; border: 0; border-radius: 8px; background: transparent; font-size: 13px; color: var(--muted); }
.seg button:hover:not(:disabled) { background: transparent; color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* 进度 */
.progress-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.progress-heading h2 { margin: 0; }
.progress-time { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); white-space: nowrap; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); }
.generation-track { height: 8px; position: relative; background: var(--surface-3); overflow: hidden; border-radius: 8px; margin: 18px 0 12px; }
.generation-fill, .generation-active { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 8px; }
.generation-fill { background: var(--accent); transition: width .4s; }
.generation-active { width: 25%; background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 200% 100%; animation: generation-pulse 1.4s linear infinite; }
@keyframes generation-pulse { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.generation-steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; font-size: 12px; color: var(--faint); }
.generation-steps .done { color: var(--green); }
.generation-steps .current { color: var(--accent-ink); font-weight: 600; }

/* 画风卡片 */
.styles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.style-card { min-width: 0; min-height: 0; display: grid; gap: 6px; padding: 8px; font-size: 13px; text-align: center; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.style-card img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; border-radius: 10px; }
.style-card span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.style-card.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

/* ---------- 输入框 ---------- */
.composer { flex: none; width: 100%; max-width: 800px; margin: 0 auto; padding: 10px 28px calc(12px + env(safe-area-inset-bottom)); }
.input-shell { display: flex; align-items: flex-end; gap: 8px; padding: 6px; border: 1px solid var(--line-strong); border-radius: 26px; background: var(--surface); box-shadow: var(--shadow-md); transition: border-color .15s, box-shadow .15s; }
.input-shell:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent), var(--shadow-md); }
.input-shell textarea { flex: 1; min-width: 0; min-height: 40px; max-height: 140px; padding: 8px 2px; border: 0; background: transparent; outline: none; resize: none; line-height: 1.5; }
.input-shell textarea:focus-visible { outline: none; }
.input-shell .attach { border: 0; background: var(--surface-2); color: var(--ink-2); }
.input-shell .send { width: 40px; height: 40px; min-height: 40px; padding: 0; border-radius: 50%; }
.input-shell .send svg { width: 20px; height: 20px; stroke-width: 2.2; }
.composer-footer { display: flex; gap: 10px; justify-content: space-between; font-size: 12px; color: var(--faint); margin-top: 8px; padding: 0 12px; }
.composer-footer > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-hint { white-space: nowrap; }
.edit-context { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0 14px; padding: 6px 6px 6px 14px; background: var(--accent-soft); color: var(--accent-ink); font-size: 13px; font-weight: 500; border-radius: 14px 14px 0 0; }
.edit-context img { width: 28px; height: 28px; border-radius: 6px; object-fit: contain; background: var(--surface); }
.edit-context span { flex: 1; display: flex; align-items: center; gap: 8px; }
.edit-context button { width: 30px; height: 30px; min-height: 30px; padding: 0; border: 0; background: transparent; color: inherit; border-radius: 50%; }
.edit-context button svg { width: 16px; height: 16px; }
.send-error { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--red); font-size: 13px; padding: 4px 12px 8px; }
.send-error button { min-height: 30px; padding: 2px 10px; color: inherit; border-color: currentColor; background: transparent; border-radius: 99px; font-size: 12px; }
.new-update { position: absolute; bottom: 118px; left: 50%; transform: translateX(-50%); min-height: 36px; padding: 6px 14px; font-size: 13px; border-radius: 99px; box-shadow: var(--shadow-md); z-index: 3; }
.new-update:active:not(:disabled) { transform: translateX(-50%) scale(.98); }
.new-update svg { width: 16px; height: 16px; }

/* ---------- 弹层 ---------- */
select { min-height: 36px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); font-size: 14px; }
dialog { color: var(--ink); background: var(--surface); width: min(92vw, 620px); max-height: 86dvh; border: 0; border-radius: 26px; padding: 22px 24px 24px; box-shadow: var(--shadow-lg); overscroll-behavior: contain; }
dialog[open] { animation: dialog-in .2s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
dialog::backdrop { background: var(--scrim); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; font-size: 18px; }
.dialog-head b { font-weight: 650; letter-spacing: -.02em; }
.dialog-head .icon-button, .zoom-close { width: 34px; height: 34px; min-height: 34px; border: 0; background: var(--surface-2); color: var(--muted); }
.dialog-head .icon-button svg, .zoom-close svg { width: 18px; height: 18px; }
#picker-content { overflow-wrap: anywhere; }
#picker-content h3 { font-size: 14px; color: var(--muted); font-weight: 600; margin: 18px 0 10px; }
#picker-content h3:first-child { margin-top: 0; }
#picker-content p { margin: 0 0 10px; }
.search { width: 100%; min-height: 44px; border: 0; border-radius: 12px; padding: 10px 14px; background: var(--surface-2); outline: none; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 14px; }
.filters button { min-height: 32px; font-size: 13px; padding: 4px 12px; border: 0; border-radius: 99px; background: var(--surface-2); }
.filters .on, .filters .on:hover:not(:disabled) { background: var(--ink); color: var(--surface); }
.project-row { display: flex; align-items: center; justify-content: flex-start; gap: 12px; width: 100%; text-align: left; margin: 8px 0; padding: 10px; border-radius: 16px; font-weight: 400; }
.project-row img { width: 56px; height: 56px; object-fit: contain; flex: none; border-radius: 12px; background: var(--surface-2); }
.project-row b { font-weight: 600; }
.project-row small { display: block; color: var(--muted); font-size: 12px; }
.project-row .kit-emoji { font-size: 26px; width: 40px; text-align: center; flex: none; }
.photos { display: flex; gap: 10px; flex-wrap: wrap; }
.photos .image-button { width: 110px; height: 110px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.attachment-option { display: grid; justify-items: start; gap: 2px; text-align: left; width: 100%; padding: 16px 18px; margin: 0 0 10px; border-radius: 18px; }
.attachment-option b { font-weight: 600; }
.attachment-option span { font-size: 13px; color: var(--muted); font-weight: 400; }
#zoom { width: auto; max-width: min(92vw, 820px); padding: 12px; background: var(--surface); }
#zoom-img { display: block; max-width: 100%; max-height: 78dvh; margin: 0 auto; border-radius: 14px; background: repeating-conic-gradient(var(--check-a) 0% 25%, var(--check-b) 0% 50%) 50% / 16px 16px; }
.zoom-close { position: absolute; top: 20px; right: 20px; z-index: 1; background: var(--glass); }

.account-card { display: grid; gap: 4px; padding: 16px; border-radius: 18px; background: var(--surface-2); }
.account-card .balance { font-size: 34px; font-weight: 700; letter-spacing: -.03em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.account-card small { color: var(--muted); }
.account-code { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .06em; }
.account-code button { background: var(--surface); min-height: 32px; padding: 4px 12px; font-size: 13px; font-family: inherit; letter-spacing: 0; }
.cost-table { width: 100%; border-collapse: collapse; margin: 14px 0 6px; font-size: 14px; }
.cost-table td { padding: 10px 0; border-bottom: 1px solid var(--line); }
.cost-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.contact-box { padding: 12px 14px; border-radius: 14px; background: var(--accent-soft); white-space: pre-wrap; font-size: 14px; }

/* 保存到相册 */
.photo-save-guide { text-align: center; margin: 4px 0 14px; }
.photo-save-guide b { font-size: 16px; }
.photo-save-guide p { font-size: 14px; color: var(--muted); margin: 6px 0 !important; line-height: 1.8; }
.photo-save-image { display: block; width: auto; height: auto; max-width: 100%; max-height: 46dvh; margin: 0 auto; border-radius: 18px; background: repeating-conic-gradient(var(--check-a) 0% 25%, var(--check-b) 0% 50%) 50% / 16px 16px; -webkit-touch-callout: default; user-select: auto; -webkit-user-select: auto; }
.save-nav { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.original-link { display: inline-flex; align-items: center; min-height: 44px; padding: 9px 16px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); text-decoration: none; font-size: 15px; font-weight: 500; color: var(--ink); }

/* 生成前的内容方案 */
.plan-invitation { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 18px; }
.plan-invitation b { font-size: 14px; font-weight: 600; }
.plan-invitation p { color: var(--muted); font-size: 13px; }
.plan-details, .plan-brief { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 12px; }
.plan-details summary, .plan-brief summary { min-height: 44px; padding: 10px 0; color: var(--accent-ink); cursor: pointer; font-size: 14px; font-weight: 500; }
.plan-warning { padding: 12px 14px; background: var(--surface-2); border-radius: 12px; font-size: 13px; line-height: 1.6; }
.sticker-plan { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 10px; }
.plan-item { display: flex; align-items: flex-start; gap: 10px; padding: 14px 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.plan-number { flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.plan-copy { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.plan-copy b { display: block; font-size: 15px; font-weight: 600; line-height: 1.6; }
.plan-intent { display: block; margin-top: 3px; font-size: 12px; color: var(--accent-ink); }
.plan-copy p { margin: 5px 0 0; font-size: 13px; line-height: 1.65; color: var(--ink-2); }
.plan-edit { flex: none; min-width: 44px; min-height: 44px; padding: 8px 4px; color: var(--accent-ink); font-size: 13px; }
.plan-edit-form { display: grid; gap: 10px; }
.plan-edit-form label { font-size: 14px; font-weight: 600; }
.plan-edit-form label span { display: block; font-size: 12px; font-weight: 400; color: var(--muted); margin-top: 4px; }
.plan-edit-form input, .plan-edit-form textarea { display: block; width: 100%; box-sizing: border-box; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface-2); color: var(--ink); font: inherit; font-size: 16px; line-height: 1.6; }
.plan-edit-form textarea { resize: vertical; min-height: 120px; }
.plan-edit-form .error-text:empty { display: none; }

/* ---------- 登录 ---------- */
.login { max-width: 420px; margin: 0 auto; padding: max(8vh, 40px) 24px 32px; text-align: center; height: calc(100dvh - var(--top-h)); overflow: auto; }
.login h1 { font-size: 30px; line-height: 1.3; letter-spacing: -.03em; margin: 22px 0 12px; }
.login > p { color: var(--muted); font-size: 15px; line-height: 1.8; margin: 0; }
.login-form { display: grid; gap: 12px; margin: 28px 0 8px; }
.login-form input { width: 100%; min-height: 56px; padding: 12px 16px; border: 1px solid var(--line-strong); border-radius: 16px; background: var(--surface); text-align: center; font-size: 20px; letter-spacing: .12em; font-family: ui-monospace, "SF Mono", Menlo, monospace; outline: none; }
.login-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent); }
.login-form .primary { min-height: 52px; font-size: 16px; border-radius: 16px; }
.login-error { color: var(--red); font-size: 14px; min-height: 1.4em; margin: 0 !important; }
.login-contact { font-size: 14px; color: var(--ink-2) !important; white-space: pre-wrap; }
.login small { display: block; margin-top: 18px; font-size: 13px; color: var(--muted); line-height: 1.7; }

#notice { position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); transform: translate(-50%, 8px); max-width: min(90vw, 440px); background: rgba(29, 29, 31, .94); color: #fff; border-radius: 14px; padding: 10px 16px; opacity: 0; pointer-events: none; z-index: 60; font-size: 14px; text-align: center; transition: opacity .2s, transform .2s; }
#notice.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 手机 ---------- */
@media (max-width: 760px) {
  :root { --top-h: 52px; }
  .top { padding: 0 8px 0 4px; gap: 4px; }
  #history-toggle { display: inline-flex; width: 44px; height: 44px; }
  .brand { font-size: 15px; gap: 8px; }
  .brand-mark { width: 28px; height: 28px; border-radius: 8px; }
  .brand-mark svg { width: 18px; height: 18px; }
  .classic-link { display: none; }
  .workspace { display: block; }
  main { height: 100%; }
  aside { position: fixed; left: 0; top: 0; bottom: 0; z-index: 40; width: min(300px, 84vw); padding: calc(16px + env(safe-area-inset-top)) 14px calc(16px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg); transform: translateX(-102%); transition: transform .25s ease; visibility: hidden; }
  aside.open { transform: none; visibility: visible; }
  .history-backdrop { display: block; position: fixed; inset: 0; z-index: 39; min-height: 0; border: 0; border-radius: 0; background: var(--scrim); }
  .session-delete { opacity: 1; }
  .conversation-head { padding: 10px 12px 6px 16px; }
  .conversation-head h1 { font-size: 17px; }
  .conversation-head p { font-size: 12px; margin-top: 0; }
  .conversation-head .quiet span { display: none; }
  .conversation-head .quiet { width: 40px; height: 40px; padding: 0; border-radius: 50%; }
  .conversation-head .quiet svg { width: 20px; height: 20px; }
  .flow-steps { padding: 0 16px 10px; gap: 4px; }
  .flow-steps li { font-size: 11px; gap: 4px; }
  .flow-steps li::before { height: 3px; }
  .chat-content { padding: 16px 14px 14px; }
  .messages { gap: 16px; }
  .message { max-width: 94%; }
  .message.user { max-width: 86%; }
  .bubble { padding: 10px 14px; }
  .work-card { padding: 20px 18px; border-radius: 22px; margin-top: 18px; }
  .work-card h2 { font-size: 18px; }
  .welcome-tips { grid-template-columns: 1fr; gap: 6px; }
  .welcome-tips li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
  .welcome-tips li::before { margin: 0; flex: none; }
  .character-preview { width: 220px; height: 220px; }
  .card-actions { gap: 8px; }
  .card-actions .next-action { flex: 1 1 100%; }
  .grid9 { gap: 6px; }
  .cell { padding: 2px; border-radius: 12px; }
  .cell .cell-no { top: 4px; left: 4px; }
  .result-primary { grid-template-columns: 1fr; }
  .composer { padding: 6px 10px calc(8px + env(safe-area-inset-bottom)); }
  .composer-footer { padding: 0 8px; font-size: 11px; margin-top: 6px; }
  .composer-hint { display: none; }
  .new-update { bottom: 96px; }
  dialog:not(#zoom) { width: 100%; max-width: 100%; max-height: 90dvh; margin: auto 0 0; inset: auto 0 0; border-radius: 26px 26px 0 0; padding: 18px 18px calc(20px + env(safe-area-inset-bottom)); }
  dialog:not(#zoom)[open] { animation: sheet-in .25s ease-out; }
  .styles { gap: 8px; }
  .login { padding-top: 6vh; }
  .login h1 { font-size: 26px; }
  #notice { bottom: calc(96px + env(safe-area-inset-bottom)); }
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: .6; } }
@media (hover: none) { .session-delete { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* 一次生成的九个主体候选 */
.character-candidates { max-width: 540px; margin-inline: auto; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-block: 18px 12px; text-align: left; }
.candidate-tile { position: relative; min-width: 0; border: 2px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--surface); }
.candidate-tile.selected { border-color: var(--accent); background: var(--accent-soft); }
.candidate-choose { display: block; width: 100%; padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--ink); cursor: pointer; text-align: center; }
.candidate-image { display: block; position: relative; width: 100%; aspect-ratio: 1; background: repeating-conic-gradient(var(--check-a) 0% 25%, var(--check-b) 0% 50%) 50% / 14px 14px; }
.candidate-image img { display: block; width: 100%; height: 100%; object-fit: contain; }
.candidate-number, .candidate-check { position: absolute; top: 5px; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 7px; font-size: 12px; font-weight: 600; }
.candidate-number { left: 5px; background: var(--surface); color: var(--muted); }
.candidate-check { right: 5px; background: var(--accent); color: #fff; }
.candidate-direction { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 5px 44px 5px 4px; font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.candidate-zoom { position: absolute; right: 0; bottom: 0; display: block; width: 44px; height: 44px; min-height: 44px; padding: 5px; border: 0; border-radius: 0; background: transparent; color: var(--accent-ink); cursor: pointer; font-size: 12px; }
.candidate-selection { font-size: 13px; line-height: 1.6; color: var(--accent-ink); }
.character-history { text-align: left; margin-top: 18px; }
.character-history summary { min-height: 44px; padding: 12px 0; cursor: pointer; color: var(--accent-ink); font-size: 14px; }
.character-history-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.character-history-item { min-width: 0; padding: 5px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); cursor: pointer; }
.character-history-item.on { border-color: var(--accent); }
.character-history-item img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; background: repeating-conic-gradient(var(--check-a) 0% 25%, var(--check-b) 0% 50%) 50% / 14px 14px; border-radius: 8px; }
.character-history-item span { display: block; padding: 6px 0; font-size: 12px; overflow-wrap: anywhere; }
@media (max-width: 430px) { .character-candidates { gap: 6px; } .candidate-tile { border-radius: 12px; } .candidate-direction { font-size: 11px; } }
@media (min-width: 761px) { .character-candidates { max-width: min(540px, max(360px, calc(100dvh - 420px))); } }
