/* ===================== phones and tablets ===================== */
.phone-only { display: none !important; }
body, #app { height: 100vh; height: 100dvh; }

/* touch screens: larger targets; 16 px inputs prevent the automatic zoom of iOS */
@media (pointer: coarse) {
  input, select, textarea { font-size: 16px !important; }
  button { min-height: 42px; }
  button.small { min-height: 36px; padding: 4px 10px; font-size: 13px; }
  .hbtn, .gps-btn { min-height: 38px; }
  .hbtn.icon-only { min-width: 40px; justify-content: center; }
  input[type=checkbox] { width: 20px; height: 20px; }
  label.check { min-height: 36px; }
  summary { padding: 6px 0; }
  .leaflet-bar a, .leaflet-touch .leaflet-bar a { width: 38px; height: 38px; line-height: 38px; }
  .mark-bar button { width: 38px; height: 38px; min-height: 38px; }
  .mark-edit .sw { width: 30px; height: 30px; }
  #h-cursor { display: none; }
}

/* tablets */
@media (min-width: 821px) and (max-width: 1180px) {
  aside { width: 330px; }
  header { gap: 8px; padding: 6px 8px; font-size: 13px; }
  #h-me, #h-cursor { display: none; }
}

/* phones, upright or sideways */
@media (max-width: 820px), (max-height: 500px) and (pointer: coarse) {
  .phone-only { display: flex !important; }
  .overlay { align-items: flex-start; overflow: auto; padding: 8px; }
  .card { width: 100%; max-width: 520px; max-height: none; padding: 18px 14px; margin: auto; }
  .roster-cards { grid-template-columns: 1fr; }

  header { flex-wrap: wrap; gap: 4px; padding: 4px 6px; padding-top: calc(4px + env(safe-area-inset-top)); font-size: 12px; }
  #h-me, #h-cursor { display: none; }
  header .h-title { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; }
  header .h-title b { overflow: hidden; text-overflow: ellipsis; }
  header #h-utc { order: 10; margin: 0; width: calc(100% - 20px); font-size: 11px; }
  header #h-link { order: 11; }
  .gps-btn { min-width: 0; padding: 4px 8px; font-size: 12px; }
  header .hbtn { font-size: 0; padding: 4px; min-width: 36px; justify-content: center; }
  header .hbtn svg.ico { width: 19px; height: 19px; margin: 0; font-size: 14px; }

  /* chart full screen, bottom bar always visible, panel over the chart */
  #body { flex-direction: column; position: relative; }
  #map-wrap { min-height: 0; }
  aside { width: 100%; border: 0; border-top: 1px solid var(--border); position: static; min-height: 0; }
  nav { order: 2; border: 0; border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); background: #fff; }
  nav button { min-height: 50px; }
  nav button.active { border-bottom: 0; box-shadow: inset 0 3px 0 var(--navy); }
  body:not(.panel-closed) aside { position: absolute; inset: 0; z-index: 1500; }
  body.panel-closed .tab, body.panel-closed .drawer { display: none !important; }
  .tab { min-height: 0; padding: 10px 12px; -webkit-overflow-scrolling: touch; }
  .drawer { position: absolute; inset: 0 0 calc(51px + env(safe-area-inset-bottom)) 0; }
  .msg-compose #msg-text { min-width: 0; }
  .msg-compose #msg-send { font-size: 0; }
  .msg-compose #msg-send svg.ico { width: 20px; height: 20px; margin: 0; font-size: 14px; }
  table.legs { display: block; overflow-x: auto; }

  /* overlays on the chart */
  .wizard { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 68%; border-radius: 12px 12px 0 0; padding: 12px; }
  .wizard .tile { min-height: 0; }
  .plot-hint { left: 54px; right: 54px; transform: none; font-size: 13px; padding: 6px 10px; justify-content: space-between; }
  .modal { width: 96vw !important; max-width: 96vw; max-height: 92dvh; padding: 14px; }
  #toasts { left: 8px; right: 8px; top: calc(86px + env(safe-area-inset-top)); bottom: auto; max-width: none; }
  .leaflet-control-scale { display: none; }
  .legend-body { max-height: 40dvh; }
}
@media (max-height: 500px) and (pointer: coarse) {
  header { flex-wrap: nowrap; }
  header #h-utc { order: 0; width: auto; }
  .leaflet-control-zoom { display: none; }          /* pinch to zoom: room for the other chart buttons */
  nav button { min-height: 40px; flex-direction: row; justify-content: center; gap: 5px; padding: 4px; }
  .drawer { bottom: calc(41px + env(safe-area-inset-bottom)); }
  .wizard { right: auto; width: min(420px, 70%); max-height: 100%; }
  #toasts { top: 50px; }
}
body.night nav { background: #0b0b0b; }
