/* 整套配色与字体：改这几个变量即可。
   七种粉彩是底色，每一章取其中两三种做渐变。 */
@property --g1 { syntax: "<color>"; inherits: true; initial-value: #bfe6d8; }
@property --g2 { syntax: "<color>"; inherits: true; initial-value: #f3efc0; }
@property --g3 { syntax: "<color>"; inherits: true; initial-value: #f5b9c9; }

:root {
  --mint: #bfe6d8;
  --butter: #f3efc0;
  --pink: #f5b9c9;
  --peach: #f7d0bb;
  --sky: #bcd8ec;
  --lilac: #c9c7ec;
  --slate: #afc3ce;

  --paper: #f4f2ea;
  --ink: #2a3037;
  --mute: #56606a;
  --faint: rgba(42, 48, 55, 0.16);
  --glass: rgba(255, 255, 255, 0.34);
  --accent: #2f6f68;
  --sans: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;

  --g1: var(--mint); --g2: var(--butter); --g3: var(--pink);
  transition: --g1 1.2s ease, --g2 1.2s ease, --g3 1.2s ease;
}
:root[data-theme="night"] {
  --mint: #1d3a36;
  --butter: #37351f;
  --pink: #40242f;
  --peach: #3f2d25;
  --sky: #1f3345;
  --lilac: #2a2a48;
  --slate: #24313a;

  --paper: #17191c;
  --ink: #eceef0;
  --mute: #a3abb3;
  --faint: rgba(236, 238, 240, 0.16);
  --glass: rgba(255, 255, 255, 0.06);
  --accent: #9fd6c6;
}

/* 每一章一张卡的颜色 */
[data-ch="zhi"]   { --g1: var(--mint);   --g2: var(--mint);   --g3: var(--butter); }
[data-ch="guan"]  { --g1: var(--butter); --g2: var(--peach);  --g3: var(--pink); }
[data-ch="wen"]   { --g1: var(--slate);  --g2: var(--slate);  --g3: var(--pink); }
[data-ch="liang"] { --g1: var(--sky);    --g2: var(--mint);   --g3: var(--butter); }
[data-ch="she"]   { --g1: var(--lilac);  --g2: var(--slate);  --g3: var(--sky); }
[data-ch="jing"]  { --g1: var(--pink);   --g2: var(--lilac);  --g3: var(--sky); }
[data-ch="yuan"]  { --g1: var(--peach);  --g2: var(--butter); --g3: var(--mint); }
[data-ch="page"]  { --g1: var(--paper);  --g2: var(--paper);  --g3: var(--sky); }

* { box-sizing: border-box; margin: 0; }
html, body { min-height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 300;
  font-size: 16px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  transition: color 0.8s;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(165deg, var(--g1) 0%, var(--g2) 52%, var(--g3) 100%);
}

button, select, textarea, input { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

.quiet {
  color: var(--mute);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  padding: 0.6em 0.2em;
  cursor: pointer;
  transition: color 0.4s;
}
.quiet:hover, .quiet:focus-visible { color: var(--ink); }
.quiet:disabled { cursor: default; color: var(--mute); }
:focus-visible { outline: 1px solid var(--mute); outline-offset: 4px; }
textarea:focus-visible, input:focus-visible { outline: none; }

.fade { animation: fade 1.4s ease both; }
@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ── 首页 ── */
.home {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem 2rem;
  text-align: center;
}
.ring { width: 80px; height: 80px; color: var(--ink); }
.ring circle { fill: none; stroke: currentColor; stroke-width: 0.6; }
.ring .trace { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 3.2s cubic-bezier(0.6, 0, 0.2, 1) 0.2s forwards; }
.ring .dot { fill: var(--ink); stroke: none; transform-origin: 50px 50px; animation: breathe 7s ease-in-out infinite; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes breathe { 0%, 100% { transform: scale(0.55); opacity: 0.5; } 50% { transform: scale(1); opacity: 1; } }
.title { font-size: 1.9rem; font-weight: 200; letter-spacing: 0.3em; padding-left: 0.3em; margin-top: 1.4rem; line-height: 1.4; }
.tagline { color: var(--mute); font-size: 0.88rem; letter-spacing: 0.06em; margin-top: 0.5rem; }
.year { margin-top: 1.2rem; }
.year select {
  appearance: none;
  background: var(--glass);
  border: 1px solid var(--faint);
  border-radius: 999px;
  text-align: center;
  text-align-last: center;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  padding: 0.25em 1.2em;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.year select option { background: var(--paper); color: var(--ink); }
.letter { margin-top: 1.4rem; max-width: 28rem; }
.letter blockquote, .prev blockquote {
  margin-top: 0.6rem;
  padding: 0.2rem 0 0.2rem 1.1rem;
  border-left: 1px solid var(--accent);
  color: var(--mute);
  text-align: left;
  white-space: pre-wrap;
  animation: fade 1.6s ease both;
}
.chapters { width: 100%; max-width: 26rem; margin-top: 2rem; border-top: 1px solid var(--faint); }
.chapters a {
  display: grid;
  grid-template-columns: 0.8rem 1.6rem auto 1fr auto;
  align-items: baseline;
  gap: 0 0.9rem;
  padding: 0.62rem 0.2rem;
  border-bottom: 1px solid var(--faint);
  text-align: left;
  transition: padding 0.4s;
}
.chapters a::before {
  content: "";
  align-self: center;
  width: 0.8rem;
  height: 1.1rem;
  border-radius: 3px;
  background: linear-gradient(165deg, var(--g1), var(--g2) 52%, var(--g3));
  box-shadow: 0 0 0 1px var(--faint), 0 2px 6px rgba(42, 48, 55, 0.12);
  transition: transform 0.4s;
}
.chapters a:hover::before, .chapters a:focus-visible::before { transform: rotate(-8deg) scale(1.15); }
.chapters a:hover, .chapters a:focus-visible { padding-left: 0.6rem; }
.chapters .no { color: var(--mute); font-size: 0.72rem; letter-spacing: 0.1em; font-variant-numeric: tabular-nums; }
.chapters .cap { font-size: 0.98rem; font-weight: 400; }
.chapters .note { color: var(--mute); font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chapters .pct { color: var(--mute); font-size: 0.72rem; font-variant-numeric: tabular-nums; }
.chapters a.done .pct { color: var(--accent); }
.home-foot { display: flex; gap: 2rem; margin-top: 1.6rem; }
.about { max-width: 26rem; margin-top: 1rem; color: var(--mute); font-size: 0.85rem; animation: fade 1s both; }

/* ── 舞台 ── */
.stage {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 clamp(1.4rem, 6vw, 4rem);
}
.stage.is-line { cursor: pointer; user-select: none; }
.bar { display: flex; justify-content: space-between; align-items: center; padding: 1.4rem 0; }
.where { color: var(--mute); font-size: 0.78rem; letter-spacing: 0.08em; font-variant-numeric: tabular-nums; }
.center { flex: 1; display: grid; place-items: center; padding: 2rem 0; }
.step { width: 100%; max-width: 34rem; text-align: center; }
.foot { display: flex; justify-content: space-between; padding: 1.4rem 0 2rem; }
.tap { opacity: 0; animation: fade 1.2s ease 2.2s forwards; }
.thread { position: fixed; left: 0; right: 0; bottom: 0; height: 1px; }
.thread i { display: block; height: 100%; background: var(--mute); transition: width 0.8s; }

.line { font-size: clamp(1.3rem, 4.2vw, 1.75rem); font-weight: 200; letter-spacing: 0.06em; line-height: 1.9; }
.line.gone { color: var(--mute); }
.glyph { color: var(--accent); font-size: 0.8rem; font-weight: 400; letter-spacing: 0.3em; padding-left: 0.3em; margin-bottom: 1.2rem; }
.q { font-size: clamp(1.2rem, 4vw, 1.5rem); font-weight: 400; letter-spacing: 0.02em; line-height: 1.7; }
.q.small { font-size: 1.15rem; }
.hint { color: var(--mute); font-size: 0.86rem; letter-spacing: 0.02em; margin-top: 0.7rem; }
.pen {
  margin-top: 2.6rem;
  padding: 0.5em 1.5em;
  letter-spacing: 0.08em;
  font-size: 0.85rem;
  background: var(--glass);
  border: 1px solid var(--faint);
  border-radius: 999px;
  transition: border-color 0.4s;
}
.pen:hover, .pen:focus-visible { border-color: var(--ink); }
.write { animation: fade 1.2s ease both; }
.write .pen { margin-top: 2rem; }

textarea {
  display: block;
  width: 100%;
  margin-top: 1.8rem;
  padding: 0.5rem 0;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--faint);
  border-radius: 0;
  resize: none;
  overflow: hidden;
  line-height: 1.8;
  text-align: left;
  transition: border-color 0.5s;
}
textarea:focus { border-color: var(--mute); }
.short textarea { text-align: center; font-size: 1.5rem; font-weight: 200; letter-spacing: 0.08em; max-width: 16rem; margin-inline: auto; }
.dissolve { animation: dissolve 2.6s ease forwards; }
@keyframes dissolve {
  to { opacity: 0; filter: blur(10px); letter-spacing: 0.5em; transform: translateY(18px); border-color: transparent; }
}
.prev { margin-top: 1.4rem; text-align: left; }

.field { display: block; margin-top: 1.5rem; text-align: left; }
.field span { color: var(--mute); font-size: 0.78rem; letter-spacing: 0.06em; }
.field textarea { margin-top: 0; }

.energy { display: flex; justify-content: center; gap: clamp(0.9rem, 4vw, 1.8rem); margin-top: 2.2rem; }
.energy button { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; color: var(--mute); font-size: 0.78rem; opacity: 0.55; transition: opacity 0.4s, color 0.4s; }
.energy i {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 1px solid currentColor;
  background: linear-gradient(to top, currentColor var(--fill), transparent var(--fill));
}
.energy button:hover { opacity: 1; }
.energy button[aria-pressed="true"] { opacity: 1; color: var(--ink); }

.slider { display: grid; grid-template-columns: 1fr 2.2rem; align-items: center; gap: 0.2rem 1rem; margin-top: 1.9rem; text-align: left; }
.slider span { grid-column: 1 / -1; color: var(--mute); font-size: 0.8rem; letter-spacing: 0.04em; }
.slider output { text-align: right; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
input[type="range"] { appearance: none; -webkit-appearance: none; width: 100%; height: 1.6rem; background: none; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 1px; background: var(--faint); }
input[type="range"]::-moz-range-track { height: 1px; background: var(--faint); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 13px; height: 13px; margin-top: -6px; border-radius: 50%; background: var(--ink); border: 0; }
input[type="range"]::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: var(--ink); border: 0; }
input[type="range"].unset::-webkit-slider-thumb { background: var(--paper); box-shadow: inset 0 0 0 1px var(--mute); }
input[type="range"].unset::-moz-range-thumb { background: var(--paper); box-shadow: inset 0 0 0 1px var(--mute); }

.chart { width: 100%; margin-top: 2rem; overflow: visible; }
.chart .base { stroke: var(--faint); stroke-dasharray: 2 5; }
.chart polyline { fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.chart circle { fill: var(--ink); }
.chart text { fill: var(--mute); font-size: 11px; }

/* ── 一页 ── */
.page { max-width: 38rem; margin: 0 auto; padding: 0 1.5rem 5rem; }
.page h1 { text-align: center; font-weight: 200; font-size: 1.6rem; letter-spacing: 0.2em; padding-left: 0.2em; margin-top: 2rem; }
.page .word { text-align: center; font-size: 2.4rem; font-weight: 200; letter-spacing: 0.1em; margin: 1.4rem 0 1rem; }
.center-text { text-align: center; }
.page section { margin-top: 2.8rem; display: grid; grid-template-columns: 6rem 1fr; gap: 0 1rem; }
.page h3 { font-weight: 400; font-size: 0.78rem; color: var(--mute); letter-spacing: 0.06em; padding-top: 0.25rem; }
.page section > :not(h3) { grid-column: 2; white-space: pre-wrap; }
.page .chart { margin-top: 0; }
.page h4 { font-weight: 500; font-size: 0.95rem; margin-top: 1.6rem; }
.page summary { cursor: pointer; color: var(--mute); font-size: 0.9rem; }
.rings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem 0.5rem; white-space: normal !important; }
.rings figure { text-align: center; }
.rings svg { width: 3.4rem; }
.rings .base { fill: none; stroke: var(--faint); }
.rings .arc { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
.rings text { fill: var(--ink); font-size: 17px; font-weight: 300; }
.rings figcaption { color: var(--mute); font-size: 0.78rem; }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem 2rem; margin-top: 4rem; padding-top: 1.6rem; border-top: 1px solid var(--faint); }

@media (max-width: 480px) {
  body { font-size: 16px; }
  .chapters .note { display: none; }
  .chapters a { grid-template-columns: 0.8rem 1.6rem 1fr auto; }
  .page section { grid-template-columns: 1fr; }
  .page section > :not(h3) { grid-column: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01s !important; animation-delay: 0s !important; transition-duration: 0.01s !important; }
}
@media print {
  body::before { display: none; }
  .bar, .actions { display: none; }
  details > * { display: block; }
}
