/* Prepared verse study ("相关教言 · AI 整理"), shared by read pages.
   Needs reading.css tokens. */
/* Prepared summaries stay visibly separate from the collected commentary. */
.library-synthesis { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); font-family: var(--sans); }
.library-synthesis-heading { display: flex; align-items: baseline; gap: 0.75rem; margin: 0 0 1rem; font: 600 0.9375rem/1.6 var(--sans); }
.library-synthesis-label { font: 0.8125rem/1.5 var(--sans); color: var(--ink-soft); }
.library-synthesis-point { margin: 1rem 0 0.5rem; }
.library-synthesis-empty { color: var(--ink-soft); }
.library-evidence { font-size: 0.875em; margin: 0.375rem 0; }
.library-evidence > summary { cursor: pointer; padding-block: 0.375rem; color: var(--ink-soft); }
.library-evidence blockquote { margin: 0.5rem 0; padding: 0.75rem; background: var(--surface); border-radius: 0.375rem; }
.library-source-button { padding: 0.5rem 0; min-height: 2.75rem; background: none; border: 0; font: 0.875rem/1.5 var(--sans); color: var(--ink-soft); cursor: pointer; text-decoration: underline; text-underline-offset: 0.2em; }
.library-source-button:disabled { cursor: wait; }
.library-source-text { white-space: pre-wrap; max-height: 28rem; overflow-y: auto; overflow-wrap: anywhere; margin-block: 0.75rem; }
.library-evidence summary:focus-visible, .library-source-button:focus-visible { outline: 2px solid var(--ink-soft); outline-offset: 2px; }

/* Quiet paragraph citations lead to one consolidated source list. */
.library-citations { white-space: nowrap; margin-left: 0.2em; }
.library-citation { display: inline; min-width: 1.4em; padding: 0.2em 0.35em; border: 0; border-radius: 0.2em; color: var(--ink-soft); background: transparent; font: 0.6875em/1 var(--sans); vertical-align: super; cursor: pointer; }
.library-citation:hover, .library-citation:focus-visible { color: var(--ink); background: var(--surface); outline: 1px solid var(--line); }
.library-references { margin-top: 1.25rem; padding-top: 0.75rem; border-top: 1px solid var(--line); }
.library-references-heading { margin: 0 0 0.25rem; color: var(--ink-soft); font: 400 0.75rem/1.5 var(--sans); }
.library-evidence > summary { display: flex; align-items: baseline; gap: 0.625rem; list-style: none; }
.library-evidence > summary::-webkit-details-marker { display: none; }
.library-evidence > summary:hover { color: var(--ink); }
.library-evidence > summary:focus-visible { outline: 1px solid var(--ink-soft); outline-offset: 2px; }
.library-source-number { flex: 0 0 1em; font-size: 0.8em; font-variant-numeric: tabular-nums; }

/* Tap-to-open verses on pages without collected commentary (佛子行): the
   verse itself is the control, and its study follows 普贤行愿品's notes —
   a column beside the text on desktop, opening in place under the verse on
   smaller screens. The study is secondary: smaller, softer sans-serif type. */
.verse.has-study { --study-gutter: 2.5rem; --study-offset: var(--study-gutter); }
.verse.has-study > .verse-body { --verse-body-pad: 0.3em; cursor: pointer; padding: var(--verse-body-pad) 0.75rem var(--verse-body-pad) var(--study-gutter); margin: calc(-1 * var(--verse-body-pad)) -0.75rem calc(-1 * var(--verse-body-pad)) calc(-1 * var(--study-offset)); border-radius: 0.375rem; transition: background-color 0.15s; -webkit-tap-highlight-color: transparent; }
.verse.has-study > .verse-body:hover,
.verse.study-open > .verse-body { background: var(--study-surface); }
/* Like 普贤行愿品, the verse number sits inside the highlight. */
.verse.has-study > .verse-body .verse-num { right: calc(100% - var(--study-gutter) + 0.5rem); margin-right: 0; }
.verse.has-study > .verse-body:focus { outline: none; }
.verse.has-study > .verse-body:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
:root { --study-surface: color-mix(in srgb, var(--ink) 7%, var(--paper)); }
html.dark { --study-surface: color-mix(in srgb, var(--ink) 15%, var(--paper)); }

.study-pane[hidden] { display: none; }
.study-pane { display: flex; flex-direction: column; min-width: 0; background: color-mix(in srgb, var(--ink) 6%, var(--paper)); border-radius: 0.375rem; color: var(--ink); font-family: var(--sans); font-size: calc(1.0625rem * var(--reading-scale, 1)); line-height: 1.85; text-align: left; overflow-wrap: break-word; }
.study-pane-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); }
.study-pane-heading { min-width: 0; }
.study-pane-eyebrow { margin: 0; font: 0.8125rem/1.5 var(--sans); color: var(--ink-soft); }
.study-pane-title { margin: 0.375rem 0 0; color: var(--ink); font: 600 0.9375rem/1.65 var(--sans); overflow-wrap: anywhere; }
.study-pane-close { flex: 0 0 auto; width: 2.75rem; height: 2.75rem; padding: 0; margin: -0.5rem -0.75rem 0 0; border: 0; border-radius: 0.375rem; font: 1.25rem/1 var(--sans); background: none; color: var(--ink-soft); cursor: pointer; }
.study-pane-close:hover { background: var(--surface); color: var(--ink); }
.study-pane-close:focus-visible, .study-collapse:focus-visible { outline: 2px solid var(--ink-soft); outline-offset: -3px; }
.study-pane-scroll { min-height: 0; overflow-y: auto; padding: 1rem; scrollbar-gutter: stable; }
.study-pane-scroll:focus { outline: none; }
.study-pane-verse { margin: 0 0 0.75rem; padding: 0 0 0.75rem; border-bottom: 1px solid var(--line); color: var(--ink); font: calc(1rem * var(--reading-scale, 1))/1.75 var(--serif); }
.study-pane-verse p { margin: 0; }
.study-collapse { display: none; min-height: 2.75rem; margin: 0 1rem 0.5rem auto; padding: 0.5rem 0; border: 0; background: none; color: var(--ink-soft); font: 0.8125rem/1.5 var(--sans); cursor: pointer; text-decoration: underline; text-underline-offset: 0.25em; }
.study-collapse:hover { color: var(--ink); }
.study-pane .library-synthesis { margin-top: 0; padding-top: 0; border-top: 0; }
.study-pane .library-evidence { font-size: 0.9286em; }
.study-pane .library-evidence blockquote { background: var(--surface); }

/* Desktop: like 普贤行愿品, the page becomes two columns only while a verse
   is open, and the column stays in view as the text scrolls. */
@media (min-width: 1100px) {
  html.study-active main { width: min(100%, calc(var(--content) + 30rem)); padding-inline: 1.5rem; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 28rem); column-gap: 1rem; align-items: start; }
  html.study-active main > * { grid-column: 1; min-width: 0; }
  html.study-active main > .study-pane { grid-column: 2; grid-row: 1 / span 2; position: sticky; top: 1rem; max-height: calc(100dvh - 2rem); overflow: hidden; }
}

/* Smaller screens: the study opens in place, right under its verse. */
.study-pane.is-inline { width: 0; min-width: calc(100% + var(--study-offset) + 0.75rem); margin: 0.5rem -0.75rem 0 calc(-1 * var(--study-offset)); background: var(--study-surface); }
.study-pane.is-inline .study-pane-head,
.study-pane.is-inline .study-pane-verse { display: none; }
.study-pane.is-inline .study-collapse { display: block; }

@media print {
  .study-pane { display: none; }
}
