/* =============================================================================
   app.css — DeepSeek 风格 · 手机端优先聊天站（零依赖、零外链字体）
   -----------------------------------------------------------------------------
   约定：
   1) 所有颜色只走 CSS 自定义属性，切换主题靠 :root[data-theme="dark"]。
      默认（没有 data-theme 属性时）跟随 prefers-color-scheme。
      JS 只在两处写 data-theme：显式选浅色 → "light"；显式选深色 → "dark"；
      "跟随系统" 时**不写属性**，这样系统切换主题能实时生效（无需 JS 监听）。
   2) 布局用 flex 列（顶栏 / 滚动区 / 输入区），不用 position:fixed 铺三个 fixed 层 ——
      iOS 键盘弹出时 fixed 层容易和可视区错位。
   3) 全部尺寸按手机优先写，>768px 只做"居中限宽"，不变成两栏。
   ========================================================================== */

/* ---------- 1. 主题变量 ---------- */
:root {
  /* 品牌与语义色（浅色模式） */
  --brand: #4D6BFE;            /* DeepSeek 蓝 */
  --brand-strong: #3B57E8;     /* 按下 / hover */
  --brand-rgb: 77, 107, 254;   /* 用于 rgba() 半透明，避免 color-mix 兼容问题 */

  --bg: #FFFFFF;               /* 页面底色 */
  --bg-soft: #F9FAFB;          /* 浅灰分区（思考面板、代码块标题） */
  --fg: #1B1B1F;               /* 主文字 */
  --fg-2: #4A4A55;             /* 次级文字 */
  --muted: #8A8F9C;            /* 弱化文字（思考正文、占位符） */
  --bubble: #EFF3FF;           /* 用户气泡底色（浅蓝） */
  --bubble-fg: #1B2A5B;        /* 用户气泡文字（深蓝） */
  --input-bg: #F4F5F7;         /* 输入药丸底色 */
  --border: #ECECF1;           /* 描边 / 分隔线 */
  --drawer-bg: #FFFFFF;        /* 历史抽屉底色 */
  --mask: rgba(17, 20, 45, .38);
  --danger: #E5484D;
  --danger-bg: rgba(229, 72, 77, .09);

  /* 代码块：浅色模式下也保持深色底（对齐 DeepSeek App） */
  --code-bg: #1E1E24;
  --code-head: rgba(255, 255, 255, .06);
  --code-fg: #E8E8F0;
  --code-dim: rgba(255, 255, 255, .55);

  --shadow: 0 6px 24px rgba(17, 20, 45, .10);

  /* 字体：不引外链字体，走系统字体栈（中文优先 PingFang / 鸿蒙 / 微软雅黑） */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "HarmonyOS Sans SC", "Hiragino Sans GB", "Microsoft YaHei",
          "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --math-font: "Cambria Math", "STIX Two Math", "Latin Modern Math", Cambria,
               Georgia, "Times New Roman", serif;

  --topbar-h: 54px;
  --col-max: 720px;            /* 桌面端正文列最大宽度 */
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --radius-pill: 24px;
}

/* 跟随系统深色：只有"没有显式选浅色"时才生效 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1B1B1F;
    --bg-soft: #202027;
    --fg: #ECECF1;
    --fg-2: #C7C9D3;
    --muted: #9A9AA5;
    --bubble: #2F3A5C;
    --bubble-fg: #E8ECFF;
    --input-bg: #2A2A30;
    --border: #33333B;
    --drawer-bg: #202024;
    --mask: rgba(0, 0, 0, .58);
    --danger: #FF6B6F;
    --danger-bg: rgba(255, 107, 111, .12);
    --code-bg: #151519;
    --shadow: 0 6px 24px rgba(0, 0, 0, .45);
  }
}

/* 显式选深色 */
:root[data-theme="dark"] {
  --bg: #1B1B1F;
  --bg-soft: #202027;
  --fg: #ECECF1;
  --fg-2: #C7C9D3;
  --muted: #9A9AA5;
  --bubble: #2F3A5C;
  --bubble-fg: #E8ECFF;
  --input-bg: #2A2A30;
  --border: #33333B;
  --drawer-bg: #202024;
  --mask: rgba(0, 0, 0, .58);
  --danger: #FF6B6F;
  --danger-bg: rgba(255, 107, 111, .12);
  --code-bg: #151519;
  --shadow: 0 6px 24px rgba(0, 0, 0, .45);
}

/* ---------- 2. 基础 ---------- */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  overflow: hidden;                 /* 只让消息区滚动，避免整页被键盘顶动 */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

button { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ---------- 3. 页面骨架 ---------- */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;             /* 移动端动态视口，键盘弹出时不会被截断 */
  width: 100%;
  overflow: hidden;
}

/* ---------- 4. 顶部栏 ---------- */
.topbar {
  flex: none;
  height: calc(var(--topbar-h) + var(--safe-t));
  padding-top: var(--safe-t);
  display: flex;
  align-items: center;
  gap: 2px;
  padding-left: 6px;
  padding-right: 6px;
  background: var(--bg);
  position: relative;
  z-index: 10;
}

.icon-btn {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  transition: background .15s ease;
}
.icon-btn:active { background: rgba(var(--brand-rgb), .10); }
@media (hover: hover) {
  .icon-btn:hover { background: rgba(var(--brand-rgb), .08); }
}

.topbar-title {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 4px;
}

/* ---------- 5. 消息滚动区 ---------- */
.messages {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.msg-list {
  max-width: var(--col-max);
  margin: 0 auto;
  padding: 14px 16px 28px;
}

/* ---------- 6. 空状态 ---------- */
.empty {
  max-width: var(--col-max);
  margin: 0 auto;
  padding: clamp(40px, 13vh, 150px) 22px 24px;
  text-align: center;
}
.empty[hidden] { display: none; }

.empty-logo {
  width: 66px;
  height: 66px;
  margin: 0 auto 18px;
  display: block;
}

.empty-title {
  margin: 0 0 26px;
  font-size: 21px;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: .2px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 460px;
  margin: 0 auto;
}

.chip {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg-2);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 14px;
  line-height: 1.3;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.chip:active {
  background: rgba(var(--brand-rgb), .10);
  border-color: rgba(var(--brand-rgb), .45);
  color: var(--brand);
}
@media (hover: hover) {
  .chip:hover {
    background: rgba(var(--brand-rgb), .07);
    border-color: rgba(var(--brand-rgb), .40);
    color: var(--brand);
  }
}

/* ---------- 7. 消息 ---------- */
.msg { margin-bottom: 22px; }
.msg:last-child { margin-bottom: 4px; }

/* 用户：右对齐浅蓝气泡 */
.msg-user { display: flex; justify-content: flex-end; }

.bubble {
  max-width: 85%;
  background: var(--bubble);
  color: var(--bubble-fg);
  border-radius: 18px;
  padding: 10px 14px;
  font-size: 16px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* 助手：左对齐、无气泡无背景 */
.msg-ai { display: block; }

/* ---------- 8. 思考面板（关键还原点） ---------- */
.reason {
  margin: 0 0 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-soft);
  overflow: hidden;
}

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

.reason-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}
.reason[data-live="true"] .reason-dot {
  background: var(--brand);
  animation: ds-pulse 1.1s ease-in-out infinite;
}

.reason-title { flex: none; }
.reason-time { flex: none; font-variant-numeric: tabular-nums; }

.reason-chev {
  flex: none;
  margin-left: auto;
  transition: transform .2s ease;
  opacity: .8;
}
.reason[data-open="true"] .reason-chev { transform: rotate(180deg); }

.reason-body { padding: 0 12px 11px; }
.reason[data-open="false"] .reason-body { display: none; }

.reason-text {
  margin: 0;
  padding-left: 10px;
  border-left: 2px solid var(--border);   /* 左侧 2px 竖线 */
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 320px;
  overflow-y: auto;
}

@keyframes ds-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .35; transform: scale(.72); }
}

/* ---------- 9. 正文 Markdown ---------- */
.md {
  font-size: 16px;
  line-height: 1.75;          /* 助手正文行高 1.75 */
  color: var(--fg);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.md-b > :first-child { margin-top: 0; }
.md-b > :last-child { margin-bottom: 0; }
.md-b + .md-b { margin-top: 14px; }

.md-h { margin: 0 0 8px; font-size: 1.12em; font-weight: 600; line-height: 1.4; }
.md-p { margin: 0; }
.md-hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }

.md-list { margin: 0; padding-left: 1.35em; }
.md-list li { margin: 3px 0; }
.md-list li > .md-list { margin: 3px 0; }
.md-task { list-style: none; margin-left: -1.2em !important; }
.md-task input { margin-right: .4em; vertical-align: -1px; }

.md-quote {
  margin: 0;
  padding: 2px 0 2px 12px;
  border-left: 3px solid var(--border);
  color: var(--fg-2);
}

.md-link { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }
.md-link:active { opacity: .7; }

.md-code-inline {
  font-family: var(--mono);
  font-size: .88em;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: .5px 4px;
  overflow-wrap: anywhere;
}

.md-del { opacity: .7; }

/* 代码块：浅色模式下也是深色底 */
.md-code {
  margin: 12px 0;
  border-radius: 12px;
  background: var(--code-bg);
  overflow: hidden;
}
.md-code-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  background: var(--code-head);
  color: var(--code-dim);
  font-size: 12px;
  font-family: var(--mono);
}
.md-code-lang { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md-copy {
  flex: none;
  border: 0;
  border-radius: 7px;
  background: rgba(255, 255, 255, .09);
  color: var(--code-dim);
  font-size: 12px;
  font-family: var(--font);
  padding: 3px 9px;
  cursor: pointer;
}
.md-copy:active { background: rgba(255, 255, 255, .18); }
.md-code pre {
  margin: 0;
  padding: 10px 13px 13px;
  overflow-x: auto;                /* 长代码横向滚动 */
  -webkit-overflow-scrolling: touch;
}
.md-code code {
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--code-fg);
  white-space: pre;
  tab-size: 2;
}

/* 表格 */
.md-table-wrap { margin: 12px 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.md-table { border-collapse: collapse; font-size: 14.5px; min-width: 60%; }
.md-table th, .md-table td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}
.md-table th { background: var(--bg-soft); font-weight: 600; }

/* ---------- 10. 数学公式（轻量渲染，见 markdown.js） ---------- */
.md-math {
  display: block;
  margin: 14px 0;
  padding: 2px 0;
  text-align: center;
  font-size: 1.08em;
  line-height: 2.1;
  font-family: var(--math-font);
  overflow-x: auto;
  overflow-y: hidden;
}
.md-math-i { font-family: var(--math-font); font-size: 1.02em; }

.md sup, .md sub { font-size: .72em; line-height: 0; }

.md-frac {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  text-align: center;
  margin: 0 .16em;
  line-height: 1.18;
  font-size: .95em;
}
.md-frac-n { border-bottom: 1px solid currentColor; padding: 0 .3em; }
.md-frac-d { padding: 0 .3em; }

.md-sqrt-wrap { white-space: nowrap; }
.md-sqrt {
  border-top: 1px solid currentColor;
  padding: 0 .12em 0 .08em;
  margin-left: .04em;
}
.md-sqrt-idx { font-size: .6em; margin-right: -.1em; }

.md-moverline { text-decoration: overline; }

/* 不支持的 LaTeX 命令：原样显示，等宽包起来，绝不吞掉 */
.md-mraw {
  font-family: var(--mono);
  font-size: .9em;
  background: rgba(127, 127, 127, .16);
  border-radius: 4px;
  padding: 0 .22em;
  overflow-wrap: anywhere;
}

/* ---------- 11. 流式光标 / 错误条 / 操作条 ---------- */
.cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -2px;
  background: var(--brand);
  animation: ds-blink .9s steps(1, end) infinite;
}

@keyframes ds-blink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: .05; }
}

.err {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 13.5px;
  line-height: 1.5;
}

.notice {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.acts {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.act {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 8px;
  cursor: pointer;
}
.act:active { background: var(--bg-soft); color: var(--fg-2); }
@media (hover: hover) {
  .act:hover { background: var(--bg-soft); color: var(--fg-2); }
}

/* ---------- 12. 输入区 ---------- */
.composer {
  flex: none;
  background: var(--bg);
  padding: 4px 12px calc(8px + var(--safe-b));
}

.composer-inner {
  max-width: var(--col-max);
  margin: 0 auto;
}

.switches {
  display: flex;
  gap: 8px;
  padding: 0 4px 8px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  line-height: 1.3;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.switch svg { flex: none; }
.switch[data-on="true"] {
  color: var(--brand);
  border-color: rgba(var(--brand-rgb), .45);
  background: rgba(var(--brand-rgb), .10);
}
.switch[data-disabled="true"] { opacity: .6; }

.pill {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  min-height: 48px;
  padding: 5px 5px 5px 6px;
  border-radius: var(--radius-pill);
  background: var(--input-bg);
}

.pill-plus {
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--fg-2);
  cursor: pointer;
}
.pill-plus:active { background: rgba(127, 127, 127, .16); }

#input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--fg);
  /* 16px 是硬性下限：小于 16px 时 iOS Safari 聚焦会自动放大页面 */
  font-size: 16px;
  font-family: inherit;
  line-height: 22px;
  padding: 8px 2px;
  margin: 0;
  max-height: 126px;         /* 5 行 × 22px + 上下 padding，超过则内部滚动（JS 会用 scrollHeight 精确同步） */
  overflow-y: hidden;
}
#input::placeholder { color: var(--muted); }

.send-btn {
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--border);
  color: var(--muted);
  cursor: default;
  transition: background .15s ease, color .15s ease;
}
.send-btn.is-ready {
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}
.send-btn.is-ready:active { background: var(--brand-strong); }
.send-btn.is-stop {
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}
.send-btn.is-stop:active { background: var(--brand-strong); }

.disclaimer {
  margin: 7px 0 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
}

/* ---------- 13. 历史抽屉 ---------- */
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(84vw, 320px);
  display: flex;
  flex-direction: column;
  background: var(--drawer-bg);
  transform: translateX(-100%);
  transition: transform .25s cubic-bezier(.4, 0, .2, 1);
  z-index: 60;
  will-change: transform;
  box-shadow: var(--shadow);
}
.drawer.is-open { transform: translateX(0); }

.drawer-head {
  flex: none;
  padding: calc(10px + var(--safe-t)) 12px 10px;
}

.new-chat {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--fg);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
}
.new-chat:active { background: rgba(var(--brand-rgb), .10); }

.conv-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 2px 8px 10px;
  -webkit-overflow-scrolling: touch;
}

.conv-empty {
  padding: 32px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

.conv {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: 10px;
  margin-bottom: 2px;
}
.conv.is-active { background: rgba(var(--brand-rgb), .10); }

.conv-open {
  flex: 1 1 auto;
  min-width: 0;
  display: block;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--fg-2);
  font-size: 14.5px;
  padding: 11px 34px 11px 11px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv.is-active .conv-open { color: var(--brand); font-weight: 500; }

.conv-del {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  transition: opacity .15s ease;
}
.conv.reveal .conv-del,
.conv.is-active.reveal .conv-del { opacity: 1; pointer-events: auto; }
.conv-del:active { color: var(--danger); }

/* 桌面端：悬停直接出现删除按钮 */
@media (hover: hover) {
  .conv:hover { background: var(--bg-soft); }
  .conv:hover .conv-del { opacity: 1; pointer-events: auto; }
}

.drawer-foot {
  flex: none;
  border-top: 1px solid var(--border);
  padding: 10px 12px calc(12px + var(--safe-b));
}

.who {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 2px 10px;
  color: var(--fg-2);
  font-size: 13.5px;
}
.who-avatar {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(var(--brand-rgb), .12);
  color: var(--brand);
  font-size: 13px;
  font-weight: 600;
}
.who-phone { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.foot-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: var(--fg-2);
  border-radius: 10px;
  padding: 10px 10px;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.foot-btn:active { background: var(--bg-soft); }
.foot-btn.danger { color: var(--danger); }

.mask {
  position: fixed;
  inset: 0;
  background: var(--mask);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
  z-index: 50;
}
.mask.is-open { opacity: 1; pointer-events: auto; }

/* ---------- 14. Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(112px + var(--safe-b));
  transform: translateX(-50%) translateY(8px);
  max-width: 78vw;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(27, 27, 31, .93);
  color: #fff;
  font-size: 13.5px;
  line-height: 1.45;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 80;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }
:root[data-theme="dark"] .toast { background: rgba(240, 240, 245, .95); color: #1B1B1F; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .toast { background: rgba(240, 240, 245, .95); color: #1B1B1F; }
}

/* ---------- 15. 登录页 ---------- */
.auth-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(28px + var(--safe-t)) 22px calc(28px + var(--safe-b));
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 380px;
}

.auth-logo {
  width: 62px;
  height: 62px;
  margin: 0 auto 16px;
  display: block;
}

.auth-title {
  margin: 0 0 28px;
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  color: var(--fg);
}

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

.auth-label {
  display: block;
  margin: 0 0 6px 2px;
  font-size: 13px;
  color: var(--muted);
}

.auth-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--input-bg);
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 0 8px 0 14px;
  transition: border-color .15s ease;
}
.auth-input-row:focus-within { border-color: rgba(var(--brand-rgb), .55); }
.auth-input-row.is-error { border-color: var(--danger); }

.auth-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--fg);
  font-size: 16px;              /* 防 iOS 聚焦缩放 */
  font-family: inherit;
  padding: 13px 0;
}
.auth-input::placeholder { color: var(--muted); }

.eye-btn {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.auth-submit {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 500;
  padding: 14px;
  margin-top: 8px;
  cursor: pointer;
  transition: background .15s ease, opacity .15s ease;
}
.auth-submit:active { background: var(--brand-strong); }
.auth-submit:disabled { opacity: .6; cursor: default; }

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  animation: ds-spin .7s linear infinite;
}
@keyframes ds-spin { to { transform: rotate(360deg); } }

.auth-error {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 13.5px;
  line-height: 1.5;
  text-align: center;
}

.auth-hint {
  margin: 18px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

/* ---------- 16. 桌面端：只居中限宽，不做两栏 ---------- */
@media (min-width: 769px) {
  .msg-list { padding-left: 0; padding-right: 0; }
  .composer { padding-left: 12px; padding-right: 12px; }
  .md { font-size: 16px; }
}

/* ---------- 17. 无障碍 / 动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

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