:root {
  color-scheme: light dark;
  --brand: #4d6bfe;
  --brand-soft: #eef1ff;
  --bg: #ffffff;
  --surface: #f6f7f9;
  --surface-2: #eef0f4;
  --text: #16181d;
  --text-dim: #6a7280;
  --text-faint: #9aa1ad;
  --border: #e6e8ee;
  --bubble: #eef1ff;
  --code-bg: #f5f6f8;
  --code-bar: #eceef2;
  --shadow: 0 8px 30px rgb(16 18 27 / 12%);
  --radius: 16px;
  --topbar: 52px;
  --vvh: 100dvh;
  --vv-top: 0px;
  --tok-kw: #a626a4;
  --tok-str: #50a14f;
  --tok-com: #9aa1ad;
  --tok-num: #b76b01;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #8fa4ff;
    --brand-soft: #242a44;
    --bg: #17181a;
    --surface: #1f2124;
    --surface-2: #2a2d32;
    --text: #eceef2;
    --text-dim: #a3a9b4;
    --text-faint: #7c828d;
    --border: #2b2e34;
    --bubble: #263049;
    --code-bg: #111214;
    --code-bar: #1c1e22;
    --shadow: 0 10px 34px rgb(0 0 0 / 45%);
    --tok-kw: #c678dd;
    --tok-str: #98c379;
    --tok-com: #7f848e;
    --tok-num: #d19a66;
  }
}

/* 手动指定主题时覆盖系统设置 */
:root[data-theme="dark"] {
  color-scheme: dark;
  --brand: #8fa4ff;
  --brand-soft: #242a44;
  --bg: #17181a;
  --surface: #1f2124;
  --surface-2: #2a2d32;
  --text: #eceef2;
  --text-dim: #a3a9b4;
  --text-faint: #7c828d;
  --border: #2b2e34;
  --bubble: #263049;
  --code-bg: #111214;
  --code-bar: #1c1e22;
  --shadow: 0 10px 34px rgb(0 0 0 / 45%);
  --tok-kw: #c678dd;
  --tok-str: #98c379;
  --tok-com: #7f848e;
  --tok-num: #d19a66;
}

:root[data-theme="light"] {
  color-scheme: light;
  --brand: #4d6bfe;
  --brand-soft: #eef1ff;
  --bg: #ffffff;
  --surface: #f6f7f9;
  --surface-2: #eef0f4;
  --text: #16181d;
  --text-dim: #6a7280;
  --text-faint: #9aa1ad;
  --border: #e6e8ee;
  --bubble: #eef1ff;
  --code-bg: #f5f6f8;
  --code-bar: #eceef2;
  --shadow: 0 8px 30px rgb(16 18 27 / 12%);
  --tok-kw: #a626a4;
  --tok-str: #50a14f;
  --tok-com: #9aa1ad;
  --tok-num: #b76b01;
}

/* 字号档位 */
:root {
  --chat-font: 16px;
}
:root[data-font="small"] {
  --chat-font: 14.5px;
}
:root[data-font="large"] {
  --chat-font: 18px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* 作者样式的 display 会盖掉 UA 的 [hidden]，这里统一兜住 */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

/* ---------------------------------------------------------------- 骨架 */

.app {
  position: fixed;
  left: 0;
  width: 100%;
  top: var(--vv-top);
  height: var(--vvh);
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.topbar {
  flex: 0 0 auto;
  height: var(--topbar);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  padding-top: env(safe-area-inset-top, 0px);
  border-bottom: 0.5px solid transparent;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  position: relative;
  z-index: 5;
}

.topbar.is-scrolled {
  border-bottom-color: var(--border);
}

.topbar__title {
  flex: 1 1 auto;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 4px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.icon-btn:active {
  background: var(--surface-2);
}

/* ---------------------------------------------------------------- 列表 */

.scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.scroll::-webkit-scrollbar {
  display: none;
}

.messages {
  max-width: 780px;
  margin: 0 auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.msg {
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: msg-in 0.18s ease-out;
}

@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

.msg--user {
  align-items: flex-end;
}

.msg--user .msg__body {
  max-width: 86%;
  background: var(--bubble);
  border-radius: 18px 18px 4px 18px;
  padding: 9px 14px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: var(--chat-font);
  line-height: 1.55;
}

.msg--assistant .msg__body {
  max-width: 100%;
  font-size: var(--chat-font);
  line-height: 1.72;
  word-break: break-word;
}

.msg__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-faint);
  font-size: 12px;
  padding: 0 2px;
}

.msg__action {
  border: 0;
  background: transparent;
  color: var(--text-faint);
  font-size: 12px;
  padding: 2px 4px;
  cursor: pointer;
  border-radius: 6px;
}

.msg__action:active {
  background: var(--surface-2);
}

/* ---------------------------------------------------------- 正文排版 */

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

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

.prose p {
  margin: 0 0 12px;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
  margin: 20px 0 8px;
  line-height: 1.35;
  font-weight: 650;
}

.prose h1 {
  font-size: 21px;
}
.prose h2 {
  font-size: 19px;
}
.prose h3 {
  font-size: 17px;
}
.prose h4,
.prose h5,
.prose h6 {
  font-size: 16px;
}

.prose ul,
.prose ol {
  margin: 0 0 12px;
  padding-left: 22px;
}

.prose li {
  margin: 3px 0;
}

.prose li > p {
  margin: 0;
}

.prose a {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

.prose blockquote {
  margin: 0 0 12px;
  padding: 2px 0 2px 12px;
  border-left: 3px solid var(--border);
  color: var(--text-dim);
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}

.prose code {
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 13.5px;
  background: var(--code-bg);
  border: 0.5px solid var(--border);
  border-radius: 6px;
  padding: 1px 5px;
  word-break: break-word;
}

.prose .md-code {
  margin: 0 0 14px;
  border-radius: 12px;
  overflow: hidden;
  border: 0.5px solid var(--border);
  background: var(--code-bg);
}

.prose .md-code__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 6px 12px;
  background: var(--code-bar);
  font-size: 12px;
  color: var(--text-dim);
}

.prose .md-code__copy {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.prose .md-code__copy:active {
  background: var(--surface-2);
}

.prose .md-code pre {
  margin: 0;
  padding: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.prose .md-code code {
  background: none;
  border: 0;
  padding: 0;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre;
}

.prose .md-table {
  overflow-x: auto;
  margin: 0 0 14px;
  -webkit-overflow-scrolling: touch;
}

.prose table {
  border-collapse: collapse;
  font-size: 14px;
  min-width: 100%;
}

.prose th,
.prose td {
  border: 0.5px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}

.prose th {
  background: var(--surface);
  font-weight: 600;
}

/* 思考过程 */

.reasoning {
  margin: 0 0 10px;
  border: 0.5px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}

.reasoning summary {
  cursor: pointer;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-dim);
  list-style: none;
}

.reasoning summary::-webkit-details-marker {
  display: none;
}

.reasoning__body {
  padding: 0 12px 10px;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow-y: auto;
}

/* 状态 */

.thinking {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  color: var(--text-dim);
  font-size: 14px;
  padding: 4px 0;
}

.thinking i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  animation: blink 1.2s infinite;
}

.thinking i:nth-child(2) {
  animation-delay: 0.2s;
}
.thinking i:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
  }
  40% {
    opacity: 1;
  }
}

.error-box {
  border: 0.5px solid color-mix(in srgb, #d94b4b 45%, var(--border));
  background: color-mix(in srgb, #d94b4b 8%, var(--bg));
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
}

/* 空状态 */

.empty {
  max-width: 780px;
  margin: 0 auto;
  padding: 18vh 24px 0;
  text-align: center;
}

.empty[hidden] {
  display: none;
}

.empty__logo {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(92deg, var(--brand), color-mix(in srgb, var(--brand) 55%, #22c1a8));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.empty__avatar-wrap {
  display: block;
  width: 96px;
  height: 96px;
  margin: 0 auto 18px;
  border-radius: 50%;
  cursor: pointer;
}

.empty__avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  background: transparent;
  border: 0;
}

.file-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
}

/* 真正的 <input type=file> 铺满按钮、透明：点哪都是原生点击，iOS 上最稳 */
.file-btn__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.attach-btn {
  position: relative;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--text-dim);
  cursor: pointer;
}

.attach-btn:active {
  background: var(--surface-2);
}

.attach-btn.is-busy {
  animation: busy-pulse 1s ease-in-out infinite;
}

@keyframes busy-pulse {
  50% {
    opacity: 0.35;
  }
}

.attach-btn[aria-pressed='true'] {
  color: #fff;
  background: var(--brand);
}

.attach-btn[aria-pressed='true'] svg {
  stroke: #fff;
}

.msg__sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  max-width: 100%;
}

.msg__sources a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 4px 9px;
  border: 0.5px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-dim);
  font-size: 12px;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg__sources .src-label {
  font-size: 12px;
  color: var(--text-faint);
  width: 100%;
  margin-bottom: 2px;
}

.attach-btn svg {
  width: 20px;
  height: 20px;
}

.attach-btn__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.model-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 30px;
  padding: 0 8px 0 11px;
  border: 0.5px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  max-width: 116px;
  white-space: nowrap;
  flex-wrap: nowrap;
}

.model-pill:active {
  background: var(--surface-2);
}

.model-pill span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-pill svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

/* 模型列表 */
.model-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.model-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: 0.5px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.model-item.is-active {
  border-color: color-mix(in srgb, var(--brand) 55%, var(--border));
  background: color-mix(in srgb, var(--brand) 8%, var(--bg));
}

.model-item__main {
  flex: 1 1 auto;
  min-width: 0;
}

.model-item__name {
  font-size: 14.5px;
  font-weight: 550;
}

.model-item__hint {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 2px;
}

.model-item__check {
  flex: 0 0 auto;
  color: var(--brand);
  font-size: 15px;
}

/* 待发送的附件 */
.pending {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 14px 8px;
  max-width: 780px;
  margin: 0 auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.pending::-webkit-scrollbar {
  display: none;
}

.pending[hidden] {
  display: none;
}

.chip {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 220px;
  padding: 6px 26px 6px 8px;
  border: 0.5px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-size: 12.5px;
  color: var(--text-dim);
}

.chip img {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  object-fit: cover;
  flex: 0 0 auto;
}

.chip__icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  font-size: 11px;
  flex: 0 0 auto;
}

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

.chip__status {
  font-size: 11px;
  color: var(--text-faint);
}

.chip--error {
  border-color: color-mix(in srgb, #d94b4b 45%, var(--border));
}

.chip__remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
}

/* 消息里的附件 */
.msg__files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.msg__file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 12px;
  color: var(--text-dim);
  max-width: 100%;
}

.msg__file span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg__file img {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: cover;
}

.avatar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar-row__pick {
  flex: 0 0 auto;
  display: block;
  cursor: pointer;
}

.avatar-row__preview {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  background: transparent;
}

.avatar-row .ghost-btn {
  flex: 1 1 0;
  padding: 9px 10px;
  font-size: 13.5px;
}

.empty__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 26px;
}

.empty__chips button {
  border: 0.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13.5px;
  cursor: pointer;
}

.empty__chips button:active {
  background: var(--surface-2);
}

.jump-bottom {
  position: absolute;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0.5px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  box-shadow: 0 6px 18px rgb(16 18 27 / 14%);
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 6;
}

.jump-bottom[hidden] {
  display: none;
}

.jump-bottom svg {
  width: 18px;
  height: 18px;
}

/* 公式 */
.math {
  font-family: 'Times New Roman', Cambria, 'Songti SC', serif;
  font-style: italic;
  white-space: nowrap;
}

.math-block {
  display: block;
  text-align: center;
  margin: 8px 0 14px;
  overflow-x: auto;
}

.math sup,
.math sub {
  font-size: 0.7em;
  font-style: italic;
}

.math-frac {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  text-align: center;
  font-size: 0.95em;
  line-height: 1.15;
  margin: 0 0.15em;
}

.math-num {
  border-bottom: 1px solid currentColor;
  padding: 0 0.22em 0.05em;
}

.math-den {
  padding: 0.05em 0.22em 0;
}

.math-sqrt {
  border-top: 1px solid currentColor;
  padding-left: 0.12em;
}

.math-sqrt::before {
  content: '√';
  margin-right: 0.06em;
  font-style: normal;
}

.math-text {
  font-style: normal;
  font-family: inherit;
}

/* 语义高亮 */
.tok-kw {
  color: var(--tok-kw);
}
.tok-str {
  color: var(--tok-str);
}
.tok-com {
  color: var(--tok-com);
  font-style: italic;
}
.tok-num {
  color: var(--tok-num);
}

/* 分段控件 */
.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 0.5px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  margin-bottom: 8px;
}

.segmented button {
  flex: 1 1 0;
  border: 0;
  background: transparent;
  border-radius: 9px;
  padding: 8px 6px;
  font-size: 13.5px;
  color: var(--text-dim);
  cursor: pointer;
}

.segmented button.is-active {
  background: var(--bg);
  color: var(--text);
  font-weight: 550;
  box-shadow: 0 1px 3px rgb(16 18 27 / 10%);
}

/* 抽屉搜索 */
.drawer__search {
  margin: 0 12px 8px;
  padding: 8px 12px;
  border: 0.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  font-size: 15px;
  outline: 0;
}

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

.composer {
  flex: 0 0 auto;
  padding: 6px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
}

.composer__box {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 6px 6px 6px 14px;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 24px;
  transition: border-color 0.15s;
}

.composer__box:focus-within {
  border-color: color-mix(in srgb, var(--brand) 55%, var(--border));
}

.composer textarea {
  flex: 1 1 auto;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  font-size: 16px;
  line-height: 1.5;
  padding: 8px 0;
  max-height: 148px;
  min-height: 24px;
  color: var(--text);
}

.composer textarea::placeholder {
  color: var(--text-faint);
}

.send-btn {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.12s;
}

.send-btn:disabled {
  opacity: 0.32;
}

.send-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.send-btn svg {
  width: 19px;
  height: 19px;
  stroke-width: 2.3;
}

.send-btn--stop {
  background: var(--surface-2);
  color: var(--text);
}

.send-btn--stop svg {
  fill: currentColor;
  stroke: none;
}

.composer__hint {
  max-width: 780px;
  margin: 6px auto 0;
  text-align: center;
  font-size: 11px;
  color: var(--text-faint);
}

/* ------------------------------------------------------------ 抽屉/弹层 */

.scrim {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 38%);
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 20;
}

.scrim.is-open {
  opacity: 1;
}

.scrim[hidden] {
  display: none;
}

.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(84vw, 320px);
  background: var(--surface);
  z-index: 21;
  display: flex;
  flex-direction: column;
  transform: translateX(-102%);
  transition: transform 0.24s cubic-bezier(0.32, 0.72, 0, 1);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: var(--shadow);
}

.drawer.is-open {
  transform: translateX(0);
}

.drawer__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 18px;
  font-weight: 650;
  font-size: 15px;
}

.drawer__head > span {
  flex: 1 1 auto;
}

.drawer__avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: transparent;
}

.drawer__new {
  margin: 4px 12px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 12px;
  border: 0.5px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  font-size: 15px;
  cursor: pointer;
}

.drawer__new svg {
  width: 18px;
  height: 18px;
}

.drawer__list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0 8px;
}

.conv {
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 10px;
  margin-bottom: 2px;
}

.conv.is-active {
  background: var(--surface-2);
}

.conv__main {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 11px 10px;
  cursor: pointer;
}

.conv__title {
  font-size: 14.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv__time {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 2px;
}

.conv__del {
  border: 0;
  background: transparent;
  color: var(--text-faint);
  padding: 8px;
  cursor: pointer;
  border-radius: 8px;
  display: grid;
  place-items: center;
}

.conv__del svg {
  width: 16px;
  height: 16px;
}

.drawer__settings {
  margin: 8px 12px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 12px;
  border: 0.5px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  font-size: 14.5px;
  cursor: pointer;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 88vh;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow);
  z-index: 22;
  transform: translateY(101%);
  transition: transform 0.26s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.sheet.is-open {
  transform: translateY(0);
}

.sheet__grab {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 8px auto 0;
}

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 6px 18px;
  font-weight: 650;
  font-size: 15px;
}

.sheet__body {
  overflow-y: auto;
  padding: 4px 18px 22px;
  -webkit-overflow-scrolling: touch;
}

.field {
  display: block;
  margin-bottom: 18px;
}

.field__label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.field__row {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 0.5px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding-right: 4px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 0.5px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 11px 12px;
  font-size: 16px;
  outline: 0;
  -webkit-appearance: none;
  appearance: none;
}

.field__row input {
  border: 0;
  background: transparent;
}

.field textarea {
  resize: vertical;
  line-height: 1.55;
}

.field select {
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.field__eye {
  border: 0;
  background: transparent;
  color: var(--brand);
  font-size: 13px;
  padding: 8px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.field__hint {
  display: block;
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 6px;
  line-height: 1.55;
}

.advanced {
  margin-bottom: 18px;
}

.advanced summary {
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 0 10px;
  list-style: none;
}

.advanced summary::-webkit-details-marker {
  display: none;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

label.ghost-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-align: center;
}

.ghost-btn {
  flex: 1 1 auto;
  border: 0.5px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

.ghost-btn:active {
  background: var(--surface-2);
}

.ghost-btn--danger {
  color: #d94b4b;
}

.ghost-btn--mini {
  flex: 0 0 auto;
  margin-top: 8px;
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 10px;
  color: var(--brand);
}

.ghost-btn:disabled {
  opacity: 0.5;
}

.sheet__note {
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.7;
  margin: 18px 0 0;
}

.toast {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  transform: translate(-50%, -8px);
  background: color-mix(in srgb, var(--text) 88%, transparent);
  color: var(--bg);
  padding: 9px 15px;
  border-radius: 999px;
  font-size: 13.5px;
  z-index: 40;
  opacity: 0;
  transition: opacity 0.18s, transform 0.18s;
  pointer-events: none;
  max-width: 88vw;
  text-align: center;
}

.toast.is-open {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast[hidden] {
  display: none;
}

/* 头像裁剪 */

.crop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: #0b0d11;
  display: flex;
  flex-direction: column;
  padding-top: calc(env(safe-area-inset-top, 0px) + 4px);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
}

.crop__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  color: #eef1f6;
}

.crop__title {
  font-size: 15px;
  font-weight: 600;
}

.crop__btn {
  border: 0;
  background: transparent;
  color: #c8cfdd;
  font-size: 15px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
}

.crop__btn:active {
  background: rgb(255 255 255 / 10%);
}

.crop__btn--primary {
  color: #9db0ff;
  font-weight: 650;
}

.crop__viewport {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.crop__stage {
  position: relative;
  width: min(86vw, 360px);
  aspect-ratio: 1 / 1;
  touch-action: none;
}

.crop__stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.crop__dim {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px rgb(255 255 255 / 88%), 0 0 0 9999px rgb(0 0 0 / 62%);
  pointer-events: none;
}

.crop__foot {
  padding: 6px 26px 0;
}

.crop__zoom {
  width: 100%;
  accent-color: #9db0ff;
}

.crop__hint {
  margin: 8px 0 0;
  text-align: center;
  color: #8b93a5;
  font-size: 12.5px;
}

/* 诊断弹窗 */

.diag {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgb(0 0 0 / 45%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.diag[hidden] {
  display: none;
}

.diag__card {
  width: 100%;
  max-width: 460px;
  max-height: 82vh;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 18px;
  padding: 20px 18px 16px;
  box-shadow: var(--shadow);
}

.diag__card h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.diag__card p {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-dim);
}

.diag__card pre {
  margin: 0 0 14px;
  padding: 10px 12px;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.diag__actions {
  display: flex;
  gap: 8px;
}

.diag__actions label.ghost-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-align: center;
}

.ghost-btn {
  flex: 1 1 auto;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

@media (min-width: 720px) {
  .messages,
  .composer__box {
    padding-left: 28px;
    padding-right: 28px;
  }
  .composer__box {
    padding-left: 20px;
  }
}
