/* Global: never let page chrome create horizontal scroll */
html,
body {
  max-width: 100%;
  overflow-x: clip;
}

/* Tablet / narrow desktop: drop right ad column */
@media (max-width: 1100px) {
  #contentcolumn_public {
    margin-right: 0;
  }

  #rightcolumn_public {
    float: none;
    width: 100%;
    margin: 12px 0 0;
  }

  #headerpublic_center {
    flex-direction: column;
    align-items: stretch;
  }

  div.header_menu,
  div.header_aside {
    margin-left: 0;
    width: 100%;
  }

  div.header_aside {
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  div.advertise,
  div.header_menu {
    margin-left: 0;
    justify-self: stretch;
  }

  #Navigation ul {
    justify-content: flex-start;
  }
}

/* Stack sidebar above content before content becomes too narrow */
@media (max-width: 980px) {
  #advertise_intern_big,
  #advertise_intern_small {
    display: none !important;
  }

  #headerintern_center {
    align-items: stretch;
  }

  .header_aside--intern {
    order: 0;
    width: 100%;
    margin-left: 0;
    justify-content: flex-end;
  }

  #status_div,
  #status_change_div {
    max-width: none;
  }

  #headerintern + table,
  #headerintern + table > tbody,
  #headerintern + table > tbody > tr,
  #showmenuTD,
  #showmenuTD + td {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  #showmenuTD {
    padding-right: 0 !important;
    margin-bottom: 12px;
  }

  #showmenuTD.is-collapsed {
    display: none !important;
  }

  #showmenuClip {
    width: auto;
    min-width: 0;
    margin-right: 0;
    overflow: visible;
    transition: none;
  }

  #showmenu {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px 18px;
    align-items: start;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100%;
    visibility: visible !important;
    pointer-events: auto;
  }

  #showmenuTD.is-collapsed #showmenu {
    visibility: hidden !important;
    pointer-events: none;
  }

  #showmenu .menu_group {
    min-width: 0;
    margin-bottom: 0;
  }

  #showmenu .menu_group .headed_bottom {
    margin-bottom: 0;
  }

  #showmenuTD + td {
    padding-left: 0 !important;
    overflow-x: clip;
  }

  /* Card table must respect stacked column width */
  #showmenuTD + td > table {
    width: 100% !important;
    max-width: 100% !important;
    table-layout: fixed;
  }

  #showmenuTD + td > table .body_mc,
  #showmenuTD + td > table .headline_mc,
  #showmenuTD + td > table .title_mc {
    width: auto !important;
    max-width: 100% !important;
  }

  .body_mc,
  .title_mc,
  .deepend_mc,
  .headline_mc,
  .popup_mc,
  .headed_mc {
    overflow-x: clip;
    max-width: 100%;
  }

  .title_mc,
  .headline_mc,
  .infoline_mc {
    white-space: normal !important;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* Legacy fixed-width UI pieces */
  [class^="slidemenu_"],
  [class*=" slidemenu_"] {
    width: auto !important;
    max-width: 100% !important;
  }

  .body_bc > div {
    flex-wrap: wrap;
  }

  .body_bc > div > div,
  .body_bc a,
  .body_bc p,
  .body_bc .sitegeneradedinsecondstext {
    white-space: normal;
  }

  .standardButton,
  .adminButton,
  .spoilerButton,
  .default_button,
  .jip-button {
    max-width: 100%;
    white-space: normal;
  }

  input[type="text"],
  input[type="password"],
  input[type="email"],
  textarea,
  select,
  .text,
  .password,
  .textarea,
  .select {
    max-width: 100% !important;
  }
}

@media (max-width: 760px) {
  body {
    padding: 8px;
  }

  .kekse_info_div,
  .cookie_banner_inner,
  .cookie_banner_content {
    max-width: 100%;
    box-sizing: border-box;
  }

  .cookie_banner_inner {
    padding: 12px 12px 14px;
    gap: 12px;
  }

  .menu_intern li.mainpoint {
    min-height: 36px;
    display: flex;
    align-items: center;
  }

  .menu_intern li.subpoint {
    min-height: 32px;
    display: flex;
    align-items: center;
  }

  h1 { font-size: 1.3rem; }
  h2 { font-size: 1.1rem; }

  .body_bc > div {
    flex-wrap: wrap;
    gap: 6px 10px;
  }

  /* Generierungszeit auf schmalen Viewports verzichtbar */
  .body_bc > div > div:last-child {
    display: none !important;
  }

  .cookie_banner_icon {
    width: 40px;
    height: 40px;
  }

  .cookie_banner_actions {
    flex-direction: column;
  }

  .cookie_banner_actions .default_button {
    width: 100% !important;
    max-width: 280px;
    white-space: normal;
  }

  .infoline {
    flex-direction: column;
    height: auto;
  }

  .infoline_mc {
    flex: 1 1 auto;
    width: 100% !important;
    height: auto;
    white-space: normal;
  }

  /* Wide legacy tables: full width; scroll inside cell if needed */
  .body_mc #body > center > table,
  .body_mc #body > table {
    width: 100% !important;
    max-width: 100%;
  }

  .body_mc #body table {
    max-width: 100%;
  }

  .body_mc #body td,
  .body_mc #body th {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}

/* Phones */
@media (max-width: 480px) {
  body {
    padding: 6px;
  }

  #showmenu {
    grid-template-columns: 1fr;
  }

  #headerintern,
  #headerpublic {
    border-radius: 8px;
  }

  .cc-theme-toggle__label {
    display: none;
  }

  .cc-theme-toggle {
    padding-right: 4px;
  }

  .body_mc,
  .headline_mc,
  .deepend_mc {
    padding-left: 10px;
    padding-right: 10px;
  }

  h1 { font-size: 1.2rem; }
  h2 { font-size: 1.05rem; }

  .standardButton,
  .adminButton,
  .default_button {
    min-width: 0;
    width: 100% !important;
    max-width: 100%;
  }

  .gallery_toolbar .standardButton,
  .gallery_toolbar .adminButton,
  .gallery_picture_nav .standardButton,
  .gallery_nav_btn {
    width: auto !important;
    max-width: none !important;
    flex: 0 0 auto;
  }
}
