/* ============================================================
   PVZH VAULT — DECK BUILDER (WORKBENCH)
   Loaded LAST, after home.css. Everything is scoped to #crafterView
   so it wins over the layered legacy rules in style.css without
   editing them. Colours reuse the homepage tokens (--vh-*).

   1. Tokens
   2. Frame: bench + readout on one surface
   3. Bench head + toolbar + menus
   4. Search, count rail, clear
   5. Deck: hero header, card grid, empty state
   6. Readout: grade, gauge, stats, cost curve, notes
   7. Dave
   8. Mobile
   9. Motion + focus
   ============================================================ */


/* ---------- 1. Tokens ---------- */

#crafterView {
    --wb-surface: var(--vh-surface, #1b2226);
    --wb-sunken: #141a1d;
    --wb-raised: #232b30;
    --wb-line: rgba(255, 255, 255, 0.07);
    --wb-line-strong: rgba(255, 255, 255, 0.12);
    --wb-text: #ffffff;
    --wb-text-2: #d3dade;
    --wb-muted: var(--vh-muted, #a0aab2);
    --wb-dim: var(--vh-dim, #828e96);
    --wb-accent: var(--vh-accent, #00b4d8);
    --wb-plant: #7cc864;
    --wb-zombie: #b48ce6;
    --wb-fill: var(--wb-accent);
    --wb-readout: 340px;
}

#crafterView[data-faction="plant"] { --wb-fill: var(--wb-plant); }
#crafterView[data-faction="zombie"] { --wb-fill: var(--wb-zombie); }


/* ---------- 2. Frame ---------- */

html body #crafterView.workbench {
    box-sizing: border-box !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) var(--wb-readout) !important;
    grid-template-areas: "bench readout" !important;
    /* The deck sets the height; the readout never makes the panel taller */
    grid-template-rows: minmax(var(--wb-min-h, 700px), auto) !important;
    align-items: stretch !important;
    gap: 0 !important;
    width: auto !important;
    max-width: 1132px !important;
    margin: 4px auto 56px !important;
    padding: 0 !important;
    background: var(--wb-surface) !important;
    border: 1px solid var(--wb-line) !important;
    border-radius: 16px !important;
    box-shadow: none !important;
    color: var(--wb-text) !important;
    text-align: left !important;
}

html body #crafterView.workbench.hidden {
    display: none !important;
}

#crafterView *,
#crafterView *::before,
#crafterView *::after {
    box-sizing: border-box;
}

#crafterView .bench {
    grid-area: bench;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 22px 26px 24px;
}

/* contain: size means the readout takes the deck's height instead of
   adding its own, so the two columns always line up. Dave's thread
   scrolls inside the space that's left under the score. */
#crafterView .readout {
    grid-area: readout;
    contain: size;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    padding: 24px 0 0 24px;
    border-left: 1px solid var(--wb-line);
}

/* Panel button off: the whole right column goes, the deck takes the width */
html body #crafterView.workbench.dave-panel-hidden {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-areas: "bench" !important;
    grid-template-rows: auto !important;
}

html body #crafterView.workbench.dave-panel-hidden .readout {
    display: none !important;
}

/* The grade still shows next to the fill bar while the panel is closed */
html body #crafterView.workbench.dave-panel-hidden .bench-grade:not([hidden]) {
    display: block !important;
}

html body #crafterView #deckStatsHud {
    flex: none !important;
}


/* ---------- 3. Bench head + toolbar ---------- */

#crafterView .bench-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 16px;
}

html body #crafterView .bench-title {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    margin: 0 !important;
    padding: 0 !important;
    color: var(--wb-text) !important;
    font-size: 18px !important;
    font-weight: 650 !important;
    line-height: 1.3 !important;
    letter-spacing: 0 !important;
    background: none !important;
    -webkit-text-fill-color: currentColor !important;
    text-align: left !important;
}

#crafterView .bench-title-logo {
    flex: none;
    display: block;
    width: 22px;
    height: 22px;
    object-fit: contain;
}

#crafterView .bench-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

@media (max-width: 1080px) {
    #crafterView .tb-long { display: none; }
}

html body #crafterView #benchTools .tb-btn {
    position: relative !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 7px !important;
    width: auto !important;
    min-width: 0 !important;
    height: 36px !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 12px !important;
    background: transparent !important;
    border: 1px solid var(--wb-line-strong) !important;
    border-radius: 9px !important;
    box-shadow: none !important;
    color: var(--wb-text-2) !important;
    font: inherit !important;
    font-size: 13.5px !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
    white-space: nowrap !important;
    cursor: pointer !important;
    transform: none !important;
    animation: none !important;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease !important;
}

html body #crafterView #benchTools .tb-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: rgba(255, 255, 255, 0.18) !important;
    color: var(--wb-text) !important;
}

html body #crafterView #benchTools .tb-btn:disabled {
    opacity: 0.38 !important;
    cursor: not-allowed !important;
    filter: none !important;
}

#crafterView .tb-icon {
    flex: none;
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#crafterView .tb-btn svg *,
#crafterView .tb-caret svg * {
    fill: none !important;
}

/* Panel on/off */
html body #crafterView #benchTools .tb-toggle[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.06) !important;
    color: var(--wb-text) !important;
}



/* Split buttons */
#crafterView .tb-split {
    position: relative;
    display: inline-flex;
}

html body #crafterView #benchTools .tb-split .tb-main {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

html body #crafterView #benchTools .tb-split .tb-caret {
    flex: none !important;
    width: 28px !important;
    padding: 0 !important;
    margin-left: -1px !important;
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
}

#crafterView .tb-caret svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.15s ease;
}

#crafterView .tb-split.mobile-open .tb-caret svg {
    transform: rotate(180deg);
}

/* Import menu: link field + screenshot option */
html body #crafterView #benchTools .tb-split.tb-import .tb-import-menu {
    left: 0 !important;
    right: auto !important;
    width: min(340px, calc(100vw - 40px)) !important;
    min-width: 0 !important;
    padding: 8px !important;
}

html body #crafterView #benchTools .tb-import-menu .tb-menu-note {
    display: block !important;
    padding: 4px 4px 8px !important;
    color: var(--wb-muted) !important;
    font-size: 12.5px !important;
    font-weight: 500 !important;
}

#crafterView .import-link-row {
    display: flex;
    gap: 6px;
}

html body #crafterView .import-link-input {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    width: auto !important;
    height: 36px !important;
    margin: 0 !important;
    padding: 0 10px !important;
    background: var(--wb-sunken) !important;
    border: 1px solid var(--wb-line-strong) !important;
    border-radius: 8px !important;
    box-shadow: none !important;
    outline: none !important;
    color: var(--wb-text) !important;
    font: inherit !important;
    font-size: 13.5px !important;
}

html body #crafterView .import-link-input::placeholder {
    color: var(--wb-dim) !important;
    opacity: 1 !important;
}

html body #crafterView .import-link-input:focus {
    border-color: rgba(0, 180, 216, 0.55) !important;
    box-shadow: 0 0 0 3px rgba(0, 180, 216, 0.14) !important;
}

html body #crafterView .import-link-input[aria-invalid="true"] {
    border-color: rgba(255, 138, 130, 0.6) !important;
}

html body #crafterView .import-link-btn {
    flex: none !important;
    width: auto !important;
    height: 36px !important;
    margin: 0 !important;
    padding: 0 12px !important;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid var(--wb-line-strong) !important;
    border-radius: 8px !important;
    box-shadow: none !important;
    color: var(--wb-text) !important;
    font: inherit !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
}

html body #crafterView .import-link-btn:hover {
    background: rgba(255, 255, 255, 0.1) !important;
}

#crafterView .import-link-msg {
    margin: 0;
    padding: 0 4px;
    color: #ff8a82;
    font-size: 12.5px;
    line-height: 1.4;
}

#crafterView .import-link-msg.is-status {
    color: var(--wb-muted);
}

#crafterView .import-link-msg:not(:empty) {
    padding-top: 7px;
}

#crafterView .tb-menu-sep {
    height: 1px;
    margin: 8px 0 4px;
    background: var(--wb-line);
}

html body #crafterView #benchTools .tb-menu-item {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 9px 6px !important;
    background: none !important;
    border: 0 !important;
    border-radius: 7px !important;
    box-shadow: none !important;
    color: var(--wb-text-2) !important;
    font: inherit !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    text-align: left !important;
    cursor: pointer !important;
}

html body #crafterView #benchTools .tb-menu-item:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05) !important;
    color: var(--wb-text) !important;
}

html body #crafterView #benchTools .tb-menu-item:disabled {
    opacity: 0.5 !important;
    cursor: progress !important;
}

#crafterView .tb-menu-item svg {
    flex: none;
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#crafterView .import-paste-hint {
    margin: 0;
    padding: 0 6px 4px 33px;
    color: var(--wb-dim);
    font-size: 12.5px;
    line-height: 1.4;
}

#crafterView .import-paste-hint kbd {
    padding: 1px 5px;
    border: 1px solid var(--wb-line-strong);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--wb-text-2);
    font: inherit;
    font-size: 11.5px;
}

/* Pasting isn't a thing on touch screens */
@media (hover: none) {
    #crafterView .import-paste-hint {
        display: none;
    }
}

/* While a screenshot is being read, the Import button shows the spinner */
#crafterView #importWrap:has(#deckImageUploadBtn.is-loading) #importMenuBtn .tb-spinner {
    display: inline-block !important;
}

#crafterView #importWrap:has(#deckImageUploadBtn.is-loading) #importMenuBtn .tb-icon {
    display: none !important;
}

/* Spinners (JS toggles .is-loading) */
#crafterView .tb-spinner {
    display: none !important;
    width: 15px;
    height: 15px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: wb-spin 0.7s linear infinite;
}

#crafterView .is-loading .tb-spinner { display: inline-block !important; }
#crafterView .is-loading .tb-icon { display: none !important; }

@keyframes wb-spin { to { transform: rotate(360deg); } }

/* Option menus — one pattern on every screen size */
html body #crafterView #benchTools .tb-menu {
    position: absolute !important;
    top: calc(100% + 6px) !important;
    right: 0 !important;
    left: auto !important;
    z-index: 80 !important;
    display: none !important;
    width: max-content !important;
    min-width: 184px !important;
    margin: 0 !important;
    padding: 6px !important;
    background: var(--wb-raised) !important;
    border: 1px solid var(--wb-line-strong) !important;
    border-radius: 11px !important;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45) !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    pointer-events: auto !important;
}

html body #crafterView #benchTools .tb-split.mobile-open .tb-menu {
    display: grid !important;
    gap: 2px !important;
}

#crafterView .tb-menu-note {
    margin: 0;
    padding: 6px 10px 6px;
    color: var(--wb-dim);
    font-size: 12px;
    line-height: 1.35;
}

html body #crafterView #benchTools .tb-check {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    margin: 0 !important;
    padding: 9px 10px !important;
    border-radius: 7px !important;
    color: var(--wb-text-2) !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    background: none !important;
    border: 0 !important;
}

html body #crafterView #benchTools .tb-check:hover {
    background: rgba(255, 255, 255, 0.05) !important;
    color: var(--wb-text) !important;
}

html body #crafterView #benchTools .tb-check input {
    flex: none !important;
    width: 16px !important;
    height: 16px !important;
    margin: 0 !important;
    accent-color: var(--wb-accent) !important;
    cursor: pointer !important;
}

html body #crafterView #benchTools .tb-check:has(input:disabled) {
    opacity: 0.45 !important;
    cursor: not-allowed !important;
}


/* ---------- 4. Search, count rail, clear ---------- */

#crafterView .bench-bar {
    margin-top: 18px;
}

#crafterView .bench-search {
    position: relative;
}

#crafterView .bench-search-icon {
    position: absolute;
    top: 50%;
    left: 14px;
    z-index: 2;
    width: 18px;
    height: 18px;
    transform: translateY(-50%);
    fill: none;
    stroke: var(--wb-dim);
    stroke-width: 1.9;
    stroke-linecap: round;
    pointer-events: none;
}

html body #crafterView #seedSearchInput {
    display: block !important;
    width: 100% !important;
    height: 48px !important;
    margin: 0 !important;
    padding: 0 14px 0 42px !important;
    background: var(--wb-sunken) !important;
    border: 1px solid var(--wb-line-strong) !important;
    border-radius: 11px !important;
    box-shadow: none !important;
    outline: none !important;
    color: var(--wb-text) !important;
    font: inherit !important;
    font-size: 15.5px !important;
    transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
}

html body #crafterView #seedSearchInput::placeholder {
    color: var(--wb-dim) !important;
    opacity: 1 !important;
}

html body #crafterView #seedSearchInput:focus {
    border-color: rgba(0, 180, 216, 0.6) !important;
    box-shadow: 0 0 0 3px rgba(0, 180, 216, 0.16) !important;
}

html body #crafterView #smartSuggestions {
    position: absolute !important;
    top: calc(100% + 6px) !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 90 !important;
    max-height: min(340px, 50vh) !important;
    overflow-y: auto !important;
    margin: 0 !important;
    padding: 5px !important;
    list-style: none !important;
    background: var(--wb-raised) !important;
    border: 1px solid var(--wb-line-strong) !important;
    border-radius: 11px !important;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45) !important;
}

html body #crafterView #smartSuggestions li {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    margin: 0 !important;
    padding: 10px 11px !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 7px !important;
    color: var(--wb-text) !important;
    font-size: 14.5px !important;
    cursor: pointer !important;
}

html body #crafterView #smartSuggestions li:hover,
html body #crafterView #smartSuggestions li.active,
html body #crafterView #smartSuggestions li.selected,
html body #crafterView #smartSuggestions li[aria-selected="true"] {
    background: rgba(255, 255, 255, 0.06) !important;
}

html body #crafterView #smartSuggestions li > span:last-child:not(:first-child) {
    flex: none !important;
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
    color: var(--wb-dim) !important;
    font-size: 12.5px !important;
    font-weight: 500 !important;
}

/* Count + 40-slot rail */
#crafterView .bench-count {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 14px;
}

#crafterView .bench-count-num {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
    flex: none;
    min-width: 50px;
    color: var(--wb-text);
    font-size: 17px;
    font-weight: 650;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

html body #crafterView #cardCountTracker {
    all: unset;
    font: inherit;
    color: inherit;
}

#crafterView .bench-rail {
    --slot: calc(100% / 40);
    --slots: repeating-linear-gradient(
        to right,
        currentColor 0,
        currentColor calc(var(--slot) - 2px),
        transparent calc(var(--slot) - 2px),
        transparent var(--slot)
    );
    position: relative;
    flex: 1;
    height: 12px;
    color: rgba(255, 255, 255, 0.09);
    background: var(--slots);
    border-radius: 2px;
}

#crafterView .bench-rail > span {
    position: absolute;
    inset: 0;
    color: var(--wb-fill);
    background: var(--slots);
    clip-path: inset(0 calc((1 - var(--deck-fill, 0)) * 100%) 0 0);
    transition: clip-path 0.35s cubic-bezier(0.2, 0.7, 0.2, 1), color 0.3s ease;
}

#crafterView .bench-grade {
    display: none;
    flex: none;
    min-width: 14px;
    font-size: 18px;
    font-weight: 750;
    line-height: 1;
    text-align: center;
}

html body #crafterView .bench-clear {
    flex: none !important;
    width: auto !important;
    height: 30px !important;
    margin: 0 -8px 0 0 !important;
    padding: 0 8px !important;
    background: none !important;
    border: 0 !important;
    border-radius: 7px !important;
    box-shadow: none !important;
    color: var(--wb-dim) !important;
    font: inherit !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
}

html body #crafterView .bench-clear:hover:not(:disabled) {
    background: rgba(255, 95, 87, 0.1) !important;
    color: #ff8a82 !important;
}

html body #crafterView .bench-clear:disabled {
    visibility: hidden !important;
}


/* ---------- 5. Deck ---------- */

#crafterView .bench-deck {
    margin-top: 22px;
}

/* Hero + editable deck name (appears once the deck is complete) */
html body #crafterView #generatedDeckTitle {
    margin: 0 0 18px !important;
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
    box-shadow: none !important;
    font-size: inherit !important;
    text-align: left !important;
}

html body #crafterView #generatedDeckTitle.hidden {
    display: none !important;
}

html body #crafterView #generatedDeckTitle .export-style-header {
    display: flex !important;
    align-items: center !important;
    gap: 14px !important;
    margin: 0 !important;
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

html body #crafterView #generatedDeckTitle .export-style-header::before,
html body #crafterView #generatedDeckTitle .export-style-header::after {
    display: none !important;
}

html body #crafterView #generatedDeckTitle .export-header-avatars {
    position: relative !important;
    flex: none !important;
    width: 48px !important;
    height: 48px !important;
    margin: 0 !important;
}

html body #crafterView #generatedDeckTitle .export-header-avatars.multi { width: 82px !important; }
html body #crafterView #generatedDeckTitle .export-header-avatars:has(img:nth-child(3)) { width: 116px !important; }

html body #crafterView #generatedDeckTitle .export-header-avatar {
    position: absolute !important;
    top: 0 !important;
    width: 48px !important;
    height: 48px !important;
    border: 2px solid var(--wb-surface) !important;
    border-radius: 50% !important;
    box-shadow: none !important;
    background: var(--wb-sunken) !important;
    object-fit: cover !important;
    transform: none !important;
}

html body #crafterView #generatedDeckTitle .export-header-text {
    display: grid !important;
    gap: 3px !important;
    flex: 1 !important;
    min-width: 0 !important;
}

html body #crafterView #generatedDeckTitle .export-deck-name-input {
    width: 100% !important;
    max-width: 420px !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 0 2px !important;
    background: none !important;
    border: 0 !important;
    border-bottom: 1px dashed transparent !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    color: var(--wb-text) !important;
    font-family: inherit !important;
    font-size: 22px !important;
    font-weight: 650 !important;
    line-height: 1.2 !important;
    letter-spacing: -0.01em !important;
    text-align: left !important;
    -webkit-text-fill-color: currentColor !important;
}

html body #crafterView #generatedDeckTitle .export-deck-name-input::placeholder {
    color: var(--wb-text) !important;
    -webkit-text-fill-color: var(--wb-text) !important;
    opacity: 1 !important;
}

html body #crafterView #generatedDeckTitle .export-deck-name-input:hover {
    border-bottom-color: var(--wb-line-strong) !important;
}

html body #crafterView #generatedDeckTitle .export-deck-name-input:focus {
    border-bottom-color: var(--wb-accent) !important;
}

html body #crafterView #generatedDeckTitle .export-hero-name {
    margin: 0 !important;
    color: var(--wb-muted) !important;
    font-size: 13.5px !important;
    font-weight: 500 !important;
    text-align: left !important;
}

/* Card grid */
#crafterView .bench-deck {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
}

html body #crafterView #generatedDeckList {
    overflow: visible !important;
    scrollbar-width: none !important;
    max-height: none !important;
    align-content: start !important;
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)) !important;
    gap: 14px 10px !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
}

html body #crafterView #generatedDeckList > .visual-card {
    position: relative !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
    box-shadow: none !important;
    cursor: pointer !important;
}

html body #crafterView #generatedDeckList > .visual-card:hover {
    transform: none !important;
}

html body #crafterView .visual-card-art {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 1 / 1 !important;
}

html body #crafterView .visual-card-art > img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    object-position: center !important;
    filter: none !important;
}

html body #crafterView .visual-card-art .card-quantity {
    bottom: 3px !important;
    left: 2px !important;
    padding: 1px 6px !important;
    background: rgba(12, 16, 18, 0.9) !important;
    border: 0 !important;
    border-radius: 6px !important;
    box-shadow: none !important;
    color: var(--wb-text) !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    line-height: 18px !important;
    letter-spacing: 0 !important;
    font-variant-numeric: tabular-nums !important;
}

/* Tap/hover controls: − Swap + */
html body #crafterView .visual-card-controls {
    top: -6px !important;
    width: 112px !important;
    height: 34px !important;
    padding: 3px !important;
    grid-template-columns: 30px minmax(0, 1fr) 30px !important;
    gap: 2px !important;
    background: var(--wb-raised) !important;
    border: 1px solid var(--wb-line-strong) !important;
    border-radius: 9px !important;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5) !important;
}

html body #crafterView .visual-card-controls .seed-btn {
    height: 26px !important;
    background: transparent !important;
    border-radius: 6px !important;
    color: var(--wb-text-2) !important;
    font-size: 17px !important;
    font-weight: 600 !important;
}

html body #crafterView .visual-card-controls .swap-btn {
    font-size: 12px !important;
    font-weight: 600 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
}

html body #crafterView .visual-card-controls .seed-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08) !important;
    color: var(--wb-text) !important;
}

html body #crafterView .visual-card-controls .seed-btn:disabled {
    color: rgba(255, 255, 255, 0.2) !important;
    background: transparent !important;
}

/* Dave's next pick, shown in the grid: same size as the other cards,
   darkened and desaturated like a recharging seed packet, full colour on hover */
html body #crafterView .visual-card.ghost-suggestion .visual-card-art {
    transform: none !important;
    outline: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    background: none !important;
}

html body #crafterView #generatedDeckList > .visual-card.ghost-suggestion .visual-card-art > img {
    opacity: 0.55 !important;
    filter: grayscale(1) brightness(0.72) !important;
    transition: transform 0.18s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.18s ease, filter 0.18s ease !important;
}

html body #crafterView .visual-card.ghost-suggestion .card-quantity {
    opacity: 1 !important;
    background: rgba(12, 16, 18, 0.9) !important;
    color: var(--wb-muted) !important;
    transition: color 0.18s ease !important;
}

@media (hover: hover) and (pointer: fine) {
    html body #crafterView #generatedDeckList > .visual-card.ghost-suggestion:hover .visual-card-art > img {
        opacity: 1 !important;
        filter: none drop-shadow(0 6px 10px rgba(0, 0, 0, 0.35)) !important;
    }

    html body #crafterView .visual-card.ghost-suggestion:hover .card-quantity {
        color: var(--wb-text) !important;
    }
}

html body #crafterView .visual-card.ghost-suggestion:focus-visible {
    outline: 2px solid var(--wb-accent) !important;
    outline-offset: 2px !important;
    border-radius: 12px !important;
}

html body #crafterView .visual-card.ghost-suggestion:focus-visible .visual-card-art > img {
    opacity: 1 !important;
    filter: none !important;
}

/* Empty deck */
html body #crafterView #generatedDeckList:has(.bench-empty) {
    flex: 1 0 auto !important;
    align-content: stretch !important;
    align-items: stretch !important;
    grid-template-rows: 1fr !important;
}

html body #crafterView .bench-empty {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 220px;
    padding: 52px 20px;
    border: 1px dashed var(--wb-line-strong);
    border-radius: 12px;
    color: var(--wb-muted);
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
}

#crafterView .bench-empty p {
    margin: 0 auto;
    max-width: 34ch;
}

#crafterView .bench-empty .bench-empty-lead {
    margin-bottom: 4px;
    color: var(--wb-text);
    font-size: 16px;
    font-weight: 600;
}


/* ---------- 6. Readout ---------- */

html body #crafterView #deckStatsHud {
    margin: 0 0 20px !important;
    padding: 0 24px 0 0 !important;
    background: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    animation: none !important;
}

html body #crafterView .pm-top {
    display: flex !important;
    align-items: center !important;
    gap: 16px !important;
    margin: 0 !important;
}

html body #crafterView .pm-grade {
    display: block !important;
    flex: none !important;
    width: auto !important;
    min-width: 36px !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    text-shadow: none !important;
    font-family: inherit !important;
    font-size: 50px !important;
    font-weight: 750 !important;
    line-height: 1 !important;
    letter-spacing: -0.02em !important;
    text-align: center !important;
    -webkit-text-fill-color: currentColor !important;
}

html body #crafterView .pm-grade.is-ungraded {
    display: none !important;
}

html body #crafterView .pm-meta {
    display: grid !important;
    gap: 5px !important;
    min-width: 0 !important;
}

html body #crafterView .pm-quality {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: baseline !important;
    gap: 2px 10px !important;
    margin: 0 !important;
    text-align: left !important;
}

html body #crafterView .pm-quality-word {
    color: var(--wb-text) !important;
    font-size: 19px !important;
    font-weight: 650 !important;
    line-height: 1.2 !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
}

html body #crafterView .pm-next-grade {
    display: none !important;
}

html body #crafterView .pm-archetype {
    color: var(--wb-muted) !important;
    font-size: 13.5px !important;
    font-weight: 500 !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
}

/* Grade gauge: six even segments, a hairline marker for the exact score */
html body #crafterView .pm-gauge {
    margin: 16px 0 0 !important;
    padding: 0 !important;
}

html body #crafterView .pm-track {
    position: relative !important;
    height: 6px !important;
    margin: 0 !important;
    background: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    overflow: visible !important;
    box-shadow: none !important;
}

html body #crafterView .pm-zones {
    display: grid !important;
    grid-template-columns: repeat(6, 1fr) !important;
    gap: 3px !important;
    height: 100% !important;
    background: none !important;
}

html body #crafterView .pm-zone {
    height: 100% !important;
    background: rgba(255, 255, 255, 0.08) !important;
    border-radius: 2px !important;
    opacity: 1 !important;
    box-shadow: none !important;
    filter: none !important;
}

html body #crafterView .pm-zone.active[data-g="F"] { background: var(--grade-f, #ff4b4b) !important; }
html body #crafterView .pm-zone.active[data-g="D"] { background: var(--grade-d, #ff8a3d) !important; }
html body #crafterView .pm-zone.active[data-g="C"] { background: var(--grade-c, #ffb300) !important; }
html body #crafterView .pm-zone.active[data-g="B"] { background: var(--grade-b, #9ccc4c) !important; }
html body #crafterView .pm-zone.active[data-g="A"] { background: var(--grade-a, #4caf50) !important; }
html body #crafterView .pm-zone.active[data-g="S"] { background: var(--grade-s, #00e5ff) !important; }

html body #crafterView .pm-marker {
    position: absolute !important;
    top: -5px !important;
    width: 2px !important;
    height: 16px !important;
    margin: 0 !important;
    background: var(--wb-text) !important;
    border: 0 !important;
    border-radius: 1px !important;
    box-shadow: 0 0 0 2px var(--wb-surface) !important;
    transform: translateX(-1px) !important;
    animation: none !important;
    transition: left 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) !important;
}

html body #crafterView .pm-marker::before,
html body #crafterView .pm-marker::after {
    display: none !important;
}

html body #crafterView .pm-letters {
    position: relative !important;
    height: 15px !important;
    margin: 7px 0 0 !important;
}

html body #crafterView .pm-letter {
    position: absolute !important;
    top: 0 !important;
    transform: translateX(-50%) !important;
    color: var(--wb-dim) !important;
    font-size: 11.5px !important;
    font-weight: 500 !important;
    line-height: 15px !important;
    text-shadow: none !important;
    opacity: 0.8 !important;
}

html body #crafterView .pm-letter.active {
    color: var(--g, var(--wb-text)) !important;
    font-weight: 700 !important;
    opacity: 1 !important;
}

/* Cards / avg cost / sparks */
html body #crafterView .pm-subtitle {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px !important;
    margin: 14px 0 0 !important;
    padding: 10px 0 !important;
    border-top: 1px solid var(--wb-line) !important;
    border-bottom: 1px solid var(--wb-line) !important;
    color: inherit !important;
    font-size: inherit !important;
}

#crafterView .pm-subtitle dt {
    margin: 0 0 2px;
    color: var(--wb-dim);
    font-size: 12px;
    font-weight: 500;
}

#crafterView .pm-subtitle dd {
    margin: 0;
    color: var(--wb-text);
    font-size: 15px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

#crafterView .readout-block {
    margin-top: 14px;
}

#crafterView .readout-h {
    margin: 0 0 10px;
    color: var(--wb-muted);
    font-size: 12.5px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
}

/* Cost curve: labelled bars */
html body #crafterView #manaCurveChart.pm-curve {
    display: grid !important;
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    gap: 8px !important;
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
}

#crafterView .curve-col {
    display: grid;
    justify-items: center;
    gap: 5px;
    min-width: 0;
}

#crafterView .curve-n {
    color: var(--wb-text-2);
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

#crafterView .curve-bar {
    position: relative;
    display: flex;
    align-items: flex-end;
    width: 100%;
    height: 48px;
    background: rgba(255, 255, 255, 0.035);
    border-radius: 4px;
    overflow: hidden;
}

#crafterView .curve-bar > span {
    display: block;
    width: 100%;
    background: var(--wb-fill);
    opacity: 0.8;
    border-radius: 4px 4px 0 0;
    transition: height 0.4s cubic-bezier(0.2, 0.7, 0.2, 1);
}

#crafterView .curve-x {
    color: var(--wb-dim);
    font-size: 12px;
    line-height: 1;
}

#crafterView .curve-col.is-empty .curve-n {
    color: var(--wb-dim);
    opacity: 0.6;
}

/* Notes (strengths / weaknesses) */
html body #crafterView .pm-callouts {
    display: grid !important;
    gap: 7px !important;
    margin: 14px 0 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

html body #crafterView .pm-callouts:empty {
    display: none !important;
}

html body #crafterView .pm-chip {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    width: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    color: var(--wb-text-2) !important;
    font-size: 13.5px !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
    text-align: left !important;
}

html body #crafterView .pm-chip::before {
    content: "" !important;
    position: static !important;
    flex: none !important;
    width: 16px !important;
    height: 16px !important;
    margin: 0 !important;
    padding: 0 !important;
    background: var(--wb-dim) !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    transform: none !important;
    -webkit-mask: var(--wb-note-icon) center / 16px 16px no-repeat !important;
    mask: var(--wb-note-icon) center / 16px 16px no-repeat !important;
}

html body #crafterView .pm-chip.up {
    --wb-note-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}

html body #crafterView .pm-chip.down {
    --wb-note-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M12 6v7.5'/%3E%3Ccircle cx='12' cy='18' r='.6' fill='black'/%3E%3C/svg%3E");
}

html body #crafterView .pm-chip.mixed {
    --wb-note-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M7 12h10'/%3E%3C/svg%3E");
}

html body #crafterView .pm-chip.mixed::before { background: var(--wb-muted) !important; }
html body #crafterView .pm-chip.up::before { background: var(--wb-plant) !important; }
html body #crafterView .pm-chip.down::before { background: #ffb300 !important; }
html body #crafterView .pm-chip::after { display: none !important; }


/* ---------- 7. Dave ---------- */

html body #crafterView #crazyDavePanel.ai-pane {
    position: static !important;
    display: flex !important;
    flex: 1 1 auto !important;
    flex-direction: column !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 20px 0 0 !important;
    background: none !important;
    border: 0 !important;
    border-top: 1px solid var(--wb-line) !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: hidden !important;
    opacity: 1 !important;
    transform: none !important;
    transition: opacity 0.25s ease !important;
}

/* No score yet: Dave leads the column, no divider above him */
html body #crafterView #deckStatsHud[style*="none"] + #crazyDavePanel.ai-pane {
    padding-top: 0 !important;
    border-top: 0 !important;
}


#crafterView .dave-head {
    flex: none;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    padding-right: 24px;
}

#crafterView .dave-avatar {
    flex: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--wb-sunken);
    object-fit: cover;
}

html body #crafterView .dave-head h3 {
    margin: 0 !important;
    color: var(--wb-text) !important;
    font-size: 14.5px !important;
    font-weight: 650 !important;
}

html body #crafterView #aiChatFeed.ai-chat-feed {
    display: flex !important;
    flex: 1 1 auto !important;
    flex-direction: column !important;
    gap: 14px !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    padding: 0 18px 24px 0 !important;
    scrollbar-width: thin !important;
    scrollbar-color: rgba(255, 255, 255, 0.14) transparent !important;
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent) !important;
    mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent) !important;
}

html body #crafterView #aiChatFeed .dave-msg {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    animation: none !important;
}

html body #crafterView #aiChatFeed .dave-msg-avatar {
    display: none !important;
}

html body #crafterView #aiChatFeed .speech-bubble {
    position: static !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 1px 0 1px 13px !important;
    background: none !important;
    border: 0 !important;
    border-left: 2px solid var(--wb-line-strong) !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    color: var(--wb-text-2) !important;
    font-size: 14px !important;
    line-height: 1.55 !important;
    text-align: left !important;
    overflow-wrap: anywhere !important;
    animation: none !important;
}

html body #crafterView #aiChatFeed .speech-bubble::before,
html body #crafterView #aiChatFeed .speech-bubble::after {
    display: none !important;
}

html body #crafterView #aiChatFeed .speech-bubble strong {
    color: var(--wb-text) !important;
    font-weight: 650 !important;
}

html body #crafterView #aiChatFeed .speech-bubble strong.card-name-accent,
html body #crafterView #aiChatFeed .speech-bubble strong[style] {
    color: var(--wb-accent) !important;
}

html body #crafterView #aiChatFeed .speech-bubble a {
    color: var(--wb-accent) !important;
    word-break: break-all !important;
}

html body #crafterView #aiChatFeed .speech-bubble br + br {
    display: none !important;
}

/* "Why this pick?" */
html body #crafterView #aiChatFeed .dave-more {
    margin: 8px 0 0 !important;
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
}

html body #crafterView #aiChatFeed .dave-more summary {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    color: var(--wb-accent) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
}

html body #crafterView #aiChatFeed .dave-more summary::-webkit-details-marker { display: none !important; }

html body #crafterView #aiChatFeed .dave-more summary::before {
    content: "" !important;
    width: 6px !important;
    height: 6px !important;
    margin: 0 2px 0 1px !important;
    background: none !important;
    border: solid currentColor !important;
    border-width: 0 1.5px 1.5px 0 !important;
    border-radius: 0 !important;
    transform: rotate(-45deg) !important;
    transition: transform 0.15s ease !important;
}

html body #crafterView #aiChatFeed .dave-more[open] summary::before {
    transform: rotate(45deg) translate(-1px, -1px) !important;
}

html body #crafterView #aiChatFeed .dave-more summary svg,
html body #crafterView #aiChatFeed .dave-more summary::after {
    display: none !important;
}

html body #crafterView #aiChatFeed .dave-more-content {
    margin-top: 8px !important;
}

html body #crafterView #aiChatFeed .rec-why-list {
    display: grid !important;
    gap: 8px !important;
    margin: 6px 0 0 !important;
}

html body #crafterView #aiChatFeed .rec-why-item,
html body #crafterView #aiChatFeed .rec-why-text {
    margin: 0 !important;
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
    color: var(--wb-muted) !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
}

html body #crafterView #aiChatFeed .starter-pick {
    margin: 0 !important;
    color: var(--wb-text-2) !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
}

html body #crafterView #aiChatFeed .starter-pick-link {
    display: inline !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
    border-radius: 2px !important;
    box-shadow: none !important;
    color: var(--wb-text) !important;
    font: inherit !important;
    font-weight: 650 !important;
    text-decoration: underline !important;
    text-decoration-color: rgba(255, 255, 255, 0.35) !important;
    text-decoration-thickness: 1.5px !important;
    text-underline-offset: 3px !important;
    cursor: pointer !important;
    transition: color 0.15s ease, text-decoration-color 0.15s ease !important;
}

html body #crafterView #aiChatFeed .starter-pick-link:hover {
    color: var(--wb-accent) !important;
    text-decoration-color: currentColor !important;
}

/* Recommended cards: no boxes, just the card and a plain button */
html body #crafterView #aiChatFeed .rec-row {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 4px !important;
    max-width: 300px !important;
    margin: -2px 0 0 15px !important;
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
    box-shadow: none !important;
}

html body #crafterView #aiChatFeed .rec-card {
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 5px !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

html body #crafterView #aiChatFeed .rec-card::before,
html body #crafterView #aiChatFeed .rec-card::after {
    display: none !important;
}

html body #crafterView #aiChatFeed .rec-badge {
    position: static !important;
    margin: 0 !important;
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
    color: var(--wb-dim) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
    box-shadow: none !important;
}

html body #crafterView #aiChatFeed .rec-badge.gold {
    color: var(--vh-gold, #ffd15c) !important;
}

html body #crafterView #aiChatFeed .rec-card img {
    flex: none !important;
    width: 100% !important;
    max-width: 76px !important;
    height: auto !important;
    aspect-ratio: 1 / 1 !important;
    object-fit: contain !important;
    margin: 0 !important;
}

/* Same quiet outline as the toolbar */
html body #crafterView #aiChatFeed .add-rec-btn {
    flex: none !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    min-width: 52px !important;
    max-width: none !important;
    height: 30px !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 12px !important;
    background: transparent !important;
    border: 1px solid var(--wb-line-strong) !important;
    border-radius: 8px !important;
    box-shadow: none !important;
    color: var(--wb-text-2) !important;
    font: inherit !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    cursor: pointer !important;
    transform: none !important;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease !important;
}

html body #crafterView #aiChatFeed .add-rec-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.06) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    color: var(--wb-text) !important;
}

/* Swap suggestion: inline with Dave's message, no box */
html body #crafterView #aiChatFeed .swap-duel {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    align-self: center !important;
    width: fit-content !important;
    max-width: none !important;
    margin: -4px auto 0 !important;
    padding: 0 !important;
    background: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    text-align: center !important;
}

html body #crafterView #aiChatFeed .swap-duel::before,
html body #crafterView #aiChatFeed .swap-duel::after {
    display: none !important;
}

html body #crafterView #aiChatFeed .swap-duel-label {
    margin: 0 0 6px !important;
    text-align: center !important;
    color: var(--wb-muted) !important;
    font-size: 12.5px !important;
    font-weight: 500 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
}

html body #crafterView #aiChatFeed .swap-duel-cards {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    margin: 0 0 10px !important;
}

html body #crafterView #aiChatFeed .swap-card {
    display: grid !important;
    justify-items: center !important;
    gap: 2px !important;
}

html body #crafterView #aiChatFeed .swap-card img {
    width: 68px !important;
    height: 68px !important;
    object-fit: contain !important;
}

html body #crafterView #aiChatFeed .swap-card.out img {
    opacity: 0.5 !important;
    filter: grayscale(0.7) !important;
}

html body #crafterView #aiChatFeed .swap-tag {
    color: var(--wb-dim) !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
}

html body #crafterView #aiChatFeed .swap-arrow {
    color: var(--wb-dim) !important;
    font-size: 15px !important;
}

html body #crafterView #aiChatFeed .swap-duel .add-rec-btn {
    width: auto !important;
    align-self: center !important;
}


/* ---------- Share row (bottom of the bench) ---------- */

#crafterView .bench-share {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid var(--wb-line);
}

#crafterView .bench-share[hidden] {
    display: none;
}

html body #crafterView .bench-share-label {
    flex: none !important;
    margin: 0 !important;
    color: var(--wb-muted) !important;
    font-size: 13px !important;
    font-weight: 500 !important;
}

html body #crafterView .bench-share-url {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    width: auto !important;
    height: 34px !important;
    margin: 0 !important;
    padding: 0 10px !important;
    background: var(--wb-sunken) !important;
    border: 1px solid var(--wb-line) !important;
    border-radius: 8px !important;
    box-shadow: none !important;
    outline: none !important;
    color: var(--wb-text-2) !important;
    font: inherit !important;
    font-size: 13px !important;
    text-overflow: ellipsis !important;
}

html body #crafterView .bench-share-url:focus {
    border-color: rgba(0, 180, 216, 0.5) !important;
}

html body #crafterView .bench-share-copy {
    flex: none !important;
    width: auto !important;
    height: 34px !important;
    margin: 0 !important;
    padding: 0 12px !important;
    background: transparent !important;
    border: 1px solid var(--wb-line-strong) !important;
    border-radius: 8px !important;
    box-shadow: none !important;
    color: var(--wb-text-2) !important;
    font: inherit !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
}

html body #crafterView .bench-share-copy:hover {
    background: rgba(255, 255, 255, 0.06) !important;
    color: var(--wb-text) !important;
}

html body #crafterView .bench-share-copy.is-done {
    color: var(--wb-plant) !important;
    border-color: rgba(124, 200, 100, 0.4) !important;
}


/* ---------- 8. Mobile ---------- */

@media (max-width: 860px) {
    #crafterView { --wb-readout: 300px; }

    #crafterView .bench { padding: 20px 20px 22px; }
    #crafterView .readout { padding: 22px 0 0 20px; }
}

@media (max-width: 720px) {
    /* On phones the builder starts right under the top bar: no site wordmark */
    html body:has(#crafterView:not(.hidden)) > header .site-title-row {
        display: none !important;
    }

    html body:has(#crafterView:not(.hidden)) > header .header-content {
        padding-top: 12px !important;
        padding-bottom: 0 !important;
        min-height: 0 !important;
    }

    html body #crafterView.workbench {
        grid-template-columns: minmax(0, 1fr) !important;
        grid-template-areas:
            "bench"
            "readout" !important;
        grid-template-rows: auto !important;
        margin: 0 auto 32px !important;
        border-radius: 14px !important;
    }

    #crafterView .readout {
        contain: none;
        overflow: visible;
    }

    html body #crafterView #deckStatsHud {
        padding-right: 0 !important;
    }

    html body #crafterView #crazyDavePanel.ai-pane {
        overflow: visible !important;
    }

    html body #crafterView #aiChatFeed.ai-chat-feed {
        overflow: visible !important;
        padding: 0 !important;
        -webkit-mask-image: none !important;
        mask-image: none !important;
    }

    #crafterView .dave-head {
        padding-right: 0;
    }

    #crafterView .bench-share-label {
        display: none;
    }

    #crafterView .bench {
        padding: 16px 14px 20px;
    }

    #crafterView .readout {
        padding: 20px 14px 22px;
        border-left: 0;
        border-top: 1px solid var(--wb-line);
    }

    #crafterView .bench-head {
        gap: 12px;
    }

    #crafterView .bench-tools {
        flex-wrap: nowrap;
        width: 100%;
        gap: 6px;
    }

    #crafterView .bench-tools > .tb-btn,
    #crafterView .bench-tools > .tb-split {
        flex: 1 1 auto;
        min-width: 0;
    }

    #crafterView .tb-split .tb-main .tb-icon {
        display: none;
    }

    html body #crafterView #benchTools .tb-split .tb-main {
        flex: 1 1 auto !important;
        min-width: 0 !important;
    }

    html body #crafterView #benchTools .tb-btn {
        padding: 0 8px !important;
        gap: 6px !important;
        font-size: 13px !important;
    }

    #crafterView .tb-long { display: none; }

        html body #crafterView #benchTools .tb-split .tb-menu {
        right: 0 !important;
    }

    /* Search + count stay pinned while you scroll the deck */
    #crafterView .bench-bar {
        position: sticky;
        top: 0;
        z-index: 40;
        margin: 14px -14px 0;
        padding: 10px 14px 10px;
        background: var(--wb-surface);
        box-shadow: 0 1px 0 var(--wb-line);
    }

    html body #crafterView #seedSearchInput {
        height: 46px !important;
        font-size: 16px !important; /* prevents iOS zoom on focus */
    }

    html body #crafterView .import-link-input {
        font-size: 16px !important;
    }

    #crafterView .bench-count {
        gap: 12px;
        margin-top: 10px;
    }

    #crafterView .bench-grade:not([hidden]) {
        display: block;
    }

    /* the bench already shows the grade while you build; Clear moves to its right */

    #crafterView .bench-deck {
        margin-top: 16px;
    }

    html body #crafterView #generatedDeckList {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        gap: 10px 6px !important;
    }

    html body #crafterView .visual-card-art .card-quantity {
        font-size: 11px !important;
        line-height: 16px !important;
        padding: 0 5px !important;
    }

    html body #crafterView .visual-card-controls {
        width: 104px !important;
        height: 36px !important;
        grid-template-columns: 30px minmax(0, 1fr) 30px !important;
    }

    html body #crafterView .visual-card-controls .seed-btn {
        height: 28px !important;
    }

    /* Keep the edge cards' controls on screen */
    html body #crafterView #generatedDeckList > .visual-card:nth-child(4n + 1) .visual-card-controls {
        left: 0 !important;
        transform: none !important;
    }

    html body #crafterView #generatedDeckList > .visual-card:nth-child(4n) .visual-card-controls {
        left: auto !important;
        right: 0 !important;
        transform: none !important;
    }

    html body #crafterView #generatedDeckTitle .export-deck-name-input {
        font-size: 20px !important;
    }

    html body #crafterView #generatedDeckTitle .export-header-avatars,
    html body #crafterView #generatedDeckTitle .export-header-avatar {
        height: 42px !important;
    }

    html body #crafterView #generatedDeckTitle .export-header-avatar {
        width: 42px !important;
    }

    html body #crafterView #generatedDeckTitle .export-header-avatars { width: 42px !important; }
    html body #crafterView #generatedDeckTitle .export-header-avatars.multi { width: 76px !important; }


    html body #crafterView #aiChatFeed .rec-row {
        margin-left: 0 !important;
    }

    #crafterView .bench-empty {
        padding: 36px 16px;
    }
}

@media (max-width: 370px) {
    /* Import and Panel keep their icons; Finish and Save keep their words */
    #crafterView .bench-tools > .tb-btn:not(#downloadImageBtn) .tb-label,
    #crafterView #importMenuBtn .tb-label { display: none; }
    #crafterView .bench-tools > .tb-btn:not(#downloadImageBtn),
    #crafterView .bench-tools > .tb-import { flex: 0 0 40px; }
    html body #crafterView #benchTools #importMenuBtn { width: 40px !important; }
}


/* ---------- 9. Motion + focus ---------- */

/* Light lift on cards and hero portraits (pointer devices only) */
html body #crafterView .visual-card-art > img,
html body #crafterView #aiChatFeed .rec-card img,
html body #crafterView #aiChatFeed .swap-card img,
html body #crafterView #generatedDeckTitle .export-header-avatar {
    transition: transform 0.18s cubic-bezier(0.2, 0.7, 0.2, 1), filter 0.18s ease !important;
}

@media (hover: hover) and (pointer: fine) {
    html body #crafterView #generatedDeckList > .visual-card:hover .visual-card-art > img,
    html body #crafterView #aiChatFeed .rec-card:hover img,
    html body #crafterView #aiChatFeed .swap-card:hover img {
        transform: translateY(-3px) scale(1.04) !important;
        filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.35)) !important;
    }

    html body #crafterView #generatedDeckTitle .export-header-avatar:hover {
        z-index: 2 !important;
        transform: scale(1.08) !important;
    }

    html body #crafterView #aiChatFeed .swap-card.out:hover img {
        filter: grayscale(0.7) drop-shadow(0 6px 10px rgba(0, 0, 0, 0.35)) !important;
    }
}


#crafterView :is(button, input, summary, [role="button"]):focus-visible {
    outline: 2px solid var(--wb-accent) !important;
    outline-offset: 2px !important;
}

html body #crafterView #seedSearchInput:focus-visible,
html body #crafterView .import-link-input:focus-visible {
    outline: none !important;
}

@media (prefers-reduced-motion: reduce) {
    #crafterView *,
    #crafterView *::before,
    #crafterView *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

html body #crafterView #aiChatFeed::-webkit-scrollbar { width: 6px; }
html body #crafterView #aiChatFeed::-webkit-scrollbar-track { background: transparent; }
html body #crafterView #aiChatFeed::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.14);
    border-radius: 3px;
}

/* ---------- Completed-deck brief (Dave) ---------- */

html body #crafterView #aiChatFeed .deck-brief {
    display: grid;
    gap: 10px;
    margin-top: 10px;
    padding-top: 12px;
    border-top: 1px solid var(--wb-line);
}

#crafterView .deck-brief-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 8px;
}

#crafterView .deck-brief-name,
#crafterView .deck-brief-meta {
    color: var(--wb-dim);
    font-size: 12.5px;
}

#crafterView .deck-brief-plan {
    margin: 0;
    color: var(--wb-text-2);
    font-size: 14px;
    line-height: 1.5;
}

#crafterView .deck-brief-rows {
    display: grid;
    gap: 9px;
    margin: 0;
}

#crafterView .deck-brief-row {
    display: grid;
    gap: 1px;
}

#crafterView .deck-brief-row dt {
    color: var(--wb-dim);
    font-size: 12.5px;
    font-weight: 500;
}

#crafterView .deck-brief-row dd {
    margin: 0;
    color: var(--wb-text-2);
    font-size: 13.5px;
    line-height: 1.45;
}

#crafterView .deck-brief-arrow {
    color: var(--wb-dim);
    padding: 0 1px;
}

/* zomboss-handoff:start (Dr. Zomboss hand-off: links the free builder to the paid Deck-O-Matic) */
/* The message itself uses Crazy Dave's .dave-msg / .speech-bubble styles; only the link button is new. */
html body #crafterView #aiChatFeed .zomboss-handoff { margin-top: 12px !important; }
html body #crafterView #aiChatFeed .zomboss-handoff strong { color: var(--wb-text); }
html body #crafterView #aiChatFeed .zomboss-handoff .zh-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    margin-top: 10px;
}
html body #crafterView #aiChatFeed .zomboss-handoff .zh-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 30px;
    padding: 0 12px 0 4px;
    border: 1px solid var(--wb-line-strong);
    border-radius: 8px;
    background: transparent;
    color: var(--wb-text-2) !important;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    word-break: normal !important;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
html body #crafterView #aiChatFeed .zomboss-handoff .zh-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--wb-text) !important;
}
html body #crafterView #aiChatFeed .zomboss-handoff .zh-btn:focus-visible { outline: 2px solid var(--wb-accent); outline-offset: 2px; }
html body #crafterView #aiChatFeed .zomboss-handoff .zh-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--wb-raised);
}
html body #crafterView #aiChatFeed .zomboss-handoff .zh-alt {
    color: var(--wb-muted) !important;
    font-size: 13px;
    text-decoration: underline;
    word-break: normal !important;
}
html body #crafterView #aiChatFeed .zomboss-handoff .zh-alt:hover { color: var(--wb-text) !important; }
/* Finish deck stays free; budget builds are a Deck-O-Matic job, so its budget dropdown is hidden. */
html body #crafterView #benchTools #finishOptionsWrap .tb-caret,
html body #crafterView #benchTools #finishOptionsWrap .action-options-menu { display: none !important; }
html body #crafterView #benchTools #finishOptionsWrap .tb-main { border-top-right-radius: 9px !important; border-bottom-right-radius: 9px !important; }
@media (max-width: 720px) {
    /* Mobile: Crazy Dave's panel always shows, so its toggle goes and Finish deck gets its icon back. */
    html body #crafterView #benchTools #toggleDavePanelBtn { display: none !important; }
    html body #crafterView #benchTools #finishOptionsWrap .tb-main .tb-icon { display: inline-block !important; }
}
@media (min-width: 371px) and (max-width: 720px) {
    /* Import, Finish and Save share the row equally. */
    html body #crafterView #benchTools > .tb-split,
    html body #crafterView #benchTools > .tb-btn { flex: 1 1 0 !important; min-width: 0 !important; }
    html body #crafterView #benchTools > .tb-split > .tb-btn:first-child { flex: 1 1 auto !important; width: 100% !important; }
}
/* zomboss-handoff:end */
