/* chat.css — 聊天页全部样式。由 index.html 拆出（设计令牌在 :root）。 */
  :root {
    /* Rose family: #EECDCC #DB9B9B #A76363 #732523 · Warm amber: #EDD3AD #EFBC97 #DD9162 #B4603A */
    --primary: #A76363;
    --primary-active: #8C4441;
    --primary-disabled: #EDD9D0;
    --ink: #4B2A26;
    --body: #5D4038;
    --muted: #9C7B71;
    --muted-soft: #B99C92;
    --hairline: #EDD9D0;
    --canvas: #FAF3EF;
    --surface-soft: #F5E6DF;
    --surface-card: #F0DCD4;
    --surface-cream-strong: #E9CFC6;
    --on-primary: #ffffff;
    --error: #B4433A;

    --font-serif: "Cormorant Garamond", "Tiempos Headline", Georgia, serif;
    --font-sans: "Inter", "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
    --font-body-serif: "Lora", "PingFang SC", "Microsoft YaHei", system-ui, serif;

    --rounded-sm: 6px;
    --rounded-md: 8px;
    --rounded-lg: 12px;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }
  html, body { height: 100%; background: var(--canvas); overflow: hidden; }
  body { position: fixed; inset: 0; }

  body {
    font-family: var(--font-sans);
    background: var(--canvas);
    color: var(--body);
    display: flex;
    justify-content: flex-start;
    -webkit-text-size-adjust: 100%;
    font-size: 16px;
    line-height: 1.55;
  }

  .shell {
    width: calc(50% + 540px);   /* 左贴 0、右边界保持原居中位置不动 */
    max-width: 100%;
    height: 100%;
    display: flex;
    position: relative;
    overflow: hidden;
  }
  .app {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--canvas);
  }

  /* ── Header ──────────────────────────────── */
  header {
    position: relative;
    padding: calc(8px + env(safe-area-inset-top)) 20px 6px;
    background: var(--canvas);
    border-bottom: 1px solid var(--canvas);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    z-index: 10;
  }

  .model-menu {
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
  }

  .model-name {
    position: relative;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 16px;
    font-weight: 500;
    color: var(--ink);
    letter-spacing: 0;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 0;
    padding: 2px 6px;
    border-radius: var(--rounded-sm);
    -webkit-tap-highlight-color: transparent;
    outline: none;
  }

  /* 箭头绝对定位：不占据布局宽度，让模型名文字真正居中 */
  .model-name .caret {
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ink);
    display: flex;
    align-items: center;
    margin-left: 1px;
  }
  .model-name .caret .ch { width: 14px; height: 14px; display: inline-flex; }
  .model-name .caret .ch-down { display: none; }
  .model-menu.caret-down .caret .ch-right { display: none; }
  .model-menu.caret-down .caret .ch-down { display: inline-flex; }

  .model-sub {
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 400;
    color: var(--muted-soft);
    line-height: 1.2;
    letter-spacing: 0;
    margin-top: -3px;
    margin-right: 0;
  }

  #modelLabel { text-transform: capitalize; }

  .model-dropdown {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 8px;
    background: var(--canvas);
    border: 1px solid var(--hairline);
    border-radius: var(--rounded-lg);
    box-shadow: 0 4px 20px rgba(115, 37, 35, 0.1);
    padding: 4px;
    min-width: 160px;
    z-index: 20;
  }

  .dropdown-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    color: var(--body);
    padding: 8px 12px;
    border-radius: var(--rounded-md);
    text-align: center;
    transition: background 0.12s;
    justify-content: center;
    position: relative;
  }
  .dropdown-item:hover { background: var(--surface-soft); }
  .dropdown-item .check { position: absolute; left: 12px; width: 16px; color: var(--primary); visibility: hidden; }
  .dropdown-item.active .check { visibility: visible; }

  .new-btn {
    border: 1px solid #FFFDFB;
    background: #FFFBF8;
    color: var(--primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 0 0 1px #E8D3CA, 0 2px 6px rgba(115, 37, 35, 0.05), 0 6px 20px rgba(115, 37, 35, 0.05);
  }
  .new-btn:hover {
    background: var(--surface-soft);
    box-shadow: 0 0 0 1px #DBC2B7, 0 2px 6px rgba(115, 37, 35, 0.07), 0 6px 20px rgba(115, 37, 35, 0.07);
  }
  .new-btn svg { display: block; width: 22px; height: 22px; }

  .back-btn {
    border: 1px solid #FFFDFB;
    background: #FFFBF8;
    color: var(--ink);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    text-decoration: none;
    box-shadow: 0 0 0 1px #E8D3CA, 0 2px 6px rgba(115, 37, 35, 0.05), 0 6px 20px rgba(115, 37, 35, 0.05);
  }
  .back-btn:hover {
    background: var(--surface-soft);
    box-shadow: 0 0 0 1px #DBC2B7, 0 2px 6px rgba(115, 37, 35, 0.07), 0 6px 20px rgba(115, 37, 35, 0.07);
  }
  .back-btn svg { width: 21px; height: 21px; }

  /* ── Messages ──────────────────────────────── */
  .messages-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-height: 0;
  }
  .messages-blur-overlay {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 60px;
    z-index: 2;
    pointer-events: none;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    -webkit-mask-image: linear-gradient(to bottom, black 0%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 0%, transparent 100%);
  }
  .messages {
    height: 100%;
    overflow-y: auto;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0.5) 0px, black 60px);
    mask-image: linear-gradient(to bottom, rgba(0,0,0,0.5) 0px, black 60px);
  }
  .messages::-webkit-scrollbar { width: 6px; }
  .messages::-webkit-scrollbar-track { background: transparent; }
  .messages::-webkit-scrollbar-thumb {
    background: var(--hairline);
    border-radius: 3px;
  }
  .messages::-webkit-scrollbar-thumb:hover { background: var(--surface-cream-strong); }

  .empty {
    margin: auto;
    text-align: center;
    position: relative;       /* 问候语绝对定位的锚点 */
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .empty-mark { width: 40px; height: 40px; }
  .empty-mark svg { display: block; width: 100%; height: 100%; }
  .empty-greet {
    position: absolute;       /* 拿出流：以花本身居中，问候语挂在花下方 */
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 10px;
    white-space: nowrap;
    font-family: "EB Garamond", var(--font-serif);
    font-size: 26px;
    font-weight: 400;
    color: var(--ink);
    letter-spacing: -0.2px;
  }

  /* ── Chat rows ──────────────────────────────── */
  .row {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .row.user { align-items: flex-end; }
  .row.assistant { align-items: flex-start; }

  .msg-time {
    font-size: 11px;
    color: var(--muted-soft);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    line-height: 1.4;
  }
  .row.user .msg-time { padding-right: 2px; }
  .row.assistant { gap: 0; }

  .msg-meta {
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .row.user .msg-meta { flex-direction: row-reverse; }
  .msg-copy {
    border: none;
    background: none;
    cursor: pointer;
    color: var(--muted);
    padding: 0;
    display: inline-flex;
    align-items: center;
  }
  .msg-copy i, .msg-copy svg { width: 17px; height: 17px; }

  .bubble {
    max-width: 75%;
    padding: 12px 16px;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.55;
    white-space: pre-wrap;
    word-wrap: break-word;
  }

  .row.user .bubble {
    background: #EECDCC;
    color: var(--ink);
    border-radius: 20px 20px 8px 20px;
    max-height: 320px;
    overflow-y: auto;
  }

  .row.assistant .bubble {
    background: transparent;
    color: var(--body);
    font-family: var(--font-body-serif);   /* AI 正文用 EB Garamond（中文回退同 Inter）*/
    border-radius: var(--rounded-lg) var(--rounded-lg) var(--rounded-lg) var(--rounded-sm);
    padding: 12px 4px 12px 0;
    max-width: 100%;
  }

  .bubble.thinking {
    color: var(--muted-soft);
    font-style: italic;
  }
  /* 思考指示：官方 Claude 标记，纯大小缩放呼吸（不变浅）*/
  /* thinking: official per-frame Spark animation */
  .spark-thinking { display: inline-block; overflow: hidden; width: 26px; aspect-ratio: 1 / 1; color: #A76363; vertical-align: middle; }
  .spark-thinking .spark-frames { display: block; will-change: transform; }
  .spark-thinking svg { display: block; width: 100%; fill: currentColor; }

  /* ── 互动内容：AI 回复里的 ```html 块 → 沙箱 iframe 卡片 ── */
  .bubble.has-artifact { width: 100%; }
  .artifact {
    margin: 10px 0 4px;
    border: 1px solid var(--hairline);
    border-radius: 16px;
    overflow: hidden;
    background: var(--canvas);
    box-shadow: 0 1px 4px rgba(115, 37, 35, 0.06);
  }
  .artifact-head {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 10px 8px 14px;
    background: var(--surface-soft);
    border-bottom: 1px solid var(--hairline);
    font-family: var(--font-sans);
    font-size: 12.5px; font-weight: 500; color: var(--muted);
  }
  .artifact-head i, .artifact-head svg { width: 15px; height: 15px; }
  .artifact-head .af-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-left: 3px; }
  .af-btn {
    flex-shrink: 0;
    width: 30px; height: 30px; border-radius: 50%;
    border: none; background: transparent; color: var(--muted);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .af-btn:hover { background: var(--surface-cream-strong); }
  .af-btn:active { transform: scale(0.92); }
  .artifact-frame { display: block; width: 100%; height: 400px; border: none; background: #fff; }
  .artifact-code {
    display: none; margin: 0; padding: 12px 14px;
    max-height: 320px; overflow: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px; line-height: 1.5;
    color: var(--body); background: var(--surface-soft);
    white-space: pre;
  }
  .artifact.show-code .artifact-frame { display: none; }
  .artifact.show-code .artifact-code { display: block; }
  .artifact-pending {
    display: flex; align-items: center; gap: 9px;
    margin: 10px 0 4px; padding: 14px 16px;
    border: 1px dashed var(--hairline); border-radius: 16px;
    font-family: var(--font-sans); font-size: 13.5px; color: var(--muted-soft);
    animation: afPulse 1.6s ease-in-out infinite;
  }
  .artifact-pending i, .artifact-pending svg { width: 16px; height: 16px; color: var(--primary); }
  @keyframes afPulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
  .af-full {
    position: fixed; inset: 0; z-index: 200;
    background: var(--canvas);
    display: flex; flex-direction: column;
  }
  .af-full-head {
    display: flex; align-items: center; gap: 10px;
    padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
    border-bottom: 1px solid var(--hairline);
    font-family: var(--font-sans); font-size: 14px; font-weight: 500; color: var(--ink);
  }
  .af-full-head .af-btn { width: 34px; height: 34px; }
  .af-full iframe { flex: 1; width: 100%; border: none; background: #fff; }

  /* 搜索跳转：定位到的消息短暂高亮 */
  .row.msg-flash .bubble { animation: msgFlash 1.9s ease; }
  @keyframes msgFlash {
    0%   { box-shadow: 0 0 0 0 rgba(167, 99, 99, 0); }
    16%  { box-shadow: 0 0 0 4px rgba(167, 99, 99, 0.38); }
    100% { box-shadow: 0 0 0 0 rgba(167, 99, 99, 0); }
  }

  .bubble.error {
    background: #FBEAE4;
    color: var(--error);
    border: 1px solid #F2CDBF;
    border-radius: var(--rounded-lg);
    padding: 12px 16px;
  }

  .bubble-img {
    display: block;
    max-width: 100%;
    max-height: 280px;
    border-radius: var(--rounded-md);
    cursor: zoom-in;
  }
  .bubble-text + .bubble-img { margin-top: 8px; }

  .row.assistant .bubble.tool-note {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 2px 4px;
    color: var(--muted-soft);
    font-size: 12px;
    font-style: italic;
  }

  /* ── Thinking fold ──────────────────────────── */
  .think-note { max-width: 80%; margin-bottom: 14px; }
  .think-note summary {
    cursor: pointer;
    list-style: none;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: none;
    background: transparent;
    padding: 0;
    font-family: inherit;
  }
  .think-note summary::-webkit-details-marker { display: none; }
  .think-note summary .think-clock { width: 17px; height: 17px; flex-shrink: 0; color: var(--muted); }
  .think-note summary .think-label { font-size: 14px; color: var(--muted); }
  .think-note summary .think-chevron { width: 14px; height: 14px; transition: transform 0.2s; color: var(--muted); }
  .think-note[open] summary .think-chevron { transform: rotate(90deg); }
  .row:has(> .think-note) { margin-bottom: -28px; }

  .think-body {
    margin-top: 12px;
    padding-left: 14px;
    border-left: 2px solid #E9CFC6;
    max-height: 320px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 15px;
    line-height: 1.55;
  }
  .think-body .seg-think { color: var(--body); }
  .think-body .seg-tool { color: var(--muted-soft); margin: 6px 0 2px; }

  /* 语音消息条 */
  .bubble.voice-bubble { padding: 9px 12px; }
  .voice-msg { display: flex; align-items: center; gap: 10px; cursor: pointer; min-width: 116px; }
  .voice-play {
    width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
    border: none; background: var(--primary); color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
  }
  .voice-play svg { width: 18px; height: 18px; display: block; }
  .voice-play .ic-pause { display: none; }
  .voice-play.playing .ic-play { display: none; }
  .voice-play.playing .ic-pause { display: block; }
  .voice-wave { display: flex; align-items: center; gap: 2px; height: 20px; flex: 1; }
  .voice-wave i { width: 2.5px; border-radius: 2px; background: var(--muted-soft); height: 35%; }
  .voice-wave i:nth-child(2n) { height: 65%; }
  .voice-wave i:nth-child(3n) { height: 90%; }
  .voice-wave i:nth-child(3n+1) { height: 50%; }
  .voice-dur { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }

  /* 回到最新消息按钮（翻历史时浮现，输入框上方 3mm 居中）*/
  .scroll-bottom-btn {
    position: absolute;
    bottom: 3mm;
    left: 50%;
    z-index: 5;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid #FFFDFB;
    background: #FFFBF8;
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 0 0 1px #E8D3CA, 0 2px 6px rgba(115, 37, 35, 0.05), 0 6px 20px rgba(115, 37, 35, 0.07);
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(6px);
    transition: opacity 0.18s ease, transform 0.18s ease;
  }
  .scroll-bottom-btn.show {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
  }
  .scroll-bottom-btn:hover {
    background: var(--surface-soft);
    box-shadow: 0 0 0 1px #DBC2B7, 0 2px 6px rgba(115, 37, 35, 0.07), 0 6px 20px rgba(115, 37, 35, 0.09);
  }
  .scroll-bottom-btn svg { width: 19px; height: 19px; }

  /* ── Composer ──────────────────────────────── */
  .composer {
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--canvas);
    border-top: none;
    flex-shrink: 0;
  }

  .composer-box {
    position: relative;
    background: #FFFBF8;
    border: 1px solid #FFFDFB;
    border-radius: 28px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 0 0 1px #E8D3CA, 0 1px 3px rgba(115, 37, 35, 0.05), 0 2px 8px rgba(115, 37, 35, 0.04);
  }

  /* 录音浮层条（盖在输入框上）*/
  .recording-bar {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: #FFFBF8;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    z-index: 6;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
  .recording-bar[hidden] { display: none; }
  .rec-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--error); flex-shrink: 0;
    animation: recPulse 1s ease-in-out infinite;
  }
  @keyframes recPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
  .rec-time {
    font-family: var(--font-sans); font-size: 16px; font-weight: 500;
    color: var(--ink); font-variant-numeric: tabular-nums;
  }
  .rec-hint { margin-left: auto; font-size: 13px; color: var(--muted-soft); }
  .recording-bar.cancel .rec-dot { background: var(--muted-soft); animation: none; }
  .recording-bar.cancel .rec-hint { color: var(--error); }

  textarea {
    flex: 1;
    resize: none;
    max-height: 128px;
    min-height: 24px;
    padding: 14px 18px 4px;
    border: none;
    border-radius: 0;
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.5;
    background: transparent;
    color: var(--ink);
    outline: none;
  }
  textarea::placeholder { color: var(--muted-soft); }

  .composer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px 10px;
  }

  .toolbar-left {
    display: flex;
    align-items: center;
    gap: 2px;
  }

  .toolbar-right {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  .attach-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    color: #4B2A26;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s;
  }
  .attach-btn i { width: 20px; height: 20px; }
  .attach-btn:hover { background: #F0DCD4; }
  .attach-btn:disabled { opacity: 0.4; cursor: not-allowed; }

  .voice-btn {
    flex-shrink: 0;
    margin-right: 4px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    color: #9C7B71;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
  }
  .voice-btn i { width: 20px; height: 20px; }
  .voice-btn:hover { background: #F0DCD4; }

  .voice-active-btn {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border: none;
    background: #732523;
    border-radius: 50%;
    cursor: pointer;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s;
  }
  .voice-active-btn i { width: 20px; height: 20px; }
  .voice-active-btn:hover { background: #8C4441; }

  .send-btn {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--primary);
    color: #ffffff;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.12s;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .send-btn i { width: 18px; height: 18px; }
  .send-btn:hover { background: var(--primary-active); }
  .send-btn:disabled { background: #E5CFC7; color: #B99C92; cursor: not-allowed; }

  .toolbar-right .hidden { display: none; }

  /* ── File chip ──────────────────────────────── */
  .file-preview { padding: 10px 14px 4px; }
  .file-preview[hidden] { display: none; }
  .preview-thumb {
    display: block;
    max-width: 120px;
    max-height: 120px;
    border-radius: 10px;
    object-fit: cover;
  }
  .file-name-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--surface-soft);
    border: 1px solid var(--hairline);
    border-radius: var(--rounded-md);
    font-size: 13px;
    font-weight: 500;
    color: var(--body);
  }
  .file-name-chip .file-icon { width: 14px; height: 14px; color: var(--muted); flex-shrink: 0; }
  .file-name-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
  .preview-remove {
    position: absolute;
    top: -6px;
    left: -6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: rgba(75, 42, 38, 0.65);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
  }
  .preview-remove:hover { background: rgba(75, 42, 38, 0.85); }
  .preview-remove i { width: 13px; height: 13px; }
  /* 多文件预览：一排缩略图/名字牌，每个自带移除键 */
  .file-preview-inner { display: flex; flex-wrap: wrap; gap: 10px; }
  .fp-item { position: relative; display: inline-flex; }
  .fp-item .preview-thumb { max-width: 84px; max-height: 84px; }

  /* ── Login ──────────────────────────────── */
  .login-overlay {
    position: fixed;
    inset: 0;
    background: var(--canvas);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 24px;
  }
  .login-overlay[hidden] { display: none; }
  .login-card {
    width: min(92%, 340px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
  }
  .login-icon {
    width: 52px; height: 52px;
    border-radius: 50%;
    background: var(--surface-card);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
  }
  .login-icon i { width: 26px; height: 26px; }
  .login-title {
    font-family: var(--font-serif);
    font-size: 24px;
    font-weight: 400;
    color: var(--ink);
    letter-spacing: -0.3px;
    margin-bottom: 4px;
  }
  .login-form { width: 100%; display: flex; flex-direction: column; gap: 10px; }
  .login-input {
    width: 100%;
    height: 46px;
    padding: 0 16px;
    border: 1px solid #FFFDFB;
    background: #FFFBF8;
    border-radius: 14px;
    box-shadow: 0 0 0 1px #E8D3CA, 0 1px 3px rgba(115, 37, 35, 0.04);
    font-family: var(--font-sans);
    font-size: 16px;
    color: var(--ink);
    outline: none;
    transition: box-shadow 0.15s;
  }
  .login-input::placeholder { color: var(--muted-soft); }
  .login-input:focus { box-shadow: 0 0 0 2px var(--primary); }
  .login-btn {
    height: 46px;
    border: none;
    border-radius: 14px;
    background: var(--primary);
    color: var(--on-primary);
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
  }
  .login-btn:hover { background: var(--primary-active); }
  .login-btn:disabled { background: var(--primary-disabled); color: var(--muted-soft); cursor: not-allowed; }
  .login-error { color: var(--error); font-size: 13px; min-height: 16px; line-height: 1.4; }

  /* ── Sidebar (会话列表) ──────────────────────── */
  .header-left { display: flex; align-items: center; gap: 8px; }
  .hamburger-btn {
    border: 1px solid #FFFDFB; background: #FFFBF8; cursor: pointer;
    width: 40px; height: 40px; border-radius: 50%; padding: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--ink); transition: all 0.15s;
    box-shadow: 0 0 0 1px #E8D3CA, 0 2px 6px rgba(115, 37, 35, 0.05), 0 6px 20px rgba(115, 37, 35, 0.05);
  }
  .hamburger-btn:hover {
    background: var(--surface-soft);
    box-shadow: 0 0 0 1px #DBC2B7, 0 2px 6px rgba(115, 37, 35, 0.07), 0 6px 20px rgba(115, 37, 35, 0.07);
  }
  .hamburger-btn svg { width: 21px; height: 21px; }

  .sidebar {
    flex: 0 0 auto;
    width: 310px;
    background: var(--canvas);
    overflow: hidden;
    display: flex;
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-inner {
    width: 310px; height: 100%;
    display: flex; flex-direction: column;
    padding-top: env(safe-area-inset-top);
  }
  .sidebar-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px;
    padding: 9px 14px 8px 18px;
  }
  .sidebar-brand {
    font-family: var(--font-serif);
    font-size: 28px; font-weight: 600; color: var(--ink);
    letter-spacing: -0.3px; line-height: 1.2;
  }
  .sidebar-brand span { display: inline-block; vertical-align: baseline; }
  .sidebar-brand .sw-stem { transform: scaleY(0.84); transform-origin: center 80%; }
  .sidebar-brand .sw-tilt { transform: rotate(-10deg); }
  .sidebar-head-actions { display: flex; align-items: center; gap: 2px; }
  .sb-icon-btn {
    border: none; background: transparent; cursor: pointer;
    width: 34px; height: 34px; border-radius: 9px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--muted);
  }
  .sb-icon-btn i { width: 19px; height: 19px; }
  .sb-icon-btn svg { stroke-width: 1.75; }

  .new-chat-btn {
    margin: 2px 12px 6px;
    display: flex; align-items: center; gap: 10px;
    border: none; background: transparent; cursor: pointer;
    padding: 6px 8px; border-radius: 12px;
    font-family: var(--font-sans); font-size: 14px; font-weight: 400; color: var(--body);
    transition: background 0.12s;
  }
  .new-chat-btn:hover { background: var(--surface-soft); }
  .new-chat-btn .plus-circle {
    width: 34px; height: 34px; border-radius: 50%;
    background: #FFFBF8; border: 1px solid #FFFDFB; color: var(--ink);
    box-shadow: 0 0 0 1px #E8D3CA, 0 2px 6px rgba(115, 37, 35, 0.05), 0 6px 20px rgba(115, 37, 35, 0.05);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  }
  .new-chat-btn .plus-circle svg { width: 18px; height: 18px; }

  .new-chat-divider {
    margin: 4px 14px 2px;
    height: 0;
    border: none;
    border-top: 1px solid #FFFDFB;
    box-shadow: 0 0.5px 3px rgba(115, 37, 35, 0.06), 0 1px 8px rgba(115, 37, 35, 0.04);
  }

  .sidebar-search { padding: 0 12px 6px; }
  .sidebar-search[hidden] { display: none; }
  .sidebar-search input {
    width: 100%; height: 38px; padding: 0 14px;
    border: 1px solid var(--hairline); background: var(--surface-soft);
    border-radius: 10px; font-family: var(--font-sans); font-size: 14px;
    color: var(--ink); outline: none; transition: border-color 0.12s;
  }
  .sidebar-search input::placeholder { color: var(--muted-soft); }
  .sidebar-search input:focus { border-color: var(--primary); }

  .sidebar-scroll {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    scrollbar-width: thin; scrollbar-color: #DBBFB4 transparent;
  }
  .sidebar-scroll::-webkit-scrollbar { width: 11px; }
  .sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
  .sidebar-scroll::-webkit-scrollbar-thumb {
    background: #DBBFB4; border-radius: 6px;
    border: 3px solid var(--canvas);
  }
  .sidebar-scroll::-webkit-scrollbar-thumb:hover { background: #C6A294; }

  .session-list { padding: 2px 8px 12px; display: flex; flex-direction: column; gap: 1px; }
  .session-list[hidden] { display: none; }
  .session-group-label {
    font-size: 12px; font-weight: 500; color: var(--muted-soft);
    padding: 14px 12px 4px;
  }
  .session-group-label:first-child { padding-top: 4px; }
  .session-item {
    padding: 6px 10px;
    border-radius: 10px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    transition: background 0.12s;
  }
  .session-item:hover { background: var(--surface-soft); }
  .session-item.active, .session-item.active:hover { background: #EECDCC; }
  .session-name {
    font-size: 14px; font-weight: 400; line-height: 1.55; color: var(--body);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }

  /* 搜索结果 */
  .search-results { padding: 2px 8px 12px; display: flex; flex-direction: column; gap: 1px; }
  .search-results[hidden] { display: none; }
  .search-empty { padding: 16px 14px; color: var(--muted-soft); font-size: 13px; line-height: 1.5; }
  .search-item {
    padding: 9px 12px; border-radius: 12px; cursor: pointer; transition: background 0.12s;
  }
  .search-item:hover { background: var(--surface-soft); }
  .search-item .si-name {
    font-size: 14px; font-weight: 500; color: var(--ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .search-item .si-snippet {
    font-size: 12px; color: var(--muted); line-height: 1.45; margin-top: 2px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .search-item .si-role { color: var(--muted-soft); }
  .search-item .si-hl { background: rgba(167, 99, 99, 0.20); color: var(--ink); border-radius: 3px; padding: 0 1px; }

  .sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(115, 37, 35, 0.32);
    z-index: 55; opacity: 0; pointer-events: none;
    transition: opacity 0.22s;
  }
  body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }

  /* 桌面端：侧边栏并入布局，可折叠（宽度动画） */
  @media (min-width: 601px) {
    .sidebar {
      position: relative;
      transform: none;
      z-index: auto;
      width: 0;
      transition: width 0.2s ease;
    }
    body.sidebar-open .sidebar { width: 310px; border-right: 1px solid var(--hairline); }
    .sidebar-backdrop { display: none; }
  }

  /* ── 右键 / 长按菜单 ──────────────────────── */
  .ctx-menu {
    position: fixed; z-index: 80;
    background: var(--canvas);
    border: 1px solid var(--hairline);
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(115, 37, 35, 0.14);
    padding: 4px; min-width: 136px;
  }
  .ctx-menu[hidden] { display: none; }
  .ctx-item {
    width: 100%; display: flex; align-items: center; gap: 9px;
    border: none; background: transparent; cursor: pointer;
    font-family: var(--font-sans); font-size: 14px; color: var(--body);
    padding: 9px 10px; border-radius: 8px; text-align: left;
  }
  .ctx-item:hover { background: var(--surface-soft); }
  .ctx-item i { width: 15px; height: 15px; }
  .ctx-item.ctx-danger { color: var(--error); }
  .ctx-item.ctx-danger:hover { background: #FBEAE4; }

  /* ── 重命名 / 删除 弹窗 ──────────────────────── */
  .sb-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(115, 37, 35, 0.3);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 120; padding: 24px;
  }
  .sb-modal-overlay[hidden] { display: none; }
  .sb-modal-card {
    background: var(--canvas); border: 1px solid var(--hairline);
    border-radius: 16px; box-shadow: 0 12px 40px rgba(115, 37, 35, 0.15);
    padding: 22px 20px 16px; width: min(90%, 320px);
  }
  .sb-modal-title {
    font-family: var(--font-serif); font-size: 19px; color: var(--ink);
    text-align: center; letter-spacing: -0.2px; line-height: 1.45;
    margin-bottom: 16px; white-space: pre-line;
  }
  .sb-modal-input {
    width: 100%; height: 44px; padding: 0 14px; margin-bottom: 16px;
    border: 1px solid #FFFDFB; background: #FFFBF8; border-radius: 12px;
    box-shadow: 0 0 0 1px #E8D3CA;
    font-family: var(--font-sans); font-size: 16px; color: var(--ink); outline: none;
  }
  .sb-modal-input[hidden] { display: none; }
  .sb-modal-input:focus { box-shadow: 0 0 0 2px var(--primary); }
  .sb-modal-actions { display: flex; gap: 10px; }
  .sb-modal-btn {
    flex: 1; height: 42px; border-radius: 10px;
    font-family: var(--font-sans); font-size: 14px; font-weight: 500;
    cursor: pointer; border: 1px solid var(--hairline);
  }
  .sb-modal-btn.cancel { background: transparent; color: var(--muted); }
  .sb-modal-btn.cancel:hover { background: var(--surface-soft); }
  .sb-modal-btn.ok { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
  .sb-modal-btn.ok:hover { background: var(--primary-active); }
  .sb-modal-btn.ok.danger { background: var(--error); border-color: var(--error); }

  /* ── 本窗口角色设定弹窗 ──────────────────────── */
  .rp-card { width: min(92%, 430px); }
  .rp-mode { display: flex; gap: 8px; margin-bottom: 12px; }
  .rp-mode-btn {
    flex: 1; height: 36px; border-radius: 10px; cursor: pointer;
    font-family: var(--font-sans); font-size: 13px; color: var(--muted);
    background: var(--surface-soft); border: 1px solid transparent;
    -webkit-tap-highlight-color: transparent;
  }
  .rp-mode-btn.active {
    background: rgba(167, 99, 99, 0.14); color: var(--primary-active);
    border-color: rgba(167, 99, 99, 0.35); font-weight: 500;
  }
  .rp-textarea {
    width: 100%; min-height: 170px; resize: vertical;
    padding: 12px 14px; margin-bottom: 10px;
    border: 1px solid #FFFDFB; background: #FFFBF8; border-radius: 12px;
    box-shadow: 0 0 0 1px #E8D3CA;
    font-family: var(--font-sans); font-size: 15px; line-height: 1.55; color: var(--ink);
    outline: none;
  }
  .rp-textarea:focus { box-shadow: 0 0 0 2px var(--primary); }
  .rp-hint { font-size: 12px; color: var(--muted-soft); line-height: 1.5; margin-bottom: 14px; }
  .rp-clear {
    width: 100%; margin-top: 10px; padding: 6px;
    background: none; border: none; cursor: pointer;
    font-family: var(--font-sans); font-size: 13px; color: var(--error);
    -webkit-tap-highlight-color: transparent;
  }
  .rp-clear[hidden] { display: none; }

  /* 空状态下的角色设定入口（挂在问候语下方） */
  .empty-rp {
    position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
    margin-top: 64px;
    display: flex; align-items: center; gap: 6px;
    background: none; border: none; cursor: pointer;
    font-family: var(--font-sans); font-size: 13px; color: var(--muted-soft);
    padding: 6px 12px; border-radius: 999px;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
  }
  .empty-rp:hover { color: var(--body); background: var(--surface-soft); }
  .empty-rp.has { color: var(--primary-active); }
  .empty-rp i { width: 14px; height: 14px; }

  /* 侧栏会话的角色设定标记 */
  .session-item.has-rp { display: flex; align-items: center; gap: 6px; }
  .session-item.has-rp .session-name { flex: 1; min-width: 0; }
  .session-rp-ico { flex-shrink: 0; width: 13px; height: 13px; color: var(--primary); opacity: 0.75; display: flex; }
  .session-rp-ico svg { display: block; width: 100%; height: 100%; }

  /* Left-edge swipe zone: blocks iOS back gesture */
  .edge-swipe-zone {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 20px;
    z-index: 50;
    touch-action: none;
  }
  @media (min-width: 601px) { .edge-swipe-zone { display: none; } }

  /* ── Mobile ──────────────────────────────── */
  @media (max-width: 600px) {
    header { padding: calc(1px + env(safe-area-inset-top)) 12px 2px; }
    /* 顶栏上 padding 含安全区、不对称：把绝对居中的 model name 往下补偿，落回内容盒中心、与图标对齐 */
    .model-menu { transform: translate(-50%, calc(-50% + (env(safe-area-inset-top) - 1px) / 2)); }
    .messages { padding: 16px 12px; gap: 12px; }
    .messages-blur-overlay { height: 50px; }
    .messages {
      -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0.5) 0px, black 50px);
      mask-image: linear-gradient(to bottom, rgba(0,0,0,0.5) 0px, black 50px);
    }
    .bubble { max-width: 88%; }
    .think-note { max-width: 92%; }
    .composer { padding: 8px 3mm 8px; }
    .composer-box { border-radius: 24px; }
    textarea { font-size: 16px; padding: 12px 14px 4px; }
    .composer-toolbar { padding: 4px 6px 8px; }
    .sidebar { width: min(288px, 84vw); }
    .sidebar-inner { width: min(288px, 84vw); }
    .session-name { font-size: 16px; }
    .new-chat-btn { font-size: 16px; }
    .session-item { padding: 7px 12px; border-radius: 12px; }
  }

/* ── 重roll / 编辑消息 / 分支切换 ─────────────────────────── */
.msg-ctl { display: inline-flex; align-items: center; gap: 10px; }
/* 统一操作按钮：28px 圆形点击区 + 17px 图标（与复制按钮同规格，防误触） */
.msg-act, .branch-nav {
  border: none; background: none; cursor: pointer;
  color: var(--muted); padding: 0;
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.msg-act i, .msg-act svg, .branch-nav i, .branch-nav svg { width: 17px; height: 17px; }
.msg-act:hover, .branch-nav:hover:not(:disabled) { background: var(--surface-soft); }
.msg-act:active, .branch-nav:active:not(:disabled) { transform: scale(0.92); }
.branch-nav:disabled { opacity: 0.22; cursor: default; }
.branch-bar { display: inline-flex; align-items: center; gap: 0; user-select: none; }
.branch-count {
  font-family: var(--font-sans); font-size: 11px; color: var(--muted-soft);
  min-width: 26px; text-align: center; font-variant-numeric: tabular-nums;
}
/* 复制按钮跟进同一点击区规格；meta 行整体间距放大 */
.msg-copy { width: 28px; height: 28px; border-radius: 50%; justify-content: center; flex-shrink: 0; }
.msg-copy:hover { background: var(--surface-soft); }
.msg-meta { gap: 10px; }
.edited-tag { font-size: 10px; color: var(--muted-soft); }
.edit-area {
  width: 100%; min-height: 64px; max-height: 240px;
  border: 1px solid var(--hairline); background: #FFFBF8; border-radius: 12px;
  padding: 10px 12px; font-family: var(--font-sans); font-size: 15px; line-height: 1.5;
  color: var(--ink); resize: vertical; outline: none;
}
.edit-area:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(167, 99, 99, 0.12); }
.edit-btns { display: flex; gap: 8px; margin-top: 8px; justify-content: flex-end; }
.edit-btns button {
  padding: 6px 16px; border-radius: 999px; cursor: pointer;
  font-family: var(--font-sans); font-size: 13px; font-weight: 500;
  border: 1px solid var(--hairline); background: transparent; color: var(--muted);
  -webkit-tap-highlight-color: transparent;
}
.edit-btns button.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.row.user .bubble.editing {
  width: min(560px, 88%); max-width: none;
  background: transparent; padding: 0; overflow: visible; max-height: none;
}

/* ── 音乐卡片 + 迷你播放器（chat-music.js，[music:...] 标记渲染）───────── */
.music-card {
  display: flex; align-items: center; gap: 12px;
  width: 300px; max-width: 100%;
  margin: 8px 0 4px;
  padding: 10px 12px;
  border: 1px solid var(--hairline);
  border-radius: 16px;
  background: #FFFBF8;
  box-shadow: 0 1px 4px rgba(115, 37, 35, 0.06);
  cursor: pointer;
  font-family: var(--font-sans);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}
.music-card:hover { background: var(--surface-soft); }
.music-card.playing { border-color: #DBB4AC; box-shadow: 0 1px 6px rgba(115, 37, 35, 0.10); }
.mc-cover {
  position: relative; width: 46px; height: 46px; flex-shrink: 0;
  border-radius: 12px; overflow: hidden;
  background: var(--surface-card);
  display: flex; align-items: center; justify-content: center;
}
.mc-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.mc-note { color: var(--primary); font-size: 18px; line-height: 1; }
.mc-meta { flex: 1; min-width: 0; }
.mc-title {
  font-size: 14.5px; font-weight: 500; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.music-card.playing .mc-title { color: var(--primary-active); }
.mc-artist {
  font-size: 12.5px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mc-play {
  width: 34px; height: 34px; border-radius: 50%; border: none; flex-shrink: 0;
  background: var(--primary); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.mc-play:active { background: var(--primary-active); }
.mc-play i, .mc-play svg { width: 16px; height: 16px; }

.music-player {
  display: none;
  align-items: center; gap: 10px;
  margin: 0 16px 2px;
  padding: 8px 12px;
  background: #FFFBF8;
  border-radius: 18px;
  box-shadow: 0 0 0 1px #E8D3CA, 0 1px 3px rgba(115, 37, 35, 0.05);
  font-family: var(--font-sans);
  flex-shrink: 0;
}
.music-player.show { display: flex; }
.mp-cover {
  position: relative; width: 38px; height: 38px; flex-shrink: 0;
  border-radius: 10px; overflow: hidden;
  background: var(--surface-card);
  display: flex; align-items: center; justify-content: center;
}
.mp-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.mp-mid { flex: 1; min-width: 0; }
.mp-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.mp-title {
  font-size: 13.5px; font-weight: 500; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0;
  max-width: 60%;
}
.mp-artist {
  font-size: 11.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.music-player.mp-error .mp-artist { color: var(--error); }
.mp-seek { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.mp-time {
  font-size: 10.5px; color: var(--muted-soft);
  font-variant-numeric: tabular-nums; flex-shrink: 0;
}
.mp-range {
  flex: 1; -webkit-appearance: none; appearance: none;
  height: 3px; border-radius: 2px; background: var(--hairline);
  outline: none; margin: 0; padding: 0; cursor: pointer;
}
.mp-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 11px; height: 11px; border-radius: 50%; background: var(--primary); border: none;
}
.mp-range::-moz-range-thumb { width: 11px; height: 11px; border-radius: 50%; background: var(--primary); border: none; }
.mp-btn {
  width: 32px; height: 32px; border-radius: 50%; border: none; flex-shrink: 0;
  background: transparent; color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.mp-btn:hover { background: var(--surface-soft); }
.mp-btn i, .mp-btn svg { width: 17px; height: 17px; }
.mp-toggle { background: var(--primary); color: #fff; }
.mp-toggle:hover { background: var(--primary-active); }

/* ── 全屏歌词页 + 歌单浮层（chat-music.js 二期）───────────────────── */
.lyric-full, .music-list {
  position: fixed; inset: 0; z-index: 300;
  background: var(--canvas);
  display: none; flex-direction: column;
  padding-top: calc(6px + env(safe-area-inset-top));
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  font-family: var(--font-sans);
}
.lyric-full.show, .music-list.show { display: flex; }

.lf-head, .ml-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; flex-shrink: 0;
}
.lf-titles { flex: 1; min-width: 0; text-align: center; }
.lf-title {
  font-size: 16px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lf-artist {
  font-size: 12.5px; color: var(--muted); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lf-heart.on { color: var(--primary); }
.lf-heart.on svg { fill: var(--primary); }

.lf-lines {
  flex: 1; overflow-y: auto; padding: 30vh 28px;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 12%, #000 88%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 12%, #000 88%, transparent 100%);
}
.lf-line {
  padding: 9px 4px; text-align: center; cursor: pointer;
  transition: opacity 0.25s, transform 0.25s;
  opacity: 0.45;
  -webkit-tap-highlight-color: transparent;
}
.lf-line .lf-text {
  font-size: 17px; line-height: 1.5; color: var(--body);
  font-family: var(--font-body-serif);
}
.lf-line .lf-trans { font-size: 13px; line-height: 1.5; color: var(--muted); margin-top: 2px; }
.lf-line.active { opacity: 1; transform: scale(1.04); }
.lf-line.active .lf-text { color: var(--primary-active); font-weight: 600; }
.lf-empty {
  text-align: center; color: var(--muted-soft); font-size: 14px;
  padding: 34vh 20px 0; line-height: 1.8;
}
.music-list .lf-empty { padding-top: 60px; }

.lf-controls {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 18px; flex-shrink: 0;
}

.ml-title { flex: 1; font-size: 16px; font-weight: 600; color: var(--ink); text-align: center; }
.ml-body { flex: 1; overflow-y: auto; padding: 4px 14px 20px; }
.ml-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px; border-radius: 14px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ml-row:hover { background: var(--surface-soft); }
.ml-note {
  font-size: 12px; color: var(--muted-soft); margin-top: 3px;
  font-family: var(--font-body-serif);
  line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;                     /* 默认收 2 行，点备注展开全文 */
}
.ml-note.open { -webkit-line-clamp: unset; }
.ml-del { opacity: 0.55; }
.ml-del:hover { opacity: 1; }

/* ── 優紀的抗议标记（重roll紬的消息：撒娇仪式）───────────────────── */
.protest-bar {
  display: flex; flex-direction: column; gap: 6px;
  margin: 4px 0 2px; max-width: 78%;
}
.row.user .protest-bar { align-items: flex-end; align-self: flex-end; margin-right: 2px; }
.protest-note {
  font-family: var(--font-sans); font-size: 12px; line-height: 1.5;
  color: var(--primary-active);
  background: rgba(167, 99, 99, 0.10);
  border: 1px dashed rgba(167, 99, 99, 0.38);
  border-radius: 14px 14px 4px 14px;
  padding: 5px 12px;
}
.protest-actions { display: flex; gap: 8px; }
.protest-actions button {
  padding: 5px 14px; border-radius: 999px; cursor: pointer;
  font-family: var(--font-sans); font-size: 12px; font-weight: 500;
  border: 1px solid var(--hairline); background: transparent; color: var(--muted);
  -webkit-tap-highlight-color: transparent;
}
.protest-actions button:hover { background: var(--surface-soft); }
.protest-actions button.insist {
  border-color: rgba(180, 96, 58, 0.45); color: #B4603A;
}
.protest-actions button.insist:hover { background: rgba(237, 211, 173, 0.35); }
.protest-stamp {
  font-family: var(--font-sans); font-size: 11px; font-weight: 600;
  letter-spacing: 0.02em; color: #B4603A;
  background: rgba(237, 211, 173, 0.45);
  border: 1px solid rgba(221, 145, 98, 0.5);
  border-radius: var(--rounded-sm);
  padding: 3px 10px;
  transform: rotate(-1.2deg);
}
.protest-v0tag, .resay-tag { font-size: 10px; color: var(--muted-soft); font-family: var(--font-sans); }

/* ── 频谱可视化（预计算数据驱动，chat-music.js vizFrame）─────────────── */
.mp-viz {
  position: absolute; left: 0; right: 0; bottom: 0; height: 13px;
  display: flex; gap: 2px; align-items: flex-end;
  padding: 0 5px 2px; pointer-events: none;
}
.mp-viz i {
  flex: 1; height: 100%;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 2px;
  transform: scaleY(0.08); transform-origin: bottom;
  box-shadow: 0 0 3px rgba(75, 42, 38, 0.25);
}
.lf-spectrum {
  display: flex; gap: 4px; align-items: flex-end;
  height: 38px; padding: 0 30px; margin-bottom: 4px;
  flex-shrink: 0;
}
.lf-spectrum i {
  flex: 1; height: 100%;
  background: var(--primary); opacity: 0.7;
  border-radius: 3px 3px 1px 1px;
  transform: scaleY(0.06); transform-origin: bottom;
}

/* ── 语音录制条按钮（点击录制 → ■ 停止 → ↑ 发送 / ✕ 丢弃）───────────── */
.rec-btn {
  width: 34px; height: 34px; border-radius: 50%; border: none; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  background: var(--surface-soft); color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
.rec-btn i, .rec-btn svg { width: 16px; height: 16px; }
.rec-btn[hidden] { display: none; }
.rec-stop { background: var(--error); color: #fff; }
.rec-stop svg { fill: currentColor; width: 13px; height: 13px; }   /* 实心停止方块 */
.rec-send { background: var(--primary); color: #fff; }
.rec-send:active { background: var(--primary-active); }
.rec-discard { background: transparent; color: var(--muted); }
.recording-bar .rec-hint { margin-left: auto; margin-right: 10px; }
.recording-bar.review .rec-dot { background: var(--muted-soft); animation: none; }

/* ── 语音通话页（chat-call.js，callhome 批1）───────────────────────── */
.call-full {
  position: fixed; inset: 0; z-index: 320;
  background: var(--canvas);
  display: none; flex-direction: column; align-items: center;
  padding: calc(14px + env(safe-area-inset-top)) 22px calc(26px + env(safe-area-inset-bottom));
  font-family: var(--font-sans);
}
.call-full.show { display: flex; }
.cf-head { text-align: center; flex-shrink: 0; }
.cf-name { font-family: var(--font-serif); font-size: 30px; font-weight: 600; color: var(--ink); }
.cf-timer { font-size: 13px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.cf-orb-wrap { flex-shrink: 0; margin: 7vh 0 2vh; text-align: center; }
.cf-orb {
  width: 108px; height: 108px; border-radius: 50%; margin: 0 auto;
  background: radial-gradient(circle at 34% 30%, #DB9B9B, var(--primary) 62%, var(--primary-active));
  box-shadow: 0 6px 30px rgba(140, 68, 65, 0.35);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.cf-orb.talking { animation: cfTalk 1.15s ease-in-out infinite; }
.cf-orb.hearing { box-shadow: 0 6px 26px rgba(140, 68, 65, 0.28), 0 0 0 10px rgba(167, 99, 99, 0.08); }
.cf-orb.linger { animation: cfLinger 2.2s ease-in-out infinite; }
@keyframes cfTalk {
  0%, 100% { transform: scale(1); box-shadow: 0 6px 26px rgba(140, 68, 65, 0.30); }
  50% { transform: scale(1.07); box-shadow: 0 8px 44px rgba(140, 68, 65, 0.48); }
}
@keyframes cfLinger {
  0%, 100% { opacity: 1; } 50% { opacity: 0.55; }
}
.cf-state { margin-top: 16px; font-size: 13.5px; color: var(--muted); min-height: 20px; }
.cf-subs {
  flex: 1; width: min(560px, 100%); overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px; padding: 8px 2px;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 14%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 14%);
}
.cf-sub {
  max-width: 86%; padding: 8px 13px; border-radius: 15px;
  font-size: 14.5px; line-height: 1.5;
}
.cf-sub.you { align-self: flex-end; background: #EECDCC; color: var(--ink); border-radius: 15px 15px 5px 15px; }
.cf-sub.her { align-self: flex-start; background: var(--surface-soft); color: var(--body);
              font-family: var(--font-body-serif); border-radius: 15px 15px 15px 5px; }
.cf-controls { flex-shrink: 0; display: flex; gap: 26px; margin-top: 12px; }
.cf-btn {
  width: 60px; height: 60px; border-radius: 50%; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 2px 10px rgba(115, 37, 35, 0.18);
}
.cf-btn i, .cf-btn svg { width: 24px; height: 24px; }
.cf-donebtn { background: #FFFBF8; color: var(--ink); }
.cf-hangup { background: var(--error); color: #fff; }
.cf-hangup:active { transform: scale(0.94); }
