:root {
  color-scheme: light;
  --page: #ecf2f3;
  --paper: #fbfdfd;
  --ink: #172c35;
  --muted: #47616a;
  --line: #c8d7da;
  --deep: #143b46;
  --accent: #21626a;
  --sea: #bce0dc;
  --lime: #e9e28c;
  --heading: "Noto Serif CJK SC", "Songti SC", "STSong", SimSun, serif;
  font-family: "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--page);
  font-synthesis: none;
  line-height: 1.55;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; }
[hidden] { display: none !important; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2 { font-family: var(--heading); line-height: 1.25; }
h1 { font-size: clamp(1.75rem, 5.8vw, 2.65rem); }
h1[tabindex="-1"]:focus { outline: none; }
h2 { font-size: clamp(1.2rem, 3.6vw, 1.56rem); }
button, input { font: inherit; }
button, a, input, label { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
button:enabled, a { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid #2e7b80; outline-offset: 4px; }

.survey-shell, .admin-shell {
  width: min(100%, 40rem);
  min-height: 100dvh;
  margin-inline: auto;
  padding-inline: clamp(1.125rem, 4.5vw, 2rem);
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
}
.admin-shell { width: min(100%, 70rem); }
.site-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: calc(4.45rem + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  margin-bottom: clamp(1.35rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--line);
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  font-size: .875rem;
  font-weight: 700;
  letter-spacing: .14em;
}
.brand-mark {
  display: inline-block;
  width: 20px;
  height: 23px;
  background:
    linear-gradient(var(--accent), var(--accent)) 1px center / 3px 9px,
    linear-gradient(var(--accent), var(--accent)) 7px center / 3px 17px,
    linear-gradient(var(--accent), var(--accent)) 13px center / 3px 13px;
  background-repeat: no-repeat;
}
.text-action {
  display: inline-flex;
  gap: .3rem;
  align-items: center;
  min-height: 44px;
  padding: .2rem .35rem;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--accent);
  font-size: .875rem;
  text-decoration: underline;
  text-underline-offset: .23em;
  text-decoration-color: #749398;
}
.button {
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .65rem 1rem;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 700;
  font-size: .95rem;
  text-decoration: none;
  text-align: center;
}
.primary { color: #fff; background: var(--deep); }
.primary:disabled { color: #4a6269; background: #dbe5e7; }
.secondary { color: var(--deep); background: transparent; border-color: #9fb8bd; }
.secondary:disabled, .text-action:disabled { opacity: .55; }
.form-message { color: #863a35; margin-top: .75rem; font-size: .875rem; }

.intro h1 {
  font-size: clamp(2.55rem, 8.6vw, 4.05rem);
  letter-spacing: .035em;
  margin-bottom: 1.35rem;
  line-height: 1.18;
}
.signal-print {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  height: clamp(6.25rem, 25vw, 9.25rem);
  border-radius: 3px 28px 3px 3px;
  background:
    linear-gradient(90deg, #bce0dc20 1px, transparent 1px) 50% 0 / 22px 100%,
    linear-gradient(0deg, #bce0dc20 1px, transparent 1px) 0 50% / 100% 22px,
    var(--deep);
}
.signal-print::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid #bbddd747;
  border-radius: inherit;
  pointer-events: none;
}
.signal-wave {
  width: 91%;
  height: 74%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(transparent calc(50% - .5px), #bce0dc6e 50%, transparent calc(50% + .5px));
}
.signal-wave span {
  width: clamp(1px, .33vw, 2px);
  background: var(--sea);
  opacity: .92;
}
.signal-wave span:nth-child(n+19):nth-child(-n+28) { background: var(--lime); }
.intro-description {
  margin-block: 1.4rem 1.65rem;
  display: grid;
  gap: .3rem;
  color: var(--muted);
  max-width: 48ch;
  font-size: .95rem;
}
.intro-time { color: var(--ink); font-weight: 700; }
.start-form {
  display: grid;
  gap: .55rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.start-form label { font-size: .9rem; font-weight: 700; }
.start-form label span { margin-left: .35rem; color: var(--muted); font-size: .8rem; font-weight: 400; }
.start-form input {
  min-height: 52px;
  width: 100%;
  padding: .65rem .8rem;
  border: 1px solid #a4bbc0;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-size: 1rem;
}
.start-form input::placeholder { color: #587079; }
.start-form .button { margin-top: .3rem; }
.start-form .form-message { margin: 0; }

.question-progress { margin-bottom: 1rem; }
.progress-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: .48rem;
  font-weight: 700;
  color: var(--muted);
  font-size: .82rem;
  font-variant-numeric: tabular-nums;
}
progress {
  display: block;
  width: 100%;
  height: .35rem;
  overflow: hidden;
  border: 0;
  border-radius: 20px;
  appearance: none;
  background: #cfdddf;
  color: var(--accent);
}
progress::-webkit-progress-bar { background: #cfdddf; }
progress::-webkit-progress-value { background: currentColor; border-radius: 20px; }
progress::-moz-progress-bar { background: currentColor; border-radius: 20px; }
.question-panel {
  border: 1px solid var(--line);
  border-radius: 17px;
  padding: clamp(.95rem, 3.6vw, 1.65rem);
  background: var(--paper);
}
.question-prompt { color: var(--muted); margin-block: .55rem 1.05rem; }
fieldset { min-width: 0; border: 0; padding: 0; margin: 0; }
.choice-hint { color: var(--muted); font-size: .8rem; margin-bottom: .53rem; }
.options { display: grid; gap: .5rem; }
.option {
  min-width: 0;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: .67rem;
  padding: .58rem .74rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: .94rem;
  font-weight: 700;
  cursor: pointer;
}
.option input {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}
.option small {
  display: block;
  color: var(--muted);
  font-size: .79rem;
  font-weight: 400;
  line-height: 1.5;
}
.option:has(input:checked) { background: #e3f0ee; border-color: #6e9e9c; }
.option:has(input:disabled) { color: var(--muted); background: #f0f4f4; cursor: default; }
.option:has(input:checked:disabled) { background: #e3f0ee; }
.question-nav { margin-top: 1.1rem; display: grid; grid-template-columns: 1fr 1.7fr; gap: .65rem; }
.mood-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mood-options .option { gap: .47rem; padding-inline: .55rem; font-size: .83rem; }

.player {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: .7rem;
  align-items: center;
  padding: .75rem;
  margin-bottom: 1rem;
  border-radius: 11px;
  color: #f4fcfb;
  background: var(--deep);
}
.play-button {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  background: var(--sea);
  color: var(--deep);
}
.play-icon {
  width: 15px;
  height: 18px;
  margin-left: 3px;
  background: currentColor;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}
.play-button[data-playing="true"] .play-icon {
  margin: 0;
  clip-path: polygon(0 0, 33% 0, 33% 100%, 0 100%, 0 0, 66% 0, 100% 0, 100% 100%, 66% 100%, 66% 0);
}
.player :focus-visible { outline-color: var(--lime); }
.audio-progress { height: .34rem; background: #42636a; color: var(--lime); }
.audio-progress::-webkit-progress-bar { background: #42636a; }
.audio-time {
  display: flex;
  justify-content: space-between;
  margin-top: .25rem;
  font-size: .72rem;
  color: var(--sea);
  font-variant-numeric: tabular-nums;
}
.replay { color: #f1fbfa; text-decoration: none; white-space: nowrap; }
.replay span { font-size: 1.15rem; }
.player-message { grid-column: 1 / -1; font-size: .8rem; color: #f9d7a6; }

.result { background: var(--paper); border-radius: 18px; overflow: hidden; border: 1px solid var(--line); }
.result-hero {
  background:
    repeating-radial-gradient(ellipse at 105% 10%, transparent 0 16px, #bce0dc24 17px 18px, transparent 19px 27px),
    var(--deep);
  color: #fff;
  padding: clamp(1.25rem, 5.5vw, 2.3rem);
}
.result-hero h1 { margin-bottom: .73rem; }
.result-alias { font-size: .85rem; color: var(--sea); margin-bottom: .35rem; overflow-wrap: anywhere; }
.result-score { display: flex; align-items: baseline; gap: .38rem; color: var(--lime); line-height: 1.05; }
.result-score strong { font-size: clamp(3.6rem, 12vw, 5.2rem); letter-spacing: -.045em; }
.result-score span { font-size: 1.42rem; color: var(--sea); }
.result-hero > p:last-child { margin-top: .4rem; color: #e8f5f4; font-size: .91rem; }
.result-section { padding: 1.1rem clamp(1rem, 5.5vw, 2.3rem) 1.3rem; }
.result-section + .result-section { border-top: 1px solid var(--line); }
.profile { display: grid; margin-top: .55rem; }
.profile div {
  padding-block: .58rem;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 5.25rem minmax(0, 1fr);
  align-items: baseline;
  gap: .38rem;
}
.profile div:last-child { border-bottom: 0; }
.profile dt, .profile small { color: var(--muted); font-size: .81rem; font-weight: 400; }
.profile dd { font-size: .95rem; font-weight: 700; }
.profile small { display: block; }
.reveals { margin: .48rem 0 0; padding-left: 1.5rem; }
.reveals li { border-bottom: 1px solid var(--line); padding: .65rem 0 .6rem .22rem; }
.reveals li:last-child { border-bottom: 0; }
.reveals li::marker { color: var(--muted); font-size: .8rem; }
.reveal-heading { display: flex; gap: .4rem; justify-content: space-between; align-items: start; font-size: .93rem; }
.reveal-heading strong { overflow-wrap: anywhere; }
.matched { color: var(--deep); background: #e2efeb; padding: .12rem .38rem; border-radius: 4px; white-space: nowrap; font-size: .72rem; }
.reveals dl { display: flex; flex-wrap: wrap; gap: .2rem .7rem; font-size: .8rem; }
.reveals dl div { display: flex; gap: .3rem; }
.reveals dt { color: var(--muted); }

.admin-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: .75rem;
  margin-bottom: 1.35rem;
}
.admin-heading p { color: var(--muted); margin-top: .45rem; font-size: .85rem; }
.admin-heading .button { flex: none; }
.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid #acc3c7;
  border-radius: 11px;
  background: #dfebec;
  overflow: hidden;
}
.metrics > div { min-width: 0; padding: .8rem .85rem; }
.metrics > div:nth-child(even) { border-left: 1px solid #acc3c7; }
.metrics > div:nth-child(n+3) { border-top: 1px solid #acc3c7; }
.metrics dt { color: var(--muted); font-size: .79rem; font-weight: 700; }
.metrics dd { font-weight: 700; font-size: clamp(1.58rem, 5vw, 2.52rem); font-variant-numeric: tabular-nums; }
.metrics small { font-weight: 400; color: var(--muted); margin-left: .24rem; font-size: .8rem; white-space: nowrap; }
.admin-section { margin-top: 1.6rem; }
.admin-section h2 { margin-bottom: .7rem; }
.tag-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.tag-stat { border-top: 2px solid #83abad; padding: .65rem .15rem .45rem; }
.tag-stat header, .tag-reading { display: flex; align-items: baseline; justify-content: space-between; gap: .2rem .45rem; flex-wrap: wrap; }
.tag-stat h3 { font-size: 1rem; }
.tag-stat span { color: var(--muted); font-size: .73rem; }
.tag-meter { margin-block: .55rem .27rem; height: 5px; }
.tag-reading strong { font-size: 1.26rem; font-variant-numeric: tabular-nums; }
.tag-bias { padding-top: .32rem; margin-top: .34rem; border-top: 1px solid var(--line); }
.tag-bias strong { display: block; font-size: .82rem; }
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}
table { width: 100%; min-width: 38rem; border-collapse: collapse; text-align: left; font-size: .87rem; }
.respondents-table { min-width: 54rem; }
th, td { padding: .67rem .8rem; vertical-align: top; }
th { white-space: nowrap; background: #dfebec; font-size: .78rem; }
tbody tr + tr { border-top: 1px solid var(--line); }
td:first-child { font-weight: 700; max-width: 17rem; overflow-wrap: anywhere; }
.respondents-table td:nth-child(2) { white-space: nowrap; }
td.table-empty { color: var(--muted); font-weight: 400; }
.table-empty { position: sticky; left: 0; }

@media (min-width: 48rem) {
  .survey-shell { padding-inline: 2rem; }
  .start-form { grid-template-columns: minmax(0, 1fr) auto; }
  .start-form label, .start-form .form-message { grid-column: 1 / -1; }
  .start-form .button { margin-top: 0; min-width: 9.25rem; }
  .metrics, .tag-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .metrics > div:nth-child(n) { border-top: 0; }
  .metrics > div + div { border-left: 1px solid #acc3c7; }
  .metrics > div { padding: 1rem 1.15rem; }
  .tag-grid { gap: 1.1rem; }
}

@media (hover: hover) {
  .primary:enabled:hover { background: #245663; }
  .secondary[href]:hover, .secondary:enabled:hover { background: #dfebec; }
  .text-action:hover { text-decoration-color: currentColor; }
  .option:not(:has(input:disabled)):hover { border-color: #719b9f; }
  .play-button:hover { background: #d3efea; }
  .replay:hover { text-decoration: underline; }
}

@media (prefers-reduced-motion: no-preference) {
  .option, .button, .play-button { transition: background-color .14s, border-color .14s; }
}
