:root {
    --pdm-space-1: 0.25rem;
    --pdm-space-2: 0.5rem;
    --pdm-space-3: 0.75rem;
    --pdm-space-4: 1rem;
    --pdm-space-5: 1.25rem;
    --pdm-space-6: 1.5rem;
    --pdm-space-8: 2rem;
    --pdm-radius-sm: 0.375rem;
    --pdm-radius-md: 0.5rem;
    --pdm-mobile-nav-height: 64px;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* ─── Global Application Shell & Responsive Sidebar Layout ─── */
.app-shell {
    min-height: 100vh;
    background-color: transparent;
    color: var(--on-surface, #d4e4fa);
    font-family: var(--font-body, 'Geist', sans-serif);
    position: relative;
    z-index: 1;
}

[data-theme="grimoire"] h1,
[data-theme="grimoire"] h2,
[data-theme="grimoire"] h3,
[data-theme="grimoire"] h4,
[data-theme="grimoire"] .font-headline-md,
[data-theme="grimoire"] .font-headline-lg,
[data-theme="grimoire"] .font-headline-lg-mobile {
    font-family: var(--font-headline, 'Cinzel', serif) !important;
}

[data-theme="grimoire"] body,
[data-theme="grimoire"] p,
[data-theme="grimoire"] .font-body-md,
[data-theme="grimoire"] .font-body-lg {
    font-family: var(--font-body, 'Alegreya', serif);
}

[data-theme="wildwood"] h1,
[data-theme="wildwood"] h2,
[data-theme="wildwood"] h3,
[data-theme="wildwood"] h4,
[data-theme="wildwood"] .font-headline-md,
[data-theme="wildwood"] .font-headline-lg,
[data-theme="wildwood"] .font-headline-lg-mobile {
    font-family: var(--font-headline, 'Eagle Lake', 'Cinzel', serif) !important;
}

[data-theme="wildwood"] body,
[data-theme="wildwood"] p,
[data-theme="wildwood"] .font-body-md,
[data-theme="wildwood"] .font-body-lg {
    font-family: var(--font-body, 'Alegreya', serif);
}

.material-symbols-outlined,
.material-symbols-sharp,
[class*="material-symbols"] {
    font-family: var(--font-symbol, 'Material Symbols Outlined') !important;
    font-variation-settings:
        'FILL' var(--symbol-fill, 0),
        'wght' var(--symbol-weight, var(--symbol-wght, 400)),
        'GRAD' var(--symbol-grad, 0),
        'opsz' var(--symbol-opsz, 24);
    filter: var(--symbol-filter, none);
    font-weight: normal;
    font-style: normal;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
    transition: filter 0.2s ease, font-variation-settings 0.2s ease, color 0.15s ease;
}

.ttrpg-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: var(--primary, #C5A059);
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    opacity: 0.6;
    margin: 1.5rem 0;
}

.app-main-wrapper {
    min-height: 100vh;
    padding-top: var(--pdm-header-height, 5rem);
    transition: padding-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-shell--expanded .app-main-wrapper {
    padding-left: 260px;
}

.app-shell--collapsed .app-main-wrapper {
    padding-left: 68px;
}

@media (max-width: 767px) {
    .app-shell--expanded .app-main-wrapper,
    .app-shell--collapsed .app-main-wrapper {
        padding-left: 0 !important;
        padding-bottom: 5rem;
    }
}

/* ─── Reusable Floating Action Button / Trigger (Safe Bottom Clearance) ─── */
.floating-action-trigger {
    position: fixed;
    z-index: 45;
    right: 1rem;
    bottom: calc(var(--pdm-mobile-nav-height, 64px) + 1rem);
    bottom: calc(var(--pdm-mobile-nav-height, 64px) + 1rem + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 768px) {
    .floating-action-trigger {
        right: 1.25rem;
        bottom: 1.25rem;
    }
}

/* ─── Table Play Print Stylesheet (@media print) ─── */
@media print {
    /* 1. Global Reset: Disable animations, transitions, backdrop filters, and text shadows that freeze or crash print engines */
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        filter: none !important;
        text-shadow: none !important;
    }

    /* 2. Paper Setup */
    @page {
        margin: 1.2cm;
        size: auto;
    }

    /* 3. Hide all non-printable chrome, navigation, headers, footers, interactive controls, and promotional frames */
    nav,
    header,
    footer,
    aside,
    iframe,
    button,
    input,
    textarea,
    select,
    .app-header,
    .app-footer,
    .app-sidebar,
    .nav-sidebar,
    .app-mobile-nav,
    .mobile-nav-bar,
    .theme-background-fx,
    .theme-texture-overlay,
    .theme-ambient-light,
    .theme-backdrop-art,
    .floating-action-trigger,
    .generation-loading-overlay,
    .feedback-trigger,
    .feedback-modal,
    #blazor-error-ui,
    #generator,
    .generator-panel,
    .generator-card,
    .celebration-banner,
    .action-btn,
    .share-card,
    .share-encounter-card,
    .export-modal-backdrop,
    #campaign-hooks,
    .campaign-hooks-section,
    .hooks-grid,
    .hook-card,
    .encounter-promo-banner,
    .campaign-lineage-nav,
    .export-sheet-button,
    .occupant-card-stack__layer,
    .occupant-card-stack__layer--under,
    .occupant-card-stack__layer--deepest,
    .active-threat__scrim,
    #guest-turnstile,
    .cf-turnstile,
    [id^="cf-turnstile"],
    .paddle-frame,
    [class*="blur-3xl"],
    [class*="blur-2xl"],
    [class*="blur-xl"],
    .tapered-hazard,
    .animate-ping,
    .animate-pulse {
        display: none !important;
        visibility: hidden !important;
    }

    /* 4. Page & Shell Container Neutralization */
    html,
    body,
    .app-shell,
    .app-main-wrapper,
    .app-shell--expanded .app-main-wrapper,
    .app-shell--collapsed .app-main-wrapper,
    .home-main,
    .home-layout,
    .home-content {
        background: #ffffff !important;
        background-color: #ffffff !important;
        background-image: none !important;
        color: #111827 !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-height: 0 !important;
        height: auto !important;
        overflow: visible !important;
        box-shadow: none !important;
        position: static !important;
        gap: 1.5rem !important;
    }

    /* 5. High-Specificity Card & Frame Overrides (Defeats Scoped Theme Styles) */
    html body [data-theme] .active-threat,
    html body [data-theme] .room-card,
    html body [data-theme] .occupant-card,
    html body [data-theme] .occupant-card--boss,
    html body [data-theme] .occupant-card--quirked,
    html body [data-theme] .loot-card,
    html body [data-theme] .twist-card,
    html body [data-theme] .short-rest-card,
    .active-threat,
    .room-card,
    .occupant-card,
    .occupant-card--boss,
    .occupant-card--quirked,
    .loot-card,
    .twist-card,
    .short-rest-card {
        background: #ffffff !important;
        background-color: #ffffff !important;
        background-image: none !important;
        color: #111827 !important;
        border: 1.5px solid #d1d5db !important;
        border-image: none !important;
        border-image-source: none !important;
        border-image-slice: 0 !important;
        border-width: 1.5px !important;
        border-style: solid !important;
        outline: none !important;
        outline-offset: 0 !important;
        box-shadow: none !important;
        break-inside: avoid !important;
        page-break-inside: avoid !important;
        margin-bottom: 1.5rem !important;
        border-radius: 0.5rem !important;
        padding: 1.25rem !important;
    }

    /* 6. Threat & Room Headings */
    html body [data-theme] .active-threat h1,
    html body [data-theme] .room-header h2,
    html body [data-theme] .occupant-card__title,
    html body [data-theme] .loot-card h2,
    .active-threat h1,
    .room-header h2,
    .occupant-card__title,
    .loot-card h2 {
        color: #111827 !important;
        text-shadow: none !important;
    }

    html body [data-theme] .room-header,
    html body [data-theme] .occupant-card__header,
    .room-header,
    .occupant-card__header {
        background: #f3f4f6 !important;
        background-color: #f3f4f6 !important;
        background-image: none !important;
        border-bottom: 1px solid #e5e7eb !important;
        margin: -1.25rem -1.25rem 0.75rem -1.25rem !important;
        padding: 0.75rem 1.25rem !important;
        border-radius: 0.5rem 0.5rem 0 0 !important;
    }

    /* 7. Occupant Card Sub-sections */
    html body [data-theme] .occupant-card__basics,
    html body [data-theme] .occupant-card__abilities > div,
    html body [data-theme] .occupant-card__details,
    html body [data-theme] .occupant-card__ability-section,
    html body [data-theme] .occupant-card__quirk-callout,
    .occupant-card__basics,
    .occupant-card__abilities > div,
    .occupant-card__details,
    .occupant-card__ability-section,
    .occupant-card__quirk-callout {
        background: #f9fafb !important;
        background-color: #f9fafb !important;
        background-image: none !important;
        border: 1px solid #e5e7eb !important;
        color: #1f2937 !important;
        box-shadow: none !important;
    }

    html body [data-theme] .occupant-card__basics strong,
    html body [data-theme] .occupant-card__details strong,
    html body [data-theme] .occupant-card__ability-section h4,
    html body [data-theme] .occupant-card__quirk-heading,
    html body [data-theme] .occupant-card__quirk-action strong,
    .occupant-card__basics strong,
    .occupant-card__details strong,
    .occupant-card__ability-section h4,
    .occupant-card__quirk-heading,
    .occupant-card__quirk-action strong {
        color: #111827 !important;
    }

    html body [data-theme] .occupant-card__subtitle,
    html body [data-theme] .occupant-card__ability,
    html body [data-theme] .occupant-card__quirk-action,
    .occupant-card__subtitle,
    .occupant-card__ability,
    .occupant-card__quirk-action {
        color: #374151 !important;
    }

    html body [data-theme] .occupant-card__badge,
    html body [data-theme] .occupant-card__challenge,
    .occupant-card__badge,
    .occupant-card__challenge {
        background: #e5e7eb !important;
        border-color: #d1d5db !important;
        color: #111827 !important;
        text-shadow: none !important;
    }

    /* 8. Stacked Count Badge */
    .occupant-card-stack__badge {
        position: static !important;
        margin-bottom: 0.5rem !important;
        background: #e5e7eb !important;
        border: 1px solid #9ca3af !important;
        color: #111827 !important;
        box-shadow: none !important;
    }

    /* 9. Loot Items & Badges */
    html body [data-theme] .loot-item,
    .loot-item {
        background: #f9fafb !important;
        background-color: #f9fafb !important;
        background-image: none !important;
        border: 1px solid #e5e7eb !important;
        box-shadow: none !important;
        color: #111827 !important;
    }

    html body [data-theme] .loot-badge,
    .loot-badge {
        background: #e5e7eb !important;
        border: 1px solid #d1d5db !important;
        color: #111827 !important;
        box-shadow: none !important;
    }

    /* 10. Short Rest Card */
    html body [data-theme] .short-rest-card,
    .short-rest-card {
        border-color: #d1d5db !important;
    }

    .short-rest-card h3 {
        color: #111827 !important;
    }

    .short-rest-card p {
        color: #374151 !important;
    }

    /* 11. Links */
    a {
        color: #111827 !important;
        text-decoration: none !important;
    }
}