.modal-dialog {
    width: 90%;
    max-width: calc(var(--container-width) * 0.9);
}

body.bg-dark {
    min-height: 100vh;
    background:
        radial-gradient(circle at 12% 8%, rgba(94, 30, 14, 0.26), transparent 24%),
        radial-gradient(circle at 88% 12%, rgba(193, 177, 138, 0.16), transparent 22%),
        linear-gradient(145deg, #0d1118 0%, #171e29 40%, #111722 100%) !important;
    color: #e9e3d3;
    background-attachment: fixed;
}

.cms-shell {
    background: rgba(9, 12, 18, 0.42);
    border: 1px solid rgba(193, 177, 138, 0.2);
    border-radius: 14px;
    padding: 1rem 1rem 1.25rem;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.32);
}

#cmsTabs {
    border-bottom: 1px solid rgba(193, 177, 138, 0.35);
    gap: 0.25rem;
}

#cmsTabs .nav-item {
    margin-bottom: 0;
}

#cmsTabs .nav-link {
    color: #d7cfb8;
    background-color: rgba(22, 28, 38, 0.9);
    border: 1px solid rgba(130, 139, 155, 0.55);
    border-bottom: none;
    border-top-left-radius: 0.5rem;
    border-top-right-radius: 0.5rem;
    transition: all 0.18s ease-in-out;
}

#cmsTabs .nav-link:hover,
#cmsTabs .nav-link:focus {
    color: #ffffff;
    background-color: rgba(40, 48, 62, 0.95);
    border-color: rgba(179, 189, 206, 0.7);
}

#cmsTabs .nav-link.active {
    color: #111111;
    background-color: #c1b18a;
    border-color: #8b7a55;
    border-bottom-color: #c1b18a;
    font-weight: 600;
}

/* Keep Character tab as a Bootstrap row (flex) only when active.
   This avoids forcing visibility on other tabs. */
#character.tab-pane.active {
    display: flex;
    flex-wrap: wrap;
}

#characterSaveControls .btn {
    box-shadow: 0 4px 14px rgba(25, 135, 84, 0.25);
}

#character .char-xp-input {
    width: 4.8rem;
    min-width: 4.8rem;
    flex: 0 0 4.8rem;
}

#character .char-specialized-skill-name {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    resize: none;
    min-height: 2rem;
    line-height: 1.2;
}

#character .char-skill-category-block {
    border-radius: 0.4rem;
    transition: opacity 0.18s ease-in-out, box-shadow 0.18s ease-in-out;
}

#character .char-skill-category-block + .char-skill-category-block {
    margin-top: 0.8rem;
    padding-top: 0.8rem;
    position: relative;
}

#character .char-skill-category-block + .char-skill-category-block::before {
    content: "";
    position: absolute;
    top: 0;
    left: 10%;
    width: 80%;
    border-top: 1px solid rgba(17, 17, 17, 0.35);
}

#character .char-skill-category-block.char-category-disabled {
    opacity: 0.48;
}

#character .char-skill-row.char-skill-locked .char-skill-value {
    background-color: #d7ccb0 !important;
    cursor: not-allowed;
}

#character .char-skill-row.char-skill-locked .xp-step-btn {
    opacity: 0.45;
}

#character .char-skill-invalid {
    border: 2px solid #dc3545 !important;
    box-shadow: 0 0 0 0.08rem rgba(220, 53, 69, 0.2);
}

#character .char-header-info-icon {
    color: #e0d6be;
    font-size: 0.95rem;
}

#character .char-skill-label-clickable {
    cursor: pointer;
    text-decoration: underline dotted;
    text-underline-offset: 2px;
}

#character .char-skill-specialization-display {
    color: #3f3f3f;
    font-style: italic;
    margin-left: 0.25rem;
}

#character .char-category-invalid {
    border: 2px solid #dc3545;
    padding: 0.35rem;
}

#character .char-vf-invalid .form-select {
    border: 2px solid #dc3545 !important;
    box-shadow: 0 0 0 0.08rem rgba(220, 53, 69, 0.2);
}

#character #charCharacteristicsCard.char-characteristics-invalid,
#character #charCharacteristicsCard.char-characteristics-rule-invalid {
    border: 2px solid #dc3545 !important;
    box-shadow: 0 0 0 0.08rem rgba(220, 53, 69, 0.2);
}

#character #charVirtuesCard.char-points-invalid {
    border: 2px solid #dc3545 !important;
    box-shadow: 0 0 0 0.08rem rgba(220, 53, 69, 0.2);
}

#character [contenteditable].char-attribute-invalid {
    border-bottom: 2px solid #dc3545 !important;
    box-shadow: inset 0 -1px 0 rgba(220, 53, 69, 0.35);
}

.dropdown-menu.bg-dark .dropdown-item {
    color: #f8f9fa !important;
}

.dropdown-menu.bg-dark .dropdown-item:hover,
.dropdown-menu.bg-dark .dropdown-item:focus {
    color: #ffffff !important;
    background-color: #5e1e0e !important;
}

.dropdown-menu.bg-dark .dropdown-item.active,
.dropdown-menu.bg-dark .dropdown-item:active {
    color: #ffffff !important;
    background-color: #7a2a15 !important;
}

#character .dropdown-menu.bg-dark {
    background-color: #e0d6be !important;
    color: #111111 !important;
    border: 1px solid #212529 !important;
}

#character .dropdown-menu.bg-dark .dropdown-item {
    color: #111111 !important;
}

#character .dropdown-menu.bg-dark .dropdown-item:hover,
#character .dropdown-menu.bg-dark .dropdown-item:focus {
    color: #111111 !important;
    background-color: #c1b18a !important;
}

#character .dropdown-menu.bg-dark .dropdown-item.active,
#character .dropdown-menu.bg-dark .dropdown-item:active {
    color: #111111 !important;
    background-color: #b7a578 !important;
}


/* Define container widths to match Bootstrap breakpoints */
@media (min-width: 576px) { /* sm */
    :root { --container-width: 540px; }
}
@media (min-width: 768px) { /* md */
    :root { --container-width: 720px; }
}
@media (min-width: 992px) { /* lg */
    :root { --container-width: 960px; }
}
@media (min-width: 1200px) { /* xl */
    :root { --container-width: 1140px; }
}
@media (min-width: 1400px) { /* xxl */
    :root { --container-width: 1320px; }
}

/* Ensure dropdown items have a dark background on hover */
#spellSubmission .dropdown-menu .dropdown-item:hover {
    background-color: #343a40 !important; /* Bootstrap's dark color */
    color: white !important; /* Ensure text stays readable */
}

.AnimalBG   { background-color: #3F2A20 !important; }
.AquamBG    { background-color: #1B3A5E !important; }
.AuramBG    { background-color: #3B4A66 !important; }
.CorpusBG   { background-color: #551B2F !important; }
.HerbamBG   { background-color: #1D442F !important; }
.IgnemBG    { background-color: #7A1B0C !important; }
.ImaginemBG { background-color: #38264A !important; }
.MentemBG   { background-color: #4A1B4F !important; }
.TerramBG   { background-color: #4E3B1B !important; }
.VimBG      { background-color: #28235E !important; }

/* Prevent Bootstrap override for Above BG colors. */
.table-striped tbody tr th[class$="BG"] { --bs-table-accent-bg: unset !important; }

/* And Character Generation */

/*.characteristicValue::after {*/
/*    content: "";*/
/*    position: absolute;*/
/*    bottom: 0;*/
/*    right: 0;*/
/*    width: 50%;*/
/*    height: 1px;*/
/*    background-color: #ccc;*/
/*}*/

/* Spells + Spell Linking + Import + Bestiary tabs: align visual language with Character tab panels */
#spells .am-section-shell,
#characterSpells .am-section-shell,
#spellImport .am-section-shell,
#bestiary .am-section-shell {
    background-color: #c1b18a;
    border: 1px solid #8b7a55;
}

#spells .am-section-header,
#characterSpells .am-section-header,
#spellImport .am-section-header,
#bestiary .am-section-header {
    background-color: #5e1e0e !important;
    color: #ffffff;
}

#spells .am-spell-card {
    background-color: #c1b18a;
    border: 1px solid #8b7a55 !important;
}

#spells .am-spell-card .card-header {
    background-color: #5e1e0e !important;
    color: #ffffff;
    border-bottom: 0;
}

#spells .am-spell-card .card-body,
#spells .am-spell-card .card-footer {
    background-color: #c1b18a;
    color: #111111;
}

#spells .am-spell-card .card-footer {
    border-top: 1px solid #8b7a55;
}

#spells .am-spell-card .form-label,
#spells .am-spell-card .form-check-label {
    color: #111111;
}

#spells .am-spell-card .form-control,
#spells .am-spell-card .form-select,
#spells .am-spell-card textarea {
    background-color: #e0d6be !important;
    color: #111111 !important;
    border-color: #212529 !important;
}

#spells .am-spell-card .form-control:focus,
#spells .am-spell-card .form-select:focus,
#spells .am-spell-card textarea:focus {
    box-shadow: 0 0 0 0.2rem rgba(94, 30, 14, 0.2);
}

#spells .am-spell-card .btn-outline-secondary {
    color: #212529;
    border-color: #212529;
}

#spells .am-spell-card .btn-outline-secondary:hover {
    color: #f8f9fa;
    background-color: #212529;
}

#spells .am-spell-card .badge.bg-secondary {
    background-color: #2f2f2f !important;
}

#spells .am-spell-card .am-mag-total-badge {
    background-color: #e0d6be !important;
    color: #111111 !important;
    border: 1px solid #8b7a55;
}

#spells .am-spell-card .am-spell-info-icon {
    color: #5e1e0e;
    border: 1px solid #5e1e0e;
    background-color: #e0d6be;
    font-weight: 700;
}

#spells .am-spell-card.am-spell-card-incomplete {
    border: 2px solid #dc3545 !important;
    box-shadow: 0 0 0 0.1rem rgba(220, 53, 69, 0.2);
}

#characterSpells .form-label,
#spellImport .form-label,
#bestiary .form-label {
    color: #111111;
}

#characterSpells .form-control,
#characterSpells .form-select,
#spellImport .form-control,
#spellImport .form-select,
#bestiary .form-control,
#bestiary .form-select {
    background-color: #e0d6be !important;
    color: #111111 !important;
    border-color: #212529 !important;
}

#characterSpells .form-control:focus,
#characterSpells .form-select:focus,
#spellImport .form-control:focus,
#spellImport .form-select:focus,
#bestiary .form-control:focus,
#bestiary .form-select:focus {
    box-shadow: 0 0 0 0.2rem rgba(94, 30, 14, 0.2);
}

#characterSpells .table,
#spellImport .table {
    --bs-table-bg: #c1b18a;
    --bs-table-color: #111111;
    --bs-table-striped-bg: #b7a578;
    --bs-table-striped-color: #111111;
    margin-bottom: 0;
}

#characterSpells .table th,
#characterSpells .table td,
#spellImport .table th,
#spellImport .table td {
    border-color: #8b7a55;
}

#characterSpells .table thead .bg-black,
#spellImport .table thead .bg-black {
    background-color: #5e1e0e !important;
    color: #ffffff !important;
}

#characterSpells #linkSpellStatus,
#spellImport #spellImportRunMeta {
    color: #111111 !important;
}

#characterSpells #linkSpellStatus.text-info,
#spellImport #spellImportStatus.text-info {
    color: #5e1e0e !important;
}

#characterSpells .text-muted,
#spellImport .text-muted,
#bestiary .text-muted {
    color: #3c3c3c !important;
}

#bestiary #bestiaryManagerStatus.text-info,
#bestiary #bestiaryCharacterLinksStatus.text-info {
    color: #5e1e0e !important;
}

#spellImport code {
    color: #5e1e0e;
    background-color: #e0d6be;
    padding: 0.05rem 0.3rem;
    border-radius: 0.2rem;
}

#characterSpells .link-mastery-pill {
    cursor: pointer;
    font-size: 0.72rem;
    line-height: 1.2;
    padding: 0.35rem 0.5rem;
}

#characterSpells .link-mastery-pill:focus-visible {
    outline: 2px solid rgba(94, 30, 14, 0.45);
    outline-offset: 2px;
}

#characterSpells .link-mastery-chooser {
    border-color: #8b7a55 !important;
}

@keyframes amMasteryPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.45);
        border-color: #c13a47;
    }
    70% {
        box-shadow: 0 0 0 0.4rem rgba(220, 53, 69, 0);
        border-color: #dc3545;
    }
    100% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0);
        border-color: #c13a47;
    }
}

#characterSpells .link-mastery-pill-incomplete {
    border: 1px solid #c13a47 !important;
    animation: amMasteryPulse 1.6s infinite;
}

#characterSpells .link-mastery-chooser-incomplete {
    border: 1px solid #c13a47 !important;
    animation: amMasteryPulse 1.6s infinite;
}
