/* Mechlab page (mechlab.html): tokens from style.css, top bar / dialogs / toast from deck.css.
   Colours of the item kinds follow the game: ballistic purple, energy yellow, missile teal, AMS green, ECM orange.
   One class prefix per component (ml- Lab, ml-pick… picker, sh- mech sheet, lib- My mechs): never reuse another
   component's root class, rules with the same specificity override each other by file order. */
:root {
  --k-ballistic: #9a5cc6; --k-energy: #e6d43a; --k-missile: #4c9aa6; --k-ams: #3cb35a; --k-ecm: #e08a2c;
  --k-equip: #5d9fd3; --k-internal: #3a414c; --k-fixed: #4a5462; --slot-h: 19px;
}
.mlpage #topbar { flex-wrap: nowrap; z-index: 40; }
.mlpage #topbar > * { flex-shrink: 0; }
.ml-variant { color: var(--muted); white-space: nowrap; }
.ml-name { flex: 1 1 140px !important; width: auto; min-width: 100px; max-width: 280px; }
.ml-variant { overflow: hidden; text-overflow: ellipsis; max-width: 240px; flex-shrink: 1 !important; }
@media (max-width: 1500px) { .ml-version { display: none; } }
.ml-version { color: var(--text-faint); font-size: 11px; white-space: nowrap; }
.ml-main { display: grid; grid-template-columns: 290px minmax(0, 1fr) 330px; gap: 10px; padding: 10px 12px 40px; align-items: start; }
.ml-panel { background: var(--surface-1); border: 1px solid var(--line); padding: 8px; position: sticky; top: calc(var(--tb-h) + 8px);
  max-height: calc(100vh - var(--tb-h) - 20px); overflow: auto; }
/* tabs and segments: active = soft amber + 2px amber line (charte §7), never the flat amber */
.ml-tabs { display: flex; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.ml-tabs button { flex: 1; display: inline-flex; align-items: center; justify-content: center; min-width: 0; padding: 7px 2px; margin-bottom: -1px;
  background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted);
  font: 600 10.5px/1 var(--f-display); letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; }
.ml-tabs button .ml-ico { display: none; }
.ml-tabs button:hover { background: var(--surface-2); color: var(--text-strong); border-color: transparent; }
.ml-tabs button.on { background: var(--accent-soft); color: var(--accent); border-bottom-color: var(--accent); }
.ml-seg button.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.ml-seg { display: inline-flex; flex-wrap: wrap; gap: 2px; }
.ml-seg button { display: inline-flex; align-items: center; gap: 5px; padding: 2px 6px; font-size: 12px; }
.ml-seg .ml-ico svg { width: 14px; height: 14px; }
/* tech badge (IS / Clan): small chamfered cartouche */
.ml-tech { --cut: 3px; display: inline-block; padding: 0 5px; font: 600 10.5px/16px var(--f-data); letter-spacing: .06em;
  background: var(--line-strong); color: var(--text-strong); clip-path: var(--ch); }
.ml-seg button.on .ml-tech { background: var(--accent); color: var(--accent-ink); }
.ml-seg button:disabled { opacity: .5; cursor: default; }

/* stats */
.ml-bigs { display: grid; grid-template-columns: 1fr; gap: 2px; margin-bottom: 6px; }
.ml-big { font-size: 13px; color: var(--muted); }
.ml-big b { font: 600 17px/1.3 var(--f-data); color: var(--text-strong); font-variant-numeric: tabular-nums; }
.ml-big.bad b, .ml-row.bad .v, .bad { color: var(--danger); }
.ml-sec { border-top: 1px solid var(--line); padding: 6px 0 4px; }
.ml-sec h3 { margin: 0 0 4px; font: 600 11px/1.3 var(--f-display); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.ml-row { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; }
.ml-row .k { color: var(--muted); }
.ml-row .v { font: 12.5px/1.4 var(--f-data); font-variant-numeric: tabular-nums; text-align: right; }
.ml-row.warn .v { color: var(--accent); }
.ml-row.total { border-top: 1px dashed var(--line); margin-top: 2px; padding-top: 3px; font-weight: 600; }
.ml-issues { list-style: none; margin: 4px 0 6px; padding: 0; }
.ml-issues li { padding: 2px 6px; margin-bottom: 2px; border-left: 3px solid; font-size: 12px; }
.ml-issues li.err { border-color: var(--danger); background: var(--danger-soft); }
.ml-issues li.warn { border-color: var(--accent); background: var(--accent-soft); }
.ml-ok { color: var(--ok); margin: 4px 0 6px; }
.ml-ammo { width: 100%; border-collapse: collapse; font-size: 12px; }
.ml-ammo th { text-align: left; color: var(--muted); font-weight: 500; }
.ml-ammo td:not(:first-child), .ml-ammo th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.ml-ammo td:not(:first-child) { font-family: var(--f-data); }
.ml-ammo tr.total td { border-top: 1px solid var(--line, rgba(255,255,255,.12)); font-weight: 600; }
.ml-ammofill { margin-top: 8px; }
.ml-quirks { list-style: none; margin: 0; padding: 0; font-size: 12px; }
.ml-quirks li { display: flex; justify-content: space-between; gap: 6px; }
.ml-quirks li.good > span:last-child { color: var(--ok); }
.ml-quirks li.bad > span:last-child { color: var(--danger); }
.ml-quirks li.skill > span:last-child { color: var(--blu); }
.ml-qparts { color: var(--text-faint); font-size: 10.5px; }
.ml-qparts .good { color: var(--ok); } .ml-qparts .bad { color: var(--danger); } .ml-qparts .skill { color: var(--blu); }
.ml-preset { width: 100%; }
.ml-credit { border-top: 1px solid var(--line); padding-top: 6px; color: var(--muted); }
.muted { color: var(--muted); }

/* paperdoll: arms and side torsos around head + centre torso, legs below */
.ml-doll { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); grid-template-areas:
  "ra rt hd lt la"
  "ra rt ct lt la"
  "op rl ct ll . "; gap: 8px; align-items: start; }
.ml-opts { grid-area: op; background: var(--surface-1); border: 1px solid var(--line); padding: 6px; margin: 0 !important; border-bottom: 1px solid var(--line) !important; }
.ml-opts h3 { margin: 0 0 4px; font: 600 11px/1.3 var(--f-display); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.ml-opts .ml-up { grid-template-columns: 1fr; gap: 2px; }
.ml-opts .ml-seg { flex-wrap: nowrap; }
.ml-opts .ml-seg button { padding: 1px 4px; font-size: 11px; white-space: nowrap; flex: 1 1 auto; }
.ml-comp.c-ra { grid-area: ra; } .ml-comp.c-rt { grid-area: rt; } .ml-comp.c-hd { grid-area: hd; } .ml-comp.c-ct { grid-area: ct; }
.ml-comp.c-lt { grid-area: lt; } .ml-comp.c-la { grid-area: la; } .ml-comp.c-rl { grid-area: rl; } .ml-comp.c-ll { grid-area: ll; }
.ml-comp.c-ra, .ml-comp.c-la { margin-top: calc(var(--doll-bar) + 24px); }
/* build toolbar floating above the arms and side torsos (not a card): the side torsos move down by its height,
   their arm and leg with them; head and centre torso stay at the top */
.ml-doll { --doll-bar: 38px; position: relative; }
.ml-comp.c-rt, .ml-comp.c-lt { margin-top: var(--doll-bar); }
.ml-dollbar { position: absolute; top: 0; display: flex; align-items: center; gap: 6px; width: calc((100% - 32px) * .4 + 8px); height: 30px; }
.ml-dollbar.left { left: 0; }
.ml-dollbar.right { right: 0; justify-content: flex-end; }
.ml-dollbar .ml-name { flex: 1 1 auto !important; max-width: none; min-width: 60px; }
.ml-dollbar .dk-tbtn, .ml-dollbar select { white-space: nowrap; }
.ml-dollbar.right .dk-menu { left: auto; right: 0; }
.ml-dollbar.right { container-type: inline-size; }
.ml-dollbar .dk-tbtn { padding-inline: 8px; }
/* not enough room above the left torso and arm: tools, share and sheet show only their icon (name in the tooltip) */
@container (max-width: 560px) { .ml-dollbar.right .dk-menuwrap .dk-tbtn > span, .ml-dollbar.right #sheetBtn > span { display: none; } }
/* narrower paperdoll (1280 px and below): save and max armor show only their icon too (name in the tooltip) */
.ml-doll { container: doll / inline-size; }
@container doll (max-width: 760px) {
  .ml-dollbar #saveBtn > span, .ml-dollbar #maxArmorBtn > span { display: none; }
  .ml-dollbar #saveBtn, .ml-dollbar #maxArmorBtn { padding-inline: 8px; }
}
/* too narrow for the bars above the torsos (paperdoll under ~520 px, 1024 px screens): they take their own row
   (a media query: the grid of the paperdoll itself changes, which its own container query cannot do) */
@media (min-width: 901px) and (max-width: 1184px) {
  .ml-doll { --doll-bar: 0px; grid-template-areas: "bl bl bl br br" "ra rt hd lt la" "ra rt ct lt la" "op rl ct ll ."; }
  body.mlpage .ml-doll { grid-template-rows: auto auto auto 1fr; }
  .ml-dollbar { position: static; width: auto; min-width: 0; gap: 4px; }
  .ml-dollbar.left { grid-area: bl; }
  .ml-dollbar.right { grid-area: br; }
  .ml-dollbar .dk-tbtn { padding-inline: 6px; }
  .ml-dollbar .ml-name { min-width: 40px; }
}
.ml-comp { background: var(--surface-1); border: 1px solid var(--line); padding: 4px; min-width: 0; transition: border-color .1s, background .1s; }
.ml-comp.over { border-color: var(--danger); }
.ml-comp.drop-ok { border-color: var(--ok); background: var(--ok-soft); }
.ml-comp.drop-no { opacity: .55; }
.ml-comp header { display: flex; align-items: baseline; gap: 4px; margin-bottom: 3px; }
.ml-comp .cname { font: 700 12px/1.25 var(--f-display); color: var(--text-strong); text-transform: uppercase; letter-spacing: .08em; }
.ml-comp .chips { display: inline-flex; flex-wrap: wrap; gap: 2px; flex: 1; }
.ml-comp .slots { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.ml-hp { font-size: 10px; padding: 0 3px; border: 1px solid; line-height: 14px; }
.ml-hp.k-ballistic { color: var(--k-ballistic); } .ml-hp.k-energy { color: var(--k-energy); } .ml-hp.k-missile { color: var(--k-missile); }
.ml-hp.k-ams { color: var(--k-ams); } .ml-hp.k-ecm { color: var(--k-ecm); } .ml-hp.over { color: var(--danger); }
.ml-armorbox { margin-bottom: 4px; container-type: inline-size; }
.ml-armor-side .lbl .tiny { display: none; }
.ml-armorrow { display: flex; flex-wrap: wrap; align-items: center; gap: 0 6px; font-size: 11px; color: var(--muted); }
.ml-armor-side { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.ml-armor-side .lbl { font: 600 10.5px/1 var(--f-display); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
/* the box fits the digits shown, left aligned: the gap to the label is the same whatever the value */
.ml-armorrow input.ml-armor { width: calc(var(--digits, 2) * 1ch + 1px); padding: 0; border: 0; border-bottom: 1px solid transparent; border-radius: 0;
  background: none; font: 600 13px/18px var(--f-data); color: var(--text-strong); text-align: left; font-variant-numeric: tabular-nums; }
.ml-armorrow:not(.ro) .ml-armor-num:hover input.ml-armor { border-bottom-color: var(--line-strong); }
.ml-armorrow input.ml-armor:focus { outline: none; border-bottom-color: var(--focus); }
.ml-armorrow input.ml-armor.bad { color: var(--danger); }
/* number + its arrows: the keyboard focus ring goes around both, outside the layout */
.ml-armor-num { position: relative; display: inline-flex; align-items: center; padding-right: 13px; }
.ml-armorrow.ro .ml-armor-num { padding-right: 0; }
.ml-armor-num:has(> input.ml-armor:focus-visible) { outline: 2px solid var(--focus); outline-offset: 0; }
.ml-armor-arrows { position: absolute; right: 0; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column;
  opacity: 0; pointer-events: none; transition: opacity .1s; }
.ml-armor-num:hover .ml-armor-arrows, .ml-armor-num:focus-within .ml-armor-arrows { opacity: 1; pointer-events: auto; }
.ml-armor-arrow { position: relative; display: flex; align-items: center; justify-content: center; width: 13px; height: 10px; padding: 0;
  border: 0; border-radius: 0; background: none; color: var(--accent); cursor: pointer; }
/* larger hit area than the drawn chevron, outward only (the number keeps its own clicks) */
.ml-armor-arrow::before { content: ''; position: absolute; inset: -3px -4px 0 0; }
.ml-armor-arrow + .ml-armor-arrow::before { inset: 0 -4px -3px 0; }
.ml-armor-arrow .ml-ico { display: contents; }
.ml-armor-arrow svg { display: block; flex: none; width: 12px; height: 8px; stroke-width: 3; }
.ml-armor-arrow:hover { background: none; color: var(--text-strong); }
.ml-armor-arrow:active { color: var(--accent); }
/* narrow cards (1600 px and below): one-letter front / rear labels */
@container (max-width: 180px) {
  .ml-armorrow { column-gap: 4px; }
  .ml-armor-side { gap: 2px; }
  .ml-armor-side .lbl .long { display: none; }
  .ml-armor-side .lbl .tiny { display: inline; }
}
/* narrower (1280 px and below): no label for a single side, the card is named */
@container (max-width: 130px) { .ml-armor-side .lbl.single { display: none; } }
/* narrowest cards (1024 px): the Thai labels are words, not letters: tighter so a 3-digit value still fits */
@container (max-width: 64px) {
  .ml-armor-side .lbl { letter-spacing: 0; }
  :lang(th) .ml-armor-side .lbl { font-size: 9px; }
}
/* gauge: front from the left, rear from the right; flex shares a bar that cannot overflow its box */
.ml-armorgauge { padding: 3px 0; cursor: ew-resize; touch-action: none; }
.ml-armorgauge.ro { cursor: default; }
.ml-armor-dragging, .ml-armor-dragging * { cursor: ew-resize !important; user-select: none; }
/* empty track = points left to place */
.ml-ag-track { display: flex; height: 3px; overflow: hidden; background: var(--line-strong); }
.ml-armorgauge:not(.ro):hover .ml-ag-track { height: 5px; margin: -1px 0; }
.ml-ag-side { display: flex; flex: 0 1 auto; min-width: 0; overflow: hidden; }
.ml-ag-gap { flex: 1 1 0; min-width: 0; }
.ml-ag-seg { flex: 1 1 0; min-width: 0; }
.ml-ag-seg.placed { background: var(--text); }
.ml-ag-side.rear .ml-ag-seg.placed { background: var(--muted); }
/* quirk and skill points are fixed (not placed): hatched */
.ml-ag-seg.quirk { background: repeating-linear-gradient(135deg, var(--ok) 0 2px, transparent 2px 4px); }
.ml-ag-seg.skill { background: repeating-linear-gradient(135deg, var(--blu) 0 2px, transparent 2px 4px); }
.ml-ag-seg.over { background: var(--danger); }
.ml-armorgauge:not(.ro):hover .ml-ag-side.front { box-shadow: inset -2px 0 var(--text-strong); }
.ml-armorgauge:not(.ro):hover .ml-ag-side.rear { box-shadow: inset 2px 0 var(--text-strong); }
.ml-armorrow .struct { margin-left: auto; font-size: 12px; color: var(--text); }
.ml-armorrow .struct b { font: 600 12.5px var(--f-data); color: var(--text-strong); }
.ml-pod, .ml-act { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.ml-pod select, .ml-act select { flex: 1; min-width: 0; font-size: 11px; padding: 1px 3px; }
.ml-pod option.dim, .ml-pod optgroup { color: var(--muted); }
.ml-pod optgroup { font-style: normal; }
.ml-engine { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; font-size: 11px; margin-bottom: 3px; color: var(--muted); }
.ml-engine select { font-size: 11px; padding: 1px 3px; }
.ml-engine button { display: inline-grid; place-items: center; padding: 1px 3px; }
.ml-enginehs { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.ml-enginehs.room { color: var(--ok); }
.ml-slot.free.inengine { color: var(--text-faint); font-size: 10px; font-style: italic; }
.ml-slots { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.ml-slot { height: calc(var(--n, 1) * var(--slot-h) + (var(--n, 1) - 1) * 1px); display: flex; align-items: flex-start; gap: 4px;
  padding: 1px 4px; font-size: 11px; line-height: 16px; overflow: hidden; background: var(--surface-2); border-left: 3px solid transparent; }
.ml-slot.free { background: var(--bg); border: 1px dashed var(--line); }
.ml-slot.internal { color: var(--text-faint); background: var(--surface-1); }
.ml-slot.fixed { color: var(--muted); font-style: italic; }
.ml-slot.dynamic { color: var(--text-faint); background: repeating-linear-gradient(135deg, var(--surface-2) 0 6px, var(--surface-1) 6px 12px); }
.ml-slot.item { cursor: grab; color: var(--text-strong); }
.ml-slot.item:hover { filter: brightness(1.2); }
.ml-slot.armed, .ml-whrow.armed { outline: 2px solid var(--focus); outline-offset: -2px; }
.ml-slot .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ml-slot .tag { color: var(--muted); font-size: 10px; }
.ml-slot .rm { display: none; padding: 0 4px; line-height: 14px; font-size: 12px; background: transparent; border: 0; color: var(--muted); }
.ml-slot.item:hover .rm { display: inline-grid; place-items: center; }
.ml-slot .rm:hover { color: var(--danger); }
.ml-slot.inengine { height: var(--slot-h); opacity: .8; }
.k-ballistic { border-left-color: var(--k-ballistic) !important; } .k-energy { border-left-color: var(--k-energy) !important; }
.k-missile { border-left-color: var(--k-missile) !important; } .k-ams { border-left-color: var(--k-ams) !important; }
.k-ecm { border-left-color: var(--k-ecm) !important; }
.k-ammo, .k-heatsink, .k-jumpjet, .k-masc, .k-bap, .k-tc, .k-case, .k-module, .k-engine, .k-utility { border-left-color: var(--k-equip) !important; }

/* warehouse */
.ml-ups { display: grid; gap: 4px; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.ml-up { display: grid; grid-template-columns: 82px 1fr; align-items: center; gap: 4px; }
.ml-up .lbl { color: var(--muted); font-size: 12px; }
.ml-whbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.ml-search { flex: 1; min-width: 120px; }
.ml-whgroup { margin-bottom: 6px; }
.ml-whhead { display: grid; grid-template-columns: auto 1fr 34px 44px; gap: 4px; align-items: center; background: var(--surface-3); border-left: 4px solid; padding: 2px 6px 2px 2px; }
.ml-whhead button { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; border-radius: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.ml-whhead button.n { justify-content: flex-end; color: var(--muted); font-size: 11px; }
.ml-whhead button:hover, .ml-whhead button.on { color: var(--text-strong); }
.ml-whhead button.on::after { content: '▲'; font-size: 8px; color: var(--accent); }
.ml-whhead button.on.desc::after { content: '▼'; }
.ml-whgroup.k-ballistic .ml-whhead { border-color: var(--k-ballistic); } .ml-whgroup.k-energy .ml-whhead { border-color: var(--k-energy); }
.ml-whgroup.k-missile .ml-whhead { border-color: var(--k-missile); } .ml-whgroup.k-ams .ml-whhead { border-color: var(--k-ams); }
.ml-whhead .gname { display: inline-flex; align-items: center; gap: 4px; }
.ml-whgroup.k-ballistic .gname .ml-ico { color: var(--k-ballistic); } .ml-whgroup.k-energy .gname .ml-ico { color: var(--k-energy); }
.ml-whgroup.k-missile .gname .ml-ico { color: var(--k-missile); }
.ml-whrow { display: grid; grid-template-columns: 1fr 34px 44px; gap: 4px; padding: 1px 6px; cursor: grab; border-left: 3px solid transparent; font-size: 12px; }
.ml-whrow:hover { background: var(--surface-2); }
.ml-whrow .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.ml-whrow.nofit { opacity: .45; }
.ml-wh.drop-remove { outline: 2px dashed var(--danger); outline-offset: -4px; }

/* tooltip */
.ml-tip { position: fixed; z-index: 90; pointer-events: none; background: var(--overlay); border: 1px solid var(--line-strong); padding: 6px 8px;
  box-shadow: var(--shadow-pop); font-size: 12px; max-width: 280px; }
#tip.ml-tip { display: block; }
.ml-tip table { border-collapse: collapse; margin-top: 4px; }
.ml-tip th { text-align: left; color: var(--muted); font-weight: 400; padding-right: 10px; }
.ml-tip td { text-align: right; font-variant-numeric: tabular-nums; }
.ml-tip tr.grp th { color: var(--text-strong); padding-top: 4px; }
.ml-tip td .delta.good { color: var(--ok); }
.ml-tip td .delta.bad { color: var(--danger); }

/* mech picker */
/* Lab tabs: the picker first, then one tab per mech opened (style of the plan tabs of the map, .ptab) */
.ml-mtabs { flex: 0 0 auto; height: 34px; padding: 0 12px; background: var(--surface-1); border-bottom: 1px solid var(--line); }
.ml-mtabs .ptab { cursor: pointer; }
.ml-mtabs .ptab .ml-ico { display: grid; place-items: center; }
.ml-mtab-pick { font-weight: 600; letter-spacing: .04em; }
.ml-mtab-dirty { width: 6px; height: 6px; flex: none; background: var(--accent); }
body.ml-picking .ml-buildctl { display: none !important; }
/* picker pane: the first tab of the Lab, fills the page */
.ml-pickpane { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 10px 12px; }
body.mlpage .ml-pickpane[hidden] { display: none; }
.ml-picklist { display: block !important; max-height: none; overflow: auto; min-height: 0; }
.ml-pickch { margin-bottom: 8px; }
.ml-pickch h4 { margin: 0 0 3px; font-size: 13px; color: var(--text-strong); }
.ml-pickvars { display: flex; flex-wrap: wrap; gap: 4px; }
.ml-pickvar { display: inline-flex; flex-direction: column; align-items: flex-start; padding: 3px 7px; }
.ml-pickvar span { color: var(--muted); font-size: 11px; }
.ml-pickvar.t-hero { border-color: var(--hero); }
.ml-pickvar.t-legend { border-color: var(--branch); }

/* narrow screens: consultation only */
@media (max-width: 900px) {
  .ml-main { grid-template-columns: 1fr; }
  .ml-panel { position: static; max-height: none; }
  .ml-doll { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "hd ct" "ra la" "rt lt" "rl ll" "op op"; }
  .ml-comp.c-ra, .ml-comp.c-la, .ml-comp.c-rt, .ml-comp.c-lt { margin-top: 0; }
  .ml-dollbar { position: static; grid-column: 1 / -1; width: auto; flex-wrap: wrap; height: auto; }
  .ml-dollbar.right { justify-content: flex-start; }
}

button.danger { color: var(--danger); }
.ml-pickbody { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 10px; flex: 1; min-height: 0; }
.ml-pickinfo { background: var(--bg); border: 1px solid var(--line); padding: 6px 8px; height: 100%; overflow: auto; font-size: 12px; min-height: 0; }
.ml-pickinfo h4 { margin: 0; color: var(--text-strong); }
.ml-pickinfo table { border-collapse: collapse; width: 100%; margin: 4px 0; }
.ml-pickinfo th { text-align: left; color: var(--muted); font-weight: 400; }
.ml-pickinfo td { text-align: right; }
.ml-podq { color: var(--ok); font-size: 11px; white-space: nowrap; cursor: help; }
@media (max-width: 900px) { .ml-pickbody { grid-template-columns: 1fr; } .ml-pickinfo { display: none; } }
.ml-sec p.warn { color: var(--accent); }
.mlpage .dk-menu { min-width: 240px; } .mlpage .dk-menu button { display: block; width: 100%; text-align: left; white-space: nowrap; }

/* picker: colours of the classes and of the equipment */
.ml-flabel { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
/* picker: advanced quirk filter, blocks joined by AND, conditions of a block by OR */
.ml-advfilter { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; padding: 6px 8px; background: var(--bg); border: 1px solid var(--line); }
.ml-advfilter > p { margin: 0; font-size: 11.5px; }
.ml-advgroup { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 4px 6px; border-left: 2px solid var(--accent); background: var(--surface-1); }
.ml-advcond { display: inline-flex; align-items: center; gap: 4px; }
.ml-advquirk { width: 260px; }
.ml-advvalue { width: 72px; }
.ml-advunit { min-width: 1ch; color: var(--muted); }
.ml-advjoin, .ml-advand { color: var(--accent); font: 600 10.5px/1.6 var(--f-display); letter-spacing: .08em; text-transform: uppercase; }
.ml-advand { margin: 0; padding-left: 6px; }
.ml-advactions { display: flex; gap: 6px; }
.ml-advvals { color: var(--ok); font-family: var(--f-data); font-size: 11px; }
.ml-seg button.c-light { border-left: 3px solid var(--cls-light); } .ml-seg button.c-medium { border-left: 3px solid var(--cls-medium); }
.ml-seg button.c-heavy { border-left: 3px solid var(--cls-heavy); } .ml-seg button.c-assault { border-left: 3px solid var(--cls-assault); }
.ml-seg button.x-ecm { border-left: 3px solid var(--k-ecm); } .ml-seg button.x-jj { border-left: 3px solid var(--k-equip); }
.ml-seg button.x-masc { border-left: 3px solid var(--k-ams); }
.ml-seg button.t-hero { border-left: 3px solid var(--hero); } .ml-seg button.t-legend { border-left: 3px solid var(--branch); }
.ml-seg button.t-special { border-left: 3px solid var(--focus); }
.ml-seg button.t-trial { border-left: 3px solid var(--muted); }
.ml-pickch { margin-bottom: 2px; }
.ml-pickhead { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 4px 8px; background: var(--surface-2); border: 0; border-left: 4px solid var(--line-strong); }
.ml-pickhead:hover { background: var(--surface-3); }
.ml-pickhead.c-light { border-left-color: var(--cls-light); } .ml-pickhead.c-medium { border-left-color: var(--cls-medium); }
.ml-pickhead.c-heavy { border-left-color: var(--cls-heavy); } .ml-pickhead.c-assault { border-left-color: var(--cls-assault); }
.ml-pickhead .arrow { display: inline-grid; color: var(--muted); width: 14px; }
.ml-pickhead b { color: var(--text-strong); }
.ml-pickhead .meta { color: var(--muted); font-size: 12px; flex: 1; }
.ml-pickhead .count { color: var(--muted); font-size: 11px; border: 1px solid var(--line-strong); padding: 0 6px; }
.ml-pickch .ml-pickvars { padding: 4px 0 6px 18px; }
.ml-pickvar.t-special { border-color: var(--focus); }
.ml-pickvar.t-trial { border-color: var(--muted); }
.ml-pickpane .list.ml-picklist { display: block; max-height: none; height: 100%; }

/* stats: folding sections and gauges */
.ml-sechead { display: flex; align-items: center; gap: 6px; width: 100%; padding: 0; margin-bottom: 4px; background: none; border: 0; text-align: left; color: var(--muted); }
.ml-sechead h3 { margin: 0; }
.ml-sec.closed { padding-bottom: 2px; }
.ml-stat { margin-bottom: 2px; }
.ml-gauge { height: 3px; background: var(--surface-3); margin: 1px 0 3px; overflow: hidden; }
.ml-gauge span { display: block; height: 100%; transition: width .15s; }
.ml-gauge.ok span { background: var(--blu); } .ml-gauge.mid span { background: var(--accent); } .ml-gauge.hot span { background: var(--danger); }
.ml-gauge.heat.ok span { background: var(--ok); }
.ml-bigs .ml-gauge { height: 4px; }
.ml-opts { min-width: 0; overflow: hidden; }
.ml-opts .ml-seg { display: flex; width: 100%; }
.ml-opts .ml-seg button { flex: 1 1 0; min-width: 0; padding: 1px 2px; font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; }
.ml-opts .ml-up { grid-template-columns: minmax(0, 1fr); }
.ml-opts .ml-seg { min-width: 0; }

/* the mechlab fills the window without scrolling the page: each column scrolls on its own */
html:has(body.mlpage) { overflow: hidden; height: 100%; }
body.mlpage { height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
body.mlpage > .dk-notice { flex: 0 0 auto; }
body.mlpage .ml-main { flex: 1 1 auto; min-height: 0; padding: 10px 12px; }
body.mlpage .ml-main[hidden] { display: none; }
body.mlpage .ml-panel { position: static; height: 100%; max-height: none; }
body.mlpage .ml-main { align-items: stretch; }
body.mlpage .ml-doll { height: 100%; overflow: auto; grid-template-rows: auto auto 1fr; }
body.mlpage .ml-opts { align-self: end; }
body.mlpage .ml-doll > .ml-comp { align-self: start; }
@media (max-width: 900px) {
  html:has(body.mlpage), body.mlpage { overflow: auto; height: auto; }
  body.mlpage { display: block; }
  body.mlpage .ml-panel, body.mlpage .ml-doll { height: auto; }
}
/* quirks by family: icon rail on the left (name in the tooltip), rows on the right; per-component quirks as chips */
.ml-qgroups { display: flex; flex-direction: column; gap: 4px; }
.ml-qgroup { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 6px; }
.ml-qrail { display: flex; align-items: flex-start; justify-content: center; padding: 2px 0 0; margin: 0; background: var(--surface-2); border: 0;
  border-left: 2px solid var(--q-color, var(--line-strong)); border-radius: 0; color: var(--q-color, var(--muted)); }
button.ml-qrail:hover { background: var(--surface-3); }
.ml-qgroup.q-weapons { --q-color: var(--k-ballistic); } .ml-qgroup.q-mobility { --q-color: var(--blu); }
.ml-qgroup.q-support { --q-color: var(--k-missile); } .ml-qgroup.q-survival { --q-color: var(--ok); }
.ml-qgroup.q-ammo { --q-color: var(--muted); }
.ml-qfold { margin: 0; padding: 1px 0; color: var(--muted); font: 600 10.5px/16px var(--f-display); letter-spacing: .06em; text-transform: uppercase; }
.ml-quirks li > span:last-child { font-family: var(--f-data); font-size: 11.5px; white-space: nowrap; }
.ml-quirks li.ml-qmerged { flex-direction: column; gap: 2px; padding-bottom: 2px; }
.ml-quirks li.ml-qmerged > span:last-child { font-family: inherit; white-space: normal; }
.ml-qchips { display: flex; flex-wrap: wrap; gap: 2px 4px; }
.ml-qchip { display: inline-flex; gap: 4px; padding: 0 4px; background: var(--surface-2); font: 10.5px/16px var(--f-data); color: var(--muted); }
.ml-qchip b { font-weight: 600; }
.ml-qchip.good b { color: var(--ok); } .ml-qchip.bad b { color: var(--danger); } .ml-qchip.skill b { color: var(--blu); }
.ml-pickq { margin: 8px 0 4px; color: var(--muted); font: 600 11px/1.3 var(--f-display); letter-spacing: .08em; text-transform: uppercase; }

/* ---------------------------------------------------------------- Analysis tab (js/mechlab/analysis-tab.js) */
.an-ctrl { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 2px 0 6px; }
.an-seg { margin: 2px 0 4px; }
.an-target { width: 110px; }
.ml-sec .viz { margin: 4px 0 2px; }


/* picker paperdoll (paperdoll.js): outline with side labels, target centred on the cockpit while hovered */
.ml-pickvar.has-doll { padding: 4px 6px 3px; gap: 1px; }
.ml-pickdoll { display: block; }
.ml-pickdoll .ml-pickdoll-shape { display: block; overflow: visible; }
.ml-pickdoll .ml-pickdoll-target { display: none; overflow: visible; }
.ml-pickvar:hover .ml-pickdoll .ml-pickdoll-shape, .ml-pickvar:focus-visible .ml-pickdoll .ml-pickdoll-shape { display: none; }
.ml-pickvar:hover .ml-pickdoll .ml-pickdoll-target, .ml-pickvar:focus-visible .ml-pickdoll .ml-pickdoll-target { display: block; }
.ml-pickdoll-outline { fill: none; stroke: var(--text); stroke-width: 1; stroke-linejoin: round; }
.ml-pickdoll-leader { fill: none; stroke: var(--line-strong); stroke-width: .9; stroke-linejoin: round; }
.ml-pickdoll-lbl { font: 700 10px var(--f-data); paint-order: stroke; stroke: var(--bg); stroke-width: 3px; stroke-linejoin: round; }
.ml-pickdoll-side { font: 600 9px var(--f-data); fill: var(--text-faint); }
.ml-pickdoll-axis { stroke: var(--text-faint); stroke-width: .8; }
.ml-pickdoll-ring { fill: none; stroke: var(--line-strong); stroke-width: .8; }
.ml-pickdoll-cockpit { fill: var(--accent); stroke: var(--bg); stroke-width: .8; }
.ml-pickdoll .k-ballistic { fill: var(--k-ballistic); color: var(--k-ballistic); } .ml-pickdoll .k-energy { fill: var(--k-energy); color: var(--k-energy); }
.ml-pickdoll .k-missile { fill: var(--k-missile); color: var(--k-missile); } .ml-pickdoll .k-ams { fill: var(--k-ams); color: var(--k-ams); }
.ml-pickdoll .k-ecm { fill: var(--k-ecm); color: var(--k-ecm); }
.ml-pickdoll-slot { stroke: var(--bg); stroke-width: .8; }
.ml-pickdoll-slot.arm { stroke: currentColor; stroke-width: 1.4; fill: var(--bg); }

/* picker: hardpoint filter (grid B/E/M/AMS x components), advanced block, weapon capacity */
.ml-hpf { display: flex; flex-direction: column; gap: 6px; }
.ml-hpfspeed { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ml-hpfgrid { display: flex; flex-direction: column; gap: 3px; }
.ml-hpfrow { display: flex; flex-wrap: nowrap; align-items: center; gap: 6px 10px; padding: 2px 6px; border-left: 3px solid var(--line-strong); }
.ml-hpfrow.k-ballistic { border-left-color: var(--k-ballistic); } .ml-hpfrow.k-energy { border-left-color: var(--k-energy); }
.ml-hpfrow.k-missile { border-left-color: var(--k-missile); } .ml-hpfrow.k-ams { border-left-color: var(--k-ams); }
.ml-hpfrow.k-ecm { border-left-color: var(--k-ecm); }
.ml-hpfrow.active { background: var(--surface-1); }
.ml-hpflabel { display: inline-flex; gap: 6px; align-items: baseline; width: 120px; text-align: left; background: none; border: 0; padding: 0; }
.ml-hpflabel b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ml-hpflabel .short { display: none; }
.ml-hpfcounter { display: inline-flex; align-items: center; gap: 4px; min-width: 96px; }
.ml-hpfcounter b { min-width: 3ch; text-align: center; }
.ml-hpf .adv { display: none; }
.ml-hpf.is-adv .adv { display: inline-block; }
.ml-hpf.is-adv .ml-hpfblock.adv { display: flex; }
.ml-hpfopts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; padding-top: 6px; border-top: 1px solid var(--line); }
.ml-hpfresult { margin: 0; display: flex; flex-wrap: nowrap; gap: 4px 12px; font-size: 12px; white-space: nowrap; }
.ml-hpfblock { display: flex; flex-direction: column; gap: 4px; padding: 4px 6px; border-left: 2px solid var(--accent); background: var(--surface-1); }
.ml-hpfnote { margin: 0; font-size: 11.5px; }
.ml-hpfdoll { display: grid; grid-template-columns: repeat(5, 44px); grid-template-areas: ". . hd . ." "ra rt ct lt la" ". rl . ll ."; gap: 3px; }
.ml-hpfdoll button { padding: 3px 0; font-size: 11px; }
.ml-hpfdoll button.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.ml-hpfdoll .d-hd { grid-area: hd; } .ml-hpfdoll .d-ct { grid-area: ct; } .ml-hpfdoll .d-lt { grid-area: lt; } .ml-hpfdoll .d-rt { grid-area: rt; }
.ml-hpfdoll .d-la { grid-area: la; } .ml-hpfdoll .d-ra { grid-area: ra; } .ml-hpfdoll .d-ll { grid-area: ll; } .ml-hpfdoll .d-rl { grid-area: rl; }
.ml-pickcell { display: inline-flex; flex-direction: column; align-items: stretch; gap: 2px; max-width: 100%; }
.ml-pickflat { padding-left: 0; }
.ml-pickextra { display: flex; flex: 1; flex-direction: column; gap: 2px; padding: 2px 4px; font-size: 11px; max-width: 260px; }
.ml-pickline { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; }
.ml-hpfhit { font-family: var(--f-data); } .ml-hpfhit.k-ballistic { color: var(--k-ballistic); } .ml-hpfhit.k-energy { color: var(--k-energy); }
.ml-hpfhit.k-missile { color: var(--k-missile); } .ml-hpfhit.k-ams { color: var(--k-ams); } .ml-hpfhit.k-ecm { color: var(--k-ecm); }
.ml-hpfpods { color: var(--ok); cursor: help; }
.ml-hpfcap { display: flex; flex: 1; flex-direction: column; gap: 2px; }
/* same height for every cell of a line: the button sits at the bottom */
.ml-hpfcap .ml-hpfopen { margin-top: auto; align-self: flex-start; padding: 2px 8px; font-size: 10.5px; }
.ml-hpfcount { font-size: 13px; }
.ml-hpfstats { color: var(--muted); font-family: var(--f-data); }
/* full type name, its letter on a narrow screen */
@media (max-width: 700px) { .ml-hpflabel { width: auto; } .ml-hpflabel .full { display: none; } .ml-hpflabel .short { display: inline; } .ml-hpfdoll { grid-template-columns: repeat(5, 1fr); } }

/* picker: compact filter bar. Row 1: search, weapon (+ its options), sort, import. Row 2: class and tech inline,
   the other filters as buttons opening a popover (fixed: it covers the list, never pushes it). Row 3: count and
   active filters. Every control of the rows is 28px high. */
.ml-pickbar { display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; margin-bottom: 6px; min-width: 0; }
.ml-pickfield { position: relative; display: flex; align-items: center; min-width: 0; }
.ml-pickfield > i, .ml-pickfield > .ml-ico { position: absolute; left: 8px; display: inline-grid; place-items: center; line-height: 0; color: var(--muted); pointer-events: none; }
.ml-pickfield svg { width: 14px; height: 14px; }
.ml-pickfield > input { width: 100%; height: 28px; padding: 0 8px 0 28px; box-sizing: border-box; background: var(--bg); }
.ml-picksearch { flex: 1 1 320px; max-width: 440px; }
.ml-pickweapon { display: flex; align-items: center; gap: 6px; flex: 0 1 300px; min-width: 150px; }
.ml-pickweapon .ml-pickfield { flex: 1 1 auto; }
.ml-pickweapon > .ml-pfwrap { flex: none; }
.ml-picksort { flex: none; margin-left: auto; white-space: nowrap; }
.ml-picksort select { height: 28px; max-width: 170px; }
.ml-pickpane #pickImport { flex: none; height: 28px; white-space: nowrap; }
/* narrow windows: the import keeps its icon (name in the tooltip), the search gets the room */
@media (max-width: 1279px) { .ml-pickpane #pickImport > span, .ml-picksort > span { display: none; } .ml-picksort select { max-width: 150px; } }
.ml-pickfilters { display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; margin-bottom: 6px; min-width: 0; }
.ml-pickfilters > .ml-seg { flex: none; flex-wrap: nowrap; }
.ml-pickfilters > .ml-seg button { height: 28px; padding: 0 6px; }
.ml-pickfilters > .ml-seg.techs { padding-right: 8px; border-right: 1px solid var(--line); }
.ml-pickpops { display: flex; flex-wrap: nowrap; align-items: center; gap: 4px; min-width: 0; }
/* a label shrinks with an ellipsis rather than overflow the bar (long words, many active filters, narrow window) */
.ml-pfwrap { display: inline-flex; flex: 0 1 auto; min-width: 0; }
.ml-pfwrap[hidden] { display: none; }
.ml-pfbtn { display: inline-flex; align-items: center; gap: 5px; min-width: 0; max-width: 100%; height: 28px; padding: 0 5px 0 8px; font-size: 12px; white-space: nowrap; }
.ml-pflabel { min-width: 3em; overflow: hidden; text-overflow: ellipsis; }
.ml-pfcount, .ml-pfbtn > .ml-ico { flex: none; }
.ml-pfbtn .ml-ico { color: var(--muted); transition: transform .15s; }
.ml-pfbtn .ml-ico svg { width: 14px; height: 14px; }
.ml-pfbtn[aria-expanded="true"] { background: var(--surface-3); border-color: var(--line-strong); }
.ml-pfbtn[aria-expanded="true"] .ml-ico { transform: rotate(180deg); }
.ml-pfbtn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.ml-pfcount { min-width: 16px; padding: 0 4px; box-sizing: border-box; font: 600 11px/16px var(--f-data); text-align: center; background: var(--accent); color: var(--accent-ink); }
.ml-pfcount:empty { display: none; }
.ml-pfpop { position: fixed; z-index: 45; box-sizing: border-box; width: max-content; min-width: 220px; overflow: auto; padding: 10px 12px;
  background: var(--overlay); border: 1px solid var(--line-strong); box-shadow: var(--shadow-pop); }
.ml-pfpop[hidden] { display: none; }
.ml-pfpop:focus { outline: none; }
.ml-pfpop .ml-seg.ml-pfcol { flex-direction: column; align-items: stretch; }
.ml-pfpop .ml-seg button { min-height: 26px; }
.ml-pfpop .ml-advfilter { max-width: 600px; margin: 0; padding: 0; background: none; border: 0; }
.ml-hpfweaponopts, .ml-hpfpresets { display: flex; flex-direction: column; gap: 8px; }
.ml-hpfweaponopts .ml-hpfnote { max-width: 420px; }
.ml-hpfpresetname, .ml-hpfpresetsel { width: 220px; }
.ml-pickweaponin { min-width: 0; }
.ml-pickstatus { display: flex; align-items: center; gap: 6px 12px; min-height: 28px; margin-bottom: 6px; min-width: 0; }
.ml-pickstatus .ml-hpfresult { flex: none; }
.ml-pickchips { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; max-height: 52px; overflow-y: auto; }
.ml-pickchip { display: inline-flex; align-items: center; gap: 2px; height: 24px; max-width: 300px; box-sizing: border-box; padding: 0 2px 0 8px;
  font-size: 12px; color: var(--text-strong); background: var(--accent-soft); border: 1px solid var(--accent); border-left-width: 3px; }
.ml-pickchip.c-light { border-left-color: var(--cls-light); } .ml-pickchip.c-medium { border-left-color: var(--cls-medium); }
.ml-pickchip.c-heavy { border-left-color: var(--cls-heavy); } .ml-pickchip.c-assault { border-left-color: var(--cls-assault); }
.ml-pickchip.x-ecm { border-left-color: var(--k-ecm); } .ml-pickchip.x-jj { border-left-color: var(--k-equip); } .ml-pickchip.x-masc { border-left-color: var(--k-ams); }
.ml-pickchiptext { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ml-pickchipx { display: inline-grid; place-items: center; flex: none; width: 18px; height: 18px; padding: 0; background: none; border: 0; color: var(--muted); }
.ml-pickchipx:hover { background: var(--surface-3); color: var(--text-strong); }
.ml-pickchipx svg { width: 12px; height: 12px; }
.ml-pickclear { flex: none; height: 24px; padding: 0 8px; }
.ml-pickclear[hidden] { display: none; }
.ml-hpfmobility { display: grid; grid-template-columns: repeat(4, auto); align-items: center; gap: 8px 6px; }
.ml-hpfmobility > .ml-hpfspeed { display: contents; }
/* class buttons: full name, one letter or icon only (picked by fitClassLabels in picker.js) */
.ml-pickfilters .ml-clslong, .ml-pickfilters .ml-clsshort { white-space: nowrap; }
.ml-pickfilters:not([data-class-labels="full"]) .ml-clslong,
.ml-pickfilters[data-class-labels="full"] .ml-clsshort,
.ml-pickfilters[data-class-labels="icon"] .ml-clsshort { display: none; }

/* tablet landscape (900-1184 px): narrower side panels, paperdoll on 4 columns so the component cards keep readable
   names and usable selects. Below 900 px the mobile shell (mechlab-mobile.css) takes over. */
@media (min-width: 900px) and (max-width: 1184px) {
  .ml-main { grid-template-columns: clamp(190px, 19vw, 220px) minmax(0, 1fr) clamp(230px, 23vw, 260px); gap: 8px; }
  body.mlpage .ml-main { padding-inline: 8px; }
  .ml-panel { padding: 6px; }
  .ml-doll { --doll-bar: 0px; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px;
    grid-template-areas: "bl bl br br" "ra rt lt la" "hd ct ct op" "rl rl ll ll"; }
  body.mlpage .ml-doll { grid-template-rows: auto auto auto auto; align-content: start; }
  .ml-comp.c-ra, .ml-comp.c-la, .ml-comp.c-rt, .ml-comp.c-lt { margin-top: 0; }
  .ml-dollbar { flex-wrap: wrap; }
  .ml-dollbar .ml-name { flex: 1 1 90px !important; min-width: 70px; }
  .ml-dollbar #saveTarget { max-width: 100px; }
  .ml-comp .cname { font-size: 11px; letter-spacing: .04em; overflow-wrap: anywhere; }
  .ml-comp header { flex-wrap: wrap; row-gap: 1px; }
  .ml-slot { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  body.mlpage .ml-opts { align-self: start; }
  /* component selects (omnipods, actuators) and the engine stay inside their card */
  .ml-pod, .ml-act { flex-wrap: wrap; }
  .ml-pod select, .ml-act select { flex: 1 1 100%; width: 100%; }
  .ml-engine { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 3px; align-items: center; }
  .ml-engine > * { min-width: 0; }
  .ml-engine select { width: 100%; text-overflow: ellipsis; }
  .ml-whbar { flex-direction: column; align-items: stretch; }
  .ml-tabs button { font-size: 10px; letter-spacing: 0; padding-inline: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ml-whrow .nm, .ml-whrow > :first-child { overflow-wrap: anywhere; }
  .ml-search { min-width: 0; }
}
@media (min-width: 900px) and (max-width: 1184px) and (pointer: coarse) {
  .ml-comp select, .ml-engine select, .ml-engine button, .ml-dollbar .dk-tbtn, .ml-dollbar select, .ml-dollbar input,
  .ml-opts .ml-seg button, .ml-tabs button, .ml-search, .ml-wh select { min-height: var(--touch, 44px); }
  .ml-dollbar .dk-tbtn.sq, .ml-engine button { min-width: var(--touch, 44px); }
  .ml-whrow, .ml-whhead { min-height: var(--touch, 44px); align-items: center; }
}

/* touch tablets (>= 900 px): 44 px targets; dense lists grow their hit area with padding + negative margin
   so the visual layout stays the same */
@media (min-width: 900px) and (pointer: coarse) {
  .ml-mtabs .ptab { min-height: var(--touch); }
  .ml-mtabs .ptab .more { width: var(--touch); height: var(--touch); margin: -11px -17px -11px -11px; }
  .ml-sechead { padding: 15px 0; margin: -15px 0 -11px; }
  .skl-edit { min-height: var(--touch); }
  .ml-qgroup { grid-template-columns: 36px minmax(0, 1fr); }
  .ml-qrail { margin-left: -8px; }
  .ml-dollbar .dk-tbtn { min-width: var(--touch); min-height: var(--touch); }
  .ml-armorrow input.ml-armor { box-sizing: border-box; width: var(--touch); padding: 13px 0; text-align: center; font-size: 16px;
    margin: -13px calc((var(--digits, 2) * 1ch + 1px - var(--touch)) / 2); }
  .ml-engine select, .ml-comp select, .ml-wh select { font-size: 16px; }
  .ml-opts .ml-seg button { min-width: var(--touch); }
  .ml-whbar .dk-inline { min-height: var(--touch); }
  .ml-whhead button { min-height: var(--touch); }
  .ml-whhead button.fold { min-width: var(--touch); margin: 0 -26px 0 -16px; justify-content: center; }
  .ml-whhead button.n { min-width: var(--touch); justify-self: end; justify-content: center; }
  .ml-pickhead { min-height: var(--touch); }
  .ml-pickpane #pickImport, .ml-pfbtn, .ml-pickfilters > .ml-seg button, .ml-pickpane .search, .ml-pickpane select.sort,
  .ml-pickweaponin { height: var(--touch); min-height: var(--touch); }
  .ml-pickpane #pickImport, .ml-pickfilters > .ml-seg button { min-width: var(--touch); }
}
