/* Radflow — reference library: encyclopedia, cases, viewer, quiz, playlists, search */

/* ---------- Shared ---------- */
.section-pad { height: 96px; }
.eyebrow { font-size: 15px; font-weight: 500; color: var(--accent); }
.muted { color: var(--muted); }
.result-note { font-size: 16px; color: var(--muted); }
.result-note a { color: var(--accent); }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 15px; color: var(--muted); margin-bottom: 20px; }
.crumbs a { color: var(--slate); }
.crumbs a:hover { color: var(--accent); }
.crumbs a + a::before { content: "·"; margin-right: 8px; color: var(--muted); }
[data-copy] { position: relative; }
[data-copy].copied::after { content: "Copied"; position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); font-size: 13px; background: var(--ink); color: #fff; padding: 4px 10px; border-radius: 6px; white-space: nowrap; }
.link-btn { border: 0; background: none; color: var(--muted); font-size: 14px; cursor: pointer; text-decoration: underline; padding: 0; }
.chip small { font-size: 13px; color: var(--muted); margin-left: 2px; }
.chip.is-on small { color: rgba(255,255,255,.75); }
.note-bar { background: var(--accent-soft); color: var(--accent); border-radius: 10px; padding: 14px 18px; margin-bottom: 24px; font-size: 16px; }
mark { background: #fbe9a6; color: inherit; border-radius: 3px; padding: 0 2px; }

/* Library search box */
.lib-search { display: flex; align-items: center; gap: 12px; height: 66px; padding: 6px 6px 6px 22px; margin-top: 36px; max-width: 720px; background: var(--white); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 1px 2px rgba(4,22,38,.04), 0 12px 32px -18px rgba(4,22,38,.25); transition: border-color .2s, box-shadow .2s; }
.lib-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.lib-search > svg { color: var(--muted); flex: none; }
.lib-search input { flex: 1; min-width: 0; border: 0; outline: none; background: none; font-size: 18px; color: var(--ink); }
.lib-search input::placeholder { color: var(--muted); }
.lib-search .btn { height: 52px; }

/* ---------- Home ---------- */
.home-hero { grid-template-columns: minmax(0, 1fr) 380px; }
.hero-search { margin-top: 40px; }
.hero-stats { margin-top: 16px; font-size: 16px; color: var(--muted); }
.hero-links { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hero-links a { display: grid; gap: 4px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); transition: border-color .2s, transform .3s var(--ease), box-shadow .3s; }
.hero-links a:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 14px 30px -20px rgba(133,28,232,.6); }
.hl-ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 8px; }
.hero-links strong { font-size: 18px; font-weight: 500; }
.hero-links small { font-size: 14px; color: var(--muted); line-height: 1.35; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 28px; }

.cotd { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); border: 1px solid var(--line); border-radius: 0; overflow: hidden; background: var(--white); }
.cotd-img { background: #05080d; display: grid; place-items: center; min-height: 420px; }
.cotd-img img { width: 100%; height: 100%; max-height: 520px; object-fit: contain; transition: transform .8s var(--ease); }
.cotd-img:hover img { transform: scale(1.03); }
.cotd-body { padding: 48px; display: flex; flex-direction: column; justify-content: center; gap: 16px; }
.cotd-body h2 { font-size: 40px; line-height: 1.15; }
.cotd-body p { font-size: 19px; line-height: 1.5; color: var(--slate); }
.cotd .btn { border-radius: 0; }
.quiz-meta { font-size: 16px !important; color: var(--muted) !important; }

.sys-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.sys-tile { position: relative; display: grid; gap: 6px; padding: 22px 48px 22px 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); transition: border-color .2s, background .2s; }
.sys-tile strong { font-size: 19px; font-weight: 500; }
.sys-tile span { font-size: 15px; color: var(--muted); }
.sys-tile svg { position: absolute; right: 20px; top: 50%; transform: translateY(-50%); color: var(--muted); transition: transform .3s var(--ease), color .2s; }
.sys-tile:hover { border-color: var(--accent); background: #fdfaff; }
.sys-tile:hover svg { color: var(--accent); transform: translate(4px, -50%); }

/* ---------- Case cards ---------- */
.cases-grid.four { grid-template-columns: repeat(4, 1fr); }
.ccard { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.ccard-img { position: relative; border-radius: var(--r); overflow: hidden; aspect-ratio: 4 / 3.4; background: #05080d; }
.ccard-img img { width: 100%; height: 100%; object-fit: contain; transition: transform .9s var(--ease); }
.ccard:hover .ccard-img img { transform: scale(1.04); }
.ccard-count { position: absolute; left: 12px; bottom: 12px; display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px; border-radius: 7px; font-size: 14px; color: #fcfcfc; background: rgba(4,22,38,.5); backdrop-filter: blur(8px); }
.ccard-body { padding: 0 6px; display: flex; flex-direction: column; gap: 12px; }
.ccard h3 { font-family: var(--sans); font-size: 21px; line-height: 1.3; font-weight: 500; transition: color .2s; }
.ccard:hover h3 { color: var(--accent); }
.ccard p { font-size: 16px; line-height: 1.45; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.case-no { color: var(--accent); font-weight: 500; }

/* ---------- Encyclopedia ---------- */
.az { display: flex; flex-wrap: wrap; gap: 4px; padding: 28px 0 20px; }
.az a, .az span { min-width: 38px; height: 38px; padding: 0 10px; display: grid; place-items: center; border-radius: 9px; font-size: 16px; font-weight: 500; }
.az a { color: var(--ink); border: 1px solid var(--line); background: var(--white); transition: all .2s; }
.az a:hover { border-color: var(--accent); color: var(--accent); }
.az a.is-on { background: var(--ink); color: #fff; border-color: var(--ink); }
.az span { color: #c4ccd8; }
.az-group { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 24px; padding: 32px 0; border-top: 1px solid var(--line); }
.az-letter { font-size: 52px; line-height: 1; color: var(--accent); }
.entry-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.eitem { display: grid; gap: 8px; align-content: start; padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); transition: border-color .2s, box-shadow .3s; }
.eitem:hover { border-color: var(--accent); box-shadow: 0 14px 30px -24px rgba(133,28,232,.7); }
.eitem h3 { font-family: var(--sans); font-size: 21px; font-weight: 500; }
.eitem:hover h3 { color: var(--accent); }
.eitem p { font-size: 16px; line-height: 1.5; color: var(--slate); }
.syn { font-size: 15px !important; color: var(--muted) !important; font-style: italic; }
.sys-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.sys-tags span { font-size: 13px; padding: 3px 9px; border-radius: 6px; background: var(--soft); color: var(--slate); }

.entry-head { padding: 64px 0 56px; max-width: 900px; }
.entry-head h1 { font-size: 64px; line-height: 1.08; }
.synonyms { margin-top: 16px; font-size: 17px; color: var(--muted); }
.synonyms strong { color: var(--slate); font-weight: 500; }
.entry-head .lede { margin-top: 18px; font-size: 21px; line-height: 1.5; color: var(--slate); max-width: 760px; }
.prose h3 { margin-top: 28px; }
.aside-case { display: block; margin-top: 20px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #05080d; }
.aside-case img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; }
.aside-case span { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; background: var(--white); font-size: 15px; color: var(--slate); }
.entry-section { margin-top: 56px; padding-top: 40px; border-top: 1px solid var(--line); }
.entry-section > h2 { font-size: 32px; margin-bottom: 24px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.refs { margin: 0; padding-left: 22px; display: grid; gap: 12px; font-size: 16px; line-height: 1.55; color: var(--slate); }
.cite-box { margin-top: 40px; display: flex; gap: 20px; align-items: center; justify-content: space-between; padding: 24px; border-radius: 14px; background: var(--soft); }
.cite-box h3 { font-family: var(--sans); font-size: 18px; font-weight: 500; margin-bottom: 6px; }
.cite-box p { font-size: 15px; line-height: 1.5; color: var(--slate); }
.see-also { display: grid; gap: 10px; }
.see-also a { display: grid; gap: 4px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); transition: border-color .2s; }
.see-also a:hover { border-color: var(--accent); }
.see-also strong { font-weight: 500; font-size: 18px; }
.see-also a:hover strong { color: var(--accent); }
.see-also span { font-size: 15px; color: var(--muted); line-height: 1.45; }

/* ---------- Case list filters ---------- */
.case-filters { display: flex; gap: 10px; flex-wrap: wrap; padding: 32px 0 20px; }
.field { display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); color: var(--muted); }
.field.grow { flex: 1; min-width: 240px; }
.field input { flex: 1; min-width: 0; border: 0; outline: none; background: none; font-size: 16px; color: var(--ink); }
.field:focus-within { border-color: var(--accent); }
.case-filters .btn { height: 46px; }
.list-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 32px; flex-wrap: wrap; }

/* Toggle switch */
.switch { display: inline-flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 500; color: var(--slate); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { width: 44px; height: 26px; border-radius: 13px; background: #cbd5e1; position: relative; transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .25s var(--ease); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Quiz mode: hide answers */
.quiz-only { display: none; }
.quiz-on .quiz-only { display: revert; }
.quiz-on .quiz-cover.quiz-only { display: flex; }
.quiz-on .answer, .quiz-on .answer-soft { display: none !important; }
.quiz-on .ccard h3 { font-size: 0; }
.quiz-on .ccard h3::after { content: "Diagnosis hidden"; font-size: 21px; color: var(--muted); }
.quiz-on .ccard .ccard-img .tags { display: flex; }

/* ---------- Case page ---------- */
.pl-bar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 24px; padding: 10px 10px 10px 18px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); font-size: 16px; }
.pl-bar > a { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.pl-bar > div { margin-left: auto; display: flex; gap: 8px; }
.pl-bar .btn { height: 42px; }
.case-head { padding: 48px 0 28px; }
.case-title-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; }
.case-badge { display: inline-flex; height: 32px; align-items: center; padding: 0 12px; border-radius: 8px; background: var(--ink); color: #fff; font-size: 15px; font-weight: 500; margin-bottom: 14px; }
.case-head h1 { font-size: 52px; line-height: 1.1; }
.case-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 40px; align-items: start; }
.case-side { position: sticky; top: 88px; display: grid; gap: 16px; }
.pdata { padding: 24px; border: 1px solid var(--line); border-radius: 16px; background: var(--white); display: grid; gap: 14px; }
.pdata h3 { font-family: var(--sans); font-size: 15px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.pdata > p { font-size: 18px; line-height: 1.5; color: var(--ink); }
.pdata dl { display: grid; grid-template-columns: 110px 1fr; gap: 10px 12px; margin: 0; padding-top: 14px; border-top: 1px solid var(--line); font-size: 16px; }
.pdata dt { color: var(--muted); }
.pdata dd { margin: 0; color: var(--slate); }
.cert { display: inline-flex; align-items: center; gap: 6px; justify-self: start; height: 32px; padding: 0 12px; border-radius: 8px; font-size: 15px; font-weight: 500; }
.c-certain { background: #e7f8ec; color: #12753a; }
.c-almost { background: #e9f3ff; color: #1556b8; }
.c-probable { background: #fff4e0; color: #9a5b00; }
.c-na { background: var(--soft); color: var(--slate); }
.side-actions { display: grid; gap: 8px; }
.side-actions .btn { width: 100%; }
.case-text { margin-top: 48px; }
.case-text > h2 { font-size: 30px; margin-bottom: 16px; }
.case-text .prose { max-width: 760px; }
.quiz-cover { margin-top: 28px; padding: 28px; border: 1px dashed #c9a6f5; border-radius: 16px; background: #fdfaff; flex-direction: column; align-items: flex-start; gap: 16px; }
.quiz-cover p { font-size: 18px; color: var(--slate); }

/* ---------- Image viewer ---------- */
.viewer { border-radius: 18px; overflow: hidden; background: #05080d; color: #e2e8f0; outline: none; }
.viewer:focus-visible { box-shadow: 0 0 0 3px var(--accent); }
.vw-stage { position: relative; height: min(68vh, 640px); overflow: hidden; cursor: grab; touch-action: none; display: grid; place-items: center; }
.vw-stage.is-drag { cursor: grabbing; }
.vw-img { max-width: 100%; max-height: 100%; object-fit: contain; transform-origin: center; user-select: none; transition: filter .15s; will-change: transform; }
.vw-mod, .vw-idx { position: absolute; top: 14px; height: 30px; display: inline-flex; align-items: center; padding: 0 11px; border-radius: 8px; font-size: 14px; background: rgba(255,255,255,.1); backdrop-filter: blur(8px); pointer-events: none; }
.vw-mod { left: 14px; font-weight: 500; }
.vw-idx { right: 14px; }
.vw-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: #fff; display: grid; place-items: center; cursor: pointer; transition: background .2s; }
.vw-nav:hover { background: rgba(255,255,255,.25); }
.vw-nav.prev { left: 14px; }
.vw-nav.next { right: 14px; }
.vw-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border-top: 1px solid rgba(255,255,255,.08); }
.vw-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.vw-tools button { height: 38px; min-width: 38px; padding: 0 12px; border-radius: 9px; border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.06); color: #e2e8f0; font-size: 15px; cursor: pointer; display: inline-grid; place-items: center; transition: background .2s, border-color .2s; }
.vw-tools button:hover, .vw-tools button[aria-pressed="true"], .vw-tools button[aria-expanded="true"] { background: rgba(155,77,255,.35); border-color: rgba(155,77,255,.7); }
.vw-adjust { display: flex; gap: 20px; flex-wrap: wrap; font-size: 14px; color: #94a3b8; }
.vw-adjust label { display: flex; align-items: center; gap: 10px; }
.vw-adjust input { accent-color: var(--accent-2); width: 140px; }
.vw-thumbs { display: flex; gap: 8px; padding: 0 14px 12px; overflow-x: auto; }
.vw-thumbs button { position: relative; flex: none; width: 92px; height: 72px; padding: 0; border-radius: 9px; overflow: hidden; border: 2px solid transparent; background: #0d131c; cursor: pointer; opacity: .6; transition: opacity .2s, border-color .2s; }
.vw-thumbs button.is-on, .vw-thumbs button:hover { opacity: 1; border-color: var(--accent-2); }
.vw-thumbs img { width: 100%; height: 100%; object-fit: cover; }
.vw-thumbs span { position: absolute; left: 4px; bottom: 4px; font-size: 11px; padding: 1px 5px; border-radius: 4px; background: rgba(0,0,0,.6); color: #fff; }
.vw-caption { padding: 14px 16px 16px; border-top: 1px solid rgba(255,255,255,.08); display: grid; gap: 6px; }
.vw-caption p { font-size: 16px; line-height: 1.5; color: #e2e8f0; }
.vw-caption small { font-size: 13px; color: #94a3b8; }
.vw-caption a { text-decoration: underline; }
.viewer:fullscreen { border-radius: 0; display: flex; flex-direction: column; }
.viewer:fullscreen .vw-stage { height: auto; flex: 1; }

/* ---------- Quiz ---------- */
.quiz-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 32px; flex-wrap: wrap; padding-bottom: 40px; }
.score { display: flex; align-items: center; gap: 4px; padding: 8px; border: 1px solid var(--line); border-radius: 16px; background: var(--white); }
.score > div { display: grid; justify-items: center; padding: 8px 18px; border-right: 1px solid var(--line); }
.score strong { font-family: var(--display); font-size: 30px; letter-spacing: -.03em; }
.score small { font-size: 13px; color: var(--muted); }
.score .link-btn { padding: 0 12px; }
.quiz-filter { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.quiz { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 40px; align-items: start; }
.quiz-panel { display: grid; gap: 14px; align-content: start; }
.quiz-panel .case-badge { justify-self: start; margin: 0; }
.quiz-panel h2 { font-size: 26px; }
.quiz-hx { font-size: 20px; line-height: 1.5; color: var(--ink); }
.options { border: 0; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; }
.options legend { font-size: 17px; font-weight: 500; color: var(--slate); margin-bottom: 12px; padding: 0; }
.opt { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 58px; padding: 10px 16px; text-align: left; border: 1px solid var(--line); border-radius: 12px; background: var(--white); font-size: 18px; color: var(--ink); cursor: pointer; transition: border-color .2s, background .2s, transform .2s var(--ease); }
.opt span { flex: none; width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--soft); font-size: 15px; font-weight: 600; color: var(--slate); }
.opt:hover:not(:disabled) { border-color: var(--accent); transform: translateX(3px); }
.opt:disabled { cursor: default; }
.opt.is-right { border-color: #22a35a; background: #ecfaf1; }
.opt.is-right span { background: #22a35a; color: #fff; }
.opt.is-wrong { border-color: #e5484d; background: #fff0f0; }
.opt.is-wrong span { background: #e5484d; color: #fff; }
.quiz-result { display: grid; gap: 14px; padding: 22px; border-radius: 14px; background: var(--soft); }
.verdict { font-family: var(--display); font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.verdict.ok { color: #12753a; }
.verdict.no { color: #b42318; }
.quiz-explain { font-size: 16px; line-height: 1.55; color: var(--slate); }
.quiz-explain p + p { margin-top: 8px; }
.quiz-explain ul { margin: 6px 0; padding-left: 20px; }
.quiz-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.skip { font-size: 15px; color: var(--muted); text-decoration: underline; justify-self: start; }

/* ---------- Playlists ---------- */
.pl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; padding-top: 48px; }
.pl-card { display: grid; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: var(--white); transition: border-color .2s, transform .3s var(--ease), box-shadow .3s; }
.pl-card:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: 0 20px 40px -28px rgba(133,28,232,.7); }
.pl-stack { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; background: #05080d; aspect-ratio: 16 / 11; }
.pl-stack img { width: 100%; height: 100%; object-fit: cover; opacity: .9; }
.pl-body { padding: 20px 22px 24px; display: grid; gap: 10px; }
.pl-body h3 { font-family: var(--sans); font-size: 22px; font-weight: 500; }
.pl-card:hover h3 { color: var(--accent); }
.pl-body p { font-size: 16px; line-height: 1.5; color: var(--slate); }
.pl-list { list-style: none; margin: 0; padding: 40px 0 0; display: grid; gap: 10px; max-width: 980px; }
.pl-list a { display: grid; grid-template-columns: 44px 120px minmax(0, 1fr) 24px; gap: 20px; align-items: center; padding: 12px 18px 12px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); transition: border-color .2s; }
.pl-list a:hover { border-color: var(--accent); }
.pl-num { font-family: var(--display); font-size: 22px; font-weight: 600; color: var(--accent); text-align: center; }
.pl-list img { width: 120px; height: 84px; object-fit: cover; border-radius: 9px; background: #05080d; }
.pl-list a > div { display: grid; gap: 4px; }
.pl-list small { font-size: 14px; color: var(--muted); }
.pl-list strong { font-size: 19px; font-weight: 500; }
.pl-list a > div > span { font-size: 15px; color: var(--slate); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-list svg { color: var(--muted); }

/* ---------- Search ---------- */
.results { padding: 8px 0 40px; display: grid; gap: 12px; }
.results-h { font-family: var(--sans); font-size: 15px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.result { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 20px; padding: 20px 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); transition: border-color .2s; }
.result:hover { border-color: var(--accent); }
.result h3 { font-family: var(--sans); font-size: 21px; font-weight: 500; margin-bottom: 6px; }
.result:hover h3 { color: var(--accent); }
.result p { font-size: 16px; line-height: 1.5; color: var(--slate); }
.r-kind { align-self: start; justify-self: start; font-size: 13px; font-weight: 500; padding: 4px 10px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); }
.more-link { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 500; font-size: 16px; }
.suggest { align-items: center; margin-top: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .home-hero { grid-template-columns: 1fr; }
  .hero-links { grid-template-columns: repeat(4, 1fr); }
  .sys-grid, .cases-grid.four { grid-template-columns: repeat(3, 1fr); }
  .case-layout { grid-template-columns: 1fr; }
  .case-side { position: static; grid-template-columns: 1fr 1fr; }
  .quiz { grid-template-columns: 1fr; }
  .footer-top { grid-template-columns: 1fr 1fr 1fr; }
}
@media (max-width: 860px) {
  .lib-search { height: 58px; padding-left: 16px; }
  .lib-search input { font-size: 16px; }
  .lib-search .btn { height: 46px; padding: 0 16px; }
  .hero-links { grid-template-columns: 1fr 1fr; }
  .cotd { grid-template-columns: 1fr; }
  .cotd-img { min-height: 280px; }
  .cotd-body { padding: 28px 24px; }
  .cotd-body h2 { font-size: 30px; }
  .sys-grid { grid-template-columns: 1fr 1fr; }
  .cases-grid.four, .grid-2, .pl-grid { grid-template-columns: 1fr; }
  .az-group { grid-template-columns: 1fr; gap: 12px; }
  .az-letter { font-size: 40px; }
  .entry-list { grid-template-columns: 1fr; }
  .entry-head { padding: 40px 0 36px; }
  .entry-head h1, .case-head h1 { font-size: 38px; }
  .cite-box { flex-direction: column; align-items: flex-start; }
  .case-side { grid-template-columns: 1fr; }
  .vw-stage { height: 56vh; }
  .vw-adjust input { width: 110px; }
  .quiz-head { align-items: flex-start; }
  .score > div { padding: 6px 12px; }
  .score strong { font-size: 24px; }
  .result { grid-template-columns: 1fr; gap: 10px; }
  .pl-list a { grid-template-columns: 36px 84px minmax(0, 1fr); gap: 12px; }
  .pl-list img { width: 84px; height: 64px; }
  .pl-list a > svg { display: none; }
  .pl-bar > div { margin-left: 0; width: 100%; }
  .footer-top { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .sys-grid { grid-template-columns: 1fr; }
  .lib-search .btn { display: none; }
}
.quiz:not(.is-answered) [data-caption] { display: none; }

/* ---------- Folder cards for the library (playlists, body systems) ---------- */
.folders.four { grid-template-columns: repeat(4, 1fr); }
.folder-scan .folder-papers img { background: #0b1220; object-fit: cover; }
.pl-folder { display: flex; flex-direction: column; gap: 6px; }
.pl-folder p { color: var(--muted); font-size: 16px; line-height: 1.5; padding-left: 4px; }
@media (max-width: 1100px) { .folders.four { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 860px) { .folders.four, .pl-folders { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .folders.four, .pl-folders { grid-template-columns: 1fr; } }

/* Hero: clinician cut-out photo */
.home-hero { grid-template-columns: minmax(0, 1fr) 420px; align-items: end; }
.home-hero { padding-bottom: 0; }
.home-hero > :first-child { padding-bottom: 72px; }
.hero-person { margin: 0; align-self: end; display: flex; justify-content: center; }
.hero-person img { width: 100%; max-width: 420px; height: auto; display: block; }
@media (max-width: 1100px) { .home-hero { grid-template-columns: 1fr; } .hero-person { max-width: 360px; margin: 0 auto; } .home-hero > :first-child { padding-bottom: 32px; } }

/* ---------- Home hero: flip-book casebook ---------- */
.fb-hero { --fb-ease: cubic-bezier(.645, .045, .355, 1); --bw: min(760px, 66vw, max(520px, calc((100vh - 340px) * 1.46))); position: relative; overflow: hidden; padding: 44px 0 36px; color: #f4f1ff;
  background: radial-gradient(120% 80% at 50% 0%, #2b2245 0%, #17122a 45%, #0e0b19 100%); }
.fb-hero::before { content: ""; position: absolute; inset: 0; background: radial-gradient(40% 35% at 50% 55%, rgba(133, 28, 232, .22), transparent 70%); pointer-events: none; }
.fb-head { position: relative; text-align: center; padding: 0 16px; }
.fb-h1 { font-family: var(--display); font-weight: 600; font-size: 46px; line-height: 1.08; letter-spacing: -.04em; color: #fff; }
.fb-meta { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 15px; color: rgba(244, 241, 255, .62); }
.fb-head > * { opacity: 0; transform: translateY(14px); animation: fbRise .9s var(--fb-ease) forwards; }
.fb-head .fb-meta { animation-delay: .12s; }
@keyframes fbRise { to { opacity: 1; transform: none; } }

.fb-stage { position: relative; display: flex; justify-content: center; margin-top: 30px; }
.fb-wrap { width: var(--bw); container-type: inline-size; opacity: 0; transform: translateY(40px) scale(.94); animation: fbRise 1.1s .15s var(--fb-ease) forwards; }
.fb-scene { perspective: 2600px; perspective-origin: 50% 30%; }
.fb-book { position: relative; width: 100%; aspect-ratio: 1.46; transform-style: preserve-3d; transition: transform 1.1s var(--fb-ease); outline: none; }
.fb-book.is-closed { transform: translateX(-25%); }
.fb-book::after { content: ""; position: absolute; left: 4%; right: 4%; bottom: -5%; height: 10%; border-radius: 50%; background: rgba(0, 0, 0, .55); filter: blur(22px); transform: translateZ(-200px); pointer-events: none; }
.fb-book.is-closed::after { left: 52%; }

.fb-sheet { position: absolute; top: 0; left: 50%; width: 50%; height: 100%; transform-origin: left center; transform-style: preserve-3d;
  transition: transform 1.15s var(--fb-ease), opacity .4s; cursor: pointer; }
.fb-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; border-radius: 0 1.1cqw 1.1cqw 0;
  background: #f4efe3; box-shadow: inset 0 0 0 1px rgba(80, 60, 30, .08); }
.fb-back { transform: rotateY(180deg); border-radius: 1.1cqw 0 0 1.1cqw; }
.fb-front::before, .fb-back::before { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.fb-front::before { background: linear-gradient(90deg, rgba(60, 40, 10, .16), rgba(60, 40, 10, .04) 6%, transparent 14%); }
.fb-back::before { background: linear-gradient(270deg, rgba(60, 40, 10, .16), rgba(60, 40, 10, .04) 6%, transparent 14%); }
.fb-face::after { content: ""; position: absolute; inset: 0; z-index: 4; pointer-events: none; background: linear-gradient(90deg, rgba(0,0,0,.28), rgba(0,0,0,0) 70%); opacity: 0; }
.fb-sheet.is-turning .fb-face::after { animation: fbShade 1.15s var(--fb-ease); }
@keyframes fbShade { 50% { opacity: 1; } }

.fb-page { position: absolute; inset: 0; padding: 5.2cqw 4.2cqw 3.4cqw; display: flex; flex-direction: column; color: #2d2a3e; }
.fb-lined { background: repeating-linear-gradient(180deg, transparent 0 calc(2.6cqw - 1px), rgba(70, 95, 140, .14) calc(2.6cqw - 1px) 2.6cqw) 0 1.4cqw / 100% auto, #f4efe3; }
.fb-dots { background: radial-gradient(circle, rgba(70, 60, 40, .16) .14cqw, transparent .2cqw) 0 0 / 1.6cqw 1.6cqw, #efe9db; }
.fb-photo { position: relative; margin: 0 auto; width: 88%; padding: 1cqw 1cqw 1cqw; background: #fff; box-shadow: 0 .6cqw 1.6cqw -.6cqw rgba(30, 20, 10, .45); }
.fb-photo img { display: block; width: 100%; aspect-ratio: 4 / 3.2; object-fit: cover; background: #0b1220; }
.fb-photo.tilt-l { transform: rotate(-2deg); } .fb-photo.tilt-r { transform: rotate(1.8deg); }
.fb-photo-person img { object-fit: contain; object-position: center bottom; background: linear-gradient(180deg, #e9ddfb, #f3e8fe); }
.fb-tape { position: absolute; top: -1.3cqw; left: 50%; width: 9cqw; height: 2.6cqw; transform: translateX(-50%) rotate(-3deg); background: rgba(232, 220, 190, .78); box-shadow: 0 1px 2px rgba(0,0,0,.08); z-index: 2; }
.fb-title { font-family: "Caveat", "Segoe Print", cursive; font-weight: 700; font-size: 3.5cqw; line-height: 1.05; margin-top: 2.6cqw; color: #22202f; }
.fb-note { font-family: "Caveat", "Segoe Print", cursive; font-weight: 500; font-size: 2.2cqw; line-height: 1.18; margin-top: .6cqw; color: #4a4560; }
.fb-tag { margin-top: auto; align-self: flex-end; font-size: 1.05cqw; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: #b64bf0; }
a.fb-tag:hover { color: #851ce8; text-decoration: underline; }
.fb-end { justify-content: flex-start; padding-top: 7cqw; }
.fb-end .fb-title { font-size: 4.6cqw; margin-top: 0; }
.fb-links { display: grid; gap: 1.2cqw; margin-top: 3cqw; }
.fb-links a { display: flex; align-items: center; gap: 1cqw; padding: 1.3cqw 1.6cqw; border-radius: 1cqw; background: #fff; border: 1px solid rgba(80, 60, 30, .12); font-size: 1.55cqw; font-weight: 500; color: #2d2a3e; transition: border-color .2s, color .2s, transform .25s; }
.fb-links a svg { width: 1.8cqw; height: 1.8cqw; color: #851ce8; flex: none; }
.fb-links a:hover { border-color: #851ce8; color: #851ce8; transform: translateX(.4cqw); }

.fb-cover { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6cqw; text-align: center; border-radius: inherit;
  background: radial-gradient(120% 90% at 30% 20%, #6d2fd0 0%, #3d1880 50%, #22104a 100%); color: #fff; box-shadow: inset 0 0 0 .5cqw rgba(255,255,255,.06), inset .9cqw 0 1.4cqw -1cqw rgba(0,0,0,.6); }
.fb-cover-mark { width: 7cqw; height: 7cqw; border-radius: 50%; display: grid; place-items: center; border: 2px solid rgba(255,255,255,.55); font-family: var(--display); font-weight: 600; font-size: 3.4cqw; margin-bottom: 1.6cqw; }
.fb-cover strong { font-family: var(--display); font-weight: 600; font-size: 5.8cqw; line-height: 1; letter-spacing: -.045em; }
.fb-cover em { font-family: "Caveat", cursive; font-style: normal; font-size: 3.6cqw; color: #e7d4ff; }
.fb-cover small { margin-top: 2cqw; font-size: 1.15cqw; letter-spacing: .2em; text-transform: uppercase; color: rgba(255,255,255,.6); }

.fb-nav { position: relative; display: flex; align-items: center; justify-content: center; gap: 6px; width: max-content; margin: 28px auto 0; padding: 5px; border-radius: 999px;
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .12); backdrop-filter: blur(10px); opacity: 0; animation: fbRise .8s .6s var(--fb-ease) forwards; }
.fb-nav button { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(255, 255, 255, .08); transition: background .2s, opacity .2s; }
.fb-nav button:hover:not(:disabled) { background: rgba(255, 255, 255, .2); }
.fb-nav button:disabled { opacity: .35; cursor: default; }
.fb-nav span { min-width: 74px; text-align: center; font-size: 14px; font-variant-numeric: tabular-nums; color: rgba(255, 255, 255, .85); }

@media (max-width: 760px) {
  .fb-hero { --pw: min(86vw, 360px); --bw: calc(var(--pw) * 2); padding: 40px 0 32px; }
  .fb-h1 { font-size: 34px; }
  .fb-meta { font-size: 13px; }
  .fb-stage { margin-top: 26px; }
  .fb-wrap { flex: none; translate: -25% 0; }
  .fb-book.is-closed { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .fb-sheet, .fb-book { transition-duration: .01s; }
  .fb-head > *, .fb-wrap, .fb-nav { animation: none; opacity: 1; transform: none; }
}
@media (max-width: 760px) {
  .fb-wrap { transition: translate .9s var(--fb-ease); }
  .fb-hero.fb-show-left .fb-wrap { translate: 25% 0; }
}

/* ---------- Square corners everywhere (design decision) ---------- */
*, *::before, *::after { border-radius: 0 !important; }
/* Soft blurred glows keep their round falloff. */
.fb-book::after, .panel-right::after { border-radius: 50% !important; }
