/* 留言視窗：右下角。顏色一律走 tokens.css 的變數。 */
.chat-launcher {
  position: fixed; right: 20px; bottom: 20px; z-index: 90; display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 22px; border-radius: 999px; border: 0; cursor: pointer; font: 700 17px/1 inherit;
  background: var(--primary-bg); color: var(--primary-fg); box-shadow: var(--shadow);
}
.chat-launcher:hover { background: var(--primary-bg-hover); }
.chat-launcher:focus-visible, .chat-close:focus-visible { outline: 3px solid var(--live); outline-offset: 3px; }
.chat-launcher.is-open { display: none; }
.chat-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 3px color-mix(in srgb, var(--live) 30%, transparent); }

.chat-panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 95; width: min(380px, 100vw - 24px); max-height: min(640px, 100dvh - 40px);
  display: flex; flex-direction: column; border-radius: 16px; overflow: hidden; background: var(--panel); color: var(--text);
  border: 1px solid var(--line-2); box-shadow: var(--shadow);
}
.chat-panel[hidden] { display: none; }
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; background: var(--panel-3); border-bottom: 1px solid var(--line); font-size: 18px; }
.chat-close { width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 26px; line-height: 1; cursor: pointer; }
.chat-close:hover { background: var(--tint-2); color: var(--text); }
.chat-log { flex: 1 1 auto; min-height: 120px; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; background: var(--bg-2); }
.chat-row { display: flex; }
.chat-me { justify-content: flex-end; }
.chat-bubble { margin: 0; max-width: 85%; padding: 10px 14px; border-radius: 14px; font-size: 16px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-them .chat-bubble { background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-me .chat-bubble { background: var(--primary-bg); color: var(--primary-fg); border-bottom-right-radius: 4px; }
.chat-form { display: grid; gap: 8px; padding: 12px 14px 14px; border-top: 1px solid var(--line); background: var(--panel); }
.chat-form .input { width: 100%; font-size: 16px; }
.chat-form textarea.input { resize: vertical; min-height: 76px; }
.chat-send { display: flex; align-items: center; gap: 12px; }
.chat-note { margin: 0; flex: 1; font-size: 13px; line-height: 1.5; color: var(--muted); }
.chat-trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
@media (max-width: 520px) {
  .chat-launcher { right: 14px; bottom: 14px; }
  .chat-panel { right: 12px; left: 12px; bottom: 12px; width: auto; }
}
@media (prefers-reduced-motion: no-preference) {
  .chat-panel { animation: chat-in .18s ease-out; }
  @keyframes chat-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
}
