/* ------------------------------------------------------------------
   Next Chat
   设计变量、尺寸、层级均对照 DeepSeek 官方 chat-demo 的 token 与组件规范
   ------------------------------------------------------------------ */

:root {
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu,
    Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  --font-code: Menlo, Monaco, Consolas, 'Cascadia Mono', 'Ubuntu Mono', 'DejaVu Sans Mono',
    'Liberation Mono', 'JetBrains Mono', 'Fira Code', Cousine, 'Roboto Mono', 'Courier New', Courier,
    monospace;

  --bg: #ffffff;
  --sidebar-bg: #f9fafb;
  --input-bg: #ffffff;
  --bubble: #edf3fe;
  --brand: #3964fe;
  --brand-hover: #5686fe;
  --brand-soft: #edf3fe;
  --brand-soft-hover: #e4edfd;
  --brand-border: #b7c8fe;

  --label-1: #0f1115;
  --label-2: #61666b;
  --label-3: #81858c;
  --label-4: #adb2b8;

  --border-1: rgba(0, 0, 0, 0.04);
  --border-2: rgba(0, 0, 0, 0.1);
  --border-3: rgba(0, 0, 0, 0.12);

  --hover: rgba(38, 49, 72, 0.06);
  --hover-accent: rgba(38, 49, 72, 0.14);
  --active: rgba(38, 49, 72, 0.1);

  --code-inline: #ebeef2;
  --code-block: #f9fafb;
  --code-banner: #f9fafb;

  --toast-bg: #353638;
  --toast-fg: #f5f5f5;
  --danger: #ec1313;

  --shadow-menu: 0 0 1px rgba(0, 0, 0, 0.2), 0 0 4px rgba(0, 0, 0, 0.02),
    0 12px 32px rgba(0, 0, 0, 0.08);
  --shadow-modal: 0 0 1px rgba(0, 0, 0, 0.2), 0 0 4px rgba(0, 0, 0, 0.02),
    0 12px 32px rgba(0, 0, 0, 0.08);

  --message-list-max-width: 840px;
  --message-list-padding-horizontal: 44px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --scroll-color: rgba(0, 0, 0, 0.08);
  --scroll-color-hover: rgba(0, 0, 0, 0.15);
  color-scheme: light;
}

body[data-theme='dark'] {
  --bg: #151517;
  --sidebar-bg: #1b1b1c;
  --input-bg: #2c2c2e;
  --bubble: #2c2c2e;
  --brand: #5686fe;
  --brand-hover: #3964fe;
  --brand-soft: #283142;
  --brand-soft-hover: #34415b;
  --brand-border: #4868b2;

  --label-1: #f9fafb;
  --label-2: #cfd3d6;
  --label-3: #adb2b8;
  --label-4: #81858c;

  --border-1: rgba(255, 255, 255, 0.06);
  --border-2: rgba(255, 255, 255, 0.12);
  --border-3: rgba(255, 255, 255, 0.16);

  --hover: rgba(255, 255, 255, 0.08);
  --hover-accent: rgba(255, 255, 255, 0.24);
  --active: rgba(255, 255, 255, 0.14);

  --code-inline: #2c2c2e;
  --code-block: #1b1b1c;
  --code-banner: #2c2c2e;

  --toast-bg: #43454a;
  --toast-fg: #f5f5f5;
  --danger: #f25a5a;

  --shadow-menu: 0 0 1px rgba(0, 0, 0, 0.6), 0 12px 32px rgba(0, 0, 0, 0.4);
  --shadow-modal: 0 0 1px rgba(0, 0, 0, 0.6), 0 12px 32px rgba(0, 0, 0, 0.4);

  --scroll-color: rgba(255, 255, 255, 0.15);
  --scroll-color-hover: rgba(255, 255, 255, 0.24);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  font-family: var(--font-family);
  font-size: 14px;
  color: var(--label-1);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: none;
  -webkit-tap-highlight-color: transparent;
  word-break: break-word;
}

button,
input,
textarea {
  font-family: inherit;
}

button {
  cursor: pointer;
}

::selection {
  background: rgba(57, 100, 254, 0.18);
}

/* 滚动条 */
.chat-scroll::-webkit-scrollbar,
.session-list::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.chat-scroll::-webkit-scrollbar-thumb,
.session-list::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
  border-radius: 8px;
  background: transparent;
}
.chat-scroll:hover::-webkit-scrollbar-thumb,
.session-list:hover::-webkit-scrollbar-thumb,
.modal-body:hover::-webkit-scrollbar-thumb {
  background: var(--scroll-color);
}
.chat-scroll:hover::-webkit-scrollbar-thumb:hover,
.session-list:hover::-webkit-scrollbar-thumb:hover,
.modal-body:hover::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-color-hover);
}

/* ------------------------------------------------------------------ */
/* 主框架                                                              */
/* ------------------------------------------------------------------ */

.frame {
  position: absolute;
  inset: 0;
  display: flex;
  overflow: hidden;
  background-color: var(--bg);
}

.main {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

/* ------------------------------------------------------------------ */
/* 侧边栏                                                              */
/* ------------------------------------------------------------------ */

.sider {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: 261px;
  height: 100%;
  padding: 6px 12px 0;
  border-right: 1px solid var(--border-1);
  background-color: var(--sidebar-bg);
  transition: margin-left 0.2s var(--ease);
}

.sider.collapsed {
  margin-left: -261px;
}

.sider-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 48px;
  margin-bottom: 16px;
  padding: 15px 0 10px 4px;
  flex-shrink: 0;
}

.app-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding-left: 4px;
  overflow: hidden;
  font-size: 20px;
  line-height: 22px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--brand);
  letter-spacing: -0.2px;
}

.app-logo {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(35, 49, 198, 0.28);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--label-2);
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.icon-btn:hover {
  background-color: var(--hover);
  color: var(--label-1);
}

.sider-collapse {
  opacity: 0;
  transition: opacity 0.15s var(--ease);
}

.sider:hover .sider-collapse,
.sider-collapse:focus-visible {
  opacity: 1;
}

.new-chat {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 100%;
  height: 40px;
  padding: 0 16px;
  border-radius: 100px;
  border: 1px solid rgba(103, 158, 254, 0);
  background: var(--bg);
  color: var(--label-1);
  font-size: 14px;
  font-weight: 500;
  user-select: none;
  box-shadow: 0 -2px 2px rgba(72, 104, 178, 0.04), 0 2px 2px rgba(106, 111, 117, 0.09),
    0 1px 2px rgba(72, 104, 178, 0.08);
  transition: box-shadow 0.3s ease;
}

.new-chat:hover {
  box-shadow: 0 4px 4px 0 rgba(72, 104, 178, 0.04), 0 -3px 4px 0 rgba(72, 104, 178, 0.04),
    0 6px 6px 0 rgba(106, 111, 117, 0.1);
}

body[data-theme='dark'] .new-chat {
  border: none;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.1), 0 2px 4px rgba(0, 0, 0, 0.3);
}

.new-chat-icon {
  display: flex;
  margin-right: 6px;
}

.list-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  margin-top: 24px;
}

.session-list {
  height: 100%;
  margin: 0 -2px;
  padding: 0 2px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-color) transparent;
}

.section {
  position: relative;
  margin-top: 16px;
  padding-top: 4px;
}

.section:first-child {
  margin-top: 0;
}

.section-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 2px 10px;
  font-size: 12px;
  line-height: 18px;
  font-weight: 500;
  color: var(--label-3);
  background-color: var(--sidebar-bg);
  user-select: none;
}

.session-item {
  position: relative;
  display: flex;
  align-items: center;
  height: 40px;
  padding: 9px 6px 9px 10px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 22px;
  color: var(--label-1);
  cursor: pointer;
  user-select: none;
}

.session-item.active {
  background-color: var(--brand-soft);
  color: var(--brand);
}

@media (hover: hover) {
  .session-item:not(.active):hover {
    background-color: var(--hover);
  }
  .session-item:hover .item-action,
  .session-item.active .item-action {
    display: flex;
  }
}

.session-title-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  line-height: 18px;
}

.item-action {
  display: none;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-left: 4px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--label-3);
}

.item-action:hover {
  background-color: var(--active);
  color: var(--label-1);
}

.empty-sessions {
  padding: 24px 10px;
  font-size: 13px;
  line-height: 20px;
  color: var(--label-4);
  text-align: center;
}

.sider-bottom {
  display: flex;
  flex-shrink: 0;
  height: 64px;
}

.settings-btn {
  display: flex;
  align-items: center;
  width: 100%;
  margin-block: auto;
  padding: 6px 2px 6px 6px;
  border: none;
  border-radius: 12px;
  background: none;
  text-align: left;
  user-select: none;
  outline: none;
}

.settings-btn:hover {
  background-color: var(--hover);
}

.settings-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  color: var(--label-1);
}

.settings-label {
  min-width: 0;
  margin-left: 4px;
  font-size: 14px;
  color: var(--label-1);
}

/* 收起态 */
.collapsed-bar {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 12px 0 0 16px;
}

.collapsed-group {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 40px;
  padding: 0 2px;
  border-radius: 100px;
  border: 1px solid var(--border-2);
  background: var(--bg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

body[data-theme='dark'] .collapsed-group {
  background: #2c2c2e;
}

/* ------------------------------------------------------------------ */
/* 会话区                                                              */
/* ------------------------------------------------------------------ */

.session-header {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  height: 60px;
  padding: 12px 18px 0;
  background: var(--bg);
}

.session-title {
  max-width: 480px;
  padding: 8px 12px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 14px;
  line-height: 22px;
  font-weight: 500;
  color: var(--label-1);
}

.mobile-menu,
.mobile-home-menu {
  display: none;
}

.mobile-home-menu {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 30;
}

.view {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* 新对话 */
.welcome {
  position: absolute;
  inset: 0;
  display: flex;
}

.welcome-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: var(--message-list-max-width);
  margin: auto;
  padding: 0 32px 64px;
}

.greeting {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 21px;
  font-size: 24px;
  line-height: 32px;
  font-weight: 600;
  text-align: center;
  color: var(--label-1);
}

.welcome-slot {
  width: 100%;
}

.welcome-caveat {
  display: none;
}

/* 会话 */
.chat-scroll {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-gutter: stable both-edges;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-color) transparent;
}

.message-column {
  width: calc(var(--message-list-max-width) - 2 * var(--message-list-padding-horizontal));
  max-width: calc(100% - 40px);
  margin: 0 auto;
  padding-bottom: 24px;
}

.composer-dock {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  width: 100%;
  background: var(--bg);
}

.composer-slot {
  width: calc(var(--message-list-max-width) - 64px);
  max-width: calc(100% - 32px);
  margin: 0 auto;
}

.caveat {
  width: 100%;
  padding: 6px 0;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
  color: var(--label-3);
  user-select: none;
}

/* ------------------------------------------------------------------ */
/* 输入框                                                              */
/* ------------------------------------------------------------------ */

.composer {
  --line-height: 24px;
  --input-padding-top: 12px;
  display: flex;
  flex-direction: column;
  width: 100%;
  font-size: 16px;
  line-height: var(--line-height);
  border-radius: 24px;
  border: 1px solid var(--border-2);
  background: var(--input-bg);
  overflow: hidden;
}

.composer.session {
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.02), 0 2px 4px rgba(0, 0, 0, 0.04);
}

.composer.home {
  box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.02), 0 2px 2px 0 rgba(72, 104, 178, 0.01),
    0 30px 60px 0 rgba(72, 104, 178, 0.03);
}

body[data-theme='dark'] .composer.home {
  box-shadow: none;
}

.textarea-wrap {
  position: relative;
  width: 100%;
}

.textarea {
  display: block;
  width: 100%;
  min-height: calc(var(--line-height) * 2 + var(--input-padding-top));
  max-height: 336px;
  margin: 0;
  padding: var(--input-padding-top) 12px 0 16px;
  border: none;
  outline: none;
  resize: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: transparent;
  color: var(--label-1);
  caret-color: var(--brand);
  font: inherit;
  line-height: inherit;
  white-space: pre-wrap;
}

.textarea::placeholder {
  color: var(--label-4);
  user-select: none;
}

.function-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding: 12px;
  min-width: 0;
}

.toggles {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.toggle {
  display: inline-flex;
  flex-shrink: 1;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  height: 34px;
  padding: 0 12px;
  border-radius: 18px;
  border: 1px solid var(--border-2);
  background-color: transparent;
  color: var(--label-1);
  font-size: 13px;
  line-height: 20px;
  font-weight: 500;
  white-space: nowrap;
  user-select: none;
  transition: border-color 0.2s, background-color 0.2s, color 0.2s;
}

.toggle:hover {
  background-color: var(--hover);
}

.toggle.selected {
  background-color: var(--brand-soft);
  color: var(--brand);
  border-color: var(--brand-border);
}

.toggle.selected:hover {
  background-color: var(--brand-soft-hover);
}

/* 深度思考 / 联网搜索的开启态 */
.toggle.active {
  background-color: var(--brand-soft);
  color: var(--brand);
  border-color: var(--brand-border);
}

.toggle.active:hover {
  background-color: var(--brand-soft-hover);
}

.toggle.active svg {
  color: var(--brand);
}

.toggle-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 模型选择器：不参与压缩，名字太长才省略，避免被挤成「GPT-5.6-L…」 */
.model-toggle {
  flex-shrink: 0;
  min-width: 104px;
  max-width: 264px;
}

.model-toggle .toggle-label {
  max-width: 208px;
}

.toggle .chev {
  flex-shrink: 0;
  opacity: 0.6;
}

.function-right {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  margin-left: 6px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--brand);
  color: #ffffff;
  transition: background 0.2s ease, opacity 0.2s ease;
}

.send-btn:hover:not(:disabled) {
  background: var(--brand-hover);
}

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

/* ------------------------------------------------------------------ */
/* 消息                                                                */
/* ------------------------------------------------------------------ */

.msg-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding-bottom: 16px;
}

.msg-user.first {
  padding-top: 34px;
}

.msg-user:hover .msg-actions {
  opacity: 1;
}

.user-bubble {
  max-width: calc(100% - 88px);
  padding: 10px 16px;
  border-radius: 22px;
  font-size: 16px;
  line-height: 24px;
  color: var(--label-1);
  background-color: var(--bubble);
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-bottom {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 30px;
  margin-top: 2px;
}

.msg-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}

.msg-actions:focus-within {
  opacity: 1;
}

.act-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--label-4);
  font-size: 13px;
  line-height: 20px;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.act-btn:hover {
  background-color: var(--hover);
  color: var(--label-1);
}

.act-btn:active {
  transform: scale(0.94);
}

.msg-assistant {
  position: relative;
  padding-bottom: 4px;
}

.msg-assistant:hover .msg-actions,
.msg-assistant:focus-within .msg-actions {
  opacity: 1;
}

.msg-assistant .msg-bottom {
  padding-top: 12px;
  padding-bottom: 10px;
  height: auto;
}

.assistant-error {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 8px;
  font-size: 14px;
  line-height: 22px;
  color: var(--danger);
}

.assistant-error svg {
  flex-shrink: 0;
  margin-top: 4px;
}

/* 等待回复的三点 */
.waiting {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 34px;
}

.waiting-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--label-4);
  animation: fading 0.9s linear infinite;
}

.waiting-dot:nth-child(2) {
  animation-delay: 0.1s;
}

.waiting-dot:nth-child(3) {
  animation-delay: 0.2s;
}

@keyframes fading {
  0%,
  100% {
    opacity: 0.3;
  }
  33%,
  66% {
    opacity: 1;
  }
}

/* 思考过程 */
.think {
  margin: 2px 0 6px;
}

.think-head {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
  border: none;
  background: none;
  color: var(--label-3);
  font-size: 13px;
  line-height: 20px;
  font-weight: 500;
}

.think-head:hover {
  color: var(--label-2);
}

.think-head .chev {
  transition: transform 0.2s var(--ease);
}

.think.open .think-head .chev {
  transform: rotate(180deg);
}

.think-body {
  display: none;
  margin: 4px 0;
  padding-left: 14px;
  border-left: 2px solid var(--border-3);
  font-size: 14px;
  line-height: 24px;
  color: var(--label-2);
}

.think.open .think-body {
  display: block;
}

/* ------------------------------------------------------------------ */
/* Markdown                                                            */
/* ------------------------------------------------------------------ */

.md {
  font-size: 16px;
  line-height: 28px;
  color: var(--label-1);
  word-break: break-word;
}

.md p {
  margin: 16px 0;
}

.md > :first-child {
  margin-top: 0;
}

.md > :last-child {
  margin-bottom: 0;
}

.md h1 {
  margin: 32px 0 16px;
  font-size: 24px;
  line-height: 34px;
  font-weight: 700;
}

.md h2 {
  margin: 32px 0 16px;
  font-size: 22px;
  line-height: 32px;
  font-weight: 700;
}

.md h3 {
  margin: 32px 0 16px;
  font-size: 20px;
  line-height: 30px;
  font-weight: 700;
}

.md h4 {
  margin: 16px 0;
  font-size: 16px;
  line-height: 28px;
  font-weight: 600;
}

.md h5,
.md h6 {
  margin: 16px 0;
  font-size: 16px;
  line-height: 28px;
  font-weight: 600;
}

.md strong {
  font-weight: 600;
}

.md a {
  color: var(--brand);
  text-decoration: none;
}

.md a:hover {
  text-decoration: underline;
}

.md ul,
.md ol {
  margin: 16px 0;
  padding-left: 18px;
}

.md li {
  margin-top: 6px;
}

.md li::marker {
  color: var(--label-2);
}

.md blockquote {
  margin: 16px 0 0;
  padding-left: 14px;
  border-left: 2px solid var(--label-4);
  color: var(--label-2);
}

.md hr {
  height: 1px;
  margin: 32px 0;
  border: none;
  background: var(--border-2);
}

.md code {
  display: inline-flex;
  align-items: center;
  padding: 0 5px;
  border-radius: 6px;
  background-color: var(--code-inline);
  font-family: var(--font-code);
  font-size: 0.875em;
}

.md table {
  width: max-content;
  max-width: 100%;
  margin: 16px 0;
  border-collapse: collapse;
  font-size: 15px;
  line-height: 25px;
}

.md th {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-3);
  font-weight: 500;
  text-align: start;
}

.md th:first-child {
  padding-left: 0;
}

.md td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-2);
}

.md td:first-child {
  padding-left: 0;
}

.md td:last-child {
  padding-right: 0;
}

.code-block {
  margin: 16px 0;
  border-radius: 12px;
  background: var(--code-block);
  overflow: hidden;
}

.code-block:not(:last-child) {
  margin-bottom: 16px;
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px;
  background: var(--code-banner);
}

.code-lang {
  margin-left: 8px;
  color: var(--label-1);
  font-family: var(--font-code);
  font-size: 12px;
  line-height: 18px;
}

.code-copy {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 28px;
  padding: 0 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--label-2);
  font-size: 13px;
  line-height: 20px;
}

.code-copy:hover {
  background: var(--hover);
}

.code-block pre {
  margin: 0;
  padding: 12px 16px 16px;
  overflow: auto;
  font-family: var(--font-code);
  font-size: 13px;
  line-height: 22px;
}

.code-block pre code {
  display: block;
  padding: 0;
  background: none;
  font-size: 13px;
  white-space: pre;
}

/* ------------------------------------------------------------------ */
/* 下拉菜单                                                            */
/* ------------------------------------------------------------------ */

.menu {
  position: fixed;
  z-index: 900;
  min-width: 124px;
  padding: 4px;
  border-radius: 12px;
  background-color: var(--bg);
  box-shadow: var(--shadow-menu);
}

body[data-theme='dark'] .menu {
  background-color: #2c2c2e;
}

.model-menu {
  min-width: 260px;
  max-width: 340px;
  max-height: 360px;
  overflow-y: auto;
}

.menu-group-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 4px;
  font-size: 12px;
  line-height: 18px;
  font-weight: 500;
  color: var(--label-3);
}

.menu-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 24px;
  color: var(--label-1);
  cursor: pointer;
  user-select: none;
}

.menu-option:hover {
  background-color: var(--hover);
}

.menu-option.selected {
  color: var(--brand);
}

.menu-option .check {
  margin-left: auto;
  flex-shrink: 0;
  opacity: 0;
}

.menu-option.selected .check {
  opacity: 1;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: var(--label-2);
}

.brand-mark svg {
  display: block;
}

.menu-empty span {
  color: var(--label-4);
  font-size: 12px;
}

.menu-empty {
  padding: 12px 10px;
  font-size: 13px;
  line-height: 20px;
  color: var(--label-3);
}

/* ------------------------------------------------------------------ */
/* 弹窗                                                                */
/* ------------------------------------------------------------------ */

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.32);
  animation: fadeIn 0.16s var(--ease);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
}

.modal {
  display: flex;
  flex-direction: column;
  width: 680px;
  max-width: 100%;
  max-height: min(84vh, 780px);
  border-radius: 16px;
  background: var(--bg);
  box-shadow: var(--shadow-modal);
  animation: popIn 0.18s var(--ease);
  overflow: hidden;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.99);
  }
}

body[data-theme='dark'] .modal {
  background: #212123;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  padding: 18px 20px 12px;
}

.modal-head h2 {
  margin: 0;
  font-size: 16px;
  line-height: 24px;
  font-weight: 600;
  color: var(--label-1);
}

.modal-body {
  flex: 1;
  min-height: 0;
  padding: 0 20px 20px;
  overflow-y: auto;
}

.section-hint {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 20px;
  color: var(--label-3);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 14px;
  line-height: 22px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 0.2s var(--ease), opacity 0.2s var(--ease);
}

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

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-hover);
}

.btn-ghost {
  border-color: var(--border-2);
  background: transparent;
  color: var(--label-1);
  font-weight: 400;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--hover);
}

.btn-danger {
  border-color: color-mix(in srgb, var(--danger) 38%, transparent);
  background: transparent;
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(236, 19, 19, 0.06);
}

.btn-text {
  padding: 0 8px;
  background: transparent;
  color: var(--label-2);
  font-weight: 400;
}

.btn-text:hover:not(:disabled) {
  background: var(--hover);
}

.auth-row {
  display: flex;
  gap: 8px;
}

.auth-row input {
  flex: 1;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border-2);
  border-radius: 10px;
  background: var(--bg);
  color: var(--label-1);
  font-size: 14px;
  outline: none;
}

.auth-row input:focus {
  border-color: var(--brand);
}

/* ------------------------------------------------------------------ */
/* Toast                                                               */
/* ------------------------------------------------------------------ */

.toast {
  position: fixed;
  top: calc(40px + env(safe-area-inset-top));
  right: 0;
  left: 0;
  z-index: 2000;
  width: fit-content;
  max-width: min(calc(100vw - 28px), 480px);
  margin: 0 auto;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 22px;
  text-align: center;
  color: var(--toast-fg);
  background-color: var(--toast-bg);
  box-shadow: 0 0 4px 2px rgba(0, 0, 0, 0.04), 0 4px 16px 0 rgba(0, 0, 0, 0.1);
  animation: toastIn 0.2s var(--ease);
  pointer-events: none;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

/* ------------------------------------------------------------------ */
/* 响应式                                                              */
/* ------------------------------------------------------------------ */

@media (max-width: 1023px) {
  :root {
    --message-list-max-width: 712px;
    --message-list-padding-horizontal: 36px;
  }
}

@media (max-width: 767px) {
  .sider {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 800;
    width: 300px;
    max-width: calc(100vw - 48px);
    background: var(--sidebar-bg);
    transition: transform 0.24s var(--ease);
  }

  .sider.collapsed {
    margin-left: 0;
    transform: translateX(-100%);
  }

  .sider-collapse {
    display: none;
  }

  .sider-mask {
    position: fixed;
    inset: 0;
    z-index: 799;
    background: rgba(0, 0, 0, 0.3);
  }

  .session-header {
    padding: 10px 12px 0;
    height: 56px;
  }

  .mobile-menu {
    display: inline-flex;
    margin-right: 2px;
  }

  /* 首页的汉堡按钮只在首页显示，否则会和会话头部的菜单按钮重叠 */
  .view.home .mobile-home-menu {
    display: inline-flex;
  }

  .welcome-inner {
    justify-content: flex-end;
    max-width: none;
    padding: 0 16px;
  }

  .greeting {
    margin: auto 0 16px;
    font-size: 20px;
    line-height: 28px;
    font-weight: 500;
  }

  .welcome-slot {
    padding-bottom: 8px;
  }

  .welcome-caveat {
    display: block;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }

  .composer-dock {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .composer-slot {
    width: 100%;
    max-width: none;
    padding: 0 8px;
  }

  .message-column {
    width: 100%;
    max-width: none;
    padding: 0 16px 12px;
  }

  .user-bubble {
    max-width: calc(100% - 68px);
  }

  .modal-mask {
    padding: 0;
    align-items: flex-end;
  }

  .modal {
    width: 100%;
    max-height: 88vh;
    border-radius: 16px 16px 0 0;
  }

  .model-menu {
    min-width: 240px;
  }

  .session-item {
    height: 44px;
    border-radius: 16px;
    font-size: 16px;
  }

  .section-header {
    padding: 4px 10px 3px;
    font-size: 14px;
    line-height: 22px;
  }
}

/* ------------------------------------------------------------------ */
/* 附件                                                                */
/* ------------------------------------------------------------------ */

.attach-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--label-2);
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.attach-btn:hover {
  background-color: var(--hover);
  color: var(--label-1);
}

.attach-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 12px 0;
}

/* 编辑历史消息时的提示条 */
.edit-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 12.5px;
  line-height: 18px;
  color: var(--brand);
  background: var(--brand-soft);
  border-bottom: 1px solid var(--brand-border);
}

.edit-hint-icon svg {
  width: 14px;
  height: 14px;
}

.edit-hint-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edit-hint-cancel {
  flex-shrink: 0;
  height: 24px;
  padding: 0 10px;
  border-radius: 12px;
  border: 1px solid var(--brand-border);
  background: transparent;
  color: var(--brand);
  font-size: 12px;
  line-height: 22px;
}

.edit-hint-cancel:hover {
  background: var(--brand-soft-hover);
}

.att-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 220px;
  padding: 7px 18px 7px 9px;
  border: 1px solid var(--border-2);
  border-radius: 10px;
  background: var(--code-block);
  color: var(--label-2);
}

.att-item.is-image {
  width: 64px;
  height: 64px;
  padding: 0;
  border: none;
  background: none;
}

.att-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.att-preview img {
  display: block;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
}

.att-meta {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  line-height: 16px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.att-meta span {
  display: block;
  font-size: 11px;
  color: var(--label-4);
}

.att-item.is-image .att-meta {
  display: none;
}

.att-remove {
  position: absolute;
  top: -4px;
  right: -4px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--toast-bg);
  color: #fff;
  opacity: 0.85;
}

.att-remove:hover {
  opacity: 1;
}

.att-item.uploading {
  padding: 8px 12px;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-3);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.textarea-wrap {
  position: relative;
}

.drop-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--brand);
  border-radius: 24px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 14px;
  pointer-events: none;
}

.composer.dragging {
  border-color: var(--brand);
}

/* 用户消息里的附件 */
.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: 8px;
}

.msg-att {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 240px;
  padding: 0;
  border: none;
  background: none;
  color: var(--label-2);
}

.msg-att img {
  display: block;
  width: 132px;
  height: 132px;
  border-radius: 12px;
  object-fit: cover;
  cursor: zoom-in;
}

.msg-att.file {
  padding: 6px 10px;
  border: 1px solid var(--border-2);
  border-radius: 10px;
  background: var(--code-block);
  font-size: 12px;
  line-height: 18px;
  color: var(--label-2);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.msg-att.file span {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ------------------------------------------------------------------ */
/* 搜索来源                                                            */
/* ------------------------------------------------------------------ */

.sources {
  margin: 14px 0 2px;
}

.sources-head {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 6px 0 0;
  border: none;
  background: none;
  color: var(--label-3);
  font-size: 13px;
  line-height: 20px;
}

.sources-head:hover {
  color: var(--label-2);
}

.sources-icon {
  display: flex;
}

.sources-count {
  padding: 0 6px;
  border-radius: 999px;
  background: var(--hover);
  font-size: 11px;
  line-height: 16px;
}

.sources-head .chev {
  transition: transform 0.2s var(--ease);
}

.sources.open .sources-head .chev {
  transform: rotate(180deg);
}

.sources-list {
  display: none;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

.sources.open .sources-list {
  display: block;
}

.sources-list li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-1);
}

.sources-list li:last-child {
  border-bottom: none;
}

.sources-list a {
  display: flex;
  gap: 6px;
  color: var(--label-1);
  font-size: 14px;
  line-height: 22px;
  text-decoration: none;
}

.sources-list a:hover .source-title {
  text-decoration: underline;
}

.source-index {
  flex-shrink: 0;
  color: var(--brand);
}

.source-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-host {
  padding-left: 16px;
  font-size: 12px;
  line-height: 18px;
  color: var(--label-4);
}

/* ------------------------------------------------------------------ */
/* 模型菜单补充                                                        */
/* ------------------------------------------------------------------ */

.menu-option-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-tag {
  flex-shrink: 0;
  margin-left: auto;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--hover);
  color: var(--label-3);
  font-size: 10px;
  line-height: 16px;
}

.menu-option.selected .model-tag {
  background: var(--brand-soft-hover);
  color: var(--brand);
}

/* ------------------------------------------------------------------ */
/* 门禁 / 图片预览                                                     */
/* ------------------------------------------------------------------ */

.gate-modal {
  width: 380px;
}

.gate-modal .modal-body {
  padding-bottom: 20px;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: rgba(0, 0, 0, 0.82);
  cursor: zoom-out;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  object-fit: contain;
}

/* ------------------------------------------------------------------ */
/* 响应式补充                                                          */
/* ------------------------------------------------------------------ */

@media (max-width: 767px) {
  .function-row {
    gap: 6px;
    padding: 10px;
  }

  .toggles {
    gap: 6px;
    overflow: visible;
  }

  .toggle {
    height: 32px;
    gap: 3px;
    padding: 0 9px;
    font-size: 12.5px;
  }

  /* 图标任何宽度下都不隐藏，只等比缩小 */
  .toggle > .ico:first-child svg {
    width: 13px;
    height: 13px;
  }

  /* 窄屏让模型选择器吃掉剩余宽度，名字尽量完整；前两个胶囊保持完整文字 */
  .toggles .toggle:not(.model-toggle) {
    flex-shrink: 0;
  }

  .model-toggle {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
  }

  .model-toggle .toggle-label {
    max-width: none;
  }

  .send-btn {
    width: 32px;
    height: 32px;
    margin-left: 2px;
  }

  .attach-btn {
    width: 32px;
    height: 32px;
  }

  .preset-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .msg-att img {
    width: 104px;
    height: 104px;
  }
}

/* 极窄屏：图标保留，文字让位（保证按钮不被挤爆） */
@media (max-width: 430px) {
  .function-row {
    gap: 4px;
    padding: 8px;
  }

  .toggles {
    gap: 4px;
  }

  .toggle {
    gap: 3px;
    padding: 0 7px;
    font-size: 12px;
  }

  .toggle > .ico:first-child svg {
    width: 12px;
    height: 12px;
  }

  .model-toggle {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
  }

  .model-toggle .toggle-label {
    max-width: none;
  }

  .model-toggle .ico.chev svg {
    width: 12px;
    height: 12px;
  }

  .attach-btn,
  .send-btn {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
  }
}


/* ------------------------------------------------------------------ */
/* 图标容器（形状取自 chat-demo 的 icons.tsx）                          */
/* ------------------------------------------------------------------ */

.ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ico svg {
  display: block;
}

/* 原版图标的尺寸是写在 svg 上的，这里按场景微调 */
.toggle .ico svg {
  width: 15px;
  height: 15px;
}

.model-toggle .ico.chev svg {
  width: 14px;
  height: 14px;
}

/* ------------------------------------------------------------------ */
/* 设置弹窗：两栏布局，尺寸 / 间距对齐 chat-demo 的 SettingsDialog     */
/* ------------------------------------------------------------------ */

.settings-modal {
  width: 760px;
  height: auto;
  min-height: 300px;
  max-height: min(84vh, 560px);
}

.settings-main {
  display: flex;
  flex: 1;
  min-height: 0;
}

.settings-nav {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  gap: 4px;
  width: 172px;
  padding: 4px 12px 16px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 10px 9px 8px;
  border: none;
  border-radius: 12px;
  background-color: transparent;
  color: var(--label-1);
  font-size: 14px;
  line-height: 22px;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.2s var(--ease);
}

.nav-item:hover,
.nav-item.active {
  background-color: var(--hover);
}

.nav-item .ico svg {
  width: 16px;
  height: 16px;
}

.settings-modal .modal-body {
  padding: 0 24px 22px 0;
}

.settings-pane {
  display: flex;
  flex-direction: column;
}

/* 外观：三块等分选卡（原版 demo 的 ThemeSetting） */
.theme-block {
  flex-shrink: 0;
  margin-top: 2px;
}

.theme-label {
  font-size: 14px;
  line-height: 22px;
  color: var(--label-1);
}

.theme-options {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 8px 0 10px;
}

.theme-option {
  display: inline-flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-sizing: border-box;
  min-width: 128px;
  height: 82px;
  padding: 0 24px;
  border: 1px solid var(--border-2);
  border-radius: 12px;
  background-color: transparent;
  color: var(--label-1);
  font-size: 14px;
  line-height: 22px;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s var(--ease);
}

.theme-option:hover,
.theme-option.selected {
  background-color: var(--brand-soft);
  border-color: var(--brand-border);
}

.theme-option .ico svg {
  width: 16px;
  height: 16px;
}

/* 设置行：左标题 + 说明，右侧动作（原版 demo 的 SettingCell） */
.setting-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 60px;
  padding: 12px 0;
  font-size: 14px;
  line-height: 22px;
  color: var(--label-1);
}

.setting-cell + .setting-cell {
  box-shadow: inset 0 1px 0 0 var(--border-1);
}

.cell-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding-right: 48px;
}

.cell-label {
  font-size: 14px;
  line-height: 22px;
}

.cell-desc {
  font-size: 12px;
  line-height: 18px;
  color: var(--label-3);
}

.cell-desc code {
  padding: 1px 5px;
  border-radius: 5px;
  background-color: var(--hover);
  font-family: var(--font-code);
  font-size: 11.5px;
}

.setting-cell .btn {
  flex-shrink: 0;
}

.btn-icon-text {
  gap: 5px;
}

.btn-icon-text .ico svg {
  width: 14px;
  height: 14px;
}

@media (max-width: 767px) {
  .settings-modal {
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: min(86vh, 680px);
  }

  .settings-main {
    flex-direction: column;
  }

  .settings-nav {
    flex-direction: row;
    width: auto;
    gap: 4px;
    padding: 0 16px 6px;
    overflow-x: auto;
  }

  .nav-item {
    flex-shrink: 0;
    min-height: 36px;
    padding: 6px 10px;
  }

  .settings-modal .modal-body {
    padding: 0 16px calc(16px + env(safe-area-inset-bottom));
  }

  .cell-text {
    padding-right: 8px;
  }

  .theme-option {
    min-width: 104px;
    height: 72px;
    padding: 0 12px;
  }
}

/* 助手回复下的操作行常驻（原版 demo 也是直接显示，不靠 hover 才出现） */
.msg-assistant .msg-actions {
  opacity: 1;
}

.msg-assistant .msg-actions .act-btn {
  color: var(--label-4);
}

.msg-assistant .msg-actions .act-btn:hover {
  color: var(--label-1);
}
