/* Catalogue is a picker; roster is the primary workspace. */
#tcModule .tc-builder-view .tc-builder-40k-layout{grid-template-columns:minmax(0,calc(var(--tc-catalog-percent,50%) - 9px)) 18px minmax(0,1fr);gap:0;align-items:start}
#tcModule .tc-builder-40k-layout>.tc-catalog-stack{grid-column:1;grid-row:1}
#tcModule .tc-builder-40k-layout>.tc-roster-panel{grid-column:3;grid-row:1;min-width:0}
#tcModule .tc-builder-resizer{grid-column:2;grid-row:1;align-self:stretch;min-height:320px;display:flex;align-items:flex-start;justify-content:center;cursor:col-resize;touch-action:none;background:transparent;color:var(--tc-gold);position:relative;user-select:none}
#tcModule .tc-builder-resizer:before{content:'';position:absolute;top:0;bottom:0;width:3px;background:var(--tc-edge)}
#tcModule .tc-builder-resizer span{position:sticky;top:45%;z-index:1;border:1px solid var(--tc-edge);background:var(--tc-card);font-size:19px;padding:8px 2px;line-height:1}
#tcModule .tc-builder-resizer:hover:before,#tcModule .tc-builder-resizer:focus-visible:before{background:var(--tc-gold)}
#tcModule .tc-catalog-panel .tc-unit-card-compact{padding:7px 8px;margin:5px 0;min-height:46px;border-radius:0}
#tcModule .tc-unit-card-compact .tc-unit-main{display:grid;grid-template-columns:minmax(0,1fr) auto 38px;gap:9px;align-items:center}
#tcModule .tc-unit-card-compact .tc-unit-title{min-width:0;display:block}
#tcModule .tc-unit-card-compact .tc-unit-title h4{font-size:12px;line-height:1.3;margin:0;overflow-wrap:anywhere}
#tcModule .tc-unit-card-compact .tc-unit-cost{display:flex;align-items:baseline;gap:3px;white-space:nowrap;min-width:0;flex-direction:column;text-align:right}
#tcModule .tc-unit-card-compact .tc-unit-cost b{font-size:13px}
#tcModule .tc-unit-card-compact .tc-unit-cost small{font-size:9px}
#tcModule .tc-unit-card-compact .tc-catalog-eye{width:38px;height:38px;min-width:38px;display:grid;place-items:center}
#tcModule .tc-catalog-limit{display:block;font-size:10px}
#tcModule .tc-ds-add-actions{position:sticky;bottom:0;background:var(--tc-card);padding:12px 0 4px;border-top:1px solid var(--tc-edge);z-index:2}
#tcModule .tc-ds-add-actions button{width:100%;min-height:48px;border-radius:0;font-weight:800}
@media(max-width:1100px){#tcModule .tc-builder-view .tc-builder-40k-layout{display:flex;flex-direction:column;gap:10px}#tcModule .tc-builder-40k-layout>.tc-roster-panel{order:1;width:100%;box-sizing:border-box}#tcModule .tc-builder-40k-layout>.tc-catalog-stack{order:2;width:100%;box-sizing:border-box}#tcModule .tc-builder-resizer{display:none}}
@media(max-width:700px){#tcModule .tc-catalog-panel .tc-unit-card-compact{padding:6px 8px}#tcModule .tc-unit-card-compact .tc-unit-main{grid-template-columns:minmax(0,1fr) auto 44px}#tcModule .tc-unit-card-compact .tc-catalog-eye{width:44px;height:44px}#tcModule .tc-roster-panel .tc-roster-unit-head{gap:6px}}

/* both columns start equal; direct add is always visible. */
#tcModule .tc-builder-view .tc-builder-40k-layout{grid-template-columns:minmax(0,calc(var(--tc-catalog-percent,50%) - 9px)) 18px minmax(0,1fr)}
#tcModule .tc-unit-card-compact .tc-unit-main{grid-template-columns:minmax(0,1fr) auto 38px auto;gap:7px}
#tcModule .tc-unit-card-compact .tc-catalog-add{min-height:38px;min-width:82px;border:1px solid var(--tc-gold);border-radius:0;background:var(--tc-card);color:var(--tc-ink);font-size:10px;font-weight:850;padding:6px 9px;cursor:pointer}
#tcModule .tc-unit-card-compact .tc-catalog-add:disabled{opacity:.45;cursor:not-allowed}
#tcModule .tc-unit-card-compact .tc-catalog-add:focus-visible{outline:2px solid var(--tc-gold);outline-offset:2px}
@media(max-width:700px){#tcModule .tc-unit-card-compact .tc-unit-main{grid-template-columns:minmax(0,1fr) auto 44px auto;gap:5px}#tcModule .tc-unit-card-compact .tc-catalog-add{min-height:44px;min-width:68px;padding:5px 6px;font-size:9px}}

/* restore page scrolling and make the roster fill the catalogue's full row.
   Override 07/08 desktop sticky, viewport-clipped scroll regions and any old theme rules. */
@media (min-width:1101px){
  #tcModule .tc-builder-view .tc-builder-40k-layout{align-items:stretch!important;grid-template-columns:minmax(0,calc(var(--tc-catalog-percent,50%) - 9px)) 18px minmax(0,1fr)!important}
  #tcModule .tc-builder-40k-layout>.tc-roster-panel{position:static!important;top:auto!important;max-height:none!important;height:auto!important;min-height:100%!important;overflow:visible!important;overflow-y:visible!important;overscroll-behavior:auto!important;scrollbar-gutter:auto!important;align-self:stretch!important}
  #tcModule .tc-builder-40k-layout>.tc-catalog-stack{align-self:stretch!important}
}
@media (max-width:1100px){
 #tcModule .tc-builder-40k-layout>.tc-roster-panel{position:static!important;max-height:none!important;height:auto!important;overflow:visible!important;overscroll-behavior:auto!important;scrollbar-gutter:auto!important}
}
#tcModule .tc-builder-view .tc-roster-panel .tc-total{position:static!important;top:auto!important}
#tcModule .tc-builder-view .tc-roster-panel{border-radius:0!important}

/* theme contrast and builder toolbar alignment.
   Theme-scoped to avoid changing the rules engine or other games. */
#tcModule .tc-builder-view > .tc-builder-nav {
  box-sizing:border-box; width:auto; margin-inline:16px; border-radius:0;
}
#tcModule .tc-builder-view .tc-builder-40k-layout .tc-catalog-panel,
#tcModule .tc-builder-view .tc-builder-40k-layout .tc-roster-panel {border-radius:0}
/* The light/imperial palette uses a legible neutral paper instead of dark cards
   carrying inherited dark text. Keep the established font families. */
body.theme-light #tcModule .tc-builder-view {
  --tc-paper:#eeeeea;--tc-card:#f7f7f4;--tc-ink:#161616;--tc-soft:#454545;--tc-edge:#a9a9a2;
}
body.theme-light #tcModule .tc-builder-view .tc-builder-nav,
body.theme-light #tcModule .tc-builder-view .tc-catalog-panel,
body.theme-light #tcModule .tc-builder-view .tc-roster-panel {
  background:#eeeeea!important;color:#161616!important;border-color:#aaa9a0!important;
}
body.theme-light #tcModule .tc-builder-view .tc-catalog-search,
body.theme-light #tcModule .tc-builder-view .tc-category,
body.theme-light #tcModule .tc-builder-view .tc-category-content,
body.theme-light #tcModule .tc-builder-view .tc-unit-card,
body.theme-light #tcModule .tc-builder-view .tc-unit-card-compact,
body.theme-light #tcModule .tc-builder-view .tc-roster-setup,
body.theme-light #tcModule .tc-builder-view .tc-total,
body.theme-light #tcModule .tc-builder-view .tc-roster-unit,
body.theme-light #tcModule .tc-builder-view .tc-roster-kit,
body.theme-light #tcModule .tc-builder-view .tc-warband-notes,
body.theme-light #tcModule .tc-builder-view .tc-mercenary-panel,
body.theme-light #tcModule .tc-builder-view .tc-court-sin {
  background:#e1e1dc!important;color:#181818!important;border-color:#aaa9a0!important;
}
body.theme-light #tcModule .tc-builder-view .tc-category summary,
body.theme-light #tcModule .tc-builder-view .tc-unit-title,
body.theme-light #tcModule .tc-builder-view .tc-unit-title h4,
body.theme-light #tcModule .tc-builder-view .tc-roster-panel h3,
body.theme-light #tcModule .tc-builder-view .tc-roster-unit-head,
body.theme-light #tcModule .tc-builder-view .tc-roster-setup summary,
body.theme-light #tcModule .tc-builder-view .tc-roster-kit summary,
body.theme-light #tcModule .tc-builder-view .tc-total > span,
body.theme-light #tcModule .tc-builder-view .tc-catalog-search label {color:#171717!important;font-weight:750}
body.theme-light #tcModule .tc-builder-view small,
body.theme-light #tcModule .tc-builder-view .tc-catalog-limit {color:#4a4a46!important}
body.theme-light #tcModule .tc-builder-view .tc-catalog-shortcuts a,
body.theme-light #tcModule .tc-builder-view .tc-catalog-eye,
body.theme-light #tcModule .tc-builder-view .tc-catalog-add,
body.theme-light #tcModule .tc-builder-view .tc-builder-nav button {
  background:#f7f7f4!important;color:#171717!important;border-color:#93938b!important;
}
body.theme-light #tcModule .tc-builder-view .tc-catalog-add:disabled {opacity:.58}
body.theme-light #tcModule .tc-builder-view .tc-catalog-search input {
  background:#fff!important;color:#171717!important;border-color:#93938b!important;
}
/* Imperial/bordeaux theme: make catalogue typography readable against dark panels. */
body.theme-bordeaux #tcModule .tc-builder-view .tc-catalog-panel,
body.theme-bordeaux #tcModule .tc-builder-view .tc-category,
body.theme-bordeaux #tcModule .tc-builder-view .tc-unit-card-compact,
body.theme-bordeaux #tcModule .tc-builder-view .tc-catalog-search {color:#f7f2e9!important}
body.theme-bordeaux #tcModule .tc-builder-view .tc-unit-title h4,
body.theme-bordeaux #tcModule .tc-builder-view .tc-category summary,
body.theme-bordeaux #tcModule .tc-builder-view .tc-catalog-search label {color:#f7f2e9!important;font-weight:750}
@media(max-width:1100px){#tcModule .tc-builder-view > .tc-builder-nav{margin-inline:0}}

/* Imperial theme uses a two-surface contrast system:
   dark catalogue with cream lettering, parchment roster with dark lettering.
   Scoped to the Trench builder and the actual theme-imperial body class. */
body.theme-imperial #tcModule .tc-builder-view {
 --tc-edge:#9e8a67; --tc-gold:#c89a32;
}
body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel {
 background:#e8dfca!important;color:#2b241b!important;border-color:#ae9871!important;
}
body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel .tc-catalog-search,
body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel .tc-category-fold,
body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel .tc-category,
body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel .tc-category-content,
body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel .tc-unit-card,
body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel .tc-unit-card-compact,
body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel .tc-mercenary-fold {
 background:#302c26!important;color:#f5eddb!important;border-color:#665943!important;
}
body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel .tc-category-fold>summary,
body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel .tc-category summary,
body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel .tc-category summary *,
body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel .tc-unit-title,
body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel .tc-unit-title h4,
body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel .tc-unit-card-compact .tc-unit-main,
body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel .tc-catalog-search>label,
body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel .tc-catalog-limit,
body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel #tcSearchCount {
 color:#f5eddb!important;text-shadow:none!important;
}
body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel small,
body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel .tc-category-fold>summary small {
 color:#d8c8a9!important;
}
body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel .tc-catalog-shortcuts a,
body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel .tc-catalog-add,
body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel .tc-catalog-eye,
body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel .tc-catalog-search-row button {
 background:#201e1a!important;color:#f8e9be!important;border:1px solid #9a7b3b!important;
}
body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel .tc-catalog-add:disabled {
 opacity:.64!important;color:#d3c7b3!important;cursor:not-allowed;
}
body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel .tc-catalog-search-row input {
 background:#f7f0df!important;color:#221e17!important;border:1px solid #b3a17c!important;
}
body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel .tc-unit-cost b{color:#f0c35d!important}
body.theme-imperial #tcModule .tc-builder-view .tc-roster-panel,
body.theme-imperial #tcModule .tc-builder-view .tc-builder-nav {
 background:#e8dfca!important;color:#29231c!important;border-color:#ad9974!important;
}
body.theme-imperial #tcModule .tc-builder-view .tc-roster-panel .tc-roster-setup,
body.theme-imperial #tcModule .tc-builder-view .tc-roster-panel .tc-roster-kit,
body.theme-imperial #tcModule .tc-builder-view .tc-roster-panel .tc-total,
body.theme-imperial #tcModule .tc-builder-view .tc-roster-panel .tc-kit-fold,
body.theme-imperial #tcModule .tc-builder-view .tc-roster-panel .tc-fireteams,
body.theme-imperial #tcModule .tc-builder-view .tc-roster-panel .tc-warband-notes {
 background:#dcd1b9!important;color:#28231c!important;border-color:#aa9879!important;
}
body.theme-imperial #tcModule .tc-builder-view .tc-roster-panel .tc-total,
body.theme-imperial #tcModule .tc-builder-view .tc-roster-panel .tc-total *,
body.theme-imperial #tcModule .tc-builder-view .tc-roster-panel .tc-roster-setup summary,
body.theme-imperial #tcModule .tc-builder-view .tc-roster-panel .tc-kit-fold summary,
body.theme-imperial #tcModule .tc-builder-view .tc-roster-panel .tc-roster-unit-head,
body.theme-imperial #tcModule .tc-builder-view .tc-roster-panel .tc-roster-unit-head strong,
body.theme-imperial #tcModule .tc-builder-view .tc-roster-panel h3,
body.theme-imperial #tcModule .tc-builder-view .tc-builder-nav button {
 color:#29231c!important;text-shadow:none!important;
}
body.theme-imperial #tcModule .tc-builder-view .tc-roster-panel .tc-save-warband,
body.theme-imperial #tcModule .tc-builder-view .tc-builder-nav button {
 background:#353027!important;color:#f5ecd7!important;border:1px solid #a58c54!important;
}
body.theme-imperial #tcModule .tc-builder-view .tc-roster-panel .tc-save-warband {color:#f5ecd7!important}
body.theme-imperial #tcModule .tc-builder-view button:focus-visible,
body.theme-imperial #tcModule .tc-builder-view a:focus-visible,
body.theme-imperial #tcModule .tc-builder-view summary:focus-visible {outline:3px solid #c89a32!important;outline-offset:2px}
@media(hover:hover){
 body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel .tc-catalog-shortcuts a:hover,
 body.theme-imperial #tcModule .tc-builder-view .tc-catalog-panel .tc-catalog-add:not(:disabled):hover {background:#51452f!important;color:#fff4d8!important}
}

/* ===== tc-variant-bar ===== */
/* Warband Variant selector and its rules, above the builder columns. */
#tcModule .tc-variant-bar{display:flex;flex-wrap:wrap;gap:10px 16px;align-items:flex-start;margin:0 0 12px;padding:10px 12px;border:1px solid var(--tc-edge,var(--line,#524e43));background:var(--tc-card,var(--panel2,#302e28));color:var(--tc-ink,var(--text,#eee9dd))}
#tcModule .tc-variant-bar>label{display:flex;flex-direction:column;gap:4px;min-width:min(100%,280px)}
#tcModule .tc-variant-bar>label span{font-size:11px;font-weight:800;letter-spacing:.08em;color:var(--tc-gold,var(--accent,#c9a350))}
#tcModule .tc-variant-bar select{min-height:40px;padding:6px 8px;max-width:100%;font:inherit;color:inherit;background:transparent;border:1px solid var(--tc-edge,var(--line,#524e43))}
#tcModule .tc-variant-bar select option{color:#161616;background:#f7f7f4}
#tcModule .tc-variant-rules{flex:1 1 320px;min-width:0}
#tcModule .tc-variant-rules summary{cursor:pointer;min-height:40px;display:flex;align-items:center;font-weight:700}
#tcModule .tc-variant-rules ul{margin:6px 0 0;padding-left:18px;display:grid;gap:8px}
#tcModule .tc-variant-rules li{line-height:1.4;overflow-wrap:anywhere}
#tcModule .tc-variant-source{display:block;opacity:.75;margin-bottom:4px}
#tcModule .tc-campaign-bar{align-items:flex-start}
#tcModule .tc-campaign-bar>small{flex:1 1 220px;align-self:center;opacity:.75}
#tcModule .tc-variant-bar>label.tc-campaign-toggle{flex-direction:row;align-items:center;gap:8px;min-width:0;min-height:40px;cursor:pointer}
#tcModule .tc-campaign-bar>label:not(.tc-campaign-toggle){flex:1 1 240px}
#tcModule .tc-campaign-toggle input{width:20px;height:20px;margin:0;flex:none}
#tcModule .tc-campaign-bar input[type=number]{min-height:40px;padding:6px 8px;max-width:100%;font:inherit;color:inherit;background:transparent;border:1px solid var(--tc-edge,var(--line,#555))}
#tcModule .tc-campaign-arsenal{flex:1 1 100%;min-width:0}
#tcModule .tc-variant-notice{flex:1 1 100%;margin:0;padding:8px 10px;font-size:13px;line-height:1.4;overflow-wrap:anywhere;border:1px solid #b9822a;border-radius:6px}
#tcModule .tc-variant-auto,#tcModule .tc-variant-manual{display:inline-block;font-size:10px;font-weight:800;letter-spacing:.05em;padding:1px 6px;border:1px solid currentColor;text-transform:uppercase}
#tcModule .tc-variant-auto{color:#4f9a5a}
#tcModule .tc-variant-manual{color:#b9822a}
