/* Static light reflections over a tinted canvas keep the reference shelves
   inexpensive to scroll. Legal text sits on a higher-opacity reading surface. */
.ref-library,.reader-layout {
  --ref-surface:linear-gradient(130deg,rgba(255,255,255,.92),rgba(245,248,255,.73));
  --ref-edge:#ffffffdf; --ref-accent:#4e5693;
  --ref-wash:linear-gradient(125deg,#e0e9f9 0%,#eeeafa 55%,#f5f0eb 100%);
  --ref-stroke:rgba(97,110,157,.18); color:var(--g-ink);
}
.dark :is(.ref-library,.reader-layout) {
  --ref-surface:linear-gradient(135deg,rgba(49,54,78,.94),rgba(35,40,60,.88));
  --ref-edge:#c7d4ff2e; --ref-accent:#c4c9fc;
  --ref-wash:linear-gradient(120deg,#202b41,#302e49 58%,#383243); --ref-stroke:#b5c2ef26;
}
.ref-library [hidden],.reader-layout [hidden] { display:none!important; }
.ref-library { min-height:100%; padding:clamp(12px,2.2vw,32px); background:var(--ref-wash); }
.ref-hero,.act-shelf,.section-card { background:var(--ref-surface); border:1px solid var(--ref-stroke); box-shadow:inset 0 1px 0 var(--ref-edge),0 3px 9px #28386307; border-radius:16px; }
.ref-hero { padding:clamp(16px,2.4vw,36px); }
.ref-heading { display:flex; align-items:center; gap:clamp(10px,1.5vw,20px); }
.ref-emblem,.act-emblem { display:grid; place-items:center; flex:none; color:var(--ref-accent); border:1px solid var(--ref-stroke); border-radius:11px; background:linear-gradient(150deg,#b9d2fa55,#c5b6ea38); box-shadow:inset 0 1px var(--ref-edge); }
.ref-emblem { width:clamp(38px,4vw,56px); aspect-ratio:1; } .ref-emblem svg { width:55%; height:55%; }
.ref-hero h1 { margin:0; font-weight:650; font-size:clamp(1.45rem,1.12rem + 1.55vw,2.8rem); letter-spacing:-.045em; line-height:1.13; }
.ref-hero p { margin:5px 0 0; color:var(--g-muted); font-size:clamp(.8rem,.72rem + .24vw,.98rem); }
.ref-filters { display:flex; gap:10px; margin-top:clamp(12px,1.6vw,24px); }
.ref-search,.ref-filters select { border-radius:12px; border:1px solid var(--ref-stroke); background-color:var(--g-soft); }
.ref-search { display:flex; align-items:center; gap:9px; padding:0 12px; min-width:0; color:var(--g-muted); }
.ref-search .glass-icon { width:17px; }
.ref-filters .ref-search { flex:1; }
.ref-search input[type=search],.ref-search input[type=search]:focus { min-width:0; width:100%; padding:10px 0; border:0; background:transparent; outline:none; box-shadow:none; color:var(--g-ink); font-size:clamp(.86rem,.81rem + .19vw,1rem); }
.ref-search:focus-within,.ref-filters select:focus-visible { outline:2px solid var(--g-focus); outline-offset:1px; }
.ref-filters select { max-width:47%; color:var(--g-ink); font-size:.85rem; }
.cat-group { margin-top:clamp(15px,2vw,28px); }
.cat-group h2,.chapter-heading { display:flex; gap:8px; align-items:baseline; color:var(--g-ink); margin:0 0 9px; font-size:clamp(.95rem,.85rem + .38vw,1.25rem); line-height:1.35; font-weight:620; letter-spacing:-.018em; }
.category-count { font-size:.77em; color:var(--g-muted); font-weight:450; }
.act-shelf { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,260px),1fr)); overflow:hidden; padding:3px; gap:3px; }
.act-card { display:flex; align-items:center; gap:11px; padding:12px; border-radius:12px; min-width:0; color:var(--g-ink); }
.act-emblem { width:34px; height:38px; border-radius:8px; } .act-emblem svg { width:17px; }
.act-card > .glass-icon { width:14px; margin-left:auto; color:var(--g-quiet); }
.act-card:hover:is(a),.idx-link:hover,.section-card button:hover { background:var(--g-soft); }
.act-summary { min-width:0; } .act-summary h3 { margin:0; font-weight:580; font-size:clamp(.88rem,.81rem + .26vw,1.05rem); line-height:1.36; }
.act-summary p,.ref-empty { margin:2px 0 0; color:var(--g-muted); font-size:clamp(.75rem,.71rem + .14vw,.87rem); }
.ref-empty { padding:20px 0; }
.unavailable .act-emblem { background:var(--g-soft); color:var(--g-quiet); }
.reader-layout { display:flex; height:100%; min-height:0; overflow:hidden; background:var(--ref-wash); }
.reader-index { display:flex; flex-direction:column; flex:none; width:clamp(206px,19vw,305px); padding:14px 10px; background:var(--ref-surface); border-inline-end:1px solid var(--ref-stroke); }
.reader-index header { display:flex; align-items:center; justify-content:space-between; padding:0 7px 10px; }
.reader-index h2 { font-size:clamp(.94rem,.84rem + .36vw,1.15rem); font-weight:640; }
.reader-index .ref-search { margin:0 4px 10px; }
#idx-nav { overflow:auto; min-height:0; overscroll-behavior:contain; }
.idx-chapter h3 { color:var(--g-muted); margin:14px 6px 4px; font-size:.78rem; font-weight:600; }
.idx-link { display:flex; align-items:baseline; gap:8px; padding:7px 9px; border-radius:8px; color:var(--g-muted); font-size:clamp(.78rem,.73rem + .16vw,.91rem); line-height:1.4; }
.idx-link span:first-child { font-variant-numeric:tabular-nums; color:var(--ref-accent); min-width:2.2em; }
.idx-link span:last-child { text-overflow:ellipsis; overflow:hidden; white-space:nowrap; }
.idx-link[aria-current] { color:var(--g-ink); background:var(--g-soft); box-shadow:inset 2px 0 var(--ref-accent); }
.act-reading { flex:1; min-width:0; overflow:auto; padding:clamp(12px,2vw,30px); }
.reader-hero h1 { margin-top:10px; }
.library-back { color:var(--ref-accent); font-size:.82rem; font-weight:550; }
.reader-hero .ref-search { margin-top:15px; }
.chapter-heading { margin-top:20px; }
.section-card { margin-top:12px; padding:clamp(16px,2vw,32px); scroll-margin-top:12px; content-visibility:auto; contain-intrinsic-size:auto 240px; }
.section-number { color:var(--ref-accent); font-weight:600; font-size:clamp(.75rem,.7rem + .18vw,.88rem); margin:0 0 4px; }
.section-title { font-size:clamp(1.04rem,.9rem + .58vw,1.55rem); line-height:1.26; letter-spacing:-.02em; font-weight:620; }
.section-desc { max-width:78ch; margin-top:12px; font:normal clamp(1rem,.93rem + .3vw,1.22rem)/1.72 Georgia,"Times New Roman",serif; white-space:pre-wrap; overflow-wrap:anywhere; }
.section-card footer { display:flex; align-items:center; gap:10px; border-top:1px solid var(--g-line); padding-top:6px; margin-top:16px; }
.section-card button,.section-card footer span { font-size:.8rem; color:var(--g-muted); } .section-card button { padding:6px; border-radius:6px; }
.section-card mark { background:#fde6a3; color:#29200f; border-radius:3px; }
#index-close,.index-toggle { display:none; }
@media (max-width:959px) {
  .index-toggle,#index-close { display:inline-flex; align-items:center; justify-content:center; gap:5px; color:var(--g-ink); min-height:38px; }
  .index-toggle { padding:0 9px; background:var(--g-soft); border:1px solid var(--g-line); border-radius:10px; font-size:.82rem; }
  #index-close { min-width:38px; }
  .reader-index { display:none; } .reader-index.open { display:flex; position:fixed; z-index:61; inset:0 0 0 auto; width:min(320px,85vw); background:var(--g-solid); }
  .index-backdrop { position:fixed; inset:0; background:#11182c55; z-index:60; }
}
@media (max-width:559px) {
  .ref-filters { flex-wrap:wrap; } .ref-filters .ref-search { flex-basis:100%; }
  .ref-filters select { padding-block:5px; max-width:100%; }
  .ref-search input[type=search],.ref-search input[type=search]:focus { font-size:1rem; }
  .act-card { padding:10px; } .ref-hero { border-radius:14px; }
}
@media print {
  body.glass-app,.glass-frame,.glass-main,.glass-content,.reader-layout,.act-reading { display:block; height:auto; overflow:visible; background:white!important; color:black; }
  #dashboard-sidebar,.glass-topbar,.reader-index,.ref-search,.section-card footer,.library-back { display:none!important; }
  .section-card { content-visibility:visible; box-shadow:none; background:white; }
}
