:root {
    --bull-emerald: #10b981;
    --bull-deep: #065f46;
    --bear-crimson: #991b1b;
    --gold-foil: #d4af37;
    --brass-mid: #9c7a3c;
    --brass-dark: #4a3718;
    --ledger-paper: #f3ead8;
    --ink-primary: #1c1915;
    --ink-emerald: #064e3b;
}

* {
    box-sizing: border-box;
}

.parchment-page, .parchment-page * {
    user-select: text;
    -webkit-user-select: text;
}

body {
    margin: 0;
    padding: 15px 0 12px 0;
    min-height: 100vh;
    background-color: #090706;
    color: var(--ledger-paper);
    font-family: 'Cormorant Garamond', Georgia, serif;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    transition: background-color 0.45s ease, color 0.45s ease;
}

body.light-theme {
    background-color: #ebe3d3;
    background-image: radial-gradient(circle at 50% 42%, #f8f3e8 0%, #dfd3bc 100%);
    color: #1c1915;
}

/* Theme Toggle Button & Unified Link Styling — High Legibility + Particle Transparency (No Shadows) */
.theme-toggle-btn:hover {
    border-color: #f0cf7b;
    color: #ffffff;
    background: rgba(48, 36, 24, 0.62);
    box-shadow: none;
    transform: translateY(-1px);
}

body.light-theme .theme-toggle-btn:hover {
    border-color: #059669;
    color: #044332;
    background: rgba(255, 252, 244, 0.84);
    box-shadow: none;
}

/* Particle Canvas — renders above book folios and translucent toolbar links */
#magic-particles {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 40;
}

/* Single-Line Unified Links Bar Under Book (20px separator, shadow-free & translucent) */
.grimoire-toolbar {
    position: relative;
    z-index: 20;
    margin-top: 20px;
    display: flex;
    flex-wrap: nowrap;
    gap: 7px;
    align-items: center;
    justify-content: center;
    width: max-content;
    max-width: 96vw;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 4px 6px 4px;
    background: transparent;
    border: none;
    box-shadow: none;
    scrollbar-width: none;
}

.grimoire-toolbar::-webkit-scrollbar {
    display: none;
}

/* Base Link / Button — Dark Theme (high-contrast warm ivory on translucent dark-amber glass) */
.arcane-btn {
    font-family: 'Cinzel', serif;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #f7edd8;
    background: rgba(26, 20, 14, 0.42);
    border: 1px solid rgba(212, 175, 55, 0.56);
    padding: 6px 14px;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: none;
    transition: border-color 0.22s ease, color 0.22s ease, background-color 0.22s ease, transform 0.22s ease;
    white-space: nowrap;
}

.arcane-btn:hover:not(:disabled) {
    border-color: #f3d47e;
    color: #ffffff;
    background: rgba(52, 40, 27, 0.65);
    box-shadow: none;
    transform: translateY(-1px);
}

.arcane-btn:focus-visible {
    outline: 2px solid #f0cf7b;
    outline-offset: 2px;
}

.arcane-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Base Link / Button — Light Theme (crisp espresso ink on translucent cream parchment) */
body.light-theme .arcane-btn {
    color: #1f170e;
    background: rgba(255, 250, 240, 0.62);
    border-color: rgba(138, 102, 46, 0.68);
    box-shadow: none;
}

body.light-theme .arcane-btn:hover:not(:disabled) {
    border-color: #5c421b;
    color: #0d0905;
    background: rgba(255, 252, 245, 0.86);
    box-shadow: none;
}

/* Primary / Emerald Accent Links — Dark Theme */
.arcane-btn.emerald-accent {
    border-color: rgba(52, 211, 153, 0.65);
    background: rgba(6, 78, 59, 0.36);
    color: #a7f3d0;
    box-shadow: none;
}

.arcane-btn.emerald-accent:hover:not(:disabled) {
    border-color: #6ee7b7;
    background: rgba(6, 95, 70, 0.58);
    box-shadow: none;
    color: #ffffff;
}

/* Primary / Emerald Accent Links — Light Theme */
body.light-theme .arcane-btn.emerald-accent {
    border-color: #059669;
    background: rgba(209, 250, 229, 0.62);
    color: #044332;
    box-shadow: none;
}

body.light-theme .arcane-btn.emerald-accent:hover:not(:disabled) {
    border-color: #047857;
    background: rgba(167, 243, 208, 0.84);
    box-shadow: none;
    color: #022c22;
}

/* Links & Buttons Inside Book Folios (.parchment-page) — identical high-contrast look in Dark & Light themes */
.parchment-page .arcane-btn {
    color: #1f170e;
    background: rgba(255, 251, 242, 0.78);
    border: 1px solid #8c6a32;
    box-shadow: none;
}

.parchment-page .arcane-btn:hover:not(:disabled) {
    color: #044332;
    background: rgba(209, 250, 229, 0.85);
    border-color: #059669;
    box-shadow: none;
    transform: translateY(-1px);
}

.parchment-page .arcane-btn.emerald-accent {
    color: #044332;
    background: rgba(209, 250, 229, 0.72);
    border-color: #059669;
    box-shadow: none;
}

.parchment-page .arcane-btn.emerald-accent:hover:not(:disabled) {
    color: #022c22;
    background: rgba(167, 243, 208, 0.92);
    border-color: #047857;
    box-shadow: none;
    transform: translateY(-1px);
}

/* Inline Folio Step Links in Chapter Header (.chapter-kicker) */
.chapter-kicker button {
    color: #064e3b;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(6, 78, 59, 0.08);
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.chapter-kicker button:hover {
    color: #022c22;
    background: rgba(16, 185, 129, 0.24);
}

/* 3D Book Stage — Top of Page */
.book-stage {
    position: relative;
    width: 94vw;
    max-width: 1140px;
    height: calc(100vh - 96px);
    max-height: 780px;
    min-height: 440px;
    perspective: 2400px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

/* ================= CLOSED ESPRESSO CALFSKIN LEDGER COVER ================= */
.closed-grimoire {
    position: relative;
    width: min(470px, 88vw);
    height: min(650px, calc(100vh - 110px));
    border-radius: 10px 22px 22px 10px;
    background: 
        radial-gradient(circle at 50% 48%, rgba(212, 175, 55, 0.14) 0%, transparent 55%),
        repeating-radial-gradient(circle at 20% 30%, rgba(255,255,255,0.025) 0, rgba(0,0,0,0.24) 2px, transparent 4px),
        linear-gradient(135deg, #241913 0%, #140d0a 48%, #0a0705 100%);
    box-shadow:
        -14px 22px 45px rgba(0, 0, 0, 0.92),
        inset 16px 0 24px rgba(0, 0, 0, 0.85),
        inset -2px 0 6px rgba(212, 175, 55, 0.38),
        12px 10px 0 #d6c5a3,
        15px 13px 0 #9c865e,
        18px 16px 0 #c7b48e,
        21px 19px 25px rgba(0,0,0,0.85);
    border: 3px solid #694e22;
    cursor: pointer;
    transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.6s ease, box-shadow 0.4s ease;
    transform-style: preserve-3d;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

body.light-theme .closed-grimoire {
    box-shadow:
        -12px 18px 36px rgba(55, 38, 16, 0.38),
        inset 16px 0 24px rgba(0, 0, 0, 0.82),
        inset -2px 0 6px rgba(212, 175, 55, 0.38),
        12px 10px 0 #d6c5a3,
        15px 13px 0 #9c865e,
        18px 16px 0 #c7b48e,
        21px 19px 22px rgba(55, 38, 16, 0.32);
}

.closed-grimoire:hover {
    transform: translateY(-6px) rotateY(-4deg) rotateX(2deg);
    box-shadow:
        -18px 28px 55px rgba(0, 0, 0, 0.95),
        0 0 38px rgba(212, 175, 55, 0.32),
        inset 16px 0 24px rgba(0, 0, 0, 0.85),
        12px 10px 0 #d6c5a3,
        15px 13px 0 #9c865e,
        18px 16px 0 #c7b48e;
}

.closed-grimoire.opening {
    transform: rotateY(-85deg) scale(1.06);
    opacity: 0;
    pointer-events: none;
}

.closed-grimoire.hidden-state {
    display: none;
}

/* Leather Spine Ribs */
.spine-ridges {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 44px;
    background: linear-gradient(90deg, #090605 0%, #261a14 45%, #0d0907 100%);
    border-right: 2px solid #7c5c26;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    padding: 25px 0;
    z-index: 2;
}

.spine-rib {
    height: 12px;
    width: 100%;
    background: linear-gradient(180deg, #4a3718 0%, #c9a24b 45%, #2e200c 100%);
    box-shadow: 0 3px 6px rgba(0,0,0,0.85);
}

/* Antique Brass Corner Protectors */
.corner-clasp {
    position: absolute;
    width: 78px;
    height: 78px;
    z-index: 4;
    pointer-events: none;
    filter: drop-shadow(2px 4px 5px rgba(0,0,0,0.85));
}
.corner-tl { top: 4px; left: 38px; }
.corner-tr { top: 4px; right: 4px; transform: scaleX(-1); }
.corner-bl { bottom: 4px; left: 38px; transform: scaleY(-1); }
.corner-br { bottom: 4px; right: 4px; transform: scale(-1, -1); }

/* Embossed Gold-Foil Ledger Frame */
.cover-filigree-border {
    position: absolute;
    inset: 18px 18px 18px 54px;
    border: 2px solid #9c7a3c;
    border-radius: 6px 14px 14px 6px;
    box-shadow: inset 0 0 18px rgba(0,0,0,0.9), 0 0 8px rgba(212,175,55,0.25);
    pointer-events: none;
}

.cover-filigree-border::after {
    content: '';
    position: absolute;
    inset: 6px;
    border: 1px dashed rgba(212, 175, 55, 0.5);
    border-radius: 4px 10px 10px 4px;
}

/* Central Gold-Foil Candlestick & Compass Astrolabe Medallion */
.astrolabe-medallion {
    position: relative;
    width: 224px;
    height: 224px;
    margin-left: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    transition: transform 0.5s ease;
}

.closed-grimoire:hover .astrolabe-medallion {
    transform: scale(1.04);
}

.astrolabe-ring-outer {
    position: absolute;
    inset: 0;
    animation: spinSlow 48s linear infinite;
}

.astrolabe-ring-inner {
    position: absolute;
    inset: 28px;
    animation: spinReverse 32s linear infinite;
}

.emerald-seal-core {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #6ee7b7 0%, #059669 36%, #064e3b 76%, #021f17 100%);
    border: 4px solid #d4af37;
    box-shadow:
        0 0 25px rgba(16, 185, 129, 0.7),
        0 0 55px rgba(212, 175, 55, 0.35),
        inset 0 0 16px rgba(255, 255, 255, 0.55);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: emeraldPulse 3.5s infinite ease-in-out;
}

@keyframes spinSlow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
@keyframes spinReverse {
    from { transform: rotate(360deg); }
    to { transform: rotate(0deg); }
}
@keyframes emeraldPulse {
    0%, 100% { box-shadow: 0 0 22px rgba(16, 185, 129, 0.65), 0 0 45px rgba(212, 175, 55, 0.28), inset 0 0 14px rgba(255,255,255,0.5); }
    50% { box-shadow: 0 0 36px rgba(52, 211, 153, 0.92), 0 0 70px rgba(212, 175, 55, 0.52), inset 0 0 20px rgba(255,255,255,0.8); }
}

.cover-title-plate {
    margin-left: 28px;
    margin-top: 16px;
    text-align: center;
    z-index: 5;
    padding: 0 18px;
}

.cover-title-text {
    font-family: 'Cinzel Decorative', serif;
    font-size: 1.28rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    color: #e3c16f;
    text-shadow: 0 2px 4px #000, 0 0 14px rgba(212, 175, 55, 0.4);
}

.cover-deck-text {
    font-family: 'Cinzel', serif;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    color: #c5a872;
    margin-top: 4px;
}

.cover-subtitle-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    color: #6ee7b7;
    margin-top: 10px;
    text-transform: uppercase;
    animation: pulseText 2.4s infinite ease-in-out;
}

@keyframes pulseText {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; text-shadow: 0 0 10px rgba(52, 211, 153, 0.85); }
}

/* ================= OPEN AGED LEDGER SPREAD ================= */
.open-grimoire {
    position: relative;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #241913 0%, #120c09 50%, #211711 100%);
    border-radius: 14px;
    padding: 14px 18px;
    box-shadow:
        0 28px 65px rgba(0, 0, 0, 0.95),
        0 0 0 3px #6b4e22,
        0 0 0 6px #17120e,
        inset 0 0 30px rgba(0, 0, 0, 0.9);
    display: none;
    opacity: 0;
    transform: scale(0.94);
    transition: opacity 0.65s ease, transform 0.65s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.4s ease;
    transform-style: preserve-3d;
}

body.light-theme .open-grimoire {
    box-shadow:
        0 24px 52px rgba(55, 38, 16, 0.35),
        0 0 0 3px #8c6a32,
        0 0 0 6px #d6c5a3,
        inset 0 0 30px rgba(0, 0, 0, 0.85);
}

.open-grimoire.visible {
    display: flex;
}

.open-grimoire.active {
    opacity: 1;
    transform: scale(1);
}

/* Layered Paper Thickness Stacks */
.page-stack-left, .page-stack-right {
    position: relative;
    flex: 1;
    height: 100%;
    display: flex;
    background: #c7b48e;
    border-radius: 6px;
    transition: padding 0.3s ease;
}

.page-stack-left {
    padding-left: var(--left-stack, 10px);
    background: repeating-linear-gradient(90deg, #9c865e 0px, #e3d5b8 2px, #856e48 3px);
    border-radius: 8px 2px 2px 8px;
    box-shadow: -4px 4px 12px rgba(0,0,0,0.65);
}

.page-stack-right {
    padding-right: var(--right-stack, 12px);
    background: repeating-linear-gradient(90deg, #856e48 0px, #e3d5b8 2px, #9c865e 3px);
    border-radius: 2px 8px 8px 2px;
    box-shadow: 4px 4px 12px rgba(0,0,0,0.65);
}

/* Individual Ruled Antique Financial Ledger Sheet */
.parchment-page {
    position: relative;
    width: 100%;
    height: 100%;
    background-color: var(--ledger-paper);
    background-image:
        radial-gradient(circle at 50% 50%, rgba(255, 252, 242, 0.55) 0%, rgba(212, 188, 142, 0.35) 82%, rgba(145, 112, 62, 0.58) 100%),
        linear-gradient(to right, rgba(153, 27, 27, 0.14) 1px, transparent 1px),
        repeating-linear-gradient(0deg, transparent 0px, transparent 23px, rgba(6, 95, 70, 0.08) 24px);
    background-size: 100% 100%, 100% 100%, 100% 24px;
    background-position: 0 0, 22px 0, 0 0;
    color: var(--ink-primary);
    padding: 24px 30px 38px 32px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #8c6a38 transparent;
}

.parchment-page::-webkit-scrollbar {
    width: 5px;
}
.parchment-page::-webkit-scrollbar-thumb {
    background: rgba(120, 86, 40, 0.45);
    border-radius: 4px;
}

.left-sheet {
    border-radius: 6px 0 0 6px;
    box-shadow:
        inset -24px 0 32px -12px rgba(45, 28, 10, 0.4),
        inset 4px 0 12px rgba(95, 68, 30, 0.22);
    border-right: 1px solid rgba(75, 50, 20, 0.35);
}

.right-sheet {
    border-radius: 0 6px 6px 0;
    box-shadow:
        inset 24px 0 32px -12px rgba(45, 28, 10, 0.4),
        inset -4px 0 12px rgba(95, 68, 30, 0.22);
}

/* Central Spine Crease & Emerald/Gold Silk Bookmark Ribbon */
.center-spine-crease {
    position: absolute;
    top: 12px;
    bottom: 12px;
    left: 50%;
    width: 34px;
    transform: translateX(-50%);
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(30, 18, 6, 0.22) 32%, 
        rgba(15, 8, 2, 0.55) 50%, 
        rgba(30, 18, 6, 0.22) 68%, 
        transparent 100%);
    pointer-events: none;
    z-index: 25;
}

.silk-ribbon {
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: calc(100% + 26px);
    background: linear-gradient(90deg, #032b20 0%, #065f46 45%, #d4af37 50%, #065f46 55%, #021f17 100%);
    z-index: 26;
    pointer-events: none;
    box-shadow: 2px 4px 8px rgba(0,0,0,0.65);
    clip-path: polygon(0 0, 100% 0, 100% 96%, 50% 100%, 0 96%);
}

/* 3D Animated Turning Leaf Overlay */
.turning-leaf {
    position: absolute;
    top: 14px;
    bottom: 14px;
    width: calc(50% - 18px);
    background-color: var(--ledger-paper);
    background-image: radial-gradient(circle at 50% 50%, rgba(255, 252, 242, 0.55) 0%, rgba(195, 165, 112, 0.55) 100%);
    z-index: 35;
    pointer-events: none;
    display: none;
    backface-visibility: hidden;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.55);
    padding: 24px 30px;
    overflow: hidden;
    color: var(--ink-primary);
}

.turning-leaf.flip-next {
    display: block;
    right: 18px;
    transform-origin: left center;
    border-radius: 0 6px 6px 0;
    animation: pageFlipNext 0.68s cubic-bezier(0.45, 0.05, 0.55, 0.95) forwards;
}

.turning-leaf.flip-prev {
    display: block;
    left: 18px;
    transform-origin: right center;
    border-radius: 6px 0 0 6px;
    animation: pageFlipPrev 0.68s cubic-bezier(0.45, 0.05, 0.55, 0.95) forwards;
}

@keyframes pageFlipNext {
    0% { transform: rotateY(0deg) skewY(0deg); filter: brightness(1); }
    45% { transform: rotateY(-85deg) skewY(-3deg); filter: brightness(0.84); box-shadow: -25px 15px 40px rgba(0,0,0,0.6); }
    100% { transform: rotateY(-180deg) skewY(0deg); filter: brightness(0.7); }
}

@keyframes pageFlipPrev {
    0% { transform: rotateY(0deg) skewY(0deg); filter: brightness(1); }
    45% { transform: rotateY(85deg) skewY(3deg); filter: brightness(0.84); box-shadow: 25px 15px 40px rgba(0,0,0,0.6); }
    100% { transform: rotateY(180deg) skewY(0deg); filter: brightness(0.7); }
}

/* Interactive Page Corner Peel Hint */
.page-corner-zone {
    position: absolute;
    bottom: 0;
    width: 56px;
    height: 56px;
    z-index: 30;
    cursor: pointer;
    transition: all 0.25s ease;
}

.corner-next {
    right: 0;
    background: linear-gradient(315deg, rgba(130, 95, 48, 0.35) 0%, rgba(255, 250, 238, 0.78) 42%, transparent 50%);
    border-radius: 12px 0 6px 0;
}
.corner-next:hover {
    width: 74px;
    height: 74px;
    background: linear-gradient(315deg, rgba(110, 75, 32, 0.55) 0%, #fbf5e6 46%, rgba(0,0,0,0.18) 50%, transparent 54%);
}

.corner-prev {
    left: 0;
    background: linear-gradient(45deg, rgba(130, 95, 48, 0.35) 0%, rgba(255, 250, 238, 0.78) 42%, transparent 50%);
    border-radius: 0 12px 0 6px;
}
.corner-prev:hover {
    width: 74px;
    height: 74px;
    background: linear-gradient(45deg, rgba(110, 75, 32, 0.55) 0%, #fbf5e6 46%, rgba(0,0,0,0.18) 50%, transparent 54%);
}

/* Ledger Typography & Callouts */
.chapter-kicker {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-emerald);
    font-weight: 700;
    border-bottom: 1px solid rgba(6, 78, 59, 0.28);
    padding-bottom: 4px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
}

.page-heading {
    font-family: 'Cinzel', serif;
    font-size: 1.32rem;
    line-height: 1.24;
    font-weight: 900;
    color: #1c1610;
    margin-bottom: 10px;
    text-shadow: 0 1px 0 rgba(255,255,255,0.6);
}

.drop-cap::first-letter {
    font-family: 'Cinzel Decorative', serif;
    float: left;
    font-size: 2.95rem;
    line-height: 0.82;
    padding: 4px 10px 2px 0;
    color: var(--ink-emerald);
    text-shadow: 1px 1px 0 #d4af37;
}

.formula-axiom-box {
    margin: 10px 0;
    padding: 8px 12px;
    background: rgba(6, 78, 59, 0.07);
    border-left: 3px solid var(--ink-emerald);
    border-right: 3px solid var(--gold-foil);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    font-weight: 600;
    color: #064e3b;
    text-align: center;
}

.mono-stat {
    font-family: 'JetBrains Mono', monospace;
}

.page-footer-num {
    position: absolute;
    bottom: 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    font-weight: 700;
    color: #5e4423;
    letter-spacing: 0.1em;
}
.footer-left { left: 28px; }
.footer-right { right: 28px; }

/* Modal Drawers for Search / Index */
.arcane-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(4, 4, 6, 0.84);
    backdrop-filter: blur(5px);
    z-index: 80;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.arcane-modal-backdrop.open {
    display: flex;
}
.arcane-modal-card {
    width: 100%;
    max-width: 580px;
    max-height: 82vh;
    overflow-y: auto;
    background: linear-gradient(145deg, #1d1612 0%, #0f0c0a 100%);
    border: 2px solid #8c6a32;
    border-radius: 14px;
    padding: 22px;
    color: #efe2c6;
    box-shadow: 0 24px 60px rgba(0,0,0,0.95), 0 0 30px rgba(212, 175, 55, 0.22);
}

body.light-theme .arcane-modal-card {
    background: linear-gradient(145deg, #fbf6eb 0%, #efe4cf 100%);
    color: #1c1915;
    box-shadow: 0 24px 60px rgba(55, 38, 16, 0.35);
}

/* Toast Notification — Page Center */
.arcane-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.94);
    background: rgba(6, 36, 27, 0.96);
    border: 1px solid #10b981;
    color: #d1fae5;
    font-family: 'Cinzel', serif;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 10px 22px;
    border-radius: 999px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6), 0 0 26px rgba(16, 185, 129, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 95;
    max-width: min(84vw, 560px);
    text-align: center;
}
.arcane-toast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

body.light-theme .arcane-toast {
    background: rgba(252, 247, 236, 0.98);
    border-color: #059669;
    color: #064e3b;
    box-shadow: 0 12px 28px rgba(55, 38, 16, 0.28), 0 0 16px rgba(16, 185, 129, 0.28);
}

/* Responsive Mobile / Narrow Screen Single-Page Adaptation */
@media (max-width: 1120px) {
    .grimoire-toolbar {
        justify-content: flex-start;
        padding-left: 8px;
        padding-right: 8px;
    }
    .arcane-btn {
        font-size: 0.68rem;
        padding: 5px 10px;
    }
}

@media (max-width: 768px) {
    .arcane-toast {
        max-width: 88vw;
        font-size: 0.74rem;
        padding: 8px 16px;
    }
    .grimoire-toolbar {
        margin-top: 20px;
        gap: 5px;
        max-width: 96vw;
    }
    .arcane-btn {
        font-size: 0.65rem;
        padding: 5px 9px;
    }
    .book-stage {
        height: calc(100vh - 92px);
        min-height: 340px;
    }
    .open-grimoire {
        flex-direction: column;
        padding: 10px;
    }
    .page-stack-left {
        display: none;
    }
    .open-grimoire.mobile-show-left .page-stack-left {
        display: flex;
    }
    .open-grimoire.mobile-show-left .page-stack-right {
        display: none;
    }
    .center-spine-crease, .silk-ribbon {
        display: none;
    }
    .parchment-page {
        border-radius: 6px;
        padding: 18px 18px 36px 20px;
    }
    .turning-leaf {
        width: calc(100% - 20px);
        left: 10px !important;
        right: 10px !important;
    }
}
