/* ── Tank Designer Styles ─────────────────────────────────────────────────── */

#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 ────────────────────────────────────────────────────── */
.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 ──────────────────────────────────────────────────── */
/* Override global .custom-dropdown { min-width: 180px } so the ⅓ column does not overflow */
#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;
}

.td-slot-icon-wrap {
    position: relative;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Grey: same opacity + grayscale as division in style.css (.td-slot-cell.slot-unit-disabled).
   Badge: corner of the slot card (slot-unlock-badge), not the centered icon area. */

.td-slot-cell.slot-unit-disabled {
    border-color: #d4900a !important;
}

.td-slot-cell.slot-unit-disabled > .slot-unlock-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 16px;
    height: 16px;
    z-index: 3;
}

.td-slot-cell.slot-unit-disabled > .slot-unlock-badge .slot-unlock-badge-icon {
    width: 12px;
    height: 12px;
}

.td-slot-icon-empty {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8a8a8a;
    font-size: 16px;
}

.td-slot-cell:hover .td-slot-icon-empty {
    color: #aaa;
}

/* ── 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;
}

/* Bottom slot cells sit directly in the grid */
.td-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;
}

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


.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 .td-slot-label {
        display: none;
    }

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

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

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

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

    .td-top-slots .td-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 (½). Spacers hidden — they only pad the desktop 6-col grid. */
    .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 .td-slot-label {
        display: none;
    }

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

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

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

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

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

    /* Keep armor vs engine identifiable; stay compact next to the level digit */
    .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;
    }
}

/* ── Tank list header: toggles hide while editing; Back appears in same slot ── */
.td-chassis-header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-left: auto;
    flex-shrink: 0;
}

/* Stacked slot so toggles and Back share one horizontal space (no empty gap while editing). */
.td-chassis-header-actions {
    position: relative;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    min-height: 28px;
}

.td-chassis-toggles {
    display: flex;
    align-items: center;
    gap: 20px;
    transition:
        opacity 0.28s ease,
        visibility 0.28s ease;
    opacity: 1;
    visibility: visible;
}

@media (max-width: 768px) {
    /* List header: one row; mobile hides “Show ” in markup (see .td-chassis-toggle-muted) — no smaller type. */
    #tank-left-panel .hoi4-section:has(#td-chassis-selection) > .section-header {
        flex-wrap: nowrap;
        min-width: 0;
    }

    #tank-left-panel .hoi4-section:has(#td-chassis-selection) > .section-header .td-chassis-header-right {
        margin-left: auto;
        flex-shrink: 1;
        min-width: 0;
    }

    #tank-left-panel .hoi4-section:has(#td-chassis-selection) .td-chassis-header-actions {
        justify-content: flex-end;
        min-width: 0;
    }

    #tank-left-panel .hoi4-section:has(#td-chassis-selection) .td-chassis-toggles {
        flex-wrap: nowrap;
        min-width: 0;
    }

    #tank-left-panel .hoi4-section:has(#td-chassis-selection) .td-chassis-toggles .comparison-filter-label {
        min-width: 0;
    }

    #tank-left-panel .hoi4-section:has(#td-chassis-selection) .td-chassis-toggles .td-chassis-toggle-muted {
        display: none;
    }

    #tank-left-panel .hoi4-section:has(#td-chassis-selection) .td-chassis-toggles .comparison-toggle-label {
        white-space: nowrap;
    }
}

#tank-left-panel .td-chassis-header-right #td-back-btn {
    display: none;
}

#tank-left-panel:has(#td-chassis-selection.is-editing) .td-chassis-toggles {
    position: absolute;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#tank-left-panel:has(#td-chassis-selection.is-editing) .td-chassis-header-right #td-back-btn {
    display: inline-flex;
}

/* Prominent “exit editor” control in Tank Designs header (gold accent; not ghost link). */
.td-chassis-header-back.td-back-btn {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 7px 14px;
    gap: 6px;
    color: #ebebeb;
    border-color: rgba(200, 169, 110, 0.55);
    background: rgba(200, 169, 110, 0.12);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

.td-chassis-header-back.td-back-btn:hover {
    color: #f2f2f2;
    border-color: #c8a96e;
    background: rgba(200, 169, 110, 0.22);
}

.td-chassis-header-back.td-back-btn:focus-visible {
    outline: 2px solid rgba(200, 169, 110, 0.65);
    outline-offset: 2px;
}

/* ── Inline editor — list ↔ module edit transitions ───────────────────── */
#td-inline-editor {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    margin-top: 4px;
    overflow: hidden;
    /* Flex child of .td-chassis-family-body: default min-width:auto can freeze a too-wide
       intrinsic width on first paint (Chrome), especially while grid-template-rows animates. */
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    transition:
        grid-template-rows 0.42s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.32s ease;
    will-change: grid-template-rows, opacity;
}

#td-inline-editor.is-open {
    grid-template-rows: 1fr;
    opacity: 1;
    /* Above .td-card-stack nodes inserted after the editor (“N designs” collapsed strips) */
    position: relative;
    z-index: 500;
}

#td-inline-editor:not(.is-open) {
    will-change: auto;
}

/* Mirror of list saved-design card (shared link loads) — same classes + is-active */
.td-inline-share-card-slot {
    margin-bottom: 10px;
}

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

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

.td-inline-editor-inner {
    overflow: hidden;
    min-height: 0;
    min-width: 0;
    box-sizing: border-box;
    border: 1px solid #2a2a2a;
    border-radius: 3px;
    background: #161616;
    padding: 10px;
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.28);
    transform: translateY(14px);
    opacity: 0.85;
    transition:
        transform 0.42s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.34s ease,
        box-shadow 0.42s ease,
        border-color 0.25s ease;
}

#td-inline-editor.is-open .td-inline-editor-inner {
    transform: translateY(0);
    opacity: 1;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.42);
    border-color: #333;
}

/*
 * Mobile: inline editor uses overflow:hidden for height animation; that clips absolutely
 * positioned dropdown menus. Allow overflow while open so variant (and other) menus show fully.
 * Standalone: keep the name/variant header above sticky module sections when the menu is open.
 */
@media (max-width: 768px) {
    #td-inline-editor.is-open {
        overflow: visible;
    }

    #td-inline-editor.is-open .td-inline-editor-inner {
        overflow: visible;
    }

    #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;
    }
}

@media (prefers-reduced-motion: reduce) {
    #td-inline-editor,
    #td-inline-editor .td-inline-editor-inner,
    .td-chassis-toggles {
        transition-duration: 0.01ms !important;
        transition-delay: 0s !important;
    }

    #td-inline-editor .td-inline-editor-inner {
        transform: none !important;
        opacity: 1 !important;
    }

    .td-card-stack {
        animation: none !important;
    }
}


/* ── Editing mode ────────────────────────────────────────────────────────── */

/* Hide stacked cards and non-active families */
.td-chassis-card.is-stacked,
.td-saved-design-card.is-stacked {
    display: none;
}

/* Hide other families only when an active family exists (from _applyEditingStacks); no anchor → rule does not match */
#td-chassis-selection.is-editing:has(.td-chassis-family.has-active-card) .td-chassis-family:not(.has-active-card) {
    display: none;
}

/* Active card highlight — eased in with editor open */
.td-chassis-card.is-active,
.td-saved-design-card.is-active {
    filter: brightness(1.28);
    border-color: #4a8a4a;
    box-shadow: 0 0 0 1px rgba(74, 138, 74, 0.28);
    position: relative;
    z-index: 1;
}

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

@keyframes td-card-stack-enter {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stack indicator blocks */
.td-card-stack {
    height: 30px;
    background: #161616;
    border: 1px solid #2a2a2a;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #444;
    font-size: 10px;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    user-select: none;
    animation: td-card-stack-enter 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
    position: relative;
    z-index: 1;
}

.td-card-stack:hover {
    color: #888;
    border-color: #3d3d3d;
}

/* Above stack: shadow layers peek downward */
.td-card-stack--above {
    box-shadow:
        0 4px 0 -1px #111,
        0 4px 0 0   #222,
        0 8px 0 -1px #0e0e0e,
        0 8px 0 0   #1e1e1e;
    margin-bottom: 10px;
}

/* Below stack: shadow layers peek upward */
.td-card-stack--below {
    box-shadow:
        0 -4px 0 -1px #111,
        0 -4px 0 0   #222,
        0 -8px 0 -1px #0e0e0e,
        0 -8px 0 0   #1e1e1e;
    margin-top: 10px;
}

/* ── Chassis selection (step 1) ──────────────────────────────────────────── */
#td-chassis-selection:not(.show-outdated) .td-chassis-card.is-outdated {
    display: none;
}

#td-chassis-selection:not(.show-outdated) .td-chassis-family:not(:has(.td-chassis-card:not(.is-outdated))) {
    display: none;
}

#td-chassis-selection:not(.show-invalid) .td-saved-design-card.is-invalid {
    display: none;
}
.td-chassis-selection {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.td-chassis-family {
    display: flex;
    flex-direction: column;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
    overflow: hidden;
}

.td-chassis-family-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #1c1c1c;
    border-bottom: 1px solid #2a2a2a;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.td-chassis-family-header:hover {
    background: #222;
}

.td-chassis-family-chevron {
    color: #666;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.td-chassis-family.is-collapsed .td-chassis-family-chevron {
    transform: rotate(-90deg);
}

.td-chassis-family-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    background: #161616;
}

.td-chassis-family.is-collapsed .td-chassis-family-body {
    display: none;
}

.td-chassis-variants {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* Default blueprint chassis — light grey tint */
.td-chassis-card:not(.td-saved-design-card) {
    background: #1c1c1e;
    border-color: #2e2e32;
}

.td-chassis-card {
    position: relative;
    background: #141414;
    border: 1px solid #222;
    border-radius: 3px;
    color: #bbb;
    padding: 0;
    display: flex;
    align-items: center;
    width: 100%;
    font-family: inherit;
    transition:
        border-color 0.2s ease,
        background 0.2s ease,
        filter 0.35s ease,
        box-shadow 0.35s ease;
    overflow: hidden;
    text-align: left;
}

.td-saved-design-card {
    cursor: pointer;
}

.td-saved-design-card:hover {
    filter: brightness(1.15);
}

.td-chassis-card-image-wrap {
    width: 72px;
    height: 56px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0e0e0e;
    border-right: 1px solid #222;
}

.td-chassis-card-img {
    width: 60px;
    height: 44px;
    object-fit: contain;
    image-rendering: pixelated;
}

.td-chassis-card-abbr {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #555;
}

.td-chassis-card-body {
    flex: 1;
    min-width: 0;
    padding: 0 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.td-chassis-card-name {
    font-size: 12px;
    font-weight: 600;
    color: #c0c0c0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.td-saved-design-card:hover .td-chassis-card-name {
    color: #e0e0e0;
}

.td-chassis-card-dlc {
    font-size: 9px;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.td-chassis-card-meta {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    padding: 6px 10px;
}

.td-chassis-card-year {
    font-size: 10px;
    color: #555;
    font-variant-numeric: tabular-nums;
    margin-top: 1px;
}

.td-chassis-card.is-outdated {
    background: #1e1208;
    border-color: #3a2010;
}

.td-saved-design-card.is-outdated:hover {
    background: #261808;
    border-color: #4a2a14;
}

.td-chassis-card.is-outdated .td-chassis-card-img {
    filter: grayscale(0.3);
}

.td-chassis-card-outdated {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #7a5a20;
    background: #2a1e00;
    border: 1px solid #3a2a00;
    border-radius: 2px;
    padding: 1px 4px;
    white-space: nowrap;
}

/* ── Shared (ephemeral) design badge ─────────────────────────────────────── */
.td-shared-design-badge {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #7878c8;
    background: #1a1830;
    border: 1px solid #3a3868;
    border-radius: 2px;
    padding: 1px 4px;
    white-space: nowrap;
}

.td-chassis-card.is-shared {
    border-color: #3a3868;
}

.td-chassis-card.is-shared.is-active {
    background: #1e2240;
    border-color: #5a58a0;
}

/* ── Create Variant button on default chassis cards ──────────────────────── */
.td-create-variant-btn {
    flex-shrink: 0;
    margin-right: 10px;
    font-size: 10px;
    font-weight: 600;
    font-family: inherit;
    letter-spacing: 0.02em;
    color: rgba(52, 148, 124, 0.85);
    background: rgba(52, 148, 124, 0.05);
    border: 1px solid rgba(52, 148, 124, 0.25);
    border-radius: 2px;
    padding: 3px 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.td-create-variant-btn:hover {
    background: rgba(52, 148, 124, 0.1);
    border-color: rgba(52, 148, 124, 0.5);
    color: rgb(52, 148, 124);
}

/* ── Saved design cards in chassis selection ────────────────────────────── */
.td-chassis-saved-designs {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 6px;
}

/* Valid saved design — teal tint */
.td-saved-design-card {
    background: rgba(52, 148, 124, 0.04);
    border-color: rgba(52, 148, 124, 0.15);
    border-left: 2px solid rgba(52, 148, 124, 0.5);
}

.td-saved-design-card:hover {
    background: rgba(52, 148, 124, 0.1);
    border-color: rgba(52, 148, 124, 0.3);
    border-left-color: rgba(52, 148, 124, 0.7);
}

/* Invalid saved design — grey with yellow accent */
.td-saved-design-card.is-invalid {
    background: #181818;
    border-color: #2a2a20;
    border-left: 2px solid #7a6a10;
    cursor: default;
}

.td-saved-design-card.is-invalid:hover {
    background: #1e1e16;
    border-left-color: #a08a18;
}

/* Outdated saved design — orange/red tint */
.td-saved-design-card.is-outdated {
    background: #1e1208;
    border-color: #3a2010;
    border-left: 2px solid #6a3010;
}

.td-saved-design-card.is-outdated:hover {
    background: #261808;
    border-left-color: #8a4018;
}

.td-chassis-card.is-previewed,
.td-saved-design-card.is-previewed {
    filter: brightness(1.4);
}

.td-saved-design-meta {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.td-design-edit-btn {
    font-size: 10px;
    padding: 3px 8px;
    white-space: nowrap;
}

.td-saved-design-chassis-label {
    font-size: 10px;
    color: #555;
    margin-top: 1px;
}

.td-chassis-stat-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.td-chassis-stat-chip {
    font-size: 10px;
    color: #777;
    display: flex;
    gap: 3px;
    align-items: center;
}

.td-ic-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0, 150, 136, 0.25);
    border: 1px solid rgba(0, 150, 136, 0.5);
    flex-shrink: 0;
}

.td-ic-icon {
    width: 11px;
    height: 11px;
    object-fit: contain;
}

.td-chassis-res-chip .resource-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
}

.td-chassis-stat-label {
    font-size: 9px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.td-design-warning-badge {
    font-size: 14px;
    line-height: 1;
    color: rgb(159, 142, 85);
    cursor: default;
    flex-shrink: 0;
}

/* ── Editor header action buttons ────────────────────────────────────────── */
.td-done-btn {
    font-size: 11px;
    padding: 4px 9px;
    flex-shrink: 0;
    margin-left: auto;
}

.td-editor-header {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.td-back-btn {
    font-size: 11px;
    padding: 4px 8px;
    flex-shrink: 0;
    color: #aaa;
    border-color: transparent;
    background: none;
    gap: 3px;
}

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

@media (max-width: 600px) {
    /* Keep label on prominent header control; hide only for minimal ghost backs elsewhere. */
    .td-back-btn:not(.td-chassis-header-back) > span {
        display: none;
    }
}

/* 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 .td-editor-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 0 1 auto;
    margin-left: auto;
}

.td-editor-header > .td-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;
}

.td-delete-design-btn[hidden] {
    display: none !important;
}

.td-delete-design-btn {
    background: #261e1e;
    border: 1px solid #3d2c2c;
    border-radius: 3px;
    padding: 5px 6px;
    color: #9a6868;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.td-delete-design-btn:hover {
    color: #c07070;
    border-color: #4a2020;
    background: #1e1010;
}

/* ── Shared designer dialog shell (.hoi4-dialog) ───────────────────────────── */
.hoi4-dialog-overlay {
    backdrop-filter: blur(4px);
}

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

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

.hoi4-dialog {
    width: 92%;
    max-width: 420px;
    border-top: 3px solid #a07038;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}

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

.hoi4-dialog--danger {
    border-top-color: #9a4a4a;
}

.td-modal-header.hoi4-dialog-header {
    background: linear-gradient(180deg, #262620 0%, #1f1f1c 100%);
    border-bottom-color: #3d3528;
}

.hoi4-dialog-heading {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #ece6d8;
    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-family-label {
    font-size: 11px;
    font-weight: 600;
    color: #a0a0a0;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.td-chassis-variants {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.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 ──────────────────────────────────────────────────────────── */
.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);
    }
}

/* Module cells — match division template .slot / .slot.filled */
.td-slot-cell {
    position: relative;
    background: #222222;
    border: 2px dashed #3d3d3d;
    border-radius: 3px;
    padding: 10px;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
    min-height: 80px;
    display: flex;
    align-items: center;
    flex-direction: column;
    gap: 6px;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.td-slot-cell:has(img.td-slot-icon) {
    border: 1px solid #548475;
    background: #1e1e1e;
}

.td-slot-cell:hover {
    border-color: #4f4f4f;
    background: #313131;
}

.td-slot-cell.is-required {
    border-color: #2e2e2e;
}

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

.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 {
    width: 36px;
    height: 36px;
    object-fit: contain;
    image-rendering: pixelated;
}

.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 ────────────────────────────────────────────────── */
.td-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.td-modal-overlay[hidden] {
    display: none;
}

.td-modal {
    background: #1c1c1c;
    border: 2px solid #3d3d3d;
    border-radius: 5px;
    width: 100%;
    max-width: 640px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.td-modal-header {
    background: #222222;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    border-bottom: 1px solid #3d3d3d;
    flex-shrink: 0;
}

.td-modal-header h3,
.td-picker-title {
    font-size: 16px;
    font-weight: 600;
    color: #e0e0e0;
    flex: 1;
    margin: 0;
}

.td-picker-close {
    padding: 2px 8px;
    font-size: 18px;
    line-height: 1;
    background: transparent;
    border-color: transparent;
    color: #e0e0e0;
}

.td-picker-close:hover {
    background: transparent;
    border-color: transparent;
    color: #fff;
}

.td-picker-search-bar {
    padding: 10px 15px;
    background: #1c1c1c;
    border-bottom: 1px solid #3d3d3d;
    flex-shrink: 0;
}

.td-picker-search {
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    background: #1e1e1e;
    border: 1px solid #3d3d3d;
    border-radius: 3px;
    color: #e0e0e0;
    font-family: inherit;
    box-sizing: border-box;
}

.td-picker-search:focus {
    outline: none;
    border-color: #c8a96e;
}

.td-picker-search::placeholder {
    color: #888;
}

.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-picker-remove-action {
    padding: 1rem 15px 1.2rem;
    border-bottom: 1px solid #3a3a3a;
}

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

.td-picker-body {
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.td-picker-category-header {
    font-size: 12px;
    font-weight: 700;
    color: #c0c0c0;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 6px 0;
    border-bottom: 1px solid #3d3d3d;
    margin-bottom: 4px;
}

.td-picker-category-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
}

/* Module cards reuse .modal-option from style.css — only small overrides needed */
.td-module-card {
    padding: 8px;
    gap: 4px;
    font-family: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.td-module-card.disabled {
    pointer-events: auto;
    cursor: not-allowed;
}

.td-module-card.is-selected {
    border-color: #c8a96e;
    background: rgba(200, 169, 110, 0.08);
}

.td-module-card-xp {
    font-size: 9px;
    color: #7aaa50;
}

.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-module-card-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 3px;
    margin-top: 3px;
}

.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 ──────────────────────────────────────────────────────── */
.td-publish-modal {
    max-width: 480px;
}

.td-modal-body {
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.td-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #2a2a2a;
}

/* Publish form fields use .publish-label / .publish-input / .publish-textarea from nav.css */

/* ── 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);
}

@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.
     */
    .td-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";
    }

    .td-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";
    }

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

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

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

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

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

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

    .td-inline-editor-inner .td-editor-header-actions {
        grid-area: actions;
        display: flex;
        align-items: stretch;
        gap: 8px;
        min-width: 0;
        /* Reset desktop flex-row push; auto margins here shrink-wrap the row and cluster controls right. */
        margin-left: 0;
        margin-inline-start: 0;
        justify-self: stretch;
        width: 100%;
    }

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

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

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

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

/* ── Share card (in-page + PNG export) ─────────────────────────────────────── */
/* In-page: match design post column (.design-main max-width: 860px in catalog.css). */
.td-share-card {
    background: #181818;
    border: 1px solid #2a2a2a;
    border-top: 2px solid #3d3528;
    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;
}

/* PNG / clipboard: fill card-export.js off-screen wrap (~landing showcase width). */
.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;
}

/* Same header rhythm as division .design-template-header + .dt-header-badges / .dt-header-load-link */
.td-share-card-header-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

/* Scoped copy of catalog .dt-header-load-link so tank-only pages / PNG pipeline don’t require catalog.css */
.td-share-card .dt-header-load-link {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.18rem 0.5rem;
    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 {
    background: rgba(200, 169, 110, 0.2);
    color: #d9be8a;
}

.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: flex-start;
}

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

.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;
}

/* Same layout idea as #td-top-slots + .td-bottom-section (editor) */
.td-share-card-slot-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Catalog-style 6-col strip: icon-only squares (see .design-card-preview--tank-modules / .dc-cell) */
.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 {
    aspect-ratio: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    border-radius: 2px;
    background: #191e1d;
    border: 1px solid #252e2c;
    font-size: 0.8rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    color: #9eb89a;
    font-family: 'Roboto Mono', 'Courier New', monospace;
}

.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 {
    flex-shrink: 0;
    display: inline-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 .td-ic-icon {
    width: 10px;
    height: 10px;
}

/*
 * Responsive tank share card (in-page). card-export.js adds .td-share-card--png-export
 * so layout/stacking rules never apply during capture (card fills compact export wrap).
 */
@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);
    }

    /* Misc. Stats (last block; Production rows are omitted from this column) — full width under Base + Combat */
    .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-stats {
        grid-template-columns: 1fr;
    }

    .td-share-card:not(.td-share-card--png-export) .td-share-card-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .td-share-card:not(.td-share-card--png-export) .td-share-card-footer-cost {
        align-self: flex-end;
    }
}
