/* Data tables: expand instead of scrolling */
.table-wrapper:not(:has(.highlighttable)) {
  overflow: visible !important;
}

.table-wrapper:not(:has(.highlighttable)) table {
  table-layout: auto;
  width: 100%;
}

.table-wrapper:not(:has(.highlighttable)) td,
.table-wrapper:not(:has(.highlighttable)) th {
  white-space: normal;
  overflow-wrap: break-word;
}

/* Keep inline code in data tables on one line */
.table-wrapper:not(:has(.highlighttable)) code {
  white-space: nowrap;
}

/* Mobile: let tables scroll horizontally and code wrap */
@media (max-width: 768px) {
  .table-wrapper:not(:has(.highlighttable)) {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .table-wrapper:not(:has(.highlighttable)) code {
    white-space: normal;
    word-break: break-all;
  }

  .md-typeset__table {
    overflow-x: auto !important;
  }

  .md-typeset .md-typeset__scrollwrap {
    overflow-x: auto !important;
  }

  /* Prevent code blocks from overflowing viewport */
  .md-typeset pre {
    max-width: 100%;
    overflow-x: auto;
  }
}

/* Source code tables: horizontal scroll, no height cap */
.table-wrapper:has(.highlighttable) {
  overflow-x: auto !important;
}

.highlighttable {
  table-layout: fixed;
  width: 100%;
}

.highlighttable .linenos {
  width: 3.5em;
  white-space: nowrap;
}

.highlighttable .code {
  overflow-x: auto;
}

.highlighttable pre {
  max-height: none;
}

/* Material theme fallbacks */
.md-typeset__table {
  overflow: visible !important;
}

.md-typeset .md-typeset__scrollwrap {
  overflow: visible !important;
}
