/* ═══════════════════════════════════════════════════════
   心析 · 样式
   移动端优先，桌面居中成一张「卡片」。全部原生 CSS，无框架。
   ═══════════════════════════════════════════════════════ */

:root {
  --bg: #fbf7f9;
  --bg-2: #f4f2fd;
  --card: #ffffff;
  --ink: #241f2c;
  --ink-2: #6b6478;
  --ink-3: #a29aae;
  --line: #efe9f0;
  --line-2: #e4dcea;
  --rose: #e8618c;
  --rose-lt: #fdeef3;
  --violet: #7c6bea;
  --violet-lt: #f0edfe;
  --amber: #d99226;
  --amber-lt: #fdf4e6;
  --danger: #d63b4c;
  --danger-lt: #fdecee;
  --ok: #2b9b6a;
  --ok-lt: #e9f7f0;
  --grad: linear-gradient(135deg, #ee6e96 0%, #a072ee 100%);
  --shadow: 0 1px 2px rgba(46, 32, 58, .04), 0 8px 24px -12px rgba(46, 32, 58, .12);
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  background-image: radial-gradient(1200px 500px at 50% -180px, #fdeaf1 0%, rgba(253, 234, 241, 0) 62%),
                    radial-gradient(900px 460px at 100% 6%, #eeebfd 0%, rgba(238, 235, 253, 0) 60%);
  background-attachment: fixed;
  color: var(--ink);
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.screen { max-width: 560px; margin: 0 auto; padding: 22px 16px 0; }
.hidden { display: none !important; }

/* ────────── 首屏头部 ────────── */
.hero { padding: 16px 4px 22px; }
.logo {
  display: inline-block;
  font-size: 13px; font-weight: 700; letter-spacing: .16em;
  color: #fff; background: var(--grad);
  padding: 5px 13px; border-radius: 999px;
  box-shadow: 0 6px 16px -8px rgba(168, 84, 178, .7);
}
.hero h1 {
  margin: 16px 0 10px;
  font-size: 28px; line-height: 1.32; font-weight: 800; letter-spacing: -.4px;
  background: linear-gradient(112deg, #2a2333 12%, #7a4a86 92%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero .sub { margin: 0; color: var(--ink-2); font-size: 14.5px; line-height: 1.7; }
.hero .sub b { color: var(--ink); font-weight: 600; }
.promise { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.promise span {
  font-size: 12px; color: var(--ink-2);
  background: rgba(255, 255, 255, .78);
  border: 1px solid var(--line);
  padding: 5px 11px; border-radius: 999px;
  backdrop-filter: blur(6px);
}

/* ────────── 卡片 ────────── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}

/* ────────── 标签页 ────────── */
.tabs {
  display: flex; gap: 4px; background: #f5f2f7;
  padding: 4px; border-radius: 12px; margin-bottom: 16px;
}
.tab {
  flex: 1; border: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: 14.5px; font-weight: 600; color: var(--ink-2);
  padding: 9px 0; border-radius: 9px; transition: .18s;
}
.tab.on { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(46, 32, 58, .1); }

/* ────────── 输入 ────────── */
.input {
  width: 100%; display: block;
  border: 1.5px solid var(--line-2); border-radius: 13px;
  background: #fdfcfe;
  padding: 12px 13px;
  /* ⚠️ 必须是 16px。iPhone 上输入框字号小于 16px 时，Safari 会在聚焦瞬间
     自动把整页放大，用户敲完字还得手动缩回去 —— 这个坑非常常见。 */
  font: inherit; font-size: 16px; line-height: 1.62; color: var(--ink);
  resize: vertical; transition: border-color .16s, box-shadow .16s;
}
.input::placeholder { color: var(--ink-3); }
.input:focus {
  outline: none; border-color: #d5b6ea; background: #fff;
  box-shadow: 0 0 0 4px rgba(124, 107, 234, .09);
}
.input-sm { font-size: 16px; padding: 10px 12px; }

.meta-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px; font-size: 12.5px; color: var(--ink-3);
}
.link-btn {
  border: 0; background: none; cursor: pointer; padding: 2px 0;
  font: inherit; font-size: 12.5px; color: var(--violet); font-weight: 600;
}
.link-btn:active { opacity: .6; }

/* ────────── 上传区 ────────── */
.dropzone {
  display: block; cursor: pointer; text-align: center;
  border: 1.5px dashed #dccfe6; border-radius: 14px;
  background: linear-gradient(180deg, #fdfaff, #fbf9fe);
  padding: 26px 16px; transition: .18s;
}
.dropzone:active { border-color: var(--violet); background: var(--violet-lt); }
.dz-icon { font-size: 26px; color: #c3aee0; line-height: 1; }
.dz-title { margin-top: 8px; font-size: 15px; font-weight: 600; }
.dz-sub { margin-top: 6px; font-size: 12.5px; color: var(--ink-3); line-height: 1.6; }

.thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.thumb {
  position: relative; aspect-ratio: 3 / 4; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line-2); background: #f3f0f6;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .x {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px;
  border: 0; border-radius: 50%; cursor: pointer;
  background: rgba(24, 18, 30, .62); color: #fff;
  font-size: 13px; line-height: 18px; padding: 0;
}
.thumb .n {
  position: absolute; left: 4px; bottom: 3px;
  font-size: 10px; color: #fff; background: rgba(24, 18, 30, .55);
  border-radius: 4px; padding: 0 4px;
}

.ocr-box { margin-top: 14px; border-top: 1px dashed var(--line-2); padding-top: 14px; }
.ocr-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13.5px; font-weight: 600; margin-bottom: 8px;
}
.ocr-hint { font-size: 12px; font-weight: 400; color: var(--ink-3); }

/* ────────── 折叠补充信息 ────────── */
.fold-head {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  border: 0; background: none; cursor: pointer; padding: 2px 0;
  font: inherit; font-size: 15px; font-weight: 600; color: var(--ink); text-align: left;
}
.fold-head em { display: block; font-style: normal; font-size: 12.5px; font-weight: 400; color: var(--ink-3); margin-top: 3px; }
.chev { color: var(--ink-3); transition: transform .2s; font-size: 13px; }
.fold-head[aria-expanded="true"] .chev { transform: rotate(180deg); }
.fold-body { padding-top: 16px; }

.field { display: block; margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field-label { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1.5px solid var(--line-2); background: #fff; cursor: pointer;
  font: inherit; font-size: 13.5px; color: var(--ink-2);
  padding: 7px 14px; border-radius: 999px; transition: .16s;
}
.chip.on {
  border-color: transparent; background: var(--grad); color: #fff; font-weight: 600;
  box-shadow: 0 6px 14px -8px rgba(168, 84, 178, .8);
}
.chip .m-hint { display: block; font-size: 11.5px; opacity: .72; margin-top: 1px; }
.chip.on .m-hint { opacity: .9; }

.tip { font-size: 12.5px; color: var(--amber); margin: 10px 0 0; line-height: 1.6; }
.foot-note { font-size: 12px; color: var(--ink-3); line-height: 1.75; text-align: center; padding: 6px 8px 0; }
.foot-note b { color: var(--ink-2); }

.cta-spacer { height: 104px; }
.cta-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  max-width: 560px; margin: 0 auto;
  padding: 12px 16px calc(12px + var(--safe-b));
  background: linear-gradient(180deg, rgba(251, 247, 249, 0), #fbf7f9 26%);
}
.primary {
  width: 100%; border: 0; cursor: pointer;
  background: var(--grad); color: #fff;
  font: inherit; font-size: 16px; font-weight: 700; letter-spacing: .02em;
  padding: 14px 20px; border-radius: 14px;
  box-shadow: 0 10px 24px -12px rgba(168, 84, 178, .9);
  transition: transform .12s, opacity .16s;
}
.primary:active { transform: scale(.985); }
.primary:disabled { opacity: .5; box-shadow: none; cursor: default; }
.primary.big { padding: 16px 20px; font-size: 16.5px; border-radius: 16px; }
.cta-note { text-align: center; font-size: 12px; color: var(--ink-3); margin-top: 8px; }

.ghost-btn {
  border: 1.5px solid var(--line-2); background: #fff; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--ink-2);
  padding: 10px 16px; border-radius: 12px;
}
.ghost-btn:active { background: #f7f4fa; }

/* ────────── 报告页 ────────── */
.report-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.report-top .ghost-btn { font-size: 13.5px; padding: 7px 13px; }
.timer { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.badges { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.badge {
  font-size: 12.5px; font-weight: 600; padding: 6px 12px; border-radius: 999px;
  background: #fff; border: 1.5px solid var(--line-2); color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 5px;
}
.badge b { font-weight: 800; font-size: 14px; }
.badge.risk-none  { background: var(--ok-lt);     border-color: #bde5d2; color: #1e7a52; }
.badge.risk-watch { background: var(--amber-lt);  border-color: #f0d9ab; color: #a8701a; }
.badge.risk-high  { background: var(--danger-lt); border-color: #f5c2c8; color: #b52a3a; }
.badge.risk-urgent{ background: #fff;             border-color: var(--danger); color: var(--danger); }

.risk-banner {
  border-radius: 14px; padding: 15px 16px; margin-bottom: 16px;
  font-size: 14px; line-height: 1.72;
}
.risk-banner.high { background: var(--danger-lt); border: 1.5px solid #f3c3c9; color: #8f2432; }
.risk-banner.urgent {
  background: var(--danger); color: #fff; border: 0;
  box-shadow: 0 12px 28px -14px rgba(214, 59, 76, .9);
}
.risk-banner h3 { margin: 0 0 8px; font-size: 15.5px; font-weight: 800; }
.risk-banner p { margin: 0 0 6px; }
.risk-banner p:last-child { margin-bottom: 0; }
.risk-banner a { color: inherit; font-weight: 700; }

/* 报告被截断时的提示 —— 绝不能让用户以为那是完整报告 */
.trunc-note {
  margin-bottom: 14px; padding: 13px 15px;
  background: var(--warn-lt, #fdf4e3); border: 1.5px solid #edd9a8; border-radius: var(--radius);
  font-size: 13.5px; line-height: 1.7; color: #7a5a12;
}
.trunc-note b { color: #5d430c; }

/* 思考中的流 */
.thinking-wrap {
  margin-bottom: 16px; padding: 15px 15px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.thinking-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 14.5px; font-weight: 700; color: var(--violet); margin-bottom: 11px;
}
.thinking-head i {
  width: 8px; height: 8px; border-radius: 50%; background: var(--violet);
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: .25; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.15); } }

/* 不确定进度条：不知道还剩多久，就不假装知道 —— 只表示「在动」 */
.thinking-meter {
  height: 4px; border-radius: 3px; background: #eee7f6; overflow: hidden; margin-bottom: 11px;
}
.thinking-bar {
  width: 38%; height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, #b9a8ee, var(--violet));
  animation: slide 1.5s ease-in-out infinite;
}
@keyframes slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(265%); }
}
.thinking-hint {
  font-size: 13px; line-height: 1.65; color: var(--ink-2, #5b5166); margin-bottom: 10px;
}
.thinking-hint b { color: var(--violet); }
.thinking-text {
  max-height: 108px; overflow: hidden;
  font-size: 12.5px; line-height: 1.7; color: var(--ink-3);
  background: #faf8fd; border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px;
  white-space: pre-wrap; word-break: break-word;
  -webkit-mask-image: linear-gradient(180deg, #000 62%, transparent);
  mask-image: linear-gradient(180deg, #000 62%, transparent);
}

/* 本地渲染的「我看到的对话」—— 不再让模型重抄一遍 */
.seen-box {
  margin-bottom: 16px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.seen-head {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 14px 17px; border: 0; background: none;
  font: inherit; font-size: 14.5px; font-weight: 700; color: var(--ink); cursor: pointer;
  text-align: left;
}
.seen-head .chev { font-size: 13px; color: var(--ink-3); transition: transform .2s; }
.seen-head.open .chev { transform: rotate(180deg); }
.seen-head span:first-child { flex: 1; }
.seen-count { font-weight: 500; color: var(--ink-3); font-size: 13px; margin-left: 6px; }
.seen-body {
  padding: 0 17px 15px; font-size: 13.5px; line-height: 1.9;
  color: var(--ink-2, #4a4155); border-top: 1px solid var(--line); padding-top: 12px;
  max-height: 340px; overflow: auto; word-break: break-word;
}
.seen-body .me { color: #2f2a3a; }
.seen-body .ta { color: #6a6178; }
.seen-body .who { font-weight: 700; }

.report-actions { display: flex; gap: 10px; margin-top: 22px; }
.report-actions button { flex: 1; }

/* ────────── Markdown 排版 ────────── */
.md {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 17px; font-size: 15px; line-height: 1.82;
  word-break: break-word; overflow-wrap: anywhere;
}
.md:empty { display: none; }
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md h2 {
  font-size: 17.5px; font-weight: 800; letter-spacing: -.2px;
  margin: 30px 0 13px; padding-left: 11px; position: relative; line-height: 1.45;
}
.md h2::before {
  content: ""; position: absolute; left: 0; top: .28em; bottom: .28em; width: 4px;
  border-radius: 3px; background: var(--grad);
}
.md h3 { font-size: 15.5px; font-weight: 700; margin: 22px 0 10px; color: #3a2f47; }
.md p { margin: 0 0 13px; }
.md strong { font-weight: 700; color: #1c1723; }
.md em { font-style: normal; background: linear-gradient(180deg, transparent 62%, #fbe3ad 62%); padding: 0 1px; }
.md ul, .md ol { margin: 0 0 14px; padding-left: 21px; }
.md li { margin-bottom: 7px; }
.md li::marker { color: #c3aee0; }
.md blockquote {
  margin: 0 0 13px; padding: 10px 14px;
  background: var(--rose-lt); border-left: 3px solid #f0aec6; border-radius: 0 11px 11px 0;
  color: #7c3d55; font-size: 14.5px;
}
.md blockquote p:last-child { margin-bottom: 0; }
.md hr { border: 0; border-top: 1px dashed var(--line-2); margin: 22px 0; }
.md code {
  background: #f4f1f8; border-radius: 5px; padding: 1px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .89em; color: #6a4f9c;
}
.md .fold {
  border: 1px solid var(--line-2); border-radius: 12px; background: #fdfcfe;
  margin: 0 0 16px; overflow: hidden;
}
.md .fold > summary {
  cursor: pointer; list-style: none; padding: 11px 14px;
  font-size: 13.5px; font-weight: 600; color: var(--ink-2);
  display: flex; align-items: center; justify-content: space-between;
}
.md .fold > summary::-webkit-details-marker { display: none; }
/* 折叠箭头用 CSS 画，不用 ▾ 字符：那个字符在不同系统上会落到不同字体，
   安卓上实测会渲染成一个像「+」的怪符号。border 三角形是字体无关的。 */
.md .fold > summary::after {
  content: ""; flex: none; margin-left: 10px;
  width: 7px; height: 7px;
  border-right: 1.6px solid #a29aae;
  border-bottom: 1.6px solid #a29aae;
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform .2s;
}
.md .fold[open] > summary::after { transform: rotate(-135deg) translate(-2px, -2px); }
.md .fold[open] > summary { border-bottom: 1px dashed var(--line-2); }
.md .fold-body { padding: 12px 14px; font-size: 13.5px; line-height: 1.85; color: var(--ink-2); }
.md .fold-body p { margin: 0 0 4px; }

.cursor { display: none; }

/* ────────── 口令闸门 ────────── */
.gate {
  position: fixed; inset: 0; z-index: 90; display: flex;
  align-items: center; justify-content: center; padding: 24px;
  background: var(--bg);
  background-image: radial-gradient(900px 420px at 50% 0%, #fdeaf1 0%, rgba(253, 234, 241, 0) 60%);
}
.gate-inner { width: 100%; max-width: 340px; text-align: center; }
.gate-logo {
  display: inline-block; font-size: 13px; font-weight: 700; letter-spacing: .16em;
  color: #fff; background: var(--grad); padding: 5px 13px; border-radius: 999px; margin-bottom: 20px;
}
.gate-tip { color: var(--ink-2); font-size: 14.5px; margin: 0 0 18px; }
.gate input {
  width: 100%; text-align: center; letter-spacing: .1em;
  border: 1.5px solid var(--line-2); border-radius: 13px; background: #fff;
  padding: 14px; font: inherit; font-size: 16px; margin-bottom: 12px;
}
.gate input:focus { outline: none; border-color: #d5b6ea; box-shadow: 0 0 0 4px rgba(124, 107, 234, .09); }
.gate-err { color: var(--danger); font-size: 13px; min-height: 20px; margin: 12px 0 0; }

/* ────────── 遮罩 & 提示 ────────── */
.overlay {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  background: rgba(250, 247, 251, .84); backdrop-filter: blur(7px);
}
.overlay-inner { text-align: center; padding: 0 30px; }
.spinner {
  width: 30px; height: 30px; margin: 0 auto 16px;
  border: 2.5px solid #ece3f1; border-top-color: var(--rose);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.overlay-msg { font-size: 15px; font-weight: 600; }
.overlay-sub { margin-top: 8px; font-size: 12.5px; color: var(--ink-3); }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translateX(-50%);
  z-index: 95; max-width: min(88vw, 420px);
  background: rgba(30, 23, 38, .93); color: #fff;
  font-size: 13.5px; line-height: 1.6; text-align: center;
  padding: 11px 18px; border-radius: 12px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .5);
  animation: rise .22s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
