:root {
  --bg: #e9d8a7;
  --bg-top: #f5ecd1;
  --bg-bottom: #dcc58c;
  --card: rgba(248, 241, 221, 0.88);
  --card-border: rgba(27, 54, 68, 0.12);
  --text: #1b3644;
  --muted: #5c6651;
  --accent: #b85e00;
  --accent-soft: #ebd999;
  --accent-deep: #8b4700;
  --teal: #58771e;
  --code-bg: rgba(27, 54, 68, 0.08);
  --surface-plain: rgba(244, 235, 211, 0.96);
  --surface-soft: rgba(248, 241, 221, 0.92);
  --surface-track: rgba(27, 54, 68, 0.08);
  --surface-border-strong: rgba(27, 54, 68, 0.16);
  --shadow: 0 18px 44px rgba(93, 71, 24, 0.15);
  --wash-a: rgba(184, 94, 0, 0.18);
  --wash-b: rgba(88, 119, 30, 0.16);
  --glow-a: rgba(184, 94, 0, 0.34);
  --glow-b: rgba(88, 119, 30, 0.24);
  --theme-toggle-border: var(--surface-border-strong);
  --chip-active-end: #799344;
  --chip-active-border: rgba(88, 119, 30, 0.38);
  --chip-active-shadow: rgba(88, 119, 30, 0.18);
  --button-primary-text: #fffaf4;
  --button-primary-end: #cc862f;
  --button-primary-shadow: rgba(184, 94, 0, 0.22);
  --progress-fill: linear-gradient(90deg, var(--teal) 0%, #89a84b 100%);
  --option-selected-border: rgba(88, 119, 30, 0.38);
  --option-selected-top: rgba(216, 228, 183, 0.92);
  --option-selected-shadow: rgba(88, 119, 30, 0.12);
  --domain-shell-top: rgba(27, 54, 68, 0.02);
  --domain-shell-border: rgba(27, 54, 68, 0.08);
  --domain-percentile: rgba(27, 54, 68, 0.82);
  --facet-group-bg: rgba(255, 251, 245, 0.82);
  --inset-highlight: rgba(255,255,255,0.45);
  --radius-lg: 24px;
  --radius-md: 16px;
  --font-display: "Iowan Old Style", "Palatino Linotype", "Source Han Serif SC", "Noto Serif SC", serif;
  --font-body: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --overview-top: 8px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #1c2b13;
  --bg-top: #25331b;
  --bg-bottom: #131d0d;
  --card: rgba(28, 39, 20, 0.88);
  --card-border: rgba(191, 255, 230, 0.1);
  --text: #eef7ef;
  --muted: #c4c3b7;
  --accent: #b85e00;
  --accent-soft: #4a3d25;
  --accent-deep: #ffd4a3;
  --teal: #b08699;
  --code-bg: rgba(191, 255, 230, 0.08);
  --surface-plain: rgba(36, 48, 27, 0.95);
  --surface-soft: rgba(33, 44, 24, 0.93);
  --surface-track: rgba(191, 255, 230, 0.08);
  --surface-border-strong: rgba(191, 255, 230, 0.14);
  --shadow: 0 22px 52px rgba(0, 0, 0, 0.34);
  --wash-a: rgba(176, 134, 153, 0.12);
  --wash-b: rgba(191, 255, 230, 0.1);
  --glow-a: rgba(176, 134, 153, 0.18);
  --glow-b: rgba(191, 255, 230, 0.12);
  --theme-toggle-border: var(--surface-border-strong);
  --chip-active-end: #8d6f7e;
  --chip-active-border: rgba(176, 134, 153, 0.34);
  --chip-active-shadow: rgba(176, 134, 153, 0.16);
  --button-primary-text: #fff4ea;
  --button-primary-end: #8f6543;
  --button-primary-shadow: rgba(184, 94, 0, 0.18);
  --progress-fill: linear-gradient(90deg, var(--teal) 0%, #cdb0be 100%);
  --option-selected-border: rgba(176, 134, 153, 0.34);
  --option-selected-top: rgba(82, 69, 57, 0.92);
  --option-selected-shadow: rgba(176, 134, 153, 0.12);
  --domain-shell-top: rgba(191, 255, 230, 0.02);
  --domain-shell-border: rgba(191, 255, 230, 0.1);
  --domain-percentile: rgba(238, 247, 239, 0.86);
  --facet-group-bg: rgba(31, 42, 22, 0.88);
  --inset-highlight: rgba(255,255,255,0.24);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, var(--wash-a), transparent 30%),
    radial-gradient(circle at top right, var(--wash-b), transparent 28%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg) 55%, var(--bg-bottom) 100%);
  font-family: var(--font-body);
  transition: background 220ms ease, color 220ms ease;
}

.page-glow {
  position: fixed;
  width: 38vw;
  height: 38vw;
  max-width: 360px;
  max-height: 360px;
  border-radius: 999px;
  filter: blur(70px);
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}

.page-glow-a { top: -80px; right: -80px; background: var(--glow-a); }
.page-glow-b { bottom: 8vh; left: -80px; background: var(--glow-b); }

.app-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 840px);
  margin: 0 auto;
  padding: 24px 16px 32px;
}

.theme-toggle {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 5;
  appearance: none;
  border: 1px solid var(--theme-toggle-border);
  background: var(--surface-plain);
  color: var(--text);
  border-radius: 999px;
  min-height: 40px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.theme-toggle:hover {
  transform: translateY(-1px);
}

.screen { display: none; animation: rise-in 360ms ease; }
.screen.active { display: block; }

.card,
.hero-card {
  backdrop-filter: blur(8px);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.hero-card,
.card { padding: 22px 18px; }

.hero-card {
  min-height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: var(--teal);
  font-weight: 700;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  line-height: 1.1;
}

h1 { font-size: clamp(2rem, 7vw, 3.4rem); }
h2 { font-size: clamp(1.6rem, 5.4vw, 2.4rem); }
h3 { font-size: 1.2rem; }

p { margin: 0; line-height: 1.7; }
a { color: var(--accent-deep); }
code {
  padding: 0 0.3em;
  border-radius: 0.4em;
  background: var(--code-bg);
  font-family: inherit;
  font-size: 0.95em;
}

.hero-copy { font-size: 1rem; }
.hero-copy.secondary,
.results-note,
.section-head p,
.progress-meta,
.copy-feedback { color: var(--muted); }

.hero-actions,
.export-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.landing-disclaimer {
  margin-top: 18px;
  color: var(--muted);
  text-align: right;
}

.landing-disclaimer summary {
  display: inline-block;
  cursor: pointer;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 0.18em;
  font-size: 0.94rem;
  font-style: italic;
  list-style: none;
}

.landing-disclaimer summary::-webkit-details-marker {
  display: none;
}

.landing-disclaimer-body {
  margin-top: 12px;
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 0.94rem;
}

.landing-disclaimer-body h3 {
  font-size: 1rem;
  color: var(--text);
}

.landing-disclaimer-body blockquote {
  margin: 0;
  padding-left: 14px;
  border-left: 2px solid var(--surface-border-strong);
  color: var(--muted);
}

.landing-disclaimer-updated {
  font-size: 0.88rem;
}

.norm-switch {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.norm-chip {
  appearance: none;
  border: 1px solid var(--card-border);
  background: var(--surface-plain);
  color: var(--muted);
  border-radius: 999px;
  padding: 10px 14px;
  min-height: 40px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.norm-chip.selected {
  color: #fffaf4;
  background: linear-gradient(135deg, var(--teal) 0%, var(--chip-active-end) 100%);
  border-color: var(--chip-active-border);
  box-shadow: 0 8px 18px var(--chip-active-shadow);
}

.button {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 14px 18px;
  min-height: 52px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease, color 180ms ease;
}

.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: 0.45; cursor: not-allowed; }

.button-primary {
  color: var(--button-primary-text);
  background: linear-gradient(135deg, var(--accent) 0%, var(--button-primary-end) 100%);
  box-shadow: 0 12px 24px var(--button-primary-shadow);
}

.button-secondary {
  color: var(--text);
  background: var(--surface-plain);
  border: 1px solid var(--card-border);
}

.hidden { display: none; }
.stack { display: grid; gap: 12px; }

.submit-form {
  margin-top: 16px;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.radio-field {
  margin: 0;
  padding: 0;
  border: 0;
}

.field-label {
  font-weight: 700;
  color: var(--text);
}

.subtle-label {
  font-size: 0.92rem;
  color: var(--muted);
}

.radio-list {
  display: grid;
  gap: 10px;
}

.radio-option {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 10px;
  row-gap: 8px;
  min-height: 50px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
  font-weight: 600;
}

.radio-option input {
  margin: 0;
  accent-color: var(--teal);
}

.radio-option-expand {
  grid-column: 2;
}

.radio-option-expand.hidden {
  display: none;
}

.field-input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
}

.quiz-header {
  position: sticky;
  top: 12px;
  z-index: 2;
  margin-bottom: 14px;
}

.progress-topline {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}

.progress-count { font-weight: 800; color: var(--accent-deep); }

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--surface-track);
  overflow: hidden;
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--progress-fill);
  transition: width 220ms ease;
}

.question-card { padding-top: 18px; margin-bottom: 14px; }

.question-content {
  will-change: transform;
}

.question-text {
  margin-bottom: 20px;
  font-size: clamp(1.55rem, 6.5vw, 2.3rem);
  line-height: 1.25;
}

.option-list { display: grid; gap: 10px; }

.option-button {
  width: 100%;
  text-align: left;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.question-content.is-switching {
  animation: question-slide 220ms cubic-bezier(.22,.61,.36,1);
}

.option-button.selected {
  border-color: var(--option-selected-border);
  background: linear-gradient(180deg, var(--option-selected-top), var(--surface-soft));
  box-shadow: 0 10px 22px var(--option-selected-shadow);
}

.nav-card {
  position: sticky;
  bottom: 12px;
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 10px;
}

.nav-button { width: 100%; }

.results-intro,
.card + .card { margin-bottom: 14px; }

.section-head { display: grid; gap: 6px; margin-bottom: 16px; }

.overview-anchor {
  height: 0;
  position: relative;
}

.overview-card {
  position: sticky;
  top: var(--overview-top);
  z-index: 3;
  padding-top: 10px;
  padding-bottom: 12px;
}

.domain-chart {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  min-height: clamp(146px, 20vh, 188px);
}

.domain-column {
  display: grid;
  gap: 6px;
  justify-items: center;
}

.domain-bar-shell {
  width: 100%;
  max-width: 92px;
  height: clamp(104px, 15vh, 138px);
  display: flex;
  align-items: end;
  justify-content: center;
  position: relative;
  padding: 6px 0 0;
  border-radius: 18px 18px 12px 12px;
  background: linear-gradient(180deg, var(--domain-shell-top), var(--surface-track));
  border: 1px solid var(--domain-shell-border);
}

.domain-bar {
  width: min(100%, 54px);
  min-height: 8px;
  border-radius: 18px 18px 8px 8px;
  box-shadow: inset 0 1px 0 var(--inset-highlight);
}

.domain-meta {
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.35;
}

.domain-percentile {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 2px;
  font-family: var(--font-display);
  font-size: clamp(0.9rem, 4.2vw, 1.28rem);
  font-weight: 700;
  color: var(--domain-percentile);
  pointer-events: none;
}

.domain-name {
  font-weight: 800;
  font-size: 0.78rem;
}

.facet-card {
  position: relative;
  z-index: 1;
}

.facet-groups {
  display: grid;
  gap: 14px;
}

.facet-group {
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--facet-group-bg);
  border: 1px solid var(--card-border);
}

.facet-group-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 12px;
}

.facet-group-title {
  font-weight: 800;
}

.facet-group-meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.facet-group-description {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.7;
}

.facet-list {
  display: grid;
  gap: 12px;
}

.facet-item {
  display: grid;
  gap: 7px;
}

.facet-item-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.facet-item-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.facet-item-score {
  color: var(--muted);
  font-size: 0.84rem;
  white-space: nowrap;
}

.facet-bar-track {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-track);
}

.facet-bar-fill {
  height: 100%;
  min-width: 6px;
  border-radius: inherit;
}

.facet-item-desc {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.65;
}

.feedback-card {
  text-align: center;
}

.feedback-contact {
  font-size: 1rem;
  font-weight: 700;
}

.feedback-contact a {
  word-break: break-all;
}

.markdown-box {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  background: var(--surface-soft);
  color: var(--text);
  font: 0.94rem/1.6 ui-monospace, "SFMono-Regular", Consolas, monospace;
  white-space: pre-wrap;
}

.markdown-box {
  min-height: 260px;
  resize: vertical;
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes question-slide {
  0% { transform: translateX(12px); }
  100% { transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
  .question-content.is-switching {
    animation: none;
  }
}

@media (min-width: 720px) {
  .app-shell { padding: 30px 22px 40px; }
  .hero-card, .card { padding: 28px 26px; }
  .facet-groups {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .domain-chart {
    min-height: clamp(190px, 26vh, 250px);
  }
  .domain-bar-shell {
    height: clamp(132px, 19vh, 182px);
  }
}
