/* ============================================================
   美希 · 智能运营官
   设计：全屏米底（无卡片）+ 左人像右对话 + 气泡从人像"说出"
   ============================================================ */

:root {
  /* 颜色 */
  --bg: #f2ece4;
  --bg-soft: #f5efe6;
  --bg-subtle: #ede3d4;

  --bubble-user: #e6d8c8;
  --bubble-ai: #ffffff;
  --bubble-greeting: #efe4d2;

  --border: #e0d4c0;
  --border-soft: #ece2cf;
  --border-strong: #c9b99f;

  --text: #333333;
  --text-secondary: #6f6960;
  --text-muted: #a29a8f;

  --accent: #c8b7a6;
  --accent-hover: #b29f8f;
  --accent-ink: #7a6b5d;
  --accent-tint: #ede3d4;

  --danger: #b76d60;

  --radius: 12px;
  --radius-lg: 18px;
  --radius-xl: 26px;
  --radius-pill: 999px;

  --shadow-xs: 0 1px 2px rgba(80, 60, 40, 0.04);
  --shadow-sm: 0 2px 8px rgba(80, 60, 40, 0.06);
  --shadow-md: 0 10px 28px rgba(80, 60, 40, 0.08);
  --shadow-lg: 0 20px 50px rgba(80, 60, 40, 0.1);

  --font-serif: "Playfair Display", "Source Han Serif SC", "Noto Serif SC", Georgia, serif;
  --font-sans: "Inter", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei",
    system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
textarea, input { font-family: inherit; color: inherit; }

body {
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   顶栏：fixed 悬浮，透明，允许人像从顶端开始
   ============================================================ */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 40px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, #dcc8a8 0%, var(--accent) 55%, var(--accent-hover) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.35),
    0 2px 6px rgba(139, 111, 71, 0.18);
}
.brand-text { display: flex; align-items: baseline; gap: 10px; }
.brand-text h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 24px;
  letter-spacing: 0.02em;
  color: var(--text);
}
.brand-sub {
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
}
.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  background: var(--bubble-ai);
  color: var(--text-secondary);
  font-size: 13px;
  box-shadow: var(--shadow-xs);
  transition: all 0.18s var(--ease);
}
.pill-btn:hover {
  color: var(--accent-ink);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.pill-btn-accent {
  background: var(--accent-tint);
  color: var(--accent-ink);
}
.pill-btn-accent:hover {
  background: var(--bubble-ai);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm);
}
.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ============================================================
   主舞台
   ============================================================ */
.stage {
  display: grid;
  grid-template-columns: minmax(440px, 46%) 1fr;
  height: 100vh;
  padding: 0 40px 0 0;
  overflow: hidden;
}

/* ============================================================
   左侧：人像 + 欢迎气泡
   ============================================================ */
.persona {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;       /* 放大倍数降低后不再需要溢出 */
  padding-top: 30px;
}

.greeting {
  position: absolute;
  top: 32vh;     /* 略靠上方，约页面 1/3 处 */
  left: 36px;
  max-width: 260px;
  z-index: 3;    /* 确保不被放大的人像遮挡 */
  padding: 14px 18px;
  background: var(--bubble-greeting);
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
  border-radius: 18px 18px 18px 6px;
  box-shadow: var(--shadow-xs);
  z-index: 2;
  animation: fade-in 0.6s var(--ease);
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.portrait {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transform: translateX(50px);   /* 整体右移约 1/3 身位 */
}
.portrait img,
.portrait svg {
  display: block;
  height: 100%;
  width: auto;
  object-fit: contain;
  object-position: bottom center;
  transform: scale(1.05);               /* 相对原图小幅放大 */
  transform-origin: bottom center;      /* 从底部锚定，脚对齐底边 */
}
.portrait svg { display: none; }

/* ============================================================
   右侧：对话
   ============================================================ */
.dialog {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 90px 0 24px; /* top 留空间给 fixed 顶栏 */
}

.chat {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 8px 30px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.chat::-webkit-scrollbar { width: 6px; }
.chat::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

/* 空对话时的"欢迎区"：开场白消息 + 快捷入口 */
.welcome {
  margin-bottom: 20px;
  padding: 0 4px;
}
.welcome-msg {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  animation: slide-up 0.3s var(--ease);
}
.welcome-msg .avatar {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #efe4d2, var(--accent));
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 14px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}
.welcome-msg .col { flex: 1; min-width: 0; }
.welcome-msg .meta { margin-bottom: 6px; }
.welcome-msg .name {
  font-weight: 500;
  font-size: 13px;
  color: var(--text);
}
.welcome-msg .bubble {
  padding: 14px 20px;
  background: var(--bubble-ai);
  border-radius: 4px 18px 18px 18px;
  box-shadow: var(--shadow-xs);
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--text);
}

.quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-left: 46px; /* 与 avatar 对齐 */
}
.chip {
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: var(--bubble-ai);
  color: var(--text-secondary);
  font-size: 13px;
  box-shadow: var(--shadow-xs);
  transition: all 0.18s var(--ease);
}
.chip:hover {
  color: var(--accent-ink);
  background: var(--accent-tint);
  transform: translateY(-1px);
}

/* 消息列表 */
.messages {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* 时间分割线：一段对话只显示一次，居中灰色小字 */
.msg-time-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-muted);
  margin: 4px 0;
  animation: none;
}
.msg-time-divider::before,
.msg-time-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--accent);
  opacity: 0.25;
  margin: 0 8px;
}

/* 顶部"加载更早"控件 */
.msg-load-older {
  display: flex;
  justify-content: center;
  margin: 0;
  padding: 0;
  animation: none; /* 不要 slide-up，避免反复加载时反复抖动 */
}
.load-older-btn {
  padding: 6px 14px;
  font-size: 12px;
  color: var(--text-muted);
  background: transparent;
  border: 1px dashed var(--accent);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.load-older-btn:hover:not(:disabled) {
  color: var(--accent-ink);
  border-style: solid;
  background: var(--accent-tint);
}
.load-older-btn:disabled {
  opacity: 0.6;
  cursor: progress;
}
.msg {
  display: flex;
  gap: 12px;
  animation: slide-up 0.25s var(--ease);
}
@keyframes slide-up {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 用户气泡 —— 右对齐，奶茶米 */
.msg-user { justify-content: flex-end; padding-right: 4px; }
.msg-user .bubble {
  max-width: 78%;
  padding: 12px 18px;
  background: var(--bubble-user);
  color: var(--text);
  border-radius: 18px 18px 4px 18px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 海报请求的用户消息 */
.msg-user-poster .bubble {
  display: flex;
  flex-direction: column;
  gap: 6px;
  white-space: normal;
  max-width: 82%;
}
.user-poster-tag {
  align-self: flex-start;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #fff;
  font-size: 10.5px;
  letter-spacing: 0.1em;
}
.user-poster-brief {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.user-poster-meta {
  font-size: 12px;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}
.user-poster-meta:empty { display: none; }

/* AI —— 头像 + 白气泡 */
.msg-ai { align-items: flex-start; padding-left: 4px; }
.msg-ai .avatar {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #efe4d2, var(--accent));
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 14px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.28);
}
.msg-ai .col { flex: 1; min-width: 0; }
.msg-ai .meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.msg-ai .name { font-weight: 500; font-size: 13px; color: var(--text); }
.msg-ai .time { font-size: 12px; color: var(--text-muted); }
.msg-ai .bubble {
  padding: 14px 20px;
  background: var(--bubble-ai);
  border-radius: 4px 18px 18px 18px;
  box-shadow: var(--shadow-xs);
}

.bubble.streaming::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -2px;
  background: var(--accent);
  animation: cursor-blink 1s steps(2, start) infinite;
}
@keyframes cursor-blink { to { visibility: hidden; } }

.msg-error .bubble { background: #fcf0ec; color: var(--danger); }

/* 深度思考折叠卡 */
.reasoning {
  margin: 2px 0 10px;
  background: var(--bg-soft);
  border-radius: 12px;
  font-size: 13px;
  overflow: hidden;
  transition: all 0.2s var(--ease);
}
.reasoning summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  user-select: none;
  transition: color 0.15s var(--ease);
}
.reasoning summary::-webkit-details-marker { display: none; }
.reasoning summary:hover { color: var(--accent-ink); }
.reasoning .reasoning-icon { opacity: 0.7; }
.reasoning .reasoning-caret {
  font-size: 11px;
  opacity: 0.5;
  transition: transform 0.2s var(--ease);
  display: inline-block;
}
.reasoning[open] .reasoning-caret { transform: rotate(90deg); }
.reasoning.thinking .reasoning-label::after {
  content: "";
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-left: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: cursor-blink 1s infinite;
}
.reasoning-content {
  padding: 10px 14px 12px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.65;
  max-height: 360px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border-top: 1px dashed var(--border-soft);
}

/* markdown */
.markdown h1, .markdown h2, .markdown h3 {
  font-family: var(--font-serif);
  font-weight: 500;
  margin: 0.8em 0 0.3em;
}
.markdown h1 { font-size: 1.25em; }
.markdown h2 { font-size: 1.15em; }
.markdown h3 { font-size: 1.05em; }
.markdown p { margin: 0.45em 0; }
.markdown p:first-child { margin-top: 0; }
.markdown p:last-child { margin-bottom: 0; }
.markdown ul, .markdown ol { margin: 0.4em 0; padding-left: 1.3em; }
.markdown li { margin: 0.3em 0; }
.markdown strong { color: var(--text); font-weight: 600; }
.markdown em { font-style: italic; color: var(--accent-ink); }
.markdown code {
  padding: 2px 6px;
  background: var(--bg-soft);
  border-radius: 4px;
  font-size: 0.9em;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.markdown pre {
  padding: 12px 14px;
  background: var(--bg-soft);
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.9em;
}
.markdown pre code { padding: 0; background: none; }
.markdown blockquote {
  margin: 0.5em 0;
  padding-left: 14px;
  border-left: 3px solid var(--accent);
  color: var(--text-secondary);
  font-style: italic;
}
.markdown a { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }

/* 建议 chip */
.suggestions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.suggestions-label {
  flex: 0 0 100%;
  font-size: 11.5px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.suggest-chip {
  padding: 6px 12px;
  font-size: 12.5px;
  color: var(--accent-ink);
  background: var(--accent-tint);
  border-radius: var(--radius-pill);
  transition: all 0.15s var(--ease);
}
.suggest-chip:hover {
  background: var(--bubble-ai);
  transform: translateY(-1px);
}

.tts-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: var(--text-muted);
  transition: all 0.15s var(--ease);
}
.tts-btn:hover { color: var(--accent-ink); background: var(--accent-tint); }
.tts-btn.playing { color: #fff; background: var(--accent); }

/* ============================================================
   底部输入区
   ============================================================ */
.composer {
  padding: 10px 8px 0;
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 8px 8px 8px 18px;
  background: var(--bubble-ai);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  transition: all 0.15s var(--ease);
}
.input-row:focus-within {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

#input {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  max-height: 180px;
  min-height: 24px;
  background: transparent;
  font-size: 15px;
  line-height: 1.55;
  padding: 8px 0;
  color: var(--text);
}
#input::placeholder { color: var(--text-muted); }

.aux-btn {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  align-self: flex-end;
  margin-bottom: 2px;
  transition: all 0.15s var(--ease);
}
.aux-btn:hover { color: var(--accent-ink); background: var(--bg-soft); }
.aux-btn.recording {
  color: #fff;
  background: var(--accent);
  animation: pulse 1.4s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(200, 183, 166, 0.45); }
  50% { box-shadow: 0 0 0 6px rgba(200, 183, 166, 0); }
}

.send-btn {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  transition: all 0.15s var(--ease);
}
.send-btn:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); }
.send-btn:active:not(:disabled) { transform: scale(0.94); }
.send-btn:disabled { background: var(--border-strong); cursor: not-allowed; }

/* 控件 + meta 行 */
.controls {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 8px 0;
  font-size: 12.5px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.control { display: inline-flex; align-items: center; gap: 8px; }
.control-label { letter-spacing: 0.04em; }
.control input[type="text"] {
  width: 130px;
  padding: 5px 12px;
  font-size: 13px;
  color: var(--text);
  background: var(--bubble-ai);
  border: none;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-xs);
  transition: all 0.15s var(--ease);
}
.control input[type="text"]:focus {
  outline: none;
  box-shadow: var(--shadow-sm), 0 0 0 3px rgba(200, 183, 166, 0.18);
}
.control-toggle { cursor: pointer; user-select: none; }
.control-toggle input { display: none; }
.control-toggle .toggle {
  position: relative;
  width: 32px;
  height: 18px;
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  transition: background 0.2s var(--ease);
}
.control-toggle .toggle::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  transition: transform 0.2s var(--ease);
}
.control-toggle input:checked + .toggle { background: var(--accent); }
.control-toggle input:checked + .toggle::after { transform: translateX(14px); }

.meta-spacer { flex: 1; min-width: 20px; }
.conv-label { font-family: ui-monospace, "SF Mono", Menlo, monospace; color: var(--text-muted); }
.hint { font-size: 11.5px; color: var(--text-muted); }

/* ============================================================
   海报生成模态（顶栏入口 + 居中卡片 + 半透明遮罩）
   ============================================================ */
/* 全局 hidden 属性兜底：任何带 [hidden] 的元素都强制隐藏，
   避免和显式 display 规则冲突 */
[hidden] { display: none !important; }

.poster-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  animation: fade-in 0.18s var(--ease);
}
.poster-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(60, 45, 25, 0.28);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.poster-card {
  position: relative;
  width: 460px;
  max-width: 100%;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--bubble-ai);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 24px 28px 22px;
  animation: slide-up 0.22s var(--ease);
}
.poster-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.poster-panel-head h3 {
  margin: 0 0 2px;
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 20px;
  color: var(--text);
  letter-spacing: 0.01em;
}
.poster-panel-sub {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.poster-close {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  transition: all 0.15s var(--ease);
}
.poster-close:hover { color: var(--accent-ink); background: var(--bg-soft); }
.poster-hint {
  margin: 6px 2px 0;
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: center;
}

.poster-form { display: flex; flex-direction: column; gap: 12px; }
.poster-field { display: flex; flex-direction: column; gap: 6px; }
.poster-field-label {
  font-size: 12.5px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.poster-field textarea,
.poster-field select {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 8px 12px;
  outline: none;
  transition: all 0.15s var(--ease);
}
.poster-field textarea { resize: vertical; min-height: 64px; }
.poster-field textarea:focus,
.poster-field select:focus {
  border-color: var(--accent);
  background: var(--bubble-ai);
  box-shadow: 0 0 0 3px rgba(200, 183, 166, 0.18);
}
.poster-row { display: flex; gap: 10px; }
.poster-row .poster-field { flex: 1; }

.poster-field-hint {
  margin: 0 0 4px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.poster-reference-field { gap: 4px; }
.poster-reference-upload {
  display: flex;
  align-items: center;
  gap: 10px;
}
.poster-reference-pick {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--accent-ink);
  background: var(--bg-soft);
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  transition: all 0.15s var(--ease);
}
.poster-reference-pick:hover {
  background: var(--accent-tint);
  border-style: solid;
  border-color: var(--accent);
}
.poster-reference-preview {
  position: relative;
  display: inline-block;
}
.poster-reference-preview img {
  display: block;
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 10px;
  box-shadow: var(--shadow-xs);
}
.poster-reference-clear {
  position: absolute;
  top: -6px; right: -6px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--text);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
}

/* 海报消息气泡里的参考图条 */
.poster-reference-ref {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 8px 10px;
  background: var(--bg-soft);
  border-radius: 10px;
  font-size: 12px;
  color: var(--text-muted);
}
.poster-reference-ref-label { flex: 1; letter-spacing: 0.02em; }
.poster-reference-ref-img {
  width: 44px; height: 44px;
  object-fit: cover;
  border-radius: 6px;
}

.poster-submit {
  margin-top: 4px;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #fff;
  font-weight: 500;
  transition: all 0.15s var(--ease);
}
.poster-submit:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); }
.poster-submit:disabled { background: var(--border-strong); cursor: not-allowed; }

/* ============================================================
   海报消息气泡
   ============================================================ */
.poster-status {
  padding: 12px 18px;
  background: var(--bubble-ai);
  border-radius: 4px 18px 18px 18px;
  box-shadow: var(--shadow-xs);
  color: var(--text-secondary);
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.poster-status::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: cursor-blink 1s infinite;
}

.poster-figure {
  margin: 8px 0 0;
  padding: 0;
  max-width: 480px;
}
.poster-image {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  background: var(--bg-soft);
}
.poster-caption {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  font-size: 12.5px;
  color: var(--text-secondary);
}
.poster-download,
.poster-regen {
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: var(--accent-tint);
  color: var(--accent-ink);
  text-decoration: none;
  transition: all 0.15s var(--ease);
}
.poster-download:hover,
.poster-regen:hover {
  background: var(--bubble-ai);
  box-shadow: 0 0 0 1px var(--accent);
}
/* 查看 prompt：默认与下载/换一张同行的小文字链接；展开后换行显示原文 */
.poster-prompt-detail {
  /* 不再强制独占一行 */
  display: inline-flex;
}
.poster-prompt-detail summary {
  cursor: pointer;
  display: inline-block;
  color: var(--text-muted);
  font-size: 12px;
  list-style: none;
  padding: 5px 0;
}
.poster-prompt-detail summary::-webkit-details-marker { display: none !important; }
.poster-prompt-detail summary::marker { display: none; content: ""; }
.poster-prompt-detail[open] {
  flex: 1 0 100%;
  margin-top: 4px;
}
.poster-prompt-detail[open] summary { color: var(--accent-ink); }
.poster-prompt-text {
  margin: 6px 0 0;
  padding: 10px 12px;
  background: var(--bg-soft);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 再改一版：默认与下载/换一张同行的"按钮"样式（accent-tint 底色突出）；展开后整行 */
.poster-refine-detail {
  display: inline-flex;
}
.poster-refine-detail summary {
  cursor: pointer;
  display: inline-block;          /* 关键：避免渲染默认 list-item 标记 */
  list-style: none;
  padding: 5px 14px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--accent-ink);
  background: var(--accent-tint);
  border-radius: var(--radius-pill);
  transition: all 0.15s var(--ease);
}
/* 全平台彻底隐藏 details 默认箭头/小圆点 */
.poster-refine-detail summary::-webkit-details-marker { display: none !important; }
.poster-refine-detail summary::marker { display: none; content: ""; }
.poster-refine-detail summary:hover {
  background: var(--bubble-ai);
  box-shadow: 0 0 0 1px var(--accent);
}
.poster-refine-detail[open] {
  flex: 1 0 100%;
  margin-top: 6px;
}
/* 展开后 summary 退化成小灰文字，不再和下方 form 抢视觉 */
.poster-refine-detail[open] summary {
  background: transparent;
  color: var(--text-muted);
  padding: 0 4px 6px;
  font-size: 11.5px;
  font-weight: normal;
  border-radius: 0;
  box-shadow: none !important;
}
.poster-refine-detail[open] summary::after {
  content: " · 点击收起";
  opacity: 0.6;
}
.poster-refine-detail[open] summary:hover {
  background: transparent;
  box-shadow: none !important;
  color: var(--accent-ink);
}
.poster-refine-form {
  margin-top: 8px;
  padding: 16px 18px;
  background: var(--bg-soft);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.poster-refine-head { display: flex; flex-direction: column; gap: 4px; }
.poster-refine-title {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 15px;
  color: var(--text);
}
.poster-refine-subtitle {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-secondary);
}
.poster-refine-input {
  width: 100%;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bubble-ai);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  outline: none;
  resize: vertical;
  min-height: 120px;
  transition: all 0.15s var(--ease);
}
.poster-refine-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(200, 183, 166, 0.18);
}
.poster-refine-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.poster-refine-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  flex: 1;
}
.poster-refine-submit {
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  border-radius: var(--radius-pill);
  transition: all 0.15s var(--ease);
  flex: 0 0 auto;
}
.poster-refine-submit:hover:not(:disabled) { background: var(--accent-hover); }
.poster-refine-submit:disabled { background: var(--border-strong); cursor: not-allowed; }

/* ============================================================
   历史会话抽屉（顶栏按钮点击后从右侧滑入）
   ============================================================ */
.history-drawer {
  position: fixed;
  inset: 0;
  z-index: 45;
  animation: fade-in 0.15s var(--ease);
}
.history-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(60, 45, 25, 0.22);
}
.history-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 92vw;
  background: var(--bg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slide-in-right 0.2s var(--ease);
}
@keyframes slide-in-right {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.history-head h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 18px;
  color: var(--text);
}
.history-close {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  transition: all 0.15s var(--ease);
}
.history-close:hover { color: var(--accent-ink); background: var(--bg-soft); }

.history-new-btn {
  margin: 12px 14px 6px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-tint);
  color: var(--accent-ink);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s var(--ease);
}
.history-new-btn:hover {
  background: var(--bubble-ai);
  box-shadow: 0 0 0 1px var(--accent);
}

.history-list {
  flex: 1;
  list-style: none;
  margin: 0;
  padding: 6px 12px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.history-empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.history-item {
  display: flex;
  align-items: stretch;
  gap: 4px;
  padding: 2px;
  border-radius: 12px;
  transition: background 0.15s var(--ease);
}
.history-item:hover { background: var(--bg-soft); }
.history-item.active { background: var(--accent-tint); }

.history-item-main {
  flex: 1;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.history-item-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.history-item-title {
  flex: 1;
  font-size: 13.5px;
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-item-badge {
  flex: 0 0 auto;
  padding: 1px 8px;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-pill);
}
.history-item-meta {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.history-item-preview {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-item-del {
  width: 28px;
  align-self: center;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  opacity: 0;
  transition: all 0.15s var(--ease);
}
.history-item:hover .history-item-del { opacity: 1; }
.history-item-del:hover {
  color: var(--danger);
  background: #fcf0ec;
}

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  left: 50%;
  top: 22px;
  transform: translateX(-50%) translateY(-20px);
  padding: 10px 18px;
  background: var(--text);
  color: #fff;
  font-size: 13px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s var(--ease);
  z-index: 20;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.danger { background: var(--danger); }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1400px) {
  .stage { grid-template-columns: minmax(500px, 52%) 1fr; }
}
@media (max-width: 1100px) {
  .stage { grid-template-columns: minmax(380px, 46%) 1fr; }
  .topbar { padding: 18px 28px; }
  .stage { padding-right: 28px; }
}

@media (max-width: 820px) {
  html, body { overflow: auto; height: auto; }
  body { min-height: 100vh; }
  .topbar { position: relative; padding: 16px 20px; pointer-events: auto; }
  .stage {
    grid-template-columns: 1fr;
    height: auto;
    padding: 0 20px;
  }
  .persona {
    min-height: 180px;
    max-height: 220px;
    justify-content: flex-start;
    padding-top: 8px;
  }
  .greeting { position: static; margin: 0 0 12px; max-width: 100%; }
  .portrait {
    position: absolute;
    right: 0;
    bottom: 0;
    max-width: 180px;
    height: 200px;
  }
  .dialog { padding: 10px 0 16px; }
  .chat { padding: 10px 0 20px; }
}

@media (max-width: 540px) {
  .brand-sub { display: none; }
  .controls { flex-wrap: wrap; gap: 10px; }
  .persona { min-height: 120px; }
  .portrait { max-width: 120px; height: 140px; }
  .msg-user .bubble, .msg-ai .bubble { max-width: 100%; }
}
