/* ==========================================================
   猫咪性格测试 · 手帐 / 领养证风
   纯静态视觉：米白纸底、咖啡墨线、纸胶带、印章、爪印。
   无外部字体与图片；插画全部为 app.js 注入的内联 SVG。
   结构 class（.view / [hidden] / .options / .btn）兼容旧逻辑。
   ========================================================== */

/* ---- 1. 基础 ---- */
:root {
  --paper: #f6eedc;
  --sheet: #fffdf5;
  --edge: #e7d9be;
  --edge2: #d9c6a4;
  --line: #efe4cb;
  --ink: #4a3b31;
  --ink2: #8a766a;
  --faint: #c9b6a0;
  --ginger: #e8874a;
  --ginger-deep: #d26f2e;
  --sage: #6e9b84;
  --sage-deep: #57826c;
  --seal: #c4573a;
  --serif: "Kaiti SC", "STKaiti", "KaiTi", "STSong", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans CJK SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --latin: Georgia, "Times New Roman", var(--serif);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--ink);
  line-height: 1.8;
  background:
    radial-gradient(1100px 620px at 14% -8%, rgba(255, 255, 255, 0.65), transparent 60%),
    radial-gradient(900px 560px at 108% 6%, rgba(232, 135, 74, 0.10), transparent 62%),
    radial-gradient(760px 520px at 0% 104%, rgba(110, 155, 132, 0.08), transparent 60%),
    var(--paper);
  overflow-x: hidden;
  padding: 8px;
}

button { font-family: inherit; }

/* 纸底的小爪印 / 小小心心（数据 URI 内联 SVG） */
.deco-paw,
.deco-heart {
  position: fixed;
  pointer-events: none;
  opacity: 0.42;
  z-index: 0;
}
.deco-paw {
  width: 42px;
  height: 42px;
  background-repeat: no-repeat;
  background-size: contain;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cellipse cx='12' cy='17.5' rx='4.6' ry='3.6' fill='%23cbb499'/%3E%3Cg fill='%23cbb499'%3E%3Ccircle cx='5.4' cy='13' r='2.1'/%3E%3Ccircle cx='11' cy='10.4' r='2.1'/%3E%3Ccircle cx='16.6' cy='13' r='2.1'/%3E%3C/g%3E%3C/svg%3E");
}
.deco-paw--1 { top: 18px; right: 4vw; transform: rotate(18deg); opacity: 0.28; }
.deco-paw--2 { bottom: 20px; left: 3vw; transform: rotate(-14deg); opacity: 0.3; }
.deco-heart {
  width: 26px;
  height: 26px;
  bottom: 7vh;
  right: 5vw;
  opacity: 0.22;
  background-repeat: no-repeat;
  background-size: contain;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 20 C 12 20 3 14.4 3 8.9 A 4.4 4.4 0 0 1 12 5.9 A 4.4 4.4 0 0 1 21 8.9 C 21 14.4 12 20 12 20 Z' fill='%23cbb499'/%3E%3C/svg%3E");
}

/* ---- 2. 页面骨架 ---- */
.page {
  position: relative;
  z-index: 1;
}

.view { animation: viewIn 0.42s ease both; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
[hidden] { display: none !important; }

/* 一张“纸卡” */
.paper-card {
  position: relative;
  max-width: 720px;
  margin: clamp(8px, 2.4vh, 26px) auto;
  padding: clamp(26px, 6vw, 46px) clamp(16px, 6vw, 44px);
  background: var(--sheet);
  border: 1px solid var(--edge);
  border-radius: 20px;
  box-shadow:
    0 1px 0 rgba(122, 88, 52, 0.04),
    0 22px 46px -30px rgba(122, 88, 52, 0.5);
}

/* 纸胶带 */
.tape {
  position: absolute;
  height: 24px;
  border-radius: 3px;
  box-shadow: 0 2px 3px rgba(122, 88, 52, 0.14);
  background-repeat: repeat;
  background-size: 8px 8px;
}
.tape.t-l {
  left: -14px;
  top: -11px;
  width: 92px;
  transform: rotate(-9deg);
  background-color: rgba(233, 173, 122, 0.78);
  background-image: repeating-linear-gradient(
    45deg, rgba(255, 255, 255, 0.34) 0 5px, transparent 5px 10px);
}
.tape.t-r {
  right: -12px;
  top: -13px;
  width: 88px;
  transform: rotate(8deg);
  background-color: rgba(178, 205, 184, 0.8);
  background-image: repeating-linear-gradient(
    -45deg, rgba(255, 255, 255, 0.32) 0 5px, transparent 5px 10px);
}
.tape.t-c {
  left: 50%;
  top: -12px;
  width: 150px;
  transform: translateX(-50%) rotate(-1.5deg);
  background-color: rgba(226, 165, 176, 0.72);
  background-image: repeating-linear-gradient(
    45deg, rgba(255, 255, 255, 0.3) 0 5px, transparent 5px 10px);
}

/* 装饰字 / 题眼 */
.eyebrow {
  margin: 0;
  font-family: var(--latin);
  font-size: 12px;
  letter-spacing: 0.2em;
  color: #c08b5a;
}

/* 沿此线裁剪的小装饰 */
.cutline {
  margin: 20px 0 2px;
  text-align: center;
  font-family: var(--latin);
  font-size: 12px;
  letter-spacing: 0.5em;
  color: var(--faint);
}

.colophon {
  margin: 6px 0 0;
  text-align: center;
  font-family: var(--latin);
  font-style: italic;
  font-size: 12px;
  color: var(--ink2);
}

/* ---- 3. 按钮 / 输入 ---- */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 13px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; }

.btn-primary {
  color: #fffdf5;
  background: linear-gradient(180deg, var(--ginger), var(--ginger-deep));
  box-shadow: 0 3px 0 #b9622a, 0 8px 16px -8px rgba(210, 111, 46, 0.65);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); }
.btn-primary:active { transform: translateY(2px); box-shadow: 0 1px 0 #b9622a; }
.btn-primary:focus-visible,
.btn-outline:focus-visible,
.btn:focus-visible {
  outline: 3px solid rgba(232, 135, 74, 0.45);
  outline-offset: 2px;
}

.btn-outline {
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--edge2);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.04);
}
.btn-outline:hover:not(:disabled) { border-color: var(--ginger); color: var(--ginger-deep); }

.btn-link {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink2);
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 4px;
  padding: 6px 2px;
}
.btn-link:hover { color: var(--ginger-deep); }

input[type="text"] {
  width: 100%;
  min-width: 0;
  padding: 12px 16px;
  font-size: 1.05rem;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--edge2);
  border-radius: 13px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
input[type="text"]::placeholder { color: var(--faint); }
input[type="text"]:focus {
  outline: none;
  border-color: var(--ginger);
  box-shadow: 0 0 0 3px rgba(232, 135, 74, 0.2);
}

/* ---- 4. 登录页 ---- */
.login-head {
  text-align: center;
}
.mascot { margin: 0 auto -2px; max-width: 240px; }
/* <picture> 包裹层：只做布局透传，不改变内部 img 的既有版式 */
.mascot picture,
.portrait picture,
.cat-face picture { display: block; }
.cat-face picture { width: 100%; height: 100%; }
.mascot img {
  display: block;
  width: clamp(150px, 34vw, 240px);
  height: auto;
  margin: 0 auto;
  filter: drop-shadow(0 10px 14px rgba(122, 88, 52, 0.16));
}

.login-title {
  margin: 10px 0 6px;
  font-size: clamp(1.7rem, 5.6vw, 2.4rem);
  line-height: 1.25;
  letter-spacing: 0.04em;
}
.login-sub {
  margin: 0 0 6px;
  color: var(--ink2);
  font-size: clamp(0.92rem, 2.6vw, 1.02rem);
}

.cat-previews { margin: 14px 0 4px; text-align: center; }
.cat-previews-hint {
  margin: 0 0 8px;
  color: var(--ink2);
  font-size: 0.9rem;
}
.cat-avatars {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px 6px;
  max-width: 520px;
  margin: 0 auto;
}
.cat-avatar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.cat-face {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #fff8ea;
  box-shadow: inset 0 0 0 2px #efe2c6;
  display: grid;
  place-items: center;
  padding: 4px;
}
.cat-face img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}
.cat-name {
  font-size: 12px;
  color: var(--ink2);
  white-space: nowrap;
}
@media (min-width: 720px) {
  .cat-avatars { grid-template-columns: repeat(8, 1fr); gap: 8px; }
}

.login-form {
  margin: 18px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.login-label {
  font-size: 0.9rem;
  color: var(--ink2);
}
.code-row { display: flex; gap: 10px; align-items: stretch; }
.code-row .btn-primary { flex: 0 0 auto; white-space: nowrap; }
@media (max-width: 399px) {
  .code-row { flex-direction: column; }
  .code-row .btn-primary { width: 100%; }
}
.login-note {
  margin: 10px 0 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--ink2);
}

/* ---- 5. 答题页 ---- */
.quiz-card { padding-top: 30px; }

.quiz-top {
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.quiz-counter {
  font-size: 0.95rem;
  color: var(--ink2);
}
.quiz-track {
  display: flex;
  gap: 3px;
}
.track-seg {
  flex: 1;
  height: 7px;
  border-radius: 4px;
  background: #f0e6cf;
  transition: background 0.2s ease;
}
.track-seg.done { background: var(--ginger); }
.track-seg.now {
  background: var(--edge2);
  box-shadow: inset 0 0 0 1px var(--ginger);
}

.q-block {
  position: relative;
  background: #fff7e8;
  border: 1px solid #f0e0bf;
  border-radius: 16px;
  padding: 18px 18px 16px;
  margin-bottom: 16px;
}
.q-block::after {
  content: "";
  position: absolute;
  right: 14px;
  top: -7px;
  width: 20px;
  height: 14px;
  background: var(--sheet);
  transform: rotate(4deg);
  border: 1px solid #f0e0bf;
  border-radius: 3px;
}
.q-badge {
  display: inline-block;
  margin-bottom: 8px;
  padding: 2px 10px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff8ea;
  font-family: var(--latin);
  font-size: 12px;
  letter-spacing: 0.08em;
}
.question {
  margin: 0;
  font-size: clamp(1.12rem, 1rem + 1vw, 1.5rem);
  font-weight: 700;
  line-height: 1.75;
  color: var(--ink);
}

.options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 760px) {
  .options { grid-template-columns: 1fr 1fr; gap: 14px; }
}

.option {
  appearance: none;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  width: 100%;
  padding: 13px 12px 13px 12px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 0.98rem;
  line-height: 1.7;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, transform 0.1s ease;
}
.option:hover { border-color: var(--edge2); transform: translateY(-1px); }
.option:active { transform: translateY(1px); }
.option:focus-visible { outline: 3px solid rgba(232, 135, 74, 0.4); outline-offset: 1px; }

.opt-key {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  margin-top: 2px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-weight: 800;
  font-size: 0.85rem;
  background: #f4ead4;
  color: #9a6a37;
}
.opt-text { flex: 1 1 auto; min-width: 0; }
.opt-tick {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin-top: 3px;
  opacity: 0;
  transform: scale(0.5) rotate(-12deg);
  transition: opacity 0.15s ease, transform 0.2s ease;
}
.opt-tick svg { width: 100%; height: 100%; display: block; }

.option.selected {
  border-color: var(--ginger);
  background: #fff2e3;
}
.option.selected .opt-key { background: var(--ginger); color: #fff8ea; }
.option.selected .opt-tick {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
}
.actions .btn-primary { flex: 1 1 auto; }
.quiz-foot-note {
  margin: 16px 0 0;
  text-align: center;
  font-size: 0.82rem;
  color: var(--ink2);
  font-style: italic;
}

/* ---- 6. 结果页 · 猫格认领卡 ---- */
.adopt-card { padding-top: 30px; }

.adopt-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding-bottom: 4px;
}
@media (min-width: 860px) {
  .adopt-head {
    flex-direction: row;
    justify-content: center;
    gap: clamp(26px, 5vw, 46px);
    padding: 6px 6px 10px;
  }
}

.portrait-box {
  position: relative;
  width: min(232px, 66vw);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.portrait-ring {
  position: absolute;
  inset: 2%;
  border: 2px dashed var(--edge2);
  border-radius: 50%;
  transform: rotate(-7deg);
  pointer-events: none;
}
.portrait-box::before {
  content: "";
  position: absolute;
  inset: 5%;
  background: #fff4e0;
  border-radius: 50%;
  box-shadow: inset 0 0 0 6px #fffdf5, 0 12px 22px -14px rgba(122, 88, 52, 0.5);
}
.portrait {
  position: relative;
  z-index: 1;
  width: 78%;
}
.portrait img {
  width: 100%;
  height: auto;
  display: block;
}
.portrait-paw {
  position: absolute;
  z-index: 2;
  right: 14px;
  bottom: 12px;
  width: 26px;
  height: 26px;
  transform: rotate(-14deg);
  background-repeat: no-repeat;
  background-size: contain;
  opacity: 0.75;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cellipse cx='12' cy='17.5' rx='4.6' ry='3.6' fill='%23d9a76a'/%3E%3Cg fill='%23d9a76a'%3E%3Ccircle cx='5.4' cy='13' r='2.1'/%3E%3Ccircle cx='11' cy='10.4' r='2.1'/%3E%3Ccircle cx='16.6' cy='13' r='2.1'/%3E%3C/g%3E%3C/svg%3E");
}

.adopt-info {
  position: relative;
  text-align: center;
  max-width: 420px;
  flex: 1 1 auto;
}
.seal {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 60px;
  height: 60px;
  opacity: 0.92;
  filter: drop-shadow(0 4px 6px rgba(196, 87, 58, 0.25));
}
@media (min-width: 860px) {
  .seal { position: static; display: inline-block; }
  .adopt-info { text-align: left; }
  .adopt-info .eyebrow { margin-top: 6px; }
}

.adopt-name {
  margin: 6px 0 4px;
  font-size: clamp(1.7rem, 6vw, 2.5rem);
  line-height: 1.25;
  letter-spacing: 0.04em;
  color: var(--ink);
}
.adopt-tagline {
  margin: 0;
  color: var(--ink2);
  font-size: 0.98rem;
}

.result-body {
  margin-top: clamp(24px, 5vh, 36px);
  display: flex;
  flex-direction: column;
  gap: clamp(22px, 4.5vh, 34px);
}

.result-part {
  border-top: 2px dotted var(--edge2);
  padding-top: 20px;
}
.part-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--ink);
}
.part-label::before {
  content: "";
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  background-repeat: no-repeat;
  background-size: contain;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cellipse cx='12' cy='17.5' rx='4.6' ry='3.6' fill='%23e8874a'/%3E%3Cg fill='%23e8874a'%3E%3Ccircle cx='5.4' cy='13' r='2.1'/%3E%3Ccircle cx='11' cy='10.4' r='2.1'/%3E%3Ccircle cx='16.6' cy='13' r='2.1'/%3E%3C/g%3E%3C/svg%3E");
}

/* 概括（米橘浅底） */
.part-body--summary {
  background: #fff3e1;
  border: 1px solid #f0dcba;
  border-radius: 16px;
  padding: 18px 20px;
}
.part-body--summary p {
  margin: 0;
}
.part-body--summary p + p { margin-top: 10px; }

/* 特点详解（笔记纸） */
.part-body--detail {
  background: #fbfaf2;
  border: 1px dashed #e2d4b6;
  border-left: 4px solid #f0c9a2;
  border-radius: 4px 16px 16px 4px;
  padding: 18px 22px 18px 20px;
}
.part-body--detail p {
  margin: 0;
}
.part-body--detail p + p {
  margin-top: 14px;
}

/* 关键词 chips */
.kw-body {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.chip {
  display: inline-block;
  padding: 6px 13px;
  border-radius: 9px;
  background: #fff;
  border: 1px solid #e9cf9e;
  color: #a66a24;
  font-size: 0.95rem;
  font-weight: 700;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.03);
}
.chip:nth-child(even) { transform: rotate(-1deg); border-color: #d9cfae; color: #6e7f4e; }
.chip:nth-child(3n)   { transform: rotate(1.2deg); border-color: #e6b9c4; color: #b25c76; }

.kw-tail {
  margin: 14px 0 0;
  padding-left: 16px;
  border-left: 3px solid var(--edge2);
  color: var(--ink2);
}

/* 八维气质 */
.dims {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px 24px;
}
@media (min-width: 700px) {
  .dims { grid-template-columns: 1fr 1fr; }
}
.dim-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}
.dim-name { font-size: 0.95rem; font-weight: 700; color: var(--ink); }
.dim-num {
  font-family: var(--latin);
  font-size: 0.85rem;
  color: var(--ginger-deep);
  font-weight: 700;
}
.dim-bar {
  display: block;
  height: 9px;
  border-radius: 6px;
  background: #f0e6cf;
  overflow: hidden;
}
.dim-bar-fill {
  display: block;
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #f2b16a, var(--ginger-deep));
}
.dims-note {
  margin: 16px 0 0;
  font-size: 0.82rem;
  color: var(--ink2);
  text-align: center;
}

.result-actions { justify-content: center; }
.result-actions .btn { flex: 0 1 auto; }

/* ---- 7. 弹窗 ---- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(63, 47, 34, 0.42);
  animation: viewIn 0.2s ease;
}
.modal-box {
  max-width: 360px;
  width: 100%;
  padding: 26px 24px 22px;
  background: var(--sheet);
  border: 1px solid var(--edge);
  border-radius: 18px;
  box-shadow: 0 26px 60px -30px rgba(63, 47, 34, 0.55);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.modal-paw {
  width: 34px;
  height: 34px;
  opacity: 0.85;
}
.modal-paw svg { width: 100%; height: 100%; display: block; }
.modal-text {
  margin: 0;
  font-size: 1rem;
  line-height: 1.8;
  white-space: pre-wrap;
  color: var(--ink);
}

/* ---- 8. 减弱动效 ---- */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
}
