/* ── Tank Designer Styles ─────────────────────────────────────────────────── */
/* Shared list / card / modal / inline-editor / slot-cell rules now live in
   designer-shared.css (dx-* prefix). This file holds only tank-specific
   structure: chassis dropdown, variant picker, top/bottom slot grid, level
   controls, share-card export, tank toast/error, tank publish + dialog. */

#td-resources-row[hidden] {
    display: none !important;
}

/* ── Stat delta carets - make stat-label a positioning context ───────────── */
#tank-right-panel .stat-label {
    position: relative;
}

/* ── Comparison tools section ────────────────────────────────────────────── */
#td-comparison-tools .comparison-dropdown {
    flex: 1;
    min-width: 0;
    position: relative;
}

/* ── Chassis dropdown (legacy) ───────────────────────────────────────────── */
.td-chassis-select {
    width: 100%;
    background: #141414;
    border: 1px solid #2e2e2e;
    color: #e0e0e0;
    padding: 6px 8px;
    font-size: 12px;
    font-family: inherit;
    border-radius: 3px;
    cursor: pointer;
    margin-top: 2px;
}

.td-chassis-select:focus {
    outline: none;
    border-color: #c8a96e;
}

.td-chassis-select option,
.td-chassis-select optgroup {
    background: #1a1a1a;
    color: #e0e0e0;
}

/* ── Variant role picker ─────────────────────────────────────────────────── */
#td-variant-section .custom-dropdown.td-variant-dropdown {
    min-width: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

.td-variant-dropdown .dropdown-header {
    min-width: 0;
}

.td-variant-dropdown .td-variant-dropdown-text {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.td-variant-dropdown .dropdown-option.is-locked {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Top slots (turret, main weapon, 4× special) ─────────────────────────── */
.td-top-slots {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.td-top-slot {
    flex: 1 1 60px;
    min-width: 54px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 8px 4px 6px;
    cursor: pointer;
    min-height: 72px;
}

.td-top-slot.is-disabled {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

/* ── Bottom slots (suspension, armor, engine) ────────────────────────────── */
.td-bottom-section {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    margin-top: 8px;
}

/* Flatten both containers so their children are direct grid items */
.td-bottom-slots,
.td-level-controls-section {
    display: contents;
}

.td-bottom-slot-wrap {
    display: contents;
}

.dx-slot-cell.td-bottom-slot {
    align-items: center;
    justify-content: center;
}

.td-bottom-row-spacer {
    /* empty grid column - no styles needed */
}

.td-level-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #141414;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
    padding: 10px;
    min-height: 80px;
}

.dx-slot-cell.td-bottom-slot.is-disabled {
    opacity: 0.3;
    pointer-events: none;
}

/* Engine/armor level pushed above the research-gated cap - mirror module "missing requirement" amber. */
.td-level-block.is-over-cap {
    position: relative;
    border-color: #d4900a;
}

.td-level-block.is-over-cap > .slot-unlock-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 16px;
    height: 16px;
    z-index: 3;
}

.td-level-block.is-over-cap > .slot-unlock-badge .slot-unlock-badge-icon {
    width: 12px;
    height: 12px;
}

.td-level-block.is-over-cap .td-level-num {
    color: #e8b84b;
}

.td-bottom-slot-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #666;
    text-align: center;
}

/* ── Level step controls ─────────────────────────────────────────────────── */
.td-level-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.td-level-btn {
    background: #1a1a1a;
    border: 1px solid #2e2e2e;
    color: #aaa;
    width: 20px;
    height: 20px;
    border-radius: 2px;
    cursor: pointer;
    font-size: 11px;
    font-family: inherit;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.1s, border-color 0.1s, color 0.1s;
}

.td-level-btn:hover {
    background: #1e2e14;
    border-color: #4a6a3a;
    color: #c8e6a0;
}

.td-level-display {
    font-size: 12px;
    font-weight: 700;
    color: #c8e6a0;
    min-width: 14px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.td-level-display.td-level-display--with-max {
    min-width: 3.5em;
}

/* ── Module slots: mobile - icon strip + compact bottom row (matches division combat density) ── */
@media (max-width: 768px) {
    .td-top-slots {
        display: grid;
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: 4px;
        flex-wrap: unset;
    }

    .td-top-slots .td-top-slot {
        flex: unset;
        min-width: 0;
        min-height: 0;
        padding: 5px 2px 4px;
        gap: 0;
        justify-content: center;
    }

    .td-top-slots .td-top-slot .dx-slot-label {
        display: none;
    }

    .td-top-slots .dx-slot-icon-wrap {
        width: 32px;
        height: 32px;
    }

    .td-top-slots .dx-slot-icon-empty {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .td-top-slots .dx-slot-icon {
        width: 28px;
        height: 28px;
    }

    .td-top-slots .dx-slot-cell.slot-unit-disabled > .slot-unlock-badge {
        top: 2px;
        right: 2px;
        width: 14px;
        height: 14px;
    }

    .td-top-slots .dx-slot-cell.slot-unit-disabled > .slot-unlock-badge .slot-unlock-badge-icon {
        width: 10px;
        height: 10px;
    }

    .td-bottom-section {
        gap: 4px;
        margin-top: 6px;
    }

    /* Inline editor only: bottom row = module slots (½) | armor + engine (½). */
    .td-bottom-section:has(#td-level-controls-section) {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        align-items: stretch;
    }

    .td-bottom-section:has(#td-level-controls-section) > .td-bottom-slots,
    .td-bottom-section:has(#td-level-controls-section) > .td-level-controls-section {
        display: grid;
        min-width: 0;
        gap: 4px;
    }

    .td-bottom-section:has(#td-level-controls-section) > .td-bottom-slots {
        grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    }

    .td-bottom-section:has(#td-level-controls-section) > .td-level-controls-section {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .td-bottom-section:has(#td-level-controls-section) .td-bottom-row-spacer {
        display: none !important;
    }

    .td-bottom-section:not(:has(#td-level-controls-section)) {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    .td-bottom-section .td-bottom-slot .dx-slot-label {
        display: none;
    }

    .td-bottom-section .dx-slot-cell.td-bottom-slot {
        min-height: 0;
        padding: 6px 3px;
        gap: 2px;
        justify-content: center;
    }

    .td-bottom-section .td-bottom-slot .dx-slot-icon-wrap {
        width: 32px;
        height: 32px;
    }

    .td-bottom-section .td-bottom-slot .dx-slot-icon-empty {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .td-bottom-section .td-bottom-slot .dx-slot-icon {
        width: 28px;
        height: 28px;
    }

    .td-bottom-section .td-level-block {
        min-height: 0;
        padding: 6px 5px 7px;
        gap: 4px;
        justify-content: center;
    }

    .td-bottom-section .td-level-block .td-bottom-slot-label {
        font-size: 8px;
        line-height: 1.15;
        letter-spacing: 0.06em;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .td-bottom-section .td-level-max {
        display: none;
    }

    .td-bottom-section .td-level-display--with-max {
        min-width: 0;
    }

    .td-bottom-section .td-level-controls {
        gap: 5px;
    }

    .td-bottom-section .td-level-btn {
        width: 26px;
        height: 26px;
        font-size: 13px;
    }
}

/* ── Mobile inline editor: variant menu must escape overflow:hidden ──────── */
@media (max-width: 768px) {
    #td-step-edit .hoi4-division-header {
        overflow: visible;
        position: relative;
        z-index: 45;
    }

    #td-step-edit #td-variant-section {
        position: relative;
        z-index: 46;
    }

    #td-step-edit #td-variant-section .custom-dropdown.td-variant-dropdown,
    #td-step-edit #td-variant-section .dropdown-menu {
        z-index: 1050;
    }
}

/* ── Editor header - variant flex ratio + saved-card mirror ──────────────── */

.td-inline-share-card-slot {
    margin-bottom: 10px;
}

.td-inline-share-saved-card-mirror.dx-saved-design-card {
    cursor: default;
    pointer-events: none;
}

.td-inline-share-saved-card-mirror .dx-design-warning-badge {
    pointer-events: auto;
    cursor: help;
}

/* Share load: list anchor only for layout/stacks; saved-style card lives in #td-inline-share-card-slot */
#td-chassis-selection.is-editing .dx-build-card.td-share-anchor-chassis {
    display: none !important;
}

/* Name ~⅔, variant ~⅓ (flex grow 2 : 1) */
.td-editor-header .td-name-wrap {
    flex: 2 1 0;
    min-width: 0;
}

.td-editor-header #td-variant-section {
    flex: 1 1 0;
    min-width: 0;
}

.td-editor-header #td-variant-section .td-variant-dropdown {
    width: 100%;
}

/* Save + Share (right); delete is a sibling before the name field */
.td-editor-header > .dx-delete-design-btn {
    flex: 0 0 auto;
}

.td-editor-header .td-editor-header-actions #td-save-btn {
    flex: 1 1 0;
    min-width: 0;
}

.td-editor-header .td-editor-header-actions .pub-split {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.td-editor-header .td-editor-header-actions .pub-split-btn,
.td-editor-header .td-editor-header-actions #td-save-btn {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

/* Standalone /tank-designer edit step: name + variant row, then load, then save/publish */
.td-tank-name-variant-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.td-tank-name-variant-row .td-name-wrap,
.td-tank-name-variant-row .division-name-input {
    flex: 2 1 0;
    min-width: 0;
}

.td-tank-name-variant-row #td-variant-section {
    flex: 1 1 0;
    min-width: 0;
}

.td-tank-name-variant-row #td-variant-section:empty {
    display: none;
}

.td-tank-load-row .saved-templates-section {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
}

@media (max-width: 768px) {
    /*
     * style.css gives .division-name-input { order: 1 } on mobile; reset so name stays
     * before the variant dropdown in the name + variant row.
     */
    #td-step-edit .td-tank-name-variant-row .division-name-input {
        order: 0;
    }

    #td-step-edit .td-tank-name-variant-row #td-variant-section {
        order: 1;
    }

    #td-step-edit .td-tank-name-variant-row {
        flex-wrap: nowrap;
        gap: 8px;
    }

    #td-step-edit .td-tank-load-row .saved-templates-section {
        order: 0;
        width: 100%;
    }
}

/*
 * Default .pub-split-menu opens to the right of the button (style.css).
 * Tank inline editor uses overflow:hidden for open/close animation - a right-opening
 * menu is clipped. Open downward and anchor to the Share button's right edge.
 */
.td-editor-header .pub-split-menu {
    left: auto;
    right: 0;
    top: calc(100% + 4px);
    z-index: 1200;
}

/* ── Shared designer dialog shell (.hoi4-dialog) ─────────────────────────────
   Unified ks-style window chrome: every modal that uses hoi4_dialog_frame gets
   the same overlay, panel, header & heading. Compact/danger modifiers tweak
   just the dimensions or border color. */
.hoi4-dialog-overlay {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
}

.td-delete-design-modal-overlay {
    z-index: 1100;
}

.dd-risk-confirm-modal-overlay {
    z-index: 10050;
}

.hoi4-dialog {
    width: 92%;
    max-width: 460px;
    background: #1a1a1a;
    border: 1px solid #2e2e2e;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.hoi4-dialog--compact {
    max-width: 400px;
}

.hoi4-dialog--danger {
    border-color: rgba(180, 80, 80, 0.5);
}

.dx-modal-header.hoi4-dialog-header {
    padding: 0.85rem 1rem;
    background: linear-gradient(180deg, rgba(200, 169, 110, 0.06) 0%, transparent 100%);
    border-bottom-color: #262626;
}

.hoi4-dialog--danger .hoi4-dialog-header {
    background: linear-gradient(180deg, rgba(180, 80, 80, 0.08) 0%, transparent 100%);
}

.hoi4-dialog-heading {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: #ebebeb;
    margin: 0;
    line-height: 1.35;
}

.hoi4-dialog-body {
    padding: 20px 22px 18px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    text-align: left;
    gap: 14px;
}

.hoi4-dialog-body--auth {
    padding-top: 22px;
    padding-bottom: 24px;
}

.hoi4-dialog-body--confirm {
    gap: 10px;
}

.hoi4-dialog-kicker {
    display: inline-flex;
    align-items: center;
    align-self: center;
    gap: 8px;
    margin: 0;
    padding: 7px 14px 7px 11px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #d4c4a4;
    border: 1px solid rgba(200, 169, 110, 0.35);
    border-radius: 999px;
    background: rgba(200, 169, 110, 0.08);
}

.hoi4-dialog-kicker-icon {
    flex-shrink: 0;
    color: #c8a96e;
    opacity: 0.95;
}

.hoi4-dialog-sub {
    font-size: 13px;
    color: #9a9a94;
    margin: 0;
    line-height: 1.55;
}

.hoi4-dialog-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 6px;
    width: 100%;
    max-width: 100%;
}

.hoi4-dialog-cta {
    justify-content: center;
    text-decoration: none;
    text-align: center;
    box-sizing: border-box;
}

.hoi4-dialog-cta--primary {
    width: 100%;
    padding-top: 10px;
    padding-bottom: 10px;
    font-weight: 600;
}

.hoi4-dialog-cta--secondary {
    width: 100%;
    background: transparent;
    border: 1px solid #4a4a46;
    color: #c8c8c2;
    padding-top: 9px;
    padding-bottom: 9px;
}

.hoi4-dialog-cta--secondary:hover {
    border-color: #6a6a62;
    color: #ececec;
    background: rgba(255, 255, 255, 0.04);
}

@media (min-width: 420px) {
    .hoi4-dialog-actions {
        max-width: 280px;
        align-self: center;
    }
}

.hoi4-dialog-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    border-top: 1px solid #3d3d3d;
    background: #1a1a1a;
    flex-shrink: 0;
}

.td-delete-design-modal-message,
#td-delete-design-modal-message,
#dd-risk-confirm-message {
    margin: 0 0 10px;
    font-size: 14px;
    color: #d0d0d0;
    line-height: 1.45;
}

.td-delete-design-modal-warning,
#dd-risk-confirm-warning {
    margin: 0;
    font-size: 12px;
    color: #888;
}

/* ── Chassis picker (legacy – kept for unused CSS cleanup later) ──────────── */
.td-chassis-picker {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.td-chassis-btn {
    background: #141414;
    border: 1px solid #2e2e2e;
    border-radius: 3px;
    color: #bbb;
    cursor: pointer;
    padding: 5px 7px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 42px;
    transition: border-color 0.15s, background 0.15s;
    font-family: inherit;
}

.td-chassis-btn:hover {
    background: #1e1e1e;
    border-color: #3d3d3d;
    color: #e0e0e0;
}

.td-chassis-btn.is-active {
    background: #1e2e14;
    border-color: #5a8a3a;
    color: #c8e6a0;
}

.td-chassis-abbr {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.td-chassis-year {
    font-size: 9px;
    color: #666;
    margin-top: 1px;
}

.td-chassis-btn.is-active .td-chassis-year {
    color: #7aaa50;
}

.td-chassis-info-inline {
    font-size: 11px;
    color: #888;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-left: 8px;
}

.td-chassis-name {
    font-weight: 700;
    color: #c8e6a0;
    font-size: 12px;
}

.td-chassis-year-tag {
    color: #666;
}

.td-chassis-dlc {
    font-size: 10px;
    color: #555;
    font-style: italic;
}

.td-chassis-desc {
    color: #777;
    font-size: 10px;
    line-height: 1.4;
    margin-top: 2px;
}

/* ── Slot grid (3-col module-pick layout used elsewhere) ─────────────────── */
.td-slot-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

@media (max-width: 600px) {
    .td-slot-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Tank-only slot details (empty state, optional flag, module name) */
.td-slot-optional {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: #444;
}

.td-slot-module {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.td-slot-module.is-empty {
    border: 1px dashed #2e2e2e;
    border-radius: 3px;
    padding: 8px;
}

.td-slot-empty-icon {
    font-size: 18px;
    color: #333;
    line-height: 1;
}

.td-slot-empty-label {
    font-size: 10px;
    color: #444;
}

.td-slot-icon-placeholder {
    width: 36px;
    height: 36px;
    background: #2a2a2a;
    border-radius: 3px;
}

.td-slot-module-name {
    font-size: 10px;
    color: #c0c0c0;
    text-align: center;
    line-height: 1.3;
}

/* ── Module picker modal - tank-specific extras over dx- shell ───────────── */
#td-picker-remove-action {
    padding: 1rem 15px 1.2rem;
    border-bottom: 1px solid #3a3a3a;
}

#td-picker-remove-action[hidden] {
    display: none !important;
}

.td-remove-module-card {
    background: #1e1010 !important;
    border-color: #4a2020 !important;
    color: #c07070 !important;
}

.td-remove-module-card:hover {
    background: #2a1414 !important;
    border-color: #7a3030 !important;
    color: #e08080 !important;
}

.td-remove-module-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    opacity: 0.7;
}

.td-remove-module-card:hover .td-remove-module-icon {
    opacity: 1;
}

.td-resource-icons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    justify-content: flex-end;
}

.td-resource-item {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
}

.td-resource-item .resource-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
}

.td-equip-badge {
    font-size: 8px;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 1px 4px;
    border-radius: 3px;
    background: rgba(210, 140, 40, 0.1);
    color: #d4900a;
    border: 1px solid rgba(210, 140, 40, 0.3);
    white-space: nowrap;
}

/* ── Load dropdown items ─────────────────────────────────────────────────── */
.td-dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    cursor: pointer;
}

.td-dropdown-item:hover {
    background: #222;
}

.td-dropdown-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.td-dropdown-item-name {
    font-size: 11px;
    font-weight: 600;
    color: #c0c0c0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.td-dropdown-item-chassis {
    font-size: 10px;
    color: #666;
}

.td-dropdown-delete-btn {
    background: none;
    border: none;
    color: #555;
    cursor: pointer;
    font-size: 11px;
    padding: 2px 5px;
    border-radius: 2px;
    flex-shrink: 0;
    font-family: inherit;
    line-height: 1;
    transition: color 0.1s, background 0.1s;
}

.td-dropdown-delete-btn:hover {
    color: #e07070;
    background: #2e1414;
}

.td-dropdown-empty {
    color: #555;
    font-style: italic;
    cursor: default;
}

.td-dropdown-empty:hover {
    background: transparent;
}

/* ── Publish modal (extends dx-modal) ────────────────────────────────────── */
.td-publish-modal {
    max-width: 480px;
}

/* ── Error banner ────────────────────────────────────────────────────────── */
.td-error-banner {
    background: #2e1414;
    border: 1px solid #6a3a3a;
    color: #e07070;
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 12px;
    margin-bottom: 12px;
}

/* ── Toast fallback ──────────────────────────────────────────────────────── */
.td-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    background: #1e2e14;
    border: 1px solid #4a6a3a;
    color: #c8e6a0;
    padding: 9px 18px;
    border-radius: 4px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 9999;
    white-space: nowrap;
}

.td-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.td-toast--stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    max-width: min(340px, calc(100vw - 32px));
    white-space: normal;
    text-align: center;
    padding: 12px 18px 14px;
    line-height: 1.4;
}

.td-toast-title {
    font-weight: 600;
    font-size: 14px;
}

.td-toast-detail {
    font-size: 12px;
    font-weight: 400;
    opacity: 0.88;
    line-height: 1.45;
}

.td-toast-success {
    background: linear-gradient(180deg, #243018 0%, #1a2614 100%);
    border: 1px solid rgba(160, 112, 56, 0.55);
    color: #dde8c8;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.td-toast-error {
    background: #2e1414;
    border-color: #6a3a3a;
    color: #e07070;
}

@media (max-width: 768px) {
    /*
     * Inline tank editor: row 1 = name + variant; row 2 = flex row (trash + Save + Share).
     * Delete is a header sibling (left of name on desktop); when visible it sits in column 1 on row 2.
     */
    .dx-inline-editor-inner .td-editor-header {
        display: grid;
        grid-template-columns: repeat(6, minmax(0, 1fr));
        column-gap: 8px;
        row-gap: 8px;
        align-items: stretch;
        overflow: visible;
        position: relative;
        z-index: 45;
        grid-template-areas:
            "name name name name variant variant"
            "actions actions actions actions actions actions";
    }

    .dx-inline-editor-inner .td-editor-header:not(:has(#td-delete-design-btn[hidden])) {
        grid-template-areas:
            "name name name name variant variant"
            "del act act act act act";
    }

    .dx-inline-editor-inner .td-editor-header:not(:has(#td-delete-design-btn[hidden])) .dx-delete-design-btn {
        grid-area: del;
    }

    .dx-inline-editor-inner .td-editor-header:not(:has(#td-delete-design-btn[hidden])) .td-editor-header-actions {
        grid-area: act;
    }

    .dx-inline-editor-inner .td-name-wrap {
        grid-area: name;
        min-width: 0;
    }

    .dx-inline-editor-inner #td-variant-section {
        grid-area: variant;
        min-width: 0;
        position: relative;
        z-index: 46;
    }

    .dx-inline-editor-inner #td-variant-section .td-variant-dropdown {
        width: 100%;
    }

    .dx-inline-editor-inner #td-variant-section .custom-dropdown.td-variant-dropdown,
    .dx-inline-editor-inner #td-variant-section .dropdown-menu {
        z-index: 1050;
    }

    .dx-inline-editor-inner .td-editor-header-actions {
        grid-area: actions;
        display: flex;
        align-items: stretch;
        gap: 8px;
        min-width: 0;
        margin-left: 0;
        margin-inline-start: 0;
        justify-self: stretch;
        width: 100%;
    }

    .dx-inline-editor-inner .td-editor-header-actions #td-save-btn {
        flex: 1 1 0;
        min-width: 0;
        width: auto;
    }

    .dx-inline-editor-inner .td-editor-header-actions .pub-split {
        flex: 1 1 0;
        min-width: 0;
        width: auto;
    }

    .dx-inline-editor-inner .td-editor-header-actions .pub-split-btn {
        width: 100%;
    }
}

/* ── Share card (in-page + PNG export) ───────────────────────────────────── */
.td-share-card {
    background: #181818;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
    font-family: 'Inter', system-ui, sans-serif;
    color: #d8d8d8;
    width: 100%;
    max-width: 860px;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

.td-share-card.td-share-card--png-export {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
    box-sizing: border-box;
    overflow: hidden;
}

.td-share-card-header {
    padding: 0.7rem 1.1rem;
    background: #141414;
    border-bottom: 1px solid #242424;
}

.td-share-card-header-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.td-share-card-header-row .dt-header-badges {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: auto;
    flex-shrink: 0;
}

.td-share-card .dt-header-load-link {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.22rem 0.55rem;
    min-height: 1.55rem;
    border-radius: 3px;
    white-space: nowrap;
    background: rgba(200, 169, 110, 0.1);
    border: 1px solid rgba(200, 169, 110, 0.25);
    color: #c8a96e;
    text-decoration: none;
    letter-spacing: 0.02em;
}

.td-share-card .dt-header-load-link:hover:not(:disabled) {
    background: rgba(200, 169, 110, 0.2);
    color: #d9be8a;
}

.td-share-card .dt-header-library-link {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.22rem 0.55rem;
    min-height: 1.55rem;
    border-radius: 3px;
    white-space: nowrap;
    text-decoration: none;
    letter-spacing: 0.02em;
    background: rgba(72, 118, 160, 0.22);
    border: 1px solid rgba(100, 150, 195, 0.42);
    color: #9ec8ea;
}

.td-share-card .dt-header-library-link:hover:not(:disabled) {
    background: rgba(88, 135, 180, 0.32);
    border-color: rgba(120, 170, 210, 0.5);
    color: #c4e2fc;
}

.td-share-card-title {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    font-size: 0.85rem;
    color: #c8c8c8;
    letter-spacing: -0.01em;
}

.td-share-card-body {
    display: flex;
    gap: 1rem;
    padding: 0.85rem 1rem 1rem;
    align-items: center;
}

.td-share-card-modules {
    flex: 0 0 280px;
    min-width: 0;
}

/* Air cards have a 5-cell armament row above a 7-cell equipment row. Keep the
   same cell size across both rows and let the shorter row sit left-aligned. */
.td-share-card.air-card .td-share-card-modules {
    flex-basis: calc(280px * 7 / 6);
    max-width: 100%;
}

.td-share-card-modules-title {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #8a8278;
    margin-bottom: 0.45rem;
    line-height: 1.3;
}

.td-share-card-slot-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.td-share-card-top-row {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 5px;
    align-items: stretch;
}

.td-share-card-slot-cell {
    aspect-ratio: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 2px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid #1e1e1e;
    box-sizing: border-box;
    overflow: hidden;
}

.td-share-card-slot-cell:not(.is-placeholder) {
    background: #191e1d;
    border-color: #252e2c;
}

.td-share-card-slot-cell.is-placeholder {
    opacity: 0.32;
    pointer-events: none;
}

.td-share-card-slot-cell img {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

.td-share-card-slot-lock {
    font-size: 6px;
    line-height: 1;
    opacity: 0.2;
    user-select: none;
}

.td-share-card-bottom-wrap {
    margin-top: 2px;
}

.td-share-card-bottom-row {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 5px;
    align-items: stretch;
}

.td-share-card-bottom-spacer {
    min-height: 1px;
}

.td-share-card-level-cell {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    box-sizing: border-box;
    border-radius: 2px;
    background: #191e1d;
    border: 1px solid #252e2c;
    padding: 0.2rem 0.15rem;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    font-family: 'Roboto Mono', 'Courier New', monospace;
}

.td-share-card-level-label {
    font-size: 0.45rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: #5a7a56;
    text-transform: uppercase;
}

.td-share-card-level-value {
    font-size: 0.8rem;
    font-weight: 700;
    color: #9eb89a;
}

.td-share-card-stats {
    flex: 1;
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem 0.75rem;
}

.td-share-card-stat-block-title {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #5a5248;
    margin-bottom: 0.2rem;
}

.td-share-card-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.68rem;
    padding: 0.08rem 0;
}

.td-share-card-stat-label {
    color: #7a7a7a;
}

.td-share-card-stat-value {
    font-family: 'Roboto Mono', 'Courier New', monospace;
    color: #c8c8c8;
    font-weight: 500;
}

.td-share-card-res-item {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    color: #a8a8a8;
}

.td-share-card-res-item img {
    width: 16px;
    height: 16px;
    object-fit: contain;
}

.td-share-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: #141414;
    border-top: 1px solid #242424;
}

.td-share-card-footer-resources {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.55rem;
    align-items: center;
    min-width: 0;
    font-family: 'Roboto Mono', 'Courier New', monospace;
    font-size: 0.75rem;
    font-weight: 600;
}

.td-share-card-footer-cost,
.td-share-card-footer-dominance {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-family: 'Roboto Mono', 'Courier New', monospace;
    font-size: 0.75rem;
    font-weight: 600;
    color: #c8c8c8;
}

.td-share-card-footer-cost-badge {
    width: 16px;
    height: 16px;
}

.td-share-card-footer-cost-badge.dx-dominance-badge {
    background: rgba(52, 148, 124, 0.22);
    border: 1px solid rgba(52, 148, 124, 0.5);
}

.td-share-card-footer-cost-badge .dx-ic-icon {
    width: 10px;
    height: 10px;
}

@media (max-width: 1024px) {
    .td-share-card:not(.td-share-card--png-export) .td-share-card-body {
        flex-direction: column;
        align-items: stretch;
    }

    .td-share-card:not(.td-share-card--png-export) .td-share-card-modules {
        flex: none;
        width: 100%;
    }

    .td-share-card:not(.td-share-card--png-export) .td-share-card-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .td-share-card:not(.td-share-card--png-export) .td-share-card-stats .td-share-card-stat-block:last-child {
        grid-column: 1 / -1;
    }

    .td-share-card:not(.td-share-card--png-export) .td-share-card-bottom-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-left: -0.15rem;
        margin-right: -0.15rem;
        padding-left: 0.15rem;
        padding-right: 0.15rem;
    }

    .td-share-card:not(.td-share-card--png-export) .td-share-card-bottom-row {
        min-width: 320px;
    }

    .td-share-card:not(.td-share-card--png-export) .td-share-card-footer {
        flex-wrap: wrap;
        row-gap: 0.5rem;
    }

    .td-share-card:not(.td-share-card--png-export) .td-share-card-footer-resources {
        flex: 1 1 auto;
        min-width: 0;
    }
}

@media (max-width: 420px) {
    .td-share-card:not(.td-share-card--png-export) .td-share-card-stat-block-title {
        font-size: 0.55rem;
    }

    .td-share-card:not(.td-share-card--png-export) .td-share-card-stat-row {
        font-size: 0.62rem;
    }

    .td-share-card:not(.td-share-card--png-export) .td-share-card-footer {
        flex-wrap: wrap;
        align-items: center;
    }

    .td-share-card:not(.td-share-card--png-export) .td-share-card-footer-cost {
        margin-left: auto;
    }

    .td-share-card:not(.td-share-card--png-export) .td-share-card-footer-dominance {
        margin-left: 0;
    }
}

/* ── Pro picker sort (shared by tank/ship/division pickers) ─────────────── */

/* Make the search bar a flex row so the sort control can sit inline with
   the input. The .modal-search version covers the division picker. */
.dx-picker-search-bar,
.modal-search {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dx-picker-search-bar .dx-picker-search,
.modal-search > input {
    flex: 1;
    min-width: 0;
}

/* Sort control: compact inline group with a clear PRO marker but a neutral
   resting state so it integrates with the search bar. Magenta accents come
   in on focus, active state (a stat is being sorted), and the PRO pill. */
.pro-picker-sort {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    padding: 3px 4px 3px 4px;
    border: 1px solid rgba(210, 90, 195, 0.18);
    border-radius: 4px;
    background: rgba(210, 90, 195, 0.025);
    transition: border-color 0.15s ease, background 0.15s ease;
}

.pro-picker-sort:hover,
.pro-picker-sort:focus-within {
    border-color: rgba(210, 90, 195, 0.4);
    background: rgba(210, 90, 195, 0.05);
}

.pro-picker-sort.is-active {
    border-color: rgba(210, 90, 195, 0.55);
    background: rgba(210, 90, 195, 0.06);
    box-shadow: 0 0 0 1px rgba(210, 90, 195, 0.15);
}

/* PRO pill — always visible for Pro users; marks this as a Pro feature */
.pro-picker-sort-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.14em;
    line-height: 1;
    padding: 3px 5px;
    border-radius: 2px;
    color: #f2cae8;
    background: linear-gradient(145deg, #3c1640 0%, #62205a 100%);
    border: 1px solid rgba(210, 90, 195, 0.5);
    text-shadow: 0 1px 0 rgba(20, 4, 12, 0.85);
    flex-shrink: 0;
}

.pro-picker-sort-glyph {
    color: #888;
    flex-shrink: 0;
    margin-left: 1px;
}

.is-active .pro-picker-sort-glyph {
    color: #e6b3cf;
}

.pro-picker-sort-select {
    background: transparent;
    color: #d0d0d0;
    border: none;
    border-radius: 3px;
    padding: 4px 6px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    max-width: 170px;
    outline: none;
}

/* Dropdown popup (rendered by the browser) - dark-theme styling for the
   expanded list and the optgroup headers. */
.pro-picker-sort-select optgroup {
    background: #1c1c1c;
    color: #c8a96e;
    font-style: normal;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 11px;
}

.pro-picker-sort-select option {
    background: #1c1c1c;
    color: #d8d8d8;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
}

.pro-picker-sort-select:hover {
    color: #fff;
}

.is-active .pro-picker-sort-select {
    color: #f2cae8;
    font-weight: 600;
}

.pro-picker-sort-dir {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    background: transparent;
    border: 1px solid #3d3d3d;
    color: #888;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    padding: 0;
    line-height: 1;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.pro-picker-sort-dir:hover {
    color: #e6b3cf;
    border-color: rgba(210, 90, 195, 0.45);
    background: rgba(210, 90, 195, 0.08);
}

.is-active .pro-picker-sort-dir {
    color: #e6b3cf;
    border-color: rgba(210, 90, 195, 0.45);
}

/* Brief loading dim while the division picker fetches stats from the backend */
.pro-picker-sort--loading {
    opacity: 0.55;
    pointer-events: none;
}

/* Per-card stat bubble - shows the value being sorted on, top-right of the
   card. Same magenta brand as the PRO badge so it reads as part of the same
   Pro feature. Card needs position: relative; .modal-option and
   .dx-module-card both already establish one via their layout. */
.modal-option,
.dx-module-card {
    position: relative;
}

.pro-picker-sort-stat-bubble {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 18px;
    padding: 0 5px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.02em;
    border-radius: 3px;
    color: #f2cae8;
    background: linear-gradient(145deg, #3c1640 0%, #62205a 100%);
    border: 1px solid rgba(210, 90, 195, 0.55);
    text-shadow: 0 1px 0 rgba(20, 4, 12, 0.85);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

/* Negative deltas (e.g., the candidate hurts the chosen stat) get a desaturated
   look so they're visually obvious as "bad". */
.pro-picker-sort-stat-bubble--negative {
    background: linear-gradient(145deg, #2a1119 0%, #3d1726 100%);
    border-color: rgba(180, 90, 120, 0.4);
    color: #c89aaa;
}

/* Zero or no-effect deltas - dimmer, signals "doesn't move the needle" */
.pro-picker-sort-stat-bubble--zero,
.pro-picker-sort-stat-bubble--missing {
    background: rgba(210, 90, 195, 0.08);
    border-color: rgba(210, 90, 195, 0.25);
    color: #b89aa3;
    text-shadow: none;
    box-shadow: none;
}

/* Locked state for non-Pro users - shaped like the upgrade prompt itself
   so it reads as "click here to unlock", with the PRO pill leading. */
.pro-picker-sort--locked {
    background: transparent;
    border: none;
    padding: 0;
}

.pro-picker-sort-locked-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 7px 3px 4px;
    text-decoration: none;
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
    border: 1px solid rgba(210, 90, 195, 0.25);
    border-radius: 4px;
    background: rgba(210, 90, 195, 0.04);
    color: #b89aa3;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.pro-picker-sort-locked-link:hover {
    border-color: rgba(210, 90, 195, 0.5);
    background: rgba(210, 90, 195, 0.1);
    color: #f2cae8;
}

.pro-picker-sort-badge--locked {
    color: #e6b3cf;
    background: rgba(210, 90, 195, 0.12);
    border: 1px solid rgba(210, 90, 195, 0.4);
    text-shadow: none;
}

.pro-picker-sort-locked-link:hover .pro-picker-sort-badge--locked {
    background: linear-gradient(145deg, #3c1640 0%, #62205a 100%);
    color: #f2cae8;
    border-color: rgba(210, 90, 195, 0.6);
}

.pro-picker-sort-locked-label {
    font-size: 12px;
    white-space: nowrap;
}

/* Pro sort upgrade modal ----------------------------------------------------
   Window chrome inherits from the unified .hoi4-dialog base above. */

.pro-sort-upgrade-modal-overlay {
    z-index: 1100;
}

/* .psup-* preview component + .psup-title-pro inline chip moved to style.css
   so /pro (which doesn't load tank-designer.css) can use them too.
   The body layout for this specific modal stays here: */

.pro-sort-upgrade-dialog-body {
    padding: 0.9rem 1rem 1.1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
    text-align: center;
}

.pro-sort-upgrade-dialog-body .hoi4-dialog-actions {
    margin-top: 0.2rem;
}

@media (max-width: 480px) {
    .dx-picker-search-bar,
    .modal-search {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        gap: 6px;
    }
    .modal-search input {
        flex: 1;
        min-width: 0;
    }
    .pro-picker-sort {
        flex-shrink: 0;
        gap: 3px;
        padding: 2px 3px;
    }
    .pro-picker-sort-badge {
        font-size: 8px;
        padding: 2px 4px;
    }
    .pro-picker-sort-select {
        max-width: 120px;
        font-size: 10px;
        padding: 3px 4px;
        text-align: left;
        text-align-last: left;
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
    }
    .pro-picker-sort-dir {
        width: 18px;
        height: 18px;
        font-size: 11px;
    }
}
