/* ============================================================
   高考志愿咨询助手 —— 视觉层
   设计基调：中性灰底 + 靛紫强调色，柔和分层阴影，线性图标，
             支持系统深色模式。
   ============================================================ */

:root {
  /* 表面 */
  --bg:            #f4f5f7;
  --surface:       #ffffff;
  --surface-2:     #fafafb;
  --surface-sunk:  #f1f2f5;
  --border:        #e7e8ec;
  --border-strong: #d8dae1;

  /* 文字 */
  --text:    #14161a;
  --text-2:  #4c5158;
  --muted:   #8a9098;

  /* 强调 */
  --brand:      #4f46e5;
  --brand-600:  #4338ca;
  --brand-soft: #eef0ff;
  --brand-ring: rgba(79, 70, 229, .16);
  --grad:       linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);

  /* 语义 */
  --ok:   #059669;
  --warn: #d97706;
  --err:  #dc2626;
  --err-soft: #fef2f2;
  --err-line: #fbd5d5;

  /* 其它 */
  --radius:    14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Consolas, monospace;
  --sh-1: 0 1px 2px rgba(16, 24, 40, .04);
  --sh-2: 0 2px 4px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
  --sh-3: 0 8px 16px rgba(16, 24, 40, .06), 0 24px 56px rgba(16, 24, 40, .10);
  --t: .18s cubic-bezier(.4, 0, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #0d0f13;
    --surface:       #15181e;
    --surface-2:     #191d24;
    --surface-sunk:  #1d222a;
    --border:        #262b34;
    --border-strong: #333944;

    --text:   #e9ebef;
    --text-2: #b3b9c4;
    --muted:  #7d8590;

    --brand:      #7c7cf8;
    --brand-600:  #6d6df5;
    --brand-soft: #1e2136;
    --brand-ring: rgba(124, 124, 248, .22);

    --ok: #34d399;
    --err: #f87171;
    --err-soft: #2a1618;
    --err-line: #4c2326;

    --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
    --sh-2: 0 2px 6px rgba(0, 0, 0, .4), 0 10px 28px rgba(0, 0, 0, .34);
    --sh-3: 0 10px 30px rgba(0, 0, 0, .5);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; width: 100%; }

/* 移动端横向溢出兜底：任何子元素宽度超过视口时裁切，避免整页被推偏 / 出现横向滚动条导致“看起来没居中” */
html, body { overflow-x: clip; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text",
    "Segoe UI", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;   /* 手机横屏时不要自作主张放大正文 */
  text-rendering: optimizeLegibility;
  font-variant-numeric: tabular-nums;
}

.hidden { display: none !important; }

/* 图标 -------------------------------------------------------- */
.ic {
  width: 1em; height: 1em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -.125em;
}

/* 滚动条 ------------------------------------------------------ */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }

/* 按钮 -------------------------------------------------------- */
.btn {
  font: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 500;
  transition: background var(--t), color var(--t), border-color var(--t),
              transform var(--t), box-shadow var(--t);
}
.btn:hover { background: var(--surface-sunk); color: var(--text); }
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }

.btn.primary {
  background: var(--grad);
  color: #fff;
  border: none;
  box-shadow: 0 1px 2px rgba(79, 70, 229, .3), 0 6px 16px rgba(79, 70, 229, .22);
}
.btn.primary:hover { filter: brightness(1.06); color: #fff; }
.btn.primary:disabled {
  filter: grayscale(.45) opacity(.55);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn.block { width: 100%; padding: 11px; font-size: 15px; }
.btn.icon { padding: 7px; font-size: 17px; border-radius: 9px; color: var(--muted); }

/* 输入 -------------------------------------------------------- */
input, textarea {
  font: inherit;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--muted); }

/* ============================================================
   登录页
   ============================================================ */
.auth-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  min-height: 100dvh;          /* 手机浏览器地址栏会吃掉 vh，dvh 才是真实可视高 */
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  background:
    radial-gradient(900px 520px at 12% -10%, rgba(99, 102, 241, .16), transparent 60%),
    radial-gradient(760px 500px at 92% 8%, rgba(139, 92, 246, .14), transparent 62%),
    var(--bg);
}
.auth-glow {
  position: absolute;
  width: 520px; height: 520px;
  border-radius: 50%;
  background: var(--grad);
  filter: blur(140px);
  opacity: .18;
  bottom: -220px; right: -120px;
  pointer-events: none;
}
.auth-card {
  position: relative;
  width: min(400px, 100%);
  max-width: 100%;
  padding: 38px 34px 30px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--sh-3);
  text-align: center;
  animation: rise .45s cubic-bezier(.2, .8, .2, 1) both;
}
.auth-mark {
  width: 54px; height: 54px;
  margin: 0 auto 14px;
  border-radius: 16px;
  display: grid; place-items: center;
  font-size: 27px;
  color: #fff;
  background: var(--grad);
  box-shadow: 0 8px 22px rgba(99, 102, 241, .35);
}
.auth-card h1 {
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -.02em;
  margin: 0 0 5px;
}
.auth-sub { color: var(--muted); font-size: 13px; margin: 0 0 24px; }

.field {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  margin-bottom: 11px;
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
}
.field:focus-within {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--brand-ring);
}
.field-ic { color: var(--muted); font-size: 17px; display: flex; }
.code-input {
  text-transform: uppercase;
  letter-spacing: .09em;
  font-variant-numeric: tabular-nums;
}
.auth-card .btn.primary { margin-top: 7px; }
/* 扫码带着卡密进来时的短暂验证态：把手输入口压暗，避免用户重复操作 */
.scanning .field { opacity: .55; pointer-events: none; }
.auth-msg { min-height: 22px; margin-top: 12px; font-size: 13px; color: var(--err); }
.auth-note {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
}


@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

/* ============================================================
   布局
   ============================================================ */
.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* 侧栏 -------------------------------------------------------- */
.sidebar {
  width: 268px;
  flex: none;
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  gap: 12px;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
}
.side-head { display: flex; align-items: center; padding: 4px 4px 0; }
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 650;
  font-size: 15.5px;
  letter-spacing: -.01em;
}
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  display: grid; place-items: center;
  font-size: 17px;
  color: #fff;
  background: var(--grad);
  box-shadow: 0 3px 10px rgba(99, 102, 241, .32);
}

.new-conv {
  width: 100%;
  justify-content: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  box-shadow: var(--sh-1);
}
.new-conv:hover { border-color: var(--brand); color: var(--brand); background: var(--surface); }
.new-conv .ic { font-size: 16px; }

.side-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 2px 6px;
}

.conv-list { flex: 1; overflow-y: auto; margin: -4px -4px 0; padding: 4px; }
.conv-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-2);
  transition: background var(--t), color var(--t);
}
.conv-item .ic { font-size: 15px; color: var(--muted); transition: color var(--t); }
.conv-item:hover { background: var(--surface); color: var(--text); }
.conv-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 500; }
.conv-item.active .ic { color: var(--brand); }
.conv-title {
  flex: 1; min-width: 0;
  font-size: 13.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-del {
  border: none; background: none; cursor: pointer;
  color: var(--muted);
  font-size: 15px;
  padding: 3px;
  border-radius: 7px;
  opacity: 0;
  display: flex;
  transition: opacity var(--t), color var(--t), background var(--t);
}
.conv-item:hover .conv-del { opacity: 1; }
.conv-del:hover { color: var(--err); background: var(--err-soft); }
.conv-empty { padding: 14px 8px; color: var(--muted); font-size: 13px; }

.side-foot { border-top: 1px solid var(--border); padding-top: 10px; }
.user-row { display: flex; align-items: center; gap: 9px; padding: 2px; }
.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 15px;
  color: var(--text-2);
  background: var(--surface-sunk);
  border: 1px solid var(--border);
}
.uname { flex: 1; font-size: 13.5px; font-weight: 500; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#logout:hover { color: var(--err); background: var(--err-soft); }

/* 主区 -------------------------------------------------------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--surface); }

.topbar {
  height: 58px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
}
.topbar-title {
  display: flex; align-items: center; gap: 9px;
  font-weight: 600; font-size: 14.5px;
}
.topbar-title .ic { font-size: 17px; color: var(--muted); }

.health { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 11px;
  white-space: nowrap;
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); flex: none; }
.chip.good .dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); }
.chip.bad  .dot { background: var(--err); box-shadow: 0 0 0 3px color-mix(in srgb, var(--err) 18%, transparent); }
.chip.off  { color: var(--muted); }

/* 顶栏账号区：桌面版账号在侧栏，这里只在窄屏出现 */
.topbar-account { display: none; align-items: center; gap: 6px; flex: none; }
.uname-top {
  font-size: 12.5px; color: var(--text-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chat {
  flex: 1;
  min-width: 0;          /* 允许在 flex 列中收缩，避免宽表格/长代码把容器撑出视口 */
  min-height: 0;         /* 允许在 flex 列中滚动，而非把整页撑高 */
  overflow-y: auto;
  overflow-x: clip;
  padding: 28px 0 12px;
  scroll-behavior: smooth;
}

/* ============================================================
   欢迎屏
   ============================================================ */
.welcome { max-width: 760px; margin: 8vh auto 0; padding: 0 28px; }
.welcome-mark {
  width: 52px; height: 52px;
  border-radius: 16px;
  display: grid; place-items: center;
  font-size: 26px; color: #fff;
  background: var(--grad);
  box-shadow: 0 10px 26px rgba(99, 102, 241, .3);
  margin-bottom: 18px;
}
.welcome h2 {
  font-size: 27px;
  font-weight: 650;
  letter-spacing: -.025em;
  margin: 0 0 8px;
}
.welcome h2 .accent {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.welcome p { color: var(--text-2); margin: 0; font-size: 14.5px; max-width: 620px; }

.samples { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-top: 26px; }
.sample {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 14px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.6;
  cursor: pointer;
  transition: border-color var(--t), transform var(--t), box-shadow var(--t), color var(--t);
}
.sample .ic { font-size: 16px; color: var(--brand); margin-top: 3px; }
.sample:hover {
  border-color: var(--brand);
  color: var(--text);
  transform: translateY(-2px);
  box-shadow: var(--sh-2);
}
@media (max-width: 760px) { .samples { grid-template-columns: 1fr; } }

/* ============================================================
   消息
   ============================================================ */
.msg {
  max-width: 860px;
  margin: 0 auto 26px;
  padding: 0 28px;
  animation: fadeUp .32s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* 用户：右侧气泡 */
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble {
  max-width: 78%;
  background: var(--grad);
  color: #fff;
  padding: 11px 16px;
  border-radius: 18px 18px 5px 18px;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 2px 10px rgba(99, 102, 241, .24);
}

/* 助手：左侧头像 + 全宽正文 */
.msg.assistant { display: flex; gap: 13px; }
.msg.assistant .avatar {
  width: 30px; height: 30px;
  flex: none;
  border-radius: 9px;
  display: grid; place-items: center;
  font-size: 16px; color: #fff;
  background: var(--grad);
  box-shadow: 0 2px 8px rgba(99, 102, 241, .28);
}
.msg.assistant .bubble { flex: 1; min-width: 0; padding-top: 2px; }

/* 处理进度提示（token 到来即移除） */
.status-line {
  display: flex; align-items: center; gap: 9px;
  color: var(--muted);
  font-size: 13.5px;
  margin: 10px 0;
}
.spinner {
  width: 14px; height: 14px; flex: none;
  border: 2px solid var(--border-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.status-text { line-height: 1.5; }

/* 过程说明 */
.note-block {
  color: var(--text-2);
  font-size: 13.5px;
  border-left: 2px solid var(--border-strong);
  padding: 1px 0 1px 12px;
  margin: 10px 0;
  white-space: pre-wrap;
}

/* 过程卡片 ---------------------------------------------------- */
.step {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 12px;
  margin: 10px 0;
  overflow: hidden;
  transition: border-color var(--t), box-shadow var(--t);
}
.step:hover { border-color: var(--border-strong); }
.step.open { box-shadow: var(--sh-1); }
.step-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 13px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-2);
  user-select: none;
  transition: background var(--t);
}
.step-head:hover { background: var(--surface-sunk); }
.step-icon {
  width: 24px; height: 24px;
  flex: none;
  border-radius: 7px;
  display: grid; place-items: center;
  font-size: 14px;
  color: var(--brand);
  background: var(--brand-soft);
}
.step-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step-badge {
  font-size: 11.5px;
  color: var(--muted);
  background: var(--surface-sunk);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}
.step-badge.err { color: var(--err); background: var(--err-soft); }
.step-chev {
  font-size: 15px; color: var(--muted);
  transition: transform var(--t);
}
.step.open .step-chev { transform: rotate(90deg); }
.step-body { padding: 0 13px 13px; display: none; }
.step.open .step-body { display: block; animation: fadeUp .2s ease both; }

.step.pending .step-icon { color: var(--brand); }
.step.pending .step-icon .ic { animation: spin 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 代码 / 结果块 ------------------------------------------------ */
pre.sql {
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  margin: 8px 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-2);
}

.tbl-wrap {
  overflow: auto;
  max-height: 360px;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 9px;
}
table.data { border-collapse: separate; border-spacing: 0; font-size: 12.5px; width: 100%; }
table.data th, table.data td {
  padding: 7px 11px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
table.data tr:last-child td { border-bottom: none; }
table.data th {
  background: var(--surface-sunk);
  position: sticky; top: 0;
  font-weight: 600;
  color: var(--text-2);
}
table.data tbody tr:hover td { background: var(--surface-sunk); }

.srch-item { margin: 9px 0; font-size: 13px; }
.srch-item a { color: var(--brand); text-decoration: none; font-weight: 500; }
.srch-item a:hover { text-decoration: underline; }
.srch-snip { color: var(--muted); font-size: 12.5px; }

/* Markdown 正文 ----------------------------------------------- */
.md { font-size: 15px; }
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3 {
  font-size: 16px; font-weight: 650; letter-spacing: -.01em;
  margin: 20px 0 9px;
}
.md p { margin: 10px 0; }
.md ul, .md ol { margin: 10px 0; padding-left: 22px; }
.md li { margin: 4px 0; }
.md li::marker { color: var(--muted); }
.md strong { font-weight: 650; color: var(--text); }
.md a { color: var(--brand); text-decoration: none; }
.md a:hover { text-decoration: underline; }
.md code {
  background: var(--surface-sunk);
  padding: 1.5px 6px;
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 13px;
}
.md pre {
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  padding: 12px 14px; border-radius: 10px; overflow-x: auto;
  font-size: 13px;
}
.md pre code { background: none; padding: 0; }
.md table {
  border-collapse: separate; border-spacing: 0;
  margin: 14px 0; font-size: 13.5px; width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.md th, .md td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.md tr:last-child td { border-bottom: none; }
.md th { background: var(--surface-sunk); font-weight: 600; }
.md blockquote {
  border-left: 3px solid var(--brand);
  background: var(--brand-soft);
  border-radius: 0 8px 8px 0;
  margin: 12px 0;
  padding: 8px 14px;
  color: var(--text-2);
}
.md hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

.err-box {
  display: flex; align-items: flex-start; gap: 8px;
  background: var(--err-soft);
  border: 1px solid var(--err-line);
  color: var(--err);
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 13.5px;
  margin: 10px 0;
}

/* 打字光标 */
.typing {
  display: inline-block;
  width: 8px; height: 16px;
  border-radius: 2px;
  background: var(--brand);
  vertical-align: text-bottom;
  animation: blink 1.05s steps(2, start) infinite;
}
@keyframes blink { 0%, 100% { opacity: 1 } 50% { opacity: .15 } }

/* ============================================================
   输入区
   ============================================================ */
.composer { flex: none; padding: 10px 28px 20px; background: var(--surface); }
.composer-inner {
  max-width: 860px;
  margin: 0 auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px 10px;
  box-shadow: var(--sh-2);
  transition: border-color var(--t), box-shadow var(--t);
}
.composer-inner:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-ring), var(--sh-2);
}
#input {
  resize: none;
  max-height: 190px;
  line-height: 1.65;
  display: block;
}
.composer-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}
.tips { font-size: 12px; color: var(--muted); }
/* 本次咨询剩余提问次数 */
.turns {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.turns.out { color: var(--err); font-weight: 600; }
#input:disabled { opacity: .6; cursor: not-allowed; }
.send {
  width: 38px; height: 38px;
  padding: 0;
  border-radius: 12px;
  font-size: 18px;
  flex: none;
}
/* 语音输入按钮（放在发送按钮左侧） */
.mic {
  width: 38px; height: 38px;
  padding: 0;
  border-radius: 12px;
  flex: none;
  color: var(--muted);
  transition: color var(--t), background var(--t), border-color var(--t);
}
.mic:hover { color: var(--brand); }
.mic.recording {
  color: #fff;
  background: var(--err);
  border-color: var(--err);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--err) 22%, transparent);
}
.mic.recording .ic { animation: mic-pulse 1.1s ease-in-out infinite; }
.mic[disabled] { opacity: .4; cursor: not-allowed; }
@keyframes mic-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.2); } }
/* 语音识别的临时错误/提示 */
.voice-msg {
  font-size: 12px;
  color: var(--err);
  max-width: 40%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  opacity: 0; transition: opacity var(--t);
}
.voice-msg.show { opacity: 1; }

/* ============================================================
   手机端（主力场景：扫码进来的都是手机）
   ============================================================ */
@media (max-width: 840px) {
  .sidebar { display: none; }

  /* 侧栏收起后，账号与「退出/换卡密」必须在顶栏还能摸到 */
  .topbar { padding: 0 12px 0 16px; gap: 10px; }
  .topbar-account { display: flex; }
  .topbar-title span { display: none; }        /* 标题让位给状态与账号 */
  .health { flex: 1; min-width: 0; }
  .health .chip:not(:first-child) { display: none; }
  .health .chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

  .msg, .welcome { padding-left: 16px; padding-right: 16px; }
  .msg.user .bubble { max-width: 88%; }
  .welcome { margin-top: 4vh; }
  .welcome h2 { font-size: 24px; }

  /* 输入区：底部留出 iPhone 的手势条，键盘弹起时也不贴边 */
  .composer { padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); }
  .composer-inner { padding: 10px 12px 8px; }
  .tips { display: none; }                     /* Enter 发送的提示在手机上无意义 */
  .turns { font-size: 11.5px; }
  .send { width: 44px; height: 44px; }         /* 触摸目标不小于 44px */
  .mic { width: 44px; height: 44px; }
  .btn.icon { padding: 10px; }

  /* iOS 上输入框字号小于 16px 会自动放大整页，必须顶到 16px */
  #input, .code-input, input, textarea { font-size: 16px; }

  /* 推荐方案常带宽表格，窄屏要能横向滑动而不是撑破布局 */
  .md table { display: block; width: 100%; overflow-x: auto; }

  .auth-card { padding: 30px 20px 24px; }
  .auth-wrap { padding: 16px; }
}

/* 触摸设备去掉点击时的灰色高亮块 */
@media (hover: none) {
  * { -webkit-tap-highlight-color: transparent; }
}

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