/* 梦说 · 样式。不依赖任何外部字体或 CDN（国内访问稳定）。 */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efece4;
  --text: #1d1f24;
  --muted: #5f6370;
  --border: #dcd8cd;
  --accent: #4a4ac4;
  --accent-ink: #ffffff;
  --accent-soft: #e6e6fa;
  --warn-bg: #fff4e0;
  --warn-border: #e9b45a;
  --danger-bg: #fdecec;
  --danger-border: #d9534f;
  --k-char: #dbe7ff;
  --k-animal: #dff3e4;
  --k-agg: #ffd9d6;
  --k-fri: #fde6f3;
  --k-emo: #fff0c2;
  --k-set: #e2f1f6;
  --k-event: #ece4ff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 20, 40, .06), 0 4px 16px rgba(20, 20, 40, .05);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  --serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161c; --surface: #1c1f27; --surface-2: #232733; --text: #e8e8ee; --muted: #a0a4b2;
    --border: #333849; --accent: #8f8ff5; --accent-ink: #14161c; --accent-soft: #2b2c52;
    --warn-bg: #3a2f1a; --warn-border: #b9893a; --danger-bg: #3d1f22; --danger-border: #e0716d;
    --k-char: #233456; --k-animal: #1f3a2a; --k-agg: #4a2523; --k-fri: #45263a; --k-emo: #45391a; --k-set: #1f3a44; --k-event: #332a52;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14161c; --surface: #1c1f27; --surface-2: #232733; --text: #e8e8ee; --muted: #a0a4b2;
  --border: #333849; --accent: #8f8ff5; --accent-ink: #14161c; --accent-soft: #2b2c52;
  --warn-bg: #3a2f1a; --warn-border: #b9893a; --danger-bg: #3d1f22; --danger-border: #e0716d;
  --k-char: #233456; --k-animal: #1f3a2a; --k-agg: #4a2523; --k-fri: #45263a; --k-emo: #45391a; --k-set: #1f3a44; --k-event: #332a52;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.75 var(--font); -webkit-text-size-adjust: 100%; }
a { color: var(--accent); text-underline-offset: 3px; }
.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; z-index: 10; background: var(--surface); padding: 6px 10px; border-radius: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* header */
.site-header { position: sticky; top: 0; z-index: 5; background: var(--bg); background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); padding-top: env(safe-area-inset-top); }
.header-inner { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "brand nav toggle"; align-items: center; gap: 8px 16px; min-height: 56px; }
.brand { grid-area: brand; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 700; font-size: 1.125rem; color: var(--text); text-decoration: none; }
.brand svg { color: var(--accent); }
nav { grid-area: nav; display: flex; justify-content: flex-end; gap: 2px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
nav::-webkit-scrollbar { display: none; }
nav a { display: inline-flex; align-items: center; min-height: 40px; color: var(--muted); text-decoration: none; font-size: .9rem; padding: 0 10px; border-radius: 8px; white-space: nowrap; }
nav a:hover { color: var(--text); background: var(--surface-2); }

.theme-toggle { grid-area: toggle; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle .icon-sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
body, .card, .panel, .theme, textarea, select, .btn { transition: background-color .2s ease, border-color .2s ease, color .2s ease; }

/* hero */
.hero { padding-top: 56px; padding-bottom: 24px; }
.eyebrow { color: var(--accent); font-weight: 600; font-size: .875rem; letter-spacing: .08em; margin: 0 0 8px; }
h1 { font-family: var(--serif); font-size: clamp(1.9rem, 5vw, 2.8rem); line-height: 1.3; margin: 0 0 16px; letter-spacing: .01em; }
.lede { font-size: 1.075rem; color: var(--muted); max-width: 40em; margin: 0; }
.lede strong { color: var(--text); }

/* sections */
h2 { font-family: var(--serif); font-size: 1.6rem; line-height: 1.35; margin: 0 0 16px; }
h3 { font-size: 1.1rem; margin: 28px 0 8px; }
h4 { font-size: 1rem; margin: 0 0 12px; }
.prose { padding-top: 56px; }
.prose p, .prose li { max-width: 42em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: 4px; }
section.tool { padding-top: 24px; }

/* cards & form */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
textarea, select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
textarea { width: 100%; padding: 12px 14px; resize: vertical; line-height: 1.7; }
select { padding: 6px 10px; }
.form-row { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; margin: 14px 0; font-size: .95rem; }
.form-row label { display: inline-flex; align-items: center; gap: 8px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn { font: inherit; font-size: .95rem; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-small { padding: 5px 12px; font-size: .875rem; margin-left: 6px; }
.link { font: inherit; background: none; border: 0; padding: 0 4px; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link:disabled { color: var(--muted); cursor: default; text-decoration: none; opacity: .6; }
.series-line { margin: 14px 0 0; font-size: .9rem; }
.privacy { margin: 6px 0 0; }

/* results */
.results { margin-top: 20px; display: grid; gap: 16px; }
.result-head h3 { margin: 8px 0 0; font-size: 1.25rem; }
.result-head p { margin: 2px 0 0; font-size: .9rem; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
details.panel > summary { cursor: pointer; font-weight: 600; }
.coded-text { line-height: 2.1; margin: 12px 0; }
mark { background: var(--k-event); color: inherit; border-radius: 4px; padding: 1px 3px; }
mark.k-char { background: var(--k-char); }
mark.k-animal { background: var(--k-animal); }
mark.k-agg { background: var(--k-agg); }
mark.k-fri { background: var(--k-fri); }
mark.k-emo { background: var(--k-emo); }
mark.k-set { background: var(--k-set); }
mark.k-crisis { background: var(--danger-bg); outline: 1px solid var(--danger-border); }
mark.is-neg { background: transparent; outline: 1px dashed var(--border); text-decoration: line-through; text-decoration-color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px; font-size: .8rem; margin: 0; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.norm-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.norm-table caption { text-align: left; font-weight: 600; padding-bottom: 8px; }
.norm-table th, .norm-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.norm-table thead th { font-size: .8rem; color: var(--muted); font-weight: 600; }
.norm-table tbody th { font-weight: 500; }
.norm-table tbody th small { display: block; color: var(--muted); font-weight: 400; font-size: .75rem; }
.norm-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.norm-table.static { background: var(--surface); border-radius: var(--radius); }
.bar-cell { width: 28%; min-width: 110px; }
.bar { position: relative; height: 10px; border-radius: 6px; background: var(--surface-2); }
.bar-you { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; background: var(--accent); }
.bar-norm { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--text); }
.reflect { margin: 0; padding-left: 1.3em; }
.reflect li + li { margin-top: 8px; }

.callout { background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: var(--radius); padding: 14px 16px; margin: 16px 0; }
.callout p { margin: 6px 0 0; }
.callout-crisis { background: var(--danger-bg); border-color: var(--danger-border); }
.callout-irt { background: var(--accent-soft); border-color: var(--accent); }
.results .callout { margin: 0; }

/* themes */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin: 20px 0 12px; }
.theme { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.theme h3 { margin: 0; font-size: 1rem; }
.theme .stat { font-family: var(--serif); font-size: 1.9rem; font-weight: 700; color: var(--accent); margin: 2px 0 6px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.theme p:not(.stat) { margin: 0; font-size: .9rem; color: var(--muted); }

a.theme { display: flex; flex-direction: column; color: inherit; text-decoration: none; transition: border-color .15s ease, transform .15s ease; }
a.theme:hover { border-color: var(--accent); }
a.theme p:last-of-type { flex: 1; }
.theme-more { margin-top: 10px; font-size: .85rem; color: var(--accent); }
nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }

/* 主题页 */
.theme-page { padding-top: 24px; }
.theme-page h1 { margin-top: 8px; }
.theme-page h2 { margin-top: 40px; font-size: 1.35rem; }
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); }
.breadcrumb a { color: var(--muted); }
.stat-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 32px; margin-top: 24px; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.stat-main { display: flex; flex-direction: column; justify-content: center; }
.stat-main p { margin: 0; }
.stat-num { font-family: var(--serif); font-size: clamp(2.6rem, 9vw, 3.6rem); font-weight: 700; line-height: 1.1; color: var(--accent); font-variant-numeric: tabular-nums; }
.stat-split p { margin: 2px 0 10px; }
.split-row { display: grid; grid-template-columns: 6.5em 1fr 3.4em; align-items: center; gap: 10px; font-size: .9rem; margin-top: 6px; }
.split-bar { height: 8px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.split-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.split-row .num { text-align: right; font-variant-numeric: tabular-nums; }
.prose .stat-extra { grid-column: 1 / -1; list-style: none; margin: 8px 0 0; padding: 12px 0 0; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 6px 24px; font-size: .9rem; }
.stat-extra li { display: flex; gap: 8px; margin: 0 !important; }
.stat-extra span { color: var(--muted); }
.cta { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 40px; }
.cta p { margin: 4px 0 0; }
.cta .btn { white-space: nowrap; text-decoration: none; }
.related { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.related-card { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; color: var(--text); text-decoration: none; }
.related-card:hover { border-color: var(--accent); }
.related-card strong { color: var(--accent); font-variant-numeric: tabular-nums; }
.related-card.more span { color: var(--muted); }
.hub-list { display: grid; gap: 10px; margin: 24px 0 12px; }
.hub-row { display: grid; grid-template-columns: 12em 1fr 3.6em; grid-template-areas: "name bar num" "teaser teaser teaser"; align-items: center; gap: 4px 14px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); text-decoration: none; }
.hub-row:hover { border-color: var(--accent); }
.hub-name { grid-area: name; font-weight: 600; }
.hub-bar { grid-area: bar; height: 8px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.hub-bar > span { display: block; height: 100%; background: var(--accent); }
.hub-row .num { grid-area: num; text-align: right; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.hub-teaser { grid-area: teaser; font-size: .875rem; color: var(--muted); }

/* IRT */
.irt-work { display: grid; gap: 22px; margin-top: 20px; }
.step { display: grid; grid-template-columns: 32px 1fr; gap: 12px; }
.step-n { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.step label { display: block; margin-bottom: 6px; }
.step p { margin: 0 0 8px; }
.timer { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.timer output { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 1.6rem; font-variant-numeric: tabular-nums; min-width: 4.5ch; }
.done { color: var(--accent); font-weight: 600; margin-top: 10px !important; }

/* glossary */
.glossary dt { font-weight: 700; margin-top: 18px; }
.glossary dt span { font-weight: 400; color: var(--muted); font-size: .9rem; margin-left: 4px; }
.glossary dd { margin: 4px 0 0; max-width: 42em; }
.glossary dd a { font-size: .85rem; margin-left: 6px; white-space: nowrap; }

.bounds { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.bounds > div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 18px 10px; }
.bounds h3 { margin-top: 14px; }

#faq details { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px; max-width: 42em; }
#faq summary { cursor: pointer; font-weight: 600; }
#faq details p { margin: 8px 0 0; }

.refs li { font-size: .9rem; margin-top: 8px; overflow-wrap: anywhere; }

.site-footer { margin-top: 72px; padding: 28px 0 40px; border-top: 1px solid var(--border); font-size: .9rem; color: var(--muted); }
.site-footer p { margin: 6px 0; }

@media (max-width: 720px) {
  html { scroll-padding-top: 112px; }
  .header-inner { grid-template-columns: 1fr auto; grid-template-areas: "brand toggle" "nav nav"; gap: 0 12px; padding-top: 4px; }
  nav { justify-content: flex-start; margin: 0 -16px; padding: 0 22px 2px 6px;
        -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
                mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
}
@media (max-width: 600px) {
  body { font-size: 16px; }
  .hero { padding-top: 28px; }
  .prose { padding-top: 44px; }
  .card { padding: 16px; }
  .panel { padding: 16px; }
  .form-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .form-row label { min-height: 44px; }
  select { min-height: 44px; flex: 1; }
  .actions .btn { flex: 1 1 auto; min-height: 44px; }
  .series-line { display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; }
  .link { min-height: 40px; padding: 0 6px; }

  /* 结果对照表：改成每行一张小卡片 —— 指标名 + 数值在上，说明在下 */
  .norm-table:not(.static):not(.compact) thead { display: none; }
  .norm-table:not(.static):not(.compact) tr { display: grid; grid-template-columns: 1fr auto auto; grid-template-areas: "label you norm" "bar bar bar" "note note note"; column-gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .norm-table:not(.static):not(.compact) th, .norm-table:not(.static):not(.compact) td { border: 0; padding: 0; }
  .norm-table:not(.static):not(.compact) tbody th { grid-area: label; }
  .norm-table:not(.static):not(.compact) td:nth-of-type(1) { grid-area: you; font-weight: 600; }
  .norm-table:not(.static):not(.compact) td:nth-of-type(1)::before { content: "你的梦 "; font-weight: 400; color: var(--muted); font-size: .75rem; }
  .norm-table:not(.static):not(.compact) td:nth-of-type(2) { grid-area: norm; }
  .norm-table:not(.static):not(.compact) td:nth-of-type(2)::before { content: "常模 "; color: var(--muted); font-size: .75rem; }
  .norm-table:not(.static):not(.compact) td.bar-cell { grid-area: bar; display: block; width: auto; min-width: 0; padding-top: 8px; }
  .norm-table:not(.static):not(.compact) td:last-child { grid-area: note; font-size: .8rem; margin-top: 4px; }
  .norm-table th, .norm-table td { padding: 8px 6px; }

  .step { grid-template-columns: 1fr; gap: 8px; }
  .step-n { width: 26px; height: 26px; font-size: .875rem; }
  .timer .btn { flex: 1; min-height: 44px; }
  .theme-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .theme { padding: 12px; }
  .theme .stat { font-size: 1.5rem; }
  .stat-hero { grid-template-columns: 1fr; padding: 16px; }
  .cta { flex-direction: column; align-items: stretch; }
  .cta .btn { text-align: center; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .hub-row { grid-template-columns: 1fr 3.6em; grid-template-areas: "name num" "bar bar" "teaser teaser"; gap: 6px 12px; }
  .related { grid-template-columns: 1fr 1fr; }
  .related-card { padding: 12px; min-height: 44px; }
  .site-footer { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
}
@media (max-width: 360px) { .theme-grid { grid-template-columns: 1fr; } }
@media (hover: none) { .btn:hover, .theme-toggle:hover { border-color: var(--border); } .theme-toggle:hover { color: var(--text); } }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }
