/* ====== 主题变量（普通版 14px；老年版 18px） ====== */
:root {
  --bg: #0b1020;
  --panel: #11172a;
  --panel-2: #0f1430;
  --text: #e8ecff;
  --muted: #a8b2d1;

  --primary: #6c95ff;
  --primary-strong: #355cff;
  --accent: #82ffc7;
  --danger: #ff6b6b;
  --ring: rgba(130, 255, 199, 0.4);

  --bubble-user: rgba(108,149,255,0.14);
  --bubble-assistant: rgba(130,255,199,0.14);
  --bubble-border: rgba(255,255,255,0.08);

  --radius: 18px;
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
  --border: 1px solid rgba(255,255,255,0.08);

  /* 字号（普通版） */
  --fz-base: 14px;  /* 普通版 14px（如需“10号”可改 13.75px） */
  --fz-sm: 13px;
  --fz-lg: 16px;
  --line: 1.65;
}

/* 老年版：更高对比度和更大字号 */
#app[data-theme="senior"] {
  --bg: #000000;
  --panel: #0b0b0b;
  --panel-2: #0e0e0e;
  --text: #ffffff;
  --muted: #f0f0f0;

  --primary: #00e5ff;
  --primary-strong: #00bcd4;
  --accent: #ffff00;
  --danger: #ff4444;
  --ring: rgba(255,255,0,0.6);

  --bubble-user: rgba(0,229,255,0.22);
  --bubble-assistant: rgba(255,255,0,0.22);
  --bubble-border: rgba(255,255,255,0.22);

  --radius: 22px;
  --shadow: 0 14px 36px rgba(0,0,0,0.55);

  /* 字号（老年版） */
  --fz-base: 24px;  /* 老年版 18px（如需“18号”可改 24px） */
  --fz-sm: 16px;
  --fz-lg: 20px;
  --line: 1.75;
}

/* ====== 全局 ====== */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(1200px 600px at 70% -20%, rgba(108,149,255,.25), transparent 60%),
    radial-gradient(800px 500px at 10% -10%, rgba(130,255,199,.15), transparent 60%),
    var(--bg);
  color: var(--text);
  font-size: var(--fz-base);
  line-height: var(--line);
}

a { color: var(--primary); text-decoration: none; }
code { background: rgba(255,255,255,0.08); padding: 2px 6px; border-radius: 6px; }

/* ====== 顶栏 ====== */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px;
  backdrop-filter: blur(8px);
  background: linear-gradient(0deg, rgba(17,23,42,0.75), rgba(17,23,42,0.85));
  border-bottom: var(--border);
}
.brand { display: flex; gap: 12px; align-items: center; font-weight: 700; letter-spacing: .5px; }
.logo-spin {
  width: 22px; height: 22px; border-radius: 50%;
  background: conic-gradient(from 0deg, var(--primary), var(--accent), var(--primary));
  animation: spin 6s linear infinite;
  box-shadow: 0 0 12px var(--primary);
}
@keyframes spin { to { transform: rotate(360deg); } }
.controls { display: flex; gap: 10px; }

/* ====== 页面布局 ====== */
.container { max-width: 980px; margin: 18px auto; padding: 0 14px; }

.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* 聊天窗口采用列布局：消息区扩展，占满剩余空间；输入区固定在底部 */
.chat-window {
  height: calc(100vh - 260px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 修复点2：消息区要能伸展，min-height:0 允许在 flex 容器内正确滚动 */
.messages {
  flex: 1 1 auto;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* ====== 气泡与头像 ====== */
.message {
  display: flex;
  gap: 12px;
  margin: 10px 0;
  width: 100%;
}
.message.assistant { justify-content: flex-start; }
.message.user { justify-content: flex-end; }

.message .avatar {
  position: relative;
  flex: 0 0 36px;
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 800;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
  user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar .fallback-emoji { font-size: 18px; line-height: 1; }

.message.user .avatar {
  background: rgba(108,149,255,0.25);
  color: var(--primary);
  order: 2;
}
.message.assistant .avatar {
  background: rgba(130,255,199,0.25);
  color: var(--accent);
}

.bubble {
  position: relative;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--bubble-border);
  max-width: min(75%, 820px);
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}
.message.user .bubble {
  background: var(--bubble-user);
  border-top-right-radius: 6px;
  border-bottom-right-radius: 6px;
  align-self: flex-end;
  max-width: min(72%, 720px);
  order: 1;
}
.message.assistant .bubble {
  background: var(--bubble-assistant);
  border-top-left-radius: 6px;
  border-bottom-left-radius: 6px;
  align-self: flex-start;
}
.message.assistant .bubble::before,
.message.user .bubble::before {
  content: "";
  position: absolute; width: 10px; height: 10px;
  bottom: 8px; transform: rotate(45deg);
  filter: blur(.2px); border: 1px solid var(--bubble-border);
}
.message.assistant .bubble::before {
  left: -6px; background: var(--bubble-assistant);
  border-right: none; border-top: none;
}
.message.user .bubble::before {
  right: -6px; background: var(--bubble-user);
  border-left: none; border-bottom: none;
}

/* ====== 输入区（固定底部，带上边框分隔） ====== */
.composer {
  margin-top: auto;
  border-top: var(--border);
  background: transparent;
}
.input-wrap {
  display: grid; grid-template-columns: 1fr auto; gap: 10px;
  padding: 10px; align-items: center;
}
.input-wrap textarea {
  width: 100%; resize: none; outline: none; border: none;
  background: transparent; color: var(--text);
  font-size: var(--fz-base);
  max-height: 200px; overflow-y: auto;
}

/* ====== 按钮 ====== */
.btn {
  position: relative;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  color: var(--text);
  cursor: pointer;
  transition: transform .1s ease, box-shadow .2s ease, border-color .2s ease;
  overflow: hidden;
}
.btn .btn-glow {
  position: absolute; inset: -100% -20% auto auto; width: 200%; height: 200%;
  background: radial-gradient(300px 120px at 80% 0%, rgba(108,149,255,0.18), transparent 60%);
  transition: transform .5s ease;
}
.btn:hover .btn-glow { transform: translate(-10%, 10%); }
.btn:hover { box-shadow: 0 6px 20px rgba(108,149,255,0.25); transform: translateY(-1px); }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px rgba(0,0,0,0.25);
}
.btn.primary { border-color: rgba(108,149,255,0.45); }
.btn.danger  { border-color: rgba(255,107,107,0.45); }
.btn.ghost   { border-color: rgba(255,255,255,0.18); }
.btn .icon-send path { fill: var(--primary); }

/* ====== 页脚 ====== */
.footer { text-align: center; color: var(--muted); padding: 16px 0 26px; }

/* 老年版组件增强 */
#app[data-theme="senior"] .message .avatar { width: 46px; height: 46px; font-size: 18px; }
#app[data-theme="senior"] .bubble { padding: 18px 20px; border-width: 2px; }
#app[data-theme="senior"] .btn { padding: 14px 18px; border-radius: 18px; }
#app[data-theme="senior"] .input-wrap textarea { min-height: 52px; }

/* ====== 语言弹窗高对比度 ====== */
.lang-dialog::backdrop { background: rgba(0,0,0,.6); } /* 更深的遮罩 */
.lang-panel {
  background: var(--panel);
  color: var(--text);
  border: var(--border);
  padding: 18px; max-width: 420px; margin: auto;
}
.lang-list { display: grid; gap: 10px; margin: 12px 0 18px; }
.lang-list label { color: var(--text); }
.lang-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ====== 滚动条 ====== */
.messages::-webkit-scrollbar,
textarea::-webkit-scrollbar { width: 10px; }
.messages::-webkit-scrollbar-thumb,
textarea::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--primary), var(--accent));
  border-radius: 10px;
}

/* === 在文件靠后位置新增：投票条样式 === */
/* [NEW] 每条助手机器人回复下的投票条 */
.feedback-bar {
  display: inline-flex;
  gap: 10px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--bubble-border);
}

.vote-btn {
  border: 1px solid rgba(255,255,255,0.18);
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  color: var(--text);
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .2s ease, border-color .2s ease;
  font-size: var(--fz-sm);
}
.vote-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(108,149,255,0.2);
}
.vote-btn:disabled, .vote-btn.voted {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.3);
}
