﻿/* 全屏聊天布局，配色与登录页 / 推广卡片一致 */
:root {
  --orange: #ff7800;
  --blue: #0099d6;
  --green: #70a100;
  --ink: #1a1a2e;
  --muted: #5c5c7a;
  --accent: var(--orange);
  --accent-secondary: var(--blue);
  --accent-gradient: linear-gradient(135deg, var(--orange), var(--blue));
  --accent-soft: rgba(255, 120, 0, 0.1);
  --bg: #ffffff;
  --sidebar-bg: #eef1f8;
  --border: rgba(26, 26, 46, 0.08);
  --text: var(--ink);
  --text-muted: var(--muted);
  --msg-user-bg: rgba(255, 120, 0, 0.06);
  --code-bg: #f6f8fa;
  --radius: 10px;
  --shadow: 0 4px 16px rgba(26, 26, 46, 0.06);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body.chat-body {
  height: 100%;
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.chat-app {
  display: flex;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.chat-sidebar {
  width: 280px;
  min-width: 240px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-tabs {
  display: flex;
  gap: 0;
  padding: 12px 12px 0;
  border-bottom: 1px solid var(--border);
}

.sidebar-tab {
  flex: 1;
  text-align: center;
  padding: 10px 8px;
  cursor: default;
  color: var(--text-muted);
  font-size: 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.sidebar-tab.active {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

.sidebar-actions {
  padding: 12px;
}

.btn-new-topic {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.btn-new-topic:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.topic-list {
  flex: 1;
  overflow: auto;
  padding: 0 8px 12px;
}

.sidebar-account-wrap {
  position: relative;
  margin-top: auto;
  padding: 10px 12px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--sidebar-bg);
}

.sidebar-account-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  text-align: left;
}

.sidebar-account-btn:hover,
.sidebar-account-wrap.is-open .sidebar-account-btn {
  background: rgba(0, 0, 0, 0.05);
}

.sidebar-account-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}

.sidebar-account-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-account-menu {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(100% + 6px);
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 20;
}

.sidebar-account-menu.hidden {
  display: none;
}

.sidebar-account-menu-item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.sidebar-account-menu-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

.sidebar-account-menu-item--logout {
  color: #c0392b;
}

.sidebar-account-logout-form {
  display: block;
  margin: 0;
}

.account-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.45);
}

.account-modal-backdrop.hidden {
  display: none;
}

.account-modal {
  position: relative;
  width: min(100%, 380px);
  padding: 24px;
  border-radius: 16px;
  background: var(--bg);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
}

.account-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.account-modal-close:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
}

.account-modal-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  padding-right: 28px;
}

.account-modal-avatar {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: #fff;
  font-size: 22px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}

.account-modal-title-wrap {
  min-width: 0;
}

.account-modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-modal-role {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
}

.account-modal-info {
  margin: 0 0 20px;
  padding: 0;
}

.account-modal-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.account-modal-row:last-child {
  border-bottom: none;
}

.account-modal-row dt {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.account-modal-row dd {
  margin: 0;
  font-size: 14px;
  text-align: right;
  word-break: break-all;
}

.account-modal-logout-form {
  margin-top: 8px;
}

.account-modal-actions {
  margin-bottom: 12px;
}

.account-modal-link-btn {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}

.account-modal-link-btn:hover {
  background: var(--accent-soft);
  border-color: var(--orange);
  color: var(--orange);
}

.account-modal-logout-form {
  margin: 0;
}

.account-modal-logout-btn {
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  background: var(--accent-gradient);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.account-modal-logout-btn:hover {
  filter: brightness(1.05);
}

.feedback-modal {
  width: min(100%, 420px);
}

.feedback-modal-hint {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.feedback-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  min-height: 120px;
}

.feedback-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.feedback-modal-actions {
  margin-top: 12px;
}

.feedback-status {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.4;
}

.feedback-status.hidden {
  display: none;
}

.feedback-status--success {
  color: var(--green);
}

.feedback-status--error {
  color: #b71c1c;
}

.topic-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 4px;
}

.topic-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

.topic-item.active {
  background: var(--accent-soft);
}

.topic-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topic-title-input {
  flex: 1;
  min-width: 0;
  padding: 4px 8px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

.topic-title-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.topic-close {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}

.topic-close:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text);
}

.topic-menu-wrap {
  position: relative;
}

.topic-menu-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  width: 26px;
  height: 24px;
  border-radius: 6px;
  font-size: 18px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.topic-item:hover .topic-menu-btn,
.topic-item.active .topic-menu-btn,
.topic-menu-wrap.open .topic-menu-btn {
  opacity: 1;
}

.topic-menu-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text);
}

.topic-menu-panel {
  position: absolute;
  top: 30px;
  right: 0;
  min-width: 120px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 6px;
  display: none;
  z-index: 20;
}

.topic-menu-wrap.open .topic-menu-panel {
  display: block;
}

.topic-menu-item {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.topic-menu-item:hover {
  background: rgba(0, 0, 0, 0.06);
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.assistant-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
}

.assistant-label span[aria-hidden="true"] {
  color: var(--orange);
}

.model-select-wrap {
  flex: 1;
  display: flex;
  justify-content: center;
}

.model-select {
  min-width: 320px;
  max-width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 14px;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.model-select:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.chat-header-user {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
  max-width: 280px;
}

.chat-user-name {
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 120px;
}

.chat-header-link {
  font-size: 13px;
  color: var(--blue);
  text-decoration: none;
}

.chat-header-link:hover {
  color: var(--orange);
  text-decoration: underline;
}

.chat-logout-form {
  display: inline;
  margin: 0;
}

.chat-logout-btn {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
}

.chat-messages {
  flex: 1;
  overflow: auto;
  padding: 20px 24px 12px;
  background: var(--bg);
}

.msg {
  max-width: 900px;
  margin: 0 auto 16px;
}

.msg-user .msg-bubble {
  margin-left: auto;
  background: var(--msg-user-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  width: fit-content;
  max-width: 85%;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-assistant .msg-bubble {
  background: transparent;
  padding: 4px 0 8px;
  line-height: 1.65;
  font-size: 15px;
}

.msg-assistant .msg-bubble :first-child {
  margin-top: 0;
}

.msg-assistant .msg-bubble :last-child {
  margin-bottom: 0;
}

.msg-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* 助手：请求失败 / 中断时的展示 */
.assistant-md.assistant-error {
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid #f0c0c0;
  background: #fff8f8;
  color: #5c1010;
}

.assistant-error-pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.55;
}

.assistant-actions {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-msg-retry {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.btn-msg-retry:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.reasoning-block {
  margin: 10px 0;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fafafa;
  font-size: 13px;
  color: var(--text-muted);
}

.reasoning-block summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}

.reasoning-pre {
  margin: 8px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

/* 推理块放在回答最上方时，与正文拉开间距 */
.reasoning-block.reasoning-on-top {
  margin: 0 0 14px;
}

/* 思考链（Chain of Thought）展示 */
.thinking-chain {
  margin: 0 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8f9fb;
  overflow: hidden;
}

.thinking-chain-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.thinking-chain-summary::-webkit-details-marker {
  display: none;
}

.thinking-chain-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  color: #6b7280;
  display: inline-flex;
}

.thinking-chain-icon svg {
  width: 22px;
  height: 22px;
}

.thinking-chain-label {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.thinking-chain-chevron {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  display: inline-flex;
  transition: transform 0.2s ease;
}

.thinking-chain-chevron svg {
  width: 18px;
  height: 18px;
}

.thinking-chain[open] .thinking-chain-chevron {
  transform: rotate(90deg);
}

.thinking-chain-body {
  padding: 0 14px 14px 46px;
  border-top: 1px solid rgba(0, 0, 0, 0.04);
}

.thinking-chain-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 12px 0 8px;
}

.thinking-chain-text {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-muted);
  white-space: normal;
  word-break: break-word;
}

.thinking-chain-text--pending {
  padding-top: 12px;
}

.assistant-md {
  min-height: 0;
}

.assistant-typing-plain {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
  line-height: 1.65;
}

.assistant-loading {
  min-height: 1.4em;
  color: var(--text-muted);
  font-size: 15px;
}

.loading-dots::after {
  content: "…";
  display: inline-block;
  animation: loading-pulse 1s ease-in-out infinite;
}

@keyframes loading-pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

.typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  margin-left: 3px;
  vertical-align: text-bottom;
  background: var(--accent);
  animation: typing-blink 0.9s step-end infinite;
}

@keyframes typing-blink {
  50% {
    opacity: 0;
  }
}

/* 代码块：带标题栏与复制（由 chat.js 包一层 .code-block-wrap） */
.code-block-wrap {
  margin: 12px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--code-bg);
}

.code-block-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: #eceff1;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  font-family: Consolas, "Courier New", monospace;
}

.code-block-toolbar .code-lang {
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}

.code-copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.code-copy-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
}

.code-copy-btn svg {
  width: 16px;
  height: 16px;
  display: block;
}

.msg-bubble pre {
  background: transparent;
  border-radius: 0;
  padding: 12px 14px;
  margin: 0;
  overflow: auto;
  border: none;
}

.msg-bubble code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
}

.msg-bubble p {
  margin: 0.6em 0;
}

.msg-thumb {
  max-width: 240px;
  border-radius: 8px;
  margin-top: 8px;
  border: 1px solid var(--border);
}

.msg-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.msg-thumbs .msg-thumb {
  margin-top: 0;
  max-width: 160px;
  max-height: 160px;
  object-fit: cover;
}

/* 输入框内待发送图片预览（缩略图条） */
.pending-images {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.pending-images:not(.hidden) {
  display: block;
}

.pending-image-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  max-height: 168px;
  overflow-y: auto;
  padding: 2px 0;
}

.pending-image-item {
  position: relative;
  flex: 0 0 auto;
  width: 72px;
  height: 72px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.04);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.pending-image-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pending-image-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 15px;
  line-height: 22px;
  cursor: pointer;
  opacity: 0.92;
}

.pending-image-remove:hover {
  background: rgba(0, 0, 0, 0.75);
}

.pending-image-count {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--text-muted);
  padding: 0 4px;
  white-space: nowrap;
}

.pending-image-item--loading {
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.06) 25%,
    rgba(0, 0, 0, 0.1) 50%,
    rgba(0, 0, 0, 0.06) 75%
  );
  background-size: 200% 100%;
  animation: pending-image-shimmer 1.2s infinite;
}

@keyframes pending-image-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.chat-input-panel {
  border-top: 1px solid var(--border);
  padding: 12px 20px 16px;
  background: var(--bg);
}

.chat-input-inner {
  max-width: 900px;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  background: var(--bg);
  padding: 10px 12px 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.chat-input-inner:focus-within {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow);
}

.chat-textarea {
  width: 100%;
  min-height: 72px;
  max-height: 200px;
  border: none;
  resize: vertical;
  font: inherit;
  font-size: 15px;
  outline: none;
  padding: 4px 4px 8px;
}

.chat-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 4px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.icon-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
}

.icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

label.icon-btn {
  cursor: pointer;
  margin: 0;
}

.icon-btn .icon-svg {
  width: 20px;
  height: 20px;
  display: block;
}

.icon-btn-stop {
  color: #c62828;
}

.icon-btn-stop:hover:not(:disabled) {
  background: rgba(198, 40, 40, 0.08);
  color: #b71c1c;
}

.btn-send {
  padding: 8px 18px;
  border-radius: 8px;
  border: none;
  background: var(--accent-gradient);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.btn-send:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: center;
}

.error-toast {
  max-width: 900px;
  margin: 0 auto 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff4f4;
  border: 1px solid #f0c0c0;
  color: #8a1f1f;
  font-size: 14px;
}

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

label.icon-btn input.hidden {
  display: none;
}

/* 桌面：侧栏常驻，隐藏菜单按钮与遮罩 */
.btn-sidebar-toggle {
  display: none;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.btn-sidebar-toggle:hover {
  background: rgba(0, 0, 0, 0.05);
}

.btn-sidebar-toggle .icon-svg {
  width: 22px;
  height: 22px;
  display: block;
}

.sidebar-backdrop {
  display: none;
}

body.chat-body.sidebar-open {
  overflow: hidden;
}

/* ── 平板 / 手机 ── */
@media (max-width: 768px) {
  .btn-sidebar-toggle {
    display: inline-flex;
  }

  .chat-header-assistant {
    display: none;
  }

  .chat-header {
    gap: 8px;
    padding: 10px 12px;
    flex-wrap: nowrap;
  }

  .model-select-wrap {
    flex: 1;
    min-width: 0;
    justify-content: stretch;
  }

  .model-select {
    min-width: 0;
    width: 100%;
    font-size: 13px;
    padding: 10px 10px;
  }

  .chat-header-user {
    flex-shrink: 0;
    max-width: none;
    gap: 6px;
  }

  .chat-user-name {
    display: none;
  }

  .chat-header-link {
    font-size: 12px;
    white-space: nowrap;
  }

  .chat-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    width: min(280px, 85vw);
    min-width: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: none;
  }

  .chat-sidebar.is-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 199;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    pointer-events: none;
  }

  .sidebar-backdrop.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .chat-messages {
    padding: 12px 14px 8px;
  }

  .msg {
    margin-bottom: 12px;
  }

  .msg-user .msg-bubble {
    max-width: 92%;
    font-size: 15px;
  }

  .msg-assistant .msg-bubble {
    font-size: 15px;
  }

  .chat-input-panel {
    padding: 10px 12px max(12px, env(safe-area-inset-bottom));
  }

  .chat-textarea {
    min-height: 64px;
    font-size: 16px;
  }

  .icon-btn {
    width: 44px;
    height: 44px;
  }

  .btn-send {
    padding: 10px 18px;
    min-height: 44px;
  }

  .topic-menu-btn {
    opacity: 1;
  }

  .topic-item {
    padding: 12px 10px;
  }

  .btn-new-topic {
    min-height: 44px;
  }
}

@media (max-width: 480px) {
  .chat-header-link:not(.chat-logout-btn) {
    display: none;
  }
}

/* —— /Try 体验页 —— */
.chat-body--trial {
  overflow: hidden;
}

.chat-app--trial {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 100%;
}

.trial-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.trial-topbar-brand {
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
}

.trial-quota-badge {
  font-size: 13px;
  color: var(--orange);
  background: rgba(255, 120, 0, 0.08);
  padding: 4px 10px;
  border-radius: 999px;
}

.trial-login-btn {
  margin-left: auto;
  font-size: 14px;
  font-weight: 600;
  color: var(--blue);
  text-decoration: none;
}

.trial-login-btn:hover {
  color: var(--orange);
}

.trial-hint-banner,
.trial-limit-banner {
  flex-shrink: 0;
  padding: 8px 16px;
  font-size: 13px;
  text-align: center;
}

.trial-hint-banner {
  background: rgba(0, 153, 214, 0.08);
  color: var(--muted);
}

.trial-limit-banner {
  background: rgba(183, 28, 28, 0.08);
  color: #b71c1c;
}

.chat-main--trial {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chat-empty-hint {
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.chat-empty-hint-title {
  margin: 0 0 8px;
  font-size: 16px;
  color: var(--ink);
  font-weight: 600;
}

.chat-empty-hint-sub {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.trial-hint-banner a {
  color: var(--blue);
  font-weight: 600;
  text-decoration: none;
}

.trial-hint-banner a:hover {
  color: var(--orange);
  text-decoration: underline;
}

.trial-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(26, 26, 46, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.trial-modal-backdrop.hidden {
  display: none;
}

.trial-modal {
  background: var(--surface);
  border-radius: 12px;
  padding: 24px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 16px 48px rgba(26, 26, 46, 0.2);
}

.trial-modal-title {
  margin: 0 0 10px;
  font-size: 18px;
}

.trial-modal-text {
  margin: 0 0 18px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

.trial-modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.trial-modal-actions .btn {
  flex: 1;
  text-align: center;
  text-decoration: none;
  min-width: 120px;
}
