/* Layout: a dark lacquered desk with one lamp pool; each puzzle is a single paper leaf under the lamp. One vermilion seal stamps what the reader commits. Deliberately single-look (the 燈下 skin). */
:root {
  --desk: #15100b;
  --desk-2: #241a11;
  --lamp: rgba(255, 196, 120, 0.20);
  --foil: #d2ae68;
  --desk-ink: #e9dcc3;
  --desk-muted: #a8977b;
  --paper: #f1e8d4;
  --paper-2: #e6dac0;
  --ink: #2a2118;
  --ink-muted: #6f604c;
  --rule: #cdbd9c;
  --seal: #c4321f;
  --seal-soft: rgba(196, 50, 31, 0.10);
  --ok: #3f6b4a;
  --ok-soft: rgba(63, 107, 74, 0.10);
  --serif: "Noto Serif TC", "Songti TC", "PMingLiU", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
/* The place's own painting behind the desk (gy-entry.js sets --place-art and data-place), dimmed at the top and
   fading into the desk lower down so paper leaves and text stay readable. */
html[data-place] body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(21,16,11,.52) 0%, rgba(21,16,11,.70) 38%, rgba(21,16,11,.90) 68%, var(--desk) 92%),
    var(--place-art) center 35% / cover no-repeat;
}
html, body { min-height: 100%; }
body {
  background: var(--desk);
  background-image:
    radial-gradient(ellipse 70% 45% at 50% 18%, var(--lamp), transparent 70%),
    linear-gradient(180deg, var(--desk-2), var(--desk) 60%);
  background-attachment: fixed;
  color: var(--desk-ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 20px 56px;
}
.wrap { max-width: 640px; margin: 0 auto; display: grid; gap: 20px; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--foil); outline-offset: 2px; }
.leaf :focus-visible { outline-color: var(--seal); }

/* desk chrome */
.mast { display: grid; gap: 6px; padding-top: 8px; }
.mast .eyebrow { font-size: 12px; letter-spacing: 0.18em; color: var(--desk-muted); }
.mast h1 { margin: 0; font-family: var(--serif); font-weight: 900; font-size: clamp(30px, 8vw, 42px); line-height: 1.15; color: var(--foil); text-wrap: balance; }
.mast p { margin: 0; color: var(--desk-ink); max-width: 34em; }
.notice { font-size: 12.5px; color: var(--desk-muted); border-top: 1px solid rgba(210, 174, 104, 0.25); padding-top: 10px; }
.back { justify-self: start; background: none; border: 0; color: var(--desk-muted); padding: 6px 0; font-size: 14px; }
.back:hover { color: var(--desk-ink); }

/* list */
.group { display: grid; gap: 10px; }
.group h2 { margin: 6px 0 0; font-family: var(--serif); font-weight: 600; font-size: 17px; color: var(--desk-ink); }
.group .sub { margin: 0; font-size: 13px; color: var(--desk-muted); }
.tiles { display: grid; gap: 8px; }
.tile {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
  text-align: left; width: 100%;
  background: var(--paper); color: var(--ink);
  border: 0; border-radius: 3px; padding: 14px 16px;
  box-shadow: 0 1px 0 var(--paper-2), 0 2px 0 var(--rule), 0 8px 18px rgba(0,0,0,0.35);
}
.tile .t { font-family: var(--serif); font-weight: 600; font-size: 16px; min-width: 0; }
.tile .q { grid-column: 1 / 2; font-size: 13px; color: var(--ink-muted); min-width: 0; }
.tile .state { grid-row: 1 / 3; grid-column: 2; font-size: 12px; white-space: nowrap; }
.tile[aria-disabled="true"] { background: #2b2219; color: var(--desk-muted); box-shadow: inset 0 0 0 1px rgba(210,174,104,0.18); cursor: not-allowed; }
.tile[aria-disabled="true"] .q { color: var(--desk-muted); }
.stamp { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 2px solid var(--seal); color: var(--seal); border-radius: 4px; font-family: var(--serif); font-weight: 900; font-size: 13px; line-height: 1.1; transform: rotate(-6deg); }
.start { color: var(--seal); font-weight: 600; }
.tester { justify-self: start; background: none; border: 1px dashed rgba(210,174,104,0.4); color: var(--desk-muted); border-radius: 3px; padding: 6px 10px; font-size: 12.5px; }

/* leaf */
.leaf {
  background: var(--paper); color: var(--ink); color-scheme: light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.35 0 0 0 0 0.28 0 0 0 0 0.18 0 0 0 0.07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  border-radius: 3px;
  padding: 22px 20px 26px;
  box-shadow: 0 1px 0 var(--paper-2), 0 3px 0 var(--rule), 0 5px 0 #b9a882, 0 18px 40px rgba(0,0,0,0.5);
  display: grid; gap: 18px;
}
.leaf h2 { margin: 0; font-family: var(--serif); font-weight: 900; font-size: 22px; line-height: 1.3; text-wrap: balance; }
.leaf .kicker { font-size: 12px; letter-spacing: 0.14em; color: var(--ink-muted); margin-bottom: 2px; }
.moves { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; counter-reset: mv; }
.move { display: grid; grid-template-columns: 26px 1fr; gap: 2px 10px; counter-increment: mv; }
.move::before { content: counter(mv); grid-row: 1 / 3; font-family: var(--serif); font-weight: 600; color: var(--ink-muted); font-variant-numeric: tabular-nums; padding-top: 1px; }
.who { font-size: 12.5px; color: var(--ink-muted); }
.who b { color: var(--ink); font-weight: 600; margin-right: 6px; }
.tag { display: inline-block; font-size: 11px; letter-spacing: 0.06em; border: 1px solid var(--rule); border-radius: 2px; padding: 0 5px; color: var(--ink-muted); }
.line { font-family: var(--serif); font-size: 17px; line-height: 1.65; min-width: 0; }
.position { border-top: 1px solid var(--rule); padding-top: 14px; display: grid; gap: 4px; }
.position .lbl { font-size: 12px; letter-spacing: 0.14em; color: var(--seal); font-weight: 600; }
.position p { margin: 0; font-family: var(--serif); font-size: 16px; }

.yours { display: grid; gap: 10px; }
.yours label { font-size: 13px; color: var(--ink-muted); }
textarea {
  width: 100%; min-height: 92px; resize: vertical;
  font-family: var(--serif); font-size: 17px; line-height: 1.6;
  color: var(--ink); background: #fbf6ea; border: 1px solid var(--rule); border-radius: 3px; padding: 10px 12px;
}
.count { font-size: 12px; color: var(--ink-muted); font-variant-numeric: tabular-nums; justify-self: end; }
.count.over { color: var(--seal); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--rule); background: transparent; color: var(--ink); border-radius: 999px; padding: 4px 11px; font-size: 13.5px; }
.chip[aria-pressed="true"] { border-color: var(--seal); color: var(--seal); background: var(--seal-soft); }
.seal-btn {
  justify-self: start; border: 0; border-radius: 3px; padding: 10px 18px;
  background: var(--seal); color: #fff7ec; font-weight: 600; letter-spacing: 0.04em;
}
.seal-btn:disabled { background: #b8a98c; color: #f3ead7; cursor: not-allowed; }
.hint { font-size: 12.5px; color: var(--ink-muted); margin: 0; }

.sealed { position: relative; border: 1px solid var(--rule); border-radius: 3px; padding: 12px 56px 12px 14px; background: #fbf6ea; }
.sealed .line { font-size: 16.5px; }
.sealed .basis { font-size: 12.5px; color: var(--ink-muted); margin-top: 4px; }
.sealed .stamp { position: absolute; right: 10px; top: 10px; }
@media (prefers-reduced-motion: no-preference) {
  .sealed .stamp.press { animation: press 0.42s cubic-bezier(.2,.9,.3,1.2); }
  @keyframes press { from { transform: rotate(-6deg) scale(1.9); opacity: 0; } to { transform: rotate(-6deg) scale(1); opacity: 1; } }
}

.layer { border-top: 1px solid var(--rule); padding-top: 14px; display: grid; gap: 10px; }
.layer h3 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 16px; }
.layer .note { margin: 0; font-size: 12.5px; color: var(--ink-muted); }
.marks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.mark { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.mark span { min-width: 0; }
.yn { display: flex; gap: 4px; }
.yn button { border: 1px solid var(--rule); background: transparent; color: var(--ink); border-radius: 3px; padding: 2px 10px; font-size: 13px; }
.yn button[aria-pressed="true"].y { border-color: var(--ok); color: var(--ok); background: var(--ok-soft); }
.yn button[aria-pressed="true"].n { border-color: var(--ink-muted); color: var(--ink); background: var(--paper-2); }
.next { justify-self: start; border: 1px solid var(--ink); background: transparent; color: var(--ink); border-radius: 3px; padding: 7px 14px; font-size: 14px; }
.next:disabled { border-color: var(--rule); color: var(--ink-muted); cursor: not-allowed; }

.demos { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.demo { display: grid; gap: 4px; padding-left: 12px; border-left: 3px solid var(--rule); }
.demo.k-good { border-left-color: var(--ok); }
.demo.k-short { border-left-color: var(--foil); }
.demo.k-trap { border-left-color: var(--seal); }
.demo .kind { font-size: 12px; font-weight: 600; }
.demo.k-good .kind { color: var(--ok); }
.demo.k-short .kind { color: #8a6a28; }
.demo.k-trap .kind { color: var(--seal); }
.demo .line { font-size: 16px; }
.demo .why { font-size: 13px; color: var(--ink-muted); }
.prose { margin: 0; font-family: var(--serif); font-size: 16px; line-height: 1.75; }
.sources { margin: 0; padding-left: 18px; font-size: 13px; color: var(--ink-muted); display: grid; gap: 2px; }
.after { display: flex; flex-wrap: wrap; gap: 8px; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.compare > div { min-width: 0; border: 1px solid var(--rule); border-radius: 3px; padding: 10px 12px; background: #fbf6ea; }
.compare .when { font-size: 12px; color: var(--ink-muted); }
.compare .line { font-size: 15px; }
@media (max-width: 380px) { .compare { grid-template-columns: 1fr; } }
.card { border: 1px solid var(--ink); border-radius: 3px; padding: 14px; background: #fbf6ea; display: grid; gap: 6px; }
.card .brand { font-size: 12px; letter-spacing: 0.14em; color: var(--seal); font-weight: 600; }
.card .ask { font-family: var(--serif); font-size: 17px; font-weight: 600; }
.card .hid { font-size: 13px; color: var(--ink-muted); border: 1px dashed var(--rule); border-radius: 3px; padding: 8px 10px; }
.tryline { display: grid; gap: 8px; }
.tryline input { width: 100%; font: inherit; color: var(--ink); background: #fbf6ea; border: 1px solid var(--rule); border-radius: 3px; padding: 8px 10px; }
.ok { color: var(--ok); font-size: 13.5px; font-weight: 600; margin: 0; }
.after .ghost { border: 1px solid var(--rule); background: transparent; color: var(--ink-muted); border-radius: 3px; padding: 7px 12px; font-size: 13.5px; }
body { margin: 0; }
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
[hidden] { display: none !important; }
/* bridge additions: the scene card, five planks walked from the fruit back to contact, and the reveal. */
.scene { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.scene li { font-family: var(--serif); font-size: 16px; line-height: 1.65; padding-left: 12px; border-left: 2px solid var(--rule); }
.fruit { font-family: var(--serif); font-weight: 900; font-size: 20px; color: var(--seal); margin: 0; }
.plank { border-top: 1px solid var(--rule); padding-top: 14px; display: grid; gap: 8px; }
.plank .nm { display: flex; align-items: baseline; gap: 10px; }
.plank .ch { font-family: var(--serif); font-weight: 900; font-size: 22px; color: var(--ink); width: 28px; }
.plank .gl { font-size: 12px; letter-spacing: 0.08em; color: var(--seal); white-space: nowrap; }
.plank .nm { flex-wrap: wrap; }
.plank .ask { font-size: 14px; color: var(--ink-muted); min-width: 0; flex-basis: 100%; }
.opts { display: grid; gap: 6px; }
.opt { text-align: left; border: 1px solid var(--rule); background: #fbf6ea; color: var(--ink); border-radius: 3px; padding: 9px 12px; font-family: var(--serif); font-size: 15.5px; line-height: 1.55; }
.opt[aria-pressed="true"] { border-color: var(--seal); background: var(--seal-soft); }
.opt:disabled { cursor: default; }
.hintbtn { justify-self: start; background: none; border: 0; padding: 2px 0; color: var(--ink-muted); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.hinttext { margin: 0; font-size: 13.5px; color: var(--ink); background: var(--paper-2); border-radius: 3px; padding: 8px 10px; }
.grade { display: grid; gap: 4px; padding-left: 12px; border-left: 3px solid var(--rule); }
.grade.k-good { border-left-color: var(--ok); }
.grade.k-short { border-left-color: var(--foil); }
.grade.k-trap { border-left-color: var(--seal); }
.grade .kind { font-size: 12.5px; font-weight: 600; }
.grade.k-good .kind { color: var(--ok); }
.grade.k-short .kind { color: #8a6a28; }
.grade.k-trap .kind { color: var(--seal); }
.grade .why { font-size: 13.5px; color: var(--ink-muted); }
.grade .ref { font-size: 13.5px; }
.ptable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ptable th, .ptable td { border-bottom: 1px solid var(--rule); padding: 6px 4px; text-align: left; vertical-align: top; }
.ptable th { font-weight: 600; color: var(--ink-muted); font-size: 12px; }
.ptable td.ok { color: var(--ok); }
.ptable td.off { color: var(--seal); }
.turn { border: 1px solid var(--ink); border-radius: 3px; padding: 16px 14px; background: #fbf6ea; display: grid; gap: 10px; }
.turn p { margin: 0; font-family: var(--serif); font-size: 18px; line-height: 1.7; }
.go { justify-self: start; border: 0; border-radius: 3px; padding: 10px 18px; background: var(--ink); color: var(--paper); font-weight: 600; text-decoration: none; font-size: 14.5px; }
/* shared courtyard additions (2026-10-28): support footer, reading label, comments, private notebook. */
.support { max-width: 640px; margin: 28px auto 0; font-size: 12px; color: var(--desk-muted); display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: space-between; }
.support a { color: var(--desk-ink); }
.label { display: inline-block; font-size: 11.5px; letter-spacing: 0.06em; color: var(--ink-muted); border: 1px dashed var(--rule); border-radius: 2px; padding: 1px 6px; }
.reading { margin: 0; font-size: 13px; color: var(--ink-muted); background: var(--paper-2); border-radius: 3px; padding: 8px 10px; }
.comments { display: grid; gap: 8px; }
.comments select { font: inherit; font-size: 14px; color: var(--ink); background: #fbf6ea; border: 1px solid var(--rule); border-radius: 3px; padding: 6px 8px; justify-self: start; }
.comments textarea { min-height: 72px; font-size: 15.5px; }
.clist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.clist li { font-size: 14px; border-left: 3px solid var(--rule); padding-left: 10px; }
.clist .on { font-size: 12px; color: var(--ink-muted); margin-right: 6px; }
.go.alt { background: transparent; color: var(--ink); border: 1px solid var(--ink); }
.golinks { display: flex; flex-wrap: wrap; gap: 8px; }

/* A folded layer: the title shows, the text opens on tap. Keeps one screen to one thing. */
details.fold > summary { cursor: pointer; list-style: none; min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-family: var(--serif); font-weight: 600; font-size: 16px; color: var(--ink); }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: "展開"; font-family: var(--sans, inherit); font-weight: 400; font-size: 12.5px; color: var(--ink-muted); }
details.fold[open] > summary::after { content: "收起"; }

/* small「為什麼」fold under a line */
.why-fold summary { cursor: pointer; font-size: 13px; color: var(--ink-muted); min-height: 32px; display: flex; align-items: center; list-style: none; }
.why-fold summary::-webkit-details-marker { display: none; }
.why-fold summary::after { content: ' ›'; margin-left: 4px; }
.why-fold[open] summary::after { content: ' ⌄'; }
.why-fold .why, .why-fold .prose { display: block; margin-top: 4px; }

/* one page at a time on long reveals (GYE.pages) */
.gy-pgnav { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--rule); }

/* 經摺 spine: after the reveal, the long chain folds into one strip of leaves (易位橋, 萬象觀) */
.spine { margin-top: 14px; padding: 12px; border: 1px solid var(--rule); border-radius: 12px; background: rgba(255, 255, 255, 0.35); }
.spine .fruit { margin: 0 0 10px; }
.sp-row { display: grid; grid-template-columns: repeat(var(--n, 6), minmax(0, 1fr)); gap: 5px; perspective: 600px; }
.sp-leaf { min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 1px solid var(--rule); border-radius: 6px; background: var(--paper, #f4ecdc); font: inherit; cursor: pointer; transform-origin: left center; }
.sp-leaf b { font-family: var(--serif); font-size: 18px; color: var(--ink); }
.sp-leaf i { font-style: normal; font-size: 11px; letter-spacing: .06em; }
.sp-leaf.k-good i { color: var(--ok); } .sp-leaf.k-short i { color: #8a6a28; } .sp-leaf.k-trap i { color: var(--seal); }
.sp-leaf.k-good { border-bottom: 3px solid var(--ok); } .sp-leaf.k-short { border-bottom: 3px solid var(--foil, #c9a24a); } .sp-leaf.k-trap { border-bottom: 3px solid var(--seal); }
.sp-leaf[aria-pressed="true"] { background: var(--ink); } .sp-leaf[aria-pressed="true"] b, .sp-leaf[aria-pressed="true"] i { color: var(--paper, #f4ecdc); }
.sp-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; }
.sp-foot .hint { margin: 0; font-size: 12px; }
.sp-scene { border: 0; background: none; font: inherit; font-size: 13px; color: var(--ink-muted); text-decoration: underline; cursor: pointer; min-height: 32px; }
.sp-open { margin-top: 10px; animation: sp-unfold .32s ease-out both; transform-origin: top center; }
.sp-open .plank { border-top: 0; padding-top: 0; }
@keyframes sp-unfold { from { opacity: 0; transform: scaleY(.6); } to { opacity: 1; transform: none; } }
.spine.fold-in .sp-leaf { animation: sp-fold .5s cubic-bezier(.2,.7,.2,1) both; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes sp-fold { from { opacity: 0; transform: rotateY(-75deg) translateX(-12px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .sp-open, .spine.fold-in .sp-leaf { animation: none; } }
.plank .pl { font-family: var(--serif); font-weight: 900; font-size: 20px; color: var(--ink); }
.plank .term { width: 100%; font-size: 13px; color: var(--seal); }
.plank .term summary { cursor: pointer; min-height: 32px; display: list-item; padding: 4px 0; }
.plank .term b { font-family: var(--serif); font-size: 16px; color: var(--ink); }

/* Finished steps fold to one line (GYE.fold). */
.gy-folded:not(.gy-unfold) > :not(.gy-sum) { display: none !important; }
.gy-folded { padding-top: 10px !important; }
.gy-sum { display: grid; grid-template-columns: auto auto 1fr auto; align-items: baseline; gap: 8px; width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--rule); border-radius: 3px; background: var(--paper-2, #f1e6cf); color: var(--ink); text-align: left; font-size: 13.5px; }
.gy-sum .ck { color: var(--ok); font-weight: 700; }
.gy-sum b { font-size: 12px; letter-spacing: 0.08em; color: var(--seal); font-weight: 600; white-space: nowrap; }
.gy-sum .v { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-muted); }
.gy-sum .tw { font-size: 12px; color: var(--ink-muted); text-decoration: underline; white-space: nowrap; }
.gy-unfold > .gy-sum { margin-bottom: 4px; }

/* A step strip: one step on screen, the strip shows where the reader is (五蘊五門 daily, and any place that needs it). */
.gy-steps { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; }
.gy-steps button { min-height: 44px; padding: 4px 2px; border: 1px solid var(--rule); border-radius: 3px; background: transparent; color: var(--ink-muted); font-family: var(--serif); font-size: 15px; display: grid; place-items: center; gap: 2px; }
.gy-steps button i { width: 7px; height: 7px; border-radius: 50%; background: var(--rule); }
.gy-steps button.done { color: var(--ink); }
.gy-steps button.done i { background: var(--seal); }
.gy-steps button[aria-current="step"] { border-color: var(--seal); color: var(--seal); background: var(--seal-soft); font-weight: 600; }
.gy-now { border-top: 0 !important; padding-top: 4px !important; }
.gy-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gy-nav .note { font-size: 12.5px; color: var(--ink-muted); }
.gy-nav .next { min-height: 44px; }
