/* Shared spacing and secondary-action contract. Loaded after page themes.
   Scope to controls/containers: never add margins to every descendant. */
:root { --ui-gap: 12px; --ui-panel-pad: 24px; --ui-edge: 16px; }
body :is(button.quiet, button.btn:not(.primary), a.btn:not(.primary):not(.primary-link)) {
  background: transparent; box-shadow: none;
}
body :is(button.quiet, button.btn:not(.primary), a.btn:not(.primary):not(.primary-link)):hover:not(:disabled) {
  background: transparent; color: var(--accent, #0965db); text-decoration: underline; text-underline-offset: 3px;
}
body :is(button, a.btn):focus-visible { outline: 2px solid var(--accent, #0965db); outline-offset: 3px; }
/* Choices remain discernible without a filled pill. */
body :is(.flu-choose, .flu-modal, .motor-toolbar) button:not(.primary):not(:disabled) { background: transparent; box-shadow: none; }
body :is(.flu-choose, .flu-modal) button[aria-pressed="true"] { color: var(--accent, #0965db); text-decoration: underline; font-weight: 700; }
body :is(.flu-modal, .flu-choose) button + button { margin-inline-start: 8px; }
body :is(.flu-modal-head, .flu-modal-foot, .cp-dialog-heading, .shop-store-sheet-head, .inv-sheet-head, .rp-sheet-head, .sch-sheet-head, .je-sheet-head, .ui-dialog-head) {
  display: flex; align-items: center; justify-content: space-between; gap: var(--ui-gap);
}
body .ui-dialog-head { margin-block-end: 16px; }
body .ui-dialog-head > :is(h2,h3) { margin: 0; min-width: 0; overflow-wrap: anywhere; }
body :is(.ui-dialog-x, .ui-dialog-floating-x, .flu-modal-x) {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 44px;
  width: 44px; height: 44px; min-height: 44px; padding: 0; margin: 0;
  border: 0; border-radius: 6px; background: transparent; box-shadow: none;
  font-size: 24px; line-height: 1; color: inherit; cursor: pointer;
}
body :is(.ui-dialog-x, .ui-dialog-floating-x, .flu-modal-x):hover { background: transparent; color: var(--accent, #0965db); }
body :is(.vs-viewer-fig, .ji-lightbox) { position: relative; }
body.shop-on .main dialog.job-tool-dialog { position: fixed; inset: 6vh var(--ui-edge) auto; max-width: calc(100vw - 2 * var(--ui-edge)); margin-inline: auto; }
body .job-tool-dialog:has(.ui-dialog-floating-x) { padding-top: 64px; }
body :is(.vs-viewer-fig, .ji-lightbox):has(.ui-dialog-floating-x) { padding-top: 56px; }
body .ui-dialog-floating-x { position: absolute; top: 8px; right: 8px; z-index: 2; }
/* Wrapping actions keep their spacing on narrow screens and with long labels. */
body :is(.flu-modal-foot, .ck-sheet-actions, .ck-actions, .je-actions, .inv-actions, .rp-actions, .jc-actions, .ji-actions, .cp-actions, .shop-store-search, .vehicle-profile-footer) {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px;
}
body :is(.flu-modal-foot, .ck-sheet-actions, .vehicle-profile-footer) { justify-content: flex-end; }
body :is(dialog, .je-sheet, .inv-sheet, .rp-sheet, .sch-sheet, .jc-sheet, .flu-modal, .shop-store-sheet) {
  box-sizing: border-box; max-width: calc(100vw - 2 * var(--ui-edge)); overflow-wrap: anywhere;
}
body :is(dialog, .je-sheet, .inv-sheet, .rp-sheet, .sch-sheet, .jc-sheet, .flu-modal, .shop-store-sheet) :is(input:not([type=checkbox]):not([type=radio]), select, textarea) { max-width: 100%; box-sizing: border-box; }
body :is(dialog, [role=dialog]) label { line-height: 1.45; }
body :is(dialog, [role=dialog]) form > :is(label, fieldset) + :is(label, fieldset) { margin-top: 12px; }
body :is(dialog, [role=dialog]) fieldset { min-width: 0; }
body :is(dialog, [role=dialog]) legend { padding-inline: 4px; }
@media(max-width: 600px) {
  :root { --ui-panel-pad: 16px; --ui-edge: 10px; --ui-gap: 10px; }
  body :is(dialog, .je-sheet, .inv-sheet, .rp-sheet, .sch-sheet, .jc-sheet) { padding: var(--ui-panel-pad); max-height: calc(100dvh - 2 * var(--ui-edge)); overflow-y: auto; }
  body :is(dialog, [role=dialog]) :is(button, a.btn) { min-height: 44px; }
  body :is(.flu-modal-head, .flu-modal-foot) { gap: 10px; }
  body .flu-modal-foot { justify-content: flex-start; }
  body :is(.je-sheet, .inv-sheet, .rp-sheet, .sch-sheet, .jc-sheet) :is(h2,h3) { overflow-wrap: anywhere; }
}
