:root {
  --brand: #f13d37;
  --brand-dark: #d72d29;
  --ink: #1e2023;
  --ink-soft: #555b61;
  --muted: #7e8489;
  --paper: #fffefa;
  --surface: #f5f5f1;
  --line: #dedfd9;
  --line-dark: #c9cbc5;
  --yellow: #f5c451;
  --habit: #f13d37;
  --ability: #31363b;
  --motivation: #d49b2d;
  --radius: 6px;
  --page-pad: clamp(20px, 6vw, 34px);
  --font: "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { background: #ecece8; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #ecece8;
  background-image: none;
  font-family: var(--font);
  letter-spacing: 0;
}

button, input, select { font-family: inherit; }
button { letter-spacing: 0; }
.app {
  width: min(100%, 640px);
  min-height: 100vh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 0 0 0 1px rgba(30, 32, 35, .05);
}
.screen { min-height: 100vh; background: var(--paper); }
.screen.active { animation: page-in .22s ease both; }
@keyframes page-in { from { opacity: 0; transform: translateY(5px); } }

/* Shared brand language */
.brand-header,
.compact-header {
  display: flex;
  align-items: center;
  width: 100%;
}
.brand-header {
  justify-content: flex-start;
  min-height: 58px;
  padding: max(16px, env(safe-area-inset-top)) var(--page-pad) 8px;
}
.brand-header img { width: min(72%, 310px); height: 44px; object-fit: contain; object-position: left center; }
.brand-header > span {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid var(--line-dark);
  border-radius: 3px;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
}
.compact-header {
  justify-content: space-between;
  min-height: 66px;
  padding: max(14px, env(safe-area-inset-top)) var(--page-pad) 10px;
  border-bottom: 1px solid var(--line);
}
.compact-header img { width: 215px; height: 38px; object-fit: contain; }
.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: transparent;
  font-size: 18px;
  cursor: pointer;
}
.step-code { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.product-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.product-eyebrow span { color: var(--ink); font-family: Consolas, monospace; }
.primary {
  width: 100%;
  min-height: 52px;
  margin: 0;
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  color: #fff;
  background: var(--brand);
  box-shadow: none;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: background .16s ease, transform .16s ease;
}
.primary:hover { background: var(--brand-dark); }
.primary:active { transform: translateY(1px); }
.text-button {
  padding: 6px 0;
  border: 0;
  color: var(--ink-soft);
  background: transparent;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* Home */
.home-shell { display: flex; min-height: 100vh; flex-direction: column; }
.home-main { flex: 1; padding: 20px var(--page-pad) 12px; }
.home-main h1 {
  margin: 0;
  font-family: var(--font);
  font-size: clamp(42px, 12vw, 62px);
  font-weight: 900;
  line-height: 1.06;
  letter-spacing: 0;
}
.home-main h1 em { color: var(--brand); font-style: normal; }
.home-main .lead {
  max-width: 460px;
  margin: 15px 0 20px;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.75;
}
.home-main .lead strong { color: var(--brand); font-weight: 800; }
.hero-stage {
  position: relative;
  height: 250px;
  margin: 0 0 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.hero-stage::before,
.hero-stage::after {
  content: "";
  position: absolute;
  pointer-events: none;
}
.hero-stage::before {
  top: -17px;
  right: 64px;
  width: 56px;
  height: 56px;
  border-top: 1.5px solid rgba(241, 61, 55, .26);
  border-left: 1.5px solid rgba(241, 61, 55, .26);
  transform: rotate(45deg);
}
.hero-stage::after {
  right: 14px;
  bottom: 13px;
  width: 30px;
  height: 21px;
  opacity: .22;
  background: radial-gradient(circle at 50% 25%, var(--brand) 0 3px, transparent 4px), radial-gradient(circle at 20% 58%, var(--brand) 0 3px, transparent 4px), radial-gradient(circle at 80% 58%, var(--brand) 0 3px, transparent 4px), radial-gradient(ellipse at 50% 82%, var(--brand) 0 8px, transparent 9px);
}
.hero-stage > img {
  position: absolute;
  z-index: 2;
  right: 14px;
  bottom: 6px;
  width: auto;
  height: 238px;
  object-fit: contain;
  object-position: bottom center;
}
.stage-copy { position: relative; z-index: 3; width: 52%; padding: 29px 0 0 22px; }
.stage-copy small { display: block; margin-bottom: 13px; color: var(--muted); font-family: Consolas, monospace; font-size: 9px; letter-spacing: .1em; }
.stage-copy strong { display: block; font-size: 25px; line-height: 1.35; }
.stage-axis { display: flex; gap: 8px; margin-top: 21px; }
.stage-axis span { padding-top: 6px; border-top: 2px solid var(--brand); color: var(--ink-soft); font-size: 10px; font-weight: 700; }
.code-sign {
  position: absolute;
  left: 19px;
  bottom: 16px;
  color: rgba(30, 32, 35, .08);
  font-family: Consolas, monospace;
  font-size: 46px;
  font-weight: 900;
}
.hero-button { position: relative; display: grid; place-items: center; overflow: hidden; padding: 0 78px; text-align: center; }
.hero-button span { font-size: 16px; font-weight: 800; }
.hero-button img { position: absolute; right: 9px; bottom: 2px; width: 68px; height: 48px; object-fit: contain; pointer-events: none; }
.home-meta { display: flex; justify-content: center; gap: 0; margin-top: 13px; color: var(--muted); font-size: 11px; }
.home-meta span { display: flex; align-items: center; }
.home-meta span + span::before { content: ""; width: 3px; height: 3px; margin: 0 9px; border-radius: 50%; background: var(--brand); }
.page-footer { display: flex; align-items: center; justify-content: flex-end; gap: 14px; padding: 10px var(--page-pad) max(18px, env(safe-area-inset-bottom)); color: var(--muted); }
.page-footer small { max-width: 250px; font-size: 9px; text-align: right; }

/* Introduction */
.page-shell { min-height: 100vh; }
.intro-content { padding: 34px var(--page-pad) 40px; }
.intro-content h2,
.state-shell h2 {
  margin: 0;
  font-size: clamp(30px, 9vw, 42px);
  line-height: 1.25;
  letter-spacing: 0;
}
.intro-lead { margin: 15px 0 0; color: var(--ink-soft); font-size: 14px; line-height: 1.75; }
.facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin: 27px 0 30px;
  overflow: visible;
  border: solid var(--line);
  border-width: 1px 0;
  border-radius: 0;
  background: transparent;
}
.fact { padding: 16px 6px; background: transparent; text-align: center; }
.fact + .fact { border-left: 1px solid var(--line); }
.fact strong { display: block; color: var(--ink); font-size: 22px; }
.fact span { color: var(--muted); font-size: 10px; }
.form-row { display: grid; grid-template-columns: 1.15fr .85fr; gap: 12px; margin: 0 0 18px; }
label { color: var(--ink-soft); font-size: 12px; font-weight: 700; }
input, select {
  width: 100%;
  height: 48px;
  margin-top: 8px;
  padding: 0 13px;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  color: var(--ink);
  background: #fff;
  outline: 0;
  font-size: 14px;
}
input:focus, select:focus { border-color: var(--ink); box-shadow: 0 0 0 2px rgba(30, 32, 35, .08); }
input.invalid { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(241, 61, 55, .1); }
.required-mark { color: var(--brand); }
.field-error { margin-top: 5px; color: var(--brand-dark); font-size: 11px; font-weight: 500; }
/* Quiz */
.quiz-head {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: max(18px, env(safe-area-inset-top)) var(--page-pad) 15px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 254, 250, .98);
  backdrop-filter: none;
}
.quiz-brand { display: flex; align-items: center; gap: 8px; margin-bottom: 19px; color: var(--ink-soft); font-size: 11px; font-weight: 700; }
.cat-code-mark { display: inline-flex; align-items: center; justify-content: center; width: 29px; height: 21px; border: 1px solid var(--brand); border-radius: 12px 12px 8px 8px; color: var(--brand); font-family: Consolas, monospace; font-size: 8px; }
.quiz-meta { margin-bottom: 9px; color: var(--muted); font-size: 11px; }
.dimension-pill { padding: 0; border-radius: 0; color: var(--ink); background: transparent; font-size: 12px; font-weight: 800; }
.progress { height: 3px; border-radius: 0; background: #e7e7e2; }
.progress > div { background: var(--brand); border-radius: 0; }
.question-wrap { padding: 42px var(--page-pad) 42px; }
.eyebrow { color: var(--brand); font-family: Consolas, monospace; font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.question {
  min-height: 104px;
  margin: 14px 0 28px;
  font-family: var(--font);
  font-size: clamp(23px, 6.4vw, 29px);
  font-weight: 800;
  line-height: 1.5;
}
.options { gap: 9px; }
.option {
  min-height: 68px;
  padding: 14px 48px 14px 15px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: #fff;
  font-size: 14px;
  line-height: 1.55;
}
.option::after { width: 17px; height: 17px; border-color: #a8aca8; }
.option:hover { border-color: var(--ink); transform: none; }
.option.selected { border-color: var(--brand); background: #fff7f5; }
.option.selected::after { border: 5px solid var(--brand); }
.option { -webkit-tap-highlight-color: transparent; }
.option:focus { outline: 0; }
.option:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.back-button { margin-top: 20px; color: var(--muted); font-size: 12px; }

@media (hover: none) {
  .option:hover { border-color: var(--line); transform: none; }
  .option.selected,
  .option.selected:hover { border-color: var(--brand); }
}

/* Loading and error */
.state-shell {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 34px var(--page-pad);
  text-align: center;
}
.state-logo { position: absolute; top: max(22px, env(safe-area-inset-top)); width: 260px; height: 48px; object-fit: contain; }
.cat-outline-mark {
  position: relative;
  display: grid;
  width: 86px;
  height: 72px;
  margin-bottom: 30px;
  place-items: center;
  border: 2px solid var(--brand);
  border-radius: 44% 44% 40% 40%;
  color: var(--brand);
  font-family: Consolas, monospace;
  font-size: 15px;
  font-weight: 800;
}
.cat-outline-mark::before,
.cat-outline-mark::after { content: ""; position: absolute; top: -14px; width: 28px; height: 28px; border-top: 2px solid var(--brand); transform: rotate(45deg); }
.cat-outline-mark::before { left: 6px; border-left: 2px solid var(--brand); }
.cat-outline-mark::after { right: 6px; border-right: 2px solid var(--brand); }
.state-shell .product-eyebrow { justify-content: center; }
.state-shell > p:not(.product-eyebrow) { margin: 14px 0 0; color: var(--muted); font-size: 13px; }
.loading-line { width: min(260px, 72vw); height: 2px; margin-top: 36px; overflow: hidden; background: var(--line); }
.loading-line span { display: block; width: 42%; height: 100%; background: var(--brand); animation: loading 1.1s ease-in-out infinite; }
@keyframes loading { 0% { transform: translateX(-110%); } 100% { transform: translateX(340%); } }
.error-state .cat-outline-mark { color: var(--ink); border-color: var(--ink); }
.error-state .cat-outline-mark::before,
.error-state .cat-outline-mark::after { border-color: var(--ink); }
.error-state .primary { max-width: 320px; margin-top: 30px; }

/* Report */
.result-head {
  position: relative;
  min-height: 270px;
  overflow: hidden;
  padding: max(24px, env(safe-area-inset-top)) var(--page-pad) 30px;
  color: #fff;
  background: var(--brand);
}
.result-head::after { content: ""; position: absolute; right: -25px; bottom: -58px; width: 150px; height: 150px; border: 1px solid rgba(255,255,255,.14); border-radius: 50%; }
.report-logo { width: 250px; height: 50px; object-fit: contain; object-position: left center; }
.report-heading { position: relative; z-index: 2; margin-top: 38px; padding-right: 150px; }
.report-kicker { margin: 0 0 9px; color: rgba(255,255,255,.6); font-family: Consolas, monospace; font-size: 10px; font-weight: 700; line-height: 1.55; letter-spacing: .06em; white-space: pre-line; }
.result-head h2 { margin: 0; font-family: var(--font); font-size: clamp(36px, 10vw, 48px); line-height: 1.2; }
.type-tag { display: inline-block; margin-top: 14px; padding: 0 0 5px; border-bottom: 2px solid rgba(255,255,255,.9); border-radius: 0; color: #fff; background: transparent; font-size: 11px; font-weight: 700; }
.report-animal {
  position: absolute;
  z-index: 1;
  right: 14px;
  bottom: 22px;
  width: 154px;
  height: 154px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,.76);
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(105, 0, 0, .2);
  pointer-events: none;
}
.report-animal img { width: 100%; height: 100%; object-fit: cover; object-position: center; }
.report { padding: 30px var(--page-pad) 48px; }
.summary { margin: 0; color: var(--ink-soft); font-size: 14px; line-height: 1.9; }
.report-section { padding: 31px 0; border-bottom: 1px solid var(--line); }
.report-footer { padding: 22px 0 0; }
.section-title { gap: 10px; margin: 0 0 22px; color: var(--ink); font-size: 18px; }
.section-no { width: 24px; height: 24px; border: 1px solid var(--brand); border-radius: 50%; color: var(--brand); background: transparent; font-family: Consolas, monospace; font-size: 9px; }
.portrait { grid-template-columns: 145px 1fr; gap: 22px; }
#radar { width: 145px; height: 145px; }
.score-list { gap: 15px; }
.score-row { grid-template-columns: 58px 1fr 34px; gap: 8px; color: var(--muted); font-size: 10px; }
.score-row strong { color: var(--ink); font-size: 12px; }
.score-track { height: 4px; border-radius: 0; background: #e6e6e1; }
.score-fill { border-radius: 0; }
.dimension-details { gap: 0; margin-top: 24px; border-top: 1px solid var(--line); }
.dimension-item { padding: 16px 0 16px 14px; border-bottom: 1px solid var(--line); border-left-width: 3px; background: transparent; }
.dimension-item header { margin-bottom: 6px; }
.dimension-item h4 { font-size: 13px; }
.dimension-item p { color: var(--muted); font-size: 12px; line-height: 1.65; }
.insight-grid { grid-template-columns: 1fr; gap: 0; border-top: 1px solid var(--line); }
.insight, .insight.alert { min-height: 0; padding: 17px 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; }
.insight h4 { margin-bottom: 7px; color: var(--ink); font-size: 13px; }
.insight h4::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 8px; border-radius: 50%; background: var(--brand); vertical-align: 1px; }
.insight.alert h4::before { background: var(--ink); }
.insight p { color: var(--muted); font-size: 12px; line-height: 1.75; }
.advice-list { gap: 0; border-top: 1px solid var(--line); }
.advice { grid-template-columns: 30px 1fr; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.advice b { width: 24px; height: 24px; border: 1px solid var(--line-dark); color: var(--brand); font-family: Consolas, monospace; font-size: 10px; }
.advice h4 { margin: 0 0 5px; font-size: 13px; }
.advice p { color: var(--muted); font-size: 12px; line-height: 1.75; }
.week-plan { grid-template-columns: repeat(7, 1fr); gap: 5px; }
.day { padding: 11px 3px; border-color: var(--line); border-radius: 3px; background: transparent; }
.day strong { color: var(--brand); font-size: 9px; }
.day span { color: var(--ink-soft); font-size: 9px; }
.method { margin-top: 22px; padding: 14px 0; border: solid var(--line); border-width: 1px 0; color: var(--muted); font-size: 10px; line-height: 1.75; }
.actions { gap: 9px; margin-top: 20px; }
.secondary { min-height: 48px; border: 1px solid var(--ink); border-radius: var(--radius); color: var(--ink); background: transparent; font-weight: 700; }
.actions button:disabled { cursor: wait; opacity: .72; }
.retest-button { grid-column: 1 / -1; justify-self: center; width: auto; margin-top: 3px; }

body.modal-open { overflow: hidden; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(30, 32, 35, .72);
}
.modal-backdrop.active { display: flex; }
.modal-panel {
  position: relative;
  width: min(100%, 420px);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 28px 24px 24px;
  border-top: 5px solid var(--brand);
  border-radius: 4px;
  background: var(--paper);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .22);
}
.modal-panel h3 { margin: 8px 38px 10px 0; font-size: 24px; }
.modal-panel > p:not(.modal-code) { margin: 0 0 22px; color: var(--muted); font-size: 13px; line-height: 1.75; }
.modal-code { margin: 0; color: var(--brand); font-family: Consolas, monospace; font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: transparent;
  font-size: 22px;
  line-height: 1;
}
.share-modal { width: min(100%, 390px); padding-bottom: 18px; }
.share-modal > p:not(.modal-code) { margin-bottom: 14px; }
#shareCardPreview {
  display: block;
  width: 100%;
  max-height: 68vh;
  object-fit: contain;
  border: 1px solid var(--line);
  background: #fff;
  -webkit-touch-callout: default;
  user-select: none;
}

@media (max-width: 420px) {
  .brand-header img { width: 246px; }
  .brand-header > span { display: none; }
  .home-main { padding-top: 14px; }
  .hero-stage { height: 230px; }
  .hero-stage > img { right: 8px; bottom: 6px; width: auto; height: 218px; }
  .stage-copy { padding-left: 17px; }
  .stage-copy strong { font-size: 22px; }
  .compact-header img { width: 190px; }
  .form-row { grid-template-columns: 1fr; }
  .question { min-height: 118px; }
  .portrait { grid-template-columns: 125px 1fr; gap: 12px; }
  #radar { width: 125px; height: 125px; }
  .week-plan { grid-template-columns: repeat(4, 1fr); }
  .page-footer small { display: none; }
  .result-head h2 { font-size: 26px; white-space: nowrap; }
}

@media (max-height: 760px) and (max-width: 480px) {
  .brand-header { min-height: 52px; }
  .brand-header img { height: 38px; }
  .home-main h1 { font-size: 39px; }
  .home-main .lead { margin: 10px 0 14px; line-height: 1.6; }
  .hero-stage { height: 198px; margin-bottom: 13px; }
  .hero-stage > img { right: 5px; bottom: 5px; width: auto; height: 188px; }
  .stage-copy { padding-top: 21px; }
  .stage-axis { margin-top: 12px; }
  .page-footer { padding-top: 4px; }
}

@media print {
  body, .app, #result { background: #fff; }
  .app { box-shadow: none; }
  .result-head { min-height: 220px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .report { padding: 18px 24px; }
  .report-section { break-inside: avoid; padding: 20px 0; }
}
