/* ─── TOKENS ───────────────────────────────────── */
:root {
    --bg: #060301;
    --bg1: #0d0704;
    --bg2: #160c06;
    --bg3: #1e1009;
    --bg4: #271610;
    --bg5: #301c14;
    --border1: rgba(180, 100, 30, .12);
    --border2: rgba(180, 100, 30, .26);
    --border3: rgba(245, 158, 11, .36);
    --amber: #f59e0b;
    --amber2: #fbbf24;
    --amber3: #d97706;
    --amber4: #92400e;
    --amber5: #78350f;
    --parch: #f2dfa8;
    --parch2: #e8cc8e;
    --parch3: #d9b872;
    --parch4: #c8a455;
    --ink1: #1a0c06;
    --ink2: #2e1a0d;
    --ink3: #3e2612;
    --ink4: #5c3a1e;
    --ink5: #7a502e;
    --ink6: #9a6a42;
    --s100: #f5f5f4;
    --s200: #e7e5e4;
    --s300: #d6d3d1;
    --s400: #a8a29e;
    --s500: #78716c;
    --s600: #57534e;
    --ease: cubic-bezier(.4, 0, .2, 1);
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box
}

html {
    height: 100%
}

body {
    font-family: 'Crimson Text', Georgia, serif;
    background: var(--bg);
    color: var(--s300);
    min-height: 100vh;
    overflow-x: hidden
}

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    background: none
}

input,
select,
textarea {
    font-family: inherit
}

/* ─── FX CANVAS ─────────────────────────────── */
#fx {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0
}

/* ─── SCENE ──────────────────────────────────── */
#scene {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 60px 80px;
    position: relative;
    z-index: 1;
}

#scene::before {
    content: '';
    position: fixed;
    top: -20vh;
    left: 50%;
    transform: translateX(-50%);
    width: 80vw;
    height: 60vh;
    background: radial-gradient(ellipse, rgba(180, 90, 20, .18) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ─── LOADING ────────────────────────────────── */
#loading {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity .7s var(--ease)
}

#loading.out {
    opacity: 0;
    pointer-events: none
}

.load-sigil {
    width: 90px;
    height: 90px;
    position: relative;
    margin-bottom: 28px
}

.load-ring {
    position: absolute;
    inset: 0;
    border: 2px solid transparent;
    border-top-color: var(--amber);
    border-radius: 50%;
    animation: spin 1.1s linear infinite
}

.load-ring2 {
    position: absolute;
    inset: 14px;
    border: 1.5px solid transparent;
    border-bottom-color: var(--amber4);
    border-left-color: var(--amber4);
    border-radius: 50%;
    animation: spin .75s linear infinite reverse
}

.load-gem {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    width: 22px;
    height: 22px;
    background: var(--amber);
    animation: gemPulse 1.1s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(245, 158, 11, .7)
}

.load-txt {
    font-family: 'Cinzel', serif;
    font-size: .65rem;
    letter-spacing: .5em;
    text-transform: uppercase;
    color: var(--s600);
    animation: textFade 1.5s ease-in-out infinite alternate
}

@keyframes spin {
    to {
        transform: rotate(360deg)
    }
}

@keyframes gemPulse {

    0%,
    100% {
        box-shadow: 0 0 12px rgba(245, 158, 11, .5)
    }

    50% {
        box-shadow: 0 0 32px rgba(245, 158, 11, 1), 0 0 60px rgba(245, 158, 11, .4)
    }
}

@keyframes textFade {
    from {
        opacity: .4
    }

    to {
        opacity: .9
    }
}

/* ─── TOP HUD ─────────────────────────────────── */
#hud {
    width: 100%;
    max-width: 980px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    position: relative;
    z-index: 2;
    flex-wrap: wrap;
    gap: 10px
}

.char-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(30, 16, 9, .75);
    border: 1px solid var(--border2);
    border-radius: 30px;
    padding: 7px 14px 7px 10px;
    backdrop-filter: blur(10px);
    cursor: pointer;
    transition: all .2s;
    user-select: none
}

.char-pill:hover {
    border-color: var(--border3)
}

.char-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--amber4), var(--amber3));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 12px rgba(180, 83, 9, .5);
    flex-shrink: 0
}

.char-avatar svg {
    width: 16px;
    height: 16px;
    stroke: #fff;
    fill: none;
    stroke-width: 1.8
}

.char-name {
    font-family: 'Cinzel', serif;
    font-size: .75rem;
    font-weight: 600;
    color: var(--amber);
    letter-spacing: .05em
}

.char-class {
    font-size: .7rem;
    color: var(--s500);
    font-style: italic
}

.char-chevron {
    margin-left: 4px;
    color: var(--s600);
    transition: transform .2s
}

.char-chevron svg {
    width: 13px;
    height: 13px
}

.char-pill:hover .char-chevron {
    color: var(--amber3)
}

/* Slot HUD */
#slots-hud {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end
}

.slot-group {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(14, 7, 3, .75);
    border: 1px solid var(--border1);
    border-radius: 20px;
    padding: 5px 11px;
    cursor: pointer;
    transition: all .2s;
    position: relative;
    backdrop-filter: blur(8px)
}

.slot-group:hover {
    border-color: var(--border3);
    background: rgba(30, 16, 9, .85)
}

.slot-lv {
    font-family: 'Cinzel', serif;
    font-size: .6rem;
    font-weight: 700;
    color: var(--s600);
    letter-spacing: .08em;
    text-transform: uppercase;
    margin-right: 3px
}

.rune {
    width: 10px;
    height: 10px;
    transform: rotate(45deg);
    border: 1px solid;
    display: inline-block;
    transition: all .5s var(--ease);
    flex-shrink: 0
}

.rune.lit {
    background: var(--amber);
    border-color: #fef3c7;
    animation: runeFlicker 3s ease-in-out infinite
}

.rune.dim {
    background: rgba(10, 5, 2, .8);
    border-color: var(--border1);
    opacity: .45
}

@keyframes runeFlicker {

    0%,
    100% {
        box-shadow: 0 0 6px rgba(251, 191, 36, .7), 0 0 14px rgba(251, 191, 36, .35)
    }

    50% {
        box-shadow: 0 0 12px rgba(251, 191, 36, 1), 0 0 28px rgba(251, 191, 36, .55), 0 0 50px rgba(251, 191, 36, .2)
    }
}

/* Slot popup */
.slot-popup {
    position: fixed;
    background: var(--bg3);
    border: 1px solid var(--border3);
    border-radius: 10px;
    padding: 14px 16px;
    min-width: 190px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .9), 0 0 20px rgba(180, 83, 9, .2);
    z-index: 400;
    display: none;
    animation: popIn .2s var(--ease)
}

.slot-popup.open {
    display: block
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: translateY(-5px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}

.slot-popup-title {
    font-family: 'Cinzel', serif;
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--amber3);
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border1);
    padding-bottom: 8px
}

.slot-popup-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px
}

.slot-popup-row span {
    font-size: .8rem;
    color: var(--s400)
}

.slot-popup-ctrls {
    display: flex;
    align-items: center;
    gap: 8px
}

.sp-btn {
    width: 24px;
    height: 24px;
    background: var(--bg4);
    border: 1px solid var(--border2);
    border-radius: 4px;
    color: var(--s400);
    font-size: .95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s
}

.sp-btn:hover:not(:disabled) {
    background: var(--bg5);
    color: var(--s200)
}

.sp-btn:disabled {
    opacity: .25;
    cursor: not-allowed
}

.sp-val {
    font-family: 'Cinzel', serif;
    font-size: .85rem;
    font-weight: 700;
    color: var(--amber);
    min-width: 16px;
    text-align: center
}

/* ─── GRIMOIRE 3D ─────────────────────────────── */
#grimoire-mount {
    position: relative;
    transform: perspective(1800px) rotateX(10deg) rotateY(0deg);
    transition: transform 1.2s var(--ease);
    will-change: transform
}

#book-glow {
    position: absolute;
    bottom: -60px;
    left: 10%;
    right: 10%;
    height: 80px;
    background: radial-gradient(ellipse, rgba(200, 120, 30, .3) 0%, transparent 70%);
    filter: blur(20px);
    pointer-events: none;
    animation: glowBreath 4s ease-in-out infinite
}

@keyframes glowBreath {

    0%,
    100% {
        opacity: .7;
        transform: scaleX(1)
    }

    50% {
        opacity: 1;
        transform: scaleX(1.05)
    }
}

#grimoire {
    display: flex;
    width: min(960px, 92vw);
    height: min(620px, 56vh);
    min-height: 380px;
    position: relative;
    box-shadow: 0 70px 140px -30px rgba(0, 0, 0, .98), 0 40px 80px -20px rgba(0, 0, 0, .85), 0 5px 0 1px #230e05, 0 7px 0 1px #1a0a03, 0 9px 0 1px #110702, 0 0 80px rgba(220, 150, 40, .1), 0 0 200px rgba(200, 120, 20, .06);
    border-radius: 2px 6px 6px 2px
}

/* Pages */
.book-pg {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column
}

.book-pg .inner {
    flex: 1;
    min-height: 0;
    padding: 20px 16px 40px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: opacity .3s var(--ease)
}

.book-pg.pg-left .inner {
    background: repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(170, 120, 55, .07) 27px, rgba(170, 120, 55, .07) 28px), linear-gradient(112deg, var(--parch) 0%, var(--parch2) 55%, var(--parch3) 100%);
    border-radius: 2px 0 0 2px
}

.book-pg.pg-right .inner {
    background: repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(170, 120, 55, .07) 27px, rgba(170, 120, 55, .07) 28px), linear-gradient(248deg, var(--parch) 0%, var(--parch2) 55%, var(--parch3) 100%);
    border-radius: 0 6px 6px 0
}

.book-pg.single .inner {
    background: repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(170, 120, 55, .07) 27px, rgba(170, 120, 55, .07) 28px), linear-gradient(112deg, var(--parch) 0%, var(--parch2) 55%, var(--parch3) 100%);
    border-radius: 4px
}

.book-pg.pg-left .inner::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 50px;
    background: linear-gradient(to left, rgba(0, 0, 0, .18), transparent);
    pointer-events: none
}

.book-pg.pg-right .inner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 50px;
    background: linear-gradient(to right, rgba(0, 0, 0, .22), transparent);
    pointer-events: none
}

#spine {
    width: 30px;
    flex-shrink: 0;
    background: linear-gradient(to right, rgba(0, 0, 0, .65) 0%, rgba(50, 20, 8, .85) 25%, rgba(70, 30, 12, .9) 50%, rgba(50, 20, 8, .85) 75%, rgba(0, 0, 0, .65) 100%);
    position: relative
}

#spine::before,
#spine::after {
    content: '';
    position: absolute;
    left: 2px;
    right: 2px;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(200, 140, 60, .25), transparent)
}

#spine::before {
    top: 30%
}

#spine::after {
    top: 70%
}

.pg-num {
    position: absolute;
    bottom: 12px;
    font-family: 'IM Fell English', serif;
    font-size: .8rem;
    color: var(--ink5);
    opacity: .5;
    pointer-events: none
}

.pg-left .pg-num {
    left: 24px
}

.pg-right .pg-num {
    right: 24px
}

.single .pg-num {
    left: 24px
}

.pg-empty {
    width: 100%;
    text-align: center;
    margin-top: 80px;
    color: var(--ink5);
    font-family: 'IM Fell English', serif;
    font-style: italic;
    font-size: 1.05rem;
    opacity: .4
}

.pg-del {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 5;
    color: rgba(180, 60, 60, .3);
    padding: 7px;
    transition: color .2s
}

.pg-del:hover {
    color: rgba(210, 60, 60, .9)
}

.pg-del svg {
    width: 16px;
    height: 16px
}

/* ─── PAGE FLIP ANIMATION ─────────────────────── */
.page-flipper {
    position: absolute;
    transform-style: preserve-3d;
    z-index: 20;
    pointer-events: none;
    will-change: transform;
}

.page-flipper.flip-dt-next {
    transform-origin: -15px 50%;
    /* Centro da lombada para página direita */
    animation: flipDtNext .72s cubic-bezier(.4, 0, .2, 1) forwards;
}

@keyframes flipDtNext {
    0% {
        transform: rotateY(0deg) translateZ(1px) skewY(0deg)
    }

    50% {
        transform: rotateY(-90deg) translateZ(30px) skewY(-2deg)
    }

    100% {
        transform: rotateY(-180deg) translateZ(1px) skewY(0deg)
    }
}

.page-flipper.flip-dt-prev {
    transform-origin: calc(100% + 15px) 50%;
    /* Centro da lombada para página esquerda */
    animation: flipDtPrev .72s cubic-bezier(.4, 0, .2, 1) forwards;
}

@keyframes flipDtPrev {
    0% {
        transform: rotateY(0deg) translateZ(1px) skewY(0deg)
    }

    50% {
        transform: rotateY(90deg) translateZ(30px) skewY(2deg)
    }

    100% {
        transform: rotateY(180deg) translateZ(1px) skewY(0deg)
    }
}

.page-flipper.flip-mb-next {
    transform-origin: 0% 50%;
    animation: flipMbNext .65s cubic-bezier(.4, 0, .2, 1) forwards;
}

@keyframes flipMbNext {
    0% {
        transform: rotateY(0deg) translateZ(1px) skewY(0deg)
    }

    50% {
        transform: rotateY(-90deg) translateZ(30px) skewY(-2deg)
    }

    100% {
        transform: rotateY(-180deg) translateZ(1px) skewY(0deg)
    }
}

.page-flipper.flip-mb-prev {
    transform-origin: 0% 50%;
    animation: flipMbPrev .65s cubic-bezier(.4, 0, .2, 1) forwards;
}

@keyframes flipMbPrev {
    0% {
        transform: rotateY(-180deg) translateZ(1px) skewY(0deg)
    }

    50% {
        transform: rotateY(-90deg) translateZ(30px) skewY(2deg)
    }

    100% {
        transform: rotateY(0deg) translateZ(1px) skewY(0deg)
    }
}

.fp-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    overflow: hidden
}

.fp-front-left {
    background:
        repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(170, 120, 55, .07) 27px, rgba(170, 120, 55, .07) 28px),
        linear-gradient(112deg, var(--parch) 0%, var(--parch2) 55%, var(--parch3) 100%);
}

.fp-front-right {
    background:
        repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(170, 120, 55, .07) 27px, rgba(170, 120, 55, .07) 28px),
        linear-gradient(248deg, var(--parch) 0%, var(--parch2) 55%, var(--parch3) 100%);
}

.fp-back {
    transform: rotateY(180deg);
}

.fp-back-left {
    background:
        repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(170, 120, 55, .07) 27px, rgba(170, 120, 55, .07) 28px),
        linear-gradient(112deg, var(--parch) 0%, var(--parch2) 55%, var(--parch3) 100%);
}

.fp-back-right {
    background:
        repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(170, 120, 55, .07) 27px, rgba(170, 120, 55, .07) 28px),
        linear-gradient(248deg, var(--parch) 0%, var(--parch2) 55%, var(--parch3) 100%);
}

.fp-content {
    position: absolute;
    inset: 0;
    padding: 32px 28px 52px;
    overflow: hidden;
    pointer-events: none
}

.fp-shadow-f {
    position: absolute;
    inset: 0;
    animation: fpShadF .7s ease-in-out forwards;
}

.fp-shadow-f.from-left {
    background: linear-gradient(to right, rgba(0, 0, 0, .3) 0%, transparent 60%)
}

.fp-shadow-f.from-right {
    background: linear-gradient(to left, rgba(0, 0, 0, .3) 0%, transparent 60%)
}

@keyframes fpShadF {
    0% {
        opacity: 0
    }

    40% {
        opacity: 1
    }

    65% {
        opacity: 1
    }

    100% {
        opacity: 0
    }
}

.fp-shadow-b {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .08)
}

.page-shadow-over {
    position: absolute;
    top: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 15;
    animation: pgShadOver .7s ease-in-out forwards;
}

.page-shadow-over.from-right {
    right: 0;
    background: linear-gradient(to left, rgba(0, 0, 0, .32), transparent)
}

.page-shadow-over.from-left {
    left: 0;
    background: linear-gradient(to right, rgba(0, 0, 0, .32), transparent)
}

@keyframes pgShadOver {
    0% {
        width: 0;
        opacity: 0
    }

    35% {
        width: 80px;
        opacity: 1
    }

    65% {
        width: 80px;
        opacity: 1
    }

    100% {
        width: 0;
        opacity: 0
    }
}

/* ─── PARCHMENT SPELL CARDS ────────────────────── */
.sp-wrap {
    position: relative;
    overflow: hidden;
    min-width: 0;
    min-height: 0;
    padding: 2px;
    user-select: none;
}

.sp-wrap.w100 {
    width: 100%
}

.sp-wrap.w50 {
    width: 50%
}

.sp-wrap.w33 {
    width: 33.333%
}

.sp-wrap.w25 {
    width: 25%
}

.sp-card {
    border-bottom: 1px solid var(--parch4);
    padding-bottom: 12px
}

.sp-card h4 {
    font-family: 'Cinzel', serif;
    color: var(--ink1);
    line-height: 1.2;
    text-shadow: 0 1px 0 rgba(255, 255, 255, .5)
}

.sp-wrap.w100 .sp-card h4 {
    font-size: 1.1rem
}

.sp-wrap.w50 .sp-card h4 {
    font-size: .9rem
}

.sp-wrap.w33 .sp-card h4,
.sp-wrap.w25 .sp-card h4 {
    font-size: .8rem
}

.sp-meta {
    font-family: 'Cinzel', serif;
    font-size: .55rem;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--ink5);
    margin-top: 2px;
    opacity: .8
}

.sp-props {
    margin-top: 8px;
    padding-left: 9px;
    border-left: 2px solid var(--ink6);
    font-style: italic;
    font-size: .78rem;
    color: var(--ink4);
    line-height: 1.55
}

.sp-props strong {
    font-style: normal;
    color: var(--ink2);
    font-size: .75rem
}

.sp-desc {
    font-family: 'Crimson Text', serif;
    font-size: .82rem;
    line-height: 1.6;
    color: var(--ink3);
    text-align: justify;
    margin-top: 7px;
    white-space: pre-line
}

.sp-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 9px;
    padding-top: 7px;
    border-top: 1px solid rgba(200, 165, 100, .35)
}

.spa {
    padding: 3px 9px;
    font-family: 'Cinzel', serif;
    font-size: .58rem;
    font-weight: 600;
    letter-spacing: .09em;
    text-transform: uppercase;
    border-radius: 3px;
    transition: all .15s
}

.spa-prep {
    border: 1px solid var(--ink6);
    color: var(--ink3);
    background: transparent
}

.spa-prep:hover {
    background: var(--parch4)
}

.spa-prep.on {
    background: rgba(30, 100, 30, .12);
    color: #1b5e20;
    border-color: #2e7d32
}

.spa-cast {
    border: 1px solid #b71c1c;
    color: #7b1919;
    background: transparent
}

.spa-cast:hover:not(:disabled) {
    background: rgba(183, 28, 28, .1)
}

.spa-cast:disabled {
    opacity: .25;
    cursor: not-allowed
}

.spa-share {
    border: 1px solid var(--ink6);
    color: var(--ink4);
    background: transparent;
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px
}

.spa-share:hover {
    background: var(--parch4)
}

.spa-share svg {
    width: 11px;
    height: 11px
}

/* ─── HOVER ACTION OVERLAY (cards gc-sm e gc-half) ── */
.sp-act-ov {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 24px 8px 8px;
    background: linear-gradient(transparent, var(--parch) 52%);
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
    z-index: 3
}

.sp-wrap:hover .sp-act-ov {
    opacity: 1;
    pointer-events: all
}

/* ─── BOTÃO CONSULTAR ───────────────────────────── */
.spa-consult {
    border: 1px solid var(--amber3);
    color: var(--amber3);
    background: transparent
}

.spa-consult:hover {
    background: rgba(217, 119, 6, .12)
}

.sp-edit-ov {
    position: absolute;
    inset: 0;
    background: rgba(180, 83, 9, .06);
    border: 2px dashed rgba(180, 83, 9, .35);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    cursor: pointer;
    z-index: 8;
    transition: opacity .2s
}

.sp-wrap:hover .sp-edit-ov {
    opacity: 1
}

.sp-edit-badge {
    background: rgba(14, 7, 3, .9);
    color: var(--amber);
    border: 1px solid rgba(245, 158, 11, .4);
    padding: 5px 11px;
    border-radius: 4px;
    font-family: 'Cinzel', serif;
    font-size: .6rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 5px
}

.sp-edit-badge svg {
    width: 11px;
    height: 11px
}

/* ─── PAGE NAV ───────────────────────────────── */
#pg-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: calc(100% + 80px);
    left: -40px;
    display: flex;
    justify-content: space-between;
    pointer-events: none
}

.pg-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--bg4);
    border: 1px solid var(--border2);
    color: var(--amber);
    pointer-events: all;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 16px rgba(0, 0, 0, .8);
    transition: all .2s
}

.pg-btn:hover:not(:disabled) {
    background: var(--bg5);
    transform: scale(1.1)
}

.pg-btn:disabled {
    opacity: 0;
    pointer-events: none
}

.pg-btn svg {
    width: 18px;
    height: 18px
}

/* ─── PREPARED BAR ───────────────────────────── */
#prep-bar {
    width: 100%;
    max-width: 960px;
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    min-height: 40px;
    position: relative;
    z-index: 2
}

.prep-label {
    font-family: 'Cinzel', serif;
    font-size: .6rem;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--s600);
    white-space: nowrap
}

.prep-spells {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    align-items: center
}

.prep-orb {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(180, 83, 9, .12);
    border: 1px solid rgba(180, 83, 9, .3);
    border-radius: 20px;
    padding: 5px 12px;
    font-size: .72rem;
    color: var(--amber3);
    cursor: pointer;
    transition: all .2s;
    font-family: 'Cinzel', serif;
    letter-spacing: .04em
}

.prep-orb:hover {
    background: rgba(180, 83, 9, .25);
    border-color: var(--amber3);
    transform: translateY(-1px)
}

.prep-orb svg {
    width: 11px;
    height: 11px;
    flex-shrink: 0
}

.prep-orb.casting {
    animation: orbCast .4s ease
}

@keyframes orbCast {
    0% {
        transform: scale(1)
    }

    50% {
        transform: scale(1.15);
        background: rgba(220, 60, 20, .3);
        border-color: #f87171
    }

    100% {
        transform: scale(1)
    }
}

.prep-empty {
    font-family: 'IM Fell English', serif;
    font-size: .85rem;
    color: var(--s600);
    font-style: italic
}

/* ─── PALETTE ────────────────────────────────── */
#palette {
    width: 100%;
    max-width: 960px;
    background: rgba(20, 10, 4, .85);
    border: 1px solid rgba(180, 83, 9, .3);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 14px;
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 2;
    display: none
}

#palette h3 {
    font-family: 'Cinzel', serif;
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--amber3);
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border1)
}

.pal-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 100px;
    overflow-y: auto
}

.pal-pill {
    background: var(--bg4);
    border: 1px solid var(--border2);
    border-radius: 4px;
    padding: 5px 11px;
    font-size: .75rem;
    color: var(--s300);
    transition: all .15s
}

.pal-pill:hover {
    background: var(--bg5);
    border-color: var(--amber4);
    color: var(--amber)
}

.pal-empty {
    font-family: 'IM Fell English', serif;
    font-size: .85rem;
    color: var(--s600);
    font-style: italic
}

/* ─── SHEETS ─────────────────────────────────── */
.sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg2);
    border-top: 1px solid var(--border2);
    border-radius: 18px 18px 0 0;
    z-index: 150;
    transform: translateY(100%);
    transition: transform .4s var(--ease);
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, .8)
}

.sheet.open {
    transform: translateY(0)
}

.sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--bg5);
    border-radius: 2px;
    margin: 14px auto 0;
    flex-shrink: 0
}

.sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 22px 0;
    flex-shrink: 0
}

.sheet-title {
    font-family: 'Cinzel', serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--amber)
}

.sheet-close {
    color: var(--s500);
    padding: 4px;
    transition: color .2s
}

.sheet-close:hover {
    color: var(--s300)
}

.sheet-close svg {
    width: 20px;
    height: 20px
}

.sheet-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 22px 24px
}

/* ─── CHARACTER MANAGER SHEET ───────────────── */
.char-manager-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px
}

.char-manager-header h3 {
    font-family: 'Cinzel', serif;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--s600)
}

.chars-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 18px
}

.char-card {
    background: var(--bg3);
    border: 1px solid var(--border1);
    border-radius: 10px;
    padding: 16px;
    cursor: pointer;
    transition: all .2s;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px
}

.char-card:hover {
    border-color: var(--border2);
    background: var(--bg4);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .5)
}

.char-card.active {
    border-color: var(--amber4);
    background: rgba(180, 83, 9, .1);
    box-shadow: 0 0 20px rgba(180, 83, 9, .15)
}

.char-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: 'Cinzel', serif;
    font-size: .85rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--amber5), var(--amber4))
}

.char-card.active .char-card-icon {
    box-shadow: 0 0 14px rgba(180, 83, 9, .5)
}

.char-card-body {
    flex: 1;
    min-width: 0
}

.char-card-name {
    font-family: 'Cinzel', serif;
    font-size: .85rem;
    font-weight: 600;
    color: var(--s200);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.char-card-class {
    font-size: .78rem;
    color: var(--s500);
    font-style: italic;
    margin-top: 2px
}

.char-card-info {
    font-size: .68rem;
    color: var(--s600);
    margin-top: 4px
}

.char-card-active-dot {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--amber);
    box-shadow: 0 0 8px rgba(245, 158, 11, .6)
}

.char-card-del {
    position: absolute;
    bottom: 10px;
    right: 10px;
    color: var(--s600);
    padding: 4px;
    opacity: 0;
    transition: all .2s
}

.char-card:hover .char-card-del {
    opacity: 1;
    color: rgba(220, 80, 80, .6)
}

.char-card-del:hover {
    color: rgba(220, 80, 80, .9) !important
}

.char-card-del svg {
    width: 13px;
    height: 13px
}

.new-char-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px;
    background: rgba(180, 83, 9, .1);
    border: 1px dashed rgba(180, 83, 9, .35);
    border-radius: 10px;
    color: var(--amber3);
    font-family: 'Cinzel', serif;
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    transition: all .25s
}

.new-char-btn:hover {
    background: rgba(180, 83, 9, .2);
    border-color: var(--amber3);
    transform: translateY(-1px)
}

.new-char-btn svg {
    width: 16px;
    height: 16px
}

/* ─── LIBRARY ──────────────────────────────── */
.lib-search-row {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap
}

.lib-search {
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: center;
    gap: 9px;
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: 8px;
    padding: 9px 13px;
    transition: border-color .2s
}

.lib-search:focus-within {
    border-color: var(--amber3)
}

.lib-search svg {
    width: 16px;
    height: 16px;
    color: var(--s600);
    flex-shrink: 0
}

.lib-search input {
    background: none;
    border: none;
    outline: none;
    color: var(--s200);
    font-size: .95rem;
    flex: 1;
    font-family: 'Crimson Text', serif
}

.lib-search input::placeholder {
    color: var(--s600);
    font-style: italic
}

.lib-cls {
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: 8px;
    padding: 9px 13px;
    color: var(--s300);
    outline: none;
    cursor: pointer;
    transition: border-color .2s;
    font-size: .85rem
}

.lib-cls:focus {
    border-color: var(--amber3)
}

.lib-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px
}

.lib-card {
    background: var(--bg3);
    border: 1px solid var(--border1);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color .2s, box-shadow .2s
}

.lib-card:hover {
    border-color: var(--border2);
    box-shadow: 0 4px 20px rgba(0, 0, 0, .5)
}

.lib-card-top {
    padding: 14px 14px 10px;
    background: linear-gradient(180deg, var(--bg4), transparent);
    border-bottom: 1px solid var(--border1)
}

.lib-card-top h4 {
    font-family: 'Cinzel', serif;
    font-size: .9rem;
    font-weight: 600;
    color: var(--amber);
    line-height: 1.3
}

.lib-card-meta {
    font-family: 'Cinzel', serif;
    font-size: .57rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--s500);
    margin: 4px 0 8px
}

.lib-card-desc {
    font-size: .82rem;
    color: var(--s500);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden
}

.lib-card-foot {
    padding: 10px;
    background: rgba(6, 3, 1, .4)
}

/* ─── CREATE / PROFILE FORMS ─────────────────── */
.cf-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px
}

.cf-row3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
    margin-bottom: 16px
}

.cf-group {
    margin-bottom: 16px
}

.cf-label {
    display: block;
    font-family: 'Cinzel', serif;
    font-size: .6rem;
    font-weight: 700;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--s600);
    margin-bottom: 7px
}

.cf-input {
    width: 100%;
    background: rgba(6, 3, 1, .5);
    border: none;
    border-bottom: 2px solid var(--border2);
    padding: 7px 2px;
    color: #f5d98b;
    font-family: 'IM Fell English', serif;
    font-size: 1rem;
    transition: border-color .2s
}

.cf-input:focus {
    outline: none;
    border-bottom-color: var(--amber)
}

.cf-input::placeholder {
    color: var(--s600);
    font-style: italic
}

.cf-select {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: 6px;
    padding: 9px 12px;
    color: var(--s300);
    outline: none;
    cursor: pointer;
    font-size: .9rem;
    transition: border-color .2s
}

.cf-select:focus {
    border-color: var(--amber3)
}

.cf-textarea {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border2);
    border-radius: 6px;
    padding: 11px 13px;
    color: var(--s300);
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
    outline: none;
    font-size: .95rem;
    transition: border-color .2s;
    margin-top: 6px
}

.cf-textarea:focus {
    border-color: var(--amber3)
}

.slot-config-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border1)
}

.slot-config-row:last-of-type {
    border-bottom: none
}

.slot-config-lv {
    font-family: 'Cinzel', serif;
    font-size: .75rem;
    color: var(--s400);
    min-width: 70px
}

.slot-config-ctrls {
    display: flex;
    align-items: center;
    gap: 10px
}

/* ─── BUTTONS ────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 18px;
    border-radius: 6px;
    border: 1px solid transparent;
    font-family: 'Cinzel', serif;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .09em;
    text-transform: uppercase;
    transition: all .2s;
    white-space: nowrap;
    cursor: pointer
}

.btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0
}

.btn-amber {
    background: rgba(180, 83, 9, .18);
    border-color: rgba(180, 83, 9, .42);
    color: var(--amber)
}

.btn-amber:hover {
    background: rgba(180, 83, 9, .35)
}

.btn-amber.on {
    background: var(--amber4);
    border-color: var(--amber3);
    color: #fff;
    box-shadow: 0 0 16px rgba(180, 83, 9, .5)
}

.btn-ghost {
    background: var(--bg4);
    border-color: var(--border2);
    color: var(--s400)
}

.btn-ghost:hover {
    background: var(--bg5);
    color: var(--s200)
}

.btn-danger {
    background: rgba(127, 29, 29, .25);
    border-color: rgba(185, 28, 28, .5);
    color: #f87171
}

.btn-danger:hover {
    background: rgba(127, 29, 29, .45)
}

.btn-full {
    width: 100%
}

.btn-lg {
    padding: 14px 22px;
    font-size: .75rem
}

/* ─── FAB ────────────────────────────────────── */
#fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 140
}

.fab-main-btn {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--amber5), var(--amber4), var(--amber3));
    color: #fff;
    box-shadow: 0 4px 20px rgba(180, 83, 9, .6), 0 0 40px rgba(245, 158, 11, .2);
    transition: all .35s var(--ease);
    display: flex;
    align-items: center;
    justify-content: center
}

.fab-main-btn svg {
    width: 24px;
    height: 24px;
    transition: transform .35s var(--ease)
}

#fab.open .fab-main-btn svg {
    transform: rotate(45deg)
}

.fab-items {
    position: absolute;
    bottom: 70px;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 9px;
    align-items: flex-end;
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
    transition: all .3s var(--ease)
}

#fab.open .fab-items {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0)
}

.fab-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(20, 10, 4, .92);
    border: 1px solid var(--border3);
    border-radius: 24px;
    padding: 10px 16px;
    color: var(--amber);
    font-family: 'Cinzel', serif;
    font-size: .72rem;
    letter-spacing: .07em;
    text-transform: uppercase;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .6);
    transition: all .2s;
    backdrop-filter: blur(10px)
}

.fab-item:hover {
    background: rgba(35, 18, 8, .95);
    transform: translateX(-4px);
    border-color: var(--amber)
}

.fab-item svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0
}

/* ─── OVERLAY ────────────────────────────────── */
#overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .75);
    z-index: 130;
    opacity: 0;
    pointer-events: none;
    transition: opacity .35s;
    backdrop-filter: blur(2px)
}

#overlay.on {
    opacity: 1;
    pointer-events: all
}

/* ─── MODALS ─────────────────────────────────── */
.modal-bg {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .88);
    backdrop-filter: blur(6px);
    z-index: 250;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s
}

.modal-bg.open {
    opacity: 1;
    pointer-events: all
}

.modal {
    background: var(--bg3);
    border: 1px solid rgba(180, 83, 9, .35);
    border-radius: 12px;
    padding: 32px;
    max-width: 460px;
    width: 100%;
    position: relative;
    box-shadow: 0 0 60px rgba(0, 0, 0, .95), 0 0 30px rgba(180, 83, 9, .12);
    transform: scale(.95) translateY(10px);
    transition: transform .25s var(--ease)
}

.modal-bg.open .modal {
    transform: scale(1) translateY(0)
}

.modal-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--amber5), var(--amber), var(--amber3));
    border-radius: 12px 12px 0 0
}

.modal-x {
    position: absolute;
    top: 12px;
    right: 12px;
    color: var(--s600);
    padding: 4px;
    transition: color .2s
}

.modal-x:hover {
    color: var(--s300)
}

.modal-x svg {
    width: 18px;
    height: 18px
}

.modal-wide {
    max-width: 580px
}

/* ─── MODAL DE CONSULTA DE MAGIA ────────────────── */
.consult-name {
    font-family: 'Cinzel', serif;
    font-size: 1.25rem;
    color: var(--amber);
    margin-bottom: 5px;
    padding-right: 28px
}

.consult-meta {
    font-family: 'Cinzel', serif;
    font-size: .58rem;
    text-transform: uppercase;
    letter-spacing: .18em;
    color: var(--s600);
    margin-bottom: 16px
}

.consult-props {
    font-family: 'Crimson Text', serif;
    font-size: .95rem;
    font-style: italic;
    color: var(--s400);
    border-left: 2px solid var(--border2);
    padding-left: 10px;
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 2px
}

.consult-desc {
    font-family: 'Crimson Text', serif;
    font-size: 1rem;
    line-height: 1.7;
    color: var(--s300);
    margin-bottom: 20px;
    white-space: pre-line;
    max-height: 42vh;
    overflow-y: auto;
    padding-right: 4px
}

.consult-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 14px;
    border-top: 1px solid var(--border1)
}

.lay-row {
    display: flex;
    gap: 6px
}

.lay-btn {
    flex: 1;
    padding: 8px 4px;
    font-family: 'Cinzel', serif;
    font-size: .62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    border: 1px solid var(--border2);
    background: var(--bg4);
    color: var(--s500);
    border-radius: 4px;
    transition: all .15s
}

.lay-btn:hover {
    background: var(--bg5);
    color: var(--s300)
}

.lay-btn.sel {
    background: rgba(180, 83, 9, .28);
    border-color: var(--amber3);
    color: var(--amber)
}

.ckl {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    background: var(--bg4);
    border: 1px solid var(--border1);
    border-radius: 5px;
    cursor: pointer;
    font-size: .9rem;
    color: var(--s300);
    margin-bottom: 5px;
    transition: background .2s
}

.ckl:hover {
    background: var(--bg5)
}

.ckl input {
    accent-color: var(--amber3);
    width: 15px;
    height: 15px
}

.mv-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin: 14px 0
}

.mv-btn {
    padding: 8px;
    border: 1px solid var(--border2);
    background: var(--bg4);
    color: var(--s500);
    border-radius: 4px;
    font-family: 'Cinzel', serif;
    font-size: .6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all .15s
}

.mv-btn:hover:not(:disabled) {
    background: var(--bg5);
    color: var(--s300)
}

.mv-btn:disabled {
    opacity: .25;
    cursor: not-allowed
}

.mv-btn svg {
    width: 12px;
    height: 12px
}

.scroll-icon {
    text-align: center;
    margin: 4px 0 18px
}

.scroll-icon svg {
    width: 54px;
    height: 54px;
    color: var(--amber)
}

/* ─── TOAST ──────────────────────────────────── */
#toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-6px);
    background: var(--bg3);
    border: 1px solid rgba(245, 158, 11, .35);
    color: var(--amber);
    padding: 11px 22px;
    border-radius: 8px;
    font-family: 'Cinzel', serif;
    font-size: .72rem;
    letter-spacing: .06em;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s, transform .25s;
    box-shadow: 0 4px 24px rgba(0, 0, 0, .7), 0 0 20px rgba(180, 83, 9, .2);
    white-space: nowrap
}

#toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0)
}

#toast svg {
    width: 14px;
    height: 14px
}

/* ─── MISC ───────────────────────────────────── */
.sec-ttl {
    display: block;
    font-family: 'Cinzel', serif;
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--s600);
    margin-bottom: 8px
}

.divider {
    border: none;
    border-top: 1px solid var(--border1);
    margin: 16px 0
}

::-webkit-scrollbar {
    width: 5px;
    height: 5px
}

::-webkit-scrollbar-track {
    background: var(--bg)
}

::-webkit-scrollbar-thumb {
    background: var(--border2);
    border-radius: 3px
}

::-webkit-scrollbar-thumb:hover {
    background: var(--amber4)
}

.book-pg .inner::-webkit-scrollbar {
    width: 3px
}

.book-pg .inner::-webkit-scrollbar-thumb {
    background: var(--ink6)
}

/* ─── CONEXÕES SHEET ─────────────────────────── */
.conn-section {
    margin-bottom: 22px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--border1)
}

.conn-section:last-child {
    border-bottom: none;
    margin-bottom: 0
}

.conn-section-title {
    font-family: 'Cinzel', serif;
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--s600);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px
}

.conn-section-title svg {
    width: 14px;
    height: 14px;
    color: var(--amber4)
}

/* Discord */
.discord-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: 8px;
    border: 1px solid #5865F2;
    background: rgba(88, 101, 242, .15);
    color: #7b8cf7;
    font-family: 'Cinzel', serif;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    transition: all .2s;
    width: 100%
}

.discord-btn:hover {
    background: rgba(88, 101, 242, .28);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(88, 101, 242, .25)
}

.discord-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0
}

.discord-connected {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: rgba(88, 101, 242, .12);
    border: 1px solid rgba(88, 101, 242, .3);
    border-radius: 8px
}

.discord-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid rgba(88, 101, 242, .5);
    object-fit: cover;
    background: rgba(88, 101, 242, .2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: 'Cinzel', serif;
    font-size: .8rem;
    color: #7b8cf7
}

.discord-info {
    flex: 1;
    min-width: 0
}

.discord-name {
    font-family: 'Cinzel', serif;
    font-size: .82rem;
    font-weight: 600;
    color: #a5b4fc
}

.discord-tag {
    font-size: .72rem;
    color: var(--s500);
    margin-top: 1px
}

.discord-disc-btn {
    background: none;
    border: 1px solid rgba(220, 80, 80, .3);
    color: rgba(248, 113, 113, .7);
    border-radius: 5px;
    padding: 4px 9px;
    font-size: .6rem;
    font-family: 'Cinzel', serif;
    text-transform: uppercase;
    letter-spacing: .06em;
    transition: all .15s;
    flex-shrink: 0
}

.discord-disc-btn:hover {
    background: rgba(220, 80, 80, .15);
    color: #f87171
}

/* Online grimoire */
.online-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--bg3);
    border: 1px solid var(--border1);
    border-radius: 8px;
    margin-bottom: 10px
}

.online-toggle-info .ot-label {
    font-family: 'Cinzel', serif;
    font-size: .78rem;
    font-weight: 600;
    color: var(--s300)
}

.online-toggle-info .ot-sub {
    font-size: .75rem;
    color: var(--s500);
    margin-top: 2px;
    font-style: italic
}

.toggle-switch {
    width: 44px;
    height: 24px;
    border-radius: 12px;
    background: var(--bg5);
    border: 1px solid var(--border2);
    position: relative;
    cursor: pointer;
    transition: background .25s;
    flex-shrink: 0
}

.toggle-switch.on {
    background: var(--amber4);
    border-color: var(--amber3)
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform .25s;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .4)
}

.toggle-switch.on::after {
    transform: translateX(20px)
}

.toggle-switch.disabled {
    opacity: .35;
    cursor: not-allowed
}

.share-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(6, 3, 1, .5);
    border: 1px solid var(--border1);
    border-radius: 6px;
    padding: 8px 12px
}

.share-url {
    flex: 1;
    font-size: .72rem;
    color: var(--s400);
    font-family: monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.share-copy-btn {
    background: var(--bg4);
    border: 1px solid var(--border2);
    color: var(--amber3);
    border-radius: 5px;
    padding: 5px 9px;
    font-size: .6rem;
    font-family: 'Cinzel', serif;
    letter-spacing: .06em;
    text-transform: uppercase;
    transition: all .15s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px
}

.share-copy-btn:hover {
    background: var(--bg5);
    border-color: var(--amber)
}

.share-copy-btn svg {
    width: 12px;
    height: 12px
}

/* Handshake */
.handshake-token-display {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: rgba(180, 83, 9, .08);
    border: 1px solid rgba(180, 83, 9, .25);
    border-radius: 8px;
    margin-bottom: 10px
}

.hs-token {
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: .25em;
    color: var(--amber);
    text-shadow: 0 0 14px rgba(245, 158, 11, .4)
}

.hs-status {
    font-size: .72rem;
    color: var(--s500);
    font-style: italic;
    margin-top: 2px
}

.hs-pulse {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--amber3);
    margin-right: 5px;
    animation: hsPulse 1.5s ease-in-out infinite
}

.hs-dot-ok {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    margin-right: 5px;
    box-shadow: 0 0 8px rgba(74, 222, 128, .5)
}

@keyframes hsPulse {

    0%,
    100% {
        opacity: .4;
        transform: scale(1)
    }

    50% {
        opacity: 1;
        transform: scale(1.2)
    }
}

.hs-connected-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(30, 100, 30, .15);
    border: 1px solid rgba(46, 125, 50, .3);
    border-radius: 8px;
    font-family: 'Cinzel', serif;
    font-size: .72rem;
    color: #4ade80
}

.hs-connected-badge svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0
}

/* Read-only banner */
#readonly-banner {
    width: 100%;
    max-width: 960px;
    margin-bottom: 14px;
    background: rgba(88, 101, 242, .12);
    border: 1px solid rgba(88, 101, 242, .3);
    border-radius: 10px;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 2;
}

#readonly-banner svg {
    width: 18px;
    height: 18px;
    color: #7b8cf7;
    flex-shrink: 0
}

.rb-text {
    font-family: 'Cinzel', serif;
    font-size: .75rem;
    color: #a5b4fc;
    letter-spacing: .04em
}

.rb-sub {
    font-size: .72rem;
    color: var(--s500);
    margin-top: 2px;
    font-family: 'Crimson Text', serif;
    font-style: italic
}

.rb-open-btn {
    margin-left: auto;
    background: rgba(88, 101, 242, .2);
    border: 1px solid rgba(88, 101, 242, .4);
    border-radius: 6px;
    padding: 7px 14px;
    color: #a5b4fc;
    font-family: 'Cinzel', serif;
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    transition: all .2s;
    flex-shrink: 0
}

.rb-open-btn:hover {
    background: rgba(88, 101, 242, .35)
}

/* ─── RESPONSIVE ─────────────────────────────── */
@media(max-width:768px) {
    #scene {
        padding: 10px 14px 80px;
        perspective: none
    }

    #grimoire-mount {
        transform: none !important
    }

    #grimoire {
        height: min(560px, 72vh)
    }

    .book-pg.pg-right {
        display: none
    }

    #spine {
        display: none
    }

    .book-pg.pg-left .inner {
        border-radius: 4px
    }

    .book-pg.pg-left .inner::after {
        display: none
    }

    #pg-nav {
        width: calc(100% + 56px);
        left: -28px
    }

    .pg-btn {
        width: 34px;
        height: 34px
    }

    #hud {
        flex-direction: column;
        align-items: flex-start
    }

    #slots-hud {
        justify-content: flex-start
    }

    #book-toolbar {
        gap: 6px
    }

    #bk-pg-info {
        display: none
    }

    #fab {
        bottom: 20px;
        right: 20px
    }

    .lib-grid {
        grid-template-columns: 1fr
    }

    .cf-row,
    .cf-row3 {
        grid-template-columns: 1fr
    }

    #toast {
        top: 14px
    }

    .chars-grid {
        grid-template-columns: 1fr 1fr
    }

    #readonly-banner {
        flex-wrap: wrap
    }
}

@media(max-width:480px) {
    .modal {
        padding: 22px
    }

    .chars-grid {
        grid-template-columns: 1fr
    }
}

/* ─── BOOK TOOLBAR ──────────────────────────── */
#book-toolbar {
    width: 100%;
    max-width: 960px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    position: relative;
    z-index: 2;
    gap: 10px;
    flex-wrap: wrap;
}

.bk-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 13px;
    border-radius: 6px;
    border: 1px solid var(--border2);
    background: rgba(14, 7, 3, .78);
    backdrop-filter: blur(8px);
    color: var(--s500);
    font-family: 'Cinzel', serif;
    font-size: .6rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    transition: all .2s;
    white-space: nowrap;
}

.bk-btn:hover {
    border-color: var(--border3);
    color: var(--amber3)
}

.bk-btn.on {
    background: rgba(180, 83, 9, .18);
    border-color: rgba(180, 83, 9, .4);
    color: var(--amber)
}

.bk-btn svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0
}

#bk-pg-info {
    font-family: 'Cinzel', serif;
    font-size: .6rem;
    font-weight: 600;
    letter-spacing: .12em;
    color: var(--s600);
    flex: 1;
    text-align: center;
}

/* ─── COVER / INDEX PAGES ────────────────────── */
.index-title {
    font-family: 'Cinzel', serif;
    font-size: .95rem;
    font-weight: 700;
    color: var(--ink1);
    margin-bottom: 3px;
    text-align: center;
    text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
}

.index-rule {
    border: none;
    border-top: 1px solid var(--parch4);
    margin: 6px 0 12px
}

.index-lv-head {
    font-family: 'Cinzel', serif;
    font-size: .58rem;
    font-weight: 700;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--ink5);
    margin: 11px 0 4px;
    opacity: .65;
}

.index-row {
    display: flex;
    align-items: baseline;
    gap: 3px;
    padding: 2px 0;
    cursor: pointer;
}

.index-row:hover .ir-name {
    color: var(--ink1);
    text-decoration: underline
}

.ir-name {
    font-family: 'IM Fell English', serif;
    font-size: .82rem;
    color: var(--ink3);
    white-space: nowrap;
    overflow: hidden;
    flex-shrink: 1;
    min-width: 0
}

.ir-dots {
    flex: 1;
    border-bottom: 1px dotted var(--parch4);
    margin: 0 3px 3px;
    min-width: 8px
}

.ir-pg {
    font-family: 'Cinzel', serif;
    font-size: .65rem;
    color: var(--ink5);
    white-space: nowrap;
    flex-shrink: 0
}

.index-empty {
    font-family: 'IM Fell English', serif;
    font-style: italic;
    color: var(--ink6);
    font-size: .82rem;
    opacity: .55;
    margin-top: 24px;
    text-align: center;
    line-height: 1.7;
}

/* ─── BOOKMARK TABS ──────────────────────────── */
.bm-tab {
    position: absolute;
    z-index: 30;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Cinzel', serif;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .7);
    transition: transform .15s, filter .15s;
    user-select: none;
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, .55));
}

.bm-tab:hover {
    filter: drop-shadow(0 3px 10px rgba(0, 0, 0, .75)) brightness(1.15)
}

.bm-tab.bm-right {
    font-size: .6rem;
    width: 20px;
    height: 32px;
    border-radius: 0 5px 5px 0;
    writing-mode: vertical-rl;
    letter-spacing: .04em
}

.bm-tab.bm-right:hover {
    transform: translateX(5px)
}

.bm-tab.bm-left {
    font-size: .6rem;
    width: 20px;
    height: 32px;
    border-radius: 5px 0 0 5px;
    writing-mode: vertical-rl;
    letter-spacing: .04em
}

.bm-tab.bm-left:hover {
    transform: translateX(-5px)
}

.bm-tab.bm-top {
    font-size: .58rem;
    width: 32px;
    height: 16px;
    border-radius: 5px 5px 0 0;
    letter-spacing: .05em
}

.bm-tab.bm-top:hover {
    transform: translateY(-4px)
}

.bm-tab.bm-bottom {
    font-size: .58rem;
    width: 32px;
    height: 16px;
    border-radius: 0 0 5px 5px;
    letter-spacing: .05em
}

.bm-tab.bm-bottom:hover {
    transform: translateY(4px)
}

@keyframes bmPulse {
    0% {
        transform: scale(1)
    }

    50% {
        transform: scale(1.18)
    }

    100% {
        transform: scale(1)
    }
}

.bm-tab.pop {
    animation: bmPulse .3s ease
}

/* ─── BOOKMARK MODAL ─────────────────────────── */
#bm-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .86);
    backdrop-filter: blur(6px);
    z-index: 270;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
}

#bm-modal.open {
    opacity: 1;
    pointer-events: all
}

.bm-box {
    background: var(--bg3);
    border: 1px solid rgba(180, 83, 9, .35);
    border-radius: 12px;
    padding: 26px;
    max-width: 360px;
    width: 100%;
    position: relative;
    box-shadow: 0 0 60px rgba(0, 0, 0, .95);
    transform: scale(.95) translateY(10px);
    transition: transform .25s var(--ease);
}

#bm-modal.open .bm-box {
    transform: scale(1) translateY(0)
}

.bm-preview {
    width: 46px;
    height: 46px;
    border-radius: 7px;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .6);
    box-shadow: 0 4px 14px rgba(0, 0, 0, .5);
    transition: background .2s;
}

.bm-colors {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-bottom: 14px
}

.bm-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all .15s;
    flex-shrink: 0;
}

.bm-swatch:hover,
.bm-swatch.sel {
    border-color: #fff;
    transform: scale(1.18);
    box-shadow: 0 0 8px rgba(255, 255, 255, .4)
}

.bm-custom-color {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px dashed var(--border2);
    overflow: hidden;
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.bm-custom-color input[type=color] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%
}

.bm-custom-color svg {
    pointer-events: none;
    color: var(--s600);
    position: relative
}

.bm-pos {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 14px
}

.bm-pos-btn {
    padding: 8px;
    border: 1px solid var(--border2);
    background: var(--bg4);
    color: var(--s500);
    border-radius: 5px;
    font-family: 'Cinzel', serif;
    font-size: .6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    transition: all .15s;
}

.bm-pos-btn:hover {
    background: var(--bg5);
    color: var(--s300)
}

.bm-pos-btn.sel {
    background: rgba(180, 83, 9, .25);
    border-color: var(--amber3);
    color: var(--amber)
}

.bm-off-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px
}

.bm-off-row label {
    font-family: 'Cinzel', serif;
    font-size: .58rem;
    color: var(--s600);
    text-transform: uppercase;
    letter-spacing: .1em;
    white-space: nowrap;
    flex-shrink: 0
}

.bm-off-row input[type=range] {
    flex: 1;
    accent-color: var(--amber3);
    height: 4px
}

.bm-off-val {
    font-family: 'Cinzel', serif;
    font-size: .62rem;
    color: var(--s500);
    min-width: 28px;
    text-align: right
}

.bm-pg-note {
    text-align: center;
    font-family: 'IM Fell English', serif;
    font-style: italic;
    font-size: .78rem;
    color: var(--s600);
    margin-bottom: 14px
}

/* ─── DRAG & DROP ─────────────────────────────── */

/* Cursor de arrasto apenas no modo edição */
.sp-wrap[draggable="true"] {
    cursor: default;
}
.edit-active .sp-wrap[draggable="true"] {
    cursor: grab;
}
.edit-active .sp-wrap[draggable="true"]:active {
    cursor: grabbing;
}

/* Card de origem enquanto está sendo arrastado */
.sp-wrap.dnd-src {
    opacity: .25;
    outline: 2px dashed var(--amber4);
    outline-offset: -2px;
    border-radius: 4px;
    pointer-events: none;
}

/* Indicador de inserção ANTES do card */
.sp-wrap.dnd-before::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 6px;
    right: 6px;
    height: 3px;
    background: var(--amber);
    border-radius: 2px;
    box-shadow: 0 0 10px rgba(245, 158, 11, .8);
    z-index: 25;
    pointer-events: none;
    animation: dndPulse .6s ease-in-out infinite alternate;
}

/* Indicador de inserção DEPOIS do card */
.sp-wrap.dnd-after::after {
    content: '';
    position: absolute;
    bottom: 15px;    /* alinha com o padding-bottom do sp-wrap */
    left: 6px;
    right: 6px;
    height: 3px;
    background: var(--amber);
    border-radius: 2px;
    box-shadow: 0 0 10px rgba(245, 158, 11, .8);
    z-index: 25;
    pointer-events: none;
    animation: dndPulse .6s ease-in-out infinite alternate;
}

@keyframes dndPulse {
    from { opacity: .7; }
    to   { opacity: 1;  }
}

/* Estado do grimório durante drag */
#grimoire.dnd-active {
    box-shadow: 0 0 0 2px rgba(245, 158, 11, .18), 0 0 40px rgba(245, 158, 11, .06);
    transition: box-shadow .25s;
}

/* Suaviza transições dos cards durante drag */
#grimoire.dnd-active .sp-wrap:not(.dnd-src) {
    transition: opacity .2s;
}

/* Leve pulse nos cards não-fantasma para indicar que são alvos */
#grimoire.dnd-active .sp-wrap:not(.dnd-src):not(.dnd-before):not(.dnd-after) {
    opacity: .85;
}

/* ─── COLUNA COMPARTILHADA ───────────────────── */

/* Container de uma coluna agrupada */
.col-group {
    display: flex;
    flex-direction: column;
    position: relative;
    min-width: 0;
}

/* Borda pontilhada sutil no modo edição */
.edit-active .col-group {
    outline: 1px dashed rgba(245, 158, 11, .22);
    outline-offset: 3px;
    border-radius: 4px;
}

/* Botão "Dissolver coluna" — aparece no hover */
.col-group-del {
    position: absolute;
    top: 5px;
    right: 8px;
    z-index: 20;
    width: 20px;
    height: 20px;
    background: rgba(14, 7, 3, .88);
    border: 1px solid rgba(245, 158, 11, .4);
    border-radius: 4px;
    color: var(--amber3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity .18s, background .18s;
}

.col-group:hover .col-group-del {
    opacity: 1;
}

.col-group-del:hover {
    background: rgba(40, 14, 4, .95);
    color: var(--amber);
}

/* Itens dentro de uma coluna ocupam 100% do container */
.col-group .sp-wrap.w100 {
    width: 100%;
}

/* ─── PAGE GRID 4×4 ──────────────────────────── */
.page-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 4px;
    position: relative;
}

/* Células-guia visíveis no modo edição */
.grid-overlay {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 4px;
    pointer-events: none;
    z-index: 1;
}
.grid-cell {
    border: 1px dashed rgba(245, 158, 11, .1);
    border-radius: 2px;
}

/* Ghost de drag / resize */
.grid-ghost {
    border: 2px solid var(--amber);
    background: rgba(245, 158, 11, .18);
    border-radius: 4px;
    pointer-events: none;
    z-index: 60;
    transition: background .12s, border-color .12s;
}
.grid-ghost.ghost-err {
    border-color: #f87171;
    background: rgba(248, 113, 113, .18);
}

/* Card de origem durante drag (fantasma) */
.sp-wrap.dnd-src {
    opacity: .25;
    outline: 2px dashed var(--amber4);
    outline-offset: -2px;
    border-radius: 3px;
}

/* Cursor: só muda no modo edição */
.edit-active .sp-wrap { cursor: grab; }
.edit-active .sp-wrap:active { cursor: grabbing; }

/* Tipografia escalada por colSpan */
.sp-wrap.gc-full  .sp-card h4 { font-size: 1rem;  }
.sp-wrap.gc-lg    .sp-card h4 { font-size: .9rem;  }
.sp-wrap.gc-half  .sp-card h4 { font-size: .82rem; }
.sp-wrap.gc-sm    .sp-card h4 { font-size: .72rem; }
.sp-wrap.gc-sm  .sp-meta,
.sp-wrap.gc-sm  .sp-props,
.sp-wrap.gc-sm  .sp-desc { font-size: .65rem; }
.sp-wrap.gc-sm  .sp-desc { -webkit-line-clamp: 3; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }

/* Descrição com clamp para cards pequenos */
.sp-wrap.gc-half .sp-desc { -webkit-line-clamp: 4; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }

/* ─── HANDLES DE RESIZE ──────────────────────── */
.rs-e, .rs-s, .rs-se {
    position: absolute;
    z-index: 20;
    background: var(--amber3);
    border-radius: 3px;
    opacity: 0;
    transition: opacity .18s;
}
.edit-active .sp-wrap:hover .rs-e,
.edit-active .sp-wrap:hover .rs-s,
.edit-active .sp-wrap:hover .rs-se { opacity: 1; }

/* Borda direita */
.rs-e {
    right: 0; top: 20%; bottom: 20%;
    width: 5px; cursor: ew-resize;
    border-radius: 3px 0 0 3px;
}
/* Borda inferior */
.rs-s {
    bottom: 0; left: 20%; right: 20%;
    height: 5px; cursor: ns-resize;
    border-radius: 3px 3px 0 0;
}
/* Canto inferior-direito */
.rs-se {
    right: 0; bottom: 0;
    width: 11px; height: 11px; cursor: nwse-resize;
    border-radius: 3px 0 0 0;
}

/* Remove regras antigas de DnD e colGroup que ficaram órfãs */
.sp-wrap[draggable="true"] { cursor: default; }
.edit-active .sp-wrap[draggable="true"] { cursor: grab; }
.edit-active .sp-wrap[draggable="true"]:active { cursor: grabbing; }
