/* ============================================================
   色议  编辑杂志风设计（Django 纯 HTML 移植版）
   ============================================================ */

@import url('https://chinese-fonts-cdn.deno.dev/packages/lxgwwenkai/dist/LXGWWenKai-Regular/result.css');
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Noto+Serif+SC:wght@400;500;600;700&display=swap');

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: 'Noto Serif SC', 'LXGW WenKai', 'Songti SC', 'STSong', serif;
  color: #2a1f1a;
  background: #2a1f1a;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* ============================================================
   全局布局
   ============================================================ */
.app {
  display: flex;
  height: 100vh;
  width: 100vw;
  background: #2a1f1a;
}

/* ============================================================
   侧栏 - 深咖啡色编辑感
   ============================================================ */
.sidebar {
  width: 300px;
  min-width: 300px;
  background: #2a1f1a;
  color: #d4c4b0;
  display: flex;
  flex-direction: column;
  position: relative;
  border-right: 1px solid #1f1612;
}

.sidebar::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 1px;
  height: 100%;
  background: linear-gradient(180deg, transparent, #c8a878 50%, transparent);
  opacity: 0.3;
}

.sidebar-brand {
  padding: 32px 28px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid rgba(200, 168, 120, 0.15);
}

.brand-mark {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, #c8a878 0%, #8b6f47 100%);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  position: relative;
}

.brand-mark::before {
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

.brand-kanji {
  font-family: 'Noto Serif SC', 'LXGW WenKai', serif;
  font-size: 28px;
  font-weight: 600;
  color: #2a1f1a;
  line-height: 1;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 22px;
  font-weight: 600;
  color: #f0e6d2;
  letter-spacing: 4px;
  line-height: 1.2;
}

.brand-sub {
  font-family: 'Cormorant Garamond', serif;
  font-size: 11px;
  font-style: italic;
  color: #8b7355;
  letter-spacing: 2px;
  margin-top: 2px;
  text-transform: uppercase;
}

/* 新对话按钮 */
.new-topic-btn {
  margin: 20px 24px;
  padding: 12px 18px;
  background: transparent;
  border: 1px solid rgba(200, 168, 120, 0.35);
  border-radius: 4px;
  color: #d4c4b0;
  font-family: 'Noto Serif SC', serif;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.25s ease;
  letter-spacing: 2px;
}

.new-topic-btn:hover {
  background: rgba(200, 168, 120, 0.08);
  border-color: #c8a878;
  color: #f0e6d2;
}

.plus-mark {
  font-size: 18px;
  line-height: 1;
  color: #c8a878;
}

/* 话题列表区 */
.topics-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.section-label {
  padding: 8px 28px 12px;
  font-family: 'Cormorant Garamond', serif;
  font-size: 10px;
  font-style: italic;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #8b7355;
}

.topics-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 16px;
}

.topic-item {
  position: relative;
  padding: 14px 14px 14px 22px;
  margin-bottom: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s;
  border-radius: 3px;
}

.topic-item:hover {
  background: rgba(200, 168, 120, 0.06);
}

.topic-item.active {
  background: rgba(200, 168, 120, 0.12);
}

.topic-line {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 0;
  background: #c8a878;
  transition: height 0.3s ease;
}

.topic-item:hover .topic-line,
.topic-item.active .topic-line {
  height: 60%;
}

.topic-body {
  flex: 1;
  min-width: 0;
}

.topic-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 14px;
  color: #e8dcc4;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.4;
}

.topic-item.active .topic-title {
  color: #f0e6d2;
}

.topic-pulse {
  width: 6px;
  height: 6px;
  background: #c8a878;
  border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

.topic-meta {
  font-family: 'Cormorant Garamond', serif;
  font-size: 11px;
  color: #8b7355;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.5px;
}

.topic-meta .dot {
  color: #5b4a3a;
}

.topic-del {
  opacity: 0;
  font-size: 18px;
  line-height: 1;
  color: #8b7355;
  padding: 4px 8px;
  transition: all 0.2s;
  border-radius: 3px;
}

.topic-item:hover .topic-del {
  opacity: 0.7;
}

.topic-del:hover {
  opacity: 1 !important;
  color: #c0392b;
  background: rgba(192, 57, 43, 0.1);
}

.empty-topics {
  padding: 40px 20px;
  text-align: center;
  color: #5b4a3a;
  font-family: 'Cormorant Garamond', serif;
  font-size: 13px;
  font-style: italic;
}

.empty-topics-mark {
  font-size: 32px;
  color: #5b4a3a;
  margin-bottom: 12px;
  font-style: normal;
}

.empty-topics .hint {
  font-size: 11px;
  color: #5b4a3a;
  margin-top: 6px;
  letter-spacing: 1px;
}

.sidebar-footer {
  padding: 16px 28px;
  border-top: 1px solid rgba(200, 168, 120, 0.15);
}

.conn {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Cormorant Garamond', serif;
  font-size: 12px;
  font-style: italic;
  letter-spacing: 1px;
}

.conn-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.conn.on {
  color: #8b7355;
}

.conn.on .conn-dot {
  background: #6b8e4e;
  box-shadow: 0 0 8px rgba(107, 142, 78, 0.6);
}

.conn.off {
  color: #8b4a3a;
}

.conn.off .conn-dot {
  background: #c0392b;
}

/* ============================================================
   聊天区 - 米白纸感
   ============================================================ */
.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #faf6f0;
  position: relative;
  min-width: 0;
}

/* 纸感纹理背景 */
.chat::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(200, 168, 120, 0.04) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(139, 111, 71, 0.04) 0%, transparent 50%);
  pointer-events: none;
}

.chat-header {
  padding: 18px 32px;
  /* iPhone 刘海/灵动岛安全区 */
  padding-top: calc(18px + env(safe-area-inset-top));
  background: #faf6f0;
  border-bottom: 1px solid #e8dcc4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  position: relative;
}

.chat-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.chat-title-text {
  font-family: 'Noto Serif SC', serif;
  font-size: 18px;
  font-weight: 600;
  color: #2a1f1a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 500px;
}

.chat-title-id {
  font-family: 'Cormorant Garamond', serif;
  font-size: 12px;
  font-style: italic;
  color: #8b7355;
  letter-spacing: 1px;
}

.chat-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* ============================================================
   输入区停止按钮（与 send-btn 互斥，同位置不同元素）
   ============================================================ */
.stop-btn-inline {
  width: 48px;
  height: 48px;
  min-height: 48px;
  border-radius: 50%;
  background: #fff;
  color: #c0392b;
  border: 2px solid #c0392b;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  cursor: pointer;
  padding: 0;
}

.stop-btn-inline:hover {
  background: #c0392b;
  color: #fff;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(192, 57, 43, 0.3);
}

.stop-btn-inline:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  background: #fff;
  color: #c0392b;
}

.stop-icon {
  font-size: 14px;
  transform: translateY(-1px);
}

/* ============================================================
   状态横幅（自然冷却 / 达到上限 / token 耗尽时插在消息流顶部）
   ============================================================ */
.status-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  margin: 8px auto 16px;
  max-width: 80%;
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Noto Serif SC', serif;
  letter-spacing: 0.3px;
  animation: bannerIn 0.3s ease-out;
}

@keyframes bannerIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.status-banner.banner-end {
  background: rgba(107, 142, 78, 0.10);
  color: #5a7a3e;
  border: 1px solid rgba(107, 142, 78, 0.25);
}

.status-banner.banner-token {
  background: rgba(217, 137, 16, 0.10);
  color: #8b6f47;
  border: 1px solid rgba(217, 137, 16, 0.30);
}

.banner-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.banner-text {
  flex: 1;
}

.banner-action {
  border: none;
  background: rgba(255, 255, 255, 0.5);
  color: inherit;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  font-family: 'Noto Serif SC', serif;
  letter-spacing: 0.5px;
  transition: all 0.15s;
}

.banner-action:hover {
  background: rgba(255, 255, 255, 0.9);
  font-weight: 600;
}

/* ============================================================
   顶部 topic-bar（话题标题 + 横排指示灯）
   ============================================================ */
.topic-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid #e8dcc4;
  background: rgba(250, 246, 240, 0.6);
  backdrop-filter: blur(6px);
  flex-shrink: 0;
  min-height: 56px;
}

.topic-bar-title {
  font-family: 'Cormorant Garamond', 'STSong', '宋体', serif;
  font-size: 18px;
  font-weight: 500;
  color: #2a1f1a;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  margin-right: 16px;
}

/* 横排指示灯容器 */
.floating-hats {
  display: flex;
  flex-direction: row;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.hat-orb {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--hat-color);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  position: relative;
  cursor: pointer;
  transition: all 0.25s;
  box-shadow: 0 1px 4px rgba(42, 31, 26, 0.12);
  overflow: visible;
}

.hat-orb:hover {
  transform: scale(1.12);
  box-shadow: 0 3px 10px rgba(42, 31, 26, 0.22);
}

.hat-orb-img {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  object-fit: cover;
  display: block;
}

/* idle 灰显 */
.hat-orb:not(.thinking) {
  opacity: 0.45;
  filter: grayscale(0.4);
}
.hat-orb:not(.thinking):hover {
  opacity: 0.85;
  filter: grayscale(0);
}

.hat-orb.thinking {
  opacity: 1;
  filter: none;
  transform: scale(1.08);
  box-shadow: 0 0 0 2px #f39c12,
              0 0 12px rgba(243, 156, 18, 0.6),
              0 3px 10px rgba(42, 31, 26, 0.25);
}

/* 图片加载失败 fallback（用 hat 颜色 + emoji） */
.hat-orb.avatar-fallback {
  background: var(--hat-color);
}

.hat-orb-mark {
  display: none;
}

.thinking-ring {
  position: absolute;
  inset: -3px;
  border: 2px solid #f39c12;
  border-radius: 12px;
  pointer-events: none;
  opacity: 0;
  animation: breathe 1.6s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% {
    opacity: 0.15;
    transform: scale(1);
  }
  50% {
    opacity: 0.85;
    transform: scale(1.18);
  }
}

/* ============================================================
   消息流
   ============================================================ */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 32px 0 24px;
  z-index: 1;
  position: relative;
}

.msg {
  display: flex;
  gap: 14px;
  padding: 12px 32px;
  animation: msgIn 0.4s ease-out;
}

@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg-user {
  justify-content: flex-end;
}

/* 头像 */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  background: var(--hat-color);
  box-shadow: 0 2px 8px rgba(42, 31, 26, 0.2);
  overflow: hidden;
}

.avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  object-fit: cover;
  display: block;
  position: relative;
  z-index: 1;
}

/* 用户头像（无图，文字 fallback） */
.avatar-user {
  background: var(--hat-color);
  color: #fff;
  font-size: 16px;
  font-weight: 500;
  font-family: 'STSong', '宋体', serif;
}

.avatar-fallback-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 18px;
  color: #fff;
  position: relative;
  z-index: 1;
}

.avatar-user .avatar-fallback-mark {
  font-size: 16px;
}

/* 气泡 */
.msg-bubble {
  max-width: 60%;
  min-width: 80px;
}

.msg-bubble-hat {
  background: #fff;
  border-radius: 4px 16px 16px 16px;
  padding: 14px 18px 16px;
  box-shadow: 0 1px 3px rgba(42, 31, 26, 0.06), 0 1px 2px rgba(42, 31, 26, 0.04);
  position: relative;
  border-top: 2px solid var(--hat-color);
}

.msg-bubble-hat::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 12px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 6px 6px 0 0;
  border-color: #fff transparent transparent transparent;
}

.msg-bubble-user {
  background: linear-gradient(135deg, #c8a878 0%, #b89968 100%);
  border-radius: 16px 4px 16px 16px;
  padding: 14px 18px 16px;
  box-shadow: 0 2px 6px rgba(42, 31, 26, 0.08);
  color: #2a1f1a;
  position: relative;
}

.msg-bubble-user::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 12px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 6px 0 0 6px;
  border-color: #b89968 transparent transparent transparent;
}

.msg-meta {
  margin-bottom: 6px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.msg-author {
  font-family: 'Noto Serif SC', serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
}

.msg-role {
  font-family: 'Cormorant Garamond', serif;
  font-size: 11px;
  color: #8b7355;
  font-style: italic;
  letter-spacing: 0.5px;
}

.msg-content {
  font-family: 'Noto Serif SC', 'LXGW WenKai', serif;
  font-size: 15px;
  line-height: 1.8;
  color: #2a1f1a;
  white-space: pre-wrap;
  word-wrap: break-word;
  letter-spacing: 0.2px;
}

/* typing 阶段占位气泡：三个跳动的点 */
.msg-content.typing-dots {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 1.5em;
  min-height: 1.5em; /* 避免换行时塌陷 */
}
.msg-content.typing-dots .dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b8a48a;
  animation: dot-bounce 1.2s ease-in-out infinite;
}
.msg-content.typing-dots .dot:nth-child(2) { animation-delay: 0.15s; }
.msg-content.typing-dots .dot:nth-child(3) { animation-delay: 0.30s; }
@keyframes dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

.msg-bubble-user .msg-content {
  color: #2a1f1a;
  font-weight: 500;
}

/* 发言被截断的灰色提示（出现在配额耗尽 / 用户主动停止导致的 pause 时，
   那个 hat 已经吐了一部分 chunk 但 typing_stop 没到的气泡尾巴） */
.msg-interrupted-tip {
  margin-top: 4px;
  font-size: 11px;
  color: #b89870;
  font-style: italic;
  opacity: 0.75;
}

/* 引用卡 */
.quote-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  margin: 0 0 8px 0;
  padding: 6px 10px 6px 10px;
  background: rgba(0, 0, 0, 0.04);
  border-left: 3px solid var(--hat-accent, #999);
  border-radius: 4px;
  border-top: none;
  border-right: none;
  border-bottom: none;
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: background 0.15s;
}
.quote-card:hover { background: rgba(0, 0, 0, 0.07); }

.quote-author {
  font-size: 12px;
  color: var(--hat-accent, #888);
  font-weight: 600;
  opacity: 0.85;
}

.quote-text {
  font-size: 13px;
  line-height: 1.5;
  color: #6b5d54;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.msg.msg-highlight {
  animation: msgHighlight 1.2s ease-out;
}
@keyframes msgHighlight {
  0%   { background: rgba(255, 235, 100, 0.45); }
  100% { background: transparent; }
}

/* Typing 状态 */
.msg-bubble-typing {
  min-width: 120px;
}

.typing-dots {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  background: #c8a878;
  border-radius: 50%;
  animation: dotBounce 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

.avatar.thinking {
  animation: avatarThink 1.6s ease-in-out infinite;
}

@keyframes avatarThink {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 2px 8px rgba(42, 31, 26, 0.2),
                0 0 0 0 rgba(243, 156, 18, 0);
  }
  50% {
    transform: scale(1.06);
    box-shadow: 0 2px 8px rgba(42, 31, 26, 0.2),
                0 0 0 4px rgba(243, 156, 18, 0.5),
                0 0 16px rgba(243, 156, 18, 0.35);
  }
}

/* ============================================================
   空状态
   ============================================================ */
.empty-state {
  /* 让 .messages 内的空状态真实垂直居中，避免内容被输入区盖住 */
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px 40px;
  text-align: center;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

.empty-mark {
  position: relative;
  width: 200px;
  height: 120px;
  margin: 0 auto 40px;
}

.empty-bubble {
  position: absolute;
  background: #fff;
  border-radius: 20px;
  padding: 16px 20px;
  box-shadow: 0 4px 12px rgba(42, 31, 26, 0.08);
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  color: #8b7355;
  font-size: 14px;
  border: 1px solid #e8dcc4;
}

.empty-bubble-1 {
  width: 80px;
  height: 40px;
  left: 10px;
  top: 10px;
  transform: rotate(-8deg);
  background: linear-gradient(135deg, #fff 0%, #f5ecd9 100%);
}

.empty-bubble-2 {
  width: 90px;
  height: 44px;
  right: 10px;
  top: 30px;
  transform: rotate(6deg);
  background: linear-gradient(135deg, #fff 0%, #faf0d8 100%);
  z-index: 2;
}

.empty-bubble-3 {
  width: 100px;
  height: 48px;
  left: 50px;
  top: 60px;
  transform: rotate(-2deg);
  background: linear-gradient(135deg, #c8a878 0%, #b89968 100%);
  color: #fff;
  z-index: 3;
}

.empty-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 32px;
  font-weight: 500;
  color: #2a1f1a;
  margin-bottom: 12px;
  letter-spacing: 4px;
}

.empty-desc {
  font-family: 'Noto Serif SC', serif;
  font-size: 14px;
  color: #8b7355;
  margin-bottom: 48px;
  letter-spacing: 2px;
}

.example-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 400px;
  margin: 0 auto;
}

.example-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: #fff;
  border: 1px solid #e8dcc4;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s;
  text-align: left;
}

.example-card:hover {
  border-color: #c8a878;
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(200, 168, 120, 0.15);
}

.example-num {
  font-family: 'Noto Serif SC', serif;
  font-size: 20px;
  color: #c8a878;
  font-weight: 600;
  width: 28px;
  flex-shrink: 0;
}

.example-text {
  font-family: 'Noto Serif SC', serif;
  font-size: 14px;
  color: #5b4a3a;
  letter-spacing: 1px;
}

/* ============================================================
   输入区
   ============================================================ */
.input-bar {
  padding: 16px 32px 20px;
  background: #faf6f0;
  border-top: 1px solid #e8dcc4;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  position: relative;
  z-index: 10;
  flex-direction: column;
  align-items: stretch;
}

.user-quote-bar {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-bottom: 8px;
  background: #fff;
  border: 1px solid #e8dcc4;
  border-left: 3px solid var(--hat-color, #888);
  border-radius: 8px;
  overflow: hidden;
}
.user-quote-bar-inner {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  min-width: 0;
}
.user-quote-label {
  font-size: 11px;
  color: #8a7a68;
  letter-spacing: 1px;
  flex-shrink: 0;
}
.user-quote-author {
  font-weight: 600;
  color: var(--hat-color, #888);
  flex-shrink: 0;
}
.user-quote-text {
  color: #5a4a3a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.user-quote-clear {
  width: 32px;
  flex-shrink: 0;
  background: #faf6f0;
  color: #8a7a68;
  font-size: 18px;
  font-weight: 300;
  border-left: 1px solid #e8dcc4;
  transition: all 0.15s;
  cursor: pointer;
}
.user-quote-clear:hover {
  background: #f0e8d8;
  color: #c0392b;
}

.mention-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.mention-bar-label {
  font-size: 12px;
  color: #8a7a68;
  letter-spacing: 1px;
  flex-shrink: 0;
  margin-right: 2px;
}
.mention-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: #fff;
  border: 1px solid #e8dcc4;
  border-radius: 14px;
  font-size: 12px;
  color: #5a4a3a;
  transition: all 0.15s;
  flex-shrink: 0;
  cursor: pointer;
  font-family: 'Noto Serif SC', serif;
}
.mention-pill:hover {
  border-color: var(--hat-accent, #888);
  background: #faf6f0;
}
.mention-pill.active {
  background: var(--hat-accent, #888);
  color: #fff;
  border-color: var(--hat-color, #888);
  font-weight: 600;
}
.mention-pill-name {
  letter-spacing: 0.5px;
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  width: 100%;
}

.input-frame {
  flex: 1;
  background: #fff;
  border: 1px solid #e8dcc4;
  border-radius: 8px;
  transition: all 0.2s;
  overflow: hidden;
}

.input-frame:focus-within {
  border-color: #c8a878;
  box-shadow: 0 0 0 3px rgba(200, 168, 120, 0.1);
}

.chat-input {
  width: 100%;
  border: none;
  outline: none;
  padding: 12px 16px;
  font-family: 'Noto Serif SC', serif;
  font-size: 15px;
  resize: none;
  background: transparent;
  color: #2a1f1a;
  line-height: 1.6;
  min-height: 48px;
  max-height: 160px;
}

.chat-input::placeholder {
  color: #b8a890;
  font-style: italic;
  letter-spacing: 0.5px;
}

.send-btn {
  /* 纯 icon 圆形按钮：干净输入框 + 纸飞机发送 */
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  background: #2a1f1a;
  color: #faf6f0;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
  background: #c8a878;
  color: #2a1f1a;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(200, 168, 120, 0.3);
}

.send-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.95);
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.send-arrow {
  font-size: 18px;            /* FA 纸飞机在圆形按钮里适中 */
  line-height: 1;
  margin: 0;
}

/* 用户消息内的 @chips / 引用卡 */
.mention-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 6px 0;
}
.mention-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--hat-color, #888);
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.quote-card-user {
  background: rgba(255, 255, 255, 0.18);
  border-left-color: var(--hat-color, #888);
  margin-bottom: 8px;
}
.quote-card-user .quote-author {
  color: #fff;
  opacity: 0.95;
}
.quote-card-user .quote-text {
  color: rgba(255, 255, 255, 0.85);
}

/* "引用此条" 按钮（hover 才显示）*/
.quote-this-btn {
  opacity: 0;
  margin-left: auto;
  padding: 2px 6px;
  font-size: 13px;
  color: #8a7a68;
  border-radius: 3px;
  transition: all 0.15s;
  cursor: pointer;
}
.msg-hat:hover .quote-this-btn {
  opacity: 0.6;
}
.quote-this-btn:hover {
  opacity: 1 !important;
  background: rgba(0, 0, 0, 0.06);
  color: #2a1f1a;
}

.mentioned-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 10px;
  color: #fff;
  font-weight: 700;
  margin-left: 4px;
  flex-shrink: 0;
}

/* ============================================================
   长按手势菜单（触屏专用）
   ============================================================ */
.menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(42, 31, 26, 0.4);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.menu-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.msg-action-menu {
  position: fixed;
  z-index: 9999;
  background: #fff;
  border: 1px solid #c8a878;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(42, 31, 26, 0.25),
              0 0 0 1px rgba(200, 168, 120, 0.15);
  padding: 6px 0;
  min-width: 180px;
  font-family: 'Noto Serif SC', serif;
  opacity: 0;
  transform: scale(0.9) translateY(-4px);
  transform-origin: top left;
  transition: opacity 0.15s, transform 0.15s;
  pointer-events: none;
}
.msg-action-menu.show {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

.msg-action-menu .menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  font-size: 15px;
  color: #2a1f1a;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.msg-action-menu .menu-item:active {
  background: rgba(200, 168, 120, 0.18);
}
.msg-action-menu .menu-item .menu-icon {
  font-size: 18px;
  width: 22px;
  text-align: center;
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', sans-serif;
}
.msg-action-menu .menu-item .menu-label {
  flex: 1;
}
.msg-action-menu .menu-item.danger {
  color: #b94d4d;
}
.msg-action-menu .menu-item.danger .menu-icon {
  color: #b94d4d;
}
.msg-action-menu .menu-divider {
  height: 1px;
  background: #e8dcc4;
  margin: 4px 0;
}
.msg-action-menu .menu-tip {
  padding: 6px 18px;
  font-size: 11px;
  color: #8a7a68;
  font-style: italic;
  font-family: 'Cormorant Garamond', serif;
  border-bottom: 1px solid #e8dcc4;
  margin-bottom: 4px;
}

/* ============================================================
   移动端响应式（抽屉式 + 紧凑布局）
   ============================================================ */
.hamburger-btn {
  display: none;
  width: 38px;
  height: 38px;
  border: none;                 /* 去边框，移动端 toolbar 按钮要干净 */
  background: transparent;        /* 透明背景，靠 :active 反馈 */
  color: #2a1f1a;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.hamburger-btn:active {
  background: rgba(200, 168, 120, 0.18);
}

.hat-collection-orb {
  display: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    #e74c3c 0deg 60deg,
    #ecf0f1 60deg 120deg,
    #2c3e50 120deg 180deg,
    #f1c40f 180deg 240deg,
    #16a085 240deg 300deg,
    #3498db 300deg 360deg
  );
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(42, 31, 26, 0.2);
}
.hat-collection-orb::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: #faf6f0;
}
.hat-collection-orb.thinking::after {
  background: var(--active-hat, #c8a878);
  animation: ringFlash 0.8s ease-in-out infinite;
}
@keyframes ringFlash {
  0%, 100% { transform: scale(0.85); opacity: 0.7; }
  50%      { transform: scale(1); opacity: 1; }
}

.hat-status-popover {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #fff;
  border: 1px solid #c8a878;
  border-radius: 8px;
  padding: 8px 0;
  min-width: 160px;
  box-shadow: 0 4px 16px rgba(42, 31, 26, 0.2);
  z-index: 100;
  font-family: 'Noto Serif SC', serif;
  font-size: 12px;
}
.hat-status-popover.show {
  display: block;
}
.hat-status-popover .status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  color: #2a1f1a;
}
.hat-status-popover .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.hat-status-popover .status-row.thinking .status-dot {
  animation: pulse 1s ease-in-out infinite;
}
.hat-status-popover .status-row .status-icon {
  margin-left: auto;
  font-size: 11px;
  color: #8a7a68;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
}
@keyframes pulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50%      { opacity: 1; transform: scale(1.3); }
}

@media (max-width: 600px) {
  /* 登录 / 用户卡 — 触摸目标 ≥44px，撑满抽屉宽度 */
  .auth-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .auth-btn {
    min-height: 44px;
    padding: 12px 18px;
    font-size: 16px;        /* iOS 聚焦不缩放 */
    letter-spacing: 1px;
  }
  .auth-btn .lock-icon {
    width: 12px;
    height: 12px;
  }
  .user-chip {
    min-height: 44px;
    padding: 8px 14px 8px 10px;
    font-size: 15px;
    justify-content: flex-start;
  }
  .user-avatar {
    width: 30px;
    height: 30px;
    font-size: 14px;
  }

  /* 桌面 hover 引用按钮在触屏下永远显示（命中区问题），但更小 */
  .quote-this-btn {
    opacity: 0.5;
    padding: 4px 8px;
    font-size: 15px;
  }
  .msg-hat:hover .quote-this-btn {
    opacity: 0.5;  /* 不依赖 hover */
  }

  /* 抽屉式布局：sidebar 默认隐藏 — 从右侧滑出（窄一点，不挤压聊天区）*/
  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 70%;
    max-width: 280px;
    z-index: 200;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: -4px 0 24px rgba(42, 31, 26, 0.3);
  }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(42, 31, 26, 0.4);
    z-index: 199;
  }
  .sidebar-backdrop.show {
    display: block;
  }

  /* 显示汉堡按钮；移动端不显示合集头像（基础样式 hat-collection-orb 已 display:none），
     也不显示桌面端 6 顶横排 — 移动端只保留汉堡入口，干净清爽 */
  .hamburger-btn {
    display: flex;
  }
  .header-hats,
  .floating-hats {
    display: none;
  }

  /* 让聊天区全屏 */
  .chat {
    width: 100%;
    max-width: 100vw;
  }
  .messages {
    padding: 16px 0;
  }
  .msg {
    padding: 8px 14px;
    gap: 10px;
  }
  .msg-bubble {
    max-width: 75%;
  }
  .avatar {
    width: 36px;
    height: 36px;
  }

  /* 聊天头一行摆下：汉堡 + 标题 + 合集头像 */
  .chat-header {
    padding: 10px 14px;
  }
  .chat-title {
    font-size: 16px;
  }

  /* @ 栏缩小到 28px chip，溢出滚动 */
  .mention-bar {
    padding: 6px 14px;
    gap: 5px;
  }
  .mention-pill {
    min-width: 28px;
    height: 28px;
    padding: 0 9px;
    font-size: 11px;
  }

  /* 输入区 */
  .input-row {
    padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
    gap: 8px;
  }
  #chat-input {
    font-size: 16px;  /* iOS 防止聚焦时缩放（id 是 chat-input 不是 msg-input） */
  }
  /* 移动端发送按钮：圆形 icon-only 略缩小，跟输入框视觉协调 */
  .send-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
  }
  .send-btn .send-arrow {
    font-size: 16px;
  }

  /* 模态弹窗适应全屏 */
  .modal-content {
    max-width: 92vw;
    padding: 22px 20px;
  }

  /* 长按菜单要全屏宽（不能太挤）*/
  .msg-action-menu {
    min-width: 200px;
  }
  .msg-action-menu .menu-item {
    padding: 14px 20px;
    font-size: 16px;
  }
}

/* 即使非触屏但窗口很小，也走这套布局（iPad 竖屏等）*/
@media (hover: none) and (pointer: coarse) {
  /* 触屏专属强化：按钮更大 */
  .quote-this-btn {
    min-width: 32px;
    min-height: 32px;
  }
}

/* ============================================================
   滚动条
   ============================================================ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #d4c4b0;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: #c8a878; }

.topics-list::-webkit-scrollbar-thumb {
  background: rgba(200, 168, 120, 0.3);
}

/* ============================================================
   响应式 - 小屏隐藏侧

/* end of base css — auth/quota/paywall styles appended below */

/* ============================================================
   登录 / 配额 / 付费墙 — 衬线编辑风，与整站搭
   ============================================================ */

/* ──────────── 侧栏底部：登录入口 + quota 细条 ──────────── */
.auth-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0 10px;
  border-top: 1px solid #3a2a22;
  margin-top: 8px;
}

.auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* 登录 CTA — 实心金扣，编辑风但有视觉权重 */
.auth-btn {
  display: flex;             /* 撑满父容器宽度 */
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;              /* 占满 auth-row */
  font-family: 'Cormorant Garamond', 'Noto Serif SC', serif;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 1px;
  color: #1f1612;
  background: linear-gradient(135deg, #8b6f47, #c8a878);
  border: 1px solid #c8a878;
  border-radius: 2px;
  padding: 10px 22px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.auth-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(200, 168, 120, 0.25);
}
.auth-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25) inset;
}
.auth-btn .lock-icon {
  width: 10px;
  height: 10px;
  opacity: 0.65;
}

/* 用户卡 — 头像徽章 + 名字，主入口感 */
.user-chip {
  display: flex;            /* 撑满父容器宽度 */
  align-items: center;
  width: 100%;
  gap: 9px;
  cursor: pointer;
  font-family: 'Cormorant Garamond', 'Noto Serif SC', serif;
  font-size: 14px;
  color: #d4c4b0;
  background: transparent;
  border: 1px solid transparent;
  padding: 5px 10px 5px 6px;
  border-radius: 2px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.user-chip:hover {
  border-color: #8b6f47;
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8b6f47, #c8a878);
  color: #1f1612;
  font-family: 'Cormorant Garamond', 'Noto Serif SC', serif;
  font-style: italic;
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0;
  transition: transform 0.2s ease;
}
.user-chip:hover .user-avatar {
  transform: scale(1.05);
}
.user-chip #user-chip-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
  flex: 1;
  min-width: 0;
}
.user-chip .caret {
  color: #8b6f47;
  font-size: 10px;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}
.user-chip:hover .caret {
  transform: rotate(180deg);
}

/* ──────────── Quota 进度（侧栏脚部） ──────────── */
.quota-line {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: 'Noto Serif SC', serif;
}
.quota-label {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #8b6f47;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.quota-label .quota-num {
  color: #d4c4b0;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  text-transform: none;
}
.quota-bar {
  height: 2px;
  background: #3a2a22;
  position: relative;
  overflow: hidden;
}
.quota-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, #8b6f47, #c8a878);
  transition: width 0.4s ease, background 0.3s ease;
}
.quota-bar-fill.warn { background: linear-gradient(90deg, #c8a878, #d4a060); }
.quota-bar-fill.crit { background: linear-gradient(90deg, #a66050, #c87860); }

/* ──────────── 弹窗（统一编辑风） ──────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 12, 8, 0.7);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.modal.hidden { display: none; }

.modal-card {
  background: #2a1f1a;
  border: 1px solid #4a3a2a;
  border-radius: 0;
  padding: 40px 36px 28px;
  width: 420px;
  max-width: 92vw;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  text-align: center;
  font-family: 'Noto Serif SC', serif;
  color: #d4c4b0;
}
.modal-card::before {
  content: '';
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 1px;
  background: #c8a878;
}
.modal-card::after {
  content: '';
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 1px;
  background: #c8a878;
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #8b6f47;
  line-height: 1;
  font-family: 'Cormorant Garamond', serif;
}
.modal-close:hover { color: #c8a878; }
.modal-title {
  margin: 8px 0 6px;
  color: #d4c4b0;
  font-family: 'Cormorant Garamond', 'Noto Serif SC', serif;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: 2px;
}
.modal-hint {
  margin: 0 0 22px;
  color: #8b6f47;
  font-size: 13px;
  font-style: italic;
  font-family: 'Cormorant Garamond', serif;
}
.modal-card input:not(.code-box) {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid #4a3a2a;
  border-radius: 0;
  font-family: 'Cormorant Garamond', 'Noto Serif SC', serif;
  font-size: 15px;
  color: #d4c4b0;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.2s;
}
.modal-card input:not(.code-box)::placeholder { color: #6a5a4a; font-style: italic; }
.modal-card input:not(.code-box):focus { border-color: #c8a878; }

.modal-btn {
  background: transparent;
  color: #c8a878;
  border: 1px solid #c8a878;
  border-radius: 0;
  padding: 10px 22px;
  cursor: pointer;
  font-family: 'Cormorant Garamond', 'Noto Serif SC', serif;
  font-size: 14px;
  letter-spacing: 2px;
  width: 100%;
  margin-bottom: 8px;
  transition: all 0.2s ease;
}
.modal-btn:hover {
  background: #c8a878;
  color: #2a1f1a;
}
.modal-btn:disabled {
  border-color: #4a3a2a;
  color: #4a3a2a;
  cursor: not-allowed;
}

.hidden { display: none !important; }
.countdown {
  font-size: 12px;
  color: #8b6f47;
  font-style: italic;
  margin-top: -4px;
  margin-bottom: 8px;
  font-family: 'Cormorant Garamond', serif;
}
.auth-error {
  color: #c87860;
  font-size: 12px;
  font-style: italic;
  min-height: 16px;
  margin-top: 6px;
  font-family: 'Cormorant Garamond', 'Noto Serif SC', serif;
}

/* ──────────── 登录弹窗：已发送显著提示 ──────────── */
.auth-sent-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 4px 0 20px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(139, 111, 71, 0.18), rgba(200, 168, 120, 0.12));
  border: 1px solid #c8a878;
  border-radius: 2px;
  color: #d4c4b0;
  font-size: 14px;
  font-family: 'Noto Serif SC', serif;
  letter-spacing: 0.5px;
  animation: authSentPulse 0.6s ease-out;
}
.auth-sent-banner b {
  color: #c8a878;
  font-weight: 600;
  margin-left: 4px;
  word-break: break-all;
}
.auth-sent-banner .check-icon {
  width: 18px;
  height: 18px;
  color: #c8a878;
  flex-shrink: 0;
}
@keyframes authSentPulse {
  0%   { transform: scale(0.96); opacity: 0; }
  60%  { transform: scale(1.02); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ──────────── 登录弹窗：6 格验证码 ──────────── */
.code-boxes {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 8px 0 18px;
}
.code-box {
  width: 44px;
  height: 54px;
  text-align: center;
  font-family: 'Cormorant Garamond', 'Noto Serif SC', serif;
  font-size: 28px;
  font-weight: 600;
  color: #c8a878;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid #4a3a2a;
  border-radius: 4px;
  outline: none;
  padding: 0;
  margin: 0;
  caret-color: #c8a878;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  -moz-appearance: textfield;
}
.code-box::-webkit-outer-spin-button,
.code-box::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.code-box:focus {
  border-color: #c8a878;
  background: rgba(200, 168, 120, 0.08);
  box-shadow: 0 0 0 3px rgba(200, 168, 120, 0.15);
}
.code-box.filled {
  border-color: #8b6f47;
  background: rgba(200, 168, 120, 0.06);
}

/* ──────────── 配额横幅（替代过去的 paywall-modal）──────────── */
/* 设计原则：
   - 不弹 modal，不挡住聊天历史可读
   - 一根 banner 贴在 chat-header 下方，× 可关
   - 不同 kind 不同严重度颜色，但都对输入区有联动
   - "登录可解" 的不出现二维码；"提额" 才出
*/
.quota-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 10px 14px;
  font-family: 'Noto Serif SC', serif;
  font-size: 13px;
  line-height: 1.5;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  animation: qbSlideDown 0.25s ease-out;
  position: relative;
  z-index: 5;
  flex-wrap: wrap;
}
.quota-banner.hidden { display: none; }
@keyframes qbSlideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.quota-banner-icon {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-weight: 600;
  font-size: 16px;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.quota-banner-text {
  flex: 1;
  min-width: 0;
}

.quota-banner-text b { font-weight: 600; }

.quota-banner-cta {
  font-family: inherit;
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid currentColor;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.quota-banner-cta:hover {
  background: currentColor;
}
.quota-banner-cta:hover > * { color: #faf6f0; }
/* 单独覆盖 hover 反色，避免 currentColor 双重 */
.quota-banner-cta:hover { color: #faf6f0; }

.quota-banner-close {
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: inherit;
  opacity: 0.5;
  padding: 4px 6px;
  flex-shrink: 0;
  font-family: 'Cormorant Garamond', serif;
}
.quota-banner-close:hover { opacity: 1; }

/* 颜色变体 — 跟现有主题对齐：椰奶 / 棕金 / 灰 */
.quota-banner.kind-login {
  background: #f3eddc;        /* 暖米黄 */
  color: #5a4a2e;
  border-bottom-color: #e4d8b8;
}
.quota-banner.kind-login .quota-banner-icon { background: #c8a878; color: #fff; }

.quota-banner.kind-token {
  background: #f0e6d2;        /* 偏红一点，提示提额 */
  color: #6b3a1f;
  border-bottom-color: #d8c098;
}
.quota-banner.kind-token .quota-banner-icon { background: #b8593a; color: #fff; }

.quota-banner.kind-info {
  background: #ebe4d4;
  color: #6a5a4a;
  border-bottom-color: #d4c8a8;
}
.quota-banner.kind-info .quota-banner-icon { background: #8b7355; color: #fff; }

.quota-banner.kind-rate {
  background: #e8ddd0;
  color: #5a4a3a;
  border-bottom-color: #c8b8a0;
}
.quota-banner.kind-rate .quota-banner-icon { background: #6a5a4a; color: #fff; }

/* ──────────── 输入区被配额禁用时的样式 ──────────── */
/* 跟现有 dark disabled 风格对齐：bg 变暗，placeholder 仍可读 */
.chat-input.input-locked {
  color: #8b7355;
  font-style: italic;
  cursor: not-allowed;
}
.chat-input.input-locked::placeholder { color: #8b7355; font-style: italic; }
.send-btn.input-locked-pulse {
  /* 提示用户去看 banner：让按钮略微脉动 */
  animation: sendLockedPulse 1.6s ease-in-out infinite;
}
@keyframes sendLockedPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(200, 168, 120, 0); }
  50%      { box-shadow: 0 0 0 4px rgba(200, 168, 120, 0.35); }
}

/* ──────────── 付费墙 ──────────── */
.paywall-stats {
  background: rgba(200, 168, 120, 0.05);
  border-top: 1px solid #4a3a2a;
  border-bottom: 1px solid #4a3a2a;
  padding: 14px;
  margin: 12px 0 18px;
  font-family: 'Cormorant Garamond', 'Noto Serif SC', serif;
  font-size: 14px;
  color: #c8a878;
  line-height: 1.6;
}
.paywall-stats .hint { color: #8b6f47; font-size: 12px; margin-top: 4px; font-style: italic; }
.paywall-tip {
  color: #8b6f47 !important;
  font-size: 13px !important;
  line-height: 1.7;
  margin-bottom: 14px !important;
  font-family: 'Cormorant Garamond', 'Noto Serif SC', serif;
}
.paywall-qr {
  /* contact_qr.jpg 原图是 888×1185 的竖图（≈3:4），写死 height 会压扁。
     只控宽，aspect-ratio 锁比例，高度自适应。 */
  width: 200px;
  height: auto;
  aspect-ratio: 888 / 1185;
  border-radius: 0;
  border: 1px solid #4a3a2a;
  margin: 8px auto 18px;
  display: block;
  background: #f5efe5;
  padding: 6px;
}

/* ──────────── Toast ──────────── */
.quota-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: #2a1f1a;
  color: #c8a878;
  border: 1px solid #c8a878;
  padding: 10px 24px;
  border-radius: 0;
  font-family: 'Cormorant Garamond', 'Noto Serif SC', serif;
  font-size: 14px;
  letter-spacing: 1px;
  z-index: 99999;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.25s ease-out;
}
.quota-toast.fade-out {
  opacity: 0;
  transition: opacity 0.3s;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.code-step-hint {
  font-size: 12px !important;
  color: #c8a878 !important;
  font-style: normal !important;
  font-family: 'Noto Serif SC', serif !important;
  letter-spacing: 0 !important;
}
.code-step-hint b {
  font-family: 'Cormorant Garamond', 'Noto Serif SC', serif;
  font-style: italic;
  font-weight: 500;
  color: #d4c4b0;
}
