/* The library pages beside the books: search (/search/), reading paths
   (/start/) and the concept index (/concept-index/), on the reader's tokens
   (reader.css). One column, phone first: Mobile Safari is the main reader. */
.library { background: var(--surface); color: var(--ink); margin: 0; }
.library-nav { max-width: 760px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 4px 12px; flex-wrap: wrap; }
.library-nav .home-brand { margin-right: auto; display: inline-flex; align-items: center; gap: 10px; min-height: var(--tap); text-decoration: none; color: var(--ink); font-weight: 600; font-size: 18px; }
.library-nav nav { display: flex; gap: 2px; margin: 0 -10px; }
.library-nav nav a { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 10px; border-radius: var(--r-2); color: var(--ink-2); text-decoration: none; font-size: var(--fs-sm); }
.library-nav nav a[aria-current="page"] { color: var(--accent-ink); font-weight: 600; }
@media (hover: hover) { .library-nav nav a:hover { color: var(--accent-hover); background: var(--surface-2); } }
.library-main { max-width: 760px; margin: 0 auto; padding: 8px 16px 64px; background: none; border: 0; }
.library-main h1 { font-size: clamp(28px, 6vw, 40px); line-height: 1.12; letter-spacing: -.015em; font-weight: 400; margin: 4px 0 12px; }
.library-main h2 { font-size: var(--fs-xl, 22px); font-weight: 400; margin: 32px 0 12px; }
.library-lead { color: var(--ink-2); font-size: 17px; line-height: 1.6; margin: 0 0 20px; }
.library-note { font-size: var(--fs-sm); line-height: 1.55; color: var(--ink-2); }
.library-note strong { color: var(--ink); font-weight: 600; }
.library [hidden] { display: none !important; }

/* Search */
.search-form { display: flex; gap: 8px; margin: 0 0 12px; }
.search-form input { flex: 1; min-width: 0; min-height: 48px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--surface); color: var(--ink); font: 17px/1.2 var(--font); -webkit-appearance: none; appearance: none; }
.search-form input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.search-form button { min-height: 48px; padding: 0 16px; }
.search-status { min-height: 1.5em; margin: 0 0 10px; font-size: var(--fs-sm); color: var(--ink-2); }
.search-books { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 14px; padding: 2px 16px 6px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.search-books::-webkit-scrollbar { display: none; }
.search-books button { flex: none; min-height: 36px; padding: 0 12px; border-radius: 999px; font-size: var(--fs-sm); white-space: nowrap; }
.search-books button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.search-books button small { margin-left: 6px; opacity: .75; }
.search-results { list-style: none; margin: 0; padding: 0; }
.search-result { position: relative; padding: 14px 0; border-top: 1px solid var(--line); }
.search-result:first-child { border-top: 0; }
.result-book { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; font-size: var(--fs-xs); color: var(--ink-2); }
.result-book img { flex: none; border-radius: 6px; }
.result-book span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-section { display: block; margin: 0 0 4px; font-size: var(--fs-ui, 16px); font-weight: 600; color: var(--ink); text-decoration: none; line-height: 1.35; }
/* The whole result opens the passage; the example link sits above it. */
.result-section::after { content: ""; position: absolute; inset: 0; }
.result-text { margin: 0; font-size: 16px; line-height: 1.55; color: var(--ink); overflow-wrap: anywhere; }
.result-text mark, .concept-passage mark { background: var(--accent-soft); color: inherit; border-radius: 2px; padding: 0 1px; }
.result-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 8px; font-size: var(--fs-sm); }
.result-kind { color: var(--ink-2); font-size: var(--fs-xs); letter-spacing: .04em; text-transform: uppercase; }
.result-play { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); text-decoration: none; font-weight: 600; }
@media (hover: hover) { .search-result:hover .result-section { color: var(--accent-hover); } .result-play:hover { background: var(--accent); color: var(--on-accent); } }
.search-more { display: block; width: 100%; margin-top: 16px; min-height: 48px; }
.search-concept { display: flex; align-items: center; gap: 12px; margin: 0 0 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface); color: var(--ink); text-decoration: none; }
.search-concept b { display: block; font-weight: 600; }
.search-concept small { display: block; color: var(--ink-2); font-size: var(--fs-sm); line-height: 1.45; }
.search-concept i { margin-left: auto; color: var(--accent-ink); font-style: normal; }
.search-tips { margin-top: 24px; }
.search-tips a { margin-right: 10px; }

/* Reading paths */
.path { margin: 24px 0 0; padding: 18px 16px; border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface); }
.path-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.path h2 { margin: 0; font-size: 24px; }
.path-level { font-size: var(--fs-xs); letter-spacing: .14em; text-transform: uppercase; font-weight: 600; color: var(--accent-ink); }
.path-blurb { color: var(--ink-2); line-height: 1.6; margin: 8px 0 12px; }
.path-progress { display: flex; align-items: center; gap: 10px; font-size: var(--fs-sm); color: var(--ink-2); margin: 0 0 12px; }
.path-progress progress { flex: 1; height: 6px; -webkit-appearance: none; appearance: none; border: 0; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.path-progress progress::-webkit-progress-bar { background: var(--surface-2); border-radius: 999px; }
.path-progress progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
.path-progress progress::-moz-progress-bar { background: var(--accent); }
.path-continue { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; margin: 0 0 8px; border-radius: var(--r-2); background: var(--accent); color: var(--on-accent); text-decoration: none; font-weight: 600; }
@media (hover: hover) { .path-continue:hover { background: var(--accent-hover); color: var(--on-accent); } }
.path-steps { list-style: none; margin: 8px 0 0; padding: 0; counter-reset: step; }
.path-step { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 4px 10px; align-items: start; padding: 12px 0; border-top: 1px solid var(--line); counter-increment: step; }
.path-step::before { content: counter(step); display: grid; place-items: center; width: 28px; height: 28px; margin-top: 2px; border-radius: 50%; border: 1.5px solid var(--line-2); font-size: var(--fs-sm); color: var(--ink-2); }
.path-step[data-state="started"]::before { border-color: var(--accent); color: var(--accent-ink); }
.path-step[data-state="done"]::before { content: "✓"; background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.path-step a.step-title { font-weight: 600; text-decoration: none; color: var(--ink); line-height: 1.35; }
@media (hover: hover) { .path-step a.step-title:hover { color: var(--accent-hover); } }
.step-book { display: block; font-size: var(--fs-xs); color: var(--ink-2); margin-top: 2px; }
.step-note { margin: 4px 0 0; font-size: var(--fs-sm); line-height: 1.5; color: var(--ink-2); }
.step-state { font-size: var(--fs-xs); color: var(--accent-ink); }
.step-done { min-height: 36px; min-width: 0; padding: 0 10px; font-size: var(--fs-xs); white-space: nowrap; }
.step-done[aria-pressed="true"] { border-color: var(--accent); color: var(--accent-ink); }
.path-reset { margin-top: 10px; font-size: var(--fs-sm); }

/* Concept index */
.concept-groups { display: grid; gap: 4px 24px; }
@media (min-width: 640px) { .concept-groups { grid-template-columns: 1fr 1fr; } }
.concept-group h2 { font-size: 15px; letter-spacing: .14em; text-transform: uppercase; font-weight: 600; color: var(--accent-ink); margin: 24px 0 6px; }
.concept-group ul { list-style: none; margin: 0; padding: 0; }
.concept-group li a { display: flex; justify-content: space-between; gap: 12px; min-height: var(--tap); align-items: center; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.concept-group li small { color: var(--ink-2); font-size: var(--fs-xs); white-space: nowrap; }
@media (hover: hover) { .concept-group li a:hover { color: var(--accent-hover); } }
.concept-book { margin: 28px 0 0; padding-top: 16px; border-top: 1px solid var(--line); }
.concept-book > h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; font-size: 20px; }
.concept-book > h2 img { border-radius: 8px; flex: none; }
.concept-book > h2 small { display: block; font-size: var(--fs-sm); color: var(--ink-2); }
.concept-start { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; margin: 0 0 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); text-decoration: none; font-weight: 600; font-size: var(--fs-sm); }
.concept-sections { margin: 0 0 8px; padding-left: 20px; line-height: 1.5; }
.concept-sections li { margin: 4px 0; }
.concept-sections small { color: var(--ink-2); }
.concept-passages { list-style: none; margin: 8px 0 0; padding: 0; }
.concept-passage { position: relative; margin: 0; padding: 10px 0; border-top: 1px dashed var(--line); }
.concept-passage p { margin: 0; line-height: 1.55; overflow-wrap: anywhere; }
.concept-passage .passage-where { display: block; margin-bottom: 2px; font-size: var(--fs-xs); color: var(--ink-2); }
.concept-more { font-size: var(--fs-sm); margin: 8px 0 0; }
.concept-examples { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 12px 0 0; padding: 0; list-style: none; }
.concept-examples a { display: block; height: 100%; padding: 8px; border: 1px solid var(--line); border-radius: var(--r-2); background: var(--surface); color: var(--ink); text-decoration: none; font-size: var(--fs-xs); line-height: 1.4; }
.concept-examples img { display: block; width: 100%; height: 72px; object-fit: contain; object-position: left center; margin-bottom: 6px; background: var(--scan); border-radius: 4px; }
:root[data-theme=dark] .concept-examples img { filter: invert(.88) hue-rotate(180deg); }
.concept-examples b { color: var(--accent-ink); font-weight: 600; }
/* Review mode (?review): mark a tag wrong, copy the corrections. */
.review-bar { position: sticky; bottom: 0; margin: 24px -16px 0; padding: 12px 16px; background: var(--surface); border-top: 1px solid var(--line); box-shadow: var(--shadow-2); }
.review-bar textarea { width: 100%; min-height: 90px; font: 12px/1.4 ui-monospace, monospace; }
.review-toggle { position: relative; z-index: 1; min-height: 32px; padding: 0 10px; font-size: var(--fs-xs); margin-top: 6px; }
.review-toggle[aria-pressed="true"] { border-color: #b3261e; color: #b3261e; }
[data-rejected] p { text-decoration: line-through; opacity: .55; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
