/* Self-hosted fonts (SIL Open Font License, see fonts/). No Google Fonts, so it also loads in mainland China. */
@font-face{font-family:'Long Cang';src:url('../fonts/LongCang-subset.woff2') format('woff2');font-weight:400;font-style:normal;font-display:swap}
@font-face{font-family:'STIX Two Text';src:url('../fonts/STIXTwoText.woff2') format('woff2');font-weight:400 700;font-style:normal;font-display:swap}
@font-face{font-family:'STIX Two Text';src:url('../fonts/STIXTwoText-Italic.woff2') format('woff2');font-weight:400 700;font-style:italic;font-display:swap}

/* Layout: one exercise-book column on blue graph paper, a red margin rule down its left edge; red pen draws, blue pen derives. */
:root{
  --paper:#FFFFFF;
  --grid:#E6EEF9;
  --ink:#1B1B24;
  --muted:#4A5A80;
  --blue:#1F3FA8;
  --red:#D7263D;
  --on-red:#FFFFFF;
  --margin:#F2A1AC;
  --axis:#9DB5E0;
  --line:#C9D6EE;
  --obs:#C9DAF8;
  --dec:#F6B8D0;
  --hand:'Long Cang','Kaiti SC','STKaiti','KaiTi',cursive;
  --sans:'PingFang SC','Hiragino Sans GB','Microsoft YaHei','Noto Sans SC','Noto Sans CJK SC',system-ui,sans-serif;
  --serif:'Songti SC','STSong','SimSun','Noto Serif SC','Noto Serif CJK SC','Source Han Serif SC',serif;
  --math:'STIX Two Text','Times New Roman',Times,serif;
  /* Always white exercise-book paper, whatever the viewer's theme. */
  color-scheme:light;
}

*{box-sizing:border-box}
[hidden]{display:none!important}
html{background:var(--paper)}
body{
  margin:0;
  background-color:var(--paper);
  background-image:linear-gradient(var(--grid) 1px,transparent 1px),linear-gradient(90deg,var(--grid) 1px,transparent 1px);
  background-size:16px 16px;
  color:var(--ink);
  font-family:var(--sans);
  font-size:15px;
  line-height:1.6;
}
.wrap{
  padding-left:max(16px,env(safe-area-inset-left,0px));
  padding-right:max(16px,env(safe-area-inset-right,0px));
  padding-block:calc(20px + env(safe-area-inset-top,0px)) calc(56px + env(safe-area-inset-bottom,0px));
}
.sheet{position:relative;max-width:460px;margin:0 auto;padding-left:30px}
.sheet::before{content:"";position:absolute;left:11px;top:-20px;bottom:-56px;width:2px;background:var(--margin)}

section{display:flex;flex-direction:column;gap:18px}
.topline{display:flex;justify-content:space-between;align-items:center;gap:12px;min-height:44px}
.hand{font-family:var(--hand);font-weight:400}
.mi{font-family:var(--math);font-style:italic;font-size:1.08em;white-space:nowrap}
.blue{color:var(--blue)}
.red{color:var(--red)}
.muted{color:var(--muted)}
.date{font-family:var(--math);font-size:13px;color:var(--muted)}
.pageno{font-size:22px;color:var(--blue)}

/* Intro */
.title{margin:4px 0 0;font-size:clamp(54px,16vw,72px);line-height:1;letter-spacing:.02em;color:var(--ink)}
.lede{margin:0;font-size:16px;line-height:1.8;max-width:30em}
.heart-svg{display:block;width:100%;height:auto}
.intro-heart{max-width:300px;margin:0 auto}
.names-form{display:flex;flex-direction:column;gap:14px}
.field{display:flex;align-items:baseline;gap:8px}
.field label{width:2.4em;flex-shrink:0;font-family:var(--hand);font-size:28px;color:var(--blue)}
.field input{
  flex:1;min-width:0;border:0;border-bottom:1.5px solid var(--blue);border-radius:0;background:transparent;
  font-family:var(--hand);font-size:30px;line-height:1.3;color:var(--ink);padding:0 4px;
}
.field input::placeholder{color:var(--muted);opacity:.75;font-size:22px}
.field input:focus{outline:none;border-bottom-color:var(--red)}
.facts{display:flex;flex-wrap:wrap;gap:6px 16px;margin:0;padding:0;list-style:none;font-size:13px;color:var(--muted)}
.facts b{font-family:var(--math);font-size:16px;color:var(--ink);font-weight:600;margin-right:2px}
.link{align-self:flex-start;padding:10px 0;color:var(--ink);font-size:15px;text-decoration:underline;text-decoration-color:var(--red);text-underline-offset:5px}
.link:hover{color:var(--red)}
.fine{margin:0;font-size:12px;line-height:1.75;color:var(--muted)}

/* Buttons */
.btn{
  display:inline-flex;align-items:center;justify-content:center;min-height:52px;padding:0 18px;
  border:1.5px solid var(--blue);background:var(--paper);color:var(--blue);
  font-family:var(--sans);font-size:16px;font-weight:500;text-decoration:none;cursor:pointer;
}
.btn:hover{background:var(--grid)}
.btn.primary{background:var(--red);border-color:var(--red);color:var(--on-red);font-weight:700}
.btn.primary:hover{filter:brightness(1.06)}
a:focus-visible,button:focus-visible,input:focus-visible,summary:focus-visible{outline:2px solid var(--blue);outline-offset:3px}
.actions{display:flex;gap:10px}
.actions .btn{flex:1}

/* Quiz */
.textbtn{border:0;background:none;padding:10px 0;min-height:44px;color:var(--blue);font-family:var(--sans);font-size:15px;cursor:pointer}
.mini{display:flex;align-items:center;gap:14px}
.mini svg{width:96px;height:auto;flex-shrink:0}
.mini-path{fill:none;stroke:var(--red);stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:1;stroke-dashoffset:1;transition:stroke-dashoffset .5s ease}
.mini-ghost{fill:none;stroke:var(--line);stroke-width:1.5;stroke-dasharray:3 4}
.mini-label{font-family:var(--hand);font-size:22px;color:var(--red);line-height:1.3}
.q-meta{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.q-no{font-size:26px;color:var(--blue)}
.chip{font-size:12px;line-height:20px;padding:0 8px;border:1px solid currentColor}
.chip.show{color:var(--red)}
.chip.study{color:var(--blue)}
.q-name{font-size:13px;color:var(--muted)}
.q-text{margin:0;font-family:var(--serif);font-size:24px;line-height:1.5;font-weight:600;text-wrap:balance}
.ends{display:flex;justify-content:space-between;gap:16px;font-size:13px;line-height:1.5;color:var(--muted)}
.ends span:last-child{text-align:right}
.ends b{font-family:var(--math);color:var(--ink);font-size:15px}
.scores{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:8px}
.score{
  position:relative;height:56px;border:1.5px solid var(--line);background:var(--paper);
  font-family:var(--math);font-size:22px;color:var(--ink);cursor:pointer;
}
.score:hover{border-color:var(--blue);color:var(--blue)}
.score.on{border-color:var(--red);color:var(--red);font-weight:600}
.score.on::after{
  content:"";position:absolute;left:50%;top:50%;width:42px;height:34px;
  transform:translate(-50%,-50%) rotate(-10deg);border:2px solid var(--red);border-radius:50%;pointer-events:none;
}
.note{margin:0;font-family:var(--hand);font-size:23px;line-height:1.45;color:var(--red);transform:rotate(-1deg);transform-origin:left center}

/* Result */
.names{font-family:var(--hand);font-size:42px;line-height:1.05}
.concl{margin:0;font-family:var(--hand);font-size:36px;line-height:1.3;color:var(--red)}
.circled{display:inline-block;padding:0 10px;border:2px solid var(--red);border-radius:50%;transform:rotate(-4deg)}
.paper{display:flex;flex-direction:column;gap:12px;font-family:var(--serif);font-size:15px;line-height:1.85}
.paper p{margin:0}
.paper b{font-weight:600}
.derive{display:flex;flex-direction:column;gap:2px;padding:6px 0 6px 14px;font-family:var(--math);font-style:italic;font-size:19px;line-height:1.55;color:var(--blue)}
.derive .red{color:var(--red)}
.qed{color:var(--red);font-style:normal;font-family:var(--sans);font-size:18px;text-align:right}
.rating{display:inline-block;padding:0 10px;margin:0 6px 0 2px;background:var(--ink);color:var(--paper);font-family:var(--sans);font-weight:700;font-size:14px;line-height:26px}
.table-box{overflow-x:auto}
table.bt{width:100%;border-collapse:collapse;font-size:14px;line-height:1.5;border-top:1.5px solid var(--ink);border-bottom:1.5px solid var(--ink)}
.bt caption{caption-side:top;font-size:12px;color:var(--muted);padding-bottom:6px;text-align:center}
.bt th{font-weight:600;text-align:left;padding:6px 4px;border-bottom:1px solid var(--ink)}
.bt td{padding:5px 4px}
.bt .n{text-align:right;font-family:var(--math);font-variant-numeric:tabular-nums}
.bt .tag{font-family:var(--sans);font-size:12px;text-align:right}
.tag-strong{color:var(--blue)}
.tag-weak{color:var(--red)}
.soft{font-family:var(--sans);font-size:13px;color:var(--muted)}
details.sources{border-top:1px dashed var(--line);padding-top:4px}
details.sources summary{cursor:pointer;padding:12px 0;min-height:44px;color:var(--blue);font-weight:500}
.sources ol{margin:4px 0 0;padding-left:1.3em;display:flex;flex-direction:column;gap:10px;font-size:13.5px;line-height:1.75}
.svg-axis{fill:none;stroke:var(--axis);stroke-width:1;stroke-dasharray:4 4}
.svg-heart{fill:none;stroke:var(--red);stroke-width:2.6;stroke-linejoin:round;stroke-linecap:round}
.svg-hatch{stroke:var(--red);stroke-width:1.8}
.svg-level{stroke:var(--red);stroke-width:1.2;stroke-dasharray:3 3}
.t-red{fill:var(--red)}
.t-blue{fill:var(--blue)}
.t-muted{fill:var(--muted)}
.t-hand{font-family:var(--hand)}
.t-math{font-family:var(--math);font-style:italic}

/* Result animation: pen draws the heart, hatching rises to P, then the writing appears. */
@keyframes draw{to{stroke-dashoffset:0}}
@keyframes rise{from{transform:scaleY(0)}to{transform:scaleY(1)}}
@keyframes fade{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
.anim .draw{stroke-dasharray:1;stroke-dashoffset:1}
.anim.play .draw{animation:draw 1.9s ease-in-out .2s forwards}
.anim .rise{transform-box:fill-box;transform-origin:50% 100%;transform:scaleY(0)}
.anim.play .rise{animation:rise 1.2s ease-out 2.1s forwards}
.anim .late{opacity:0}
.anim.play .late{animation:fade .55s ease-out forwards}
.anim.play .d1{animation-delay:3.2s}
.anim.play .d2{animation-delay:3.5s}
.anim.play .d3{animation-delay:4s}
.anim.play .d4{animation-delay:4.5s}
.anim.play .d5{animation-delay:5s}
.anim.play .d6{animation-delay:5.5s}
@media (prefers-reduced-motion: reduce){
  .anim .draw{stroke-dashoffset:0}
  .anim .rise{transform:none}
  .anim .late{opacity:1}
  .anim.play .draw,.anim.play .rise,.anim.play .late{animation:none}
  .mini-path{transition:none}
}

/* Singles */
.title-s{margin:0;font-size:clamp(36px,10vw,46px);line-height:1.15;color:var(--ink);text-wrap:balance}
.steppers{display:flex;flex-direction:column;border:1.5px solid var(--line);background:var(--paper)}
.step{display:flex;align-items:center;gap:6px;min-height:60px;padding:6px 6px 6px 12px}
.step+.step{border-top:1px solid var(--line)}
.step .lbl{flex:1;min-width:0;font-size:15px}
.step .val{width:76px;text-align:center;font-family:var(--math);font-size:21px;font-variant-numeric:tabular-nums}
.sbtn{width:44px;height:44px;border:1.5px solid var(--line);background:var(--paper);color:var(--ink);font-family:var(--math);font-size:22px;cursor:pointer}
.sbtn:hover{border-color:var(--blue);color:var(--blue)}
.timeline{display:flex;flex-direction:column;gap:6px}
.tl-labels{display:flex;justify-content:space-between;gap:12px;font-size:12px;font-weight:700}
.tl-bar{position:relative;display:flex;gap:2px;height:24px}
.tl-bar i{flex:1;min-width:0}
.tl-bar i.obs{background:var(--obs)}
.tl-bar i.dec{background:var(--dec)}
.tl-marker{position:absolute;left:37%;top:-7px;bottom:-7px;width:3px;margin-left:-1px;background:var(--ink)}
.tl-axis{position:relative;height:20px;font-family:var(--math);font-size:13px;color:var(--muted)}
.tl-axis span{position:absolute;top:0}
.concl-s{margin:0;font-family:var(--hand);font-size:32px;line-height:1.35;color:var(--red)}
