:root {
  color-scheme: light;
  --bg: #f7f3ef;
  --panel: #fffaf6;
  --panel-strong: #ffffff;
  --text: #2f2824;
  --muted: #7a6e67;
  --line: #eadfd6;
  --accent: #9d6b55;
  --accent-dark: #764c3c;
  --danger: #9f3d3d;
  --shadow: 0 18px 50px rgba(63, 45, 34, 0.13);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(circle at top left, #fff7f0, var(--bg) 48%, #efe7df);
  color: var(--text);
  /* Desktop: lock to one viewport; only the message list scrolls (see .messages). Mobile
     reverts to normal page scroll in the media query below. */
  height: 100vh;
  overflow: hidden;
}
button, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell {
  display: grid;
  grid-template-columns: 300px 300px minmax(0, 1fr);
  gap: 18px;
  height: 100vh;
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px;
}
.sidebar { overflow-y: auto; }

/* Desktop: the drawer wrapper is transparent to the grid (sidebar + conv-column remain
   direct columns). On mobile (media query below) it becomes the ☰ slide-in drawer. */
.side-drawer { display: contents; }
.menu-btn { display: none; }
.drawer-overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(30, 20, 14, 0.4);
}
.drawer-overlay[hidden] { display: none; }

/* The conversation-list column (own column, between the sidebar and the chat). */
.conv-column {
  height: calc(100vh - 36px);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
}
.conv-column .conv-list {
  flex: 1;             /* fill the column; the list scrolls internally */
  max-height: none;
}

.sidebar, .conv-column, .chat-panel {
  background: rgba(255, 250, 246, 0.9);
  border: 1px solid rgba(234, 223, 214, 0.9);
  border-radius: 26px;
  box-shadow: var(--shadow);
}

.sidebar {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 42px; height: 42px; border-radius: 16px;
  display: grid; place-items: center;
  background: #efe2d8;
  color: var(--accent-dark);
  font-size: 22px;
}
h1, h2, p { margin: 0; }
h1 { font-size: 20px; }
h2 { font-size: 18px; }
.brand p, .chat-header p, .hint, .privacy-note { color: var(--muted); font-size: 13px; line-height: 1.5; }

.secondary-btn, .danger-btn, .quick-prompts button, #sendBtn, .image-btn {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: var(--panel-strong);
  color: var(--text);
}
.secondary-btn:hover, .quick-prompts button:hover, .image-btn:hover { border-color: var(--accent); }
.danger-btn { color: var(--danger); }

.setting-block { display: grid; gap: 7px; }
.setting-block label, .toggle-row { color: var(--muted); font-size: 13px; }
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: white;
  padding: 10px 12px;
  color: var(--text);
}
.toggle-row { display: flex; align-items: center; gap: 8px; }
.session-card {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
  background: rgba(255,255,255,.55);
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
.session-card code { color: var(--text); word-break: break-all; }

.chat-panel {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  height: calc(100vh - 36px);
  overflow: hidden;
}
/* The scrollable message region (grid row 1fr). Wraps #messages + the right-side nav rail. */
.messages-wrap { position: relative; min-height: 0; overflow: hidden; }
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}
.status-badge {
  white-space: nowrap;
  padding: 7px 11px;
  border-radius: 999px;
  background: #efe2d8;
  color: var(--accent-dark);
  font-size: 12px;
}
.status-badge.error { background: #f8dddd; color: var(--danger); }
.status-badge.loading { background: #eee9ff; color: #594b91; }

.messages {
  height: 100%;
  overflow-y: auto;
  padding: 24px 34px 24px 22px;   /* extra right padding to clear the nav rail */
  display: flex;
  flex-direction: column;
  gap: 22px;                       /* room below each bubble for the hover action bar */
}
.message {
  position: relative;
  max-width: min(720px, 92%);
  padding: 13px 15px;
  border-radius: 20px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-text { white-space: pre-wrap; word-break: break-word; }

/* Hover action bar (copy / edit), tucked just below each bubble. */
.msg-actions {
  position: absolute;
  bottom: -19px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.12s ease;
  z-index: 2;
}
.message.user .msg-actions { right: 2px; }
.message.assistant .msg-actions { left: 2px; }
.message:hover .msg-actions, .msg-actions:focus-within { opacity: 1; }
.msg-actions button {
  font-size: 12px;
  color: var(--muted);
  background: transparent;
  border: none;
  padding: 2px 7px;
  border-radius: 8px;
  line-height: 1.4;
}
.msg-actions button:hover { background: rgba(120,110,100,0.14); color: var(--text); }

/* Edit-and-resend mode: the user bubble becomes an editable box. */
.message.editing { max-width: min(720px, 92%); width: 92%; background: var(--accent-dark); }
.edit-box {
  width: 100%;
  min-height: 44px;
  resize: none;
  border: none;
  border-radius: 12px;
  padding: 9px 11px;
  line-height: 1.5;
  outline: none;
  color: var(--text);
  background: white;
}
.edit-actions { display: flex; gap: 8px; margin-top: 8px; justify-content: flex-end; }
.edit-actions button {
  font-size: 13px; padding: 5px 12px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.35); background: transparent; color: white;
}
.edit-actions .edit-send { background: white; color: var(--accent-dark); border-color: white; }

/* Brief highlight when jumping to a message from the nav rail. */
.message.jump-flash { box-shadow: 0 0 0 3px rgba(157,107,85,0.5); }

/* Per-answer feedback (👎 → tags + comment form). */
.fb-note { margin-top: 8px; font-size: 12px; color: var(--muted); }
.fb-form {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff7f1;
}
.fb-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.fb-tag {
  font-size: 12px;
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  border-radius: 999px;
  padding: 4px 10px;
}
.fb-tag.on { background: var(--accent); color: white; border-color: var(--accent); }
.fb-comment {
  width: 100%;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  line-height: 1.5;
  outline: none;
  background: white;
  color: var(--text);
}
.fb-comment:focus { border-color: var(--accent); }
.fb-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.fb-actions button {
  font-size: 13px; padding: 5px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: white; color: var(--text);
}
.fb-actions .fb-submit { background: var(--accent); color: white; border-color: var(--accent); }
.message.user {
  align-self: flex-end;
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 7px;
}
.message.assistant {
  align-self: flex-start;
  background: white;
  border: 1px solid var(--line);
  border-bottom-left-radius: 7px;
}
.message.system {
  align-self: center;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 4px 8px;
}

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 22px 12px;
}
.quick-prompts button { font-size: 13px; padding: 8px 10px; }

.composer {
  display: flex;
  flex-wrap: wrap;            /* lets the image chip take its own full-width line */
  align-items: flex-end;
  gap: 10px;
  padding: 14px 22px 10px;
  border-top: 1px solid var(--line);
  background: rgba(255,250,246,.95);
}
.image-btn { white-space: nowrap; }
.image-btn input { display: none; }
/* Selected-image chip: a full-width bar ABOVE the input row (order:-1), so it never squeezes
   the textarea/send button off-screen on narrow phones. Includes a ✕ to deselect. */
.image-preview {
  flex: 1 1 100%;
  order: -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 7px 10px;
  background: white;
}
.image-preview[hidden] { display: none; }  /* explicit: our display:flex must not defeat `hidden` */
.image-preview-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-remove {
  border: none; background: transparent; color: var(--muted);
  font-size: 14px; padding: 2px 6px; border-radius: 8px; flex: none;
}
.image-remove:hover { color: var(--danger); background: rgba(160,60,50,0.08); }
textarea { min-width: 0; }   /* flex shrink guard on narrow screens */
textarea {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 160px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 11px 13px;
  line-height: 1.5;
  outline: none;
  background: white;
  color: var(--text);
}
textarea:focus { border-color: var(--accent); }
#sendBtn {
  min-width: 78px;
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
#sendBtn:disabled { opacity: .55; cursor: not-allowed; }
.privacy-note { padding: 0 22px 16px; }

/* --- Right-side question navigator (like the ChatGPT minimap): one tick per user question,
      hover shows a preview, click scrolls to it. --- */
.msg-nav {
  position: absolute;
  top: 0; right: 4px; bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  gap: 7px;
  padding: 10px 0;
  pointer-events: none;   /* only the ticks are interactive */
  overflow: visible;      /* let the hover preview tooltip escape leftward */
}
.nav-tick {
  position: relative;
  width: 15px; height: 3px;
  padding: 0; border: none;
  border-radius: 3px;
  background: var(--line);
  pointer-events: auto;
  transition: width 0.12s ease, background 0.12s ease;
}
.nav-tick:hover { width: 22px; background: var(--accent); }
.nav-tick.active { width: 22px; background: var(--accent); }
.nav-tip {
  position: absolute;
  right: 24px; top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  max-width: 240px;
  overflow: hidden; text-overflow: ellipsis;
  background: var(--text);
  color: white;
  font-size: 12px;
  padding: 5px 9px;
  border-radius: 9px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.12s ease;
  box-shadow: var(--shadow);
}
.nav-tick:hover .nav-tip { opacity: 1; }

@media (max-width: 820px) {
  /* Mobile: fullscreen chat + ☰ slide-in drawer (the standard chat-app pattern).
     100dvh (not 100vh) so the browser address bar never pushes the composer off-screen. */
  body { height: 100vh; height: 100dvh; overflow: hidden; }
  .app-shell { display: block; height: 100vh; height: 100dvh; padding: 0; max-width: none; }
  .chat-panel {
    height: 100%;
    border-radius: 0; border: none; box-shadow: none;
  }

  /* ☰ button appears in the header. */
  .menu-btn {
    display: grid; place-items: center;
    width: 40px; height: 40px; flex: none;
    border: 1px solid var(--line); border-radius: 12px;
    background: var(--panel-strong); font-size: 18px; color: var(--text);
  }
  .chat-header { padding: 12px 14px; align-items: center; gap: 12px; }
  .chat-header h2 { font-size: 16px; }
  .chat-sub { display: none; }              /* keyboard hint is desktop-only */

  /* The wrapper becomes the drawer: conversation list first, settings below. */
  .side-drawer {
    display: flex; flex-direction: column; gap: 16px;
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 50;
    width: min(84vw, 320px);
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    background: var(--bg);
    border-right: 1px solid var(--line);
    box-shadow: 0 0 60px rgba(40, 25, 15, 0.25);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    overflow-y: auto;
  }
  .side-drawer.open { transform: translateX(0); }
  @media (prefers-reduced-motion: reduce) { .side-drawer { transition: none; } }

  /* Inside the drawer the two sections lose their card chrome and stack naturally. */
  .side-drawer .sidebar, .side-drawer .conv-column {
    background: transparent; border: none; box-shadow: none; border-radius: 0;
    padding: 0; height: auto; overflow: visible;
  }
  .side-drawer .conv-column { order: -1; }        /* ＋新对话 + 对话列表 on top */
  .side-drawer .conv-column .conv-list { flex: none; max-height: 44vh; overflow-y: auto; }
  .side-drawer .sidebar { border-top: 1px solid var(--line); padding-top: 16px; }
  .side-drawer .brand { display: none; }          /* header already names the app */
  .side-drawer .session-card { display: none; }   /* debug ids — not for mobile users */

  /* Chat area */
  .message { max-width: 96%; }
  .messages { padding: 14px 14px 18px; gap: 20px; }
  .msg-nav { display: none; }                     /* the minimap is a desktop affordance */
  .quick-prompts { display: none; }               /* hidden on mobile (user decision) */
  .composer { padding: 10px 12px; }
  /* Bottom-most element carries the iPhone home-bar safe area. */
  .privacy-note { font-size: 11px; padding: 4px 14px calc(8px + env(safe-area-inset-bottom)); margin: 0; }
}

/* --- Conversation list: one white card, rows split by dividers --- */
.conv-list {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;          /* clip the active-row highlight to the rounded corners */
  max-height: 46vh;
  overflow-y: auto;
  margin: 2px 0 8px;
}
.conv-empty { color: var(--muted); font-size: 13px; padding: 14px; text-align: center; }
.conv-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 11px 12px;
  cursor: pointer;
  color: var(--text);
  background: transparent;                 /* white (the card) when idle */
  border-bottom: 1px solid var(--line);    /* horizontal divider between conversations */
  transition: background 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.conv-item:last-child { border-bottom: none; }
.conv-item:hover { background: rgba(157, 107, 85, 0.06); }
.conv-item.active { background: rgba(157, 107, 85, 0.15); }   /* selected = the accent tint */
.conv-item:active { background: rgba(157, 107, 85, 0.22); }   /* press feedback */
.conv-title {
  flex: 1;                    /* pushes the actions to the far right */
  min-width: 0;
  font-size: 14px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-item.active .conv-title { font-weight: 600; }
.conv-actions { display: flex; gap: 0; flex-shrink: 0; opacity: 0; transition: opacity 0.12s ease; }
.conv-item:hover .conv-actions, .conv-item.active .conv-actions { opacity: 1; }
.conv-actions button {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  padding: 4px 5px;
  border-radius: 6px;
  transition: color 0.12s ease;
}
.conv-actions button:hover { color: var(--text); }
.conv-actions button.del:hover { color: var(--danger); }

/* --- Process disclosure: a bare chevron that blends into the bubble (no label, no box) --- */
.process { margin-bottom: 2px; }
.process-toggle {
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.proc-sum { font-size: 12px; color: var(--muted); }
.proc-icons { margin-right: 4px; letter-spacing: 2px; }
.process-toggle:hover .proc-sum { color: var(--text); }
.process-toggle:hover { color: var(--text); }
.process-toggle .chev {
  display: inline-block;
  font-size: 13px;
  transition: transform 0.14s ease;
}
.process-toggle.open .chev { transform: rotate(90deg); }
.process-body { margin: 4px 0 2px; }        /* no border, no fill — one with the bubble */
.process-preamble {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  margin-bottom: 6px;
}
.process-preamble:empty { display: none; }
.process-tools { display: flex; flex-wrap: wrap; gap: 10px; }
.tool-chip { font-size: 12px; color: var(--muted); }   /* plain muted text, no pill */
.stream-status { opacity: 0.55; font-size: 13px; }

/* --- Plan A: touch devices have no hover — message actions (复制/编辑/👍/👎) are ALWAYS
   visible, styled as small chips so they read cleanly between bubbles. Desktop (hover-capable)
   keeps the hover-reveal behavior. Placed last so it wins the cascade on phones. --- */
@media (hover: none) {
  .msg-actions { opacity: 1; bottom: -32px; }
  .msg-actions button {
    font-size: 13px;
    padding: 4px 11px;
    background: var(--panel-strong);
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--muted);
  }
  .msg-actions button:active { background: var(--line); color: var(--text); }
  /* Room between bubbles for the always-visible bar, and below the last one. */
  .messages { gap: 42px; padding-bottom: 40px; }
}

/* --- Product cards (screen surface): a horizontally-scrollable row under a recommendation. --- */
.pcards {
  display: flex; gap: 12px; overflow-x: auto;
  align-items: flex-start;            /* cards size to their own content, don't stretch to tallest */
  margin-top: 12px; padding: 2px 2px 8px;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
}
.pcard {
  flex: 0 0 auto; width: 178px;
  background: var(--panel-strong); border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden; display: flex; flex-direction: column;
  scroll-snap-align: start;
}
.pcard-img { aspect-ratio: 1; background: #fff; border-bottom: 1px solid var(--line); }
.pcard-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pcard-img.noimg, .pcard-img:empty { background: var(--panel); aspect-ratio: 1; }
.pcard-body { padding: 10px 11px; display: flex; flex-direction: column; gap: 6px; }
.pcard-brand { font-size: 11px; color: var(--muted); }
.pcard-name { font-size: 13px; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcard-price { font-size: 15px; font-weight: 700; color: var(--accent-dark); }
.pcard-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.pchip { font-size: 11px; background: #f0e4db; color: var(--accent-dark); padding: 1px 7px; border-radius: 8px; }
.pcard-stars { font-size: 11.5px; color: var(--accent); }
.pcard-why { font-size: 12px; color: var(--muted); line-height: 1.45; }
.pcard-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.pbadge { font-size: 11px; padding: 2px 7px; border-radius: 8px; border: none; line-height: 1.5; }
.pbadge.good { background: #e6f0e6; color: #3a6b45; }
.pbadge.warn { background: #f7ecd6; color: #9a6a12; cursor: pointer; }
.pcard-detail { margin-top: 2px; font-size: 12px; color: var(--muted);
  background: transparent; border: none; padding: 4px 0; text-align: left; cursor: pointer; }
.pcard-detail:hover { color: var(--text); }
.pcard-detailbody { font-size: 11.5px; color: var(--muted); line-height: 1.5;
  display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.pcard-detailbody[hidden] { display: none; }   /* our display:flex must not defeat the hidden attribute */
.pcard-detailbody b { color: var(--text); font-weight: 600; }
.pd-risk { color: #9a6a12; }
.pd-note { font-size: 11px; opacity: 0.7; font-style: italic; }
.pd-nmpa { font-size: 11px; opacity: 0.75; }

/* ---------------- Overall / report feedback ---------------- */

/* Sentiment faces — shared by the modal and the inline pulse. */
.fb-sent { display: flex; gap: 8px; }
.fb-sent-btn {
  font-size: 24px;
  line-height: 1;
  width: 44px; height: 44px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.12s ease, background 0.12s ease;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.fb-sent-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.fb-sent-btn.on {
  border-color: var(--accent);
  background: #fbeee7;
  box-shadow: 0 0 0 2px rgba(157, 107, 85, 0.25);
}

/* Inline pulse card — sits in the message flow after a few turns. */
.fb-inline {
  align-self: center;
  max-width: 460px;
  width: 100%;
  margin: 6px auto 2px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: #fff7f1;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 10px 14px;
  flex-wrap: wrap;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(63, 45, 34, 0.06);
}
.fb-inline-q { font-size: 14px; color: var(--text); font-weight: 500; }
.fb-inline-skip {
  border: none; background: transparent; color: var(--muted);
  font-size: 15px; cursor: pointer; padding: 4px 6px; border-radius: 8px; line-height: 1;
}
.fb-inline-skip:hover { background: rgba(120, 110, 100, 0.12); color: var(--text); }
.fb-inline-thanks { font-size: 14px; color: var(--accent-dark); font-weight: 500; }

/* Modal (opened from the sidebar). Desktop: centered card. Mobile: bottom sheet. */
.fb-modal-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(47, 40, 36, 0.42);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.fb-modal-overlay[hidden] { display: none; }
.fb-modal {
  position: relative;
  width: 100%; max-width: 440px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 22px 20px 18px;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
}
.fb-modal h3 { margin: 0 0 14px; font-size: 17px; color: var(--text); }
.fb-modal-close {
  position: absolute; top: 12px; right: 12px;
  border: none; background: transparent; color: var(--muted);
  font-size: 18px; cursor: pointer; width: 32px; height: 32px; border-radius: 8px; line-height: 1;
}
.fb-modal-close:hover { background: rgba(120, 110, 100, 0.12); color: var(--text); }
.fb-seg {
  display: flex; gap: 4px; padding: 4px;
  background: #f1e7df; border-radius: 12px; margin-bottom: 16px;
}
.fb-seg-btn {
  flex: 1; border: none; background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; padding: 8px 10px; border-radius: 9px; cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.fb-seg-btn.on { background: var(--panel-strong); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(63,45,34,0.1); }
.fb-sent-row { margin-bottom: 14px; }
.fb-sent-label { display: block; font-size: 13.5px; color: var(--muted); margin-bottom: 10px; }
.fb-sent-row .fb-sent { justify-content: space-between; max-width: 220px; }
.fb-modal-text {
  width: 100%; resize: none; box-sizing: border-box;
  border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; font: inherit; line-height: 1.55; outline: none;
  background: var(--panel); color: var(--text);
}
.fb-modal-text:focus { border-color: var(--accent); background: var(--panel-strong); }
.fb-modal-actions { display: flex; justify-content: flex-end; margin-top: 14px; }
.fb-modal-actions .fb-submit {
  font: inherit; font-size: 14px; padding: 9px 22px; border-radius: 11px;
  border: 1px solid var(--accent); background: var(--accent); color: white; cursor: pointer;
}
.fb-modal-actions .fb-submit:disabled { opacity: 0.45; cursor: not-allowed; }
.fb-modal-thanks { text-align: center; padding: 26px 0 8px; font-size: 15px; color: var(--accent-dark); }

/* ---- 长期记忆中心 ---- */
.memory-modal { max-width: 680px; }
.memory-mode-row {
  display: grid; grid-template-columns: minmax(120px, .45fr) 1fr;
  align-items: center; gap: 10px; margin: 16px 0;
  padding: 12px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--panel);
}
.memory-mode-row label, .memory-section h4 {
  color: var(--muted); font-size: 13px; font-weight: 600;
}
.memory-section { margin-top: 16px; }
.memory-section h4 { margin: 0 0 8px; }
.memory-profile {
  white-space: pre-wrap; line-height: 1.55; font-size: 13px;
  padding: 10px 12px; border-radius: 12px; background: var(--panel);
  color: var(--text);
}
.memory-items { display: grid; gap: 9px; }
.memory-card {
  border: 1px solid var(--line); border-radius: 13px;
  background: var(--panel); padding: 10px;
}
.memory-card textarea {
  width: 100%; min-height: 54px; resize: vertical; border: 1px solid transparent;
  border-radius: 9px; background: var(--panel-strong); color: var(--text);
  padding: 8px 9px; line-height: 1.45;
}
.memory-card textarea:focus { outline: none; border-color: var(--accent); }
.memory-card-meta, .memory-card-buttons, .memory-actions {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.memory-card-meta { margin-top: 7px; }
.memory-card-meta select { width: auto; padding: 6px 8px; font-size: 12px; }
.memory-card-time { color: var(--muted); font-size: 11px; margin-left: auto; }
.memory-card-buttons { justify-content: flex-end; margin-top: 8px; }
.memory-card-buttons button, .memory-actions button {
  border: 1px solid var(--line); border-radius: 9px; padding: 6px 10px;
  background: var(--panel-strong); color: var(--text); font-size: 12px;
}
.memory-card-buttons .memory-delete, .memory-actions .danger-btn { color: var(--danger); }
.memory-actions {
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line);
}
.memory-actions select { width: auto; min-width: 150px; padding: 7px 9px; font-size: 12px; }

@media (max-width: 820px) {
  .fb-modal-overlay { align-items: flex-end; padding: 0; }
  .fb-modal {
    max-width: none; border-radius: 18px 18px 0 0;
    padding-bottom: max(18px, env(safe-area-inset-bottom));
    max-height: 88dvh;
  }
  .fb-sent-btn { width: 48px; height: 48px; font-size: 26px; }
  .fb-sent-row .fb-sent { max-width: none; }
  .memory-mode-row { grid-template-columns: 1fr; }
  .memory-actions select, .memory-actions button { width: 100%; }
}

/* 用户消息里的照片回显。此前照片发送后就从界面消失，用户看不到自己传了什么。 */
.msg-photo { margin-top: .5rem; }
.msg-photo img {
  max-width: min(220px, 60%);
  border-radius: 10px;
  display: block;
  cursor: zoom-in;
  border: 1px solid rgba(0, 0, 0, .08);
}

/* ---- 「我的照片」弹窗（L2 资产生命周期） ---- */
.photos-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px; max-height: 60vh; overflow-y: auto; margin-top: 10px;
}
.photo-cell {
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  background: var(--panel); display: flex; flex-direction: column;
}
.photo-cell img {
  width: 100%; aspect-ratio: 1; object-fit: cover; display: block;
  background: var(--line);
}
.photo-ts { font-size: 11px; color: var(--muted); padding: 4px 8px 0; }
.photo-del {
  margin: 4px 8px 8px; font-size: 12px; border: 1px solid var(--line);
  background: transparent; color: #a2402f; border-radius: 8px;
  padding: 3px 0; cursor: pointer;
}
.photo-del:hover { background: rgba(162, 64, 47, 0.08); }
.photos-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 30px 0; grid-column: 1 / -1; }
.image-preview-hint { font-size: 11px; color: var(--muted); margin: 0 8px; flex: 1; min-width: 0; }
.photo-again {
  margin: 4px 8px 0; font-size: 12px; border: 1px solid var(--line);
  background: transparent; color: var(--accent, #9d6b55); border-radius: 8px;
  padding: 3px 0; cursor: pointer;
}
.photo-again:hover { background: rgba(157, 107, 85, 0.08); }
.photo-cell.picked { outline: 2px solid var(--accent); outline-offset: -2px; }
.photo-cell img { cursor: pointer; }
.photos-actions { margin-top: 10px; text-align: right; }
.memory-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 13px; }
.memory-row span { flex: 1; min-width: 0; }
.memory-mini-btn {
  font-size: 11px; border: 1px solid var(--line); background: transparent;
  color: var(--muted); border-radius: 6px; padding: 1px 8px; cursor: pointer; margin-left: 8px;
}
.memory-mini-btn:hover { color: #a2402f; border-color: #a2402f; }


/* 工具预告：留在屏幕上填补查询等待，但视觉上弱化，别看着像最终答案。 */
.bubble-content.is-preamble, .message.assistant .is-preamble { opacity: 0.6; font-style: italic; }
