:root {
  --paper: #f1eadb;
  --paper-deep: #e5dac5;
  --ink: #171512;
  --muted: #746d60;
  --cobalt: #1248c8;
  --red: #c52b1e;
  --hairline: rgba(23, 21, 18, 0.28);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 8%, rgba(255,255,255,.42), transparent 34%),
    linear-gradient(118deg, rgba(128,92,45,.04), transparent 44%),
    var(--paper);
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
}

button, textarea { font: inherit; }
button { color: inherit; }

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .18;
  z-index: 20;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.78' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.22'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

.masthead {
  width: min(1180px, calc(100% - 40px));
  margin: 20px auto 0;
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 188px 72px;
  align-items: end;
  border-top: 8px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  padding: 15px 0 12px;
}

.masthead h1 {
  margin: 0;
  font-size: clamp(46px, 8vw, 112px);
  line-height: .88;
  letter-spacing: -.07em;
  font-weight: 900;
}

.masthead p {
  grid-column: 2 / 5;
  margin: 14px 0 0;
  font-size: 13px;
  letter-spacing: .13em;
}

.edition, .eyebrow, .card-kicker, footer {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  text-transform: uppercase;
  letter-spacing: .12em;
}

.edition { font-size: 11px; transform: rotate(-90deg); transform-origin: left bottom; margin-left: 18px; }

.brand-signature {
  align-self: center;
  justify-self: end;
  display: grid;
  grid-template-columns: 54px auto;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  margin-right: 16px;
}
.brand-signature img { display:block; width:54px; height:54px; object-fit:cover; border:1px solid rgba(23,21,18,.3); box-shadow:3px 3px 0 rgba(18,72,200,.1); }
.brand-wordmark { display:flex; flex-direction:column; min-width:112px; }
.brand-wordmark strong { font-size:18px; letter-spacing:.08em; line-height:1.1; }
.brand-wordmark small { margin-top:6px; color:var(--cobalt); font-family:ui-monospace,monospace; font-size:7px; letter-spacing:.12em; white-space:nowrap; }
.brand-signature:focus-visible { outline:2px solid var(--cobalt); outline-offset:5px; }

.seal {
  justify-self: end;
  color: var(--paper);
  background: var(--red);
  padding: 8px 10px;
  font-weight: 800;
  line-height: 1.18;
  font-size: 12px;
  text-align: center;
  transform: rotate(2deg);
  box-shadow: 2px 2px 0 rgba(197, 43, 30, .18);
}
.seal i { display:block; width:100%; height:1px; margin:5px 0; background:rgba(241,234,219,.7); }

main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }

.panel {
  display: none;
  min-height: 650px;
  position: relative;
  padding: 78px 6vw 90px;
  border-bottom: 1px solid var(--ink);
}

.panel.is-active { display: block; animation: paper-in .6s cubic-bezier(.2,.7,.2,1) both; }

@keyframes paper-in {
  from { opacity: 0; transform: translateY(22px) rotate(.25deg); }
  to { opacity: 1; transform: translateY(0) rotate(0); }
}

.step-mark {
  position: absolute;
  left: 0;
  top: 32px;
  color: var(--cobalt);
  font-family: ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: .18em;
  writing-mode: vertical-rl;
}

.eyebrow { color: var(--cobalt); font-size: 11px; margin: 0 0 18px; }
h2 { margin: 0; font-size: clamp(48px, 8vw, 100px); line-height: .92; letter-spacing: -.06em; }
.lead { max-width: 540px; margin: 28px 0 0; font-size: 18px; line-height: 1.9; }

.primary-button, .reveal-button, .text-button {
  border: 0;
  cursor: pointer;
  background: none;
}

.primary-button {
  margin-top: 34px;
  padding: 15px 24px;
  color: var(--paper);
  background: var(--ink);
  border-radius: 0;
  box-shadow: 6px 6px 0 var(--cobalt);
  transition: transform .18s, box-shadow .18s;
}
.primary-button:hover { transform: translate(3px,3px); box-shadow: 3px 3px 0 var(--cobalt); }

.ritual-panel { grid-template-columns: 1.2fr .8fr; align-items: center; }
.ritual-panel.is-active { display: grid; }

.incense {
  position: relative;
  justify-self: center;
  width: 260px;
  height: 420px;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.burner { position: absolute; left: 45px; bottom: 36px; width: 170px; height: 72px; background: var(--ink); border-radius: 0 0 80px 80px; transform: skewX(-5deg); }
.burner::before { content:""; position:absolute; left:-15px; top:-12px; width:200px; height:28px; border:4px solid var(--ink); background:var(--paper); border-radius:50%; }
.stick { position:absolute; left:128px; bottom:98px; width:5px; height:190px; background:var(--red); transform:rotate(2deg); }
.ember { position:absolute; left:127px; bottom:286px; width:9px; height:9px; background:#ff5b1b; border-radius:50%; box-shadow:0 0 15px #ff5b1b; opacity:0; }
.smoke { position:absolute; left:92px; bottom:292px; width:75px; height:110px; border:3px solid transparent; border-left-color:var(--cobalt); border-radius:50%; opacity:0; }
.smoke-two { left:112px; bottom:350px; transform:scale(.7) rotate(160deg); }
.incense.is-burning .ember { opacity:1; }
.incense.is-burning .smoke { animation: smoke 2.8s ease-out infinite; }
.incense.is-burning .smoke-two { animation-delay:.8s; }
@keyframes smoke { 0%{opacity:0;transform:translateY(8px) scale(.7)} 25%{opacity:.7} 100%{opacity:0;transform:translateY(-85px) translateX(22px) scale(1.2) rotate(22deg)} }

.question-layout { display:grid; grid-template-columns:1fr 1fr; gap:8vw; align-items:end; }
.question-form { border-top:5px solid var(--ink); padding-top:18px; }
.question-form label { display:block; color:var(--cobalt); font-size:13px; margin-bottom:12px; }
.question-form textarea { width:100%; min-height:190px; resize:vertical; border:0; border-bottom:2px solid var(--ink); background:rgba(255,255,255,.18); padding:18px; font-size:24px; line-height:1.65; outline:none; }
.question-form textarea:focus { background:rgba(255,255,255,.42); box-shadow:inset 5px 0 0 var(--cobalt); }
.question-footer { display:flex; align-items:flex-start; justify-content:space-between; }
.question-footer span { padding-top:18px; color:var(--muted); font-family:ui-monospace,monospace; font-size:11px; }
.question-footer .primary-button { margin-top:18px; }

.casting-head { display:flex; align-items:flex-end; justify-content:space-between; gap:30px; }
blockquote { margin:0; padding-left:18px; border-left:4px solid var(--cobalt); max-width:420px; line-height:1.7; }
.casting-grid { margin-top:56px; display:grid; grid-template-columns:minmax(0,1.3fr) minmax(270px,.7fr); gap:clamp(36px,5vw,70px); align-items:center; }
.oracle-board {
  width:100%;
  min-width:0;
  min-height:700px;
  display:grid;
  grid-template-columns:minmax(0,1fr);
  place-items:center;
  border:1px solid var(--hairline);
  padding:112px 46px 72px;
  background:
    linear-gradient(90deg,transparent 49.8%,rgba(18,72,200,.05) 50%,transparent 50.2%),
    rgba(255,255,255,.14);
  position:relative;
  overflow:hidden;
}
.oracle-board::after { content:"八"; position:absolute; right:20px; bottom:-34px; color:rgba(18,72,200,.09); font-size:190px; font-weight:900; }
.casting-guide {
  position:absolute;
  top:25px;
  left:50%;
  width:min(540px,calc(100% - 48px));
  margin:0;
  transform:translateX(-50%);
  color:var(--cobalt);
  font-size:15px;
  line-height:1.7;
  text-align:center;
  letter-spacing:.035em;
}
.casting-guide[hidden] { display:none; }
.bagua-wheel,.line-stack { grid-area:1 / 1; }
.bagua-wheel[hidden],.line-stack[hidden] { display:none!important; }
.bagua-wheel {
  width:min(560px,100%);
  max-width:100%;
  justify-self:center;
  margin-inline:auto;
  position:relative;
  padding:17px 20px 22px;
  border:1px solid var(--hairline);
  background:transparent;
  box-shadow:8px 8px 0 rgba(18,72,200,.08);
  transform:rotate(-.25deg);
}
.diagram-title { display:flex; justify-content:space-between; margin:0 24px 14px; font-size:24px; font-weight:800; letter-spacing:.15em; }
.diagram-ring { width:100%; aspect-ratio:1; position:relative; border:1px solid var(--hairline); border-radius:50%; }
.diagram-ring::before { content:""; position:absolute; inset:20%; border:1px dashed var(--hairline); border-radius:50%; }
.diagram-ring::after { content:""; position:absolute; inset:38%; border:1px solid var(--ink); border-radius:50%; }
.diagram-caption { margin-top:14px; color:var(--cobalt); font-family:ui-monospace,monospace; font-size:9px; letter-spacing:.14em; }
.yin-yang { position:absolute; left:50%; top:50%; width:23%; height:23%; transform:translate(-50%,-50%) rotate(-2deg); z-index:1; }
.gua { position:absolute; width:56px; height:56px; display:grid; place-items:center; border:1px solid var(--ink); border-radius:50%; background:var(--paper); z-index:3; }
.gua::after { content:""; position:absolute; width:46px; height:1px; background:var(--hairline); transform-origin:left center; z-index:-1; }
.gua b { font-family:inherit; font-size:17px; font-weight:500; }
.pos-8{left:50%;top:0;transform:translate(-50%,-50%)} .pos-4{right:13%;top:13%;transform:translate(50%,-50%)}
.pos-3{right:0;top:50%;transform:translate(50%,-50%)} .pos-2{right:13%;bottom:13%;transform:translate(50%,50%)}
.pos-1{left:50%;bottom:0;transform:translate(-50%,50%)} .pos-5{left:13%;bottom:13%;transform:translate(-50%,50%)}
.pos-6{left:0;top:50%;transform:translate(-50%,-50%)} .pos-7{left:13%;top:13%;transform:translate(-50%,-50%)}
.pos-8::after{left:50%;top:56px;transform:rotate(90deg)} .pos-4::after{right:44px;bottom:3px;transform:rotate(135deg)}
.pos-3::after{right:56px;top:50%;transform:rotate(180deg)} .pos-2::after{right:45px;top:3px;transform:rotate(225deg)}
.pos-1::after{left:50%;bottom:56px;transform:rotate(270deg)} .pos-5::after{left:45px;top:3px;transform:rotate(315deg)}
.pos-6::after{left:56px;top:50%} .pos-7::after{left:45px;bottom:3px;transform:rotate(45deg)}
.trigram-mark { position:absolute; width:48px; text-align:center; z-index:2; transform:translate(-50%,-50%); }
.trigram-mark span { display:block; font-family:serif; font-size:29px; line-height:.8; }
.trigram-mark em { display:block; margin-top:5px; font-family:inherit; font-size:13px; font-style:normal; }
.mark-1{left:50%;top:72%}.mark-2{left:68%;top:68%}.mark-3{left:72%;top:50%}.mark-4{left:68%;top:32%}
.mark-5{left:32%;top:68%}.mark-6{left:28%;top:50%}.mark-7{left:32%;top:32%}.mark-8{left:50%;top:28%}
.coin-layer { position:absolute; inset:0; z-index:8; pointer-events:none; }
.cast-coin {
  position:absolute;
  left:50%;
  top:50%;
  width:54px;
  height:54px;
  border-radius:50%;
  transform:translate(-50%,-50%) scale(.28) rotate(-22deg);
  opacity:0;
  transition:left .6s cubic-bezier(.18,.82,.25,1),top .6s cubic-bezier(.18,.82,.25,1),transform .6s cubic-bezier(.18,.82,.25,1),opacity .22s;
  background:
    radial-gradient(circle at 28% 23%,rgba(226,204,139,.62),transparent 15%),
    radial-gradient(circle at 75% 72%,rgba(61,107,81,.34),transparent 24%),
    radial-gradient(circle,#9d7944 0 40%,#51452f 42% 48%,#a88955 50% 64%,#4d412c 66% 72%,#82663f 74% 100%);
  border:2px solid #4c402b;
  box-shadow:0 4px 7px rgba(44,28,11,.34),inset 0 0 0 2px rgba(218,197,139,.28);
}
.cast-coin::before { content:""; position:absolute; left:50%; top:50%; width:14px; height:14px; transform:translate(-50%,-50%) rotate(8deg); background:var(--paper); border:2px solid #433824; box-shadow:inset 0 0 2px rgba(0,0,0,.55); z-index:1; }
.coin-char { position:absolute; color:#302719; font-family:"Songti SC","STSong",serif; font-size:9px; font-style:normal; font-weight:800; line-height:1; text-shadow:0 1px rgba(222,202,148,.38); z-index:2; }
.coin-char-1 { left:50%; top:5px; transform:translateX(-50%); }
.coin-char-2 { right:5px; top:50%; transform:translateY(-50%); }
.coin-char-3 { left:50%; bottom:5px; transform:translateX(-50%); }
.coin-char-4 { left:5px; top:50%; transform:translateY(-50%); }
.cast-coin.is-landed { opacity:1; transform:translate(-50%,-50%) scale(1) rotate(var(--coin-turn)); }
.cast-coin.is-red { box-shadow:0 4px 7px rgba(44,28,11,.35),0 0 0 5px rgba(197,43,30,.16),inset 0 0 0 2px rgba(255,221,132,.34); }
.cast-coin.is-red::before { width:20px; height:20px; border:0; background:var(--red); box-shadow:inset 0 0 0 3px rgba(119,13,8,.3); transform:translate(-50%,-50%) rotate(-7deg); }
.cast-coin.is-red::after { color:#fff1df; content:"朱"; position:absolute; inset:0; display:grid; place-items:center; font-size:11px; font-weight:800; z-index:3; }
.coin-counter { position:absolute; left:24px; bottom:22px; color:var(--cobalt); font-family:ui-monospace,monospace; font-size:10px; letter-spacing:.12em; }
.coin-counter::before { content:"●"; margin-right:8px; }
.line-stack { width:min(430px,100%); max-width:100%; justify-self:center; margin-inline:auto; display:flex; flex-direction:column; gap:11px; padding:24px 22px; border:1px solid var(--hairline); background:rgba(255,255,255,.16); box-shadow:8px 8px 0 rgba(18,72,200,.08); }
.line-row { min-height:58px; display:grid; grid-template-columns:32px 1fr 54px; align-items:center; gap:14px; color:var(--muted); }
.line-row span { font-family:ui-monospace,monospace; }
.line-row i { height:10px; background:var(--ink); display:block; }
.line-coin-slot { width:54px; height:54px; position:relative; display:block; }
.line-coin { left:50%; top:50%; width:46px; height:46px; }
.line-row:has(.line-coin.is-red) { color:var(--red); }

.cast-record { list-style:none; padding:0; margin:0 0 28px; border-top:5px solid var(--ink); }
.cast-record li { display:flex; justify-content:space-between; gap:20px; padding:17px 0; border-bottom:1px solid var(--hairline); }
.cast-record span { color:var(--muted); font-family:ui-monospace,monospace; font-size:11px; }
.cast-record strong { font-size:20px; }
.cast-record li.is-set strong { color:var(--cobalt); }
.cast-record .line-record-separator { position:relative; margin-top:22px; border-top:5px solid var(--ink); }
.cast-record .line-record-separator::before { content:"定爻"; position:absolute; transform:translateY(-31px); color:var(--muted); background:var(--paper); padding-right:10px; font-family:ui-monospace,monospace; font-size:9px; letter-spacing:.14em; }
.cast-record .line-record-value { display:flex; align-items:center; justify-content:flex-end; gap:16px; }
.cast-record .record-coins { display:flex; flex-direction:column-reverse; align-items:center; gap:2px; color:inherit; font-family:inherit; font-size:inherit; }
.record-coin { position:relative; display:block; width:14px; height:14px; border:1px solid #4c402b; border-radius:50%; background:radial-gradient(circle,#a88853 0 56%,#5a4930 59% 71%,#947448 74% 100%); }
.record-coin::after { content:""; position:absolute; left:50%; top:50%; width:4px; height:4px; transform:translate(-50%,-50%) rotate(5deg); border:1px solid #4c402b; background:var(--paper); }
.cast-record .record-line-name { color:var(--cobalt); font-family:inherit; font-size:20px; }
.cast-button { width:100%; min-height:145px; border:0; padding:24px; color:var(--paper); background:var(--ink); cursor:pointer; text-align:left; position:relative; overflow:hidden; }
.cast-button::after { content:"摇"; position:absolute; right:16px; bottom:8px; color:var(--cobalt); font-size:118px; line-height:1; opacity:.9; }
.cast-button span { display:block; font-family:ui-monospace,monospace; font-size:11px; letter-spacing:.15em; }
.cast-button strong { display:block; margin-top:8px; font-size:34px; }
.cast-button.is-casting::after { animation:shake .12s linear infinite alternate; }
@keyframes shake { to { transform:translate(6px,-4px) rotate(3deg); } }
.reveal-button { width:100%; margin-top:12px; padding:18px; border:2px solid var(--cobalt); color:var(--cobalt); font-weight:800; font-size:21px; }
.reveal-button:not(:disabled):hover { color:var(--paper); background:var(--cobalt); }
.reveal-button:disabled { opacity:.25; cursor:not-allowed; }

.result-panel { overflow:hidden; }
.result-panel::after { content:var(--result-glyph, ""); position:absolute; right:-35px; top:105px; color:rgba(18,72,200,.055); font-size:220px; font-weight:900; letter-spacing:-.18em; writing-mode:vertical-rl; pointer-events:none; }
.result-head { position:relative; z-index:1; display:grid; grid-template-columns:minmax(420px,1fr) minmax(480px,1fr); gap:32px; align-items:stretch; border-top:7px solid var(--ink); border-bottom:1px solid var(--ink); padding:24px 0 28px; }
.result-title-block h2 { font-size:clamp(76px,11vw,142px); }
.result-name-line { display:flex; align-items:baseline; flex-wrap:wrap; gap:10px 20px; margin:8px 0 0; color:var(--cobalt); }
.result-name-line span { font-size:22px; font-weight:800; }
.result-name-line strong { color:var(--ink); font-size:clamp(28px,3vw,42px); font-weight:800; }
.result-label { display:flex; align-items:baseline; flex-wrap:wrap; gap:8px 22px; margin:6px 0 0; color:var(--cobalt); font-size:18px; font-weight:800; }
.result-changed-name { display:inline-flex; align-items:baseline; gap:9px; }
.result-changed-name small { color:var(--muted); font-family:ui-monospace,monospace; font-size:10px; font-weight:500; letter-spacing:.12em; }
.result-changed-name strong { color:var(--red); font-size:clamp(28px,3vw,42px); font-weight:800; }
.result-meta { display:flex; margin:28px 0 0; }
.result-meta div { min-width:92px; padding:10px 18px 8px 0; border-top:1px solid var(--ink); }
.result-meta dt { color:var(--muted); font-family:ui-monospace,monospace; font-size:9px; letter-spacing:.12em; }
.result-meta dd { margin:6px 0 0; font-size:22px; }
.result-side { display:grid; grid-template-columns:minmax(190px,.85fr) minmax(230px,1.15fr); gap:14px; align-items:stretch; }
.result-frame { min-height:430px; border:1px solid var(--hairline); background:rgba(255,255,255,.13); }
.result-hexagram-frame { display:grid; grid-template-rows:1fr auto 1fr; gap:18px; padding:22px; }
.hexagram-section { display:flex; flex-direction:column; justify-content:flex-end; min-width:0; }
.hexagram-section header { display:flex; align-items:baseline; justify-content:space-between; gap:12px; padding-top:2px; }
.hexagram-section header span { color:var(--muted); font-family:ui-monospace,monospace; font-size:9px; letter-spacing:.12em; }
.hexagram-section header strong { color:var(--ink); font-size:14px; line-height:1.35; }
.changed-hexagram-section header span { font-size:13px; font-weight:700; }
.changed-hexagram-section header strong { color:var(--red); }
.hexagram-divider { height:1px; background:var(--hairline); }
.result-question-frame { display:flex; flex-direction:column; justify-content:flex-end; padding:26px 24px; }
.result-question-frame > span { margin-bottom:18px; color:var(--muted); font-family:ui-monospace,monospace; font-size:10px; letter-spacing:.12em; }
.result-side blockquote { width:100%; max-width:none; align-self:end; font-size:15px; }
.result-question-frame blockquote { font-size:clamp(24px,2.2vw,30px); line-height:1.7; overflow-wrap:anywhere; }
.result-hexagram { width:100%; display:flex; flex-direction:column; gap:9px; margin-top:14px; padding:2px 0; }
.hex-row { display:grid; grid-template-columns:24px 1fr; gap:12px; align-items:center; color:var(--muted); font-family:ui-monospace,monospace; font-size:10px; }
.hex-line { height:6px; display:block; position:relative; }
.hex-line.solid { background:var(--ink); }
.hex-line.broken::before,.hex-line.broken::after { content:""; position:absolute; top:0; width:44%; height:6px; background:var(--ink); }
.hex-line.broken::before { left:0; }.hex-line.broken::after { right:0; }
.hex-row.is-selected { color:var(--red); font-weight:800; }
.hex-row.is-selected .hex-line { box-shadow:0 0 0 3px rgba(197,43,30,.09); }
.hex-row.is-selected .hex-line.solid { background:var(--red); }
.hex-row.is-selected .hex-line.broken { background:transparent; }
.hex-row.is-selected .hex-line.broken::before,.hex-row.is-selected .hex-line.broken::after { background:var(--red); }
.source-layout { display:grid; grid-template-columns:.8fr 1.2fr; gap:40px; margin-top:50px; align-items:start; }
.source-layout.text-only { display:block; max-width:none; margin-top:28px; }
.transcription-card { border-top:0; padding:18px 0 20px; background:transparent; }
.edition-grid { display:grid; grid-template-columns:.82fr 1.18fr; gap:18px; margin-top:14px; }
.text-edition { position:relative; margin-top:0; border:1px solid var(--ink); padding:20px 24px 24px; background:rgba(241,234,219,.66); }
.text-edition h3 { display:flex; align-items:center; gap:12px; margin:0; padding-bottom:14px; border-bottom:1px solid var(--hairline); font-size:18px; letter-spacing:.08em; }
.text-edition h3 span { color:var(--paper); background:var(--ink); padding:4px 7px; font-family:ui-monospace,monospace; font-size:10px; letter-spacing:0; }
.verse-edition { border-color:var(--red); box-shadow:5px 5px 0 rgba(197,43,30,.1); }
.verse-edition h3 { color:var(--red); }
.verse-edition h3 span { background:var(--red); }
.commentary-edition { border-color:var(--cobalt); box-shadow:5px 5px 0 rgba(18,72,200,.12); }
.commentary-edition h3 { color:var(--cobalt); }
.commentary-edition h3 span { background:var(--cobalt); }
.ocr-columns { min-height:250px; margin-top:20px; display:flex; flex-direction:row; justify-content:flex-start; gap:18px; overflow-x:auto; padding:8px 8px 18px; direction:rtl; }
.verse-columns { min-height:250px; justify-content:center; gap:16px; }
.verse-pair { display:flex; direction:rtl; gap:5px; padding:0 10px; }
.verse-pair + .verse-pair { border-right:1px solid var(--hairline); }
.commentary-columns { min-height:250px; justify-content:center; }
.ocr-column { writing-mode:vertical-rl; text-orientation:upright; font-size:20px; line-height:1.8; letter-spacing:.08em; direction:ltr; }
.verse-columns .ocr-column { font-size:27px; font-weight:700; line-height:1.7; }
.commentary-columns .ocr-column { font-size:18px; white-space:pre-wrap; }
.ocr-column.low-confidence { color:var(--muted); }
.source-note { margin:18px 0 0; padding-top:14px; border-top:1px solid var(--hairline); color:var(--muted); font-size:12px; line-height:1.8; }
.original-reading-layout { margin-top:28px; }
.original-reading-card { border:1px solid var(--ink); background:rgba(255,255,255,.2); box-shadow:6px 6px 0 rgba(23,21,18,.08); }
.original-reading-card > header { min-height:62px; padding:13px 18px; display:flex; align-items:center; justify-content:space-between; gap:20px; border-bottom:1px solid var(--ink); }
.original-reading-card h3 { margin:0; font-size:20px; letter-spacing:.1em; }
.original-reading-card header span { color:var(--cobalt); font-weight:700; letter-spacing:.12em; }
.original-reading-guide { min-height:52px; display:grid; grid-template-columns:1fr auto 1fr; align-items:center; gap:18px; padding:10px 18px; border-bottom:1px solid var(--hairline); background:rgba(255,255,255,.16); }
.original-reading-guide span { display:flex; align-items:center; gap:9px; font-size:15px; font-weight:800; }
.original-reading-guide b { padding:4px 7px; color:var(--paper); font-family:ui-monospace,monospace; font-size:10px; letter-spacing:.08em; }
.original-reading-guide .guide-right { grid-column:3; grid-row:1; justify-self:end; color:var(--red); }
.original-reading-guide .guide-right b { background:var(--red); }
.original-reading-guide .guide-left { grid-column:1; grid-row:1; justify-self:start; color:var(--cobalt); }
.original-reading-guide .guide-left b { background:var(--cobalt); }
.original-reading-guide em { grid-column:2; grid-row:1; color:var(--muted); font-family:ui-monospace,monospace; font-size:10px; font-style:normal; letter-spacing:.1em; text-align:center; }
.original-reading-images { min-height:520px; padding:24px; display:flex; direction:rtl; align-items:flex-start; justify-content:center; gap:0; overflow:auto; background:#f8f6f0; }
.original-reading-images img { display:block; width:auto; max-width:100%; height:min(68vh,760px); object-fit:contain; mix-blend-mode:multiply; }
.original-reading-images.is-split img { max-width:50%; }
.ai-copy-panel { margin-top:34px; padding:28px; display:grid; grid-template-columns:1.05fr .95fr; gap:42px; align-items:end; border:1px solid var(--ink); border-top:7px solid var(--ink); background:rgba(255,255,255,.16); }
.ai-copy-copy h3 { margin:0; font-size:clamp(28px,3vw,42px); }
.ai-copy-copy > p:last-child { max-width:620px; margin:18px 0 0; font-size:15px; line-height:1.9; }
.ai-copy-actions { display:grid; gap:10px; }
.ai-copy-button { width:100%; min-height:58px; display:flex; align-items:center; gap:16px; padding:13px 18px; border:2px solid var(--cobalt); color:var(--paper); background:var(--cobalt); cursor:pointer; font-weight:800; font-size:17px; text-align:left; transition:transform .18s,background .18s,color .18s; }
.ai-copy-button span { font-family:ui-monospace,monospace; font-size:10px; letter-spacing:.12em; }
.ai-copy-button:hover { transform:translateY(-2px); }
.ai-copy-button:active { transform:translateY(1px); }
.ai-copy-button:focus-visible { outline:2px solid var(--red); outline-offset:3px; }
.ai-copy-status { min-height:1.5em; margin:3px 0 0; color:var(--muted); font-size:12px; line-height:1.5; }
.ai-copy-status.is-error { color:var(--red); }
.ai-screenshot-note { margin:10px 0 0; padding:15px 17px 15px 20px; border-left:5px solid var(--cobalt); color:var(--ink); background:rgba(18,72,200,.08); font-size:16px; font-weight:700; line-height:1.75; }
.ai-screenshot-note::before { content:"提示"; display:inline-block; margin-right:10px; padding:3px 7px; color:var(--paper); background:var(--cobalt); font-family:ui-monospace,monospace; font-size:10px; font-weight:800; letter-spacing:.1em; vertical-align:.12em; }
.result-actions { display:flex; justify-content:flex-end; margin-top:30px; }
.text-button { padding-bottom:5px; border-bottom:1px solid var(--ink); white-space:nowrap; }

.book-introduction { width:min(1180px,calc(100% - 40px)); margin:78px auto 0; padding:36px 0 64px; border-top:8px solid var(--ink); border-bottom:1px solid var(--ink); }
.introduction-head { display:grid; grid-template-columns:.52fr 1.08fr 1.15fr; gap:34px; align-items:end; padding-bottom:34px; border-bottom:1px solid var(--ink); }
.introduction-head .eyebrow { align-self:start; }
.introduction-head h2 { font-size:clamp(42px,5.5vw,76px); }
.introduction-head h2 span { color:var(--red); }
.introduction-head > p:last-child { margin:0; font-size:15px; line-height:1.9; }
.preface-grid { display:grid; grid-template-columns:1fr 1fr; gap:22px; margin-top:24px; align-items:start; }
.preface-nan { grid-column:1 / -1; }
.preface { border:1px solid var(--ink); background:rgba(255,255,255,.12); }
.preface > header { display:flex; align-items:center; gap:14px; padding:15px 18px; border-bottom:1px solid var(--ink); }
.preface > header span { padding:5px 8px; color:var(--paper); background:var(--ink); font-family:ui-monospace,monospace; font-size:10px; }
.preface > header h3 { margin:0; font-size:19px; letter-spacing:.08em; }
.preface-nan > header { color:var(--cobalt); border-color:var(--cobalt); }
.preface-nan > header span { background:var(--cobalt); }
.preface-shao > header { color:var(--red); border-color:var(--red); }
.preface-shao > header span { background:var(--red); }
.preface-france > header { color:var(--ink); border-color:var(--ink); }
.preface-france > header span { background:var(--ink); }
.preface-copy { padding:24px 26px 30px; column-count:2; column-gap:34px; column-rule:1px solid var(--hairline); }
.preface-nan .preface-copy { column-count:3; }
.preface-shao .preface-copy,.preface-france .preface-copy { column-count:1; }
.preface-copy p { margin:0 0 1.35em; font-size:15px; line-height:2; text-align:justify; }
.preface-copy p:first-child::first-letter { float:left; margin:.06em .12em 0 0; color:var(--red); font-size:3.6em; font-weight:900; line-height:.8; }
.preface-signature { break-inside:avoid; padding-top:16px; border-top:1px solid var(--hairline); text-align:right!important; font-size:13px!important; }

.bagua-knowledge { width:min(1180px,calc(100% - 40px)); margin:78px auto 0; padding:38px 0 66px; border-top:8px solid var(--ink); border-bottom:1px solid var(--ink); }
.knowledge-head { max-width:900px; }
.knowledge-head h2 { font-size:clamp(48px,7vw,94px); }
.knowledge-intro { max-width:760px; margin-top:24px; }
.knowledge-intro p { margin:0 0 10px; font-size:16px; line-height:1.9; }
.bagua-song { display:grid; grid-template-columns:.38fr 1.62fr; gap:24px; align-items:center; margin-top:34px; padding:24px 0; border-top:1px solid var(--ink); border-bottom:1px solid var(--ink); }
.bagua-song h3 { margin:0; color:var(--red); font-size:24px; }
.bagua-song p { margin:0; font-size:clamp(20px,2.5vw,32px); font-weight:800; line-height:1.65; }
.bagua-song p span { display:block; }
.fuxi-hexagram-figure { width:min(900px,100%); margin:46px auto 0; border:1px solid var(--ink); background:rgba(255,255,255,.22); }
.fuxi-hexagram-figure img { display:block; width:100%; height:auto; mix-blend-mode:multiply; }
.fuxi-hexagram-figure figcaption { padding:15px 18px; border-top:1px solid var(--ink); color:var(--cobalt); font-size:15px; font-weight:800; letter-spacing:.08em; text-align:center; }
.bagua-meanings { margin-top:46px; }
.bagua-meanings > h3 { margin:0 0 24px; padding:0 0 18px; border-bottom:7px solid var(--ink); font-size:clamp(38px,5vw,64px); }
.meaning-grid { display:grid; grid-template-columns:1fr 1fr; gap:24px; align-items:start; }
.meaning-item { border:1px solid var(--ink); background:rgba(255,255,255,.12); }
.meaning-item > header { min-height:88px; display:grid; grid-template-columns:38px 52px 1fr auto; align-items:center; gap:10px; padding:14px 18px; color:var(--paper); background:var(--ink); }
.meaning-item:nth-child(4n+2) > header,.meaning-item:nth-child(4n+3) > header { background:var(--cobalt); }
.meaning-item:nth-child(4n+4) > header { background:var(--red); }
.meaning-item > header span { font-family:ui-monospace,monospace; font-size:11px; }
.meaning-item > header b { font-family:serif; font-size:40px; font-weight:500; line-height:1; }
.meaning-item > header h4 { margin:0; font-size:30px; letter-spacing:.08em; }
.meaning-item > header em { padding:5px 8px; border:1px solid rgba(241,234,219,.65); font-size:14px; font-style:normal; }
.meaning-list { margin:0; padding:20px 22px 24px; }
.meaning-list > div { display:grid; grid-template-columns:48px minmax(0,1fr); gap:10px; padding:7px 0; }
.meaning-list > div:last-child { grid-template-columns:48px auto 42px auto 42px 1fr; margin-top:9px; padding-top:14px; border-top:1px solid var(--hairline); }
.meaning-list dt { color:var(--cobalt); font-size:13px; font-weight:800; }
.meaning-item:nth-child(even) .meaning-list dt { color:var(--red); }
.meaning-list dd { margin:0; font-size:14px; line-height:1.75; }

footer { width:min(1180px,calc(100% - 40px)); margin:0 auto; padding:24px 0 50px; display:flex; justify-content:space-between; align-items:center; gap:20px; color:var(--muted); font-size:10px; }
footer a { color:inherit; text-underline-offset:3px; }
.footer-brand { display:grid; grid-template-columns:32px auto; align-items:center; column-gap:9px; color:inherit; text-decoration:none; text-transform:none; letter-spacing:0; }
.footer-brand img { grid-row:1 / 3; display:block; width:32px; height:32px; object-fit:cover; border:1px solid rgba(23,21,18,.24); }
.footer-brand b { color:var(--ink); font-family:"Songti SC","STSong",serif; font-size:13px; letter-spacing:.12em; }
.footer-brand em { font-style:normal; font-family:ui-monospace,monospace; font-size:8px; letter-spacing:.09em; text-transform:uppercase; }
.footer-actions { display:flex; align-items:center; gap:8px; }
.footer-action { min-height:34px; padding:8px 12px; border:1px solid var(--ink); color:var(--ink); background:transparent; cursor:pointer; font-family:"Songti SC","STSong",serif; font-size:13px; font-weight:800; text-decoration:none; }
.footer-action:hover { color:var(--paper); background:var(--ink); }
.footer-action:focus-visible { outline:2px solid var(--cobalt); outline-offset:3px; }
.wechat-dialog { width:min(480px,calc(100% - 34px)); margin:auto; padding:0; border:1px solid var(--ink); color:var(--ink); background:var(--paper); box-shadow:12px 12px 0 rgba(18,72,200,.18); font-family:"Songti SC","STSong",serif; }
.wechat-dialog::backdrop { background:rgba(23,21,18,.68); backdrop-filter:blur(3px); }
.wechat-dialog-head { display:flex; align-items:flex-start; justify-content:space-between; gap:20px; padding:20px 22px 16px; border-top:7px solid var(--ink); border-bottom:1px solid var(--ink); }
.wechat-dialog-head span { color:var(--cobalt); font-family:ui-monospace,monospace; font-size:10px; letter-spacing:.14em; }
.wechat-dialog-head h2 { margin:8px 0 0; font-size:34px; letter-spacing:-.04em; }
.wechat-dialog-head button { padding:7px 10px; border:1px solid var(--ink); background:transparent; cursor:pointer; font-size:13px; }
.wechat-dialog-head button:hover { color:var(--paper); background:var(--ink); }
.wechat-dialog > img { display:block; width:min(390px,calc(100% - 44px)); height:auto; margin:22px auto 14px; background:#fff; }
.wechat-dialog > p { margin:0; padding:0 22px 22px; color:var(--muted); font-size:14px; line-height:1.7; text-align:center; }

@media (max-width: 1000px) {
  .result-head { display:block; }
  .result-side { margin-top:24px; }
}

@media (max-width: 800px) {
  .masthead { grid-template-columns:40px minmax(0,1fr) 46px 54px; }
  .masthead p { grid-column:1/5; line-height:1.6; }
  .brand-signature { grid-template-columns:40px; margin-right:6px; }
  .brand-signature img { width:40px; height:40px; }
  .brand-wordmark { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
  .edition { display:none; }
  .panel { min-height:auto; padding:64px 20px 74px 36px; }
  .casting-panel { padding-inline:0; }
  .ritual-panel.is-active,.question-layout,.casting-grid,.source-layout { display:grid; grid-template-columns:1fr; }
  .incense { height:340px; transform:scale(.82); }
  .question-layout,.casting-grid,.source-layout { gap:42px; }
  .casting-head,.result-head { display:block; }
  .casting-head blockquote,.result-head blockquote { margin-top:24px; }
  .casting-grid { width:100%; min-width:0; }
  .oracle-board { min-height:690px; padding:116px 14px 66px; }
  .casting-guide { top:24px; width:calc(100% - 36px); font-size:14px; }
  .bagua-wheel {
    width:calc(100% - 8px);
    max-width:560px;
    margin-inline:auto;
    transform:none;
  }
  .gua { width:42px; height:42px; }
  .gua::after { width:34px; }
  .gua b { font-size:15px; }
  .pos-8::after{top:42px} .pos-4::after{right:33px} .pos-3::after{right:42px} .pos-2::after{right:34px}
  .pos-1::after{bottom:42px} .pos-5::after{left:34px} .pos-6::after{left:42px} .pos-7::after{left:34px}
  .trigram-mark { width:38px; }
  .trigram-mark span { font-size:22px; }
  .trigram-mark em { margin-top:3px; font-size:11px; }
  .cast-coin { width:42px; height:42px; }
  .cast-coin::before { width:11px; height:11px; }
  .cast-coin.is-red::before { width:16px; height:16px; }
  .coin-char { font-size:7px; }
  .coin-char-1 { top:4px; } .coin-char-2 { right:4px; } .coin-char-3 { bottom:4px; } .coin-char-4 { left:4px; }
  .result-head h2,.result-name-line,.result-label,.result-head blockquote { display:block; }
  .result-name-line strong { display:block; margin-top:7px; }
  .result-side { margin-top:24px; grid-template-columns:1fr 1.2fr; }
  .result-frame { min-height:440px; }
  .edition-grid { grid-template-columns:1fr; }
  .original-reading-images { min-height:420px; padding:14px; }
  .original-reading-images img { height:min(62vh,620px); }
  .original-reading-guide { grid-template-columns:1fr 1fr; }
  .original-reading-guide .guide-left { grid-column:1; }
  .original-reading-guide .guide-right { grid-column:2; }
  .original-reading-guide em { grid-column:1 / -1; grid-row:2; }
  .ai-copy-panel { grid-template-columns:1fr; gap:26px; padding:24px 20px; }
  .introduction-head,.preface-grid { grid-template-columns:1fr; }
  .preface-nan { grid-column:auto; }
  .preface-copy { column-count:1; }
  .bagua-song { grid-template-columns:1fr; }
  .meaning-grid { grid-template-columns:1fr; }
  .text-button { justify-self:start; }
  footer { flex-direction:column; }
  .footer-actions { order:2; }
  #footerReading { order:3; }
}

@media (max-width: 520px) {
  .masthead { grid-template-columns:1fr 42px 46px; }
  .masthead h1 { grid-column:1 / 2; font-size:clamp(42px,15vw,70px); }
  .brand-signature { grid-column:2; }
  .seal { grid-column:3; }
  .masthead p { grid-column:1/4; }
  .result-side { grid-template-columns:1fr; }
  .result-frame { min-height:440px; }
  .cast-button strong { font-size:28px; }
  .cast-button::after { right:12px; bottom:14px; font-size:88px; }
  .meaning-item > header { grid-template-columns:28px 44px 1fr auto; padding:12px 14px; }
  .meaning-list { padding:16px 15px 20px; }
  .meaning-list > div:last-child { grid-template-columns:44px 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { animation-duration:.01ms!important; animation-iteration-count:1!important; scroll-behavior:auto!important; transition-duration:.01ms!important; }
}
