/* theinferencemechanic.com/read — the in-browser preview reader */
.rd .nav-in { gap: 14px; }
.rd-tools { display: flex; align-items: center; gap: 6px; }
.rd-where { display: inline-flex; align-items: baseline; gap: 12px; margin-right: 8px; font-family: var(--ui); font-size: 12.5px; color: var(--text-mid); white-space: nowrap; }
.rd-chap { font-weight: 600; color: var(--text-hi); max-width: 34vw; overflow: hidden; text-overflow: ellipsis; }
.rd-pages b { color: var(--gold); font-weight: 600; }
.rd-btn { display: inline-grid; place-items: center; min-width: 36px; height: 36px; padding: 0 10px; border-radius: 10px; border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.06); color: var(--text-hi); font: 600 15px var(--ui); cursor: pointer; transition: background .2s, border-color .2s; }
.rd-btn:hover { background: rgba(255,255,255,.12); border-color: rgba(240,192,112,.5); }
.rd-btn svg { width: 16px; height: 16px; }
.rd-toc-btn { font-size: 13px; padding: 0 14px; }
.rd-toc-btn[aria-expanded="true"] { background: rgba(240,192,112,.14); border-color: rgba(240,192,112,.6); color: var(--gold); }
.rd-toc { position: fixed; top: calc(var(--nav-h) + 12px); right: 18px; z-index: 45; width: min(360px, calc(100vw - 36px)); max-height: calc(100vh - var(--nav-h) - 40px); overflow: auto; padding: 18px 18px 14px; border-radius: var(--r-md); }
.rd-toc[hidden] { display: none; }
.rd-toc-h { font-family: var(--ui); font-size: 11px; letter-spacing: 3px; text-transform: uppercase; color: var(--orange); font-weight: 600; margin-bottom: 10px; }
.rd-toc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.rd-toc-list a { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 7px 10px; border-radius: 10px; font-size: 13.5px; color: var(--text-mid); }
.rd-toc-list a:hover, .rd-toc-list a.on { background: rgba(255,255,255,.07); color: var(--text-hi); }
.rd-toc-list a b { font-weight: 500; }
.rd-toc-list a span { color: var(--text-lo); font-variant-numeric: tabular-nums; }
.rd-toc-list a.lvl2 { padding-left: 24px; font-size: 12.5px; }
.rd-toc-more { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--text-lo); }
.rd-toc-more a { color: var(--gold); }

.rd-main { padding: calc(var(--nav-h) + 22px) 16px 40px; }
.rd-note { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0 auto 18px; max-width: 900px; text-align: center; font-family: var(--ui); font-size: 12.5px; color: var(--text-lo); }
.rd-note i { width: 7px; height: 7px; border-radius: 50%; background: #5fd08a; box-shadow: 0 0 10px #5fd08a; flex: none; }
.rd-note b { color: var(--text-mid); font-weight: 600; }
.rd-pages { display: grid; gap: 22px; justify-items: center; min-height: 60vh; }
.rd-page { position: relative; width: var(--pw, min(900px, 100%)); background: #f3ece0; border-radius: 6px; box-shadow: 0 26px 60px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.08); overflow: hidden; }
.rd-page::before { content: ""; display: block; padding-top: calc(100% * 666 / 504); }
.rd-page canvas, .rd-page .rd-text { position: absolute; inset: 0; width: 100%; height: 100%; }
.rd-page .rd-text { overflow: hidden; line-height: 1; color: transparent; }
.rd-page .rd-text span { position: absolute; white-space: pre; transform-origin: 0 0; color: transparent; }
.rd-page .rd-text ::selection { background: rgba(240,115,61,.35); }
.rd-page .rd-num { position: absolute; right: 12px; bottom: 8px; font: 500 11px var(--ui); color: rgba(20,18,16,.45); letter-spacing: .3px; pointer-events: none; }
.rd-page.is-loading::after { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, rgba(0,0,0,.02) 20%, rgba(0,0,0,.06) 50%, rgba(0,0,0,.02) 80%); background-size: 200% 100%; animation: rdshimmer 1.4s linear infinite; }
@keyframes rdshimmer { to { background-position: -200% 0; } }
.rd-loading { display: inline-flex; align-items: center; gap: 12px; padding: 18px 22px; border-radius: 14px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1); color: var(--text-mid); font-size: 14px; }
.rd-spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.18); border-top-color: var(--orange); animation: rdspin .9s linear infinite; }
@keyframes rdspin { to { transform: rotate(360deg); } }
.rd-error { max-width: 640px; padding: 18px 22px; border-radius: 14px; background: rgba(255,120,110,.10); border: 1px solid rgba(255,120,110,.4); color: #ffb3aa; font-size: 14px; }
.rd-error a { color: var(--gold); text-decoration: underline; }

/* the gate */
.rd-gate { margin: 40px auto 0; max-width: 1080px; }
.rd-gate-in { padding: clamp(24px, 3.2vw, 44px); display: grid; grid-template-columns: 220px 1fr; gap: clamp(24px, 4vw, 56px); align-items: center; }
.rd-gate-cover img { width: 100%; height: auto; border-radius: 8px; box-shadow: 0 26px 60px rgba(0,0,0,.6), 0 0 0 1px rgba(240,192,112,.42); transform: perspective(1200px) rotateY(-6deg); }
.rd-gate-copy { display: grid; gap: 14px; }
.rd-gate-copy h2 { font-size: clamp(28px, 3.2vw, 44px); }
.rd-gate-copy > p { margin: 0; color: var(--text-mid); font-size: 15px; line-height: 1.6; max-width: 66ch; }
.rd-form { padding: 0 !important; background: none !important; border: 0 !important; box-shadow: none !important; backdrop-filter: none !important; -webkit-backdrop-filter: none !important; border-radius: 0 !important; gap: 10px; grid-template-columns: 1fr 1fr; }
.rd-form::before, .rd-form::after { display: none; }
.rd-form .bk-submit, .rd-form .bk-form-note, .rd-form .bk-form-done, .rd-form .bk-form-err { grid-column: 1 / -1; }
/* locked state: a soft veil over the last page while the gate is in view */
.rd-page.is-last::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 34%; background: linear-gradient(180deg, rgba(20,18,16,0), rgba(20,18,16,.85)); pointer-events: none; }
.rd-page.is-last .rd-last-k { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); white-space: nowrap; padding: 9px 14px; border-radius: 999px; font: 600 11px var(--ui); letter-spacing: 2px; text-transform: uppercase; color: #1a120a; background: linear-gradient(135deg, #ffd9a0, var(--gold) 60%, #d9a955); box-shadow: 0 12px 28px rgba(240,192,112,.35); }
@media (max-width: 860px) {
  .rd .nav-in { padding: 0 12px; } .rd .nav-right { display: none; } .rd-where { gap: 8px; font-size: 12px; } .rd-chap { display: none; }
  .rd-toc-btn { font-size: 12px; padding: 0 10px; }
  .rd-gate-in { grid-template-columns: 1fr; } .rd-gate-cover { width: 160px; margin: 0 auto; } .rd-form { grid-template-columns: 1fr; }
  .rd-main { padding-left: 10px; padding-right: 10px; }
}
