/* Extra styles for the book pages (book/src/bNN.html); common.css comes first. */
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 640px) { .two { grid-template-columns: minmax(0, 1fr); } }
canvas.chart { width: 100%; height: 210px; display: block; }
canvas.wide { width: 100%; height: 260px; display: block; }
canvas.sq { width: 100%; max-width: 440px; aspect-ratio: 1 / 1; height: auto; display: block; margin: 0 auto; border-radius: 6px; touch-action: none; }
.cap { font-size: 12px; color: var(--muted); margin-top: 3px; text-align: center; font-family: var(--f-mono); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.legend i { display: inline-block; width: 14px; height: 3px; margin-right: 6px; vertical-align: 3px; border-radius: 2px; }
.src { font-size: 12.5px; color: var(--muted); }
table.plain td, table.plain th { padding: 6px 10px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; font-size: 14px; }
table.plain th { color: var(--muted); font-weight: 600; }
.controls { grid-template-columns: minmax(0, 1fr); }
.controls select, .bench select { width: 100%; max-width: 100%; min-width: 0; }
pre.algo { font-family: var(--f-mono); font-size: 13px; line-height: 1.6; background: var(--paper); border-radius: 8px; padding: 10px 14px; overflow-x: auto; margin: 10px 0; white-space: pre-wrap; }

/* where the passage sits in the book */
.bref { font-family: var(--f-mono); font-size: 11.5px; letter-spacing: .04em; color: var(--muted); border: 1px solid var(--rule); border-radius: 4px; padding: 0 6px; margin-left: 8px; vertical-align: 3px; white-space: nowrap; font-weight: 400; }

/* the book's own "Message" boxes and lemmas */
.msg { background: var(--accent-soft); border-radius: 10px; padding: 12px 18px; margin: 16px 0; }
.msg .k { font-family: var(--f-mono); font-size: 11.5px; letter-spacing: .1em; color: var(--accent); display: block; margin-bottom: 2px; }

/* additions that are not in the book */
details.bg > summary::before { content: "轉述者補充"; }
details.pf { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; margin: 14px 0; padding: 0 18px; }
details.pf > summary { cursor: pointer; padding: 11px 0; font-weight: 600; color: var(--accent); list-style: none; display: flex; gap: 10px; align-items: baseline; }
details.pf > summary::-webkit-details-marker { display: none; }
details.pf > summary::before { content: "推導"; font-family: var(--f-mono); font-size: 11px; letter-spacing: .08em; border: 1px solid var(--accent); border-radius: 4px; padding: 0 6px; flex: none; }
details.pf[open] > summary { border-bottom: 1px solid var(--rule); margin-bottom: 12px; }
details.pf > div { padding-bottom: 8px; }

/* figures from the book (tap to enlarge) and redrawn diagrams */
figure.bookfig { margin: 18px 0; }
figure.bookfig img { display: block; width: 100%; max-width: 100%; height: auto; background: #fff; border: 1px solid var(--rule); border-radius: 8px; cursor: zoom-in; }
figure.bookfig figcaption, figure.diag figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.6; }
figure.diag { margin: 18px 0; }
figure.diag .diagwrap > svg { display: block; width: 100%; height: auto; }
.diagwrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: 10px; background: var(--surface); padding: 10px; }

/* page navigation inside the series */
.booknav { font-size: 13.5px; color: var(--muted); margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.prevnext { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-top: 28px; }
.prevnext a, .prevnext span { display: block; border: 1px solid var(--rule); border-radius: 10px; padding: 10px 14px; text-decoration: none; color: var(--ink); background: var(--surface); min-width: 0; }
.prevnext small { display: block; color: var(--muted); font-family: var(--f-mono); font-size: 11px; letter-spacing: .08em; }
.prevnext .next { text-align: right; }
.prevnext span { color: var(--muted); }

/* table of contents on the index page */
ol.pages { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 2px; }
ol.pages li { display: grid; grid-template-columns: 3.2em minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--rule); }
ol.pages .num { font-family: var(--f-mono); color: var(--muted); font-size: 13px; }
ol.pages small { display: block; color: var(--muted); font-size: 13px; }
ol.pages .st { font-size: 12px; font-family: var(--f-mono); color: var(--muted); white-space: nowrap; }
ol.pages .st.done { color: var(--ok); }
h3.part { font-size: 15px; margin: 22px 0 4px; color: var(--accent); }

/* full-screen figure viewer */
dialog.figbox { width: min(100vw, 1200px); max-width: 100vw; max-height: 100dvh; margin: auto; padding: 0; border: 1px solid var(--rule); border-radius: 10px; background: var(--surface); color: var(--ink); box-sizing: border-box; }
dialog.figbox::backdrop { background: rgba(0, 0, 0, 0.72); }
.figbox .fb-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 12px; font-size: 13px; color: var(--muted); }
.figbox button { font: inherit; font-size: 14px; color: var(--ink); background: var(--paper); border: 1px solid var(--rule); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.figbox .fb-view { overflow: auto; max-height: calc(100dvh - 60px); touch-action: pan-x pan-y pinch-zoom; background: #fff; }
.figbox .fb-view img { display: block; width: 100%; height: auto; cursor: zoom-in; }
.figbox .fb-view.zoom img { width: 200%; max-width: none; cursor: zoom-out; }
.progress { height: 4px; background: var(--rule); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); }
