/* 和绯栖聊聊天 (#/chat): portrait slot, settings drawer and the chat window. */
.chat-page { min-height:100vh; padding-bottom:40px; background:radial-gradient(ellipse at 6% 4%,#f6e3e7,transparent 34%),radial-gradient(ellipse at 98% 42%,#f4eadf,transparent 30%),var(--paper); color:var(--ink); }
.chat-intro { padding-block:44px 30px; }
.chat-intro .eyebrow { margin-bottom:16px; }
.chat-intro h1 { margin:0 0 12px; font:clamp(32px,4.2vw,50px)/1.35 var(--serif); letter-spacing:0; }
.chat-intro h1 em { font-style:normal; color:var(--rose); }
.chat-intro > p:not(.eyebrow) { margin:0; max-width:40em; color:var(--muted); font-size:13px; line-height:1.9; }

.chat-stage { display:grid; grid-template-columns:minmax(230px,300px) minmax(0,1fr); gap:44px; align-items:start; }

/* Portrait slot: once assets/chat/feiqi-chat.webp exists, replace .chat-portrait-frame with an <img> of it. */
.chat-portrait { position:sticky; top:24px; margin:0; }
.chat-portrait-frame, .chat-portrait img { display:block; width:100%; aspect-ratio:2/3; border:8px solid #fffaf6; border-radius:150px 150px 22px 22px; box-shadow:0 16px 40px #8e627017, 0 0 0 1px #e8d6cf; }
.chat-portrait img { height:auto; object-fit:cover; object-position:50% 18%; background:linear-gradient(160deg,#f7e7e9,#efdcd2); }
.chat-portrait figcaption { margin-top:14px; text-align:center; font:15px var(--serif); color:#8f6b72; }

.chat-column { display:grid; gap:16px; min-width:0; }

/* Settings drawer */
.chat-settings { background:#fffaf6; border:1px solid var(--line); border-radius:16px; }
.chat-settings > summary { display:flex; align-items:center; gap:12px; min-height:52px; padding:12px 18px; border-radius:16px; cursor:pointer; list-style:none; }
.chat-settings > summary::-webkit-details-marker { display:none; }
.chat-settings > summary::after { content:"▾"; flex:none; color:#b48a95; transition:transform .2s; }
.chat-settings[open] > summary::after { transform:rotate(180deg); }
.chat-settings > summary:focus-visible { outline:2px solid var(--rose); outline-offset:3px; }
.chat-settings-title { display:flex; align-items:center; gap:9px; font:17px var(--serif); color:var(--rose); white-space:nowrap; }
.chat-settings-title svg { width:20px; height:20px; color:#b07d8b; }
.chat-ready-badge { min-width:0; margin-left:auto; padding:5px 11px; overflow:hidden; border-radius:999px; background:#f4e4e4; color:#8b6471; font-size:11px; text-overflow:ellipsis; white-space:nowrap; }
.chat-ready-badge[data-ready="true"] { background:#ebf1e3; color:#57704b; }
.chat-settings-form { display:grid; grid-template-columns:1fr 1fr; gap:16px 18px; margin:0 18px; padding:18px 0 4px; border-top:1px dashed var(--line); }
.chat-format, .chat-remember, .chat-settings-actions, .chat-settings-status { grid-column:1 / -1; }
.chat-format { display:flex; flex-wrap:wrap; gap:8px; margin:0; padding:0; border:0; }
.chat-format legend { float:left; width:100%; margin-bottom:8px; padding:0; color:var(--muted); font-size:12px; }
.chat-format label { position:relative; }
.chat-format input { position:absolute; inset:0; margin:0; opacity:0; cursor:pointer; }
.chat-format span { display:inline-flex; align-items:center; min-height:40px; padding:8px 16px; border:1px solid #e4ced1; border-radius:20px; background:#fff; color:#8b6471; font-size:13px; }
.chat-format input:checked + span { border-color:#94566e; background:#94566e; color:#fff; }
.chat-format input:focus-visible + span { outline:2px solid var(--rose); outline-offset:3px; }
.chat-field { display:grid; gap:7px; align-content:start; min-width:0; }
.chat-field > label { color:var(--muted); font-size:12px; }
.chat-field small { color:#b29b98; font-size:11px; }
.chat-field input, .chat-field select { width:100%; min-width:0; min-height:42px; padding:9px 12px; border:1px solid #e4d3d0; border-radius:10px; background:#fff; color:var(--ink); font:14px var(--sans); }
.chat-field input::placeholder, #chat-input::placeholder { color:#b9a8a5; }
.chat-field input:focus, .chat-field select:focus, #chat-input:focus { border-color:#c592a2; outline:2px solid #f2d6dd; outline-offset:0; }
.chat-inline { display:flex; gap:8px; min-width:0; }
.chat-inline button { flex:none; min-height:42px; padding:8px 12px; border:1px solid #e4ced1; border-radius:10px; background:#f8eeee; color:#8b5a6a; font-size:12px; }
.chat-inline button:hover { background:#f3e3e5; }
.chat-inline button:disabled { opacity:.55; cursor:progress; }
.chat-remember { display:flex; align-items:center; gap:9px; color:#6f5f5d; font-size:13px; cursor:pointer; }
.chat-remember input { width:17px; height:17px; margin:0; accent-color:#94566e; }
.chat-settings-actions { display:flex; flex-wrap:wrap; gap:10px; }
.chat-save, .chat-forget { min-height:42px; padding:9px 22px; border-radius:999px; font-size:13px; }
.chat-save { background:#94566e; color:#fff; }
.chat-save:hover { background:#834a60; }
.chat-forget { border:1px solid #e4ced1; background:transparent; color:#8b6471; }
.chat-forget:disabled { opacity:.45; cursor:default; }
.chat-settings-status { min-height:1.7em; margin:0; color:#8b5a6a; font-size:12px; line-height:1.7; overflow-wrap:anywhere; }
.chat-privacy { margin:4px 18px 18px; padding:12px 14px; border-radius:10px; background:#f7efe8; color:#7a6a66; font-size:12px; line-height:1.85; }
.chat-privacy strong { margin-right:4px; color:var(--rose); font-weight:600; }

/* Chat window */
.chat-window { display:flex; flex-direction:column; min-width:0; overflow:hidden; background:#fffaf6; border:1px solid var(--line); border-radius:22px; box-shadow:0 16px 40px #8e627012; }
.chat-window-top { display:flex; align-items:center; gap:12px; padding:14px 18px; border-bottom:1px dashed #ead9d4; background:linear-gradient(#fff5f2,#fffaf6); }
.chat-avatar { flex:none; width:48px; height:48px; border-radius:50%; object-fit:cover; background:#f6e1e4; box-shadow:0 0 0 3px #fff, 0 0 0 4px #efd3d9; }
.chat-who { display:grid; gap:1px; min-width:0; }
.chat-who strong { color:var(--rose); font:400 20px var(--serif); }
.chat-who span { display:flex; align-items:center; gap:6px; color:var(--muted); font-size:12px; }
.chat-who span::before { content:""; flex:none; width:7px; height:7px; border-radius:50%; background:#9cc28e; }
.chat-window:has(.chat-log[aria-busy="true"]) .chat-who span::before { background:var(--peach-deep); animation:chat-pulse 1.2s ease-in-out infinite; }
.chat-clear { flex:none; min-height:36px; margin-left:auto; padding:6px 13px; border:1px solid transparent; border-radius:999px; color:#9b7a82; font-size:12px; }
.chat-clear:hover { border-color:#ecd5d9; background:#fff; }
.chat-log { display:flex; flex-direction:column; gap:14px; height:min(56vh,560px); min-height:320px; margin:0; padding:22px 20px 14px; overflow-y:auto; overscroll-behavior:contain; list-style:none; background:radial-gradient(circle at 1px 1px,#f0e1dc 1px,transparent 1.5px) 0 0 / 18px 18px,#fffaf6; }
.chat-log:focus-visible { outline:2px solid var(--rose); outline-offset:-4px; }
.chat-msg { display:flex; max-width:100%; }
.chat-msg.from-you { justify-content:flex-end; }
.chat-bubble { max-width:min(80%,540px); margin:0; padding:10px 15px; font:15px/1.8 var(--sans); white-space:pre-wrap; overflow-wrap:anywhere; }
.from-feiqi .chat-bubble { border:1px solid #efdcd8; border-radius:4px 18px 18px 18px; background:#fff; color:var(--ink); box-shadow:0 3px 0 #f3e5e1; }
.from-you .chat-bubble { border-radius:18px 4px 18px 18px; background:#94566e; color:#fff8f6; box-shadow:0 3px 0 #e6ccd3; }
.chat-greeting .chat-bubble { border-style:dashed; background:#fdf1f2; }
.chat-action { color:#b07a8a; font-size:.9em; }
.chat-code { display:block; margin:8px 0; padding:10px 12px; overflow-x:auto; border:1px solid #eedfda; border-radius:10px; background:#faf4f1; color:#5b4a48; font:12.5px/1.6 var(--mono); white-space:pre; }
.chat-typing { display:inline-flex; gap:5px; padding-block:6px; vertical-align:middle; }
.chat-typing i { width:7px; height:7px; border-radius:50%; background:#dba6b3; animation:chat-dot 1.1s ease-in-out infinite; }
.chat-typing i:nth-child(2) { animation-delay:.15s; }
.chat-typing i:nth-child(3) { animation-delay:.3s; }
.chat-msg.chat-error { flex-direction:column; align-items:flex-start; gap:8px; max-width:min(88%,560px); padding:12px 15px; border:1px dashed #dc9fac; border-radius:14px; background:#fff3f3; color:#8a3d52; font-size:13px; line-height:1.7; }
.chat-error p { margin:0; overflow-wrap:anywhere; }
.chat-error button { min-height:34px; padding:5px 14px; border:1px solid #e3b5bf; border-radius:999px; background:#fff; color:#8a3d52; font-size:12px; }
.chat-suggestions { display:flex; flex-wrap:wrap; gap:8px; padding:12px 18px 2px; background:#fffaf6; }
.chat-suggestions button { min-height:36px; padding:5px 14px; border:1px solid #ecd3d8; border-radius:999px; background:#fff; color:#8b5a6a; font:15px var(--serif); }
.chat-suggestions button:hover { background:#fbeef0; }
.chat-composer { display:flex; align-items:flex-end; gap:10px; padding:12px 14px 14px; background:#fffaf6; }
#chat-input { flex:1; min-width:0; min-height:48px; max-height:160px; padding:12px 14px; border:1px solid #e4d3d0; border-radius:16px; background:#fff; color:var(--ink); font:15px/1.55 var(--sans); resize:none; field-sizing:content; }
.chat-send, .chat-stop { flex:none; min-height:48px; padding:10px 20px; border-radius:16px; font:17px var(--serif); }
.chat-send { background:#94566e; color:#fff; }
.chat-send:hover { background:#834a60; }
.chat-stop { border:1px solid #e4c4cb; background:#f6e7e7; color:#834a60; }
.chat-status { margin:0; padding:0 18px 12px; background:#fffaf6; color:#8b5a6a; font-size:12px; line-height:1.7; }
.chat-status:empty { display:none; }
@keyframes chat-dot { 0%, 80%, 100% { opacity:.45; transform:translateY(0); } 40% { opacity:1; transform:translateY(-4px); } }
@keyframes chat-pulse { 50% { opacity:.35; } }
/* One-click provider addresses, the visitor's note, stickers and the tools under the latest reply. */
.chat-presets { grid-column:1 / -1; display:grid; gap:8px; }
.chat-presets > span { color:var(--muted); font-size:12px; }
#chat-presets { display:flex; flex-wrap:wrap; gap:6px; }
#chat-presets button { min-height:34px; padding:5px 12px; border:1px dashed #e4ced1; border-radius:999px; background:#fffdfb; color:#8b6471; font-size:12px; }
#chat-presets button:hover { border-style:solid; background:#fff; }
#chat-presets button[aria-pressed="true"] { border-style:solid; border-color:#c592a2; background:#fbeef1; color:#7d3f55; }
.chat-field:has(#chat-about) { grid-column:1 / -1; }
.chat-field textarea { width:100%; min-height:64px; padding:9px 12px; border:1px solid #e4d3d0; border-radius:10px; background:#fff; color:var(--ink); font:14px/1.7 var(--sans); resize:vertical; }
.chat-field textarea::placeholder { color:#b9a8a5; }
.chat-field textarea:focus { border-color:#c592a2; outline:2px solid #f2d6dd; outline-offset:0; }
.chat-clear + .chat-clear { margin-left:0; }
.chat-msg.from-feiqi { flex-direction:column; align-items:flex-start; gap:6px; }
.chat-sticker { width:112px; height:112px; margin-left:4px; object-fit:contain; filter:drop-shadow(0 3px 0 #f3e5e1); animation:chat-sticker-in .35s ease-out; }
@keyframes chat-sticker-in { from { opacity:0; transform:scale(.7) rotate(-6deg); } to { opacity:1; transform:none; } }
.chat-tools { display:flex; gap:6px; margin-left:4px; }
.chat-tools button { min-height:32px; padding:3px 12px; border:1px solid #ecd9d8; border-radius:999px; background:#fffaf8; color:#8b6a72; font-size:12px; }
.chat-tools button:hover { border-color:#dcb9c1; background:#fff; color:#7d3f55; }
.chat-jump { position:relative; z-index:2; display:block; width:max-content; margin:-48px auto 12px; padding:6px 14px; border:1px solid #e4ced1; border-radius:999px; background:#fffdfb; color:#8b5a6a; font-size:12px; box-shadow:0 6px 16px #8e627024; }
.chat-jump[hidden] { display:none; }

@media (max-width:900px) {
  .chat-stage { grid-template-columns:1fr; gap:22px; }
  .chat-portrait { position:static; display:grid; grid-template-columns:112px 1fr; align-items:center; gap:18px; }
  .chat-portrait-frame, .chat-portrait img { aspect-ratio:1; border-width:5px; border-radius:56px 56px 14px 14px; }
  .chat-portrait img { object-position:50% 4%; }
  .chat-portrait figcaption { margin:0; text-align:left; font-size:16px; }
}
@media (max-width:640px) {
  .chat-intro { padding-block:28px 22px; }
  .chat-intro h1 { font-size:32px; }
  .chat-intro > p:not(.eyebrow) { font-size:12px; }
  .chat-settings-form { grid-template-columns:1fr; margin-inline:14px; }
  .chat-settings > summary { padding-inline:14px; }
  .chat-privacy { margin-inline:14px; }
  .chat-window { border-radius:18px; }
  .chat-window-top { padding:12px 14px; }
  .chat-log { height:min(60svh,540px); padding:18px 12px 12px; }
  .chat-bubble { max-width:86%; font-size:14px; }
  .chat-suggestions { padding-inline:12px; }
  .chat-suggestions button { font-size:14px; }
  .chat-composer { gap:8px; padding:10px; }
  .chat-send, .chat-stop { padding-inline:14px; font-size:15px; }
  .chat-sticker { width:96px; height:96px; }
  .chat-window-top { gap:10px; }
  .chat-who { flex:1; overflow:hidden; }
  .chat-who span { white-space:nowrap; }
  .chat-clear { padding-inline:8px; font-size:11px; }
}
@media (prefers-reduced-motion: reduce) {
  .chat-typing i, .chat-window:has(.chat-log[aria-busy="true"]) .chat-who span::before, .chat-sticker { animation:none; }
  .chat-settings > summary::after { transition:none; }
}
@media (forced-colors: active) {
  .chat-bubble, .chat-msg.chat-error { border:1px solid CanvasText; }
}
