/* Navigator — mobile (≤959px): карта на весь экран, панели сверху/снизу */

@media (max-width: 959px) {
  #view-navigator.tab-active .stud-nav-screen {
    flex: 1;
    min-height: 0;
    height: 100%;
  }

  .stud-nav-stage {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    min-height: 0;
    height: 100%;
  }

  .stud-nav-map-layer {
    position: absolute;
    inset: 0;
  }

  /* Панель не перекрывает карту целиком — только верх и низ */
  .stud-nav-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }

  .stud-nav-panel-body {
    position: absolute;
    left: 0;
    right: 0;
    bottom: var(--nav-ui-bottom);
    z-index: 19;
    pointer-events: none;
  }

  .stud-nav-top {
    position: relative;
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: max(6px, env(safe-area-inset-top)) 8px 6px;
    pointer-events: auto;
    max-height: min(42dvh, 300px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .stud-nav-top-back {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--color-elevated);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }

  .stud-nav-top-back[hidden] {
    display: none !important;
  }

  .stud-nav-planner {
    flex: 1;
    min-width: 0;
  }

  .stud-nav-planner-card {
    background: var(--color-elevated);
    border-radius: 12px;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.12);
  }

  .stud-nav-trip-row {
    min-height: 44px;
  }

  .stud-nav-trip-input {
    padding: 10px 0;
    font-size: 0.9rem;
  }

  .stud-nav-planner-actions {
    padding: 6px 10px 10px;
  }

  .stud-nav-primary-btn {
    min-height: 40px;
    font-size: 0.875rem;
  }

  .stud-nav-stage.has-route .stud-nav-top,
  .stud-nav-stage.is-navigating .stud-nav-top {
    display: none !important;
  }

  .stud-nav-gesture-hint {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(var(--nav-ui-bottom) + 58px);
    z-index: 8;
    margin: 0;
    padding: 7px 11px;
    max-width: calc(100% - 72px);
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--color-text-muted);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    pointer-events: none;
  }

  html.dark .stud-nav-gesture-hint {
    background: rgba(26, 31, 41, 0.94);
  }

  .stud-nav-gesture-hint.is-hidden {
    opacity: 0;
  }

  .stud-nav-stage.has-route .stud-nav-gesture-hint {
    bottom: calc(var(--nav-ui-bottom) + var(--nav-sheet-peek) + 8px);
  }

  .stud-nav-map-legend {
    position: absolute;
    left: 8px;
    bottom: calc(var(--nav-ui-bottom) + 58px);
    z-index: 9;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-width: calc(100% - 64px);
    pointer-events: none;
  }

  .stud-nav-stage.has-route .stud-nav-map-legend {
    bottom: calc(var(--nav-ui-bottom) + var(--nav-sheet-peek) + 8px);
  }

  .stud-nav-stage.is-navigating .stud-nav-gesture-hint,
  .stud-nav-stage.is-navigating .stud-nav-map-legend {
    display: none !important;
  }

  .stud-nav-legend-item {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.62rem;
    font-weight: 700;
    background: var(--color-elevated);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
  }

  .stud-nav-legend-item--elevator::before,
  .stud-nav-legend-item--stairs::before,
  .stud-nav-legend-item--toilet::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
  }

  .stud-nav-legend-item--elevator::before { background: #f9ab00; }
  .stud-nav-legend-item--stairs::before { background: #7b5ea7; }
  .stud-nav-legend-item--toilet::before { background: #0d9488; }

  .stud-nav-guidance {
    top: max(6px, env(safe-area-inset-top));
    left: 8px;
    right: 8px;
  }

  .stud-nav-floor-stack {
    position: absolute;
    left: 8px;
    right: auto;
    top: auto;
    bottom: calc(var(--nav-ui-bottom) + 8px);
    z-index: 9;
    pointer-events: none;
  }

  .stud-nav-stage.has-route .stud-nav-floor-stack {
    bottom: calc(var(--nav-ui-bottom) + var(--nav-sheet-peek) + 8px);
  }

  .stud-nav-stage.is-navigating .stud-nav-floor-stack {
    bottom: calc(var(--nav-ui-bottom) + 64px);
  }

  .stud-nav-floor-badge {
    padding: 5px 9px;
    border-radius: 8px;
    background: var(--color-elevated);
    font-size: 0.65rem;
    font-weight: 800;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }

  .stud-nav-map-controls {
    display: none;
  }

  .stud-nav-map-hint {
    display: none;
  }

  .stud-nav-fabs {
    position: absolute;
    right: 8px;
    bottom: calc(var(--nav-ui-bottom) + 10px);
    z-index: 15;
    pointer-events: none;
  }

  .stud-nav-fab {
    pointer-events: auto;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--color-elevated);
    color: var(--color-brand);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }

  .stud-nav-fab#nav-reset-view {
    display: none;
  }

  .stud-nav-stage.has-route .stud-nav-fabs {
    bottom: calc(var(--nav-ui-bottom) + var(--nav-sheet-peek) + 6px);
  }

  .stud-nav-stage.is-navigating .stud-nav-fabs {
    bottom: calc(var(--nav-ui-bottom) + 8px);
  }

  .stud-nav-route-panel {
    position: relative;
    left: 0;
    right: 0;
    margin: 0 6px;
    background: var(--color-elevated);
    border-radius: 14px;
    box-shadow: 0 -2px 24px rgba(0, 0, 0, 0.14);
    max-height: min(50dvh, calc(100dvh - var(--nav-ui-bottom) - 80px));
    display: flex;
    flex-direction: column;
    transform: translateY(calc(100% + 20px));
    transition: transform 0.34s cubic-bezier(0.32, 0.72, 0, 1);
    pointer-events: none;
    visibility: hidden;
  }

  .stud-nav-route-panel.is-open {
    transform: translateY(0);
    pointer-events: auto;
    visibility: visible;
  }

  .stud-nav-route-panel.is-expanded {
    max-height: min(58dvh, calc(100dvh - var(--nav-ui-bottom) - 48px));
  }

  .stud-nav-route-panel.is-open,
  .stud-nav-route-panel.is-open * {
    pointer-events: auto;
  }

  .stud-nav-sheet-grab {
    width: 100%;
    border: none;
    background: transparent;
    padding: 8px 0 2px;
    cursor: pointer;
    display: flex;
    justify-content: center;
  }

  .stud-nav-sheet-grab::before {
    content: '';
    width: 32px;
    height: 4px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.16);
  }

  .stud-nav-sheet-peek {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px 8px;
  }

  .stud-nav-sheet-peek[hidden],
  .stud-nav-sheet-scroll[hidden],
  .stud-nav-sheet-bar[hidden] {
    display: none !important;
  }

  .stud-nav-sheet-scroll {
    flex: 1;
    min-height: 0;
    overflow: auto;
    border-top: 1px solid var(--color-border);
  }

  .stud-nav-route-panel:not(.is-expanded) .stud-nav-sheet-scroll {
    display: none !important;
  }

  .stud-nav-sheet-bar {
    padding: 6px 12px 10px;
    border-top: 1px solid var(--color-border);
  }

  .stud-nav-stage.is-navigating .stud-nav-route-panel.is-open {
    transform: translateY(0);
    max-height: none;
  }

  .stud-nav-stage.is-navigating .stud-nav-sheet-peek,
  .stud-nav-stage.is-navigating .stud-nav-sheet-scroll {
    display: none !important;
  }

  .stud-nav-stage.is-navigating .stud-nav-sheet-bar {
    display: block !important;
    border-top: none;
  }
}
