/* Dashboard play surfaces: Collection+, deck library, and deck builder. */
html[data-theme-enabled][data-theme='dark'] .collection-plus-page,
html[data-theme-enabled][data-theme='dark'] .my-decks-page,
html[data-theme-enabled][data-theme='dark'] body.deck-builder-page {
  color: var(--theme-text);
  background: var(--theme-bg);
}

html[data-theme-enabled][data-theme='dark'] .collection-plus-page,
html[data-theme-enabled][data-theme='dark'] .my-decks-page { --plum: var(--theme-text); --plum-2: var(--theme-accent); --gold: var(--theme-gold); --line: var(--theme-border); --ivory: var(--theme-surface); }

/* Shared controls and accessible focus. */
html[data-theme-enabled][data-theme='dark'] .collection-plus-page :is(.form-control,.form-select,.cp-search input),
html[data-theme-enabled][data-theme='dark'] .my-decks-page :is(.deck-search,.my-decks-controls select,.deck-filter-toggle),
html[data-theme-enabled][data-theme='dark'] .deck-builder-page :is(.form-control,.form-select) {
  color: var(--theme-text);
  background-color: var(--theme-input);
  border-color: var(--theme-border);
}
html[data-theme-enabled][data-theme='dark'] :is(.collection-plus-page,.my-decks-page,.deck-builder-page) :is(input,select,textarea,button):focus-visible {
  outline: 3px solid var(--theme-accent);
  outline-offset: 2px;
}
html[data-theme-enabled][data-theme='dark'] :is(.collection-plus-page,.my-decks-page,.deck-builder-page) :is(.form-control,.form-select,.cp-search input):focus {
  color: var(--theme-text);
  background-color: var(--theme-input);
  border-color: var(--theme-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--theme-accent) 30%, transparent);
}
html[data-theme-enabled][data-theme='dark'] :is(.collection-plus-page,.my-decks-page,.deck-builder-page) ::placeholder { color: var(--theme-muted); opacity: 1; }
html[data-theme-enabled][data-theme='dark'] :is(.collection-plus-page,.my-decks-page,.deck-builder-page) .text-muted { color: var(--theme-muted) !important; }

/* Collection+. Never recolor card art, rarity, playset glows, or semantic status badges. */
html[data-theme-enabled][data-theme='dark'] .collection-plus-heading,
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-groups-rail-wrap,
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-filters,
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-group-bar {
  color: var(--theme-text);
  background: var(--theme-surface);
  border-color: var(--theme-border);
}
html[data-theme-enabled][data-theme='dark'] .collection-plus-heading :is(h1,p),
html[data-theme-enabled][data-theme='dark'] .collection-plus-breadcrumb a,
html[data-theme-enabled][data-theme='dark'] .collection-plus-page :is(.cp-groups-rail-head h2,.cp-groups-rail-head span,.cp-groups-empty-hint,.cp-loading,.cp-empty-state) { color: var(--theme-text); }
html[data-theme-enabled][data-theme='dark'] .collection-plus-page :is(.collection-plus-create,.cp-variants-modal__footer .btn-primary) {
  color: var(--theme-on-action) !important;
  background: var(--theme-action) !important;
  border-color: var(--theme-action) !important;
}
html[data-theme-enabled][data-theme='dark'] .collection-plus-page :is(.collection-plus-create:hover,.cp-variants-modal__footer .btn-primary:hover) { filter: brightness(1.12); }
html[data-theme-enabled][data-theme='dark'] .collection-plus-visibility,
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-filter-toggle,
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-search,
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .form-select {
  color: var(--theme-text);
  background: var(--theme-input);
  border-color: var(--theme-border);
}
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-group-chip,
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-group-chip--all,
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-group-chip__actions,
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-group-chip__menu summary {
  color: var(--theme-text);
  background-color: var(--theme-raised);
  border-color: var(--theme-border);
}
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-group-chip:hover,
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-group-chip.active,
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-group-chip__actions button:hover,
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-group-chip__actions button:focus-visible { background-color: var(--theme-surface); }
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-group-chip__body :is(strong,small),
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-group-bar :is(.cp-group-bar__label,.cp-group-bar__stats),
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-card__name { color: var(--theme-text); }
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-group-chip__body small { color: var(--theme-muted); }
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-card,
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-card__footer {
  color: var(--theme-text);
  background: var(--theme-raised);
  border-color: var(--theme-border);
}
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-card:hover { background: var(--theme-surface); border-color: var(--theme-accent); }
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-card__img-wrap { background: var(--theme-bg); }
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-group-bar__close,
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-group-export .btn { color: var(--theme-text); border-color: var(--theme-border); }
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-group-bar__close:hover,
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-group-export .btn:hover { color: var(--theme-on-action); background: var(--theme-action); border-color: var(--theme-action); }

/* Collection dialogs, popovers, variant controls, and empty states. */
html[data-theme-enabled][data-theme='dark'] .collection-plus-page :is(.cp-variants-modal,.cp-market-modal,#cpGroupModal .modal-content,.cp-art-picker,.cp-cover-picker,.cp-group-picker-popover,.cp-export-menu) {
  color: var(--theme-text);
  background: var(--theme-surface);
  border-color: var(--theme-border);
}
html[data-theme-enabled][data-theme='dark'] .collection-plus-page :is(.modal-header,.modal-footer,.cp-variants-modal__header,.cp-variants-modal__footer,.cp-group-picker-popover__head) { border-color: var(--theme-border); }
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-variants-modal__header { color: var(--theme-text); background: var(--theme-raised); }
html[data-theme-enabled][data-theme='dark'] .collection-plus-page :is(.cp-modal-preview,.cp-variant-row,.cp-cover-result-item,.cp-art-picker__tile,.cp-group-picker-popover__option,.cp-variant-group-picker__option) { color: var(--theme-text); background: var(--theme-raised); border-color: var(--theme-border); }
html[data-theme-enabled][data-theme='dark'] .collection-plus-page :is(.cp-variant-row:hover,.cp-cover-result-item:hover,.cp-art-picker__tile:hover:not(:disabled),.cp-group-picker-popover__option:hover,.cp-variant-group-picker__option:hover) { background: var(--theme-surface); }
html[data-theme-enabled][data-theme='dark'] .collection-plus-page :is(.cp-qty-btn,.cp-toggle,.cp-market-btn,.cp-group-picker-popover__head button,.cp-art-picker__close) { color: var(--theme-text); background: var(--theme-input); border-color: var(--theme-border); }
html[data-theme-enabled][data-theme='dark'] .collection-plus-page :is(.cp-qty-btn:hover,.cp-toggle:hover,.cp-market-btn:hover:not(:disabled)) { color: var(--theme-on-action); background: var(--theme-action); border-color: var(--theme-action); }
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .btn-secondary { color: var(--theme-text); background: var(--theme-raised); border-color: var(--theme-border); }
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-selection-bar { color: var(--theme-text); background: var(--theme-surface); border-color: var(--theme-border); box-shadow: 0 -4px 18px color-mix(in srgb, var(--theme-bg) 70%, transparent); }

/* My decks and its shared deck cards. */
html[data-theme-enabled][data-theme='dark'] .my-decks-heading { border-color: var(--theme-border); }
html[data-theme-enabled][data-theme='dark'] .my-decks-heading :is(h1,p),
html[data-theme-enabled][data-theme='dark'] .my-decks-breadcrumb a,
html[data-theme-enabled][data-theme='dark'] .deck-card :is(h2,.deck-card__tribes,.deck-card__record,.deck-card__metrics,.deck-card__value) { color: var(--theme-text); }
html[data-theme-enabled][data-theme='dark'] .my-decks-heading p,
html[data-theme-enabled][data-theme='dark'] .deck-card__tribes,
html[data-theme-enabled][data-theme='dark'] :is(.deck-empty,.deck-empty-filter) { color: var(--theme-muted); }
html[data-theme-enabled][data-theme='dark'] .my-decks-create { color: var(--theme-on-action) !important; background: var(--theme-action); border-color: var(--theme-action); }
html[data-theme-enabled][data-theme='dark'] .my-decks-create:hover { filter: brightness(1.12); }
html[data-theme-enabled][data-theme='dark'] .deck-search { color: var(--theme-text); }
html[data-theme-enabled][data-theme='dark'] .deck-card { background: var(--theme-raised); border-color: var(--theme-border); box-shadow: 0 6px 16px color-mix(in srgb, var(--theme-bg) 55%, transparent); }
html[data-theme-enabled][data-theme='dark'] .deck-card :is(.deck-card__record,.deck-card__metrics) { border-color: var(--theme-border); }
html[data-theme-enabled][data-theme='dark'] :is(.deck-card__edit,.deck-card__more,.deck-card__menu,#deck-confirm-dialog,#deck-confirm-dialog button) { color: var(--theme-text); background: var(--theme-surface); border-color: var(--theme-border); }
html[data-theme-enabled][data-theme='dark'] .deck-card__menu button { color: var(--theme-text); }
html[data-theme-enabled][data-theme='dark'] .deck-card__menu button:hover { background: var(--theme-raised); }
html[data-theme-enabled][data-theme='dark'] #deck-confirm-dialog::backdrop { background: color-mix(in srgb, var(--theme-bg) 75%, transparent); }

/* Builder: includes existing inline-colored panels without changing card art or tribe badges. */
html[data-theme-enabled][data-theme='dark'] body.deck-builder-page > .deck-builder-toolbar { background: var(--theme-surface) !important; border-color: var(--theme-border); }
html[data-theme-enabled][data-theme='dark'] .deck-builder-page :is(h5,h6,.form-label,.card-list-name,.card-list-type,.cost-column,.hand-simulator-empty) { color: var(--theme-text) !important; }
html[data-theme-enabled][data-theme='dark'] .deck-builder-page .deck-builder-toolbar .navbar-brand { color: var(--theme-text) !important; }
html[data-theme-enabled][data-theme='dark'] .deck-builder-page :is(.deck-builder-toolbar a.btn,.deck-builder-toolbar .dropdown > button,.builder-filter-button,.container-fluid .btn-success,.container-fluid .btn-info) { color: var(--theme-text) !important; background: var(--theme-raised) !important; border-color: var(--theme-border) !important; }
html[data-theme-enabled][data-theme='dark'] .deck-builder-page #saveDeckBtn { color: var(--theme-on-action) !important; background: var(--theme-action) !important; border-color: var(--theme-action) !important; }
html[data-theme-enabled][data-theme='dark'] .deck-builder-page :is(.card,.dropdown-menu,.card-list-item,.builder-metrics .rounded,#vaultCards,#kingdomCards,#sideboardCards,.hand-simulator-board) { color: var(--theme-text); background: var(--theme-surface) !important; border-color: var(--theme-border) !important; }
html[data-theme-enabled][data-theme='dark'] .deck-builder-page .card-header,
html[data-theme-enabled][data-theme='dark'] .deck-builder-page .card .text-center.h-100 { color: var(--theme-text) !important; background: var(--theme-raised) !important; }
html[data-theme-enabled][data-theme='dark'] .deck-builder-page .builder-tribes { background: var(--theme-raised); border-color: var(--theme-border); }
html[data-theme-enabled][data-theme='dark'] .deck-builder-page .builder-tribes :is(.form-label,.form-select,.builder-required) { color: var(--theme-text) !important; background-color: var(--theme-input); border-color: var(--theme-border); }
html[data-theme-enabled][data-theme='dark'] .deck-builder-page :is(.builder-cover #normalBannerSection,.builder-cover #guardianCardSection) { background: var(--theme-raised) !important; border-color: var(--theme-border) !important; }
html[data-theme-enabled][data-theme='dark'] .deck-builder-page .builder-metrics :is(.progress,.progress-bar) { background: var(--theme-border) !important; }
html[data-theme-enabled][data-theme='dark'] .deck-builder-page .builder-metrics .progress-bar { background: var(--theme-gold) !important; }
html[data-theme-enabled][data-theme='dark'] .deck-builder-page :is(.modal-content,.modal-body,.modal-footer) { color: var(--theme-text); background: var(--theme-surface); border-color: var(--theme-border); }
html[data-theme-enabled][data-theme='dark'] .deck-builder-page :is(#guardianSelectorModal .modal-header,#importDeckModal .modal-header) { color: var(--theme-text); background: var(--theme-raised) !important; }
html[data-theme-enabled][data-theme='dark'] .deck-builder-page :is(.alert-info,.dropdown-divider) { color: var(--theme-text); background-color: var(--theme-raised); border-color: var(--theme-border); }

@media (max-width: 800px) {
  html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-filter-panel,
  html[data-theme-enabled][data-theme='dark'] .my-decks-page .deck-filter-panel[data-open='true'] { background: var(--theme-surface); }
}

/* Inline builder panels and state feedback retain their meaning while using dark surfaces. */
html[data-theme-enabled][data-theme='dark'] .deck-builder-page div:has(> .form-check #showCardPricesToggle),
html[data-theme-enabled][data-theme='dark'] .deck-builder-page #formatFilterIndicator,
html[data-theme-enabled][data-theme='dark'] .deck-builder-page :is(.cost-badge,.vault-cost-chip,.card-list-pool,.card-list-vault-cost,.quantity-badge,.price-badge) {
  color: var(--theme-text) !important;
  background-color: var(--theme-raised) !important;
  border-color: var(--theme-border) !important;
}
html[data-theme-enabled][data-theme='dark'] .deck-builder-page :is(#cardsList,.deck-area-vault,.deck-area-cost-columns,.cost-column) { background-color: var(--theme-bg) !important; border-color: var(--theme-border) !important; }
html[data-theme-enabled][data-theme='dark'] .deck-builder-page .card-list-item:hover { background: var(--theme-raised) !important; border-color: var(--theme-accent) !important; }
html[data-theme-enabled][data-theme='dark'] .deck-builder-page :is(.hand-simulator-empty,.hand-sim-card,.card-preview-tooltip) { color: var(--theme-text); background-color: var(--theme-raised); border-color: var(--theme-border); }
html[data-theme-enabled][data-theme='dark'] .deck-builder-page .btn-warning { color: var(--theme-on-action); background: var(--theme-gold); border-color: var(--theme-gold); }
html[data-theme-enabled][data-theme='dark'] .deck-builder-page :is(.btn-primary,.btn-success) { color: var(--theme-on-action); background-color: var(--theme-action); border-color: var(--theme-action); }
html[data-theme-enabled][data-theme='dark'] .deck-builder-page label[for='showCardPricesToggle'] { color: var(--theme-text) !important; }

/* Bootstrap mounts Collection+ modals outside `.collection-plus-page`; source styles load later, so these must be explicit. */
html[data-theme-enabled][data-theme='dark'] :is(#cpVariantsModal .cp-variants-modal,#cpMarketActionModal .cp-market-modal,#cpGroupModal .modal-content) {
  color: var(--theme-text) !important;
  background: var(--theme-surface) !important;
  border-color: var(--theme-border) !important;
}
html[data-theme-enabled][data-theme='dark'] :is(#cpVariantsModal .modal-header,#cpMarketActionModal .modal-header,#cpGroupModal .modal-header,#cpVariantsModal .modal-body,#cpMarketActionModal .modal-body,#cpGroupModal .modal-body,#cpVariantsModal .modal-footer,#cpMarketActionModal .modal-footer,#cpGroupModal .modal-footer) {
  color: var(--theme-text) !important;
  background: var(--theme-surface) !important;
  border-color: var(--theme-border) !important;
}
html[data-theme-enabled][data-theme='dark'] #cpVariantsModal .cp-variants-modal__header { background: var(--theme-raised) !important; }
html[data-theme-enabled][data-theme='dark'] :is(#cpVariantsModal,#cpMarketActionModal,#cpGroupModal) :is(.modal-title,.form-label,.form-check-label,.cp-variants-section-title,.cp-modal-preview__label,.cp-variant-row__name,.cp-market-modal__variant,.cp-market-modal__hint) { color: var(--theme-text) !important; }
html[data-theme-enabled][data-theme='dark'] :is(#cpVariantsModal,#cpMarketActionModal,#cpGroupModal) :is(.form-control,.form-select) { color: var(--theme-text) !important; background: var(--theme-input) !important; border-color: var(--theme-border) !important; }
html[data-theme-enabled][data-theme='dark'] :is(#cpVariantsModal,#cpMarketActionModal,#cpGroupModal) .btn-close { filter: invert(1) grayscale(1); }
html[data-theme-enabled][data-theme='dark'] :is(#cpVariantsModal,#cpMarketActionModal,#cpGroupModal) .btn-secondary { color: var(--theme-text) !important; background: var(--theme-raised) !important; border-color: var(--theme-border) !important; }
html[data-theme-enabled][data-theme='dark'] :is(#cpVariantsModal,#cpMarketActionModal,#cpGroupModal) .btn-primary { color: var(--theme-on-action) !important; background: var(--theme-action) !important; border-color: var(--theme-action) !important; }
html[data-theme-enabled][data-theme='dark'] .collection-plus-page .cp-group-chip--all .cp-group-chip__icon { color: var(--theme-gold) !important; }
html[data-theme-enabled][data-theme='dark'] #cpVariantsModal :is(.cp-modal-preview,.cp-variant-row,.cp-variant-card__body,.cp-variant-row__market,.cp-variant-group-chip,.cp-variant-group-add,.cp-foil-create-btn,.cp-foil-badge,.cp-market-btn,.cp-toggle,.cp-qty-btn) {
  color: var(--theme-text) !important;
  background: var(--theme-raised) !important;
  border-color: var(--theme-border) !important;
}
html[data-theme-enabled][data-theme='dark'] #cpVariantsModal :is(.cp-qty-input,.cp-market-modal .form-control) { color: var(--theme-text) !important; background: var(--theme-input) !important; border-color: var(--theme-border) !important; }
html[data-theme-enabled][data-theme='dark'] #cpGroupModal :is(.cp-cover-picker,.cp-cover-result-item,.cp-cover-preview) { color: var(--theme-text) !important; background: var(--theme-raised) !important; border-color: var(--theme-border) !important; }
