/* 性格与潜能实验室 · H5 样式
 * 视觉：纸张 + 墨色 + 硬边。零圆角、零模糊阴影，靠字号与分割线建立层级。
 * 基准 390px，适配 320px 窄屏与桌面。
 */

:root {
  --paper: #f4f0e6;
  --paper-2: #ebe3d3;
  --ink: #191512;
  --ink-2: #453d33;
  --ink-3: #7b705f;
  --line: rgba(25, 21, 18, 0.16);
  --line-strong: rgba(25, 21, 18, 0.72);
  --accent: #191512;
  --accent-soft: #ede7da;
  --serif: "Songti SC", "Source Han Serif SC", "Noto Serif SC", "STSong", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --pad: clamp(16px, 5.2vw, 24px);
  --bar: calc(64px + env(safe-area-inset-bottom, 0px));
}

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

html { background: var(--paper); }

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* 纸纹：极轻的噪点，避免大面积纯色的塑料感 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.32'/%3E%3C/svg%3E");
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 var(--pad) 40px;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }

/* ---------- 通用小件 ---------- */

.rule { height: 1.5px; background: var(--ink); }
.hair { height: 1px; background: var(--line); }

.caps {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--ink-3);
}

.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--accent);
  vertical-align: middle;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  padding: 0 20px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.06em;
  border: 1.5px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.32; pointer-events: none; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.sm { min-height: 44px; font-size: 14px; }

.chev { font-family: var(--serif); font-size: 17px; line-height: 1; }

/* ---------- 首页 ---------- */

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 22px 0 10px;
  border-bottom: 1.5px solid var(--ink);
}
.masthead .name {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.masthead .issue { font-size: 10.5px; letter-spacing: 0.16em; color: var(--ink-3); }

.hero { padding: 26px 0 24px; }
.hero h1 {
  font-family: var(--serif);
  font-size: clamp(27px, 8.2vw, 36px);
  font-weight: 700;
  line-height: 1.34;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.hero h1 em { font-style: normal; box-shadow: inset 0 -0.42em 0 var(--accent-soft); }
.hero p {
  margin-top: 12px;
  font-size: 13.5px;
  line-height: 1.85;
  color: var(--ink-3);
  max-width: 30em;
}

.list { border-top: 1.5px solid var(--ink); }

.card {
  position: relative;
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 12px;
  align-items: center;
  padding: 19px 0 18px 12px;
  border-bottom: 1px solid var(--line);
  transition: background 0.16s ease, padding-left 0.16s ease;
}
.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.16s ease;
}
.card:active { background: var(--accent-soft); padding-left: 16px; }
.card:active::before { opacity: 1; }

.card .no {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  letter-spacing: -0.02em;
}
.card .no small {
  display: block;
  font-family: var(--sans);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--ink-3);
  margin-top: 5px;
}
.card h3 {
  font-family: var(--serif);
  font-size: 19.5px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -0.01em;
}
.card .sub {
  margin-top: 5px;
  font-size: 12.3px;
  line-height: 1.65;
  color: var(--ink-3);
}
.card .meta {
  display: flex;
  gap: 10px;
  margin-top: 9px;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}
.card .meta span { display: flex; align-items: center; gap: 5px; }
.card .go {
  margin-left: auto;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  white-space: nowrap;
}

.foot { margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--line); }
.foot p { font-size: 11.5px; line-height: 1.9; color: var(--ink-3); }
.foot p + p { margin-top: 4px; }

/* ---------- 介绍屏 ---------- */

.intro { padding-bottom: calc(var(--bar) + 24px); }
.intro { position: relative; }
.intro-mark {
  position: absolute;
  right: -14px;
  bottom: 44px;
  z-index: 0;
  font-family: var(--serif);
  font-size: clamp(150px, 46vw, 210px);
  font-weight: 700;
  line-height: 0.8;
  letter-spacing: -0.05em;
  color: transparent;
  -webkit-text-stroke: 1px rgba(25, 21, 18, 0.09);
  pointer-events: none;
  user-select: none;
}
.intro-top, .intro-body { position: relative; z-index: 1; }
.intro-top { display: flex; align-items: center; justify-content: space-between; padding: 18px 0 0; }
.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-3);
  padding: 6px 0;
}
.intro-body { padding: 30px 0 0; }
.intro-body h1 {
  font-family: var(--serif);
  font-size: clamp(29px, 8.8vw, 38px);
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin-top: 14px;
}
.intro-body .lede {
  margin-top: 16px;
  font-size: 14.6px;
  line-height: 1.95;
  color: var(--ink-2);
}
.intro-specs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 26px 0 0;
  border-top: 1.5px solid var(--ink);
  border-bottom: 1px solid var(--line);
}
.intro-specs div { padding: 14px 0; }
.intro-specs div + div { border-left: 1px solid var(--line); padding-left: 14px; }
.intro-specs b {
  display: block;
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.2;
}
.intro-specs span { font-size: 10.5px; letter-spacing: 0.1em; color: var(--ink-3); }

.note {
  margin-top: 22px;
  padding: 14px 15px;
  background: rgba(25, 21, 18, 0.035);
  border-left: 2px solid var(--line-strong);
  font-size: 12px;
  line-height: 1.85;
  color: var(--ink-3);
}

.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 10px var(--pad) calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--paper);
  border-top: 1.5px solid var(--ink);
}
.bottom-bar .inner { max-width: 560px; margin: 0 auto; display: flex; gap: 10px; }
/* 底部有常驻按钮时，正文要给按钮让出空间，别被盖住半行字 */
body.has-bar .wrap { padding-bottom: calc(106px + env(safe-area-inset-bottom, 0px)); }

/* ---------- 答题页 ---------- */

.qhead {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  padding: 12px 0 0;
}
.qhead .row { display: flex; align-items: center; justify-content: space-between; padding-bottom: 10px; }
.qhead .cnt {
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.06em;
}
.qhead .cnt b { font-size: 21px; }
.qhead .cnt span { color: var(--ink-3); font-size: 12px; }
.qhead .tag { font-size: 10.5px; letter-spacing: 0.14em; color: var(--ink-3); }

.ticks { display: flex; gap: 4px; padding-bottom: 12px; }
.ticks i { flex: 1; height: 3px; background: rgba(25, 21, 18, 0.13); transition: background 0.2s ease; }
.ticks i.done { background: var(--accent); opacity: 0.55; }
.ticks i.now { background: var(--ink); opacity: 1; }

.qbody { padding: 20px 0 calc(var(--bar) + 18px); }
.qbody .qno { font-size: 11px; letter-spacing: 0.18em; color: var(--accent); font-weight: 600; }
.qbody h2 {
  font-family: var(--serif);
  font-size: clamp(21px, 6.4vw, 25px);
  font-weight: 700;
  line-height: 1.55;
  letter-spacing: -0.01em;
  margin-top: 10px;
  min-height: 2.9em;
  text-wrap: balance;
}

.opts { margin-top: 22px; display: flex; flex-direction: column; gap: 9px; }
.opt {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 15px 14px;
  border: 1.5px solid rgba(25, 21, 18, 0.55);
  background: transparent;
  text-align: left;
  font-size: 14.6px;
  line-height: 1.7;
  color: var(--ink);
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.1s ease;
}
.opt:active { transform: scale(0.994); }
.opt .k {
  flex: 0 0 auto;
  width: 25px;
  height: 25px;
  border: 1.2px solid currentColor;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 700;
  margin-top: 1px;
  opacity: 0.75;
}
.opt.on {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
.opt.on .k { background: var(--paper); color: var(--ink); border-color: var(--paper); opacity: 1; }
.opt.dim { opacity: 0.55; }

.qfoot {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  padding: 10px var(--pad) calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--paper);
  border-top: 1.5px solid var(--ink);
}
.qfoot .inner { max-width: 560px; margin: 0 auto; display: flex; gap: 9px; }
.qfoot .btn { flex: 1; }
.qfoot .btn.prev { flex: 0 0 96px; background: transparent; color: var(--ink); }
.qfoot .btn.prev[disabled] { opacity: 0.28; }

.qhint {
  margin-top: 16px;
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
  text-align: center;
}

/* 切题动效 */
.fade-in { animation: fadeIn 0.22s ease both; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .fade-in { animation: none; }
  .card, .opt, .btn { transition: none; }
}

/* ---------- 结果页 ---------- */

.res-head { padding: 20px 0 4px; display: flex; align-items: center; justify-content: space-between; }
.res-hero { padding: 22px 0 18px; border-bottom: 1.5px solid var(--ink); }
.res-kicker { font-size: 10.5px; letter-spacing: 0.2em; color: var(--accent); font-weight: 600; }
.res-name {
  font-family: var(--serif);
  font-size: clamp(38px, 11.6vw, 54px);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin-top: 10px;
}
.res-sub {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink-2);
  margin-top: 8px;
}
.res-keys { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.chip {
  font-size: 11.5px;
  letter-spacing: 0.04em;
  padding: 4px 9px;
  border: 1px solid rgba(25, 21, 18, 0.32);
  color: var(--ink-2);
  background: rgba(255, 255, 255, 0.28);
}

.res-sec { padding: 21px 0 19px; border-bottom: 1px solid var(--line); }
.res-sec .lab {
  display: flex;
  align-items: baseline;
  gap: 9px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--ink-3);
}
.res-sec .lab i {
  font-family: var(--serif);
  font-style: normal;
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 0;
}
.res-sec p {
  margin-top: 10px;
  font-size: 14.6px;
  line-height: 1.95;
  color: var(--ink-2);
}
.res-sec.accent p { color: var(--ink); }

.second {
  margin-top: 22px;
  padding: 16px 16px 17px;
  background: var(--accent-soft);
  border: 1.5px solid var(--accent);
}
.second .caps { color: var(--accent); letter-spacing: 0.16em; }
.second b { display: block; font-family: var(--serif); font-size: 21px; margin-top: 7px; }
.second span { display: block; font-size: 12.5px; line-height: 1.8; color: var(--ink-2); margin-top: 4px; }

/* 城市类 */
.city-match { display: flex; align-items: flex-end; gap: 12px; margin-top: 14px; }
.city-match b {
  font-family: var(--serif);
  font-size: 62px;
  line-height: 0.9;
  color: var(--accent);
  letter-spacing: -0.03em;
}
.city-match span { font-size: 11px; line-height: 1.5; color: var(--ink-3); padding-bottom: 4px; }
.city-match span i { display: block; font-style: normal; font-size: 10px; letter-spacing: 0.1em; }

.rank-list { margin-top: 8px; }
.rank-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 11px 0;
  border-bottom: 1px dashed var(--line);
}
.rank-row .n { font-family: var(--serif); font-size: 13px; color: var(--ink-3); }
.rank-row .nm { font-family: var(--serif); font-size: 17px; font-weight: 700; }
.rank-row .nm small { display: block; font-family: var(--sans); font-size: 11.5px; font-weight: 400; color: var(--ink-3); margin-top: 2px; }
.rank-row .ix { font-family: var(--serif); font-size: 18px; color: var(--accent); }
.rank-row .ix small { font-size: 10px; color: var(--ink-3); margin-left: 2px; }

.dims { margin-top: 14px; display: flex; flex-direction: column; gap: 18px; }
.dim { display: block; }
.dim-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 7px; }
.dim .dn { font-size: 12.5px; color: var(--ink-2); letter-spacing: 0.02em; }
.dim .dv { font-family: var(--serif); font-size: 13px; color: var(--ink-3); }
.dim .track {
  position: relative;
  height: 1.5px;
  background: rgba(25, 21, 18, 0.16);
  margin: 0 5px;
}
.dim .track::before, .dim .track::after {
  content: "";
  position: absolute;
  top: -3.5px;
  width: 1px; height: 8px;
  background: rgba(25, 21, 18, 0.3);
}
.dim .track::before { left: 0; }
.dim .track::after { right: 0; }
.dim .track b {
  position: absolute;
  top: 50%;
  width: 10px; height: 10px;
  background: var(--accent);
  transform: translate(-50%, -50%);
}
.dim .poles {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  font-size: 10px;
  line-height: 1.3;
  color: var(--ink-3);
}
.dim .poles span:last-child { text-align: right; }
.dim-legend {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}

.disclaimer {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  line-height: 1.85;
  color: var(--ink-3);
}
.res-actions { display: flex; gap: 10px; margin-top: 22px; padding-bottom: calc(var(--bar) + 10px); }
.res-actions .btn { flex: 1; }

/* ---------- 分享卡 ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  background: rgba(22, 18, 13, 0.97);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  padding: 14px;
  overflow-y: auto;
}
.sheet.on { display: block; }
.sheet .stage { display: flex; flex-direction: column; align-items: center; gap: 14px; min-height: 100%; justify-content: center; }
.sheet canvas, .sheet img.cardimg {
  width: min(86vw, 380px);
  height: auto;
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.5);
  background: var(--paper);
  -webkit-touch-callout: default;
}
.sheet canvas { display: none; }
.sheet .acts { display: flex; gap: 9px; width: min(86vw, 380px); }
.sheet .acts button {
  flex: 1;
  min-height: 46px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  letter-spacing: 0.04em;
}
.sheet .acts button.primary { background: #fff; color: #241b12; border-color: #fff; }
.sheet .hint { font-size: 11.5px; color: rgba(255, 255, 255, 0.55); text-align: center; letter-spacing: 0.04em; }
.sheet .close-x {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: 12px;
  width: 40px; height: 40px;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  opacity: 0.7;
}

.preview-img { width: min(86vw, 380px); height: auto; display: block; }

/* ---------- 状态 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bar) + 16px);
  transform: translateX(-50%) translateY(8px);
  z-index: 90;
  max-width: 84vw;
  padding: 10px 16px;
  background: rgba(25, 21, 18, 0.93);
  color: var(--paper);
  font-size: 12.5px;
  line-height: 1.6;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  text-align: center;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

.loading { padding: 60px 0; text-align: center; font-size: 12.5px; color: var(--ink-3); letter-spacing: 0.1em; }

.empty { padding: 50px 0; text-align: center; }
.empty b { display: block; font-family: var(--serif); font-size: 20px; margin-bottom: 8px; }
.empty p { font-size: 13px; color: var(--ink-3); line-height: 1.8; }
.empty .btn { margin-top: 20px; }

@media (max-width: 340px) {
  .card { grid-template-columns: 38px 1fr; gap: 9px; padding-left: 9px; }
  .card .no small { letter-spacing: 0.02em; font-size: 8.5px; white-space: nowrap; }
  .card h3 { font-size: 17.5px; }
  .card .no { font-size: 22px; }
  .opt { font-size: 13.8px; padding: 13px 12px; }
  .intro-specs b { font-size: 17px; }
  .qfoot .btn.prev { flex: 0 0 92px; font-size: 13px; padding: 0 8px; }
}
