/* MeshBuddy mobile app shell. Desktop stays untouched. */
:root {
  --mb-mobile-safe-top: env(safe-area-inset-top, 0px);
  --mb-mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
  --mb-mobile-tabbar-h: 74px;
  --mb-mobile-glass: rgba(5, 12, 8, .86);
  --mb-mobile-glass-strong: rgba(7, 15, 10, .96);
  --mb-mobile-line: rgba(143, 255, 185, .18);
  --mb-mobile-line-strong: rgba(143, 255, 185, .34);
  --mb-mobile-text: #edf7ef;
  --mb-mobile-muted: rgba(224, 241, 229, .68);
  --mb-mobile-green: #46e06b;
  --mb-mobile-blue: #6cb2ff;
  --mb-mobile-amber: #ffb84d;
}

.mb-mobile-tabbar,
.mb-mobile-more-sheet,
.mb-mobile-more-backdrop,
.mb-mobile-field-strip {
  display: none;
}

@media (max-width: 820px), (pointer: coarse) and (max-width: 1180px) {
  html {
    scroll-padding-bottom: calc(var(--mb-mobile-tabbar-h) + var(--mb-mobile-safe-bottom) + 20px);
    -webkit-text-size-adjust: 100%;
  }

  body.mb-mobile-app {
    min-width: 0;
    overflow-x: hidden;
    background:
      radial-gradient(circle at 20% 0, rgba(70, 224, 107, .10), transparent 34vw),
      radial-gradient(circle at 90% 12%, rgba(108, 178, 255, .09), transparent 40vw),
      #050806;
    color: var(--mb-mobile-text);
    padding-bottom: calc(var(--mb-mobile-tabbar-h) + var(--mb-mobile-safe-bottom));
  }

  body.mb-mobile-app button,
  body.mb-mobile-app a,
  body.mb-mobile-app input,
  body.mb-mobile-app select,
  body.mb-mobile-app textarea {
    -webkit-tap-highlight-color: rgba(70, 224, 107, .22);
  }

  body.mb-mobile-app input,
  body.mb-mobile-app select,
  body.mb-mobile-app textarea {
    min-height: 44px;
    font-size: 16px;
    border-radius: 8px;
  }

  .npn-site-classbar,
  .tac-class-bar {
    min-height: calc(16px + var(--mb-mobile-safe-top)) !important;
    padding-top: var(--mb-mobile-safe-top) !important;
    font-size: 8px !important;
    letter-spacing: .16em !important;
  }

  .npn-site-header {
    position: sticky;
    top: 0;
    z-index: 19000;
    border-bottom-color: var(--mb-mobile-line-strong);
    background:
      linear-gradient(180deg, rgba(17, 27, 21, .98), rgba(7, 13, 9, .94)),
      var(--mb-mobile-glass-strong);
    -webkit-backdrop-filter: blur(18px) saturate(145%);
    backdrop-filter: blur(18px) saturate(145%);
  }

  .npn-site-primary {
    min-height: 60px;
    padding: 8px 10px;
    gap: 8px;
  }

  .npn-site-brand {
    flex: 1 1 auto;
    min-width: 0;
    gap: 9px;
  }

  .npn-site-logo {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    clip-path: none;
  }

  .npn-site-title,
  .topbar .title {
    display: block;
    max-width: 46vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 19px !important;
    letter-spacing: .08em !important;
  }

  .npn-site-subtitle,
  .topbar .subtitle {
    display: none !important;
  }

  .npn-site-readouts,
  .tac-readouts {
    flex: 0 0 auto;
    width: auto !important;
    max-width: 48vw;
    margin-left: auto;
    gap: 7px;
    justify-content: flex-end;
  }

  .npn-site-cell-data,
  .tac-cell-data {
    display: none !important;
  }

  .npn-site-cell .cap,
  .tac-cell .cap {
    font-size: 8px !important;
  }

  .npn-site-cell .val,
  .tac-cell .val {
    font-size: 11px !important;
  }

  .npn-site-meshcon,
  .tac-meshcon {
    height: 34px !important;
    min-width: 0;
    padding: 0 9px !important;
    border-radius: 8px;
    font-size: 11px !important;
  }

  .npn-site-actions {
    gap: 8px;
    padding: 7px 10px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    background: rgba(7, 13, 9, .90);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }

  .npn-site-btn {
    height: 42px;
    min-height: 42px;
    padding: 0 13px;
    border-radius: 8px;
    scroll-snap-align: start;
  }

  .topbar {
    border-bottom-color: var(--mb-mobile-line-strong) !important;
    background:
      linear-gradient(180deg, rgba(12, 20, 14, .98), rgba(5, 10, 6, .94)) !important;
    -webkit-backdrop-filter: blur(18px) saturate(145%);
    backdrop-filter: blur(18px) saturate(145%);
  }

  .topbar .brand {
    gap: 9px !important;
  }

  .topbar .logo {
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
  }

  .topbar .actions.tac-actions-2row {
    align-items: center !important;
    gap: 8px !important;
  }

  .topbar .tac-primary-row {
    display: none !important;
  }

  .topbar .tac-viewgroup {
    display: flex !important;
    gap: 7px !important;
    min-width: 0;
    overflow-x: auto;
  }

  .topbar .tac-viewgroup button,
  .topbar .npn-mobile-action {
    border-radius: 8px !important;
    min-height: 42px !important;
  }

  .mb-mobile-tabbar {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: max(8px, var(--mb-mobile-safe-bottom));
    z-index: 22000;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    min-height: 60px;
    padding: 7px;
    border: 1px solid var(--mb-mobile-line-strong);
    border-radius: 18px;
    background:
      linear-gradient(180deg, rgba(17, 31, 22, .90), rgba(5, 9, 6, .96)),
      var(--mb-mobile-glass);
    box-shadow: 0 18px 50px rgba(0, 0, 0, .46), inset 0 1px 0 rgba(255, 255, 255, .10);
    -webkit-backdrop-filter: blur(18px) saturate(155%);
    backdrop-filter: blur(18px) saturate(155%);
  }

  .mb-mobile-tabbar a,
  .mb-mobile-tabbar button {
    display: grid;
    place-items: center;
    gap: 3px;
    min-width: 0;
    min-height: 48px;
    border: 0;
    border-radius: 13px;
    background: transparent;
    color: var(--mb-mobile-muted);
    font: 700 10px "Saira Condensed", "Arial Narrow", Arial, sans-serif;
    letter-spacing: .04em;
    line-height: 1;
    text-decoration: none;
    text-transform: uppercase;
  }

  .mb-mobile-tabbar svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mb-mobile-tabbar .is-current,
  .mb-mobile-tabbar button[aria-expanded="true"] {
    background: linear-gradient(180deg, rgba(70, 224, 107, .22), rgba(70, 224, 107, .08));
    color: var(--mb-mobile-green);
    box-shadow: inset 0 0 0 1px rgba(70, 224, 107, .24);
  }

  .mb-mobile-more-backdrop {
    position: fixed;
    inset: 0;
    z-index: 21980;
    display: none;
    background: rgba(0, 0, 0, .46);
  }

  body.mb-mobile-more-open .mb-mobile-more-backdrop {
    display: block;
  }

  .mb-mobile-more-sheet {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--mb-mobile-tabbar-h) + var(--mb-mobile-safe-bottom) + 14px);
    z-index: 21990;
    display: grid;
    gap: 10px;
    max-height: min(62svh, 430px);
    padding: 13px;
    overflow: auto;
    border: 1px solid var(--mb-mobile-line-strong);
    border-radius: 18px;
    background:
      linear-gradient(180deg, rgba(17, 31, 22, .94), rgba(5, 9, 6, .98)),
      var(--mb-mobile-glass-strong);
    box-shadow: 0 -18px 55px rgba(0, 0, 0, .52);
    -webkit-backdrop-filter: blur(18px) saturate(155%);
    backdrop-filter: blur(18px) saturate(155%);
    transform: translateY(120%);
    transition: transform .22s ease;
  }

  body.mb-mobile-more-open .mb-mobile-more-sheet {
    transform: translateY(0);
  }

  .mb-mobile-more-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--mb-mobile-line);
  }

  .mb-mobile-more-head b {
    color: var(--mb-mobile-text);
    font: 800 16px "Saira Condensed", "Arial Narrow", Arial, sans-serif;
    letter-spacing: .11em;
    text-transform: uppercase;
  }

  .mb-mobile-more-head span {
    display: block;
    color: var(--mb-mobile-muted);
    font-size: 11px;
    margin-top: 2px;
  }

  .mb-mobile-more-close {
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid var(--mb-mobile-line-strong);
    border-radius: 10px;
    background: rgba(5, 9, 6, .78);
    color: var(--mb-mobile-text);
    font-weight: 900;
    text-transform: uppercase;
  }

  .mb-mobile-more-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .mb-mobile-more-grid a {
    display: grid;
    gap: 4px;
    min-height: 58px;
    padding: 11px;
    border: 1px solid var(--mb-mobile-line);
    border-left: 3px solid var(--mb-mobile-blue);
    border-radius: 12px;
    background: rgba(11, 22, 15, .72);
    color: var(--mb-mobile-text);
    text-decoration: none;
  }

  .mb-mobile-more-grid b {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font: 800 13px "Saira Condensed", "Arial Narrow", Arial, sans-serif;
    letter-spacing: .08em;
    text-transform: uppercase;
  }

  .mb-mobile-more-grid small {
    color: var(--mb-mobile-muted);
    font-size: 11px;
    line-height: 1.25;
  }

  .mb-mobile-field-strip {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    gap: 8px;
    padding: 8px 10px;
    overflow-x: auto;
    border-bottom: 1px solid var(--mb-mobile-line);
    background: rgba(5, 10, 7, .86);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
  }

  .mb-mobile-field-strip a {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 9px 11px;
    border: 1px solid var(--mb-mobile-line);
    border-radius: 999px;
    color: var(--mb-mobile-text);
    font: 800 11px "Saira Condensed", "Arial Narrow", Arial, sans-serif;
    letter-spacing: .06em;
    text-decoration: none;
    text-transform: uppercase;
    background: rgba(12, 22, 15, .76);
  }

  body.mb-mobile-map #map,
  body.mb-mobile-map .maplibregl-map,
  body.mb-mobile-map .leaflet-container {
    bottom: calc(var(--mb-mobile-tabbar-h) + var(--mb-mobile-safe-bottom) + 4px) !important;
  }

  body.mb-mobile-map .maplibregl-ctrl-bottom-left,
  body.mb-mobile-map .maplibregl-ctrl-bottom-right,
  body.mb-mobile-map .leaflet-bottom {
    bottom: calc(var(--mb-mobile-tabbar-h) + var(--mb-mobile-safe-bottom) + 12px) !important;
  }

  body.mb-mobile-map .npn-map-layer-control,
  body.mb-mobile-map .npn-solar-control,
  body.mb-mobile-map .npn-solar-forecast-control,
  body.mb-mobile-map .npn-range-control,
  body.mb-mobile-map .npn-rf-control,
  body.mb-mobile-map #npn-rf-command-center,
  body.mb-mobile-map #npn-node-solar-forecast,
  body.mb-mobile-map #npn-home-spacewx-badge,
  body.mb-mobile-map #npn-hamclock-panel,
  body.mb-mobile-map .npn-mobile-tools-sheet {
    bottom: calc(var(--mb-mobile-tabbar-h) + var(--mb-mobile-safe-bottom) + 10px) !important;
    border-radius: 18px 18px 14px 14px !important;
  }

  body.mb-mobile-map .map-layout > .sidebar,
  body.mb-mobile-map .map-layout > .sidebar.right {
    bottom: calc(var(--mb-mobile-tabbar-h) + var(--mb-mobile-safe-bottom) + 8px) !important;
    max-height: min(68svh, 540px) !important;
    border-radius: 18px 18px 0 0;
  }

  body.mb-mobile-map.npn-mobile-filters-open .map-layout > .sidebar:not(.right) {
    transform: translateY(0) !important;
  }

  body.mb-mobile-map.npn-mobile-filters-open .map-layout > .sidebar.right {
    transform: translateY(calc(100% + 92px)) !important;
  }

  body.mb-mobile-map.npn-mobile-contacts-open .map-layout > .sidebar.right {
    transform: translateY(0) !important;
  }

  body.mb-mobile-map.npn-mobile-contacts-open .map-layout > .sidebar:not(.right) {
    transform: translateY(calc(100% + 92px)) !important;
  }

  body.mb-mobile-map.npn-mobile-contacts-open .npn-mobile-backdrop {
    display: block;
  }

  body.mb-mobile-map .panel,
  body.mb-mobile-map .panel-body {
    border-radius: 14px;
  }

  body.mb-mobile-map .contact-panel-body {
    max-height: calc(min(68svh, 540px) - 54px);
    overflow: auto;
  }

  body.site-planner-page .planner-shell {
    padding: 8px 8px calc(var(--mb-mobile-tabbar-h) + var(--mb-mobile-safe-bottom) + 14px);
    gap: 10px;
  }

  body.site-planner-page .planner-map-wrap {
    min-height: min(72svh, 680px);
    border-radius: 18px;
    overflow: hidden;
  }

  body.site-planner-page #plannerMap {
    min-height: min(72svh, 680px);
  }

  body.site-planner-page .planner-card,
  body.site-planner-page .planner-recommendation,
  body.site-planner-page .site-slot,
  body.site-planner-page .result-grid div {
    border-radius: 16px;
  }

  body.site-planner-page .planner-map-toolbar {
    min-height: 50px;
    gap: 7px;
    overflow-x: auto;
  }

  body.site-planner-page .planner-map-toolbar button,
  body.site-planner-page .planner-map-toolbar select {
    min-height: 40px;
    border-radius: 10px;
  }

  .olympics-page,
  .about-page,
  .solar-page,
  .mqtt-page,
  .analytics-page,
  .cinematic-page {
    padding-bottom: calc(var(--mb-mobile-tabbar-h) + var(--mb-mobile-safe-bottom) + 16px) !important;
  }

  .olympics-page section,
  .about-page section,
  .solar-page section,
  .mqtt-page section,
  .analytics-page section,
  .analytics-card,
  .mqtt-card,
  .lab-card,
  .about-card {
    border-radius: 18px !important;
  }

  .scoreboard-nav,
  .analytics-tabs,
  .mqtt-tabs,
  .solar-tabs {
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  .scoreboard-nav a,
  .analytics-tabs a,
  .mqtt-tabs button,
  .solar-tabs button {
    min-height: 42px;
    scroll-snap-align: start;
  }
}

@media (max-width: 430px) {
  :root {
    --mb-mobile-tabbar-h: 70px;
  }

  .mb-mobile-tabbar {
    left: 6px;
    right: 6px;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    padding: 6px;
    border-radius: 16px;
  }

  .mb-mobile-tabbar a,
  .mb-mobile-tabbar button {
    font-size: 9px;
    min-height: 46px;
  }

  .mb-mobile-tabbar svg {
    width: 17px;
    height: 17px;
  }

  .mb-mobile-more-grid {
    grid-template-columns: 1fr;
  }

  .npn-site-title,
  .topbar .title {
    max-width: 42vw;
    font-size: 17px !important;
  }

  .npn-site-cell-nodes,
  .tac-cell-nodes {
    display: none !important;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  :root {
    --mb-mobile-tabbar-h: 58px;
  }

  .mb-mobile-tabbar {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    min-height: 50px;
    padding: 5px;
  }

  .mb-mobile-tabbar a,
  .mb-mobile-tabbar button {
    min-height: 40px;
    grid-template-columns: auto auto;
    justify-content: center;
    gap: 5px;
  }

  .mb-mobile-tabbar svg {
    width: 16px;
    height: 16px;
  }

  body.mb-mobile-map .map-layout > .sidebar,
  body.mb-mobile-map .map-layout > .sidebar.right,
  .mb-mobile-more-sheet {
    max-height: 72svh !important;
  }
}
