:root {
  color-scheme: dark;
  --ink: #f5effa;
  --muted: #bdb1c8;
  --night: #110f18;
  --panel: rgba(31, 26, 42, .82);
  --line: rgba(241, 222, 255, .14);
  --plum: #a877c8;
  --gold: #d9b77b;
  --mint: #8fc7b8;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 15% 0%, #2b2038 0, transparent 36rem), var(--night); color: var(--ink); }
a { color: inherit; }
button, input, select { font: inherit; }
.ambient { position: fixed; border-radius: 50%; filter: blur(90px); opacity: .16; pointer-events: none; }
.ambient-one { width: 28rem; height: 28rem; background: #8459a4; right: -10rem; top: 20%; }
.ambient-two { width: 22rem; height: 22rem; background: #4f9f8a; left: -10rem; bottom: -8rem; }
.site-header { position: sticky; top: 0; z-index: 20; width: 100%; max-width: 76rem; height: 5.2rem; margin: 0 auto; padding: 1.3rem 2rem; display: flex; align-items: center; gap: 2rem; border: 1px solid transparent; border-bottom-color: var(--line); transition: background .2s, border-color .2s, border-radius .2s, box-shadow .2s; }
.site-header.is-scrolled { background: linear-gradient(110deg, rgba(39,29,52,.96), rgba(17,15,24,.94)); border-color: rgba(217,183,123,.26); border-top-color: transparent; border-radius: 0 0 1.25rem 1.25rem; box-shadow: 0 .75rem 2.5rem rgba(5,4,8,.46), 0 1px 0 rgba(217,183,123,.1) inset; backdrop-filter: blur(20px); }
.site-header.is-scrolled::after { content: ""; position: absolute; right: 12%; bottom: -1px; left: 12%; height: 1px; background: linear-gradient(90deg, transparent, rgba(217,183,123,.7), transparent); }
.brand { display: flex; gap: .75rem; align-items: center; text-decoration: none; margin-right: auto; }
.brand-mark { width: 2.4rem; height: 2.4rem; display: grid; place-items: center; border: 1px solid rgba(217,183,123,.6); border-radius: 50%; color: var(--gold); font-family: Georgia, serif; }
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; }
.nav-panel { display: flex; align-items: center; gap: 2rem; }
.main-nav { display: flex; gap: .35rem; }
.main-nav a { position: relative; padding: .6rem .8rem; border-radius: 999px; color: var(--muted); text-decoration: none; overflow: hidden; transition: color .35s ease, background .35s ease, box-shadow .5s ease, text-shadow .5s ease; }
.main-nav a::after { content: ""; position: absolute; top: 50%; right: .55rem; width: 3px; height: 3px; border-radius: 50%; background: #fff0bd; box-shadow: .38rem -.28rem 0 -1px rgba(168,119,200,.8), .65rem .25rem 0 -1px rgba(143,199,184,.7), 0 0 .45rem rgba(217,183,123,.8); opacity: 0; pointer-events: none; }
.main-nav a:hover::after { animation: nav-dust-drift 1.35s ease-out; }
.main-nav a:hover, .main-nav a[aria-current="page"] { background: rgba(255,255,255,.07); color: var(--ink); box-shadow: 0 0 1.2rem rgba(168,119,200,.08) inset; text-shadow: 0 0 .8rem rgba(217,183,123,.22); }
.wand-menu-toggle { display: none; }
.cursor-dust { position: fixed; z-index: 100; left: 0; top: 0; width: var(--dust-size); height: var(--dust-size); border-radius: 50%; background: #f6dfaa; box-shadow: 0 0 .45rem .08rem rgba(217,183,123,.55); pointer-events: none; transform: translate(-50%, -50%); animation: cursor-dust-fade .7s ease-out forwards; }
.quiet-button, .pager button, .card-navigation button { border: 1px solid var(--line); color: var(--ink); background: transparent; border-radius: 999px; padding: .65rem 1rem; cursor: pointer; }
.page-shell { position: relative; z-index: 1; max-width: 76rem; margin: 0 auto; padding: clamp(3rem, 7vw, 7rem) 2rem; }
.hero { max-width: 54rem; margin-bottom: 4rem; }
.home-page .page-shell { padding-top: clamp(1.5rem, 4vw, 3.5rem); }
.home-hero { margin-left: auto; margin-right: auto; text-align: center; }
.home-hero .lede { margin-left: auto; margin-right: auto; }
.hero.compact { margin-bottom: 2rem; }
.eyebrow, .book-count { color: var(--gold); text-transform: uppercase; letter-spacing: .16em; font-size: .72rem; font-weight: 700; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; }
h1 { margin: .3rem 0 1.2rem; font-size: clamp(2.8rem, 7vw, 6.5rem); line-height: .98; letter-spacing: -.035em; }
.lede { max-width: 44rem; color: var(--muted); font-size: clamp(1.05rem, 2vw, 1.3rem); line-height: 1.65; }
.room-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.room-grid--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.room-card, .book-card, .history-entry, .empty-state, .flashcard, .login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 1.35rem; backdrop-filter: blur(16px); }
.room-card { min-height: 16rem; padding: 1.7rem; display: flex; flex-direction: column; text-decoration: none; transition: transform .2s, border-color .2s; }
.room-card:hover { transform: translateY(-4px); border-color: rgba(217,183,123,.42); }
.room-card h2 { margin: 0 0 .5rem; font-size: 2.2rem; }
.room-card p { color: var(--muted); line-height: 1.55; }
.card-link { margin-top: auto; padding-top: 1.2rem; color: var(--gold); }
.login-page .page-shell { min-height: 100dvh; display: grid; place-items: center; padding: 2rem; }
.login-page .site-header { display: none; }
.login-page { position: relative; overflow-x: hidden; }
.login-page::before { content: ""; position: fixed; inset: 0; background: radial-gradient(circle at 50% 48%, rgba(168,119,200,.11), transparent 28rem); pointer-events: none; }
.login-magic { position: fixed; z-index: 0; inset: 0; overflow: hidden; pointer-events: none; }
.magic-mote { position: absolute; left: var(--x); top: var(--y); width: var(--size); height: var(--size); border-radius: 50%; background: #e8d6ff; opacity: .18; box-shadow: 0 0 .45rem .08rem rgba(207,180,235,.45); animation: stardust-drift var(--duration) ease-in-out var(--delay) infinite alternate; }
.magic-mote:nth-child(3n) { background: #f0ca83; box-shadow: 0 0 .5rem .08rem rgba(217,183,123,.5); }
.magic-mote:nth-child(5n) { background: #bce6df; box-shadow: 0 0 .45rem .08rem rgba(143,199,184,.4); }
.magic-glint { width: calc(var(--size) * 2.2); height: calc(var(--size) * 2.2); border-radius: 0; background: transparent !important; box-shadow: none !important; opacity: .42; }
.magic-glint::before, .magic-glint::after { content: ""; position: absolute; top: 50%; left: 50%; border-radius: 999px; background: #f9edcf; box-shadow: 0 0 .6rem rgba(240,202,131,.55); transform: translate(-50%, -50%); }
.magic-glint::before { width: 100%; height: 1px; }
.magic-glint::after { width: 1px; height: 100%; }
.falling-star { position: absolute; left: var(--x); top: var(--y); width: var(--length); height: 1px; border-radius: 999px; background: linear-gradient(90deg, transparent, rgba(232,214,255,.18) 55%, #fff7dc); opacity: 0; filter: drop-shadow(0 0 .35rem rgba(217,183,123,.7)); transform: rotate(var(--angle)) translate3d(-4rem, 0, 0) scaleX(.6); transform-origin: center; animation: starfall var(--duration) ease-out var(--delay) infinite; }
.falling-star.comet { height: 2px; background: linear-gradient(90deg, transparent, rgba(168,119,200,.08) 20%, rgba(143,199,184,.28) 70%, #fff8db); filter: drop-shadow(0 0 .5rem rgba(168,119,200,.85)); animation-name: comet-pass; animation-timing-function: cubic-bezier(.2,.55,.35,1); }
.falling-star.comet::after { content: ""; position: absolute; top: 50%; right: -.1rem; width: .32rem; height: .32rem; border-radius: 50%; background: #fff9e7; box-shadow: 0 0 .45rem .12rem rgba(240,202,131,.9), 0 0 1.1rem .3rem rgba(168,119,200,.45); transform: translateY(-50%); }
.login-card { position: relative; z-index: 1; isolation: isolate; width: min(100%, 31rem); margin: 0; padding: clamp(2.5rem, 5vw, 3.5rem); box-shadow: 0 1.5rem 5rem rgba(4,3,7,.38), 0 0 3rem rgba(168,119,200,.05); animation: ward-glow 7s ease-in-out infinite; }
.login-card::after { content: ""; position: absolute; z-index: -1; inset: -1px; border: 1px solid transparent; border-radius: inherit; background: linear-gradient(125deg, rgba(240,202,131,.4), transparent 22%, transparent 70%, rgba(168,119,200,.38)) border-box; mask: linear-gradient(#000 0 0) padding-box, linear-gradient(#000 0 0); mask-composite: exclude; pointer-events: none; }
.login-card > .eyebrow { position: absolute; top: 0; left: 50%; width: max-content; margin: 0; padding: .3rem .85rem; background: #211b2b; transform: translate(-50%, -50%); text-align: center; }
.login-card h1 { font-size: 2.88rem; }
.login-card { transition: opacity .65s ease, filter .65s ease, transform .65s ease; }
.is-welcoming .login-card { opacity: .08; filter: blur(5px); transform: scale(.96); }
.welcome-spell { position: fixed; z-index: 40; inset: 0; display: grid; place-items: center; padding: 2rem; background: radial-gradient(circle at center, rgba(50,35,66,.46), rgba(8,7,12,.78) 56%, rgba(8,7,12,.9)); opacity: 0; backdrop-filter: blur(7px) saturate(.72); transition: opacity .45s ease; pointer-events: none; }
.welcome-spell[hidden] { display: none; }
.welcome-spell.welcome-on-destination { opacity: 1; }
.welcome-spell.is-visible { opacity: 1; }
.welcome-spell.is-leaving { opacity: 0; transition-duration: .55s; }
.welcome-spell-content { position: relative; isolation: isolate; width: min(42rem, 100%); padding: 4rem 1rem; text-align: center; transform: scale(.82); filter: blur(10px); opacity: 0; transition: opacity .65s ease .08s, filter .8s ease .08s, transform .8s cubic-bezier(.2,.7,.2,1) .08s; }
.welcome-spell.is-visible .welcome-spell-content { opacity: 1; filter: blur(0); transform: scale(1); }
.welcome-spell.is-leaving .welcome-spell-content { opacity: 0; filter: blur(7px); transform: scale(1.04); transition-delay: 0s; transition-duration: .5s; }
.welcome-spell-content::before, .welcome-spell-content::after { content: ""; position: absolute; z-index: -1; top: 50%; left: 50%; aspect-ratio: 1; border: 1px solid rgba(217,183,123,.22); border-radius: 50%; transform: translate(-50%, -50%) scale(.35); opacity: 0; animation: welcome-ring 1.8s ease-out .2s forwards; }
.welcome-spell-content::before { width: min(26rem, 72vw); }
.welcome-spell-content::after { width: min(36rem, 92vw); border-color: rgba(168,119,200,.16); animation-delay: .42s; }
.welcome-spell-content > p { margin: 0 0 .8rem; color: var(--gold); font-size: .7rem; font-weight: 700; letter-spacing: .22em; text-transform: uppercase; }
.welcome-spell h2 { margin: 0; font-size: clamp(3rem, 9vw, 6.5rem); line-height: .96; letter-spacing: -.035em; text-shadow: 0 .2rem 1.6rem rgba(4,3,7,.9), 0 0 2.8rem rgba(168,119,200,.22); }
.welcome-spell h2 span { color: transparent; background: linear-gradient(100deg, #f7e7bd 10%, #dcbcec 48%, #bce6df 70%, #f7e7bd 90%); background-size: 220% auto; background-clip: text; -webkit-background-clip: text; animation: welcome-shimmer 1.8s linear infinite; }
.welcome-sparks { position: absolute; z-index: -1; top: 50%; left: 50%; width: 1px; height: 1px; }
.welcome-sparks span { position: absolute; width: .22rem; height: .22rem; border-radius: 50%; background: #fff7dd; box-shadow: 0 0 .65rem .12rem rgba(217,183,123,.65); opacity: 0; transform: rotate(var(--angle)) translateX(1.5rem) scale(.2); animation: welcome-spark 1.45s ease-out var(--delay) forwards; }
label { display: grid; gap: .45rem; color: var(--muted); font-size: .85rem; }
.login-card form { display: grid; gap: 1rem; margin-top: 2rem; }
input, select { width: 100%; border: 1px solid var(--line); border-radius: .75rem; background: rgba(8,7,12,.62); color: var(--ink); padding: .85rem 1rem; outline: none; }
input:focus, select:focus { border-color: var(--plum); box-shadow: 0 0 0 3px rgba(168,119,200,.15); }
.primary-button, .secondary-button { border: 0; border-radius: 999px; padding: .85rem 1.2rem; cursor: pointer; text-decoration: none; text-align: center; }
.primary-button { background: var(--ink); color: var(--night); font-weight: 700; }
.secondary-button { border: 1px solid var(--line); color: var(--ink); }
.form-error { color: #f3a7aa; }
@keyframes stardust-drift {
  0% { opacity: .12; transform: translate3d(0, .65rem, 0) scale(.75); }
  48% { opacity: .55; }
  100% { opacity: .18; transform: translate3d(var(--drift), -.85rem, 0) scale(1.12); }
}
@keyframes starfall {
  0%, 48% { opacity: 0; transform: rotate(var(--angle)) translate3d(-4rem, 0, 0) scaleX(.6); }
  52% { opacity: .82; }
  82% { opacity: .65; }
  92%, 100% { opacity: 0; transform: rotate(var(--angle)) translate3d(var(--distance), 0, 0) scaleX(1); }
}
@keyframes comet-pass {
  0%, 60% { opacity: 0; transform: rotate(var(--angle)) translate3d(-7rem, 0, 0) scaleX(.72); }
  64% { opacity: .9; }
  84% { opacity: .82; }
  94%, 100% { opacity: 0; transform: rotate(var(--angle)) translate3d(var(--distance), 0, 0) scaleX(1); }
}
@keyframes ward-glow {
  0%, 100% { box-shadow: 0 1.5rem 5rem rgba(4,3,7,.38), 0 0 2.6rem rgba(168,119,200,.04); }
  50% { box-shadow: 0 1.5rem 5rem rgba(4,3,7,.42), 0 0 3.8rem rgba(168,119,200,.11); }
}
@keyframes welcome-ring {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.35); }
  35% { opacity: .7; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.18); }
}
@keyframes welcome-spark {
  0% { opacity: 0; transform: rotate(var(--angle)) translateX(1.5rem) scale(.2); }
  24% { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--angle)) translateX(var(--distance)) scale(1); }
}
@keyframes welcome-shimmer {
  to { background-position: 220% center; }
}
@keyframes cursor-dust-fade {
  0% { opacity: .75; transform: translate(-50%, -50%) scale(.75); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dust-x)), calc(-50% + var(--dust-y))) scale(.15); }
}
@keyframes wand-spark {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.2) rotate(0); }
  32% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.8) rotate(80deg); }
}
@keyframes nav-dust-drift {
  0% { opacity: 0; transform: translate(0, -50%) scale(.2); }
  22% { opacity: .85; }
  70% { opacity: .42; }
  100% { opacity: 0; transform: translate(-3rem, -1rem) scale(.1); }
}
.magic-visitor-stage { position: fixed; z-index: 31; inset: 0; overflow: hidden; pointer-events: none; }
.magic-summon-button { position: fixed; z-index: 32; right: max(1rem, env(safe-area-inset-right)); bottom: max(1rem, env(safe-area-inset-bottom)); width: 3.25rem; height: 3.25rem; display: grid; place-items: center; padding: 0; border: 1px solid rgba(217,183,123,.48); border-radius: 50%; background: radial-gradient(circle at 38% 32%, rgba(74,53,91,.96), rgba(21,17,29,.94) 70%); color: #f6dfaa; box-shadow: 0 .7rem 2rem rgba(4,3,7,.48), 0 0 1.1rem rgba(168,119,200,.16), 0 0 0 1px rgba(255,255,255,.025) inset; cursor: pointer; transition: opacity .18s ease, transform .25s ease, border-color .25s ease, box-shadow .35s ease; }
.magic-summon-button::before { content: ""; position: absolute; inset: .3rem; border: 1px solid rgba(143,199,184,.22); border-radius: inherit; }
.magic-summon-button[hidden] { display: none; }
.magic-summon-button span { position: relative; font-size: 1.2rem; line-height: 1; text-shadow: 0 0 .65rem rgba(217,183,123,.75); transition: transform .4s ease; }
.magic-summon-button:hover { border-color: rgba(217,183,123,.8); box-shadow: 0 .7rem 2rem rgba(4,3,7,.5), 0 0 1.6rem rgba(168,119,200,.28); transform: translateY(-2px); }
.magic-summon-button:hover span { transform: rotate(32deg) scale(1.12); }
.magic-summon-button.is-casting { opacity: 0; pointer-events: none; animation: summon-pulse .8s ease-out; }
.magic-summon-button:disabled { opacity: .55; cursor: wait; }
.magic-visitor { position: absolute; pointer-events: none; will-change: transform, opacity; }
.magic-visitor--broom { top: var(--visitor-top); width: clamp(18rem, 34vw, 31rem); transform-origin: 50% 65%; }
.magic-visitor--broom.travels-rtl { left: 100%; animation: broom-story-rtl var(--visitor-duration) forwards; }
.magic-visitor--broom.travels-ltr { right: 100%; animation: broom-story-ltr var(--visitor-duration) forwards; }
.broom-cat-poses { position: relative; width: 100%; animation: broom-hover var(--visitor-duration) ease-in-out forwards; }
.broom-cat-poses.is-mirrored { transform: scaleX(-1); }
.broom-cat-poses img { display: block; width: 100%; height: auto; user-select: none; filter: drop-shadow(0 1rem 1.25rem rgba(4,3,7,.5)); }
.broom-cat-turn-1, .broom-cat-turn-2, .broom-cat-glance { position: absolute; inset: 0; opacity: 0; }
.broom-cat-turn-1 { animation: cat-turn-one var(--visitor-duration) steps(1, end) forwards; will-change: opacity; }
.broom-cat-turn-2 { animation: cat-turn-two var(--visitor-duration) steps(1, end) forwards; will-change: opacity; }
.broom-cat-glance { animation: cat-glance var(--visitor-duration) steps(1, end) forwards; will-change: opacity; }
.broom-cat-flight { animation: cat-flight-pose var(--visitor-duration) steps(1, end) forwards; will-change: opacity; }
.broom-rainbow-canvas { position: fixed; z-index: -1; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.magic-visitor--paw { top: var(--visitor-top); width: clamp(17rem, 35vw, 30rem); }
.magic-visitor--paw.enters-right { right: 0; animation: cat-paw-story-right var(--visitor-duration) forwards; }
.magic-visitor--paw.enters-left { left: 0; animation: cat-paw-story-left var(--visitor-duration) forwards; }
.cat-paw-figure { position: relative; width: 100%; }
.cat-paw-figure.is-mirrored { transform: scaleX(-1); }
.cat-paw-image { display: block; width: 100%; height: auto; filter: drop-shadow(0 .8rem 1.15rem rgba(4,3,7,.5)); }
.magic-claw-mark { position: fixed; z-index: -1; width: clamp(6.5rem, 13vw, 10rem); height: .58rem; opacity: 0; background: linear-gradient(90deg, #fff7d8 0, #d9b77b 28%, rgba(168,119,200,.88) 82%, rgba(168,119,200,.18) 100%); clip-path: polygon(0 37%, 18% 28%, 38% 47%, 61% 25%, 81% 41%, 100% 32%, 100% 61%, 81% 56%, 61% 47%, 38% 68%, 18% 49%, 0 59%); filter: drop-shadow(0 0 .18rem rgba(217,183,123,.52)); animation: claw-cut-linger 1.88s var(--scratch-delay) ease-out forwards; }
.magic-claw-mark.trails-right { transform-origin: left center; }
.magic-claw-mark.trails-left { transform-origin: right center; background: linear-gradient(270deg, #fff7d8 0, #d9b77b 28%, rgba(168,119,200,.88) 82%, rgba(168,119,200,.18) 100%); }
.magic-visitor--peek { width: clamp(11rem, 22vw, 17rem); }
.magic-visitor--peek.peeks-bottom-left { bottom: 0; left: max(1rem, 4vw); animation: cat-peek-bottom var(--visitor-duration) forwards; }
.magic-visitor--peek.peeks-bottom-right { right: max(1rem, 4vw); bottom: 0; animation: cat-peek-bottom var(--visitor-duration) forwards; }
.magic-visitor--peek.peeks-left { top: var(--visitor-top); left: 0; animation: cat-peek-left var(--visitor-duration) forwards; }
.magic-visitor--peek.peeks-right { top: var(--visitor-top); right: 0; animation: cat-peek-right var(--visitor-duration) forwards; }
.cat-peek-figure { position: relative; width: 100%; transform-origin: center; }
.peeks-bottom-right .cat-peek-figure { transform: scaleX(-1); }
.peeks-left .cat-peek-figure { transform: rotate(90deg); }
.peeks-right .cat-peek-figure { transform: rotate(-90deg); }
.cat-peek-image { position: absolute; inset: 0; display: block; width: 100%; height: auto; opacity: 0; filter: drop-shadow(0 1rem 1.2rem rgba(4,3,7,.55)); will-change: opacity; }
.cat-peek-frame-1 { position: relative; opacity: 1; }
.cat-peek-frame-2 { animation: cat-meow-frame-two var(--visitor-duration) steps(1, end) forwards; }
.cat-peek-frame-3 { animation: cat-meow-frame-three var(--visitor-duration) steps(1, end) forwards; }
.cat-peek-frame-4 { animation: cat-meow-frame-four var(--visitor-duration) steps(1, end) forwards; }
.cat-peek-frame-5 { animation: cat-meow-frame-five var(--visitor-duration) steps(1, end) forwards; }
.cat-peek-frame-6 { animation: cat-meow-frame-six var(--visitor-duration) steps(1, end) forwards; }
.cat-peek-glints { position: absolute; inset: 0; }
.cat-peek-glints span { position: absolute; top: 45%; width: 12%; aspect-ratio: 1; opacity: 0; transform: translate(-50%, -50%) scale(.15) rotate(0); animation: cat-eye-glint var(--visitor-duration) ease-out forwards; }
.cat-peek-glints span:first-child { left: 35%; }
.cat-peek-glints span:last-child { left: 64%; animation-delay: .12s; }
.cat-peek-glints span::before, .cat-peek-glints span::after { content: ""; position: absolute; top: 50%; left: 50%; border-radius: 999px; background: #fff8d6; box-shadow: 0 0 .55rem rgba(247,209,112,.88); transform: translate(-50%, -50%); }
.cat-peek-glints span::before { width: 100%; height: 2px; }
.cat-peek-glints span::after { width: 2px; height: 100%; }
.magic-visitor--butterfly { top: var(--visitor-top); width: clamp(5.5rem, 11vw, 9rem); }
.magic-visitor--butterfly.flies-ltr { left: -11rem; }
.magic-visitor--butterfly.flies-rtl { right: -11rem; }
.butterfly-figure { position: relative; width: 100%; transform-style: preserve-3d; animation: butterfly-bob .58s ease-in-out infinite alternate; }
.butterfly-body, .butterfly-wing { display: block; width: 100%; height: auto; filter: drop-shadow(0 .55rem .75rem rgba(4,3,7,.45)); }
.butterfly-body { position: relative; clip-path: polygon(43% 0, 57% 0, 57% 100%, 43% 100%); }
.butterfly-wing { position: absolute; inset: 0; will-change: transform; }
.butterfly-wing-left { clip-path: polygon(0 0, 50% 0, 50% 100%, 0 100%); transform-origin: 50% 54%; animation: butterfly-wing-left .2s ease-in-out infinite alternate; }
.butterfly-wing-right { clip-path: polygon(50% 0, 100% 0, 100% 100%, 50% 100%); transform-origin: 50% 54%; animation: butterfly-wing-right .2s ease-in-out infinite alternate; }
.butterfly-dust-canvas { position: fixed; z-index: -1; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.magic-visitor--book { top: var(--visitor-top); left: 50%; width: clamp(11rem, 24vw, 18rem); transform-style: preserve-3d; }
.magic-visitor--book.book-enters-left { animation: enchanted-book-story-left var(--visitor-duration) forwards; }
.magic-visitor--book.book-enters-right { animation: enchanted-book-story-right var(--visitor-duration) forwards; }
.enchanted-book-figure { position: relative; width: 100%; transform-style: preserve-3d; animation: enchanted-book-hover 1.15s ease-in-out infinite alternate; }
.enchanted-book-image { display: block; width: 100%; height: auto; filter: drop-shadow(0 1rem 1.2rem rgba(4,3,7,.58)); backface-visibility: hidden; }
.enchanted-book-open { position: absolute; inset: 0; opacity: 0; transform-origin: 50% 65%; animation: enchanted-book-open var(--visitor-duration) ease-in-out forwards; }
.enchanted-book-closed { position: relative; transform-origin: 50% 65%; animation: enchanted-book-closed var(--visitor-duration) ease-in-out forwards; }
.enchanted-book-glyphs { position: absolute; z-index: 2; inset: 0; }
.enchanted-book-glyphs span { position: absolute; top: 47%; left: 50%; opacity: 0; color: #fff0ba; font: 700 clamp(.8rem, 2vw, 1.25rem)/1 Georgia, serif; text-shadow: 0 0 .45rem rgba(217,183,123,.9), 0 0 1rem rgba(168,119,200,.62); animation: enchanted-glyph-rise var(--glyph-duration) var(--glyph-delay) ease-out forwards; }
.magic-visitor--bubbles { inset: 0; width: 100%; height: 100%; overflow: hidden; }
.soap-bubble { position: absolute; display: block; border: 1px solid rgba(255,255,255,.52); border-radius: 50%; opacity: 0; background: radial-gradient(circle at 31% 25%, rgba(255,255,255,.92) 0 2%, rgba(255,255,255,.34) 3%, transparent 11%), radial-gradient(circle at 68% 73%, hsla(var(--bubble-hue), 82%, 72%, .22), transparent 34%), conic-gradient(from 42deg, rgba(245,188,255,.2), rgba(154,231,255,.18), rgba(255,236,164,.2), rgba(245,188,255,.2)); box-shadow: inset .15rem .15rem .5rem rgba(255,255,255,.25), inset -.2rem -.25rem .55rem rgba(120,88,170,.16), 0 0 .6rem rgba(183,211,255,.12); backdrop-filter: blur(.4px); will-change: transform, opacity; }
.soap-bubble::after { content: ""; position: absolute; inset: 12%; border-radius: inherit; border-top: 1px solid rgba(255,255,255,.34); transform: rotate(-28deg); }
@keyframes summon-pulse {
  0% { box-shadow: 0 0 0 0 rgba(217,183,123,.5); }
  100% { box-shadow: 0 0 0 1.5rem rgba(217,183,123,0); }
}
@keyframes broom-story-rtl {
  0% { opacity: 1; transform: translate3d(4rem, 1rem, 0) rotate(1deg); animation-timing-function: cubic-bezier(.08,.82,.18,1); }
  34% { opacity: 1; transform: translate3d(calc(-50vw - 42%), -1rem, 0) rotate(-1deg); }
  45.7% { opacity: 1; transform: translate3d(calc(-50vw - 42%), -1rem, 0) rotate(-1deg); animation-timing-function: ease-in; }
  51.7% { opacity: 1; transform: translate3d(calc(-50vw - 42%), 1rem, 0) rotate(-3deg); animation-timing-function: cubic-bezier(.62,0,.92,.35); }
  61.7% { opacity: 1; transform: translate3d(calc(-72vw - 42%), -4rem, 0) rotate(9deg); animation-timing-function: cubic-bezier(.28,.58,.36,1); }
  73.7%, 100% { opacity: 1; transform: translate3d(calc(-155vw - 42%), -22vh, 0) rotate(15deg); }
}
@keyframes broom-story-ltr {
  0% { opacity: 1; transform: translate3d(-4rem, 1rem, 0) rotate(-1deg); animation-timing-function: cubic-bezier(.08,.82,.18,1); }
  34% { opacity: 1; transform: translate3d(calc(50vw + 42%), -1rem, 0) rotate(1deg); }
  45.7% { opacity: 1; transform: translate3d(calc(50vw + 42%), -1rem, 0) rotate(1deg); animation-timing-function: ease-in; }
  51.7% { opacity: 1; transform: translate3d(calc(50vw + 42%), 1rem, 0) rotate(3deg); animation-timing-function: cubic-bezier(.62,0,.92,.35); }
  61.7% { opacity: 1; transform: translate3d(calc(72vw + 42%), -4rem, 0) rotate(-9deg); animation-timing-function: cubic-bezier(.28,.58,.36,1); }
  73.7%, 100% { opacity: 1; transform: translate3d(calc(155vw + 42%), -22vh, 0) rotate(-15deg); }
}
@keyframes cat-paw-story-right {
  0% { transform: translate3d(108%, 0, 0) rotate(0); animation-timing-function: cubic-bezier(.14,.82,.22,1); }
  22% { transform: translate3d(17%, 0, 0) rotate(0); animation-timing-function: cubic-bezier(.25,.7,.3,1); }
  38% { transform: translate3d(-2%, 0, 0) rotate(0); }
  53% { transform: translate3d(2%, 0, 0) rotate(0); }
  66% { transform: translate3d(17%, 0, 0) rotate(0); animation-timing-function: cubic-bezier(.7,0,.9,.25); }
  100% { transform: translate3d(110%, 0, 0) rotate(0); }
}
@keyframes cat-paw-story-left {
  0% { transform: translate3d(-108%, 0, 0) rotate(0); animation-timing-function: cubic-bezier(.14,.82,.22,1); }
  22% { transform: translate3d(-17%, 0, 0) rotate(0); animation-timing-function: cubic-bezier(.25,.7,.3,1); }
  38% { transform: translate3d(2%, 0, 0) rotate(0); }
  53% { transform: translate3d(-2%, 0, 0) rotate(0); }
  66% { transform: translate3d(-17%, 0, 0) rotate(0); animation-timing-function: cubic-bezier(.7,0,.9,.25); }
  100% { transform: translate3d(-110%, 0, 0) rotate(0); }
}
@keyframes cat-peek-bottom {
  0% { transform: translate3d(0, 94%, 0); animation-timing-function: cubic-bezier(.16,.82,.23,1); }
  24% { transform: translate3d(0, 20%, 0); }
  32% { transform: translate3d(0, 15%, 0); }
  62% { transform: translate3d(0, 15%, 0); animation-timing-function: ease-in; }
  67% { transform: translate3d(0, 20%, 0); animation-timing-function: cubic-bezier(.68,0,.88,.32); }
  81%, 100% { transform: translate3d(0, 96%, 0); }
}
@keyframes cat-peek-left {
  0% { transform: translate3d(-94%, 0, 0); animation-timing-function: cubic-bezier(.16,.82,.23,1); }
  24% { transform: translate3d(-20%, 0, 0); }
  32% { transform: translate3d(-15%, 0, 0); }
  62% { transform: translate3d(-15%, 0, 0); animation-timing-function: ease-in; }
  67% { transform: translate3d(-20%, 0, 0); animation-timing-function: cubic-bezier(.68,0,.88,.32); }
  81%, 100% { transform: translate3d(-96%, 0, 0); }
}
@keyframes cat-peek-right {
  0% { transform: translate3d(94%, 0, 0); animation-timing-function: cubic-bezier(.16,.82,.23,1); }
  24% { transform: translate3d(20%, 0, 0); }
  32% { transform: translate3d(15%, 0, 0); }
  62% { transform: translate3d(15%, 0, 0); animation-timing-function: ease-in; }
  67% { transform: translate3d(20%, 0, 0); animation-timing-function: cubic-bezier(.68,0,.88,.32); }
  81%, 100% { transform: translate3d(96%, 0, 0); }
}
@keyframes butterfly-bob {
  0% { translate: 0 -.18rem; }
  100% { translate: 0 .35rem; }
}
@keyframes butterfly-wing-left {
  0% { transform: perspective(420px) rotateY(68deg) rotateZ(1deg); }
  100% { transform: perspective(420px) rotateY(3deg) rotateZ(0); }
}
@keyframes butterfly-wing-right {
  0% { transform: perspective(420px) rotateY(-68deg) rotateZ(-1deg); }
  100% { transform: perspective(420px) rotateY(-3deg) rotateZ(0); }
}
@keyframes enchanted-book-story-left {
  0% { transform: translate3d(calc(-50vw - 65%), -50%, 0) rotate(-13deg) scale(.76); animation-timing-function: cubic-bezier(.12,.78,.22,1); }
  20% { transform: translate3d(-50%, -50%, 0) rotate(2deg) scale(1.03); }
  28%, 72% { transform: translate3d(-50%, -50%, 0) rotate(0) scale(1); }
  80% { transform: translate3d(-50%, -54%, 0) rotate(3deg) scale(1); animation-timing-function: cubic-bezier(.7,0,.92,.28); }
  100% { transform: translate3d(calc(50vw + 65%), -68%, 0) rotate(14deg) scale(.78); }
}
@keyframes enchanted-book-story-right {
  0% { transform: translate3d(calc(50vw + 65%), -50%, 0) rotate(13deg) scale(.76); animation-timing-function: cubic-bezier(.12,.78,.22,1); }
  20% { transform: translate3d(-50%, -50%, 0) rotate(-2deg) scale(1.03); }
  28%, 72% { transform: translate3d(-50%, -50%, 0) rotate(0) scale(1); }
  80% { transform: translate3d(-50%, -54%, 0) rotate(-3deg) scale(1); animation-timing-function: cubic-bezier(.7,0,.92,.28); }
  100% { transform: translate3d(calc(-50vw - 65%), -68%, 0) rotate(-14deg) scale(.78); }
}
@keyframes enchanted-book-hover {
  0% { translate: 0 -.25rem; rotate: -1deg; }
  100% { translate: 0 .38rem; rotate: 1deg; }
}
@keyframes enchanted-book-closed {
  0%, 27.5% { opacity: 1; transform: perspective(550px) rotateX(0) scaleY(1); }
  30.5%, 69.5% { opacity: 0; transform: perspective(550px) rotateX(72deg) scaleY(.72); }
  72.5%, 100% { opacity: 1; transform: perspective(550px) rotateX(0) scaleY(1); }
}
@keyframes enchanted-book-open {
  0%, 28.5% { opacity: 0; transform: perspective(550px) rotateX(-68deg) scaleY(.7); }
  31.5%, 68.5% { opacity: 1; transform: perspective(550px) rotateX(0) scaleY(1); }
  71.5%, 100% { opacity: 0; transform: perspective(550px) rotateX(68deg) scaleY(.72); }
}
@keyframes enchanted-glyph-rise {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.3) rotate(0); }
  16% { opacity: .96; }
  68% { opacity: .72; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--glyph-x)), calc(-50% + var(--glyph-y))) scale(1.18) rotate(150deg); }
}
@keyframes cat-eye-glint {
  0%, 17% { opacity: 0; transform: translate(-75%, -65%) scale(.12) rotate(0); }
  21% { opacity: .95; transform: translate(-50%, -50%) scale(.88) rotate(38deg); }
  25% { opacity: 0; transform: translate(-20%, -72%) scale(1.35) rotate(76deg); }
  28% { opacity: .88; transform: translate(-70%, -32%) scale(.45) rotate(98deg); }
  32% { opacity: 0; transform: translate(-38%, -65%) scale(1.18) rotate(142deg); }
  35% { opacity: .9; transform: translate(-58%, -55%) scale(.35) rotate(170deg); }
  40%, 100% { opacity: 0; transform: translate(-25%, -30%) scale(1.25) rotate(220deg); }
}
@keyframes cat-meow-frame-two {
  0%, 16% { opacity: 0; }
  17%, 21% { opacity: 1; }
  22%, 38% { opacity: 0; }
  39%, 43% { opacity: 1; }
  44%, 100% { opacity: 0; }
}
@keyframes cat-meow-frame-three {
  0%, 20% { opacity: 0; }
  21%, 25% { opacity: 1; }
  26%, 36% { opacity: 0; }
  37%, 39% { opacity: 1; }
  40%, 100% { opacity: 0; }
}
@keyframes cat-meow-frame-four {
  0%, 24% { opacity: 0; }
  25%, 29% { opacity: 1; }
  30%, 100% { opacity: 0; }
}
@keyframes cat-meow-frame-five {
  0%, 28% { opacity: 0; }
  29%, 33% { opacity: 1; }
  34%, 100% { opacity: 0; }
}
@keyframes cat-meow-frame-six {
  0%, 32% { opacity: 0; }
  33%, 37% { opacity: 1; }
  38%, 100% { opacity: 0; }
}
@keyframes claw-cut-linger {
  0% { opacity: 0; transform: scaleX(.02); }
  30%, 62% { opacity: .98; transform: scaleX(1); }
  100% { opacity: 0; transform: scaleX(1.03); }
}
@keyframes broom-hover {
  0%, 31%, 48.7%, 100% { translate: 0 0; }
  37% { translate: 0 .35rem; }
  43% { translate: 0 -.3rem; }
}
@keyframes cat-flight-pose {
  0%, 100% { opacity: 1; }
}
@keyframes cat-turn-one {
  0%, 2.4% { opacity: 0; }
  3.4%, 6.4% { opacity: 1; }
  7.4%, 44.7% { opacity: 0; }
  45.7%, 47.7% { opacity: 1; }
  48.7%, 100% { opacity: 0; }
}
@keyframes cat-turn-two {
  0%, 4.4% { opacity: 0; }
  5.4%, 8.4% { opacity: 1; }
  9.4%, 41.7% { opacity: 0; }
  42.7%, 46.7% { opacity: 1; }
  47.7%, 100% { opacity: 0; }
}
@keyframes cat-glance {
  0%, 6.4% { opacity: 0; }
  7.4%, 43.7% { opacity: 1; }
  44.7%, 100% { opacity: 0; }
}
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 2rem; margin-bottom: 2.5rem; }
.page-heading h1, .workbook-heading h1 { font-size: clamp(2.7rem, 6vw, 5rem); }
.filter-bar { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: .8rem; margin-bottom: 1.2rem; }
.history-list { display: grid; gap: .8rem; }
.history-entry { padding: 1.35rem 1.5rem; }
.history-entry header { display: flex; justify-content: space-between; color: var(--muted); font-size: .85rem; }
.history-entry header div { display: flex; gap: .7rem; }
.history-entry h2 { font-family: inherit; font-size: 1rem; margin: 1rem 0 .5rem; }
.history-entry p { margin: 0; color: var(--muted); line-height: 1.55; white-space: pre-wrap; }
.history-entry-preview { position: relative; max-height: 10.5rem; overflow: hidden; cursor: pointer; transition: transform .18s, border-color .18s, background .18s; }
.history-entry-preview::after { content: ""; position: absolute; right: 0; bottom: 0; left: 0; height: 3.4rem; background: linear-gradient(transparent, rgba(31,26,42,.98)); pointer-events: none; }
.history-entry-preview:hover, .history-entry-preview:focus-visible { transform: translateY(-2px); border-color: rgba(217,183,123,.5); background: rgba(39,31,52,.94); outline: none; }
.history-entry-preview h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-entry-preview p { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; white-space: normal; }
.history-dialog { width: min(46rem, calc(100% - 2rem)); max-height: calc(100dvh - 2rem); padding: 0; overflow: auto; border: 1px solid rgba(217,183,123,.34); border-radius: 1.35rem; background: #1f1a2a; color: var(--ink); box-shadow: 0 2rem 6rem rgba(3,2,5,.7); }
.history-dialog::backdrop { background: rgba(7,5,10,.74); backdrop-filter: blur(7px); }
.history-dialog .history-entry { border: 0; border-radius: inherit; background: transparent; backdrop-filter: none; padding: clamp(1.5rem, 5vw, 2.5rem); }
.history-dialog .history-entry h2 { padding-right: 2rem; font-size: clamp(1.1rem, 3vw, 1.35rem); }
.history-dialog-close { position: sticky; z-index: 2; top: .85rem; float: right; margin: .85rem .85rem 0 0; width: 2.5rem; height: 2.5rem; border: 1px solid var(--line); border-radius: 50%; background: rgba(17,15,24,.88); color: var(--ink); font-size: 1.55rem; line-height: 1; cursor: pointer; }
.route-pill { display: inline-block; margin-top: .9rem; padding: .25rem .55rem; border-radius: 999px; background: rgba(168,119,200,.15); color: #d9b9ec; font-size: .72rem; }
.pager, .card-navigation { margin-top: 1.5rem; display: flex; justify-content: center; align-items: center; gap: 1rem; }
button:disabled { opacity: .35; cursor: not-allowed; }
.empty-state { padding: 2.5rem; color: var(--muted); }
.empty-state h2 { color: var(--ink); }
.scriptorium-tabs { width: fit-content; display: flex; gap: .25rem; margin-bottom: 2rem; padding: .3rem; border: 1px solid var(--line); border-radius: 999px; background: rgba(17,15,24,.48); }
.scriptorium-tabs a { padding: .6rem 1rem; border-radius: 999px; color: var(--muted); text-decoration: none; }
.scriptorium-tabs a[aria-current="page"] { background: rgba(255,255,255,.08); color: var(--ink); }
.book-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1rem; }
.book-card { display: flex; flex-direction: column; overflow: hidden; text-decoration: none; }
.book-card--coming-soon { border-color: rgba(217,183,123,.32); }
.book-card--coming-soon .book-cover-placeholder { background: linear-gradient(145deg, rgba(217,183,123,.16), rgba(168,119,200,.2)); }
.book-card-cover { display: block; text-decoration: none; }
.book-card img { width: 100%; height: 20rem; object-fit: cover; object-position: center top; display: block; }
.book-cover-placeholder { height: 20rem; padding: 2rem; display: grid; place-items: center; background: linear-gradient(145deg, rgba(168,119,200,.28), rgba(79,159,138,.12)); border-bottom: 1px solid var(--line); }
.book-cover-placeholder span { max-width: 14rem; text-align: center; font: 500 2rem/1.08 Georgia, "Times New Roman", serif; }
.book-card .book-card-body { flex: 1; display: flex; flex-direction: column; padding: 1.4rem; }
.book-card .book-cover-placeholder { padding: 2rem; }
.book-card h2 { margin: .4rem 0; font-size: 1.6rem; }
.book-card h2 a { text-decoration: none; }
.book-card p:last-child { color: var(--muted); }
.book-coming-soon { width: fit-content; padding: .28rem .62rem; border: 1px solid rgba(217,183,123,.4); border-radius: 999px; color: var(--gold); letter-spacing: .08em; text-transform: uppercase; }
.book-teaser { max-width: 32rem; color: var(--muted); line-height: 1.55; }
.book-card-actions { display: flex; gap: .6rem; margin-top: auto; padding-top: 1.2rem; }
.book-card-actions a { flex: 1; padding: .65rem .8rem; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); text-align: center; text-decoration: none; }
.book-card-actions a:last-child { border-color: rgba(217,183,123,.38); color: var(--gold); }
.back-link { color: var(--muted); text-decoration: none; }
.workbook-heading { max-width: 58rem; margin: 0 auto 1.4rem; }
.workbook-heading h1 { margin-bottom: .75rem; }
.workbook-author { margin: 0 0 1.4rem; }
.workbook-tools { display: flex; align-items: end; gap: 1rem; }
.search-box { flex: 1; }
.flashcard { max-width: 58rem; margin: 0 auto; padding: clamp(1.5rem, 5vw, 3.4rem); }
.flashcard header { display: flex; align-items: center; gap: 1rem; border-bottom: 1px solid var(--line); padding-bottom: 1.2rem; }
.flashcard header p { flex: 0 0 auto; min-width: 2.35rem; height: 2.35rem; margin: 0; padding: 0 .45rem; display: grid; place-items: center; border: 1px solid rgba(217,183,123,.55); border-radius: 999px; color: var(--gold); font-weight: 700; }
.flashcard h2 { min-width: 0; margin: 0; font-size: clamp(2.15rem, 6vw, 4.5rem); overflow-wrap: anywhere; }
.card-fields { display: grid; gap: 1.2rem; margin-top: 1.5rem; }
.card-fields h3 { margin: 0 0 .35rem; color: var(--mint); font-size: .76rem; text-transform: uppercase; letter-spacing: .12em; }
.card-fields p { margin: 0; color: #ddd3e5; white-space: pre-wrap; line-height: 1.65; }
.card-caption p { color: var(--muted); font-size: .92rem; font-style: italic; }
.card-media { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr)); gap: 1rem; align-items: start; }
.card-image-button img { display: block; width: 100%; max-height: 32rem; object-fit: contain; border-radius: .8rem; background: #f5f2eb; }
.card-image-button { width: 100%; padding: 0; overflow: hidden; border: 0; border-radius: .8rem; background: transparent; cursor: zoom-in; }
.card-image-button:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.card-content-section { display: grid; gap: 1.2rem; padding: 1.2rem; border: 1px solid rgba(241,222,255,.09); border-radius: 1rem; }
.card-reference-link { grid-column: 1 / -1; width: fit-content; padding: .7rem 1rem; border: 1px solid rgba(217,183,123,.35); border-radius: 999px; color: var(--gold); text-decoration: none; }
.card-reference-link:hover { border-color: var(--gold); background: rgba(217,183,123,.08); }
.search-results { max-width: 58rem; margin: 0 auto 1rem; border: 1px solid var(--line); border-radius: 1rem; overflow: hidden; background: #191520; }
.search-results button { width: 100%; display: flex; justify-content: space-between; gap: 1rem; padding: .8rem 1rem; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.search-results span { color: var(--muted); font-size: .8rem; }
.card-position-button { min-width: 6.5rem; color: var(--gold) !important; border-color: rgba(217,183,123,.34) !important; }
.card-jump-dialog { width: min(24rem, calc(100% - 2rem)); padding: 0; border: 1px solid rgba(217,183,123,.34); border-radius: 1.35rem; background: #1f1a2a; color: var(--ink); box-shadow: 0 2rem 6rem rgba(3,2,5,.7); }
.card-jump-dialog::backdrop { background: rgba(7,5,10,.74); backdrop-filter: blur(7px); }
.card-jump-dialog form { display: grid; gap: 1rem; padding: 1.5rem; }
.card-jump-dialog h2 { margin: 0; padding-right: 2.5rem; font-size: 1.8rem; }
.card-jump-close { position: absolute; top: .75rem; right: .75rem; width: 2.5rem; height: 2.5rem; border: 1px solid var(--line); border-radius: 50%; background: rgba(17,15,24,.88); color: var(--ink); font-size: 1.55rem; line-height: 1; cursor: pointer; }
.image-lightbox { width: fit-content; max-width: calc(100vw - 2rem); max-height: calc(100dvh - 2rem); padding: 0; border: 0; background: transparent; color: var(--ink); box-shadow: none; overflow: visible; }
.image-lightbox::backdrop { background: rgba(5,4,8,.84); backdrop-filter: blur(8px); }
.image-lightbox img { display: block; width: auto; height: auto; max-width: calc(100vw - 2rem); max-height: calc(100dvh - 2rem); object-fit: contain; background: #f5f2eb; }
.image-lightbox-close { position: fixed; top: max(1rem, env(safe-area-inset-top)); right: max(1rem, env(safe-area-inset-right)); z-index: 2; width: 2.75rem; height: 2.75rem; display: grid; place-items: center; padding: 0; border: 1px solid rgba(255,255,255,.2); border-radius: 50%; background: rgba(17,15,24,.9); color: var(--ink); cursor: pointer; }
.image-lightbox-close span { position: relative; width: 1.15rem; height: 1.15rem; }
.image-lightbox-close span::before, .image-lightbox-close span::after { content: ""; position: absolute; top: 50%; left: 50%; width: 1.15rem; height: 2px; border-radius: 999px; background: currentColor; transform-origin: center; }
.image-lightbox-close span::before { transform: translate(-50%, -50%) rotate(45deg); }
.image-lightbox-close span::after { transform: translate(-50%, -50%) rotate(-45deg); }
.study-setup, .study-complete { max-width: 58rem; margin: 0 auto; }
.study-session { max-width: 34rem; margin: 0 auto; }
.study-setup .page-heading { align-items: center; }
.study-setup form { display: grid; gap: 1.5rem; }
.study-mode-grid, .study-size-options { min-width: 0; margin: 0; padding: 0; border: 0; }
.study-mode-grid legend, .study-size-options legend { margin-bottom: .8rem; color: var(--gold); font-size: .72rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.study-mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.study-mode-option { display: block; cursor: pointer; }
.study-mode-option input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.study-mode-option span { min-height: 9rem; display: flex; flex-direction: column; padding: 1.2rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--panel); transition: border-color .18s, background .18s; }
.study-mode-option strong { color: var(--ink); font: 500 1.35rem/1.1 Georgia, "Times New Roman", serif; }
.study-mode-option small { margin-top: .55rem; color: var(--muted); font-size: 1rem; line-height: 1.45; }
.study-mode-option em { margin-top: auto; padding-top: .8rem; color: var(--gold); font-size: .9rem; font-style: normal; }
.study-mode-option input:checked + span { border-color: rgba(217,183,123,.65); background: rgba(52,41,63,.92); }
.study-mode-option input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 2px; }
.study-mode-option.is-unavailable { cursor: not-allowed; opacity: .38; }
.study-size-options { display: flex; justify-content: center; gap: .6rem; }
.study-size-options legend { width: 100%; text-align: center; }
.study-size-options label { display: block; cursor: pointer; }
.study-size-options input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.study-size-options span { min-width: 4.5rem; display: block; padding: .7rem 1rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); text-align: center; }
.study-size-options input:checked + span { border-color: var(--gold); color: var(--ink); background: rgba(217,183,123,.1); }
.study-start { justify-self: center; min-width: 12rem; }
.study-session-header { display: flex; justify-content: flex-end; align-items: center; margin-bottom: 1rem; }
.study-session-header #study-exit { position: absolute; top: clamp(3rem, 7vw, 7rem); right: 2rem; width: auto; display: inline-flex; align-items: center; gap: .5rem; }
.study-stop-icon { width: 1em; height: 1em; flex: 0 0 auto; fill: currentColor; }
.study-exit-label-short { display: none; }
.study-session-header p { margin: 0; color: var(--muted); }
.study-card { position: relative; width: 100%; min-height: 14rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2rem; padding: 2rem 2rem 4rem; border: 1px solid rgba(217,183,123,.34); border-radius: 1.5rem; background: var(--panel); color: var(--ink); cursor: pointer; text-align: center; }
.study-card:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.study-card-footer { position: absolute; right: 1.25rem; bottom: .3rem; left: 1.25rem; display: flex; align-items: baseline; gap: 1rem; min-width: 0; }
.study-card-context { min-width: 0; flex: 1 1 auto; overflow: hidden; color: var(--gold); font-size: .62rem; font-weight: 700; letter-spacing: .1em; text-align: left; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.study-card-face { width: 100%; display: grid; justify-items: center; gap: 1.4rem; }
.study-term { max-width: 100%; font: 500 clamp(2.3rem, 6vw, 4.5rem)/1 Georgia, "Times New Roman", serif; overflow-wrap: anywhere; }
.study-term-small { color: var(--muted); font-size: clamp(1.2rem, 4vw, 2rem); }
.study-blurred-term { opacity: .62; font: 500 clamp(2.3rem, 6vw, 4.5rem)/1 Georgia, "Times New Roman", serif; filter: blur(.7rem); user-select: none; }
.study-definition { max-width: 29rem; color: #ddd3e5; font-size: clamp(1rem, 2vw, 1.25rem); line-height: 1.5; }
.study-answer { color: var(--ink); }
.study-card-image { display: block; width: auto; max-width: min(100%, 34rem); max-height: 20rem; object-fit: contain; border-radius: 1rem; background: #f5f2eb; }
.study-card-hint { flex: 0 0 auto; color: var(--muted); font-size: .72rem; white-space: nowrap; }
.study-answer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-top: 1rem; }
.study-explanation { margin-top: 1rem; padding: 1rem 1.2rem; border: 1px solid var(--line); border-radius: 1rem; background: rgba(17,15,24,.45); }
.study-explanation summary { color: var(--gold); cursor: pointer; }
.study-explanation-content { display: grid; gap: 1rem; margin: 1rem 0; color: #ddd3e5; line-height: 1.65; }
.study-explanation-content p { margin: 0; white-space: pre-wrap; }
.study-explanation-section { display: grid; gap: 1rem; }
.study-explanation-image { display: block; width: 100%; max-height: 32rem; object-fit: contain; border-radius: .8rem; background: #f5f2eb; }
.study-explanation-caption { color: var(--muted); font-size: .92rem; font-style: italic; }
.study-explanation a { color: var(--gold); }
.study-complete { text-align: center; }
.study-complete h1 { font-size: clamp(3rem, 8vw, 6rem); }
.study-complete .lede { margin-right: auto; margin-left: auto; }
.study-complete-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .7rem; }
.study-complete-actions a { text-decoration: none; }
@media (max-width: 760px) {
  .site-header { height: 4.9rem; padding: .85rem 1rem; gap: .75rem; }
  .brand-mark { width: 2.35rem; height: 2.35rem; }
  .wand-menu-toggle { position: relative; flex: 0 0 auto; width: 2.9rem; height: 2.9rem; display: grid; place-items: center; padding: 0; border: 1px solid rgba(217,183,123,.35); border-radius: 50%; background: rgba(23,19,31,.76); color: var(--gold); cursor: pointer; transition: border-color .25s, background .25s, box-shadow .25s; }
  .wand-menu-toggle[aria-expanded="true"] { border-color: rgba(217,183,123,.7); background: rgba(42,31,53,.94); box-shadow: 0 0 1.6rem rgba(168,119,200,.25); }
  .wand-icon { width: 2.45rem; height: 2.45rem; display: block; object-fit: contain; filter: drop-shadow(0 0 .38rem rgba(217,183,123,.28)); transition: transform .55s cubic-bezier(.2,.75,.25,1), filter .45s ease; }
  .wand-menu-toggle[aria-expanded="true"] .wand-icon { transform: rotate(38deg) scale(1.06); }
  .wand-menu-toggle[aria-expanded="true"] .wand-icon { filter: drop-shadow(0 0 .55rem rgba(217,183,123,.52)); }
  .wand-toggle-spark { position: absolute; top: .55rem; left: .5rem; width: .75rem; height: .75rem; pointer-events: none; animation: wand-spark .7s ease-out forwards; }
  .wand-toggle-spark::before, .wand-toggle-spark::after { content: ""; position: absolute; top: 50%; left: 50%; border-radius: 999px; background: #fff1bd; box-shadow: 0 0 .6rem rgba(217,183,123,.85); transform: translate(-50%, -50%); }
  .wand-toggle-spark::before { width: 100%; height: 1px; }
  .wand-toggle-spark::after { width: 1px; height: 100%; }
  .nav-panel { position: absolute; top: calc(100% + .55rem); right: 1rem; left: 1rem; display: grid; gap: .65rem; padding: .8rem; border: 1px solid rgba(217,183,123,.26); border-radius: 1.2rem; background: linear-gradient(145deg, rgba(40,30,52,.98), rgba(18,15,25,.98)); box-shadow: 0 1.2rem 3rem rgba(4,3,7,.58), 0 1px 0 rgba(255,255,255,.04) inset; backdrop-filter: blur(22px); opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(-.7rem) scale(.98); transform-origin: top right; transition: opacity .22s ease, visibility .22s, transform .3s cubic-bezier(.2,.75,.25,1); }
  .site-header.menu-open .nav-panel { opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0) scale(1); }
  .main-nav { display: grid; gap: .25rem; }
  .main-nav a { padding: .8rem 1rem; border-radius: .8rem; }
  .nav-panel .quiet-button { width: 100%; border-color: rgba(217,183,123,.2); border-radius: .8rem; color: var(--muted); text-align: left; }
  .page-shell { padding: 3.5rem 1rem; }
  .home-page .page-shell { padding-top: 1.5rem; }
  .room-grid { grid-template-columns: 1fr; }
  .room-card { min-height: 15rem; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .page-heading { align-items: start; flex-direction: column; }
  .history-entry header { display: grid; gap: .35rem; }
  .workbook-tools { align-items: stretch; flex-direction: column; }
  .page-heading > .primary-button { width: 100%; }
  .study-mode-grid { grid-template-columns: 1fr; }
  .scriptorium-tabs { gap: .15rem; padding: .25rem; }
  .scriptorium-tabs a { padding: .6rem .65rem; }
  .study-session-header { flex-direction: row; align-items: center; }
  .study-session-header #study-exit { top: 3.5rem; right: 1rem; gap: .35rem; padding: .65rem .75rem; }
  .study-exit-label-full { display: none; }
  .study-exit-label-short { display: inline; }
  .study-session { max-width: 34rem; }
  .study-card { min-height: 14rem; padding: 1.75rem 1.3rem 4.5rem; }
}
@media (hover: hover) and (pointer: fine) and (min-width: 761px) {
  .wand-cursor-active, .wand-cursor-active :is(a, button, [role="button"], [tabindex], summary, .room-card, .book-card, .history-entry-preview) { cursor: url("/static/magic-wand-cursor.png?v=1") 11 12, auto !important; }
  .wand-cursor-active input, .wand-cursor-active textarea, .wand-cursor-active [contenteditable="true"] { cursor: text !important; }
  .wand-cursor-active select { cursor: default !important; }
}
@media (prefers-reduced-motion: reduce) {
  .magic-mote, .falling-star, .login-card, .welcome-spell-content::before, .welcome-spell-content::after, .welcome-sparks span, .welcome-spell h2 span, .cursor-dust, .wand-toggle-spark { animation: none; }
  .magic-mote { opacity: .28; }
  .falling-star { display: none; }
  .login-card, .welcome-spell, .welcome-spell-content, .nav-panel, .wand-icon, .study-mode-option span { transition: none; }
  .welcome-spell-content, .welcome-spell.is-visible .welcome-spell-content { filter: none; transform: none; }
  .magic-visitor-stage, .magic-summon-button { display: none; }
}
