@media (max-width: 768px) {
  .filterbox {
    width: 100%;
    max-width: 100vw;
    margin-left: 0;
    margin-right: 0;
    box-sizing: border-box;
    overflow-x: auto;
  }
  .filterbox ul {
    width: 100%;
    padding-left: 0;
    margin-left: 0;
    margin-right: 0;
    box-sizing: border-box;
  }
  .filterbox li {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 0.7em;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5em;
  }
  .filterbox label,
  .filterbox input,
  .filterbox select {
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Responsive table plan for mobile, matching dashboard.css/public_new_plan.html */
  table.sortable, .table_plan, .table-plan, .table_plan_wrapper {
    display: block;
    width: 100vw;
    max-width: 100vw;
    overflow-x: auto;
    border-radius: 14px;
    background: linear-gradient(120deg, #f8fafc 80%, #eaf6fb 100%);
    box-shadow: 0 4px 18px rgba(0,0,0,0.10);
    font-size: 0.97em;
    margin-bottom: 1.2em;
    border: 1.5px solid #e0e6ef;
    position: relative;
  }
  table.sortable thead, .table_plan thead {
    display: table-header-group;
    background: #eaf6fb;
    position: sticky;
    top: 0;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0,160,210,0.07);
  }
  table.sortable tr, .table_plan tr {
    border-bottom: 1px solid #f0f2f7;
  }
  table.sortable th, table.sortable td, .table_plan th, .table_plan td {
    min-width: 120px;
    white-space: nowrap;
    padding: 0.7em 0.4em;
    text-align: left;
  }
  table.sortable td, .table_plan td {
    background: #fcfcff;
    border-right: 1px solid #e0e6ef;
    border-bottom: 1px solid #e0e6ef;
    position: relative;
    box-shadow: 0 1px 4px rgba(0,160,210,0.04);
    transition: box-shadow 0.18s;
  }
  table.sortable th:last-child, table.sortable td:last-child, .table_plan th:last-child, .table_plan td:last-child {
    border-right: none;
  }
  /* Scroll hint arrow */
  table.sortable::after, .table_plan::after {
    content: '\27A1  scroll';
    position: absolute;
    right: 1.2em;
    bottom: 0.7em;
    top: auto;
    font-size: 1em;
    font-weight: 600;
    color: #4fa3d1;
    background: linear-gradient(90deg, #f4fafd 80%, #eaf6fb 100%);
    padding: 0.11em 0.9em 0.11em 0.6em;
    border-radius: 14px;
    border: 1.2px solid #b3e0ff;
    z-index: 10;
    pointer-events: none;
    letter-spacing: 0.01em;
    box-shadow: 0 2px 8px rgba(0,160,210,0.07);
    display: block;
    margin-bottom: 0.2em;
    opacity: 0.93;
    animation: scrollhint-pulse 1.6s infinite alternate;
  }
  @keyframes scrollhint-pulse {
    0% { box-shadow: 0 2px 8px rgba(0,160,210,0.07); opacity: 0.93; }
    100% { box-shadow: 0 3px 12px rgba(0,160,210,0.11); opacity: 0.98; }
  }
}

@media (max-width: 900px) {
  thead#fixed_header {
    display: none !important;
  }
  /* Mobile table plan styles to match personal_plan.css */
  table.sortable, .table_plan, .table-plan, .table_plan_wrapper {
    display: block;
    width: 105vw;
    max-width: 105vw;
    overflow-x: auto;
    border-radius: 14px;
    background: linear-gradient(120deg, #f8fafc 80%, #eaf6fb 100%);
    box-shadow: 0 4px 18px rgba(0,0,0,0.10);
    font-size: 0.97em;
    margin-bottom: 1.2em;
    border: 1.5px solid #e0e6ef;
    position: relative;
  }
  table.sortable::after, .table_plan::after {
    content: '\27A1  scroll';
    position: absolute;
    right: 1.2em;
    bottom: 0.7em;
    top: auto;
    font-size: 1em;
    font-weight: 600;
    color: #4fa3d1;
    background: linear-gradient(90deg, #f4fafd 80%, #eaf6fb 100%);
    padding: 0.11em 0.9em 0.11em 0.6em;
    border-radius: 14px;
    border: 1.2px solid #b3e0ff;
    z-index: 10;
    pointer-events: none;
    letter-spacing: 0.01em;
    box-shadow: 0 2px 8px rgba(0,160,210,0.07);
    display: block;
    margin-bottom: 0.2em;
    opacity: 0.93;
    animation: scrollhint-pulse 1.6s infinite alternate;
  }
  @keyframes scrollhint-pulse {
    0% { box-shadow: 0 2px 8px rgba(0,160,210,0.07); opacity: 0.93; }
    100% { box-shadow: 0 3px 12px rgba(0,160,210,0.11); opacity: 0.98; }
  }
  table.sortable thead, .table_plan thead {
    display: table-header-group;
    background: #eaf6fb;
    position: sticky;
    top: 0;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0,160,210,0.07);
  }
  table.sortable tr, .table_plan tr {
    border-bottom: 1px solid #f0f2f7;
  }
  table.sortable th, table.sortable td, .table_plan th, .table_plan td {
    min-width: 130px;
    white-space: nowrap;
    padding: 0.7em 0.4em;
    text-align: left;
    font-size: 1.05em;
  }
  table.sortable td, .table_plan td {
    background: #fcfcff;
    border-right: 1px solid #e0e6ef;
    border-bottom: 1px solid #e0e6ef;
    position: relative;
    box-shadow: 0 1px 4px rgba(0,160,210,0.04);
    transition: box-shadow 0.18s;
  }
  table.sortable th:last-child, table.sortable td:last-child, .table_plan th:last-child, .table_plan td:last-child {
    border-right: none;
  }
  /* Table title row (colspan=6) */
  table.plan.sortable tr td[colspan],
  table.plan tr td[colspan],
  .table_plan tr td[colspan] {
    background: #eaf6fb !important;
    color: #0077b6 !important;
    font-size: 1.18em !important;
    font-weight: bold !important;
    text-align: center;
    border-radius: 12px 12px 0 0;
    border-bottom: 2px solid #b3c6d9;
    letter-spacing: 0.01em;
    padding: 1em 0.4em !important;
  }
  /* Weekday header cells (Montag, Dienstag, ...) */
  table.plan.sortable thead.plan tr:nth-child(2) td,
  table.plan thead.plan tr:nth-child(2) td,
  .table_plan thead tr:nth-child(2) td {
    background: #eaf6fb !important;
    color: #0077b6 !important;
    font-weight: bold !important;
    font-size: 1.05em !important;
    text-align: center;
    border-bottom: 2px solid #b3c6d9;
    letter-spacing: 0.01em;
    padding: 0.85em 0.4em !important;
  }

  /* Block plan table: match student dashboard look */
  table.block_plan, .block_plan_wrapper, .block-plan-table {
    display: block;
    width: 105vw;
    max-width: 105vw;
    overflow-x: auto;
    border-radius: 14px;
    background: linear-gradient(120deg, #f8fafc 80%, #eaf6fb 100%);
    box-shadow: 0 4px 18px rgba(0,0,0,0.10);
    font-size: 0.97em;
    margin-bottom: 1.2em;
    border: 1.5px solid #e0e6ef;
    position: relative;
  }
  table.block_plan::after, .block_plan_wrapper::after, .block-plan-table::after {
    content: '\27A1  scroll';
    position: absolute;
    right: 1.2em;
    bottom: 0.7em;
    top: auto;
    font-size: 1em;
    font-weight: 600;
    color: #4fa3d1;
    background: linear-gradient(90deg, #f4fafd 80%, #eaf6fb 100%);
    padding: 0.11em 0.9em 0.11em 0.6em;
    border-radius: 14px;
    border: 1.2px solid #b3e0ff;
    z-index: 10;
    pointer-events: none;
    letter-spacing: 0.01em;
    box-shadow: 0 2px 8px rgba(0,160,210,0.07);
    display: block;
    margin-bottom: 0.2em;
    opacity: 0.93;
    animation: scrollhint-pulse 1.6s infinite alternate;
  }
  @keyframes scrollhint-pulse {
    0% { box-shadow: 0 2px 8px rgba(0,160,210,0.07); opacity: 0.93; }
    100% { box-shadow: 0 3px 12px rgba(0,160,210,0.11); opacity: 0.98; }
  }
  table.block_plan thead, .block_plan_wrapper thead, .block-plan-table thead {
    display: table-header-group;
    background: #eaf6fb;
    position: sticky;
    top: 0;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0,160,210,0.07);
  }
  table.block_plan tr, .block_plan_wrapper tr, .block-plan-table tr {
    border-bottom: 1px solid #f0f2f7;
  }
  table.block_plan th, table.block_plan td, .block_plan_wrapper th, .block_plan_wrapper td, .block-plan-table th, .block-plan-table td {
    min-width: 130px;
    white-space: nowrap;
    padding: 0.7em 0.4em;
    text-align: left;
    font-size: 1.05em;
  }
  table.block_plan td[colspan], .block_plan_wrapper td[colspan], .block-plan-table td[colspan] {
    background: #eaf6fb !important;
    color: #0077b6 !important;
    font-size: 1.18em !important;
    font-weight: bold !important;
    text-align: center;
    border-radius: 12px 12px 0 0;
    border-bottom: 2px solid #b3c6d9;
    letter-spacing: 0.01em;
    padding: 1em 0.4em !important;
  }
  table.block_plan thead tr:nth-child(2) td, .block_plan_wrapper thead tr:nth-child(2) td, .block-plan-table thead tr:nth-child(2) td {
    background: #eaf6fb !important;
    color: #0077b6 !important;
    font-weight: bold !important;
    font-size: 0.90em !important;
    text-align: center;
    border-bottom: 2px solid #b3c6d9;
    letter-spacing: 0.01em;
    padding: 0.85em 0.4em !important;
  }
  /* Consistent font size for all text in block plan table on mobile */
  table.block_plan, .block_plan_wrapper, .block-plan-table,
  table.block_plan th, table.block_plan td,
  .block_plan_wrapper th, .block_plan_wrapper td,
  .block-plan-table th, .block-plan-table td {
    font-size: 0.70em !important;
  }
  table.block_plan th, table.block_plan td,
  .block_plan_wrapper th, .block_plan_wrapper td,
  .block-plan-table th, .block-plan-table td {
    font-size: 0.70em !important;
  }
  table.block_plan td[style*="font-size"],
  .block_plan_wrapper td[style*="font-size"],
  .block-plan-table td[style*="font-size"] {
    font-size: 0.70em !important;
  }
} 

@media (max-width: 900px) {
  table.block_plan, .block_plan_wrapper, .block-plan-table,
  table.block_plan th, table.block_plan td,
  .block_plan_wrapper th, .block_plan_wrapper td,
  .block-plan-table th, .block-plan-table td,
  table.block_plan a, .block_plan_wrapper a, .block-plan-table a {
    font-size: 0.90em !important;
  }
  table.block_plan td[style*="font-size"],
  .block_plan_wrapper td[style*="font-size"],
  .block-plan-table td[style*="font-size"] {
    font-size: 0.90em !important;
  }
  /* Responsive style for Modulkataloge PDF section heading */
  h3 {
    font-size: 1.08em;
    font-weight: 700;
    color: #0077b6;
    margin: 1.2em 0 0.7em 0;
    padding: 0.2em 0.5em;
    width: 100%;
    box-sizing: border-box;
    text-align: left;
    background: none;
    border-radius: 0;
  }
  .left_column {
    width: 100% !important;
    max-width: 100vw;
    box-sizing: border-box;
    padding: 0;
    margin: 0 0 1.2em 0;
    overflow-x: auto;
  }
} 

@media (max-width: 768px) {
  /* Responsive module description table */
  .module-description-table,
  .module-description-table table,
  .module-description-table > table {
    display: block;
    width: 100vw;
    max-width: 100vw;
    overflow-x: auto;
    border-radius: 14px;
    background: linear-gradient(120deg, #f8fafc 80%, #eaf6fb 100%);
    box-shadow: 0 4px 18px rgba(0,0,0,0.10);
    font-size: 0.97em;
    margin-bottom: 1.2em;
    border: 1.5px solid #e0e6ef;
    position: relative;
  }
  .module-description-table table tr {
    border-bottom: 1px solid #f0f2f7;
  }
  .module-description-table table td,
  .module-description-table table th {
    min-width: 120px;
    white-space: pre-line;
    padding: 0.7em 0.4em;
    text-align: left;
    font-size: 1.05em;
    background: #fcfcff;
    border-right: 1px solid #e0e6ef;
    border-bottom: 1px solid #e0e6ef;
    position: relative;
    box-shadow: 0 1px 4px rgba(0,160,210,0.04);
    transition: box-shadow 0.18s;
  }
  .module-description-table table td.left {
    background: #eaf6fb !important;
    color: #0077b6 !important;
    font-weight: bold;
    min-width: 110px;
    text-align: left;
    border-right: 2px solid #b3c6d9;
  }
  .module-description-table table td.no_padding {
    padding: 0 !important;
  }
  .module-description-table table.embedded {
    margin: 0.5em 0 0.5em 0;
    border-radius: 10px;
    background: #f8fafc;
    box-shadow: 0 2px 8px rgba(0,160,210,0.07);
    font-size: 0.95em;
    width: 100%;
    display: block;
    overflow-x: auto;
  }
  .module-description-table table.embedded td,
  .module-description-table table.embedded th {
    min-width: 90px;
    font-size: 0.95em;
    padding: 0.5em 0.3em;
  }
  .module-description-table h1 {
    font-size: 1.25em !important;
    word-break: break-word;
    margin-bottom: 0.7em;
    margin-top: 0.5em;
    color: #d90429 !important;
    text-align: left;
    padding-left: 0.2em;
  }
} 

@media (max-width: 768px) {
  /* Move scroll hint further left only for consultation list table */
  table.consultation-list.sortable::after {
    right: 12.2em;
  }
  /* Move scroll hint further down for exam consultation table */
  table.exam-consultation-list.sortable::after {
    bottom: -1.8em;
  }
} 

@media (max-width: 900px), (max-width: 768px) {
  /* Allow module column to wrap and show full text on mobile for courses table */
  table.sortable td.module, table.sortable th.module {
    white-space: normal !important;
    word-break: break-word;
    max-width: 90vw;
  }
  /* Move scroll hint further left for courses table only */
  table.sortable:not(.consultation-list):not(.block_plan)::after {
    right: 4.2em;
  }
} 
@media (max-width: 768px) {
  .back-to-top {
    position: fixed;
    bottom: 1.6em;
    right: 1.2em;
    z-index: 999;
    background-color: rgba(0, 160, 210, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    padding: 0.75em;
    font-size: 1.2em;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    cursor: pointer;

    /* Smooth transition setup */
    display: block;            /* always in DOM */
    opacity: 0;                /* invisible by default */
    transform: translateY(20px);
    pointer-events: none;      /* not clickable until shown */
    transition: opacity 0.3s ease, transform 0.3s ease;
  }

  .back-to-top.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }

  .back-to-top i {
    display: inline-block;
    line-height: 1;
    font-size: 1.2em;
  }
}
