/* ==========================================================================
   智能医师助理 · 症状资料采集系统 · 样式系统
   风格取向：宣纸米底 / 黛绿主色 / 赭石点缀 / 细线分隔 / 衬线标题
   移动端优先，桌面端居中收窄
   ========================================================================== */

:root {
  --bg: #f1ebdf;
  --paper: #f8f4ec;
  --paper-2: #fffdf8;
  --ink: #262a24;
  --ink-2: #5c615a;
  --ink-3: #8d9189;
  --jade: #41604f;
  --jade-2: #2e4839;
  --jade-soft: #e8eee9;
  --clay: #a8623c;
  --clay-soft: #f6ece2;
  --gold: #b8995c;
  --line: rgba(38, 42, 36, 0.13);
  --line-2: rgba(38, 42, 36, 0.07);
  --danger: #a8443a;
  --font-serif: "Songti SC", "STSong", "Source Han Serif SC", "Noto Serif SC", "SimSun", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Helvetica Neue", Arial, sans-serif;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(38, 42, 36, 0.04), 0 8px 24px -14px rgba(38, 42, 36, 0.22);
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; overscroll-behavior-y: none; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.7;
  min-height: 100vh;
  background-image:
    radial-gradient(circle at 18% 8%, rgba(184, 153, 92, 0.07), transparent 42%),
    radial-gradient(circle at 88% 92%, rgba(65, 96, 79, 0.06), transparent 46%);
}

.wrap { width: 100%; max-width: 640px; margin: 0 auto; padding: 0 18px; }
.wrap-narrow { max-width: 520px; }

/* ---------------- 页头 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(241, 235, 223, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-2);
}
.topbar-in { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.seal {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  font-family: var(--font-serif); font-size: 19px; font-weight: 700; color: #fff;
  background: var(--clay);
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  letter-spacing: 0;
}
.brand-text b { display: block; font-family: var(--font-serif); font-size: 16px; letter-spacing: 3px; font-weight: 600; line-height: 1.2; }
.brand-text span { display: block; font-size: 11px; color: var(--ink-3); letter-spacing: 1px; }
.topbar-right { margin-left: auto; font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 10px; }
.link-btn { background: none; border: none; color: var(--jade); font-size: 13px; cursor: pointer; padding: 6px 2px; font-family: inherit; }

/* ---------------- 通用块 ---------------- */
.page { padding: 26px 0 48px; }
.card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 18px;
  margin-bottom: 16px;
}
.card-title {
  font-family: var(--font-serif); font-size: 16px; letter-spacing: 2px;
  color: var(--jade-2); margin: 0 0 14px; font-weight: 600;
  display: flex; align-items: center; gap: 9px;
}
.card-title::before { content: ""; width: 3px; height: 15px; background: var(--clay); border-radius: 2px; }
.card-title small { margin-left: auto; font-family: var(--font-sans); font-size: 11px; color: var(--ink-3); letter-spacing: 0; font-weight: 400; }

.hero { text-align: center; padding: 6px 0 22px; }
.hero h1 { font-family: var(--font-serif); font-size: 26px; letter-spacing: 6px; margin: 0 0 10px; color: var(--ink); font-weight: 600; }
.hero p { margin: 0 auto; max-width: 30em; color: var(--ink-2); font-size: 13.5px; }
.hero .rule { width: 46px; height: 1px; background: var(--gold); margin: 16px auto; }

.notice {
  background: var(--clay-soft);
  border-left: 3px solid var(--clay);
  padding: 12px 14px; border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 12.5px; color: #6d4a33; line-height: 1.75;
}
.notice b { color: #5c3b26; }
.notice.ghost { background: rgba(255, 255, 255, 0.55); border-left-color: var(--line); color: var(--ink-2); }

.steps { display: flex; gap: 0; margin: 0 0 18px; }
.step { flex: 1; text-align: center; font-size: 11.5px; color: var(--ink-3); position: relative; padding-top: 20px; }
.step::before { content: ""; position: absolute; top: 5px; left: 50%; transform: translateX(-50%); width: 9px; height: 9px; border-radius: 50%; background: var(--paper-2); border: 1.5px solid var(--line); }
.step.on::before { background: var(--jade); border-color: var(--jade); }
.step.on { color: var(--jade); }
.step .bar { position: absolute; top: 9px; left: 50%; width: 100%; height: 1.5px; background: var(--line); z-index: -1; }
.step:last-child .bar { display: none; }

/* ---------------- 表单 ---------------- */
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; letter-spacing: 0.5px; }
.field > label .req { color: var(--clay); margin-left: 2px; }
.field input[type="text"], .field input[type="tel"], .field input[type="number"], .field textarea, .field select {
  width: 100%; border: none; border-bottom: 1px solid var(--line); background: transparent;
  padding: 9px 2px; font-size: 16px; font-family: inherit; color: var(--ink); outline: none;
  transition: border-color .18s;
}
.field input:focus, .field textarea:focus { border-bottom-color: var(--jade); }
.field textarea { resize: vertical; min-height: 62px; line-height: 1.7; }
.field .hint { font-size: 11.5px; color: var(--ink-3); margin-top: 5px; }
.field .err { font-size: 11.5px; color: var(--danger); margin-top: 5px; display: none; }
.field.has-err input, .field.has-err textarea { border-bottom-color: var(--danger); }
.field.has-err .err { display: block; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.segmented { display: flex; gap: 8px; }
.segmented button {
  flex: 1; padding: 9px 4px; border: 1px solid var(--line); background: var(--paper);
  border-radius: var(--radius); font-size: 14px; color: var(--ink-2); cursor: pointer;
  font-family: inherit; transition: all .15s;
}
.segmented button.on { border-color: var(--jade); background: var(--jade-soft); color: var(--jade-2); font-weight: 600; }

.btn {
  display: block; width: 100%; padding: 13px 16px; border: none; border-radius: var(--radius);
  background: var(--jade); color: #f6f5f0; font-size: 15px; letter-spacing: 4px; font-family: var(--font-serif);
  cursor: pointer; transition: background .18s, transform .08s; text-align: center;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--jade); border: 1px solid var(--jade); letter-spacing: 2px; }
.btn.clay { background: var(--clay); }
.btn.sm { padding: 9px 14px; font-size: 13px; letter-spacing: 2px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ---------------- 采集页 ---------------- */
.progress-box { padding: 14px 0 6px; }
.progress-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); margin-bottom: 7px; }
.progress-head b { color: var(--jade-2); font-weight: 600; }
.progress-track { height: 3px; background: rgba(38, 42, 36, 0.09); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--jade), var(--gold)); transition: width .5s ease; }
.dim-chips { display: flex; flex-wrap: nowrap; gap: 5px; margin-top: 9px; overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; padding-bottom: 2px; scroll-snap-type: x proximity; }
.dim-chips::-webkit-scrollbar { display: none; }
.dim-chip { font-size: 10.5px; padding: 3px 8px; border-radius: 10px; background: var(--jade-soft); color: var(--jade-2); border: 1px solid rgba(65, 96, 79, 0.16); white-space: nowrap; flex: none; scroll-snap-align: start; }
.dim-chip.pending { background: transparent; color: var(--ink-3); border-color: var(--line); }

.chat { padding: 16px 0 200px; }
.msg { margin-bottom: 14px; }
.q-card {
  background: var(--paper-2); border: 1px solid var(--line); border-left: 3px solid var(--jade);
  border-radius: 0 var(--radius) var(--radius) 0; padding: 15px 16px 12px; box-shadow: var(--shadow);
}
.q-card .q-no { font-size: 11px; color: var(--gold); letter-spacing: 1px; margin-bottom: 5px; font-family: var(--font-serif); }
.q-card .q-text { font-size: 16px; line-height: 1.75; color: var(--ink); margin: 0; }
.q-card .q-foot { margin-top: 11px; padding-top: 9px; border-top: 1px dashed var(--line-2); font-size: 11px; color: var(--ink-3); }
.q-card.filtered { border-left-color: var(--clay); }
.filter-flag { font-size: 11px; color: var(--clay); background: var(--clay-soft); padding: 3px 8px; border-radius: 3px; display: inline-block; margin-bottom: 8px; }

.a-chip {
  margin-left: auto; max-width: 86%; background: var(--jade); color: #f4f3ee;
  padding: 9px 13px; border-radius: 12px 12px 3px 12px; font-size: 14.5px; line-height: 1.6;
  width: fit-content; word-break: break-word;
}
.a-meta { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 5px; }
.a-meta .edit-link { font-size: 11.5px; color: var(--jade); background: none; border: none; cursor: pointer; font-family: inherit; padding: 2px 0; }
.a-meta .t { font-size: 11px; color: var(--ink-3); }

.sys-note { text-align: center; font-size: 11.5px; color: var(--ink-3); padding: 6px 0; }

/* 选项控件 */
.options { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.opt {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 13px; min-height: 48px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper);
  cursor: pointer; font-size: 14.5px; color: var(--ink); transition: all .15s; line-height: 1.55;
}
.opt input { margin: 3px 0 0; accent-color: var(--jade); width: 16px; height: 16px; flex: none; }
.opt.on { border-color: var(--jade); background: var(--jade-soft); }
.opt .mk { width: 15px; height: 15px; border: 1.5px solid var(--ink-3); border-radius: 50%; flex: none; margin-top: 4px; position: relative; }
.opt.on .mk { border-color: var(--jade); background: var(--jade); }
.opt.on .mk::after { content: ""; position: absolute; inset: 3.5px; background: #fff; border-radius: 50%; }
.opt.multi .mk { border-radius: 3px; }
.opt.multi.on .mk::after { border-radius: 1px; }

/* 输入区 */
.answer-box {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  background: rgba(248, 244, 236, 0.97); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding: 10px 18px calc(10px + env(safe-area-inset-bottom));
}
.answer-box .inner { max-width: 640px; margin: 0 auto; }
.answer-box textarea {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-2);
  padding: 11px 12px; font-size: 16px; font-family: inherit; resize: none; outline: none; min-height: 46px; max-height: 120px; line-height: 1.6;
}
.answer-box textarea:focus { border-color: var(--jade); }
.answer-actions { display: flex; gap: 9px; margin-top: 9px; align-items: center; }
.answer-actions .btn { flex: 1; }
.answer-actions .btn.ghost { flex: none; width: auto; padding: 13px 14px; }
.answer-hint { font-size: 11px; color: var(--ink-3); margin-top: 6px; text-align: center; }

/* 舌苔上传 */
.tongue-card { border: 1px dashed var(--gold); background: #fdfaf3; border-radius: var(--radius); padding: 14px; margin-top: 12px; }
.tongue-card h4 { font-family: var(--font-serif); font-size: 14.5px; margin: 0 0 8px; color: var(--jade-2); letter-spacing: 1px; }
.tongue-tips { margin: 0 0 11px; padding-left: 18px; font-size: 12.5px; color: var(--ink-2); line-height: 1.85; }
.tongue-tips li { margin-bottom: 1px; }
.upload-row { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.file-btn {
  display: inline-block; padding: 10px 16px; border: 1px solid var(--jade); color: var(--jade);
  border-radius: var(--radius); font-size: 13.5px; cursor: pointer; background: transparent;
}
.file-btn input { display: none; }
.thumb-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.thumb { position: relative; }
.thumb img { width: 66px; height: 66px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); display: block; }
.thumb .x { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; background: var(--danger); color: #fff; border: none; font-size: 13px; line-height: 1; cursor: pointer; }

/* 完成页 */
.done-seal { text-align: center; padding: 10px 0 4px; }
.done-seal .circle {
  width: 76px; height: 76px; margin: 0 auto 14px; border-radius: 50%; border: 2px solid var(--jade);
  display: grid; place-items: center; color: var(--jade); font-family: var(--font-serif); font-size: 24px; letter-spacing: 2px;
  background: var(--jade-soft);
}
.done-seal h1 { font-family: var(--font-serif); font-size: 22px; letter-spacing: 5px; margin: 0 0 8px; color: var(--jade-2); }
.done-seal .no { font-family: "Menlo", Consolas, monospace; font-size: 13px; color: var(--clay); letter-spacing: 1px; }

/* 汇总表 */
.summary { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.summary .sec-row { background: var(--jade-soft); color: var(--jade-2); font-family: var(--font-serif); letter-spacing: 2px; font-size: 13.5px; }
.summary table { width: 100%; border-collapse: collapse; }
.summary td { border-bottom: 1px solid var(--line-2); border-right: 1px solid var(--line-2); padding: 9px 11px; font-size: 13.5px; vertical-align: top; line-height: 1.7; }
.summary td.k { width: 92px; color: var(--ink-2); background: #faf7f1; }
.summary tr:last-child td { border-bottom: none; }
.summary tr.sec-row td { background: var(--jade-soft); border-right: none; font-weight: 600; }
.pending-box { background: #fbf6ec; border: 1px dashed #d9c7a3; color: #7a5a2c; padding: 10px 12px; border-radius: var(--radius); font-size: 12.5px; margin-top: 14px; }

/* 后台 */
.admin-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.admin-bar input[type="text"], .admin-bar input[type="password"] {
  flex: 1; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-2);
  padding: 10px 12px; font-size: 14.5px; font-family: inherit; outline: none;
}
.admin-bar input:focus { border-color: var(--jade); }
.list-item {
  display: block; width: 100%; text-align: left; background: var(--paper-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px 14px; margin-bottom: 10px; cursor: pointer; font-family: inherit;
}
.list-item:hover { border-color: var(--jade); }
.list-item .row1 { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.list-item .nm { font-size: 15.5px; font-weight: 600; }
.list-item .no { font-family: "Menlo", Consolas, monospace; font-size: 11px; color: var(--ink-3); }
.list-item .row2 { font-size: 12.5px; color: var(--ink-2); margin-top: 4px; }
.tag { font-size: 11px; padding: 1.5px 7px; border-radius: 9px; border: 1px solid; white-space: nowrap; }
.tag.collecting { color: var(--clay); border-color: rgba(168, 98, 60, .35); background: var(--clay-soft); }
.tag.completed { color: var(--jade); border-color: rgba(65, 96, 79, .3); background: var(--jade-soft); }
.tag.abandoned { color: var(--ink-3); border-color: var(--line); }

.detail-kv { display: grid; grid-template-columns: 78px 1fr; gap: 6px 12px; font-size: 13.5px; }
.detail-kv dt { color: var(--ink-3); font-size: 12.5px; }
.detail-kv dd { margin: 0; }

.dlg-record { border: 1px solid var(--line-2); border-radius: 4px; padding: 9px 11px; margin-bottom: 8px; background: var(--paper); font-size: 13.5px; }
.dlg-record .q { color: var(--ink-2); font-size: 12.5px; margin-bottom: 3px; }
.dlg-record .a { color: var(--ink); }
.dlg-record.sys { background: var(--clay-soft); color: #6d4a33; font-size: 12.5px; }

.photo-grid { display: flex; gap: 10px; flex-wrap: wrap; }
.photo-grid a { display: block; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; background: #fff; }
.photo-grid img { width: 110px; height: 110px; object-fit: cover; display: block; }

.empty { text-align: center; color: var(--ink-3); font-size: 13.5px; padding: 36px 0; }
.muted { color: var(--ink-3); font-size: 12.5px; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mb12 { margin-bottom: 12px; }
.center { text-align: center; }
.err-text { color: var(--danger); font-size: 12.5px; margin-top: 8px; }

.foot-note { margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--line-2); font-size: 11.5px; color: var(--ink-3); line-height: 1.85; text-align: center; }
.foot-note b { color: var(--ink-2); }

@media (max-width: 420px) {
  .hero h1 { font-size: 22px; letter-spacing: 4px; }
  .row2 { grid-template-columns: 1fr; gap: 0; }
}
@media (min-width: 720px) {
  body { font-size: 15.5px; }
  .card { padding: 26px 26px; }
}

/* ==========================================================================
   移动端与流畅度优化
   ========================================================================== */

/* 新消息淡入 */
@keyframes riseIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.msg { animation: riseIn .28s cubic-bezier(.22,.61,.36,1) both; }
.sys-note { animation: riseIn .28s ease both; }

/* 顶部栏在滚动时更有层次 */
.topbar { transition: box-shadow .25s ease, background .25s ease; }
.topbar.stuck { box-shadow: 0 1px 0 rgba(38,42,36,.08), 0 8px 20px -16px rgba(38,42,36,.5); }

/* 选项与按钮的按压反馈 */
.opt, .btn, .segmented button, .file-btn { transition: transform .12s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease; }
.opt:active, .btn:active, .segmented button:active, .file-btn:active { transform: scale(.985); }

/* 作答区提示 */
.answer-tip {
  font-size: 11.5px; color: var(--ink-3); margin: 7px 2px 0;
  padding-left: 10px; border-left: 2px solid var(--gold); line-height: 1.5;
}

/* 舌照卡片细节 */
.tongue-card .thumb-row { margin-top: 10px; }
.tongue-card .thumb img { width: 78px; height: 78px; }
.file-btn { user-select: none; -webkit-user-select: none; }

/* 顶栏与底部条的安全区 */
@supports (padding: max(0px)) {
  .topbar-in { padding-top: max(12px, env(safe-area-inset-top)); }
  .answer-box .inner { padding-bottom: env(safe-area-inset-bottom); }
  .page { padding-bottom: max(48px, calc(48px + env(safe-area-inset-bottom))); }
}

/* 移动端更紧凑的间距 */
@media (max-width: 420px) {
  .card { padding: 18px 15px; }
  .q-card { padding: 14px 14px 11px; }
  .q-card .q-text { font-size: 15.5px; }
  .hero { padding: 2px 0 18px; }
  .wrap { padding: 0 14px; }
  .topbar-in { padding: 10px 0; }
  .notice { padding: 11px 12px; }
  .answer-box { padding: 9px 14px calc(9px + env(safe-area-inset-bottom)); }
  .btn { padding: 12px 14px; letter-spacing: 3px; }
  .a-chip { max-width: 88%; font-size: 14px; }
}

/* 大屏时限制正文宽度、放大可读性 */
@media (min-width: 1024px) {
  .chat { max-width: 720px; margin: 0 auto; }
  .progress-box { max-width: 720px; margin: 0 auto; }
}

/* 无障碍：尊重系统的减弱动效设置 */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}