/* ==========================================================================
 * 03 AI 对话（子页面：白底导航栏，无胶囊 TabBar、无悬浮球，底部输入条）
 * --------------------------------------------------------------------------
 * 与 01/02 的骨架不同，逐条对照设计稿：
 *   · 顶部白底导航栏（不是蓝渐变头）：左返回圆钮 · 居中标题 16.5px（规范 H2）
 *     · 右 + 圆钮；副标题是成功绿的「已接入本地裁判文书库」
 *   · 没有底部胶囊 Tab Bar、没有悬浮 AI 按钮 —— 底部整块让给输入条
 *   · 页面底色 #F1F4F7，气泡与卡片浮在其上（卡片阴影）
 *
 * 尺寸取自规范（字号 / 圆角 / 颜色 / 阴影）；规范没逐项给出的（气泡内边距、
 * 卡片密度、输入条高度）按设计稿实测密度取整，并用逐屏比对收敛 ——
 * 第一版偏松，类案卡第二行被挤出屏外，这一版是收紧后的值。
 * ========================================================================== */

/* ------------------------------ 顶部导航栏 ------------------------------ */
body.mobile .ma-nav {
  position: sticky; top: 0; z-index: 6;
  background: var(--m-card);
  border-bottom: 1px solid var(--m-line);
  /* 与 01/02 同一套状态栏占位：62px 占位 与 真机安全区 取较大者；
     套壳 App 里 --m-status-h 由 mobile-kit.css 归零，不会叠出两条。 */
  padding-top: max(var(--m-status-h, 62px), var(--m-safe-top));
}
body.mobile .ma-nav-in {
  position: relative; height: 48px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 var(--m-gutter);
}
body.mobile .ma-round {
  width: 32px; height: 32px; flex: none; padding: 0; border: none;
  border-radius: 50%; background: #F1F4F7; color: var(--m-t1);
  display: flex; align-items: center; justify-content: center;
}
body.mobile .ma-round.back { position: absolute; left: var(--m-gutter); }
body.mobile .ma-round.plus { position: absolute; right: var(--m-gutter); }
body.mobile .ma-round:active { background: #E7EBF0; }
/* 图标集只有右向 chevron，「返回」语义必须朝左 —— 翻过来，不另造图标 */
body.mobile .ma-round.back svg { transform: rotate(180deg); }

body.mobile .ma-title { text-align: center; min-width: 0; }
body.mobile .ma-title b {
  display: block; font-size: var(--m-fs-h2); font-weight: 600; color: var(--m-t1);
  line-height: 1.25;
}
body.mobile .ma-title span {
  display: flex; align-items: center; justify-content: center; gap: 3px;
  margin-top: 1px; font-size: var(--m-fs-micro); color: var(--m-ok);
}
body.mobile .ma-title span .mk-ic { color: var(--m-ok); }

/* ------------------------------ 消息流 ------------------------------ */
body.mobile .ma-body {
  padding: 12px var(--m-gutter) 10px;
  display: flex; flex-direction: column; gap: 11px;
}
body.mobile .ma-msg { display: flex; align-items: flex-start; gap: 9px; }
body.mobile .ma-ava {
  width: 32px; height: 32px; flex: none; border-radius: 50%;
  background: var(--m-grad-head); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--m-sh-card);
}
body.mobile .ma-bubble {
  max-width: 232px; padding: 10px 12px;
  border-radius: 14px 14px 14px 4px;
  background: var(--m-card); color: var(--m-t1);
  font-size: 13.5px; line-height: 1.68;
  box-shadow: var(--m-sh-card);
}
/* 用户消息：右对齐、品牌蓝实心 */
body.mobile .ma-msg.me { justify-content: flex-end; }
body.mobile .ma-msg.me .ma-bubble {
  border-radius: 14px 14px 4px 14px;
  background: var(--m-brand); color: #fff;
}

/* ------------------------------ 研判卡 ------------------------------ */
body.mobile .ma-card {
  background: var(--m-card); border: 1px solid var(--m-line);
  border-radius: var(--m-r-card); box-shadow: var(--m-sh-card);
  padding: 12px 12px 11px;
}
body.mobile .ma-card-h {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 10px;
}
body.mobile .ma-card-h em {
  font-style: normal; height: 20px; padding: 0 7px; border-radius: var(--m-r-chip);
  background: var(--m-tint); color: var(--m-tint-tx);
  font-size: var(--m-fs-micro); font-weight: 600;
  display: inline-flex; align-items: center;
}
body.mobile .ma-card-h span { font-size: var(--m-fs-micro); color: var(--m-t3); }

/* 研判条目：左侧标记 + 一段文字 */
body.mobile .ma-item { display: flex; gap: 8px; }
body.mobile .ma-item + .ma-item { margin-top: 9px; }
body.mobile .ma-item .mk-ic { flex: none; margin-top: 2px; }
body.mobile .ma-item.ok .mk-ic { color: var(--m-ok); }
body.mobile .ma-item.warn .mk-ic { color: var(--m-warn); }
body.mobile .ma-item p {
  margin: 0; font-size: 12.5px; line-height: 1.68; color: var(--m-t2);
}
body.mobile .ma-item p b { color: var(--m-t1); font-weight: 600; }

/* 卡片底部两枚动作按钮 */
body.mobile .ma-acts { display: flex; gap: 9px; margin-top: 12px; }
body.mobile .ma-btn {
  flex: 1; height: 36px; border-radius: 18px; border: none;
  font-size: 12.5px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  font-family: var(--m-ff);
}
body.mobile .ma-btn.solid { background: var(--m-grad-btn); color: #fff; box-shadow: var(--m-sh-btn); }
body.mobile .ma-btn.ghost { background: var(--m-card); color: var(--m-t1); border: 1px solid var(--m-line); }
body.mobile .ma-btn:active { transform: scale(.98); }

/* ------------------------------ 追问建议（横向胶囊） ------------------------------ */
body.mobile .ma-chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
body.mobile .ma-chips::-webkit-scrollbar { display: none; }
body.mobile .ma-chip {
  flex: none; height: 30px; padding: 0 12px; border-radius: 999px;
  background: var(--m-card); border: 1px solid var(--m-line);
  color: var(--m-t1); font-size: 12.5px; font-weight: 500;
  display: inline-flex; align-items: center; cursor: pointer;
  font-family: var(--m-ff);
}
body.mobile .ma-chip:active { background: #F7F9FB; }

/* ------------------------------ 关联类案推送 ------------------------------ */
body.mobile .ma-case { display: flex; gap: 8px; align-items: flex-start; }
body.mobile .ma-case + .ma-case { margin-top: 10px; }
body.mobile .ma-case .mk-ic { flex: none; color: var(--m-brand); margin-top: 2px; }
body.mobile .ma-case p {
  margin: 0; font-size: 12.5px; line-height: 1.6; color: var(--m-t1);
}
body.mobile .ma-case p i { font-style: normal; color: var(--m-t3); }

/* ------------------------------ 底部输入条 ------------------------------ */
body.mobile .ma-input {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--m-card);
  border-top: 1px solid var(--m-line);
  padding: 9px var(--m-gutter) calc(9px + var(--m-safe-bottom));
  display: flex; align-items: center; gap: 9px;
}
body.mobile .ma-input .ma-round { width: 32px; height: 32px; }
body.mobile .ma-field {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px; border-radius: 18px;
  background: #F1F4F7; color: var(--m-t4);
  font-size: 12.5px; font-family: var(--m-ff);
  border: none; outline: none;
}
body.mobile .ma-field.mk-on { color: var(--m-t1); }
body.mobile .ma-send {
  width: 36px; height: 36px; flex: none; padding: 0; border: none;
  border-radius: 50%; background: var(--m-grad-fab); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--m-sh-fab);
}
body.mobile .ma-send:active { transform: scale(.95); }
body.mobile .ma-send:disabled { background: #C6D6E6; box-shadow: none; }

/* 输入条高度补偿：不让最后一条消息被压在输入条下面 */
body.mobile .ma-page { padding-bottom: calc(54px + var(--m-safe-bottom) + 10px); }

/* ------------------------------ 真实会话的补充样式 ------------------------------
   上面那套版式是照设计稿做的静态帧，气泡里是一段段短文案。
   换成真实会话后多了三样东西，这里只补这三样，版式一行未改：
     · 模型输出的 Markdown（小标题 / 列表 / 引用 / 加粗 / 行内代码）
     · 等待回复的动态提示
     · 失败气泡（接口未配置、额度不足、密钥无效都走这里，原样显示服务端原因）
   ---------- */

/* 助手气泡装得下一段正文：比用户短句略宽，仍不占满一行 */
body.mobile .ma-bubble.ma-md { max-width: 262px; }
body.mobile .ma-md > *:first-child { margin-top: 0; }
body.mobile .ma-md > *:last-child { margin-bottom: 0; }
body.mobile .ma-md p { margin: 0 0 7px; }
body.mobile .ma-md h4 { margin: 10px 0 6px; font-size: 13px; font-weight: 600; color: var(--m-t1); }
body.mobile .ma-md ul, body.mobile .ma-md ol { margin: 0 0 7px; padding-left: 17px; }
body.mobile .ma-md li { margin: 2px 0; }
body.mobile .ma-md strong { font-weight: 600; color: var(--m-t1); }
body.mobile .ma-md em { font-style: normal; color: var(--m-brand); }
body.mobile .ma-md code {
  background: #EEF3FA; border-radius: 4px; padding: 1px 5px;
  font-size: 12px; font-family: ui-monospace, Menlo, Consolas, monospace;
}
body.mobile .ma-md blockquote {
  margin: 0 0 7px; padding: 2px 0 2px 9px;
  border-left: 2px solid var(--m-line); color: var(--m-t2);
}
body.mobile .ma-md hr { border: none; border-top: 1px solid var(--m-line); margin: 8px 0; }
body.mobile .ma-md a { color: var(--m-brand); }

/* Markdown 表格：气泡内横向滚动，表头固定底色，避免竖线原文糊成一团 */
body.mobile .ma-md .ma-table-wrap {
  max-width: 100%;
  margin: 8px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--m-line);
  border-radius: 8px;
  background: #fff;
}
body.mobile .ma-md .ma-table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: auto;
  font-size: 12px;
  line-height: 18px;
  color: var(--m-t1);
}
body.mobile .ma-md .ma-table th,
body.mobile .ma-md .ma-table td {
  padding: 7px 9px;
  border-right: 1px solid var(--m-line);
  border-bottom: 1px solid var(--m-line);
  vertical-align: top;
  text-align: left;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}
body.mobile .ma-md .ma-table th {
  background: #F3F6FB;
  font-weight: 600;
  white-space: nowrap;
}
body.mobile .ma-md .ma-table tr:last-child td { border-bottom: none; }
body.mobile .ma-md .ma-table th:last-child,
body.mobile .ma-md .ma-table td:last-child { border-right: none; }

/* 等待回复：三点呼吸。与首屏骨架同一取向 —— 不用转圈 */
body.mobile .ma-typing { display: flex; align-items: center; gap: 4px; min-width: 46px; }
body.mobile .ma-typing i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--m-t4);
  animation: ma-dot 1.1s infinite ease-in-out;
}
body.mobile .ma-typing i:nth-child(2) { animation-delay: .16s; }
body.mobile .ma-typing i:nth-child(3) { animation-delay: .32s; }
@keyframes ma-dot {
  0%, 60%, 100% { opacity: .25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

/* 失败气泡 */
body.mobile .ma-ava.err { background: #FFF4E5; color: var(--m-warn); box-shadow: none; }
body.mobile .ma-bubble.ma-err { background: #FFF9F0; border: 1px solid #F4E0BE; box-shadow: none; }
body.mobile .ma-bubble.ma-err p { margin: 0; color: #8A5A06; }
body.mobile .ma-retry {
  margin-top: 8px; height: 28px; padding: 0 14px; border-radius: 14px;
  border: 1px solid #E9CFA0; background: #fff; color: #8A5A06;
  font-size: 12px; font-family: var(--m-ff);
}

/* 顶部副标题：没接上接口时用提醒色，别让「已接入」一直显示成成功绿 */
body.mobile .ma-title span.off { color: var(--m-warn); }
body.mobile .ma-title span.off .mk-ic { color: var(--m-warn); }
