/* Shared defaults, loaded on every page. Feature styles can refine individual layouts. */
:root {
  word-break: keep-all;
  overflow-wrap: anywhere;
  line-break: strict;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

:where(button, input, select, textarea) {
  min-inline-size: 0;
  max-inline-size: 100%;
  box-sizing: border-box;
  word-break: inherit;
}

:where(h1, h2, h3, p, label, button, summary) {
  text-wrap: pretty;
}

:where(fieldset, article, section, form, figure, dl, dd) {
  min-inline-size: 0;
}

:where(img, video, canvas, iframe) {
  max-inline-size: 100%;
}

:where(dialog) {
  box-sizing: border-box;
  max-inline-size: calc(100% - 1.5rem);
  max-block-size: calc(100dvh - 1.5rem);
  overflow: auto;
}

/* New toolbars wrap their controls as units before the labels need to wrap. */
:where(nav, [role="toolbar"], [role="tablist"]) { flex-wrap: wrap; }
:where(nav, [role="toolbar"], [role="tablist"]) > :where(a, button, select) {
  flex-shrink: 0;
  max-inline-size: 100%;
}

@media (max-width: 48rem) {
  :where(main, header, footer, aside, nav, fieldset) { min-inline-size: 0; }
  :where(input, select, textarea) { scroll-margin-block: 1rem; }
  :where(pre) { max-inline-size: 100%; overflow-x: auto; }
  :where(dialog) { overscroll-behavior: contain; }
}
