:root {
  --paper: #f7f2ea;
  --paper-2: #fffdf9;
  --ink: #221d18;
  --ink-2: #5c5248;
  --muted: #8b8073;
  --line: #e4dbcd;
  --cinnabar: #b8402c;
  --cinnabar-soft: #f6e4de;
  --jade: #3d6b56;
  --jade-soft: #e3ede7;
  --amber: #b47a1f;
  --shadow: 0 12px 30px rgba(70, 50, 30, 0.08);
  --r: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  background-image:
    radial-gradient(1200px 600px at 50% -10%, #fffaf2 0%, rgba(255, 250, 242, 0) 60%),
    radial-gradient(800px 400px at 110% 110%, #efe6d8 0%, rgba(239, 230, 216, 0) 60%);
  background-attachment: fixed;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: 18px 18px 48px;
}

/* 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 2px 18px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.seal {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  background: var(--cinnabar);
  color: #fff;
  border-radius: 12px;
  font-family: "Songti SC", "Noto Serif CJK SC", serif;
  font-size: 22px;
  box-shadow: 0 6px 14px rgba(184, 64, 44, 0.28);
}
.brand h1 {
  font-family: "Songti SC", "Noto Serif CJK SC", Georgia, serif;
  font-size: 20px;
  letter-spacing: 0.06em;
  margin: 0;
  font-weight: 600;
}
.brand .sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); letter-spacing: 0.08em; }
.tag {
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 4px 8px;
  border-radius: 999px;
}

/* 面板 */
.panel { display: none; animation: fade 0.35s ease; }
.panel.active { display: block; }
@keyframes fade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.lead {
  font-family: "Songti SC", "Noto Serif CJK SC", Georgia, serif;
  font-size: 22px;
  line-height: 1.5;
  margin: 6px 0 10px;
  letter-spacing: 0.02em;
}
.muted { color: var(--muted); font-size: 14px; line-height: 1.75; margin: 0 0 18px; }
.hint { color: var(--cinnabar); font-size: 13px; min-height: 18px; margin: 10px 0 0; }

.linkbtn {
  display: inline-block;
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--jade);
  font-size: 13px;
  letter-spacing: 0.04em;
  border-bottom: 1px solid rgba(61, 107, 86, 0.35);
  cursor: pointer;
  font-family: inherit;
}

/* 拍摄指引 */
.guide {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  counter-reset: g;
}
.guide li {
  counter-increment: g;
  position: relative;
  padding: 13px 0 13px 44px;
  border-bottom: 1px solid var(--line);
}
.guide li:first-child { border-top: 1px solid var(--line); }
.guide li::before {
  content: counter(g, decimal-leading-zero);
  position: absolute;
  left: 0; top: 14px;
  font-family: Georgia, serif;
  font-size: 13px;
  color: var(--cinnabar);
  letter-spacing: 0.06em;
}
.guide b { display: block; font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.guide span { color: var(--muted); font-size: 13px; line-height: 1.65; }

/* 按钮 */
.actions { display: flex; gap: 10px; margin-top: 8px; }
.btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}
.btn:active { transform: scale(0.985); }
.btn.primary {
  background: var(--ink);
  color: var(--paper-2);
  box-shadow: var(--shadow);
}
.btn.primary:hover { background: #34281f; }
.btn.ghost {
  background: var(--paper-2);
  color: var(--ink);
  border-color: var(--line);
}
.btn.small { flex: 0 0 auto; padding: 8px 14px; font-size: 13px; border-radius: 10px; background: var(--paper-2); border-color: var(--line); }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

/* 取景 */
.viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: var(--r);
  overflow: hidden;
  background: #16120f;
  box-shadow: var(--shadow);
}
.viewport video { width: 100%; height: 100%; object-fit: cover; }
.guide-oval {
  position: absolute;
  left: 50%; top: 54%;
  width: 62%; height: 46%;
  transform: translate(-50%, -50%);
  border: 2px dashed rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.28);
}
.viewhint {
  position: absolute;
  bottom: 14px; left: 0; right: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  letter-spacing: 0.08em;
}

/* 加载 */
#loading { text-align: center; padding: 64px 0; }
.loader { display: flex; justify-content: center; gap: 8px; margin-bottom: 18px; }
.loader span {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--cinnabar);
  animation: pulse 1.1s infinite ease-in-out;
}
.loader span:nth-child(2) { animation-delay: 0.16s; }
.loader span:nth-child(3) { animation-delay: 0.32s; }
@keyframes pulse {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-5px); }
}

/* 结果 */
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.shot {
  margin: 4px 0 16px;
  background: var(--paper-2);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.shot img { display: block; width: 100%; }
.shot figcaption {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 10px 14px;
  font-size: 11.5px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}
.dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.dot.tip { background: #f57856; }
.dot.edge { background: #78be78; }
.dot.center { background: #ebbe3c; }
.dot.back { background: #dc8cca; }

.chips {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.chip {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}
.chip .k { font-size: 11.5px; color: var(--muted); letter-spacing: 0.06em; }
.chip .v {
  margin-top: 6px;
  font-size: 16px;
  font-weight: 600;
  font-family: "Songti SC", "Noto Serif CJK SC", serif;
}
.chip.warn { border-color: #ecd6cd; background: #fdf7f3; }
.chip.good { border-color: #d8e6dd; background: #f6fbf7; }

.summary {
  background: var(--jade-soft);
  border-left: 3px solid var(--jade);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 14.5px;
  line-height: 1.85;
  margin-bottom: 16px;
}
.summary.healthy { background: var(--jade-soft); }
.summary.abnormal { background: var(--cinnabar-soft); border-color: var(--cinnabar); }

.warnings {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}
.warn-line {
  font-size: 13px;
  color: #8a5a12;
  background: #fdf3e2;
  border: 1px solid #f0dfc0;
  border-radius: 10px;
  padding: 10px 12px;
  line-height: 1.6;
}
.danger {
  background: #fdeceb;
  border: 1px solid #f3c9c4;
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.danger h4 { margin: 0 0 6px; font-size: 15px; color: #97281a; }
.danger p { margin: 0; font-size: 13.5px; line-height: 1.75; color: #7d332a; }

.section-title {
  font-family: "Songti SC", "Noto Serif CJK SC", serif;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.06em;
  margin: 26px 0 12px;
  padding-left: 10px;
  border-left: 3px solid var(--cinnabar);
}

.cards { display: grid; gap: 10px; }
.card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}
.card .head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.card .region { font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }
.card .badge {
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--cinnabar-soft);
  color: var(--cinnabar);
  font-weight: 600;
}
.card p { margin: 0; font-size: 14px; line-height: 1.85; color: #35302a; }

.next { margin: 0; padding-left: 18px; }
.next li { font-size: 13.5px; line-height: 1.85; color: var(--ink-2); margin-bottom: 8px; }

.cta {
  margin-top: 22px;
  padding: 18px;
  border-radius: var(--r);
  background: linear-gradient(135deg, #2f2721, #4a3a2c);
  color: #f6efe4;
  box-shadow: var(--shadow);
}
.cta h4 { margin: 0 0 8px; font-size: 16px; font-family: "Songti SC", serif; letter-spacing: 0.04em; }
.cta p { margin: 0 0 14px; font-size: 13px; line-height: 1.7; color: rgba(246, 239, 228, 0.78); }
.cta .btn { width: 100%; background: var(--cinnabar); color: #fff; }

.disclaimer {
  margin: 22px 0 0;
  font-size: 11.5px;
  line-height: 1.75;
  color: var(--muted);
}

.debug { margin-top: 20px; }
.debug summary {
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  letter-spacing: 0.06em;
}
.debug pre {
  font-size: 11px;
  line-height: 1.6;
  color: var(--ink-2);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  overflow: auto;
  max-height: 260px;
}

/* ---------------- 首页双入口 ---------------- */
.brand-btn {
  border: 0;
  background: none;
  padding: 0;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
}
.brand-text { display: block; }

.mode-card {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--paper-2);
  padding: 20px 54px 20px 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.mode-card:active { transform: scale(0.99); }
.mode-card.fun { border-top: 3px solid var(--cinnabar); }
.mode-card.consult { border-top: 3px solid var(--jade); }
.mode-badge {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.12em;
  padding: 3px 9px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.mode-card.fun .mode-badge { background: var(--cinnabar-soft); color: var(--cinnabar); }
.mode-card.consult .mode-badge { background: var(--jade-soft); color: var(--jade); }
.mode-card strong {
  display: block;
  font-family: "Songti SC", "Noto Serif CJK SC", serif;
  font-size: 19px;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}
.mode-desc { display: block; font-size: 13px; line-height: 1.75; color: var(--muted); }
.mode-arrow {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: var(--muted);
}
.home-note {
  margin-top: 20px;
  padding: 16px 18px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: rgba(255, 253, 249, 0.6);
}
.home-note p { margin: 0 0 8px; font-size: 12.5px; line-height: 1.75; color: var(--ink-2); }
.home-note p:last-child { margin-bottom: 0; }

.backlink {
  border: 0;
  background: none;
  padding: 0;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.04em;
}
.backlink:hover { color: var(--ink); }

/* ---------------- 趣味结果 ---------------- */
.persona {
  position: relative;
  margin: 6px 0 18px;
  padding: 22px 20px;
  border-radius: var(--r);
  background: linear-gradient(140deg, #2f2721, #4a3a2c);
  color: #f6efe4;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.persona::after {
  content: "舌";
  position: absolute;
  right: -8px;
  bottom: -26px;
  font-family: "Songti SC", serif;
  font-size: 110px;
  color: rgba(247, 242, 234, 0.07);
  pointer-events: none;
}
.persona-label { font-size: 11px; letter-spacing: 0.18em; color: rgba(246, 239, 228, 0.6); }
.persona-name {
  margin: 8px 0 2px;
  font-family: "Songti SC", "Noto Serif CJK SC", serif;
  font-size: 30px;
  letter-spacing: 0.04em;
  color: #fbf3e6;
}
.persona-sub { margin: 0 0 12px; font-size: 13px; color: var(--cinnabar-soft); letter-spacing: 0.06em; }
.persona-desc { margin: 0; font-size: 13.5px; line-height: 1.85; color: rgba(246, 239, 228, 0.85); }

.face-card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}
.face-card .muted { margin-bottom: 10px; }
.face-result { display: flex; gap: 12px; align-items: flex-start; }
.face-result img {
  width: 104px;
  height: 104px;
  object-fit: cover;
  border-radius: 12px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
}
.face-result strong {
  display: block;
  font-family: "Songti SC", serif;
  font-size: 17px;
  margin-bottom: 6px;
}
.face-result p { margin: 0 0 6px; font-size: 13px; line-height: 1.75; color: var(--ink-2); }

.share { display: flex; gap: 10px; margin-top: 22px; }

/* ---------------- 诊疗辅助表单 ---------------- */
.upload-card {
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: var(--paper-2);
  padding: 16px;
  margin-bottom: 6px;
}
.upload-empty p { margin: 0 0 12px; font-size: 13px; color: var(--muted); line-height: 1.7; }
.upload-empty .actions { margin-top: 0; }
.upload-preview { position: relative; margin: 0; }
.upload-preview img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 12px;
}
.upload-preview .btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 253, 249, 0.92);
}

.symptom-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}
.sym-chip {
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.sym-chip.on {
  border-color: var(--jade);
  background: var(--jade);
  color: #fff;
}
.sym-chip.flag { border-style: dashed; }
.sym-chip.flag.on { background: var(--cinnabar); border-color: var(--cinnabar); }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-2);
  padding: 12px 14px;
  font-size: 14.5px;
  font-family: inherit;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease;
}
.field select { -webkit-appearance: none; appearance: none; }
.field input:focus,
.field textarea:focus,
.field select:focus { border-color: var(--jade); }
.field textarea { resize: vertical; line-height: 1.7; }

/* 首页历史入口 */
.link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper-2);
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.link-row .count { color: var(--muted); font-size: 12px; margin-left: 4px; }

/* 历史记录 */
.hist-list { display: grid; gap: 12px; margin-bottom: 16px; }
.hist-item {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.hist-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.hist-title b {
  display: block;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 3px;
}
.hist-time { font-size: 11.5px; color: var(--muted); letter-spacing: 0.03em; }
.hist-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.hist-main { display: flex; gap: 12px; align-items: flex-start; }
.hist-thumb {
  width: 74px;
  height: 74px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  flex: 0 0 auto;
  background: #efe8dc;
}
.hist-summary {
  margin: 0 0 6px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hist-extra { margin: 0; font-size: 11.5px; color: var(--muted); }
.hist-details { margin-top: 12px; }
.hist-details summary {
  font-size: 12.5px;
  color: var(--jade);
  cursor: pointer;
  letter-spacing: 0.03em;
}
.hist-details .report-copy { margin-top: 10px; max-height: 200px; }
.hist-details .field { margin-top: 10px; margin-bottom: 10px; }
.hist-details .actions { gap: 8px; }
.hist-details .btn.small { flex: 1; }

/* ---------------- 诊疗报告 ---------------- */
.report-block { margin-bottom: 6px; }
.report-summary {
  margin: 0;
  padding: 14px 16px;
  background: var(--jade-soft);
  border-left: 3px solid var(--jade);
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.9;
}

.feature-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.feature-table th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(228, 219, 205, 0.25);
}
.feature-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  line-height: 1.6;
  color: var(--ink-2);
  vertical-align: top;
}
.feature-table tr:last-child td { border-bottom: 0; }
.feature-table td b { color: var(--ink); }

.stat-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.pill {
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #efe8dc;
  color: var(--ink-2);
  letter-spacing: 0.04em;
}
.pill.good { background: var(--jade-soft); color: var(--jade); }
.pill.warn { background: #fdf0e0; color: #94631a; }

.corr-list { display: grid; gap: 10px; }
.corr {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.corr.conflict { border-color: #ecd6cd; background: #fdf7f3; }
.corr-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}
.corr p { margin: 0; font-size: 12.5px; line-height: 1.75; color: var(--ink-2); }

.report-copy {
  margin: 0 0 12px;
  padding: 14px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.75;
  color: var(--ink-2);
  white-space: pre-wrap;
  max-height: 300px;
  overflow: auto;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
}

/* 面部取景 */
.guide-oval.face-mode {
  width: 72%;
  height: 70%;
  top: 46%;
  border-radius: 46% 46% 42% 42%;
}
.viewport.face-frame { aspect-ratio: 3 / 4; }

/* Toast */
#toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translate(-50%, 16px);
  background: rgba(34, 29, 24, 0.92);
  color: #f7f2ea;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 560px) {
  .app { padding-top: 32px; }
  .chips { grid-template-columns: repeat(4, 1fr); }
}
