/* ================================
   GLOBAL
================================ */

* {
    box-sizing: border-box;
}

.wallet-form-page { max-width:760px; margin:20px auto; padding:24px; border:2px solid #70002b; border-radius:10px; background:#f8f8f8; }
.wallet-form-page h1 { margin:0 0 10px; color:#70002b; }
.wallet-form { display:grid; gap:20px; margin-top:20px; }
.wallet-form label { display:grid; gap:7px; min-width:0; font-weight:750; }
.wallet-form input { width:100%; min-height:44px; padding:10px; border:1px solid #aaa; border-radius:6px; font:inherit; }
.wallet-coin-fields { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,170px),1fr)); gap:14px; }
.wallet-form-actions { display:flex; justify-content:flex-end; align-items:center; gap:20px; padding-top:14px; border-top:1px solid #ccc; }
.wallet-form-actions button { min-height:44px; padding:10px 18px; border:1px solid #176b17; border-radius:6px; background:#228b22; color:#fff; font:inherit; font-weight:750; cursor:pointer; }
.wallet-form-error { padding:12px; border-left:4px solid #70002b; background:#f6e8ed; color:#70002b; }

/* ================================
   OPERATIONAL DATA TABLES
   Weather, transactions, storage, and campaign locations share this treatment. Reference tables
   intentionally keep their separate maroon presentation.
================================ */

div.dt-container table.dataTable.operational-table thead th {
    padding: 5.5px 10px !important;
    border: 1px solid #cccccc;
    background: #d3d3d3;
    color: #222222;
    font-weight: 700;
    text-align: left;
}

div.dt-container table.dataTable.operational-table tbody td {
    padding: 5px 10px !important;
    border: 1px solid #cccccc;
    font-weight: 400;
    text-align: left;
}

div.dt-container table.dataTable.operational-table tbody td:first-child {
    font-weight: 700;
}

:is(#terrainTable_wrapper, #transactionTable_wrapper, #storageTable_wrapper, #locationsTable_wrapper, #campaignRecordsTable_wrapper, #characterRosterTable_wrapper, #campaignRosterTable_wrapper, #characterInventoryTable_wrapper, #storageTable_wrapper, #spellLibraryTable_wrapper, #domainRosterTable_wrapper)
    > .dt-layout-row:not(.dt-layout-table):last-child {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
}

:is(#terrainTable_wrapper, #transactionTable_wrapper, #storageTable_wrapper, #locationsTable_wrapper, #campaignRecordsTable_wrapper, #characterRosterTable_wrapper, #campaignRosterTable_wrapper, #characterInventoryTable_wrapper, #storageTable_wrapper, #spellLibraryTable_wrapper, #domainRosterTable_wrapper)
    > .dt-layout-row:not(.dt-layout-table):last-child
    > .dt-layout-start {
    display: flex !important;
    justify-content: flex-start;
    margin: 0 auto 0 0;
    text-align: left;
}

:is(#terrainTable_wrapper, #transactionTable_wrapper, #storageTable_wrapper, #locationsTable_wrapper, #campaignRecordsTable_wrapper, #characterRosterTable_wrapper, #campaignRosterTable_wrapper, #characterInventoryTable_wrapper, #storageTable_wrapper, #spellLibraryTable_wrapper, #domainRosterTable_wrapper)
    > .dt-layout-row:not(.dt-layout-table):last-child
    > .dt-layout-end {
    display: flex !important;
    justify-content: flex-end;
    margin: 0 0 0 auto;
    text-align: right;
}

:root {
    --accent-red: #E22028;
    --accent-green: #228B22;
    --accent-burgundy: #70002b;
    --header-background: #3f3f3f;
    --header-text: #E0E0E0;
}

html {
    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background-color: #ead3ac;
    background-image: url("../backgrounds/parchmentbackground.jpg");
    background-position: center top;
    background-repeat: no-repeat;
    background-size: cover;
    background-attachment: fixed;
    color: #222;
}


/* ================================
   HEADER / NAVIGATION
================================ */

.site-header {
    background: var(--header-background);
    color: var(--header-text);
    position: relative;
    z-index: 100;
}

.header-inner {
    max-width: none;
    margin: 0 auto;

    padding: 12px 12px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.site-title {
    color: var(--header-text);
    margin-left: auto;
    min-width: 0;
    overflow: hidden;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;

    font-size: 1.25rem;
    font-weight: 700;

    text-decoration: none;
}

.profile-button {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 5px;
    border: 1px solid #aaa;
    border-radius: 8px;
    background: #f4f4f4;
    cursor: pointer;
}

.profile-button:hover, .profile-button:focus-visible { background: #fff; outline: 2px solid #e0e0e0; outline-offset: 2px; }
.profile-button img { max-width: 100%; height: auto; }

.auth-card { width: min(100% - 32px, 460px); margin: clamp(30px, 10vh, 110px) auto; padding: 30px; border: 1px solid #ccc; border-radius: 14px; background: #fff; box-shadow: 0 8px 28px rgba(0,0,0,.12); }
.auth-logo { display: block; width: 86px; height: 86px; margin: 0 auto 14px; border-radius: 14px; }
.auth-eyebrow, .character-eyebrow { margin: 0 0 5px; color: #666; font-size: .8rem; font-weight: 800; letter-spacing: .08em; }
.auth-card h1 { margin: 0 0 8px; }
.auth-form { display: grid; gap: 15px; margin-top: 22px; }
.auth-form label, .auth-two-column label { display: grid; gap: 5px; font-weight: 700; }
.auth-form input { width: 100%; padding: 9px; border: 1px solid #aaa; border-radius: 5px; font: inherit; }
.auth-password-field { position: relative; display: block; }
.auth-password-field input { padding-right: 48px; }
.password-visibility-toggle { position: absolute; top: 50%; right: 7px; display: grid; place-items: center; width: 34px; height: 34px; padding: 4px; border: 0; border-radius: 5px; background: transparent; cursor: pointer; transform: translateY(-50%); }
.password-visibility-toggle:hover, .password-visibility-toggle:focus-visible { background: #e8e8e8; outline: 2px solid #555; outline-offset: 1px; }
.password-visibility-toggle img { width: 24px; height: 24px; }
.auth-form small { color: #666; font-weight: 400; }
.auth-submit-button { min-height: 52px; border: 1px solid #176b17; border-radius: 5px; background: #228b22; color: #fff; font: inherit; font-weight: 800; cursor: pointer; }
.auth-submit-button:hover, .auth-submit-button:focus-visible { background: #176b17; outline: 2px solid #174d17; outline-offset: 2px; }
.auth-two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.auth-error { padding: 10px; border-left: 4px solid #b42318; background: #fef3f2; color: #8a1914; }
.auth-switch { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px; margin: 24px 0 0; text-align: center; }
.auth-create-button { display: inline-flex; align-items: center; min-height: 38px; padding: 7px 13px; border: 1px solid #777; border-radius: 5px; background: #f4f4f4; color: #222; font-weight: 750; text-decoration: none; }
.auth-create-button:hover, .auth-create-button:focus-visible { border-color: #176b17; background: #e4f1e4; color: #174d17; outline: 2px solid #176b17; outline-offset: 2px; }
.administration-page { max-width: 1100px; margin: 0 auto; }
.admin-heading, .admin-panel, .admin-empty { padding: 22px; border: 1px solid #ccc; border-radius: 10px; background: #fff; margin-bottom: 18px; }
.admin-heading h1, .admin-panel h2, .admin-empty h2 { margin: 0 0 7px; }
.campaign-list { display: grid; gap: 18px; }
.campaign-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding-bottom: 16px; border-bottom: 1px solid #ddd; }
.campaign-card-heading p { margin: 0; }
.admin-edit-button { min-height: 40px; padding: 8px 16px; border: 2px solid #70002b; border-radius: 7px; background: #fff; color: #70002b; font: inherit; font-weight: 800; cursor: pointer; }
.admin-edit-button:hover, .admin-edit-button:focus-visible { background: #f7e9ee; outline: 2px solid #70002b; outline-offset: 2px; }
.campaign-details-form { display: grid; max-width: 720px; gap: 12px; margin: 18px 0; }
.campaign-name-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.campaign-party-separator { color: #777; font-weight: 400; }
.campaign-details-form[hidden] { display: none; }
.campaign-card:not(.is-editing) .campaign-edit-only { display: none; }
.campaign-details-form label { display: grid; gap: 5px; font-weight: 700; }
.campaign-details-form input, .campaign-details-form textarea { width: 100%; padding: 9px; border: 1px solid #aaa; border-radius: 7px; font: inherit; }
.campaign-details-form textarea { resize: vertical; }
.campaign-details-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 12px; }
.admin-member-form { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(180px, .65fr) auto; gap: 12px; align-items: end; margin: 20px 0 8px; }
.admin-member-form label { display: grid; gap: 5px; font-weight: 700; }
.admin-member-form select { padding: 9px; border: 1px solid #aaa; border-radius: 7px; font: inherit; }
.admin-primary-button { min-height: 40px; padding: 8px 15px; border: 1px solid #176b17; border-radius: 7px; background: #228b22; color: #fff; font: inherit; font-weight: 800; cursor: pointer; }
.admin-primary-button:hover:not(:disabled), .admin-primary-button:focus-visible:not(:disabled) { background: #176b17; outline: 2px solid #174d17; outline-offset: 2px; }
.admin-primary-button:disabled { opacity: .5; cursor: not-allowed; }
.role-badge { display: inline-block; padding: 3px 8px; border-radius: 999px; background: #e5e5e5; font-size: .85rem; font-weight: 700; }
.role-badge-dm { background: #70002b; color: #fff; }
.admin-create-row { display: flex; margin-top: 24px; }
.admin-create-row .admin-primary-button { width: 100%; }
dialog.character-dialog { width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; overflow: auto; border: 4px solid #70002b; border-radius: 14px; background: #f7f7f7; box-shadow: 0 14px 50px rgb(0 0 0 / 38%); }
dialog.character-dialog::backdrop { background: rgb(0 0 0 / 60%); }
dialog.character-dialog .character-dialog-header { position: relative; display: flex; align-items: center; justify-content: space-between; margin: 0; padding: 18px 24px; }
dialog.character-dialog .character-dialog-header::after { position: absolute; right: 40px; bottom: 0; left: 40px; height: 1px; background: #c7c7c7; content: ''; }
dialog.character-dialog .character-dialog-header h2 { margin: 0; color: #70002b; }
dialog.character-dialog .character-dialog-header .character-dialog-close { display:grid; place-items:center; flex:0 0 34px; width:34px; height:34px; min-height:34px; padding:0; margin-left:auto; border:0; border-radius:50%; background:#e0e0e0; color:#333; font-size:1.35rem; line-height:1; cursor:pointer; }
dialog.character-dialog .character-dialog-header .character-dialog-close:hover, dialog.character-dialog .character-dialog-header .character-dialog-close:focus-visible { background:#f2e2e8; color:#70002b; }
dialog.character-dialog .character-form { padding: 22px 24px 24px; }
dialog.character-proficiency-dialog .character-form { display: grid; gap: 14px; }
/* The result list is a popover: it must be allowed to extend outside this compact dialog. */
dialog.character-proficiency-dialog,
dialog.character-spell-dialog {
    position: fixed;
    top: clamp(24px, 12vh, 120px);
    right: auto;
    bottom: auto;
    left: 50%;
    margin: 0;
    overflow: visible;
    transform: translateX(-50%);
}
dialog.character-proficiency-dialog .character-form label { display: grid; gap: 5px; font-weight: 700; }
dialog.character-proficiency-dialog .character-form label[hidden] { display: none; }
dialog.character-proficiency-dialog .character-form input,
dialog.character-proficiency-dialog .character-form select { width: 100%; padding: 9px; border: 1px solid #aaa; border-radius: 7px; background: #fff; font: inherit; }
dialog.character-proficiency-dialog .character-form input:focus,
dialog.character-proficiency-dialog .character-form select:focus { border-color: #70002b; outline: 2px solid rgb(112 0 43 / 18%); outline-offset: 1px; }
.searchable-combobox { position: relative; }
.searchable-combobox-trigger { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 42px; padding: 9px; border: 1px solid #aaa; border-radius: 7px; background: #fff; color: #666; font: inherit; text-align: left; cursor: pointer; }
.searchable-combobox-trigger::after { margin-left: 12px; color: #70002b; content: "⌄"; font-size: 1.2rem; }
.searchable-combobox-trigger.has-value { color: #222; }
.searchable-combobox-trigger:focus-visible { border-color: #70002b; outline: 2px solid rgb(112 0 43 / 18%); outline-offset: 1px; }
.searchable-combobox-panel { position: absolute; z-index: 100; top: 0; right: 0; left: 0; overflow: hidden; border: 1px solid #70002b; border-radius: 8px; background: #fff; box-shadow: 0 10px 22px rgb(0 0 0 / 22%); }
.searchable-combobox-panel input { box-sizing: border-box; width: calc(100% - 16px); margin: 8px; padding: 9px; border: 1px solid #aaa; border-radius: 6px; font: inherit; }
.searchable-combobox.opens-upward .searchable-combobox-panel { top: auto; bottom: 0; }
.searchable-combobox-results { max-height: var(--combobox-results-height, 320px); overflow-y: auto; padding: 0 0 8px; }
.searchable-combobox-group { position: sticky; top: 0; padding: 7px 12px; background: #f2e7eb; color: #70002b; font-size: .84rem; font-weight: 800; text-transform: uppercase; }
.searchable-combobox-option { display: block; width: 100%; padding: 8px 12px; border: 0; background: #fff; color: #222; font: inherit; text-align: left; cursor: pointer; }
.searchable-combobox-option:hover, .searchable-combobox-option:focus-visible { background: #f5eef1; outline: none; }
.searchable-combobox-option:disabled { color: #777; cursor: not-allowed; }
.searchable-combobox-empty { margin: 0; padding: 14px; color: #666; }
.admin-create-dialog .character-form { display: grid; gap: 15px; }
.admin-create-dialog .character-form label { display: grid; gap: 5px; font-weight: 700; }
.admin-create-dialog .character-form input, .admin-create-dialog .character-form textarea { width: 100%; padding: 9px; border: 1px solid #aaa; border-radius: 7px; font: inherit; }
.admin-create-dialog .character-form textarea { resize: vertical; }
.admin-create-dialog .character-dialog-actions { justify-content: flex-end; }
.profile-username { margin-top: 0; color: #555; }
.profile-tabs { display: flex; gap: 6px; padding: 16px 24px 0; border-bottom: 1px solid #ddd; }
.profile-tab { padding: 8px 12px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: #555; font: inherit; font-weight: 800; cursor: pointer; }
.profile-tab.is-active { border-bottom-color: #70002b; color: #70002b; }
.profile-dialog [data-profile-panel="details"] { padding: 0 24px 24px; }
.profile-create-character { padding: 24px; }
.profile-create-character h3 { margin-top: 0; color: #70002b; }
.profile-note { color: #666; }
.profile-campaign-switch { margin-top: 18px; padding-top: 18px; border-top: 1px solid #ddd; }
.profile-campaign-switch h3 { margin: 0 0 7px; color: #70002b; font-size: .82rem; letter-spacing: .04em; text-transform: uppercase; }
.profile-campaign-switch select { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #aaa; border-radius: 7px; background: #fff; color: #222; font: inherit; }
.profile-campaign-switch select:focus { border-color: #70002b; outline: 2px solid rgb(112 0 43 / 18%); outline-offset: 1px; }
.profile-logout { margin-top: 22px; }
.profile-campaign-switch .profile-active-character-heading { margin-top: 18px; }
@media (max-width: 640px) { .auth-two-column, .admin-member-form, .campaign-name-row { grid-template-columns: 1fr; } .campaign-card-heading { flex-direction: column; } .admin-edit-button { width: 100%; } }

.header-menu {
    position: relative;
    flex: 0 0 auto;
}

.header-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid #aaa;
    border-radius: 8px;
    cursor: pointer;
    list-style: none;
}

.header-menu-toggle::-webkit-details-marker {
    display: none;
}

.header-menu-toggle .menu-icon-active {
    display: none;
}

.header-menu[open] .header-menu-toggle,
.header-menu-toggle:hover,
.header-menu-toggle:focus-visible {
    background: #f4f4f4;
}

.header-menu[open] .menu-icon-inactive,
.header-menu-toggle:hover .menu-icon-inactive,
.header-menu-toggle:focus-visible .menu-icon-inactive {
    display: none;
}

.header-menu[open] .menu-icon-active,
.header-menu-toggle:hover .menu-icon-active,
.header-menu-toggle:focus-visible .menu-icon-active {
    display: block;
}

.main-nav {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 260px;
    max-width: calc(100vw - 32px);
    padding: 6px 8px;
    border: 1px solid #aaa;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

.main-nav a {
    display: block;
    color: #222;
    font-weight: 700;
    text-align: left;
    white-space: nowrap;

    text-decoration: none;
    border: 0;
}

.nav-parent-button {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: #222;
    font: inherit;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

.nav-parent-button:hover .nav-entry,
.nav-parent-button:focus-visible .nav-entry,
.nav-parent-button.active .nav-entry,
.nav-parent-button[aria-expanded="true"] .nav-entry {
    background: #eee;
    outline: 1px solid #aaa;
    outline-offset: -1px;
}

.nav-parent-indicator {
    margin-left: auto;
    font-size: 1.1rem;
    line-height: 1;
}

.nav-submenu-panel {
    position: fixed;
    z-index: 110;
    width: 280px;
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px 8px;
    border: 1px solid #aaa;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

.main-nav > :not(:first-child) {
    border-top: 1px solid #ccc;
}

.nav-submenu-panel a {
    display: block;
    color: #222;
    font-weight: 700;
    text-decoration: none;
}

.nav-submenu-panel a + a {
    border-top: 1px solid #ccc;
}

.nav-section-label {
    margin: 4px 8px 2px;
    color: #666;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.nav-submenu-panel .nav-section-label:not(:first-child) {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #aaa;
}

.nav-submenu-panel a:hover .nav-entry,
.nav-submenu-panel a:focus-visible .nav-entry,
.nav-submenu-panel a.active .nav-entry {
    background: #e0e0e0;
    color: #222;
}

.nav-entry {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    margin: 4px 0;
    padding: 7px 8px;
    border-radius: 8px;
}

.nav-icon {
    display: block;
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.main-nav a:hover .nav-entry,
.main-nav a:focus-visible .nav-entry {
    background: #eee;
    outline: 1px solid #aaa;
    outline-offset: -1px;
}

.main-nav a.active .nav-entry {
    background: #e0e0e0;
    color: #222;
}


/* ================================
   PAGE
================================ */

.page-container {
    width: 100%;
    max-width: 1100px;

    margin: 0 auto;

    padding: 16px;
}

.page-card {
    min-width: 0;
    padding: clamp(12px, 2vw, 24px);
    border: 2px solid var(--accent-burgundy);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 6px 18px rgb(0 0 0 / 8%);
}

.page-card div.dt-container table.dataTable.operational-table {
    border-color: var(--accent-burgundy);
    background: #fff;
}

.page-card div.dt-container table.dataTable.operational-table :is(th, td),
.page-card div.dt-container .dt-input {
    border-color: var(--accent-burgundy);
}

.page-card > .character-heading {
    margin-bottom: 18px;
    padding: 0 0 18px;
    border: 0;
    border-bottom: 1px solid var(--accent-burgundy);
    border-radius: 0;
}


/* =================================
   HOME / MAP PAGE
================================= */

.campaign-map img {
    display: block;
    width: 100%;
    height: auto;
}

/* Rulebook viewer: a defined height is required by EmbedPDF. */
.manual-page-container {
    max-width: none;
    height: calc(100dvh - var(--site-header-height, 68px));
    padding: 2px;
}

.rulebook-page {
    height: 100%;
}

.rulebook-viewer {
    height: 100%;
    width: 100%;
    min-width: 0;
    border: 0;
    border-radius: 0;
    overflow: hidden;
    background: #fff;
}

/* =================================
   WALLET PAGE
================================= */

.wallet-page {
    width: 100%;
}


/* Page title */

.page-title {
    margin-top: 0;
    margin-bottom: 24px;

    text-align: left;
}


/* =================================
   BALANCE / ACTION AREA
================================= */

.wallet-summary {
    width: 100%;
    max-width: 600px;

    margin: 0 auto 40px auto;
}


/* Current balance */

.wallet-balance {
    text-align: center;

    margin-bottom: 20px;
}

.balance-label {
    display: block;

    font-size: 1rem;
    font-weight: 600;

    margin-bottom: 4px;
}

.balance-value {
    display: block;

    font-size: 1.8rem;
    font-weight: 700;

    overflow-wrap: anywhere;
}


/* =================================
   DEPOSIT / SPEND BUTTONS
================================= */

.wallet-actions {
    display: flex;

    justify-content: center;

    gap: 12px;

    width: 100%;
}

.wallet-button {
    flex: 1;

    max-width: 200px;

    padding: 14px 20px;

    text-align: center;

    font-size: 1.1rem;
    font-weight: 700;

    text-decoration: none;

    color: #000;

    border: 1px solid #222;
    border-radius: 6px;
}

.wallet-button:hover {
    box-shadow: 0 0 0 2px #222;
}

.deposit-button {
    background: var(--accent-green);
}

.spend-button {
    background: var(--accent-red);
}

.transaction-dialog,
.storage-dialog {
    width: calc(100% - 32px);
    max-width: 480px;
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
}

.transaction-dialog,
.storage-dialog {
    position: fixed;
    padding: 0;
    border: 4px solid #70002b;
    border-radius: 14px;
    background: #f7f7f7;
}

.transaction-dialog::backdrop,
.storage-dialog::backdrop {
    background: rgba(0, 0, 0, 0.55);
}

.transaction-dialog .app-dialog-header,
.storage-dialog .app-dialog-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 24px;
}

.transaction-dialog .app-dialog-header::after,
.storage-dialog .app-dialog-header::after {
    position: absolute;
    right: 40px;
    bottom: 0;
    left: 40px;
    height: 1px;
    background: #c7c7c7;
    content: '';
}

.transaction-dialog h1,
.storage-dialog h1 { margin: 0; color: #70002b; }

.dialog-close {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid #aaa;
    border-radius: 6px;
    background: #fff;
    color: #222;
    font-size: 1.35rem;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
}

.dialog-close:hover,
.dialog-close:focus-visible {
    background: var(--accent-red);
    color: #fff;
    font-weight: 700;
}

.transaction-dialog input,
.transaction-dialog select,
.transaction-dialog textarea,
.storage-dialog input,
.storage-dialog select,
.storage-dialog textarea {
    max-width: 100%;
    font-size: 16px;
}

.transaction-dialog-error {
    color: var(--accent-red);
    font-weight: 600;
}

.transaction-dialog-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 22px 24px 24px;
}

.transaction-note-field {
    display: grid;
    gap: 6px;
}

.transaction-note-field textarea {
    width: 100%;
    min-height: 3.5rem;
    resize: vertical;
    overflow-y: auto;
}

.denomination-grid {
    display: grid;
    gap: 8px;
}

.denomination-grid label,
.gp-equivalent-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 9rem;
    align-items: center;
    gap: 12px;
}

.denomination-grid input {
    width: 9rem;
    text-align: right;
}

.gp-equivalent-row {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid #ccc;
    font-weight: 700;
}

.gp-equivalent-row output {
    width: 9rem;
    padding: 4px 2px;
    text-align: right;
}

.transaction-submit {
    width: 100%;
    padding: 14px 20px;
    border: 1px solid #222;
    border-radius: 6px;
    color: #000;
    font: inherit;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
}

.transaction-submit:hover,
.transaction-submit:focus-visible {
    box-shadow: 0 0 0 2px #222;
}

.deposit-submit {
    background: var(--accent-green);
}

.spend-submit {
    background: var(--accent-red);
}

.storage-dialog-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 22px 24px 24px;
}

.storage-form-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 12rem;
    align-items: center;
    gap: 12px;
}

.storage-form-field input,
.storage-form-field select {
    width: 12rem;
}

.storage-form-field input[type="number"] {
    text-align: right;
}

.storage-textarea-field {
    display: grid;
    gap: 6px;
}

.storage-textarea-field textarea {
    width: 100%;
    min-height: 3.5rem;
    resize: vertical;
    overflow-y: auto;
}


/* =================================
   TRANSACTION HISTORY
================================= */

.transaction-section {
    margin-top: 40px;
}

.transaction-section h2 {
    margin-bottom: 12px;
}

.table-container {
    width: 100%;
    overflow-x: auto;
}

.dt-container {
    font-size: 0.8rem;
}

/* Keep DataTables controls compact and side-by-side until the viewport is
   genuinely phone-sized. DataTables otherwise stacks them below 767px. */
body div.dt-container div.dt-layout-row:not(.dt-layout-table) {
    display: flex;
    gap: 8px;
    margin: 0.35em 0;
}

body div.dt-container div.dt-layout-row:not(.dt-layout-table) div.dt-layout-cell {
    display: flex;
    align-items: center;
    padding: 0;
}

body div.dt-container div.dt-layout-row:not(.dt-layout-table) div.dt-layout-cell > * {
    margin: 0.15em 0;
}

div.dt-container .dt-search input,
div.dt-container .dt-length select {
    padding: 2px 4px;
}

div.dt-container .dt-paging .dt-paging-button {
    padding: 0.25em 0.55em;
}

div.dt-container table.dataTable th,
div.dt-container table.dataTable td {
    padding: 3.2px 1px !important;
}

.transaction-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.transaction-table th,
.transaction-table td {
    padding: 3.2px 1px;
    border: 1px solid #ccc;
    text-align: left;
    white-space: nowrap;
}

.transaction-table th {
    font-weight: 700;
}


/* =================================
   DEEP STORAGE
================================= */

.storage-page {
    width: 100%;
}

.storage-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.storage-heading .page-title {
    margin: 0;
}

.storage-page-actions {
    display: flex;
    gap: 12px;
}

.storage-button,
.storage-action-button {
    border: 1px solid #222;
    border-radius: 6px;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.storage-button {
    padding: 12px 18px;
    color: #000;
}

.storage-button:hover,
.storage-action-button:not(:disabled):hover {
    box-shadow: 0 0 0 2px #222;
}

.store-button,
.add-one-button {
    background: var(--accent-green);
}

.take-mode-toggle {
    background: #d3d3d3;
}

.take-mode-toggle.take-mode-active,
.take-one-button:not(:disabled) {
    background: var(--accent-red);
}

.storage-section {
    margin-top: 24px;
}

.storage-section h2 {
    margin-bottom: 12px;
}

.storage-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.storage-table th,
.storage-table td {
    padding: 3.2px 1px;
    border: 1px solid #ccc;
    text-align: left;
    white-space: nowrap;
}

.storage-table th {
    font-weight: 700;
}

.storage-actions {
    display: flex;
    gap: 6px;
}

.storage-actions form {
    margin: 0;
}


/* =================================
   SPELLS
================================= */

.spell-list-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.spell-list-heading .page-title {
    margin: 0;
}

.spell-browser-controls {
    margin-bottom: 20px;
    padding: 14px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #fff;
}

.spell-search-field,
.spell-filter-row label {
    display: grid;
    gap: 4px;
}

.spell-search-field input {
    width: 100%;
    padding: 8px;
    font: inherit;
}

.spell-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 10px;
    margin-top: 10px;
}

.spell-filter-row select,
.spell-filter-clear {
    min-height: 34px;
    font: inherit;
}

.custom-spell-filter {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 34px;
}

.spell-filter-clear {
    padding: 4px 10px;
    border: 1px solid #666;
    border-radius: 4px;
    background: #eee;
    cursor: pointer;
}

.spell-type-filter-panel {
    margin-top: 12px;
}

.spell-type-filter-panel summary {
    cursor: pointer;
    font-weight: 700;
}

.spell-type-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin: 10px 0;
}

.spell-type-filters label,
.spell-filter-mode {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.spell-result-count {
    margin: 12px 0 0;
    font-weight: 700;
}

.spell-card-list {
    display: grid;
    gap: 16px;
}

.spell-card {
    padding: 16px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #fff;
}

.spell-card h2 {
    margin: 0 0 12px;
    color: #8a302b;
    font-size: 1.38rem;
}

.spell-properties {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 16px;
    margin-bottom: 14px;
}

.spell-properties p {
    margin: 0;
}

.spell-description {
    font-size: 0.8rem;
    line-height: 1.5;
    white-space: pre-line;
}

.custom-spell-label {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 6px;
    border-radius: 4px;
    background: #e0e0e0;
    color: #222;
    font-size: 0.7rem;
    text-transform: uppercase;
    vertical-align: middle;
}

.no-spell-results {
    margin-top: 18px;
    font-weight: 700;
}

/* =================================
   MAGIC ITEMS
================================= */

.magic-item-browser-controls {
    margin-bottom: 20px;
    padding: 14px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #fff;
}

.magic-item-search-field,
.magic-item-filter-row label {
    display: grid;
    gap: 4px;
}

.magic-item-search-field input {
    width: 100%;
    padding: 8px;
    font: inherit;
}

.magic-item-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 10px;
    margin-top: 10px;
}

.magic-item-filter-row select,
.magic-item-filter-clear {
    min-height: 34px;
    font: inherit;
}

.magic-item-filter-clear {
    padding: 4px 10px;
    border: 1px solid #666;
    border-radius: 4px;
    background: #eee;
    cursor: pointer;
}

/* Shared search and filter controls for spell and magic-item browsers. */
.spell-browser-controls,
.magic-item-browser-controls {
    padding: 18px;
    border: 2px solid #70002b;
    border-radius: 10px;
    background: #f8f8f8;
}

.spell-search-field > span,
.spell-filter-row label > span,
.magic-item-search-field > span,
.magic-item-filter-row label > span {
    color: #70002b;
    font-size: .82rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.spell-browser-controls input[type="search"],
.spell-browser-controls select,
.magic-item-browser-controls input[type="search"],
.magic-item-browser-controls select {
    box-sizing: border-box;
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid #aaa;
    border-radius: 7px;
    background: #fff;
    color: #222;
    font: inherit;
}

.spell-browser-controls select,
.magic-item-browser-controls select {
    min-width: 180px;
}

.spell-browser-controls input[type="search"]:focus,
.spell-browser-controls select:focus,
.magic-item-browser-controls input[type="search"]:focus,
.magic-item-browser-controls select:focus {
    border-color: #70002b;
    outline: 2px solid rgb(112 0 43 / 18%);
    outline-offset: 1px;
}

.spell-filter-clear,
.magic-item-filter-clear {
    min-height: 42px;
    padding: 9px 12px;
    border-color: #70002b;
    border-radius: 7px;
    background: #fff;
    color: #70002b;
    font-weight: 800;
}

.spell-filter-clear:hover,
.magic-item-filter-clear:hover,
.spell-filter-clear:focus-visible,
.magic-item-filter-clear:focus-visible {
    background: #f5eef1;
    outline: none;
}

.magic-item-result-count {
    margin: 12px 0 0;
    font-weight: 700;
}

.magic-item-card-list {
    display: grid;
    gap: 16px;
}

.magic-item-card {
    min-width: 0;
    padding: 16px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #fff;
}

.magic-item-card h2 {
    margin: 0 0 12px;
    color: #8a302b;
    font-size: 1.38rem;
}

.magic-item-properties {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 16px;
    margin-bottom: 14px;
}

.magic-item-properties p {
    margin: 0;
}

.magic-item-description,
.magic-item-effects div {
    font-size: 0.8rem;
    line-height: 1.5;
    white-space: pre-line;
}

.magic-item-effects {
    margin-top: 12px;
}

.magic-item-effects summary {
    cursor: pointer;
    font-weight: 700;
}

.magic-item-effects div {
    margin-top: 8px;
}

.no-magic-item-results {
    margin-top: 18px;
    font-weight: 700;
}

/* =================================
   CONDITIONS GLOSSARY
================================= */

.conditions-browser-controls {
    margin-bottom: 20px;
    padding: 18px;
    border: 2px solid #70002b;
    border-radius: 10px;
    background: #f8f8f8;
}

.conditions-search-field,
.conditions-filter-row label { display: grid; gap: 4px; }

.conditions-search-field > span,
.conditions-filter-row label > span {
    color: #70002b;
    font-size: .82rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.conditions-browser-controls input[type="search"],
.conditions-browser-controls select {
    box-sizing: border-box;
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid #aaa;
    border-radius: 7px;
    background: #fff;
    color: #222;
    font: inherit;
}

.conditions-browser-controls select { min-width: 180px; }

.conditions-browser-controls input[type="search"]:focus,
.conditions-browser-controls select:focus {
    border-color: #70002b;
    outline: 2px solid rgb(112 0 43 / 18%);
    outline-offset: 1px;
}

.conditions-filter-row { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-top: 10px; }

.conditions-filter-clear {
    min-height: 42px;
    padding: 9px 12px;
    border: 1px solid #70002b;
    border-radius: 7px;
    background: #fff;
    color: #70002b;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.conditions-filter-clear:hover,
.conditions-filter-clear:focus-visible { background: #f5eef1; outline: none; }

.conditions-result-count { margin: 12px 0 0; font-weight: 700; }
.conditions-card-list { display: grid; gap: 16px; }

.condition-card {
    min-width: 0;
    padding: 16px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #fff;
}

.condition-card h2 { margin: 0 0 12px; color: #8a302b; font-size: 1.38rem; }
.condition-properties { margin-bottom: 14px; }
.condition-properties p { margin: 0; }

.condition-description {
    font-size: .8rem;
    line-height: 1.5;
    white-space: pre-line;
}

.condition-related-link {
    padding: 0;
    border: 0;
    background: transparent;
    color: #70002b;
    font: inherit;
    font-weight: 800;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    cursor: pointer;
}

.condition-related-link:focus-visible { outline: 2px solid #70002b; outline-offset: 2px; }
.no-condition-results { margin-top: 18px; font-weight: 700; }

.condition-details-dialog {
    width: min(680px, calc(100vw - 28px));
    max-height: calc(100vh - 28px);
    padding: 24px;
    overflow: auto;
    border: 2px solid #70002b;
    border-radius: 10px;
    background: #f7f7f7;
    box-shadow: 0 14px 50px rgb(0 0 0 / 38%);
}

.condition-details-dialog::backdrop { background: rgb(0 0 0 / 60%); }
.condition-dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-bottom: 14px; border-bottom: 1px solid #ccc; }
.condition-dialog-header h2 { margin: 0; color: #70002b; }
.condition-dialog-close { min-width: 34px; min-height: 34px; border: 1px solid #aaa; border-radius: 7px; background: #fff; color: #333; font-size: 1.25rem; line-height: 1; cursor: pointer; }
.condition-details-source { margin: 14px 0; color: #555; font-size: .9rem; font-weight: 700; }

@media (max-width: 600px) {
    .conditions-browser-controls { padding: 14px; }
    .conditions-filter-row > * { width: 100%; }
    .conditions-browser-controls select { min-width: 0; }
}

/* =================================
   CLASSES REFERENCE
================================= */

.classes-reference-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: -2px 0 10px; }
.classes-reference-tab { min-height: 52px; padding: 9px 12px; border: 1px solid #aaa; border-radius: 7px 7px 0 0; background: #e0e0e0; color: #333; font: inherit; font-weight: 800; cursor: pointer; box-shadow: 0 3px 6px rgb(0 0 0 / 15%); }
.classes-reference-tab:hover, .classes-reference-tab:focus-visible { border-color: #70002b; background: #f2e2e8; }
.classes-reference-tab.is-active { border-color: #70002b; background: #70002b; color: #fff; box-shadow: inset 0 -4px #4e001e; }
.classes-reference-carousel { overflow: hidden; border: 1px solid #ccc; border-radius: 10px; background: #fff; box-shadow: 0 10px 24px rgb(0 0 0 / 9%); }
.classes-reference-cards { display: flex; align-items: flex-start; height: auto; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scrollbar-width: none; transition: height .18s ease; }
.classes-reference-cards::-webkit-scrollbar { display: none; }
.classes-reference-card { align-self: flex-start; box-sizing: border-box; flex: 0 0 100%; min-width: 0; padding: 20px; scroll-snap-align: start; }
.classes-reference-card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid #ccc; color: #70002b; font-size: 1.16rem; font-weight: 800; }
.classes-reference-card-title small { color: #555; font-size: .88rem; }
.classes-reference-selector { display: grid; gap: 5px; width: min(360px, 100%); margin-bottom: 16px; color: #70002b; font-size: .82rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.classes-reference-selector select { min-height: 42px; padding: 9px 11px; border: 1px solid #aaa; border-radius: 7px; background: #fff; color: #222; font: inherit; text-transform: none; }
.classes-reference-selector select:focus { border-color: #70002b; outline: 2px solid rgb(112 0 43 / 18%); outline-offset: 1px; }
.classes-reference-carousel-actions { display: flex; justify-content: space-between; padding: 10px 14px; border-top: 1px solid #ccc; background: #f8f8f8; }
.classes-reference-arrow { min-width: 44px; min-height: 40px; border: 1px solid #70002b; border-radius: 7px; background: #fff; color: #70002b; font: inherit; font-size: 1.5rem; font-weight: 800; cursor: pointer; }
.classes-reference-arrow:hover, .classes-reference-arrow:focus-visible { background: #f5eef1; outline: none; }

@media (max-width: 760px) {
    .classes-reference-tabs { grid-template-columns: 1fr; }
    .classes-reference-tab { min-height: 44px; border-radius: 7px; }
    .classes-reference-card { padding: 14px; }
}

/* =================================
   CACODEMON SUMMONING
================================= */

.cacodemon-roller, .cacodemon-result, .cacodemon-pool { margin-bottom: 20px; padding: 20px; border: 2px solid #70002b; border-radius: 10px; background: #f8f8f8; }
.cacodemon-roller h1, .cacodemon-result h2, .cacodemon-pool h2 { margin: 0; color: #70002b; }
.cacodemon-roller > p { margin: 9px 0 0; color: #444; }
.cacodemon-form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin-top: 18px; }
.cacodemon-form label { display: grid; flex: 1 1 220px; gap: 5px; color: #70002b; font-size: .82rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.cacodemon-form select { min-height: 42px; padding: 9px 11px; border: 1px solid #aaa; border-radius: 7px; background: #fff; color: #222; font: inherit; text-transform: none; }
.cacodemon-button { min-height: 42px; padding: 9px 14px; border: 1px solid #176b17; border-radius: 7px; background: #228b22; color: #fff; font: inherit; font-weight: 800; cursor: pointer; }
.cacodemon-button:hover:not(:disabled), .cacodemon-button:focus-visible:not(:disabled) { background: #176b17; }
.cacodemon-button:disabled { opacity: .55; cursor: wait; }
.cacodemon-secondary { border-color: #777; background: #fff; color: #333; }
.cacodemon-secondary:hover:not(:disabled), .cacodemon-secondary:focus-visible:not(:disabled) { background: #eee; }
.cacodemon-status { min-height: 22px; margin: 12px 0 0; color: #176b17; font-weight: 750; }
.cacodemon-status.is-error { color: #b3262e; }
.cacodemon-result-heading, .cacodemon-pool-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.cacodemon-result-heading > span, .cacodemon-pool-heading > span { color: #555; font-weight: 750; }
.cacodemon-fate { display: flex; align-items: center; gap: 12px; color: #555; font-weight: 750; }
.cacodemon-fate .cacodemon-actions { margin: 0; }
.cacodemon-name-dialog { width: min(430px, calc(100vw - 30px)); margin: auto; padding: 0; border: 2px solid #70002b; border-radius: 10px; background: #f8f8f8; box-shadow: 0 18px 60px rgba(0, 0, 0, .38); }
.cacodemon-name-dialog::backdrop { background: rgba(0, 0, 0, .55); }
.cacodemon-name-dialog form { padding: 20px; }
.cacodemon-name-dialog h2 { margin: 0; color: #70002b; }
.cacodemon-name-dialog p { margin: 8px 0 18px; color: #444; }
.cacodemon-name-dialog label { display: grid; gap: 5px; color: #70002b; font-size: .8rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.cacodemon-name-dialog input { min-height: 42px; padding: 9px 11px; border: 1px solid #aaa; border-radius: 7px; font: inherit; text-transform: none; }
.cacodemon-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.cacodemon-save-row { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 14px; margin-top: 16px; }
.cacodemon-save-row > label, .cacodemon-pool-tools label { display: grid; gap: 5px; color: #70002b; font-size: .78rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.cacodemon-save-row input, .cacodemon-pool-tools input, .cacodemon-pool-tools select { min-height: 42px; padding: 9px 11px; border: 1px solid #aaa; border-radius: 7px; background: #fff; color: #222; font: inherit; text-transform: none; }
.cacodemon-save-row input { width: min(320px, 100%); }
.cacodemon-save-row .cacodemon-actions { margin-top: 0; }
.cacodemon-pool-tools { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin: 0 0 15px; }
.cacodemon-pool-tools label { flex: 1 1 190px; }
.cacodemon-pool-tools label:first-child { flex-basis: 260px; }
.cacodemon-pool-tools .cacodemon-button { align-self: end; }
.cacodemon-pool-cards { display: grid; gap: 14px; }
.cacodemon-pool-entry { overflow: hidden; border: 1px solid #bbb; border-left: 4px solid #70002b; border-radius: 7px; background: #fff; }
.cacodemon-pool-entry > summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 14px; cursor: pointer; }
.cacodemon-pool-entry > summary > span { display: grid; gap: 3px; }
.cacodemon-pool-entry > summary strong { color: #70002b; font-size: 1.05rem; }
.cacodemon-pool-entry > summary small { color: #555; }
.cacodemon-pool-entry > summary em { color: #555; font-size: .88rem; font-style: normal; text-align: right; }
.cacodemon-pool-entry[open] > summary { border-bottom: 1px solid #ddd; background: #f7f2f4; }
.cacodemon-pool-entry-body { padding: 12px; background: #f8f8f8; }
.cacodemon-pool-entry-body .cacodemon-card { border-top-width: 3px; }
.cacodemon-remove { display: block; width: 100%; min-height: 40px; margin-top: 10px; border: 1px solid #a11f2b; border-radius: 6px; background: #fff; color: #8d1724; font: inherit; font-weight: 800; cursor: pointer; }
.cacodemon-remove:hover, .cacodemon-remove:focus-visible { background: #fcecee; }
.cacodemon-card { overflow: hidden; border: 1px solid #bbb; border-top: 4px solid #70002b; border-radius: 8px; background: #fff; }
.cacodemon-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid #ddd; background: #f7f2f4; }
.cacodemon-card h3 { margin: 0 0 3px; color: #70002b; font-size: 1.12rem; }
.cacodemon-card header p, .cacodemon-card-meta { margin: 0; color: #555; font-size: .9rem; }
.cacodemon-card-meta { padding: 10px 16px 0; }
.cacodemon-winged { padding: 4px 8px; border: 1px solid #70002b; border-radius: 999px; color: #70002b; font-size: .8rem; font-weight: 800; white-space: nowrap; }
.cacodemon-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin: 0; padding: 14px 16px; }
.cacodemon-stats div { min-width: 0; padding: 7px 8px; border-left: 3px solid #70002b; background: #f8f8f8; }
.cacodemon-stats dt { color: #70002b; font-size: .72rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.cacodemon-stats dd { margin: 3px 0 0; overflow-wrap: anywhere; }
.cacodemon-stats small { color: #555; }
.cacodemon-inherent, .cacodemon-note { margin: 0 16px 12px; line-height: 1.45; }
.cacodemon-note { padding: 9px 11px; border-left: 3px solid #70002b; background: #f7f2f4; }
.cacodemon-abilities { padding: 0 16px 16px; }
.cacodemon-abilities h4 { margin: 0 0 8px; color: #70002b; text-transform: uppercase; }
.cacodemon-abilities details { margin-top: 7px; padding: 9px 10px; border: 1px solid #ddd; border-radius: 5px; background: #f8f8f8; }
.cacodemon-abilities summary { display: flex; justify-content: space-between; gap: 12px; cursor: pointer; }
.cacodemon-abilities summary span { color: #555; font-size: .85rem; }
.cacodemon-abilities p { margin: 8px 0 0; line-height: 1.45; white-space: pre-wrap; }
.cacodemon-empty { margin: 0; color: #555; }

@media (max-width: 600px) {
    .cacodemon-roller, .cacodemon-result, .cacodemon-pool { padding: 14px; }
    .cacodemon-form label, .cacodemon-form .cacodemon-button { flex-basis: 100%; width: 100%; }
    .cacodemon-actions .cacodemon-button { width: 100%; }
    .cacodemon-save-row > label, .cacodemon-save-row input, .cacodemon-pool-tools label, .cacodemon-pool-tools .cacodemon-button { width: 100%; }
    .cacodemon-pool-entry > summary { align-items: flex-start; flex-direction: column; gap: 5px; }
    .cacodemon-pool-entry > summary em { text-align: left; }
    .cacodemon-card header, .cacodemon-result-heading, .cacodemon-pool-heading { align-items: flex-start; flex-direction: column; }
    .cacodemon-fate { align-items: flex-start; flex-direction: column; }
    .cacodemon-abilities summary { align-items: flex-start; flex-direction: column; gap: 3px; }
}

/* =================================
   LEVEL PROGRESSION
================================= */

.reference-page-selector {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 20px;
}

.reference-page-selector-label {
    color: #70002b;
    font-size: 1.15rem;
    font-weight: 700;
}

.reference-class-picker {
    position: relative;
}

.reference-class-picker summary {
    display: flex;
    align-items: center;
    min-height: 36px;
    padding: 0 44px 0 15px;
    border: 3px solid #70002b;
    border-radius: 9px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 12'%3E%3Cpath d='M2 2l8 8 8-8' fill='none' stroke='%2370002b' stroke-linecap='round' stroke-linejoin='round' stroke-width='4'/%3E%3C/svg%3E") no-repeat right 13px center / 17px 11px;
    color: #222;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}

.reference-class-picker summary::-webkit-details-marker {
    display: none;
}

.reference-class-picker summary:hover,
.reference-class-picker summary:focus-visible {
    border-color: #8a002f;
    outline: 3px solid rgba(112, 0, 43, 0.18);
    outline-offset: 2px;
}

.reference-class-picker ul {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 20;
    min-width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 3px solid #70002b;
    border-radius: 9px;
    background: #fff;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.18);
    list-style: none;
}

.reference-class-picker li:nth-child(odd) {
    background: #f4f4f4;
}

.reference-class-picker li:nth-child(even) {
    background: #fff;
}

.reference-class-picker a {
    display: block;
    padding: 3px 15px;
    color: #222;
    font-size: 1.1rem;
    font-weight: 400;
    text-decoration: none;
    white-space: nowrap;
}

.reference-class-picker a:hover,
.reference-class-picker a:focus-visible {
    background: #e8dce1;
    outline: none;
}

.reference-class-picker a.selected {
    color: #70002b;
    font-weight: 700;
}

.level-progression-table-wrap {
    overflow-x: auto;
    border: 2px solid #70002b;
    border-radius: 8px;
}

.attack-saving-throws-table-wrap {
    overflow-x: auto;
    border: 2px solid #70002b;
    border-radius: 8px;
}

.level-progression-table {
    width: 100%;
    min-width: 620px;
    border-collapse: collapse;
    background: #fff;
}

.attack-saving-throws-table {
    width: 100%;
    min-width: 620px;
    border-collapse: collapse;
    background: #fff;
}

.level-progression-table th {
    padding: 8px 10px;
    background: #70002b;
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.05;
    text-align: center;
}

.attack-saving-throws-table th {
    padding: 8px 10px;
    background: #70002b;
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.05;
    text-align: center;
}

.level-progression-table th:nth-child(3),
.level-progression-table td:nth-child(3) {
    text-align: left;
}

.level-progression-table td {
    padding: 5px 10px;
    text-align: center;
}

.attack-saving-throws-table td {
    padding: 5px 10px;
    text-align: center;
}

.level-progression-table tbody tr:nth-child(odd) {
    background: #f4f4f4;
}

.attack-saving-throws-table tbody tr:nth-child(odd) {
    background: #f4f4f4;
}

.level-progression-table tbody tr:nth-child(even) {
    background: #fff;
}

.attack-saving-throws-table tbody tr:nth-child(even) {
    background: #fff;
}

/* =================================
   ARMOR & WEAPON PROFICIENCY
================================= */

.equipment-matrix-note {
    margin: 0 0 14px;
    font-size: 0.85rem;
    line-height: 1.4;
}

.equipment-matrix-wrap {
    overflow: auto;
    border: 2px solid #70002b;
    border-radius: 8px;
}

.equipment-matrix {
    width: 100%;
    min-width: 1120px;
    border-collapse: collapse;
    background: #fff;
}

.equipment-matrix th,
.equipment-matrix td {
    padding: 6px 8px;
    text-align: center;
}

.equipment-matrix thead th {
    background: #70002b;
    color: #fff;
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.05;
}

.equipment-matrix thead tr:nth-child(2) th {
    border-top: 1px solid rgba(255, 255, 255, 0.35);
    font-size: 0.8rem;
}

.equipment-class-name {
    position: sticky;
    left: 0;
    z-index: 1;
    min-width: 130px;
    background: inherit;
    color: #222;
    text-align: left !important;
}

.equipment-class-header {
    position: sticky;
    left: 0;
    z-index: 3;
    min-width: 130px;
    text-align: left !important;
}

.equipment-matrix tbody tr:nth-child(odd) {
    background: #f4f4f4;
}

.equipment-matrix tbody tr:nth-child(even) {
    background: #fff;
}

.equipment-proficient {
    color: #70002b;
    font-size: 1.05rem;
    font-weight: 800;
}

.equipment-variant {
    margin-left: 2px;
    color: #70002b;
    font-weight: 800;
}

.jump-to-top {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    z-index: 10;
    padding: 10px 18px;
    border: 1px solid #202020;
    border-radius: 7px;
    box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.2), inset -1px -1px 0 rgba(0, 0, 0, 0.45), 1px 1px 2px rgba(0, 0, 0, 0.35);
    background: #3f3f3f;
    color: #f4f4f4;
    font: inherit;
    font-size: 1rem;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
}

.jump-to-top:hover,
.jump-to-top:focus-visible {
    background: #555;
}

/* =================================
   PROFICIENCIES
================================= */

.proficiency-browser-controls {
    margin-bottom: 20px;
    padding: 14px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #fff;
}

.proficiency-search-field,
.proficiency-filter-row label {
    display: grid;
    gap: 4px;
}

.proficiency-search-field input {
    width: 100%;
    padding: 8px;
    font: inherit;
}

.proficiency-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 10px;
    margin-top: 10px;
}

.proficiency-filter-row select,
.proficiency-filter-clear {
    min-height: 34px;
    font: inherit;
}

.proficiency-filter-clear {
    padding: 4px 10px;
    border: 1px solid #666;
    border-radius: 4px;
    background: #eee;
    cursor: pointer;
}

.proficiency-result-count {
    margin: 12px 0 0;
    font-weight: 700;
}

.proficiency-card-list {
    display: grid;
    gap: 16px;
    min-width: 0;
}

.proficiency-card {
    min-width: 0;
    padding: 16px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #fff;
}

.proficiency-card h2 {
    margin: 0 0 12px;
    color: #8a302b;
    font-size: 1.38rem;
}

.proficiency-properties {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 16px;
    margin-bottom: 14px;
}

.proficiency-properties p {
    margin: 0;
}

.proficiency-classes {
    grid-column: 1 / -1;
}

.proficiency-description {
    min-width: 0;
    font-size: 0.8rem;
    line-height: 1.5;
    overflow-x: auto;
}

.proficiency-description p {
    margin: 0 0 0.8rem;
}

.proficiency-description table {
    width: 100%;
    min-width: 420px;
    margin: 1rem 0;
    border-collapse: collapse;
}

.proficiency-description th,
.proficiency-description td {
    padding: 0.55rem;
    text-align: left;
}

.proficiency-description th {
    border-bottom: 1px solid #ccc;
}

.proficiency-description tbody tr:nth-child(odd) {
    background: #f0f0f0;
}

.no-proficiency-results {
    margin-top: 18px;
    font-weight: 700;
}

.spell-editor-page { max-width: 960px; margin: 0 auto; }
.workshop-card { border: 2px solid var(--accent-burgundy); border-radius: 9px; background: #fff; box-shadow: 0 4px 12px rgb(0 0 0 / 8%); }
.spell-editor-heading { display: flex; justify-content: space-between; gap: 24px; margin: 2px 0 16px; padding: clamp(16px, 3vw, 24px); }
.spell-editor-heading h1 { margin: 0; color: var(--accent-burgundy); font-size: clamp(1.6rem, 3vw, 2.2rem); }
.spell-editor-heading p { margin: 7px 0 0; color: #555; }
.spell-editor-eyebrow { color: var(--accent-burgundy) !important; font-size: .75rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.spell-editor-message { margin: 0 0 16px; padding: 11px 13px; border: 1px solid; border-radius: 7px; font-weight: 700; }
.spell-editor-message.is-error { border-color: #a62b2b; background: #fff0f0; color: #8b1d1d; }
.spell-editor-message.is-success { border-color: #287a42; background: #ecf8ef; color: #155d2b; }
.spell-editor-message.is-warning { border-color: #926a1c; background: #fff8e9; color: #6c4b08; }
.workshop-tabs-card { margin-bottom: 0; padding: 8px 10px 0; border-bottom: 0; border-radius: 9px 9px 0 0; }
.spell-editor-tabs { display: flex; gap: 7px; margin: 0; border-bottom: 1px solid var(--accent-burgundy); }
.spell-editor-tab { margin-bottom: -1px; padding: 11px 16px; border: 1px solid transparent; border-bottom: 0; border-radius: 7px 7px 0 0; background: transparent; color: #555; font: inherit; font-weight: 800; cursor: pointer; }
.spell-editor-tab:hover, .spell-editor-tab:focus-visible { background: #f2e2e8; color: var(--accent-burgundy); }
.spell-editor-tab.is-active { border-color: var(--accent-burgundy); background: var(--accent-burgundy); color: #fff; }
.spell-editor-panel { padding: clamp(16px, 3vw, 26px); border: 2px solid var(--accent-burgundy); border-radius: 0 0 9px 9px; background: #fff; box-shadow: 0 5px 14px rgb(0 0 0 / 7%); }
.spell-editor-panel[hidden] { display: none; }
.spell-editor-panel-heading { margin-bottom: 20px; }
.spell-editor-panel-heading h2 { margin: 0; color: #333; font-size: 1.25rem; }
.spell-editor-panel-heading p { margin: 5px 0 0; color: #666; }
.spell-editor-form { display: grid; gap: 18px; }
.spell-editor-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.spell-editor-grid label, .spell-picker label { display: grid; gap: 6px; color: #333; font-weight: 700; }
.spell-editor-grid label.is-wide { grid-column: 1 / -1; }
.spell-editor-grid b { color: #a51e46; }
.spell-editor-grid input, .spell-editor-grid textarea, .spell-picker input { width: 100%; box-sizing: border-box; padding: 9px 10px; border: 1px solid #aaa; border-radius: 5px; background: #fff; color: #222; font: inherit; font-weight: 400; }
.spell-editor-grid :is(input, textarea):focus, .spell-picker input:focus { border-color: var(--accent-burgundy); outline: 3px solid rgb(112 0 43 / 16%); }
.spell-editor-grid textarea { min-height: 220px; resize: vertical; line-height: 1.45; }
.spell-editor-grid small { color: #666; font-weight: 400; }
.equipment-editor { grid-column: 1 / -1; min-width: 0; margin: 0; padding: 18px; border: 1px solid #ccc; border-radius: 7px; background: #faf9f8; }
.equipment-editor legend { padding: 0 7px; font-weight: 700; color: var(--accent-burgundy); }
.equipment-editor > p { margin-top: 0; color: #555; }
.equipment-editor select { width: 100%; box-sizing: border-box; min-height: 40px; padding: 9px 10px; border: 1px solid #aaa; border-radius: 5px; background: white; color: #222; font: inherit; font-weight: 400; }
.equipment-editor select[multiple] { min-height: 180px; }
.equipment-editor select:focus { border-color: var(--accent-burgundy); outline: 3px solid rgb(112 0 43 / 16%); }
.equipment-editor select:disabled { background: #eee; color: #777; }
.spell-editor-actions { display: flex; justify-content: flex-end; }
.spell-editor-actions .transaction-submit { width: auto; min-width: 190px; }
.spell-picker { display: flex; align-items: end; gap: 12px; margin: 0 0 22px; padding: 15px; border: 1px solid #ddd; border-radius: 7px; background: #f9f8f8; }
.spell-picker label { flex: 1; }
.spell-editor-secondary-button { padding: 10px 14px; border: 1px solid var(--accent-burgundy); border-radius: 5px; background: #fff; color: var(--accent-burgundy); font: inherit; font-weight: 800; cursor: pointer; }
.spell-editor-secondary-button:hover, .spell-editor-secondary-button:focus-visible { background: #f2e2e8; }
.spell-editor-empty { margin: 0; padding: 26px; border: 1px dashed #b8a8ae; border-radius: 7px; color: #666; text-align: center; }
.spell-builder-note { margin: 0 0 18px; padding: 10px 12px; border-left: 4px solid var(--accent-burgundy); background: #f8f3f5; color: #54434a; }
.spell-builder-form select { width: 100%; box-sizing: border-box; padding: 9px 10px; border: 1px solid #aaa; border-radius: 5px; background: #fff; color: #222; font: inherit; font-weight: 400; }
.spell-builder-form select[multiple] { min-height: 160px; }
.spell-builder-form select:focus { border-color: var(--accent-burgundy); outline: 3px solid rgb(112 0 43 / 16%); }
.spell-builder-result { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 22px 0 10px; }
.spell-builder-result div { padding: 14px; border: 1px solid #cfbec5; border-radius: 7px; background: #faf7f8; }
.spell-builder-result span { display: block; color: #65545a; font-size: .8rem; font-weight: 800; text-transform: uppercase; }
.spell-builder-result strong { display: block; margin-top: 4px; color: var(--accent-burgundy); font-size: 1.35rem; }
.spell-builder-calculation { margin: 0 0 18px; color: #65545a; font-size: .92rem; }
.spell-builder-panel > .transaction-submit { width: auto; min-width: 245px; }
.builder-choice-field { grid-column: 1 / -1; margin: 0; padding: 0; border: 0; color: #333; font-weight: 700; }
.builder-choice-field legend { margin-bottom: 6px; }
.builder-multi-picker { border: 1px solid #aaa; border-radius: 5px; background: #fff; }
.builder-multi-picker summary { padding: 10px; color: #333; font-weight: 400; cursor: pointer; }
.builder-multi-picker[open] summary { border-bottom: 1px solid #ddd; }
.builder-multi-picker .builder-choice-list { max-height: 270px; border: 0; border-radius: 0; }
.builder-choice-list, .item-effect-spells { display: grid; gap: 4px; max-height: 180px; overflow: auto; padding: 7px; border: 1px solid #aaa; border-radius: 5px; background: #fff; }
.builder-choice-list label, .item-effect-spells label { display: flex; gap: 9px; align-items: start; padding: 5px 7px; border-radius: 4px; font-weight: 400; cursor: pointer; }
.builder-choice-list label:hover, .item-effect-spells label:hover { background: #f2e2e8; }
.builder-choice-list input, .item-effect-spells input { width: 19px; height: 19px; margin: 0; accent-color: var(--accent-burgundy); }
.item-builder-effects { display: grid; gap: 14px; margin: 18px 0 12px; }
.item-effect-row { display: grid; grid-template-columns: minmax(200px, 1fr) minmax(280px, 1fr); gap: 10px 14px; padding: 12px; border: 1px solid var(--accent-burgundy); border-radius: 7px; background: #faf7f8; }
.item-effect-row-head, .item-effect-spells { grid-column: 1 / -1; }
.item-effect-row-head { display: flex; justify-content: space-between; align-items: center; color: var(--accent-burgundy); }
.item-effect-row label { display: grid; gap: 6px; font-weight: 700; }
.item-effect-row > label { align-self: start; align-content: start; }
.item-effect-row > label select { height: auto; min-height: 42px; }
.item-effect-spell-controls { display: grid; gap: 6px; min-width: 0; }
.item-effect-spell-search input { width: 100%; box-sizing: border-box; padding: 9px 10px; border: 1px solid #aaa; border-radius: 5px; background: #fff; color: #222; font: inherit; font-weight: 400; }
.item-effect-spell-search input:focus { border-color: var(--accent-burgundy); outline: 3px solid rgb(112 0 43 / 16%); }
.item-effect-spells { grid-column: auto; max-height: 145px; font-size: .9rem; }
.item-effect-spells label { display: flex; grid-template-columns: none; gap: 9px; align-items: center; padding: 5px 7px; font-weight: 400; }

@media (max-width: 600px) {
    .spell-editor-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; border: 0; }
    .spell-editor-tab { margin: 0; border: 1px solid #b8a8ae; border-radius: 6px; }
    .spell-editor-grid { grid-template-columns: 1fr; }
    .spell-editor-grid label.is-wide { grid-column: auto; }
    .spell-picker { display: grid; }
    .spell-editor-secondary-button, .spell-editor-actions .transaction-submit { width: 100%; }
    .spell-builder-result { grid-template-columns: 1fr; }
    .spell-builder-panel > .transaction-submit { width: 100%; }
    .item-effect-row { grid-template-columns: 1fr; }
}

.storage-action-button {
    padding: 5px 8px;
    color: #000;
    white-space: nowrap;
}

.take-one-button:disabled {
    background: #d3d3d3;
    color: #666;
    cursor: not-allowed;
}


/* =================================
   MOBILE
================================= */

@media (max-width: 600px) {

    .header-inner {
        padding-left: 16px;
        padding-right: 16px;
    }

    .page-title {
        margin-bottom: 20px;
    }

    .wallet-summary {
        margin-bottom: 32px;
    }

    .balance-value {
        font-size: 1.5rem;
    }

    .wallet-actions {
        gap: 10px;
    }

    .wallet-button {
        max-width: none;
        padding: 14px 10px;
    }

    .storage-heading {
        align-items: stretch;
        flex-direction: column;
        gap: 12px;
    }

    .storage-button {
        padding: 14px 10px;
        text-align: center;
    }

    .storage-page-actions {
        flex-direction: column;
    }

    .storage-button {
        width: 100%;
    }

    .spell-list-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .spell-properties {
        grid-template-columns: 1fr;
    }

    .magic-item-properties {
        grid-template-columns: 1fr;
    }

    .proficiency-properties {
        grid-template-columns: 1fr;
    }

}

@media (max-width: 480px) {

    .level-progression-table {
        min-width: 500px;
    }

    .attack-saving-throws-table {
        min-width: 500px;
    }

    .level-progression-table th {
        padding: 6px 4px;
    }

    .attack-saving-throws-table th {
        padding: 6px 4px;
    }

    .level-progression-table td {
        padding: 4px;
    }

    .attack-saving-throws-table td {
        padding: 4px;
    }

    .equipment-matrix th,
    .equipment-matrix td {
        padding: 4px;
    }

    body div.dt-container div.dt-layout-row:not(.dt-layout-table) {
        display: block;
    }

    body div.dt-container div.dt-layout-row:not(.dt-layout-table) div.dt-layout-cell {
        display: block;
        margin: 0;
        text-align: center;
    }

}

/* Editable database equipment references */
.equipment-reference-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 24px; }
.equipment-reference-tabs a { display: block; padding: 9px 13px; border: 1px solid #ccc; border-radius: 6px; color: #444; background: #f7f7f7; text-decoration: none; }
.equipment-reference-tabs a.is-active { color: white; background: var(--accent-burgundy); border-color: var(--accent-burgundy); }
.equipment-reference-search { display: grid; gap: 5px; max-width: 440px; font-weight: 700; }
.equipment-reference-search input { min-height: 40px; padding: 9px; border: 1px solid #aaa; border-radius: 5px; font: inherit; }
.equipment-reference-table th { white-space: nowrap; }
.equipment-reference-table td { min-width: 90px; max-width: 440px; overflow-wrap: break-word; }
.equipment-reference-table td:nth-child(2) { min-width: 220px; }
.equipment-reference-unspecified { color: #777; }

/* Shared item form, starting with campaign Deep Storage. */
.inventory-dialog { max-width: 880px; max-height: calc(100dvh - 28px); overflow-y: auto; overscroll-behavior: contain; }
.inventory-item-form { display: grid; gap: 20px; padding: 22px 24px 24px; }
.inventory-item-form fieldset { min-width: 0; margin: 0; padding: 16px; border: 1px solid #ccc; border-radius: 7px; background: #fff; }
.inventory-item-form legend { padding: 0 7px; color: var(--accent-burgundy); font-weight: 700; }
.inventory-form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.inventory-form-grid label { display: grid; align-content: start; gap: 6px; min-width: 0; font-weight: 700; }
.inventory-form-grid .inventory-wide { grid-column: 1 / -1; }
.inventory-form-grid input, .inventory-form-grid select, .inventory-form-grid textarea { box-sizing: border-box; width: 100%; min-height: 42px; padding: 9px 10px; border: 1px solid #aaa; border-radius: 5px; background: #fff; color: #222; font: inherit; font-weight: 400; }
.inventory-form-grid textarea { resize: vertical; }
.inventory-form-grid small { font-size: .85rem; font-weight: 400; color: #666; }
.inventory-form-grid b { color: var(--accent-burgundy); }
.inventory-form-grid :is(input,select,textarea):focus { outline: 3px solid rgb(112 0 43 / 16%); border-color: var(--accent-burgundy); }
.inventory-form-grid select:disabled { background: #eee; }
.inventory-form-grid [hidden] { display: none; }
.inventory-reference-summary { margin: 0; padding: 12px; border-left: 3px solid var(--accent-burgundy); background: #f7f4f5; line-height: 1.5; }
.inventory-item-form:not([data-catalog-kind="equipment"]) [data-catalog-field] { grid-column: 1 / -1; }
.inventory-part-details { display: grid; gap: 12px; padding: 16px; border-radius: 6px; background: #f8f5f6; overflow-wrap: anywhere; }
.inventory-part-details p { margin: 0; line-height: 1.5; }
.inventory-part-details strong { font-weight: 700; }
.inventory-magic-details { display: grid; gap: 10px; min-width: 0; }
.inventory-magic-details > p { margin: 0 0 2px; overflow-wrap: anywhere; }
.inventory-magic-details details { min-width: 0; border: 1px solid #e1d5db; border-radius: 6px; background: #faf7f8; }
.inventory-magic-details summary { padding: 12px 14px; color: var(--accent-burgundy); font-weight: 700; cursor: pointer; }
.inventory-magic-details summary:focus-visible { outline: 3px solid #70002b40; outline-offset: 2px; border-radius: 6px; }
.inventory-magic-details details[open] summary { border-bottom: 1px solid #e1d5db; }
.inventory-magic-details details > div { padding: 14px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.inventory-part-effects { display: grid; gap: 10px; }
.inventory-part-effect-groups { display: flex; flex-wrap: wrap; gap: 12px; }
.inventory-part-effect-groups section { flex: 1 1 220px; min-width: 0; padding: 12px 14px; border: 1px solid #e5dce0; border-radius: 6px; background: #fff; }
.inventory-part-effect-groups h3 { margin: 0 0 10px; color: var(--accent-burgundy); font-size: .9rem; font-weight: 700; line-height: 1.4; }
.inventory-part-effect-groups ul { display: grid; gap: 6px; margin: 0; padding-left: 20px; line-height: 1.5; }
.inventory-part-details .inventory-part-note { padding-top: 10px; border-top: 1px solid #e5dce0; color: #61545a; font-size: .875rem; }
.inventory-form-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 12px; }
.inventory-override-toast { position: fixed; z-index: 10000; right: 20px; bottom: 20px; display: flex; align-items: flex-start; gap: 14px; max-width: min(560px,calc(100vw - 40px)); box-sizing: border-box; padding: 16px 18px; color: #fff; background: #403138; border-left: 5px solid #b3d59c; border-radius: 7px; box-shadow: 0 5px 24px #0003; }
.inventory-override-toast p { margin: 0; line-height: 1.5; overflow-wrap: anywhere; }
.inventory-override-toast button { flex: none; border: 0; padding: 0; background: transparent; color: #fff; font: inherit; font-size: 1.3rem; cursor: pointer; }
.inventory-form-actions .transaction-submit { width: auto; min-width: 150px; }
.inventory-form-page { max-width: 960px; margin-inline: auto; }
.storage-item-kind { display: block; margin-top: 4px; color: #666; font-size: .8rem; white-space: normal; }
@media(max-width: 600px) {
 .inventory-form-grid { grid-template-columns: 1fr; }
 .inventory-item-form { padding: 14px; }
 .inventory-item-form fieldset { padding: 12px; }
}
.inventory-owner-label { display: block; min-height: 42px; box-sizing: border-box; padding: 9px 10px; border: 1px solid #ddd; border-radius: 5px; background: #f5f5f5; font-weight: 400; }
.inventory-ready-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; }
.inventory-form-grid .inventory-ready-controls label { display: flex; align-items: center; gap: 7px; }
.inventory-ready-controls input[type=checkbox] { width: 18px; min-height: 18px; height: 18px; }
#characterInventoryDialog { padding: 0; width: min(880px, calc(100vw - 28px)); }
#characterInventoryDialog .character-dialog-header { padding: 20px 24px 0; }
#characterInventoryTable td { white-space: normal; }

/* Ordinal suffixes do not change description line spacing. */
sup.ordinal-suffix, [data-ordinal-text] sup { font-size:.7em; line-height:0; vertical-align:super; }

/* Floating utilities must yield to open menus and table controls. */
body:has(details[open]) .jump-to-top { visibility: hidden; }
body:has(.jump-to-top) main { padding-bottom: 90px; }
.jump-to-top { left: auto; right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); transform: none; z-index: 2; }
.campaign-read-trigger { border:0; background:none; color:#70002b; text-align:left; font:inherit; font-weight:700; cursor:pointer; text-decoration:underline; }
.campaign-reader { width:min(780px, calc(100vw - 28px)); max-height:calc(100dvh - 28px); padding:24px; overflow:auto; border:1px solid #777; border-radius:10px; background:#f7f7f7; }
.campaign-reader::backdrop { background:rgb(0 0 0 / 60%); }
.campaign-reader header { display:flex; justify-content:space-between; align-items:start; gap:16px; }
.campaign-reader h2 { margin:0 0 16px; color:#70002b; }
.campaign-reader button { cursor:pointer; min-height:40px; }
.campaign-reader dt { font-weight:700; margin-top:16px; color:#70002b; }
.campaign-reader dd { margin:5px 0 0; white-space:pre-wrap; overflow-wrap:anywhere; line-height:1.6; }

/* Campaign table layout: actions left, filters/search right, page size in footer. */
.campaign-reader .campaign-dialog-close { display:grid; place-items:center; flex:0 0 34px; width:34px; height:34px; min-height:34px; padding:0; border:0; border-radius:50%; background:#e0e0e0; color:#333; font-size:1.35rem; }
.campaign-reader .campaign-dialog-close:hover, .campaign-reader .campaign-dialog-close:focus-visible { background:#f2e2e8; color:#70002b; }
.campaign-records-page .dt-layout-end, .locations-page .dt-layout-end { gap:14px; flex-wrap:wrap; }
.campaign-reader h2 { overflow-wrap:anywhere; }
.roster-henchman-name { padding-left:24px !important; }

div.dt-container table.dataTable.operational-table tbody td.roster-henchman-name { padding-left:28px !important; }

/* Journal actions remain visible while the entry body scrolls. */
.campaign-reader-with-actions[open] { display:flex; flex-direction:column; overflow:hidden; }
.campaign-reader-with-actions > header { flex:0 0 auto; }
.campaign-reader-with-actions > dl { min-height:0; overflow-y:auto; margin:0; padding:0 8px 20px 0; overscroll-behavior:contain; }
.campaign-reader-actions { display:flex; justify-content:space-between; gap:16px; flex:0 0 auto; padding-top:16px; border-top:1px solid #ccc; }
.campaign-reader-actions > button { flex:0 1 220px; }

.inventory-type-disclosure { padding:12px 15px; border:1px solid #ccc; border-radius:6px; background:#faf7f8; }
.inventory-type-disclosure > summary { cursor:pointer; color:#70002b; font-weight:700; }
.inventory-type-disclosure > p { color:#555; margin:10px 0; }
.inventory-type-disclosure > fieldset { margin-top:12px; }
