@import url("https://fonts.googleapis.com/css2?family=Cinzel:wght@500;600;700&family=Cormorant+Garamond:ital,wght@0,400;0,500;1,400&display=swap");
/* The Greb Library — candlelit 3D bookshelf home screen.
   EVERYTHING is scoped under .greb-library because the source design reuses
   generic class names (.reader/.book/.page/.section/.title) that collide with
   the app's reader. Keyframes are renamed lib-* for the same reason. */
.greb-library{
  --ink:#e9d9b8; --gold:#d8b46a; --gold-bright:#f3d894;
  --wood-1:#3c2415; --wood-2:#2a1810; --wood-3:#150a04; --room:#0d0705;
  position:relative; min-height:100vh;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(255,150,60,.08), transparent 55%),
    linear-gradient(180deg, #1a0d06 0%, var(--room) 50%, #060302 100%);
  color:var(--ink);
  font-family:"Cormorant Garamond", Georgia, serif;
  -webkit-font-smoothing:antialiased; user-select:none; overflow-x:hidden;
}
.greb-library *{ box-sizing:border-box; }

.greb-library .motes{ position:fixed; inset:0; pointer-events:none; z-index:5; overflow:hidden; }
.greb-library .mote{ position:absolute; bottom:-10px; border-radius:50%;
  background:radial-gradient(circle, rgba(255,200,130,.9), rgba(255,180,100,0));
  animation:lib-rise linear infinite; }
@keyframes lib-rise{ from{transform:translateY(0);opacity:0} 10%{opacity:.8} 90%{opacity:.45} to{transform:translateY(-105vh) translateX(40px);opacity:0} }

.greb-library .vignette{ position:fixed; inset:0; pointer-events:none; z-index:6;
  box-shadow: inset 0 0 220px 90px rgba(0,0,0,.82);
  background:radial-gradient(60% 50% at 50% 30%, rgba(255,150,60,.05), transparent 70%);
  animation:lib-flicker 5s ease-in-out infinite; }
@keyframes lib-flicker{ 0%,100%{opacity:1} 45%{opacity:.93} 70%{opacity:.9} }

.greb-library .topbar{
  position:sticky; top:0; z-index:8;
  display:flex; align-items:center; gap:18px; flex-wrap:wrap;
  /* right padding clears the fixed user avatar (40px @ right:1rem, z>topbar) */
  padding:14px 72px 14px 26px; backdrop-filter:blur(6px);
  background:linear-gradient(180deg, rgba(15,8,4,.92), rgba(15,8,4,.55));
  border-bottom:1px solid rgba(216,180,106,.18);
}
.greb-library .topbar .brand{ font-family:"Cinzel",serif; font-weight:600; letter-spacing:.2em; color:var(--gold);
  font-size:16px; text-shadow:0 0 18px rgba(216,180,106,.35); }
.greb-library .topbar .count{ font-style:italic; opacity:.6; font-size:14px; }
.greb-library .topbar .spacer{ flex:1; }
.greb-library .topbar .lbl{ font-size:12px; letter-spacing:.18em; opacity:.5; font-family:"Cinzel",serif; }

/* Colecciones popover — list of collection names; pick one to jump to its shelf */
.greb-library .lib-collections{ position:relative; }
.greb-library .lib-coll-menu{
  position:absolute; top:calc(100% + 8px); left:0; z-index:30;
  min-width:240px; max-width:min(78vw,340px); max-height:60vh; overflow-y:auto;
  padding:6px; border-radius:12px;
  background:rgba(28,16,9,.98); border:1px solid rgba(216,180,106,.4);
  box-shadow:0 18px 50px rgba(0,0,0,.6);
}
.greb-library .lib-coll-item{
  display:flex; align-items:center; gap:10px; width:100%; text-align:left;
  border:none; background:transparent; cursor:pointer;
  padding:10px 12px; border-radius:8px;
  font-family:"Cinzel",serif; font-size:14px; letter-spacing:.04em; color:var(--ink);
}
.greb-library .lib-coll-item:hover{ background:rgba(216,180,106,.16); color:var(--gold-bright); }
.greb-library .lib-coll-n{ margin-left:auto; font-style:italic; opacity:.5; font-size:12px; }

.greb-library .hero{ text-align:center; padding:30px 16px 4px; }
.greb-library .hero p{ font-style:italic; opacity:.55; }

.greb-library .wall{ width:min(1180px,94vw); margin:0 auto; padding:16px 0 90px; }
.greb-library .section{ margin-top:30px; }
.greb-library .section-head{ display:flex; align-items:baseline; gap:14px; padding:0 8px 8px; }
.greb-library .section-head .sw{ width:13px; height:13px; border-radius:3px; flex:0 0 auto; align-self:center;
  box-shadow:0 0 12px -1px var(--swc,#fff), inset 0 0 0 1px rgba(255,255,255,.3); }
.greb-library .section-head .name{ font-family:"Cinzel",serif; font-weight:600; letter-spacing:.18em;
  color:var(--gold); font-size:17px; text-shadow:0 0 14px rgba(216,180,106,.3); white-space:nowrap; }
.greb-library .section-head .ct{ font-style:italic; opacity:.45; font-size:13px; white-space:nowrap; }
.greb-library .section-head .line{ flex:1; height:1px; background:linear-gradient(90deg, rgba(216,180,106,.5), transparent); }

.greb-library .shelves{ perspective:2600px; perspective-origin:50% 38%; }
.greb-library .row{
  position:relative; display:flex; align-items:flex-end; gap:3px;
  padding:0 14px 18px; transform-style:preserve-3d; min-height:60px;
}
.greb-library .row::after{ content:""; position:absolute; left:2px; right:2px; bottom:-2px; height:24px;
  transform:translateZ(46px) rotateX(64deg); transform-origin:top;
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,.16) 0 2px, transparent 2px 26px),
    linear-gradient(180deg, var(--wood-1), var(--wood-3));
  border-radius:2px; box-shadow:0 16px 28px rgba(0,0,0,.65), inset 0 2px 0 rgba(255,180,110,.10); }

.greb-library .divider{
  position:relative; flex:0 0 auto; width:40px; align-self:flex-end;
  border-radius:3px 3px 0 0; margin-right:6px;
  background:linear-gradient(90deg, #1d0f07, #150a04 60%, #0e0603);
  box-shadow: inset 2px 0 2px rgba(255,180,110,.10), inset -3px 0 6px rgba(0,0,0,.6), 0 8px 16px rgba(0,0,0,.5);
  display:flex; align-items:center; justify-content:center; overflow:hidden;
}
.greb-library .divider::before{ content:""; position:absolute; top:8px; left:50%; transform:translateX(-50%) rotate(45deg);
  width:12px; height:12px; background:var(--sec,#caa861); border-radius:2px;
  box-shadow:0 0 12px var(--sec,rgba(216,180,106,.5)), inset 0 0 0 1px rgba(255,255,255,.25); }
.greb-library .divider .lab{ writing-mode:vertical-rl; transform:rotate(180deg); margin-top:14px;
  font-family:"Cinzel",serif; font-weight:600; font-size:11px; letter-spacing:.16em;
  color:#caa861; text-shadow:0 1px 0 #000; white-space:nowrap; max-height:78%; }
.greb-library .divider .lab .n{ opacity:.55; font-weight:500; letter-spacing:.08em; }

/* packed shelves: sections share rows, so give consecutive boards their own
   vertical rhythm (the per-section 30px wrapper margin no longer separates them) */
.greb-library .shelves .row + .row{ margin-top:34px; }

.greb-library .book{ position:relative; flex:0 0 auto; transform-style:preserve-3d; cursor:pointer;
  transition:transform .4s cubic-bezier(.22,1,.36,1), filter .4s ease; will-change:transform; }
.greb-library .book .spine{ position:absolute; inset:0; border-radius:2px 3px 3px 2px; backface-visibility:hidden;
  box-shadow: inset 2px 0 3px rgba(255,255,255,.12), inset -3px 0 6px rgba(0,0,0,.55), 0 8px 14px rgba(0,0,0,.45);
  display:flex; align-items:center; justify-content:center; overflow:hidden; }
.greb-library .book .spine::before{ content:""; position:absolute; inset:0;
  background:linear-gradient(90deg, rgba(255,255,255,.10), transparent 22%, transparent 78%, rgba(0,0,0,.35)),
    repeating-linear-gradient(0deg, transparent 0 18px, rgba(0,0,0,.16) 18px 20px);
  mix-blend-mode:overlay; opacity:var(--wear,.7); }
.greb-library .book .title{ writing-mode:vertical-rl; text-orientation:mixed; transform:rotate(180deg);
  font-family:"Cinzel",serif; font-weight:600; color:var(--gold); letter-spacing:.1em;
  text-shadow:0 0 6px rgba(255,210,130,.3), 0 1px 0 rgba(0,0,0,.6);
  white-space:nowrap; padding:12px 0; line-height:1; z-index:1; }
.greb-library .book .foredge{ position:absolute; top:0; right:0; height:100%; transform-origin:right center;
  transform:rotateY(90deg); border-radius:0 2px 2px 0; backface-visibility:hidden;
  background:
    linear-gradient(90deg, rgba(0,0,0,.28), transparent 30%),
    repeating-linear-gradient(0deg, #e7d8b4 0 1px, #c9b486 1px 2.4px),
    linear-gradient(180deg,#ecdcb6,#d2bd8e);
  box-shadow:inset 0 0 8px rgba(120,90,50,.25); }
.greb-library .book .top{ position:absolute; left:0; top:0; width:100%; transform-origin:top center; transform:rotateX(-90deg);
  border-radius:2px 2px 0 0; backface-visibility:hidden;
  background:
    linear-gradient(180deg, rgba(0,0,0,.22), transparent 40%),
    repeating-linear-gradient(90deg, #e7d8b4 0 1px, #c9b486 1px 2.6px);
  box-shadow:inset 0 2px 4px rgba(0,0,0,.3); }
.greb-library .book:hover{ transform:translateZ(34px) translateY(-8px) rotateY(-15deg);
  filter:drop-shadow(0 0 24px rgba(255,170,80,.55)); z-index:4; }
.greb-library .book:hover .title{ color:var(--gold-bright); text-shadow:0 0 14px rgba(255,210,130,.8); }
/* hjkl keyboard cursor on the shelf wall — a pulled-out, lit spine */
.greb-library .book.selected{ transform:translateZ(40px) translateY(-12px) rotateY(-15deg);
  filter:drop-shadow(0 0 26px rgba(255,190,90,.75)); z-index:5; }
.greb-library .book.selected .spine{ outline:2px solid var(--gold-bright);
  outline-offset:-2px; box-shadow:inset 0 0 18px rgba(255,210,130,.35); }
.greb-library .book.selected .title{ color:var(--gold-bright); text-shadow:0 0 14px rgba(255,210,130,.9); }

/* ---- horizontal spine: stacked centred lines + raised bands + emblem ---- */
.greb-library .book .spine.horizontal{ flex-direction:column; padding:7px 2px; gap:0; }
.greb-library .book .spine.horizontal .htext{ flex:1; display:flex; flex-direction:column;
  align-items:center; justify-content:center; gap:1px; width:100%; overflow:hidden; z-index:1; }
.greb-library .book .spine.horizontal .hline{ font-family:"Cinzel",serif; font-weight:600;
  color:var(--gold); text-transform:uppercase; letter-spacing:.03em; line-height:1.05;
  text-align:center; white-space:nowrap; max-width:100%; overflow:hidden; text-overflow:clip;
  text-shadow:0 0 5px rgba(255,210,130,.3), 0 1px 0 rgba(0,0,0,.6); }
.greb-library .book .spine.horizontal .hline.hl-num{ font-size:1.5em; margin:.2em 0;
  color:var(--gold-bright); }
.greb-library .book .spine.horizontal .hline.hl-title{ font-size:.95em; margin-top:.1em; }
.greb-library .book .spine.horizontal .hline.hl-author{ font-size:.92em; letter-spacing:.1em; margin-bottom:.15em; }
.greb-library .book .spine.horizontal .hline.hl-series{ font-size:.74em; opacity:.9; letter-spacing:.08em; line-height:1.18; }
/* emblem at the FOOT (the Collected Works' silver cross) */
.greb-library .book .spine.horizontal.em-bottom{ padding:8px 2px 5px; }
.greb-library .book .spine.horizontal.em-bottom .htext{ justify-content:flex-start; padding-top:3px; }
.greb-library .book .spine.horizontal.em-bottom .emblem{ margin:3px 0 0; font-size:12px; color:#cfd2da;
  opacity:.78; text-shadow:0 1px 0 rgba(0,0,0,.6); }
.greb-library .book .spine.horizontal .emblem{ color:var(--gold); opacity:.85; line-height:1;
  font-size:13px; margin-bottom:1px; text-shadow:0 0 6px rgba(255,200,120,.5); z-index:1; }
.greb-library .book .spine.horizontal .hband{ width:80%; height:0; flex:0 0 auto; z-index:1;
  border-top:1px solid rgba(255,210,130,.28); box-shadow:0 1px 0 rgba(0,0,0,.45); }
.greb-library .book .spine.horizontal .hband.t{ margin:0 0 4px; }
.greb-library .book .spine.horizontal .hband.b{ margin:4px 0 0; }
.greb-library .book:hover .spine.horizontal .hline,
.greb-library .book.selected .spine.horizontal .hline{ color:var(--gold-bright);
  text-shadow:0 0 12px rgba(255,210,130,.8); }

/* ---- Jung altar: black Collected Works standing on the flat Red Book ---- */
.greb-library .row.jung-altar{ padding-bottom:0; margin-bottom:0; justify-content:center; gap:2px; }
.greb-library .row.jung-altar::after{ display:none; }   /* no wooden board — the Red Book is the board */
.greb-library .redbook-base{ position:relative; width:100%; height:62px; cursor:pointer; overflow:hidden;
  margin-top:-1px; border-radius:2px 2px 3px 3px;
  background:linear-gradient(180deg,#8a241f 0%,#6e1a16 55%,#480f0c 100%);
  box-shadow: inset 0 2px 0 rgba(255,170,130,.22), inset 0 -8px 16px rgba(0,0,0,.5),
    inset 3px 0 6px rgba(0,0,0,.35), inset -3px 0 6px rgba(0,0,0,.35),
    0 22px 44px rgba(0,0,0,.6); transition:filter .3s ease, box-shadow .3s ease; }
.greb-library .redbook-base:hover{ filter:brightness(1.12) saturate(1.1);
  box-shadow: inset 0 2px 0 rgba(255,190,150,.3), inset 0 -8px 16px rgba(0,0,0,.45),
    inset 3px 0 6px rgba(0,0,0,.3), inset -3px 0 6px rgba(0,0,0,.3),
    0 0 34px 6px rgba(214,68,52,.55), 0 0 70px 12px rgba(170,40,30,.35), 0 22px 44px rgba(0,0,0,.6); }
.greb-library .redbook-base:hover .rb-face{ color:#f6db8a; text-shadow:0 1px 0 rgba(0,0,0,.5), 0 0 16px rgba(246,219,138,.5); }
.greb-library .redbook-base .rb-top{ position:absolute; left:0; right:0; top:0; height:9px;
  background:linear-gradient(180deg, rgba(255,180,140,.30), rgba(120,30,24,0));
  border-bottom:1px solid rgba(0,0,0,.25); }
.greb-library .redbook-base .rb-face{ position:absolute; inset:9px 0 0; display:flex; align-items:center;
  justify-content:center; gap:clamp(18px,5vw,70px); padding:0 26px;
  font-family:"Cinzel",serif; color:#e8c869; letter-spacing:.14em; white-space:nowrap;
  text-shadow:0 1px 0 rgba(0,0,0,.55), 0 0 12px rgba(232,200,106,.25); }
.greb-library .redbook-base .rb-author,
.greb-library .redbook-base .rb-mark{ font-size:12.5px; letter-spacing:.26em; opacity:.82; }
.greb-library .redbook-base .rb-title{ display:inline-flex; align-items:baseline; gap:.55em;
  font-size:clamp(15px,1.7vw,21px); letter-spacing:.12em; }
.greb-library .redbook-base .rb-title b{ font-weight:700; }
.greb-library .redbook-base .rb-title i{ font-style:italic; font-weight:500; opacity:.8; letter-spacing:.18em; }

/* ---- spine customizer (admin) ---- */
.spine-editor{ position:fixed; right:18px; top:50%; transform:translateY(-50%); z-index:30;
  width:236px; padding:14px 14px 12px; border-radius:11px; color:#e9dcbe;
  background:linear-gradient(180deg,#1d140d,#130c06); border:1px solid rgba(255,200,120,.26);
  box-shadow:0 22px 60px rgba(0,0,0,.62), inset 0 1px 0 rgba(255,220,160,.10);
  font-family:system-ui,-apple-system,sans-serif; font-size:12.5px; }
.spine-editor .se-head{ display:flex; align-items:baseline; gap:6px; margin-bottom:10px;
  font-family:"Cinzel",serif; font-size:13px; letter-spacing:.04em; color:#d8b96a; }
.spine-editor .se-title{ flex:1; font-family:system-ui,sans-serif; font-size:11px;
  color:#a99169; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.spine-editor .se-x{ border:0; background:none; color:#a99169; cursor:pointer; font-size:13px; padding:0 2px; }
.spine-editor .se-x:hover{ color:#e9dcbe; }
.spine-editor .se-lbl{ margin:10px 0 5px; font-size:10.5px; letter-spacing:.08em;
  text-transform:uppercase; color:#9a835c; }
.spine-editor .se-row{ display:flex; align-items:center; gap:8px; margin:7px 0; }
.spine-editor .se-wrap{ justify-content:space-between; }
.spine-editor .se-wrap span{ font-size:11.5px; color:#c9b58c; }
.spine-editor .se-orient{ gap:6px; }
.spine-editor .se-orient button{ flex:1; padding:7px 0; cursor:pointer; border-radius:7px;
  border:1px solid rgba(255,200,120,.22); background:rgba(255,210,140,.05); color:#c9b58c;
  font-family:"Cinzel",serif; font-size:11.5px; letter-spacing:.03em; }
.spine-editor .se-orient button.on{ background:linear-gradient(180deg,#caa861,#9a7e3e);
  color:#1a1109; border-color:#caa861; box-shadow:0 0 10px rgba(216,180,106,.4); }
.spine-editor .se-w{ flex:1; accent-color:#caa861; }
.spine-editor .se-color{ width:34px; height:24px; padding:0; border:1px solid rgba(255,200,120,.3);
  border-radius:5px; background:none; cursor:pointer; }
.spine-editor .se-grid{ display:grid; grid-template-columns:repeat(6,1fr); gap:5px; }
.spine-editor .se-sw{ aspect-ratio:1; border-radius:5px; cursor:pointer;
  border:1px solid rgba(0,0,0,.4); box-shadow:inset 0 0 0 1px rgba(255,255,255,.12); }
.spine-editor .se-sw:hover{ outline:2px solid var(--gold-bright,#f3d488); outline-offset:1px; }
.spine-editor .se-ems .se-em{ aspect-ratio:1; cursor:pointer; border-radius:6px; font-size:15px;
  border:1px solid rgba(255,200,120,.18); background:rgba(255,210,140,.05); color:#d8b96a; }
.spine-editor .se-ems .se-em:hover{ background:rgba(255,210,140,.16); color:#f3d488; }
.spine-editor .se-foot{ justify-content:flex-end; margin-top:12px; }
.spine-editor .se-reset{ padding:5px 12px; cursor:pointer; border-radius:7px; font-size:11.5px;
  border:1px solid rgba(255,160,120,.3); background:rgba(180,70,60,.12); color:#d9a99f; }
.spine-editor .se-reset:hover{ background:rgba(180,70,60,.24); color:#f0cabf; }

/* ---- carousel (coverflow) ---- */
.greb-library .carousel{ position:fixed; inset:0; z-index:14; display:flex; flex-direction:column;
  align-items:center; justify-content:center; opacity:0; pointer-events:none; transition:opacity .45s ease; }
.greb-library .carousel.open{ opacity:1; pointer-events:auto; }
.greb-library .carousel .cbg{ position:absolute; inset:0;
  background:radial-gradient(55% 60% at 50% 46%, rgba(255,160,70,.10), rgba(0,0,0,.9) 72%); backdrop-filter:blur(5px); }
.greb-library .cf-stage{ position:relative; width:100%; height:62vh; perspective:1500px; }
.greb-library .cf-track{ position:absolute; left:50%; top:50%; transform-style:preserve-3d; }
.greb-library .cf-card{ position:absolute; left:-100px; top:-145px; width:200px; height:290px;
  border-radius:6px 14px 14px 6px; cursor:pointer; backface-visibility:hidden;
  transform-style:preserve-3d; transition:transform .5s cubic-bezier(.2,.8,.25,1), opacity .5s ease;
  display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center;
  padding:26px 22px; overflow:hidden; box-shadow:0 26px 50px rgba(0,0,0,.6); }
.greb-library .cf-card::after{ content:""; position:absolute; inset:0; pointer-events:none;
  background:linear-gradient(90deg, rgba(0,0,0,.45), transparent 16%), radial-gradient(120% 120% at 80% 18%, rgba(255,255,255,.10), transparent 45%); }
.greb-library .cf-card .em{ width:54px; height:54px; border-radius:50%; border:2px solid var(--gold); margin-bottom:14px;
  display:flex; align-items:center; justify-content:center; font-family:"Cinzel",serif; font-size:22px; color:var(--gold-bright);
  box-shadow:0 0 16px rgba(216,180,106,.4), inset 0 0 12px rgba(0,0,0,.4); }
.greb-library .cf-card .ct{ font-family:"Cinzel",serif; font-weight:700; font-size:18px; letter-spacing:.04em; color:var(--gold-bright);
  text-shadow:0 0 12px rgba(216,180,106,.5); line-height:1.15; }
.greb-library .cf-card .cr{ width:44px; height:1px; background:var(--gold); margin:11px 0; opacity:.7; }
.greb-library .cf-card .au{ font-style:italic; font-size:15px; color:rgba(255,235,200,.78); }
.greb-library .cf-card .sc{ position:absolute; bottom:12px; font-family:"Cinzel",serif; font-size:9px; letter-spacing:.2em; color:rgba(255,220,170,.45); }
.greb-library .cf-card .readhint{ position:absolute; bottom:32px; font-style:italic; font-size:12px; opacity:0; color:rgba(255,235,200,.7); transition:opacity .3s; }
.greb-library .cf-card.center{ cursor:zoom-in; }
.greb-library .cf-card.center .readhint{ opacity:.85; }

/* ── Actual Bollingen dust-jacket on the carousel card (Jung Collected Works) ── */
.greb-library .cf-card.cf-jacket{
  display:block; text-align:left; padding:20px 18px;
  background:
    radial-gradient(ellipse at 20% 110%, rgba(255,255,255,.04), transparent 65%),
    radial-gradient(ellipse at 110% -10%, rgba(255,255,255,.05), transparent 60%),
    #0a0a0a;
  box-shadow:0 26px 50px rgba(0,0,0,.6), inset 0 0 0 1px rgba(244,236,218,.10); }
.greb-library .cf-jacket .cfj-eyebrow{
  text-align:right; color:#98bdd6; font-family:"Cinzel",serif;
  font-size:7px; font-weight:600; letter-spacing:.05em; line-height:1.4;
  white-space:pre-line; text-transform:uppercase; margin-bottom:20px; }
.greb-library .cf-jacket .cfj-stack{ margin-top:4px; }
.greb-library .cf-jacket .cfj-author{
  display:inline-block; background:#f0e6cc; color:#0a0a0a;
  font-family:"Libre Franklin","Helvetica Neue",Arial,sans-serif; font-weight:900;
  font-size:15px; letter-spacing:.1em; padding:4px 9px 3px; margin-bottom:14px; line-height:1; }
.greb-library .cf-jacket .cfj-title{
  font-family:"Oswald","Roboto Condensed","Helvetica Neue",sans-serif; font-weight:600;
  font-size:14.5px; letter-spacing:.02em; line-height:1.14; text-transform:uppercase; color:#f0e6cc; }
.greb-library .cf-jacket .cfj-colophon{
  position:absolute; bottom:18px; right:18px; text-align:right;
  color:#98bdd6; font-family:"Cinzel",serif; font-size:6.5px; font-weight:600;
  letter-spacing:.1em; text-transform:uppercase; }
.greb-library .cf-jacket .readhint{ color:rgba(240,230,204,.72); }

.greb-library .cf-caption{ position:relative; z-index:2; text-align:center; margin-top:14px; }
.greb-library .cf-caption .nm{ font-family:"Cinzel",serif; letter-spacing:.16em; color:var(--gold); font-size:13px; }
.greb-library .cf-caption .pos{ font-style:italic; opacity:.5; font-size:13px; margin-top:2px; }

.greb-library .cf-nav{ position:absolute; top:50%; transform:translateY(-50%); z-index:3;
  width:52px; height:52px; border-radius:50%; cursor:pointer;
  background:rgba(40,22,12,.55); border:1px solid rgba(216,180,106,.4); color:var(--gold);
  font-size:22px; display:flex; align-items:center; justify-content:center; backdrop-filter:blur(4px); transition:.2s; }
.greb-library .cf-nav:hover{ background:rgba(70,40,20,.8); color:var(--gold-bright); }
.greb-library .cf-prev{ left:5vw; } .greb-library .cf-next{ right:5vw; }

.greb-library .cf-close, .greb-library .closebook{ position:fixed; top:22px; right:26px; z-index:16;
  font-family:"Cinzel",serif; letter-spacing:.16em; font-size:12px;
  color:var(--gold); background:rgba(40,22,12,.6); border:1px solid rgba(216,180,106,.4); border-radius:30px;
  padding:11px 20px; cursor:pointer; opacity:0; transition:opacity .4s ease .2s, background .2s; backdrop-filter:blur(4px); }
.greb-library .cf-close:hover, .greb-library .closebook:hover{ background:rgba(70,40,20,.8); color:var(--gold-bright); }
.greb-library .carousel.open .cf-close{ opacity:1; }

/* ---- reading overlay ---- */
.greb-library .lib-reader{ position:fixed; inset:0; z-index:20; display:flex; align-items:center; justify-content:center;
  perspective:2200px; opacity:0; pointer-events:none; transition:opacity .5s ease; }
.greb-library .lib-reader.open{ opacity:1; pointer-events:auto; }
.greb-library .reader-bg{ position:absolute; inset:0; background:radial-gradient(50% 45% at 50% 42%, rgba(255,160,70,.12), rgba(0,0,0,.92) 70%); backdrop-filter:blur(5px); }
.greb-library .tome{ position:relative; transform-style:preserve-3d; transform:rotateX(8deg) scale(.7);
  transition:transform .7s cubic-bezier(.22,.61,.36,1); width:300px; height:430px; }
.greb-library .lib-reader.open .tome{ transform:rotateX(8deg) scale(1); }
/* width/height MUST be set explicitly: the global `.page{width:var(--pw);
   height:var(--page-height,1056px)}` in magazine.css (the course reader's
   US-Letter page) otherwise wins over our `inset:0` and balloons this page to
   816×1056 inside the 300×430 tome — overflowing the whole viewport. */
.greb-library .tome .page{ position:absolute; inset:0; width:100%; height:100%; overflow:hidden;
  border-radius:4px 12px 12px 4px;
  background:radial-gradient(120% 80% at 0% 50%, rgba(120,90,50,.18), transparent 40%), linear-gradient(180deg,#f3e8cb,#e3d2a8);
  box-shadow:0 30px 70px rgba(0,0,0,.7), inset 14px 0 28px rgba(120,80,40,.18);
  padding:40px 34px 34px 46px; color:#43331c; transform:translateZ(-6px); }
.greb-library .page .chapter{ font-family:"Cinzel",serif; font-size:12px; letter-spacing:.28em; color:#8a6a35; }
.greb-library .page h2{ font-family:"Cinzel",serif; font-weight:600; font-size:24px; margin:8px 0 4px; color:#3a2c16; }
.greb-library .page .by{ font-style:italic; opacity:.7; margin-bottom:16px; }
.greb-library .page p{ font-size:17px; line-height:1.55; opacity:.86; }
.greb-library .page .drop{ float:left; font-family:"Cinzel",serif; font-size:52px; line-height:.8; padding:6px 10px 0 0; color:#7a4a1c; }
.greb-library .tome .frontcover{ position:absolute; inset:0; transform-origin:left center; transform:rotateY(0) translateZ(8px);
  transition:transform .9s cubic-bezier(.4,.1,.2,1); border-radius:4px 12px 12px 4px;
  box-shadow:0 22px 50px rgba(0,0,0,.6); backface-visibility:hidden;
  display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; padding:34px; overflow:hidden; }
.greb-library .tome .frontcover::after{ content:""; position:absolute; inset:0;
  background:linear-gradient(90deg, rgba(0,0,0,.45), transparent 18%), radial-gradient(120% 120% at 80% 20%, rgba(255,255,255,.08), transparent 45%); }
.greb-library .lib-reader.open .tome.unsealed .frontcover{ transform:rotateY(-158deg) translateZ(8px); }
.greb-library .frontcover .emblem{ width:60px; height:60px; border-radius:50%; border:2px solid var(--gold); margin-bottom:18px;
  display:flex; align-items:center; justify-content:center; font-family:"Cinzel",serif; font-size:24px; color:var(--gold-bright);
  box-shadow:0 0 18px rgba(216,180,106,.4), inset 0 0 14px rgba(0,0,0,.4); }
.greb-library .frontcover h2{ font-family:"Cinzel",serif; font-weight:700; font-size:22px; letter-spacing:.05em; color:var(--gold-bright);
  text-shadow:0 0 14px rgba(216,180,106,.5); line-height:1.2; }
.greb-library .frontcover .ca{ margin-top:12px; font-style:italic; color:rgba(255,235,200,.75); }
.greb-library .frontcover .rule{ width:52px; height:1px; background:var(--gold); margin:14px 0; opacity:.7; }
/* real cover art on the swinging front cover (matches the carousel card) */
.greb-library .frontcover.has-cover{ background-size:cover; background-position:center; padding:0; }
.greb-library .frontcover.has-cover::after{ background:linear-gradient(90deg, rgba(0,0,0,.4), transparent 15%); }
.greb-library .lib-reader.open .closebook{ opacity:1; }
.greb-library .openhint{ position:absolute; bottom:30px; left:0; right:0; text-align:center;
  font-style:italic; color:rgba(255,235,200,.7); font-size:13px; }
/* cover books: the inside page is dark so the floating REAL cover glows */
.greb-library .page.cover-page{ background:radial-gradient(120% 80% at 50% 40%, #2a1d10, #120c06); }
.greb-library .page .float-cover{
  position:absolute; inset:6% 9% 12%; background-size:cover; background-position:center;
  border-radius:5px; box-shadow:0 18px 50px rgba(0,0,0,.6), 0 0 30px rgba(216,180,106,.18);
  animation:lib-cover-float 2.6s ease-in-out infinite; }
@keyframes lib-cover-float{
  0%,100%{ transform:translateY(0) rotate(-1deg) scale(1); filter:brightness(1); }
  50%{ transform:translateY(-12px) rotate(1deg) scale(1.03); filter:brightness(1.1); } }

/* Scriptor (search) icon in the topbar → opens the omnibox */
.greb-library .lib-scriptor{
  display:inline-flex; align-items:center; justify-content:center;
  width:34px; height:34px; margin-left:14px; padding:0; cursor:pointer;
  border:1px solid rgba(216,180,106,.4); border-radius:50%;
  background:rgba(40,22,12,.5); color:var(--gold);
  transition:background .2s, color .2s, transform .1s;
}
.greb-library .lib-scriptor:hover{ background:rgba(70,40,20,.85); color:var(--gold-bright); }
.greb-library .lib-scriptor:active{ transform:scale(.92); }
.greb-library .lib-scriptor svg{ width:17px; height:17px; }
.greb-library .lib-scriptor-lbl{ display:none; }

/* ── Phones (portrait): the candlelit shelf reads too dark and the search
   affordance is a tiny glyph. Lift the room a touch and make the omnirepl
   opener an obvious labelled pill with a 44px tap target. ── */
@media (max-width:640px) and (orientation:portrait){
  .greb-library{
    background:
      radial-gradient(130% 70% at 50% 0%, rgba(255,160,70,.12), transparent 55%),
      linear-gradient(180deg, #2c1810 0%, #1c1009 52%, #120a05 100%);
  }
  /* Keep the topbar on ONE line on phones — drop the decorative brand/count/
     label text so the Buscar + Colecciones pills (and the fixed avatar) fit. */
  .greb-library .topbar{ flex-wrap:nowrap; gap:10px; padding:12px 64px 12px 14px; }
  .greb-library .topbar .brand,
  .greb-library .topbar .count,
  .greb-library .topbar .lbl{ display:none; }
  .greb-library .vignette{ background:radial-gradient(70% 55% at 50% 28%, rgba(255,160,70,.07), transparent 72%); }
  .greb-library .lib-scriptor{
    width:auto; min-height:40px; padding:0 14px; gap:7px; border-radius:999px;
    background:rgba(216,180,106,.18); border-color:rgba(216,180,106,.6);
    color:var(--gold-bright);
  }
  .greb-library .lib-scriptor svg{ width:18px; height:18px; }
  .greb-library .lib-scriptor-lbl{
    display:inline; font-family:"Cinzel",serif; font-size:13px;
    letter-spacing:.08em; font-weight:600;
  }
}

/* coverflow card showing a REAL cover image */
.greb-library .cf-card.has-cover{
  background-size:cover; background-position:center; padding:0; justify-content:flex-end;
}
.greb-library .cf-card.has-cover::after{
  background:linear-gradient(180deg, rgba(0,0,0,.05) 40%, rgba(0,0,0,.82));
}
.greb-library .cf-card .cf-cap{ position:relative; z-index:2; width:100%; padding:16px 18px 8px; text-align:center; }
.greb-library .cf-card .cf-cap .ct{ margin-bottom:4px; }

/* ---- orientation lock (touch devices only) ----
   The shelf is composed vertically; on a phone/iPad held in landscape it
   must NOT reflow — the whole library rotates 90° so it stays portrait and
   the natural move is to turn the device upright. Opening a book leaves
   .greb-library entirely, so reading in landscape (two-page spreads) is
   unaffected. Desktop/laptop (fine pointer) never matches. The rotated
   element becomes its own scroll + containing block (the transform also
   re-scopes the position:fixed motes/vignette to it, which is what we want). */
@media (orientation: landscape) and (pointer: coarse){
  .greb-library{
    position:fixed; top:0; left:0; z-index:1;
    width:100vh; height:100vw;
    width:100dvh; height:100dvw;
    min-height:0;
    transform:rotate(90deg) translateY(-100%);
    transform-origin:top left;
    overflow-y:auto; overflow-x:hidden;
    overscroll-behavior:contain;
  }
}
