/*
 * Site-wide mobile layout for VT SuperDARN.
 *
 * Loaded after Tailwind and Flowbite so these rules can resize buttons,
 * form controls, and page chrome without rewriting every template.
 *
 * Breakpoints match Tailwind:
 *   767px  — below md (phones and large phones)
 *   639px  — below sm
 *   479px  — compact phones
 */

/* Prevent iOS from inflating text and keep tap highlights subtle. */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* -------------------------------------------------------------------------- */
/* Phones and large phones                                                    */
/* -------------------------------------------------------------------------- */
@media (max-width: 767px) {
  /* ---- Page chrome ---- */
  nav.bg-HokieMaroon > div {
    padding: 0.5rem 0.75rem;
  }

  nav.bg-HokieMaroon .self-center {
    font-size: 1.05rem;
    line-height: 1.25;
  }

  nav [data-drawer-toggle="logo-sidebar"] {
    min-width: 44px;
    min-height: 44px;
    padding: 0.5rem;
  }

  nav a[href*="login"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.5rem 0.85rem;
  }

  nav img.w-10.h-10 {
    width: 2.75rem;
    height: 2.75rem;
  }

  #dropdown-user {
    right: 0.5rem;
    left: auto;
    max-width: calc(100vw - 1rem);
  }

  aside#logo-sidebar {
    width: min(18rem, 88vw);
  }

  #logo-sidebar button,
  #logo-sidebar a {
    min-height: 44px;
  }

  #logo-sidebar a,
  #logo-sidebar span {
    white-space: normal;
  }

  #main-body {
    padding: 0.5rem;
    margin-left: 0;
  }

  #main-body > main {
    margin-top: 3.25rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    padding-top: 0.75rem;
  }

  #footer {
    margin: 0.75rem 0 0;
    width: 100%;
  }

  /* ---- Shared tap-target size ---- */
  #main-body button,
  #main-body [type="button"],
  #main-body [type="submit"],
  #main-body [type="reset"] {
    min-height: 44px;
  }

  /* Primary actions should span the screen instead of sitting in a cramped row. */
  #main-body #submitButton,
  #main-body #btn-plot,
  #main-body #download-button,
  #main-body button[type="submit"],
  #main-body [id^="btn-"] {
    width: 100%;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* Keep icon-only and overlay controls compact but still tappable. */
  #main-body .rti-info-trigger,
  #main-body [id$="_zoom_in"],
  #main-body [id$="_zoom_out"],
  #main-body [id$="_zoom_reset"],
  #main-body [id$="_download_btn"],
  #main-body [id$="_modal_close"],
  #gallery-close,
  #gallery-prev,
  #gallery-next {
    width: auto;
    min-width: 44px;
    min-height: 44px;
  }

  #main-body .rti-info-trigger {
    width: 1.75rem;
    min-width: 1.75rem;
    height: 1.75rem;
    min-height: 1.75rem;
  }

  /* Carousel arrows stay overlaid; enlarge the visible hit circle. */
  [data-carousel] [data-carousel-prev] span,
  [data-carousel] [data-carousel-next] span {
    width: 2.75rem;
    height: 2.75rem;
  }

  /* ---- Forms and feature rows ---- */
  #main-body select,
  #main-body textarea,
  #main-body input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]) {
    width: 100%;
    max-width: 100%;
    min-height: 44px;
    font-size: 16px; /* stops iOS zoom-on-focus */
  }

  #main-body input[type="checkbox"],
  #main-body input[type="radio"] {
    width: 1.25rem;
    height: 1.25rem;
  }

  /* Stack desktop-only form rows (date/radar/time controls) to full width. */
  #main-body .flex.gap-4 {
    flex-wrap: wrap;
  }

  #main-body .flex.gap-4 > * {
    flex: 1 1 100%;
    min-width: 0;
    max-width: 100%;
    width: 100%;
  }

  /* Baseband has two explicit desktop field rows; force each field onto its
     own line instead of relying on flex wrapping alone. */
  #baseband_image_modal ~ .grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }

  #baseband_image_modal ~ .grid > .flex {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 1rem;
    margin-bottom: 0;
  }

  #baseband_image_modal ~ .grid > .flex > div {
    flex: none;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  /* Interactive Fan parameters */
  #main-body #fan-primary-parameters {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
  }

  #main-body #fan-primary-parameters > div,
  #main-body #fan-date-parameters > div,
  #main-body #fan-value-parameters > div,
  #main-body #fan-coordinate-options > div {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  #main-body #fan-date-parameters,
  #main-body #fan-value-parameters,
  #main-body #fan-coordinate-options {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  #main-body #fan-display-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    margin-top: 1rem;
  }

  #main-body #fan-display-options > div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    min-width: 0;
    padding: 0.65rem 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background: white;
  }

  #main-body #fan-display-options > div > label {
    line-height: 1.35;
  }

  #main-body #fan-display-options > div > input[type="checkbox"] {
    grid-column: 2;
    grid-row: 1;
    margin: 0;
  }

  #main-body #fan-recalc-option,
  #main-body #fan-movie-option {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  #main-body #fan-recalc-option > input[type="checkbox"],
  #main-body #fan-movie-option > input[type="checkbox"] {
    align-self: flex-start;
  }

  #main-body #fan-recalc-option > label,
  #main-body #fan-movie-option > label {
    margin-left: 0;
  }

  #main-body #fan-recalc-option > div,
  #main-body #fan-movie-option > div {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
  }

  #main-body #fan-radar-toggles {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
  }

  #main-body #fan-radar-toggles button {
    width: 100%;
    white-space: normal;
    line-height: 1.3;
  }

  /* data library and historical geoactivity browser pages section */
  
  #main-body #day-data-panels {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 1rem;
    width: 100%;
    max-width: 100%;
  }

  #main-body #day-data-panels > div,
  #main-body #radar-activity-panel,
  #main-body #data-library-panel {
    flex: none;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  #main-body #radarActivityGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  #main-body #radarActivityGrid > div {
    min-width: 0;
    padding-left: 0.35rem;
    padding-right: 0.35rem;
    font-size: 1rem;
    text-align: center;
    overflow-wrap: anywhere;
  }

  #main-body #dayStatsPlaceholder {
    width: 100%;
    max-width: 100%;
    overflow: visible;
    white-space: normal;
    text-overflow: clip;
  }

  #main-body .data-library-format-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    width: 100%;
    min-width: 0;
    margin-bottom: 0.85rem;
  }

  #main-body .data-library-format-label {
    width: 100%;
    max-width: 100%;
    margin-right: 0;
    overflow-wrap: anywhere;
  }

  #main-body .data-library-availability-boxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    width: 100%;
    max-width: 100%;
  }

  #main-body .data-library-availability-box {
    flex: 0 0 1.25rem;
    width: 1.25rem;
    height: 1.25rem;
    margin: 0;
  }

  #main-body #data-library-calendar-header {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    width: 100%;
  }

  #main-body #data-library-calendar-header #calendarHeader {
    grid-column: 1 / -1;
    grid-row: 1;
    margin-bottom: 0.25rem;
    font-size: 1.25rem;
    line-height: 1.4;
    text-align: center;
  }

  #main-body #data-library-calendar-header #prevYearBtn {
    grid-column: 1;
    grid-row: 2;
  }

  #main-body #data-library-calendar-header #nextYearBtn {
    grid-column: 2;
    grid-row: 2;
  }

  #main-body #data-library-calendar-header #prevMonthBtn {
    grid-column: 1;
    grid-row: 3;
  }

  #main-body #data-library-calendar-header #nextMonthBtn {
    grid-column: 2;
    grid-row: 3;
  }

  #main-body #data-library-calendar-header button {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 0.55rem 0.5rem;
    white-space: normal;
    font-size: 0.875rem;
    line-height: 1.25;
  }

  #main-body .flex.items-center.gap-6 {
    flex-wrap: wrap;
    width: 100%;
    justify-content: stretch;
    gap: 0.5rem;
  }

  #main-body .flex.items-center.gap-6 > * {
    flex: 1 1 calc(50% - 0.5rem);
    min-width: 9rem;
  }

  #main-body .flex.items-center.gap-6 > #range-label {
    flex: 1 1 100%;
    text-align: center;
    padding: 0.25rem 0;
  }

  /* Hour:minute pairs stay on one line. */
  #main-body .flex.gap-2 {
    flex-wrap: nowrap;
    align-items: center;
  }

  #main-body .flex.gap-2 > select {
    width: auto;
    flex: 1 1 0;
  }

  /* Keep the real-time hour/minute values visible. */
  #main-body #realtime-time-range {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0.75rem;
    width: 100%;
  }

  #main-body #realtime-time-range > div {
    display: flex;
    width: 100%;
    min-width: 0;
  }

  #main-body #realtime-time-range > div > .flex {
    display: grid;
    grid-template-columns: minmax(4.5rem, 1fr) auto minmax(4.5rem, 1fr);
    align-items: center;
    gap: 0.5rem;
    width: 100%;
  }

  #main-body #realtime-time-range > div:nth-child(2) {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 0.5rem;
  }

  #main-body #realtime-time-range select {
    width: 100%;
    min-width: 4.5rem;
    min-height: 44px;
    padding: 0.5rem 0.75rem;
    background-color: white;
    color: #111827;
    -webkit-text-fill-color: #111827;
    font-size: 16px;
    line-height: 1.25;
    opacity: 1;
  }

  /* ---- Navigation clusters (plot day/beam, geoactivity, quick-browse) ---- */
  #main-body .pagination,
  #main-body nav[aria-label="View navigation"] ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
    justify-content: stretch;
  }

  #main-body .pagination > *,
  #main-body nav[aria-label="View navigation"] li {
    flex: 1 1 calc(50% - 0.5rem);
    min-width: 8.5rem;
  }

  #main-body .pagination a,
  #main-body .pagination button,
  #main-body nav[aria-label="View navigation"] a,
  #main-body nav[aria-label="View navigation"] button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    text-align: center;
  }

  /* Keep the quick date-change controls compact. */
  #main-body #daily-multi-radar-date-controls,
  #main-body #convection-date-controls,
  #main-body #daily-geoactivity-date-controls {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
    max-width: 28rem;
    margin-inline: auto;
  }

  #main-body #daily-multi-radar-date-controls > li,
  #main-body #convection-date-controls > li,
  #main-body #daily-geoactivity-date-controls > li {
    width: auto;
    min-width: 0;
  }

  #main-body #daily-multi-radar-date-controls button,
  #main-body #convection-date-controls button,
  #main-body #daily-geoactivity-date-controls button {
    width: 100%;
    min-width: 0;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    white-space: nowrap;
  }

  #panel-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.85rem;
    align-items: center;
  }

  #panel-controls label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 44px;
  }

  #panel-controls #showAllPanels {
    width: auto;
    min-width: 8rem;
  }

  /* ---- Content that otherwise overflows ---- */
  #main-body table {
    width: 100%;
    max-width: 100%;
  }

  #main-body td,
  #main-body th {
    word-break: break-word;
  }

  #main-body .min-w-full,
  #main-body .overflow-x-auto {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* radars/radar pages section */
  #northern-radar-table,
  #southern-radar-table,
  #radar-management-table {
    width: max-content !important;
    max-width: none !important;
    min-width: 64rem;
    table-layout: auto;
    font-size: 0.875rem;
  }

  #main-body .table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #northern-radar-table th,
  #northern-radar-table td,
  #southern-radar-table th,
  #southern-radar-table td,
  #radar-management-table th,
  #radar-management-table td {
    min-width: 6.5rem;
    padding: 0.65rem 0.75rem;
    word-break: normal;
    overflow-wrap: normal;
    white-space: normal;
    line-height: 1.35;
  }

  #northern-radar-table th:nth-child(3),
  #northern-radar-table td:nth-child(3),
  #northern-radar-table th:nth-child(6),
  #northern-radar-table td:nth-child(6),
  #northern-radar-table th:nth-child(7),
  #northern-radar-table td:nth-child(7),
  #southern-radar-table th:nth-child(3),
  #southern-radar-table td:nth-child(3),
  #southern-radar-table th:nth-child(6),
  #southern-radar-table td:nth-child(6),
  #southern-radar-table th:nth-child(7),
  #southern-radar-table td:nth-child(7) {
    min-width: 10rem;
  }

  #radar-hardware-table {
    width: 100%;
    table-layout: auto;
    font-size: 0.875rem;
  }

  #radar-hardware-table th,
  #radar-hardware-table td {
    padding: 0.65rem 0.75rem;
    word-break: normal;
    overflow-wrap: anywhere;
    line-height: 1.35;
  }

  #radar-hardware-table th:first-child,
  #radar-hardware-table td:first-child {
    width: 48%;
  }

  .radar-section-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding-left: 0;
    padding-right: 0;
  }

  .radar-section-header > h2 {
    width: 100%;
    font-size: 1.25rem;
    line-height: 1.4;
  }

  #main-body .radar-status-filters {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.35rem;
    width: 100%;
    margin-left: 0;
  }

  #main-body .radar-status-filters > label {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    min-height: 44px;
    padding: 0.5rem 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background: white;
    white-space: nowrap;
  }

  #main-body .radar-status-filters input[type="checkbox"] {
    flex: 0 0 1.25rem;
    margin: 0;
  }

  #main-body img {
    max-width: 100%;
  }

  #output_plt_img,
  #main-body img[id$="_plt_img"] {
    height: auto;
  }

  /* The Microsoft calendar is cross-origin, so make its iframe use the
     available phone viewport and provide Outlook's responsive view as a
     fallback. */
  #microsoft-calendar-page {
    width: 100%;
    padding: 0;
  }

  #microsoft-calendar-page > .container {
    width: 100%;
    max-width: 100%;
  }

  #microsoft-calendar-mobile-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    margin-bottom: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    background: #861f41;
    color: white;
    font-weight: 600;
    text-align: center;
  }

  #microsoft-calendar-frame {
    width: 100%;
    max-width: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  #microsoft-calendar {
    display: block;
    width: 100%;
    max-width: 100%;
    height: calc(100vh - 9.5rem);
    height: calc(100dvh - 9.5rem);
    min-height: 32rem;
    border: 0;
  }

  #default-carousel .relative.h-64,
  [data-carousel] .relative.h-64 {
    height: 14rem;
  }

  /* ---- Calendars ---- */
  .calendar {
    width: 100%;
    max-width: 100%;
  }

  .calendar-panel {
    left: 0;
    right: auto;
    width: min(22rem, calc(100vw - 2rem));
    max-width: calc(100vw - 2rem);
  }

  .calendar-header button,
  .hemisphere-button,
  .calendar-view-button,
  .calendar-button {
    min-height: 44px;
    padding: 0.5rem 0.85rem;
  }

  .calendar-year-page {
    width: 100%;
    padding: 0.75rem;
  }

  .calendar-year-page .calendar-controls,
  .calendar-year-page .hemisphere-controls,
  .calendar-year-page .calendar-view-controls {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
  }

  #year-calendar {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  /* ---- Dialogs and image viewers ---- */
  [id$="_image_modal"],
  #gallery-modal,
  #helpDialog {
    max-width: 100vw;
  }

  #helpDialog {
    width: calc(100vw - 1.5rem);
    max-height: 90vh;
    overflow: auto;
  }

  #gallery-close,
  #gallery-prev,
  #gallery-next {
    width: 2.75rem;
    height: 2.75rem;
  }

  #gallery-modal-image {
    max-height: 70vh;
  }

  /* Real-time fan plot */
  #real-time-fan h1 {
    font-size: 1.25rem;
    line-height: 1.3;
    padding-top: 0.75rem;
    padding-bottom: 1rem;
    text-align: center;
  }

  #real-time-fan #colorbar-title {
    font-size: 0.65rem;
  }

  #real-time-fan #colorbar-ticks {
    font-size: 0.65rem;
  }

  #real-time-fan #connecting-indicator {
    flex-wrap: wrap;
    text-align: center;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
  }

  #real-time-fan #map-controls .sticky .flex {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  #real-time-fan #select-data-type {
    width: auto;
    min-width: 9rem;
    flex: 1 1 9rem;
  }

  #real-time-fan .modebar-btn,
  #real-time-fan .modebar-btn * {
    width: auto;
    min-width: 0;
    min-height: 0;
  }

  /* ---- Admin dashboard ---- */
  #admin-dashboard {
    width: 100%;
    max-width: 100%;
    display: block;
  }

  #admin-dashboard > div {
    width: 100%;
    max-width: 100%;
    padding: 0.75rem 0.25rem;
    box-shadow: none;
  }

  #admin-dashboard h1 {
    font-size: 1.5rem;
    line-height: 1.3;
    margin-bottom: 0.75rem;
  }

  #admin-dashboard > div > .text-center.text-lg {
    font-size: 1rem;
  }

  #admin-dashboard-nav {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    width: 100%;
    padding-top: 0.35rem;
  }

  #admin-dashboard-nav > * {
    margin-left: 0;
  }

  #admin-dashboard-nav button {
    width: 100%;
    min-height: 3.25rem;
    padding: 0.9rem 1rem;
    font-size: 0.95rem;
    line-height: 1.3;
    white-space: normal;
    text-align: center;
  }

  #admin-dashboard [id$="-section"] {
    width: 100%;
    max-width: 100%;
  }

  #admin-dashboard [id$="-section"] > .bg-white,
  #admin-dashboard [id$="-section"] .overflow-hidden {
    max-width: 100%;
  }

  #usage-stats-row {
    gap: 0.65rem;
    width: 100%;
  }

  #usage-stats-row > * {
    flex: 1 1 calc(50% - 0.65rem);
    min-width: 8rem;
    min-height: 4.75rem;
    justify-content: center;
    padding: 0.85rem 0.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background: white;
  }

  /* Keep row icon/text actions compact. Issue Resolve/Cancel stay full-width. */
  #admin-dashboard table .flex.items-center.space-x-3 button,
  #admin-dashboard table .flex.items-center.space-x-3 [type="submit"],
  #manage-articles-section table button,
  #manage-radars-section table [type="submit"],
  #manage-downloads-section table [type="submit"] {
    width: auto;
    min-width: 44px;
    padding-left: 0.45rem;
    padding-right: 0.45rem;
  }

  #admin-dashboard table th,
  #admin-dashboard table td {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  /* Issue reports: stacked cards instead of a sideways-scrolling table. */
  #manage-issues-section .overflow-x-auto {
    overflow: visible;
    max-width: 100%;
  }

  #issue-reports-table,
  #issue-reports-table thead,
  #issue-reports-table tbody,
  #issue-reports-table tr,
  #issue-reports-table th,
  #issue-reports-table td {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  #issue-reports-table thead {
    display: none;
  }

  #issue-reports-table tbody {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0.85rem 0.75rem 1rem;
  }

  #issue-reports-table tbody tr {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    min-height: 12rem;
    padding: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  }

  #issue-reports-table td {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    padding: 0.15rem 0 0.35rem;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  #issue-reports-table td::before {
    content: attr(data-label);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #6b7280;
  }

  #issue-reports-table td[colspan]::before {
    content: none;
  }

  #issue-reports-table .issue-text-cell {
    min-height: 6.5rem;
    padding: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background: #f9fafb;
    white-space: pre-wrap;
  }

  #issue-reports-table .issue-notes-cell form,
  #issue-reports-table .issue-actions-cell,
  #issue-reports-table .issue-actions-cell .flex {
    width: 100%;
  }

  #issue-reports-table textarea {
    min-height: 8.5rem;
    width: 100%;
    font-size: 16px;
  }

  #issue-reports-table .issue-notes-cell button,
  #issue-reports-table .issue-actions-cell button {
    width: 100%;
    min-height: 3.25rem;
    padding: 0.85rem 1rem;
  }

  #admin-dashboard [id$="Modal"] {
    padding: 0.75rem;
    align-items: flex-start;
    overflow-y: auto;
  }

  #admin-dashboard [id$="Modal"] > .relative {
    width: 100%;
    max-width: 100%;
    max-height: calc(100dvh - 1.5rem);
    overflow-y: auto;
  }

  #admin-dashboard [id$="Modal"] h3 {
    font-size: 1.15rem;
    line-height: 1.3;
  }

  #admin-dashboard [id$="Modal"] button.w-8,
  #admin-dashboard [id$="Modal"] button.h-8 {
    width: 2.75rem;
    min-width: 2.75rem;
    height: 2.75rem;
    min-height: 2.75rem;
    padding: 0;
  }

  #admin-dashboard [id$="Modal"] .flex.items-center.justify-end {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  #admin-dashboard [id$="Modal"] .flex.items-center.justify-end > button {
    flex: 1 1 8rem;
  }
}

/* -------------------------------------------------------------------------- */
/* Compact phones                                                             */
/* -------------------------------------------------------------------------- */
@media (max-width: 479px) {
  nav.bg-HokieMaroon .self-center {
    font-size: 0.95rem;
  }

  #main-body > main {
    padding-left: 0.25rem;
    padding-right: 0.25rem;
  }

  #main-body .flex.items-center.gap-6 > * {
    flex: 1 1 100%;
  }

  #main-body .pagination > *,
  #main-body nav[aria-label="View navigation"] li {
    flex: 1 1 100%;
  }

  #default-carousel .relative.h-64,
  [data-carousel] .relative.h-64 {
    height: 11rem;
  }

  .calendar-year-page h1,
  #main-body h1 {
    font-size: 1.35rem;
    line-height: 1.3;
  }
}

/* -------------------------------------------------------------------------- */
/* Mid-size phones / small tablets in portrait                                */
/* -------------------------------------------------------------------------- */
@media (min-width: 480px) and (max-width: 767px) {
  #year-calendar {
    grid-template-columns: 1fr 1fr;
  }

  #admin-dashboard-nav {
    grid-template-columns: 1fr 1fr;
  }

  #admin-dashboard-nav button {
    min-height: 3.75rem;
  }
}

/* Real-time fan plot: fit map + color bar below the xl two-column layout. */
@media (max-width: 1279px) {
  #real-time-fan {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  #real-time-fan-layout,
  #real-time-fan-map-column,
  #real-time-fan-stage {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  #real-time-fan-layout > *,
  #real-time-fan-stage > * {
    margin-left: 0;
  }

  #real-time-fan-stage {
    height: auto;
    justify-content: center;
    align-items: stretch;
    column-gap: 0.4rem;
  }

  #real-time-fan #map {
    width: min(70dvh, calc(100% - 4.75rem));
    height: min(70dvh, calc(100% - 4.75rem));
    max-width: calc(100% - 4.75rem);
    flex: 0 1 auto;
  }

  #real-time-fan-legend {
    flex: 0 0 4.25rem;
    width: 4.25rem;
    min-width: 4.25rem;
    max-width: 4.25rem;
    height: auto;
    align-self: stretch;
  }

  #real-time-fan #colorbar-title {
    margin-bottom: 0.4rem;
    line-height: 1.2;
    text-align: center;
    overflow-wrap: anywhere;
  }

  #real-time-fan #colorbar-track {
    height: 70%;
    width: auto;
    max-width: 100%;
    position: relative;
  }

  #real-time-fan #colorbar {
    width: 1.15rem;
    flex: 0 0 1.15rem;
  }

  #real-time-fan #colorbar-ticks {
    position: static;
    left: auto;
    top: auto;
    margin-left: 0.2rem;
    height: 100%;
    line-height: 1;
  }

  #real-time-fan #gd-scatter-legend {
    margin-top: 0.65rem;
    max-width: 100%;
  }

  #real-time-fan #gd-scatter-legend span {
    overflow-wrap: anywhere;
    line-height: 1.2;
  }

  #real-time-fan #connecting-indicator {
    width: 100%;
    max-width: 100%;
  }

  #real-time-fan #map-controls {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 479px) {
  #real-time-fan #map {
    width: min(70dvh, calc(100% - 4.15rem));
    height: min(70dvh, calc(100% - 4.15rem));
    max-width: calc(100% - 4.15rem);
  }

  #real-time-fan-legend {
    flex-basis: 3.75rem;
    width: 3.75rem;
    min-width: 3.75rem;
    max-width: 3.75rem;
  }

  #real-time-fan #colorbar {
    width: 1rem;
    flex-basis: 1rem;
  }
}
