:root {
  --bg: #f3f5f8;
  --sidebar: #eef2f6;
  --rail: #e8edf3;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #8b95a5;
  --line: #d7dee8;
  --accent: #6b5cff;
  --accent-soft: #eef0ff;
  --btn-blue: #3b82f6;
  --btn-blue-bg: #eaf2ff;
  --danger: #94a3b8;
  --shadow: 0 4px 18px rgba(15, 23, 42, 0.06);
  --radius: 14px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --app-height: 100dvh;
  --vv-top: 0px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background: #dfe5ee;
  overscroll-behavior-x: none;
  overscroll-behavior-y: none;
  overflow: hidden;
  overflow-x: hidden;
  width: 100%;
  max-width: 100%;
  position: relative;
}

button,
input,
textarea {
  font: inherit;
}

.rail,
.rail *,
.sidebar-head,
.new-chat-btn,
.composer-toolbar,
.round-tool,
.send-btn {
  user-select: none;
  -webkit-user-select: none;
}

#app {
  height: var(--app-height);
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  position: relative;
  overflow: hidden;
  overscroll-behavior-x: none;
}

/* 手机：钉住 visualViewport，避免 iOS Safari/微信 弹键盘后输入框悬空 */
@media (max-width: 767px) {
  html,
  body {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
  }

  #app {
    position: fixed;
    top: var(--vv-top);
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: var(--app-height);
    margin: 0;
  }
}

/* 平板：居中中等窗口 */
@media (min-width: 768px) {
  body {
    background: #dfe5ee;
  }

  #app {
    width: 100%;
    max-width: 720px;
    height: min(var(--app-height), calc(100dvh - 32px));
    margin: 16px auto;
    border-radius: 18px;
    box-shadow: 0 0 40px rgba(15, 23, 42, 0.12);
  }

  .auth-gate {
    padding: 32px;
  }

  .bubble {
    max-width: min(480px, calc(100% - 42px));
  }
}

/* 电脑：第一版大窗口尺寸 */
@media (min-width: 1024px) {
  #app {
    max-width: 920px;
    height: calc(100dvh - 48px);
    margin: 24px auto;
  }

  .bubble {
    max-width: min(560px, calc(100% - 42px));
  }
}

/* Left icon rail — collapses when history sidebar pushes open */
.rail {
  box-sizing: border-box;
  width: 56px;
  min-width: 0;
  flex-shrink: 0;
  background: var(--rail);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 14px 0 16px;
  gap: 14px;
  overflow: hidden;
  position: relative;
  z-index: 2;
  transition: width 0.22s ease, padding 0.22s ease, opacity 0.18s ease;
}

#app.sidebar-open .rail {
  width: 0;
  padding-left: 0;
  padding-right: 0;
  opacity: 0;
  pointer-events: none;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(145deg, #7a6bff, #5b4dff);
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 6px 14px rgba(91, 77, 255, 0.28);
}

.brand-icon svg {
  width: 22px;
  height: 22px;
}

.rail-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #64748b;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.rail-btn:hover {
  background: rgba(255, 255, 255, 0.7);
}

.rail-btn.active {
  background: #fff;
  color: var(--accent);
  box-shadow: var(--shadow);
}

.rail-spacer {
  flex: 1;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: #3b82f6;
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}

/* History sidebar — 用 width 过渡推开主区（不要改 flex-basis / visibility，否则会变成弹出） */
.sidebar {
  width: 0;
  min-width: 0;
  flex-shrink: 0;
  background: var(--sidebar);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: width 0.22s ease, padding 0.22s ease, opacity 0.18s ease;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid transparent;
  position: relative;
  z-index: 1;
}

#app.sidebar-open .sidebar,
.sidebar.open {
  width: 280px;
  min-width: 280px;
  height: 100%;
  min-height: 0;
  padding: 12px 12px;
  opacity: 1;
  pointer-events: auto;
  border-right-color: rgba(148, 163, 184, 0.25);
  z-index: 3;
  /* 中间列表滚动；底部账号区吸底，避免大块留白 */
  overflow: hidden;
  touch-action: pan-y;
}

@media (max-width: 767px) {
  #app.sidebar-open .sidebar,
  .sidebar.open {
    width: min(280px, 82vw);
    min-width: min(280px, 82vw);
    height: 100%;
  }

}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 16px;
  font-weight: 700;
}

.new-chat-btn {
  width: 100%;
  border: 1px solid #93c5fd;
  background: var(--btn-blue-bg);
  color: var(--btn-blue);
  border-radius: 10px;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 600;
  flex-shrink: 0;
}

.new-chat-btn:hover {
  background: #dbeafe;
}

.sidebar-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  margin-top: 4px;
  padding-right: 2px;
  padding-bottom: 4px;
}

/* 展开设置时历史区按内容高度，多余空间给底部设置，不留空档 */
.sidebar:has(.key-fold:not(.is-collapsed)) .sidebar-scroll {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 28%;
}

.side-section {
  margin-top: 8px;
}

.side-section + .side-section {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(148, 163, 184, 0.28);
}

.side-section-bar {
  display: flex;
  align-items: center;
  gap: 4px;
}

.side-section-toggle {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 4px 2px;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  color: #475569;
  -webkit-tap-highlight-color: transparent;
}

.side-section-chevron {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  color: #94a3b8;
  transition: transform 0.18s ease;
  flex-shrink: 0;
}

.side-section.is-collapsed .side-section-chevron {
  transform: rotate(-90deg);
}

.side-section-title {
  font-size: 14px;
  font-weight: 600;
}

.side-section-count {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  background: #eef2f7;
  border-radius: 999px;
  padding: 1px 7px;
}

.side-section-count:empty {
  display: none;
}

.side-section-body {
  margin-top: 6px;
}

.side-section.is-collapsed .side-section-body {
  display: none;
}

.icon-btn {
  border: none;
  background: transparent;
  color: var(--danger);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: rgba(148, 163, 184, 0.18);
  color: #ef4444;
}

.history-list {
  margin-top: 0;
  overflow-x: hidden;
  overflow-y: auto;
  flex: 0 0 auto;
  max-height: min(42vh, 300px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.sidebar-dock {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  min-height: 0;
  overflow: hidden;
}

.sidebar:has(.key-fold:not(.is-collapsed)) .sidebar-dock {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 8px;
}

.key-box {
  margin-top: 0;
  padding-top: 10px;
  padding-bottom: 0;
  border-top: 1px solid rgba(148, 163, 184, 0.35);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 0;
  overflow: hidden;
  background: var(--sidebar);
  position: relative;
  z-index: 2;
}

.sidebar:has(.key-fold:not(.is-collapsed)) .key-box {
  flex: 1 1 auto;
  min-height: 0;
}

.key-label {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
}

.key-fold {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 0;
  border: 1px solid #dbe3ef;
  border-radius: 12px;
  background: #f8fafc;
  overflow: hidden;
  min-height: 0;
}

.key-fold:not(.is-collapsed) {
  flex: 1 1 auto;
  min-height: 0;
}

.key-fold-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border: none;
  background: #f1f5f9;
  cursor: pointer;
  text-align: left;
  color: #334155;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.key-fold-head:active {
  background: #e2e8f0;
}

.key-fold-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.key-fold-title {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
}

.key-fold-main .key-status {
  font-size: 11px;
  line-height: 1.35;
  word-break: break-all;
}

.key-fold-aside {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.key-fold-hint {
  font-size: 11px;
  font-weight: 600;
  color: #3b82f6;
  white-space: nowrap;
}

.key-fold-chevron {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #cbd5e1;
  color: #64748b;
  transition: transform 0.18s ease;
}

.key-fold.is-collapsed .key-fold-chevron {
  transform: rotate(-90deg);
}

.key-fold:not(.is-collapsed) .key-fold-head {
  border-bottom: 1px solid #e2e8f0;
}

.key-fold-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px 12px;
  background: #fff;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.key-fold-body[hidden] {
  display: none;
}

.account-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  margin-top: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  flex: 0 0 auto;
  flex-shrink: 0;
  position: relative;
  z-index: 3;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

.account-foot-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.account-foot-meta .key-label {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
}

.account-foot-meta .key-status {
  font-size: 13px;
  font-weight: 600;
}

.account-logout-btn {
  flex-shrink: 0;
  border: none;
  border-radius: 8px;
  padding: 7px 12px;
  background: #3b82f6;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.account-logout-btn:active {
  background: #2563eb;
}

.key-status {
  font-size: 12px;
  color: #94a3b8;
}

.key-status.ok {
  color: #16a34a;
}

.key-input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  outline: none;
}

.key-input:focus {
  border-color: #93c5fd;
}

.key-save-btn {
  border: none;
  border-radius: 8px;
  padding: 9px 10px;
  background: #3b82f6;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.key-save-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.key-link {
  font-size: 12px;
  color: #3b82f6;
  text-decoration: none;
}

.key-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.key-mode-btn {
  border: 1px solid #dbe3ee;
  background: #f8fafc;
  color: #64748b;
  border-radius: 8px;
  padding: 7px 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.key-mode-btn.active {
  background: #eaf3ff;
  border-color: #93c5fd;
  color: #2563eb;
}

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

.key-link-btn {
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 12px;
  text-align: left;
  padding: 0;
  cursor: pointer;
}

.key-link-btn:hover {
  color: #2563eb;
}

.model-allow-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
  flex: 0 0 auto;
}

.model-allow-box[hidden] {
  display: none !important;
}

.model-allow-mode {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.model-allow-mode-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #475569;
  cursor: pointer;
}

.model-allow-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.model-allow-list {
  flex: 0 0 auto;
  min-height: 200px;
  max-height: min(48vh, 420px);
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
  padding: 4px 4px 8px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: auto;
  touch-action: pan-y;
}

.model-allow-save {
  position: sticky;
  bottom: -12px;
  z-index: 2;
  margin: 0 -12px -12px;
  padding: 8px 12px 12px;
  background: #fff;
}

#btnSaveModelAllow {
  position: relative;
  z-index: 1;
  width: 100%;
  box-shadow: none;
}

.model-allow-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 12px;
  color: #0f172a;
  cursor: pointer;
}

.model-allow-item:hover {
  background: #fff;
}

.model-allow-item input {
  margin-top: 2px;
  flex-shrink: 0;
}

.model-allow-item-text {
  min-width: 0;
}

.model-allow-item-name {
  font-weight: 650;
  line-height: 1.3;
}

.model-allow-item-id {
  color: #94a3b8;
  font-size: 11px;
  margin-top: 1px;
  word-break: break-all;
}

.history-empty {
  padding: 12px 10px;
  color: #94a3b8;
  font-size: 13px;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 8px;
}

.history-row:hover,
.history-row.active {
  background: rgba(255, 255, 255, 0.85);
}

.history-item {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  text-align: left;
  padding: 10px 8px 10px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.history-run-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
  animation: history-run-pulse 1.5s ease-out infinite;
}

.history-row.is-running .history-item-text {
  color: #166534;
}

@keyframes history-run-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
    opacity: 1;
  }
  70% {
    box-shadow: 0 0 0 7px rgba(34, 197, 94, 0);
    opacity: 0.85;
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .history-run-dot {
    animation: none;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
  }
}

.history-del {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin-right: 4px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  display: grid;
  place-items: center;
  opacity: 0.7;
}

.history-del:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  opacity: 1;
}

.collapse-fab {
  position: absolute;
  right: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: #64748b;
  display: none;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  z-index: 2;
}

#app.sidebar-open .collapse-fab {
  display: grid;
}

/* 收起过程中立刻隐藏凸出按钮，避免左侧残留一条侧栏+箭头 */
#app:not(.sidebar-open) .collapse-fab {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

.sidebar:not(.open) {
  border-right-color: transparent;
}

.backdrop {
  display: none !important;
  pointer-events: none !important;
}

/* Main chat — 保持可读宽度；侧栏推开时整体右移，由 #app overflow 裁切，绝不把文字挤成竖条 */
.main {
  flex: 0 0 calc(100% - 56px);
  width: calc(100% - 56px);
  min-width: calc(100% - 56px);
  max-width: none;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
  z-index: 1;
  pointer-events: auto;
}

.rail,
.sidebar {
  touch-action: pan-y;
}

.topbar {
  height: 52px;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 4px;
  padding: 0 10px 0 8px;
  background: rgba(243, 245, 248, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent;
  position: relative;
  z-index: 2;
}

.expand-hint {
  border: none;
  background: transparent;
  color: #94a3b8;
  width: 28px;
  height: 28px;
  justify-self: start;
  display: grid;
  place-items: center;
  cursor: pointer;
  border-radius: 8px;
}

.expand-hint:hover {
  background: rgba(255, 255, 255, 0.85);
  color: var(--accent);
}

#app.sidebar-open .expand-hint {
  visibility: hidden;
}

.chat-title-wrap {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.topbar h1,
.topbar .chat-title {
  margin: 0;
  max-width: 100%;
  min-width: 0;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  cursor: pointer;
  border-radius: 8px;
  padding: 4px 6px;
}

.topbar .chat-title:hover {
  background: rgba(255, 255, 255, 0.7);
}

.topbar .chat-title[hidden] {
  display: none !important;
}

.chat-title-input {
  width: min(100%, 280px);
  min-width: 0;
  box-sizing: border-box;
  margin: 0 auto;
  border: 1px solid #93c5fd;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  outline: none;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.chat-title-input[hidden] {
  display: none !important;
}

.history-rename {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #94a3b8;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}

.history-rename:hover {
  background: rgba(148, 163, 184, 0.15);
  color: var(--accent);
}

.history-item-input {
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
  border: 1px solid #93c5fd;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  outline: none;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.topbar-new {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #64748b;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.topbar-new:hover {
  background: rgba(255, 255, 255, 0.85);
  color: var(--accent);
}


.messages {
  flex: 1;
  overflow: auto;
  padding: 10px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  user-select: text;
  -webkit-user-select: text;
}

body.keyboard-open .messages {
  padding-bottom: 8px;
}

.msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  max-width: 100%;
  user-select: text;
  -webkit-user-select: text;
}

.msg-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  max-width: min(100%, calc(100% - 42px));
  min-width: 0;
}

.msg-col-assistant {
  align-items: flex-start;
}

.msg-meta {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 2px;
  max-width: 100%;
}

.msg-duration {
  color: #94a3b8;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.msg-edit-btn,
.msg-copy-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: #94a3b8;
  font-size: 12px;
  line-height: 1;
  padding: 2px 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.msg-edit-btn:active,
.msg-copy-btn:active {
  color: #64748b;
}

.msg-edit-btn:hover,
.msg-copy-btn:hover {
  color: #64748b;
}

.msg.user.is-editing-msg .msg-col {
  width: min(420px, 100%);
  max-width: min(100%, calc(100% - 42px));
}

.bubble.bubble-inline-edit {
  width: 100%;
  max-width: 100%;
  background: #fff;
  box-shadow: 0 0 0 1.5px #3b82f6;
  padding: 10px 12px 8px;
}

.inline-edit-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.inline-edit-thumb {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  overflow: hidden;
  background: #f1f5f9;
}

.inline-edit-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  margin: 0;
  max-width: none;
  max-height: none;
  cursor: default;
}

.inline-edit-thumb-x {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.65);
  color: #fff;
  font-size: 12px;
  line-height: 18px;
  padding: 0;
  cursor: pointer;
}

.inline-edit-input {
  width: 100%;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  min-height: 44px;
  max-height: 180px;
  padding: 0;
  margin: 0;
}

.inline-edit-tip {
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.35;
  color: #94a3b8;
}

.inline-edit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding-top: 6px;
}

.inline-edit-cancel {
  appearance: none;
  border: 0;
  background: transparent;
  color: #64748b;
  font-size: 13px;
  padding: 6px 4px;
  cursor: pointer;
}

.inline-edit-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.inline-edit-attach {
  width: 32px;
  height: 32px;
  border: 1.5px solid #cfd6e0;
  border-radius: 50%;
  background: #fff;
  color: #334155;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  position: relative;
  flex-shrink: 0;
}

.inline-edit-attach .ico-plus,
.inline-edit-attach .ico-close {
  grid-area: 1 / 1;
}

.inline-edit-attach .ico-close,
.inline-edit-attach.is-open .ico-plus {
  display: none;
}

.inline-edit-attach.is-open .ico-close {
  display: block;
}

.inline-edit-attach.is-open {
  border-color: #94a3b8;
  background: #f8fafc;
}

/* 轻量横排图标，贴在加号左侧，避免小气泡里再塞大磁贴 */
.inline-attach-menu {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 999px;
  background: #eef2f7;
  animation: inline-attach-in 0.16s ease;
}

@keyframes inline-attach-in {
  from {
    opacity: 0;
    transform: translateX(6px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.inline-attach-item {
  appearance: none;
  border: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: transparent;
  color: #334155;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}

.inline-attach-item:active {
  background: #fff;
  color: #0f172a;
}

.inline-edit-send {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}

.inline-edit-send:active {
  filter: brightness(0.95);
}

.msg.user {
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(145deg, #7a6bff, #5b4dff);
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.msg.user .msg-avatar {
  background: #3b82f6;
}

.bubble {
  background: var(--panel);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  line-height: 1.55;
  font-size: 14px;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: min(320px, calc(100% - 42px));
  min-width: 0;
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: default;
}

.bubble:has(.md-table-wrap) {
  max-width: min(100%, calc(100% - 42px));
}

.msg.user .bubble {
  background: #eef4ff;
}

.msg-col .bubble:not(.bubble-inline-edit) {
  max-width: min(320px, 100%);
}

.msg-col-assistant .bubble:not(.bubble-inline-edit) {
  max-width: min(320px, 100%);
}

.bubble img.thumb,
.md-body img {
  display: block;
  max-width: min(260px, 100%);
  max-height: 220px;
  border-radius: 8px;
  margin: 8px 0;
  object-fit: contain;
  background: #f1f5f9;
  cursor: zoom-in;
}

.bubble .thumb-masked {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: min(260px, 100%);
  width: min(200px, 100%);
  min-height: 120px;
  max-height: 220px;
  margin: 8px 0;
  padding: 12px 14px;
  box-sizing: border-box;
  border-radius: 8px;
  border: 1px dashed #cbd5e1;
  background:
    repeating-linear-gradient(
      -45deg,
      #f1f5f9,
      #f1f5f9 6px,
      #e2e8f0 6px,
      #e2e8f0 12px
    );
  color: #64748b;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}

.md-img-missing {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff7ed;
  color: #c2410c;
  font-size: 12px;
  line-height: 1.45;
}

.md-img-missing p {
  margin: 0 0 6px;
}

.md-img-missing p:last-of-type {
  margin-bottom: 8px;
}

.md-img-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.md-img-fill {
  display: inline-block;
  border: 1px solid #fdba74;
  background: #fff;
  color: #c2410c;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
}

.md-img-fill.is-ghost {
  border-color: #fed7aa;
  color: #9a3412;
  background: transparent;
}

.md-img-fill:disabled {
  opacity: 0.6;
  cursor: wait;
}

.md-img-fill:active {
  background: #ffedd5;
}

.md-body {
  white-space: normal;
}

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

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

.md-body p {
  margin: 0 0 0.65em;
}

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

.md-body h1,
.md-body h2,
.md-body h3,
.md-body h4 {
  margin: 0.8em 0 0.4em;
  font-weight: 700;
  line-height: 1.3;
}

.md-body h1 { font-size: 1.2em; }
.md-body h2 { font-size: 1.1em; }
.md-body h3 { font-size: 1.05em; }

.md-body ul,
.md-body ol {
  margin: 0.4em 0 0.65em;
  padding-left: 1.35em;
}

.md-body li {
  margin: 0.2em 0;
}

.md-body li > p {
  margin: 0;
}

.md-body blockquote {
  margin: 0.5em 0;
  padding: 0.25em 0 0.25em 0.75em;
  border-left: 3px solid #cbd5e1;
  color: #64748b;
}

.md-body code {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
  font-size: 0.9em;
  background: rgba(15, 23, 42, 0.06);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.md-code {
  margin: 0.65em 0;
  border-radius: 12px;
  overflow: hidden;
  background: #0f172a;
  border: 1px solid #1e293b;
}

.md-code-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  background: #111827;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.md-code-lang {
  font-size: 11px;
  color: #94a3b8;
  text-transform: lowercase;
  letter-spacing: 0.02em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.md-code-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.md-code-btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1.2;
  background: rgba(148, 163, 184, 0.16);
  color: #e2e8f0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.md-code-btn:active {
  background: rgba(148, 163, 184, 0.28);
}

.md-code-btn.primary {
  background: #4f46e5;
  color: #fff;
}

.md-code-btn.primary:active {
  filter: brightness(0.95);
}

.md-body pre,
.md-code pre {
  margin: 0;
  padding: 12px;
  background: transparent;
  color: #e2e8f0;
  border-radius: 0;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.5;
  -webkit-overflow-scrolling: touch;
}

.md-code.is-collapsed pre {
  max-height: 10.5em;
  overflow: hidden;
  position: relative;
}

.md-code.is-collapsed pre::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 48px;
  background: linear-gradient(to bottom, rgba(15, 23, 42, 0), #0f172a 88%);
  pointer-events: none;
}

.md-code-more {
  display: none;
  width: 100%;
  border: 0;
  border-top: 1px solid rgba(148, 163, 184, 0.14);
  background: #111827;
  color: #93c5fd;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.md-code.is-collapsed .md-code-more {
  display: block;
}

.md-code-more:active {
  color: #bfdbfe;
}

.md-body pre code,
.md-code pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: inherit;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
  white-space: pre;
}

.bubble:has(.md-code) {
  max-width: min(100%, calc(100% - 42px));
}

.html-preview {
  position: fixed;
  inset: 0;
  z-index: 190;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(15, 23, 42, 0.45);
  padding: 0;
}

.html-preview[hidden] {
  display: none !important;
}

.html-preview-panel {
  width: 100%;
  height: min(86dvh, 86vh, 860px);
  background: #fff;
  border-radius: 16px 16px 0 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  box-shadow: 0 -8px 40px rgba(15, 23, 42, 0.2);
  animation: attach-rise 0.22s ease;
}

.html-preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid #e8eef5;
}

.html-preview-title {
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
}

.html-preview-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: #f1f5f9;
  color: #334155;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.html-preview-frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 55vh;
  border: 0;
  background: #fff;
}

.md-body hr {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 0.8em 0;
}

.md-body strong {
  font-weight: 700;
}

.md-table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 0.55em 0;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  -webkit-overflow-scrolling: touch;
}

.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  line-height: 1.4;
  min-width: 220px;
}

.md-table th,
.md-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #eef2f7;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.md-table th {
  background: #f8fafc;
  font-weight: 700;
  color: #334155;
}

.md-table tr:last-child td {
  border-bottom: none;
}

.md-table tr:nth-child(even) td {
  background: #fcfdff;
}

.msg.user .md-table-wrap {
  border-color: #dbe7ff;
}

.msg.user .md-table th {
  background: #e8f0ff;
}

.md-plain {
  margin: 0;
  white-space: pre-wrap;
}

.typing {
  color: var(--muted);
  font-size: 13px;
}

.msg.queue {
  max-width: 100%;
  width: 100%;
}

.queue-card {
  width: 100%;
  max-width: min(520px, 100%);
  margin: 0 auto 0 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.queue-head {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
  text-align: left;
}

.queue-chevron {
  display: inline-grid;
  place-items: center;
  transition: transform 0.18s ease;
  color: #94a3b8;
}

.queue-card.is-collapsed .queue-chevron {
  transform: rotate(-90deg);
}

.queue-count {
  font-weight: 600;
  color: #64748b;
}

.queue-meta {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: #94a3b8;
  font-size: 11px;
}

.queue-body {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 4px 10px 12px 12px;
}

.queue-card.is-collapsed .queue-body {
  display: none;
}

.queue-spinner {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  margin-top: 3px;
  border: 1.5px solid #cbd5e1;
  border-top-color: #64748b;
  border-radius: 50%;
  animation: queue-spin 0.8s linear infinite;
}

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

.queue-copy {
  flex: 1;
  min-width: 0;
}

.queue-prompt {
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.queue-detail {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.queue-stop {
  flex-shrink: 0;
  height: 28px;
  padding: 0 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  color: #64748b;
  font-size: 12px;
  line-height: 1;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.queue-stop:active,
.queue-stop:hover {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
}

.send-queue {
  margin: 0 0 8px;
}

.send-queue[hidden] {
  display: none !important;
}

.send-queue-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
  box-shadow: none;
}

.send-queue-head {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
}

.send-queue-card.is-collapsed .queue-chevron {
  transform: rotate(-90deg);
}

.send-queue-card.is-collapsed .send-queue-list {
  display: none;
}

.send-queue-list {
  padding: 2px 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.send-queue-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  border-radius: 0;
  background: transparent;
  border: 0;
  border-top: 1px solid #f1f5f9;
}

.send-queue-item:first-child {
  border-top: 0;
}

.send-queue-item.is-running {
  align-items: flex-start;
}

.send-queue-item .queue-spinner {
  margin-top: 2px;
}

.send-queue-item.is-editing {
  margin: 2px 0;
  padding: 8px 6px;
  border-radius: 8px;
  border-top-color: transparent;
  background: #eff6ff;
  box-shadow: inset 0 0 0 1.5px #3b82f6;
}

.send-queue-item.is-editing + .send-queue-item {
  border-top-color: transparent;
}

.queue-edit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: -4px -4px 6px;
  padding: 8px 10px;
  border-radius: 10px 10px 0 0;
  background: #eef2f7;
  border-bottom: 1px solid #e2e8f0;
}

.queue-edit-bar[hidden] {
  display: none !important;
}

.composer.is-editing-queue {
  border-color: #93c5fd;
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.18);
}

.queue-edit-label {
  font-size: 12px;
  color: #475569;
  font-weight: 500;
}

.queue-edit-cancel {
  border: 0;
  background: transparent;
  color: #2563eb;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}

.queue-edit-cancel:active {
  background: #dbeafe;
}

.send-queue-item .queue-spinner {
  margin-top: 2px;
}

.send-queue-copy {
  flex: 1;
  min-width: 0;
}

.send-queue-dot {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  border: 1.5px solid #cbd5e1;
  border-radius: 50%;
}

.send-queue-text {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.send-queue-sub {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
}

.send-queue-stream {
  margin-top: 4px;
  font-size: 12px;
  color: #475569;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 4.2em;
  overflow: hidden;
}

.msg.is-streaming .bubble {
  position: relative;
}

.stream-caret {
  display: inline-block;
  width: 7px;
  height: 1em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: #64748b;
  animation: stream-caret-blink 1s steps(1) infinite;
}

@keyframes stream-caret-blink {
  50% {
    opacity: 0;
  }
}

.send-queue-actions {
  display: flex;
  gap: 0;
  flex-shrink: 0;
  align-items: center;
}

.send-queue-btn {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #94a3b8;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  line-height: 0;
}

.send-queue-btn svg {
  display: block;
}

.send-queue-btn:active,
.send-queue-btn:hover {
  background: #f1f5f9;
  color: #64748b;
}

.send-queue-btn.danger:active,
.send-queue-btn.danger:hover {
  background: #fef2f2;
  color: #dc2626;
}

.send-queue-item .queue-stop {
  margin-top: -2px;
}

.composer-wrap {
  flex-shrink: 0;
  padding: 8px 12px calc(10px + var(--safe-bottom));
  background: var(--bg);
}

.attach-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 10px;
  padding: 4px 2px 2px;
  animation: attach-rise 0.22s ease;
}

.attach-panel[hidden] {
  display: none !important;
}

@keyframes attach-rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.attach-tile {
  appearance: none;
  border: 0;
  background: #fff;
  border-radius: 14px;
  padding: 16px 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.05);
  border: 1px solid #eef2f7;
  color: #0f172a;
}

.attach-tile:active {
  background: #f8fafc;
}

.attach-tile-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: #f1f5f9;
  color: #111827;
  display: grid;
  place-items: center;
}

.attach-tile-label {
  font-size: 13px;
  line-height: 1.2;
  color: #334155;
}

.round-tool.is-open {
  border-color: #94a3b8;
  background: #f8fafc;
}

.preview-row {
  display: none;
  gap: 8px;
  overflow-x: auto;
  padding: 0 2px 2px;
  -webkit-overflow-scrolling: touch;
}

.preview-row.show {
  display: flex;
}

.preview-item {
  position: relative;
  flex: 0 0 auto;
  width: min(220px, 72vw);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 28px 8px 8px;
  background: #f3f5f8;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  cursor: pointer;
}

.preview-item .preview-thumb {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: #e5e9f0;
}

.preview-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.preview-name {
  font-size: 13px;
  font-weight: 600;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.preview-size {
  font-size: 12px;
  color: #94a3b8;
}

.preview-item .preview-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: #1f2937;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  line-height: 0;
}

.preview-item .preview-remove svg {
  width: 12px;
  height: 12px;
  display: block;
}

.composer {
  background: #fff;
  border-radius: 22px;
  box-shadow: 0 2px 14px rgba(15, 23, 42, 0.06);
  border: 1px solid rgba(148, 163, 184, 0.18);
  display: flex;
  flex-direction: column;
  padding: 12px 12px 10px;
  gap: 10px;
}

.composer textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  min-height: 28px;
  max-height: 120px;
  padding: 2px 4px;
  background: transparent;
  line-height: 1.45;
  font-size: 15px;
}

.composer textarea::placeholder {
  color: #b0b8c4;
}

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.composer-picks {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.mode-seg {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border-radius: 999px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.mode-seg-btn {
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1.2;
  -webkit-tap-highlight-color: transparent;
}

.mode-seg-btn.active {
  background: #fff;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.model-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: min(42vw, 160px);
  min-width: 0;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #334155;
  border-radius: 999px;
  padding: 5px 8px 5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.model-chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.model-chip svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.model-sheet {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.model-sheet[hidden] {
  display: none !important;
}

.model-sheet-card {
  width: 100%;
  max-width: 560px;
  max-height: min(78vh, 640px);
  background: #fff;
  border-radius: 18px 18px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -8px 30px rgba(15, 23, 42, 0.18);
}

.model-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
  flex-shrink: 0;
}

.model-sheet-title {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}

.model-sheet-x {
  width: 32px;
  height: 32px;
  border: none;
  background: #f1f5f9;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
}

.model-sheet-search {
  margin: 0 16px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  background: #f8fafc;
  flex-shrink: 0;
}

.model-sheet-search:focus {
  border-color: #93c5fd;
  background: #fff;
}

.model-sheet-list {
  flex: 1;
  overflow: auto;
  padding: 0 8px 8px;
  -webkit-overflow-scrolling: touch;
}

.model-row {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 11px 12px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #0f172a;
}

.model-row:active,
.model-row.is-selected {
  background: #f1f5f9;
}

.model-row-main {
  min-width: 0;
  flex: 1;
}

.model-row-name {
  font-size: 14px;
  font-weight: 650;
  line-height: 1.3;
}

.model-row-sub {
  margin-top: 2px;
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.3;
}

.model-row-check {
  flex-shrink: 0;
  color: var(--accent, #2f7cf6);
  font-size: 16px;
  font-weight: 700;
  width: 18px;
  text-align: center;
}

.model-variant-group {
  margin: 0 4px 8px;
  padding: 4px 0 4px 10px;
  border-left: 2px solid #e2e8f0;
}

.model-sheet-empty,
.model-sheet-loading {
  padding: 28px 16px;
  text-align: center;
  color: #94a3b8;
  font-size: 14px;
}

.model-sheet-foot {
  padding: 8px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  font-size: 11px;
  color: #94a3b8;
  border-top: 1px solid #f1f5f9;
  flex-shrink: 0;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.round-tool {
  width: 34px;
  height: 34px;
  border: 1.5px solid #cfd6e0;
  border-radius: 50%;
  background: #fff;
  color: #334155;
  display: grid;
  place-items: center;
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
}

#btnAttach .attach-icon-plus,
#btnAttach .attach-icon-close {
  grid-area: 1 / 1;
  display: block;
}

#btnAttach .attach-icon-close,
#btnAttach.is-open .attach-icon-plus {
  display: none;
}

#btnAttach.is-open .attach-icon-close {
  display: block;
}

.round-tool.active {
  border-color: #2f7cf6;
  color: #2f7cf6;
  background: #eaf3ff;
}

.send-btn {
  width: 34px;
  height: 34px;
  border: 1.5px solid transparent;
  border-radius: 10px;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  background: var(--accent);
  color: #fff;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, border-radius 0.18s ease;
}

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

/* 白底 + 黑方块，一眼能认出是停止 */
.send-btn.is-stop {
  background: #fff;
  color: #0f172a;
  border-color: #e2e8f0;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.send-btn.is-stop:hover,
.send-btn.is-stop:active {
  background: #fff;
  color: #000;
  border-color: #cbd5e1;
}

body.keyboard-open .composer-wrap {
  padding-bottom: 8px;
}

/* 键盘弹出时去掉底部安全区空白，输入条贴键盘 */
@media (max-width: 767px) {
  body.keyboard-open .composer-wrap {
    padding-bottom: 6px;
  }
}

.error-toast {
  position: fixed;
  left: 50%;
  top: 50%;
  top: 50dvh;
  transform: translate(-50%, -50%);
  background: #1e293b;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
  width: max-content;
  max-width: min(86%, 360px);
  text-align: center;
  word-break: break-word;
  z-index: 200;
  display: none;
  box-sizing: border-box;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.22);
}

.error-toast.show {
  display: block;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 23, 42, 0.88);
  display: none;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  padding: 52px 0 96px;
  pointer-events: none;
}

.lightbox:not([hidden]) {
  display: flex;
  pointer-events: auto;
}

.lightbox[hidden] {
  display: none !important;
  pointer-events: none !important;
}

.lightbox-stage {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  padding: 0 16px;
  -webkit-user-select: none;
  user-select: none;
}

.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 0;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  transform-origin: center center;
  will-change: transform;
  -webkit-user-drag: none;
  user-select: none;
}

.lightbox.is-zoomed .lightbox-stage {
  cursor: grab;
}

.lightbox.is-zoomed .lightbox-stage:active {
  cursor: grabbing;
}

.lightbox-zoom-tools {
  position: absolute;
  right: 12px;
  bottom: max(88px, calc(72px + env(safe-area-inset-bottom, 0px)));
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lightbox-filmstrip[hidden] ~ .lightbox-zoom-tools {
  bottom: max(16px, calc(12px + env(safe-area-inset-bottom, 0px)));
}

.lightbox-zoom-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  line-height: 0;
}

.lightbox-zoom-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

.lightbox-zoom-btn:active {
  background: rgba(255, 255, 255, 0.28);
}

.lightbox-meta {
  position: absolute;
  top: max(12px, env(safe-area-inset-top, 0px));
  left: 12px;
  right: 100px;
  z-index: 2;
  padding: 7px 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.72);
  color: #f8fafc;
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  width: max-content;
  max-width: calc(100% - 112px);
}

.lightbox-nav {
  position: absolute;
  top: calc(50% - 28px);
  transform: translateY(-50%);
  z-index: 2;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.28);
}

.lightbox-nav.prev {
  left: 10px;
}

.lightbox-nav.next {
  right: 10px;
}

.lightbox-nav[hidden] {
  display: none !important;
}

.lightbox-close {
  position: absolute;
  top: max(10px, env(safe-area-inset-top, 0px));
  right: 12px;
  z-index: 3;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  line-height: 0;
}

.lightbox-copy {
  position: absolute;
  top: max(10px, env(safe-area-inset-top, 0px));
  right: 56px;
  z-index: 3;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  line-height: 0;
}

.lightbox-copy[data-count]::after {
  content: attr(data-count);
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #3b82f6;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.lightbox-copy:active,
.lightbox-close:active {
  background: rgba(255, 255, 255, 0.28);
}

.lightbox-copy svg,
.lightbox-close svg {
  width: 18px;
  height: 18px;
  display: block;
}

.lightbox-filmstrip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
  padding: 10px 12px max(12px, env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, rgba(15, 23, 42, 0.72), rgba(15, 23, 42, 0.28) 70%, transparent);
}

.lightbox-film-all {
  flex: 0 0 auto;
  width: 36px;
  height: 56px;
  padding: 4px 2px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0;
  white-space: normal;
  text-align: center;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.lightbox-film-all.is-on {
  background: rgba(59, 130, 246, 0.9);
}

.lightbox-film-all:active {
  background: rgba(255, 255, 255, 0.28);
}

.lightbox-film-thumbs {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.lightbox-filmstrip[hidden] {
  display: none !important;
}

.lightbox-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.55);
  overflow: hidden;
  cursor: pointer;
  opacity: 0.72;
}

.lightbox-thumb-check {
  position: absolute;
  top: 3px;
  right: 3px;
  z-index: 1;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  background: rgba(15, 23, 42, 0.4);
  box-sizing: border-box;
  pointer-events: auto;
}

.lightbox-thumb.is-selected {
  opacity: 1;
  border-color: #93c5fd;
}

.lightbox-thumb.is-selected .lightbox-thumb-check {
  background: #3b82f6;
  border-color: #fff;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'><path d='M5 12.5l5 5 9-10'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px 12px;
}

.lightbox-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.lightbox-thumb:hover {
  opacity: 0.92;
}

.lightbox-thumb.active {
  border-color: #fff;
  opacity: 1;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.bubble a.msg-link {
  color: #2563eb;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
  cursor: pointer;
}

.msg.user .bubble a.msg-link {
  color: #1d4ed8;
}

.link-sheet {
  position: absolute;
  inset: 0;
  z-index: 32;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  pointer-events: none;
}

.link-sheet:not([hidden]) {
  display: flex;
  pointer-events: auto;
}

.link-sheet[hidden] {
  display: none !important;
  pointer-events: none !important;
}

.link-sheet-card {
  width: min(100%, 420px);
  background: #fff;
  border-radius: 16px;
  padding: 16px 16px 14px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.2);
  margin: 0;
}

.link-sheet-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.link-sheet-host {
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 6px;
}

.link-sheet-url {
  font-size: 12px;
  color: #64748b;
  word-break: break-all;
  line-height: 1.45;
  max-height: 4.5em;
  overflow: auto;
  margin-bottom: 14px;
}

.link-sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.link-sheet-btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  background: #fff;
  color: #334155;
  font-size: 14px;
  cursor: pointer;
}

.link-sheet-btn.primary {
  background: var(--btn-blue);
  border-color: var(--btn-blue);
  color: #fff;
  font-weight: 600;
}

.link-sheet-btn.ghost {
  border-color: transparent;
  background: #f8fafc;
}

.link-embed {
  position: absolute;
  inset: 0;
  z-index: 34;
  background: rgba(15, 23, 42, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  pointer-events: none;
}

.link-embed:not([hidden]) {
  display: flex;
  pointer-events: auto;
}

.link-embed[hidden] {
  display: none !important;
  pointer-events: none !important;
}

.link-embed-panel {
  width: 80%;
  height: 80%;
  max-width: 960px;
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.28);
}

.link-embed-bar {
  flex-shrink: 0;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 14px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.link-embed-host {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-embed-actions {
  display: flex;
  gap: 4px;
}

.link-embed-icon {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #64748b;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.link-embed-icon:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.link-embed-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
}

.link-embed-fallback {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  color: #64748b;
  font-size: 14px;
  text-align: center;
}

.link-embed-fallback[hidden] {
  display: none !important;
}

.link-embed-fallback .link-sheet-btn {
  min-width: 180px;
}

.app-hidden {
  display: none !important;
}

/* 启动遮罩：绝不拦截点击 */
.boot-splash {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #e8edf5 0%, #f3f5f8 100%);
  color: #64748b;
  font-size: 14px;
  pointer-events: none !important;
}

body.booting .boot-splash:not([hidden]) {
  display: flex;
}

.boot-splash[hidden] {
  display: none !important;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(180deg, #e8edf5 0%, #f3f5f8 100%);
}

.auth-gate.hidden {
  display: none !important;
  pointer-events: none !important;
}

/* 保证可点：覆盖任何残留 pointer-events:none */
#app,
#app button,
#app a,
#app textarea,
#app input,
#app .rail-btn,
#app .avatar,
#app .send-btn,
#app .round-tool,
#app .topbar-new,
#app .topbar-share {
  pointer-events: auto !important;
}

.auth-card {
  width: min(100%, 360px);
  background: #fff;
  border-radius: 20px;
  padding: 22px 20px 18px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
}

.auth-brand {
  text-align: center;
  margin-bottom: 16px;
}

.auth-brand .brand-icon {
  margin: 0 auto 10px;
}

.auth-brand h2 {
  margin: 0;
  font-size: 20px;
}

.auth-brand p {
  margin: 6px 0 0;
  color: #94a3b8;
  font-size: 13px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #475569;
}

.auth-field[hidden] {
  display: none !important;
}

.auth-field input {
  border: 1px solid #dbe3ee;
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
}

.auth-field input:focus {
  border-color: #93c5fd;
}

.auth-error {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
}

.auth-error[hidden] {
  display: none !important;
}

.auth-field.invalid input {
  border-color: #fca5a5;
  background: #fff7f7;
}

.auth-submit {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 12px;
  background: #5b4dff;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.auth-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.auth-tip {
  margin-top: 10px;
  text-align: center;
  font-size: 12px;
  color: #94a3b8;
}

.auth-alt {
  display: block;
  width: 100%;
  margin-top: 8px;
  border: none;
  background: none;
  color: #5b4dff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 0;
}

.auth-alt:hover {
  text-decoration: underline;
}

.guest-qa-bar {
  margin: 0 0 8px;
  padding: 7px 10px;
  border-radius: 10px;
  background: #eef2ff;
  color: #4338ca;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.guest-qa-bar[hidden] {
  display: none !important;
}

body.is-guest .key-box {
  display: none !important;
}

body:not(.is-admin) #guestPassesSection {
  display: none !important;
}

.voice-entry-btn {
  width: calc(100% - 0px);
  margin-top: 8px;
  border: 1px solid #d7dee8;
  background: #fff;
  color: #334155;
  border-radius: 10px;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 600;
  flex-shrink: 0;
}

.voice-entry-btn:hover {
  background: #f8fafc;
}

.voice-page {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.voice-page[hidden] {
  display: none;
}

.voice-page-bar {
  height: 52px;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 64px;
  align-items: center;
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
  background: rgba(243, 245, 248, 0.94);
}

.voice-page-back {
  border: none;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  padding: 8px;
}

.voice-page-bar-title {
  text-align: center;
  font-weight: 650;
}

.voice-page-bar-spacer {
  display: block;
}

.voice-page-records {
  border: none;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  text-align: right;
  padding: 8px;
}

.voice-page-records[hidden] {
  visibility: hidden;
  pointer-events: none;
}

.voice-page-body,
.voice-history-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

.voice-page-body {
  padding: 20px 16px calc(20px + var(--safe-bottom));
}

.voice-page-body[hidden] {
  display: none !important;
}

.voice-history-view {
  padding: 8px 16px calc(16px + var(--safe-bottom));
  align-items: stretch;
}

.voice-history-view[hidden] {
  display: none !important;
}

.voice-page-kicker {
  font-size: 12px;
  color: var(--muted);
}

.voice-persona {
  margin-top: 14px;
  display: flex;
  gap: 8px;
}

.voice-persona-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: #475569;
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 600;
  cursor: pointer;
}

.voice-persona-btn.active {
  border-color: #0f172a;
  background: #0f172a;
  color: #fff;
}

.voice-persona-custom {
  margin-top: 10px;
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  resize: vertical;
  min-height: 96px;
  background: #fff;
  color: var(--text);
}

.voice-persona-custom:focus {
  outline: none;
  border-color: #94a3b8;
}

.voice-timbre-label {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
}

.voice-timbre {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  max-width: 420px;
}

.voice-timbre-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: #475569;
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  min-width: 62px;
  line-height: 1.2;
}

.voice-timbre-btn small {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: #94a3b8;
  font-weight: 500;
}

.voice-timbre-btn.active {
  border-color: #0f172a;
  background: #0f172a;
  color: #fff;
}

.voice-timbre-btn.active small {
  color: #cbd5e1;
}

.voice-page-orb {
  margin-top: 28px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: #eef0ff;
  color: var(--accent);
  display: grid;
  place-items: center;
}

.voice-page.is-live .voice-page-orb {
  background: #fff1f1;
  color: #ef4444;
}

.voice-page.is-live .voice-page-kicker,
.voice-page.is-live .voice-persona,
.voice-page.is-live .voice-persona-custom,
.voice-page.is-live .voice-timbre-label,
.voice-page.is-live .voice-timbre,
.voice-page.is-live .voice-page-orb {
  display: none;
}

.voice-call-status {
  margin-top: 18px;
  min-height: 1.4em;
  color: #475569;
  font-size: 15px;
  flex-shrink: 0;
}

.voice-page.is-live .voice-call-status {
  margin-top: 0;
}

.voice-chat {
  margin-top: 14px;
  width: 100%;
  max-width: 520px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 2px 8px;
}

.voice-page:not(.is-live) .voice-chat:empty {
  display: none;
}

.voice-chat-history {
  margin-top: 0;
  max-width: none;
}

.voice-detail-meta {
  flex-shrink: 0;
  padding: 10px 4px 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}

.voice-detail-line {
  font-size: 13px;
  color: #64748b;
}

.voice-detail-prompt {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.voice-bubble {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 86%;
}

.voice-bubble-user {
  align-self: flex-end;
  align-items: flex-end;
}

.voice-bubble-assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.voice-bubble-label {
  font-size: 11px;
  color: #94a3b8;
  padding: 0 4px;
}

.voice-bubble-text {
  background: #fff;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.voice-bubble-user .voice-bubble-text {
  background: #eef4ff;
}

.voice-bubble.is-pending .voice-bubble-text {
  opacity: 0.88;
}

.voice-history-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}

.voice-hist-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.voice-hist-item:active {
  background: #f8fafc;
}

.voice-hist-main {
  flex: 1;
  min-width: 0;
}

.voice-hist-title {
  font-weight: 650;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.voice-hist-preview {
  margin-top: 4px;
  font-size: 13px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.voice-hist-meta {
  margin-top: 4px;
  font-size: 12px;
  color: #94a3b8;
}

.voice-hist-del {
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: #94a3b8;
  font-size: 18px;
  line-height: 1;
  padding: 6px 8px;
  cursor: pointer;
}

.voice-history-empty {
  margin: auto;
  color: #94a3b8;
  font-size: 14px;
  text-align: center;
  padding: 40px 16px;
}

.voice-call-start {
  margin-top: auto;
  width: min(100%, 280px);
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
  padding: 14px 18px;
  cursor: pointer;
}

.voice-rec-banner {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 650;
  color: #ef4444;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
}

.voice-rec-banner[hidden] {
  display: none;
}

.voice-rec-live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  animation: voice-rec-pulse 1s ease-in-out infinite;
}

@keyframes voice-rec-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.voice-call-hang-wrap {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.voice-call-hang-wrap[hidden] {
  display: none;
}

.voice-call-actions {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 44px;
}

.voice-call-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.voice-call-rec {
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 50%;
  background: #0f172a;
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.voice-call-rec-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ef4444;
  display: block;
}

.voice-call-rec.is-on {
  background: #ef4444;
}

.voice-call-rec.is-on .voice-call-rec-dot {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: #fff;
}

.voice-call-hang {
  width: 72px;
  height: 72px;
  border: 0;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 18px rgba(239, 68, 68, 0.28);
}

.voice-call-hang svg {
  display: block;
}

.voice-call-hang-label {
  font-size: 13px;
  font-weight: 650;
  color: #64748b;
}

.voice-call-hang:active,
.voice-call-start:active,
.voice-call-rec:active {
  transform: scale(0.97);
}

.voice-detail-rec {
  margin-top: 12px;
}

.voice-detail-rec audio,
.voice-detail-rec video {
  width: 100%;
  margin-top: 6px;
}

.voice-detail-rec-btn {
  margin-top: 8px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.voice-hist-rec {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 650;
  color: #ef4444;
}

.voice-rec-canvas {
  position: fixed;
  left: 0;
  top: 0;
  width: 2px;
  height: 2px;
  opacity: 1;
  pointer-events: none;
  z-index: 0;
}

.voice-rec-canvas:not(.is-live) {
  display: none;
}

.rail-btn.voice-live {
  background: #fff;
  color: #ef4444;
}

body.is-guest #btnOpenVoicePage,
body.is-guest #btnRailVoice {
  display: none !important;
}
