/* Мобильная версия: сверху только школа, снизу полноширинная панель поиска и маршрута. */
@media (max-width: 760px) {
  :root {
    --mobile-edge: 10px;
    --mobile-safe-top: max(10px, env(safe-area-inset-top));
    --mobile-safe-bottom: env(safe-area-inset-bottom);
    --mobile-school-height: 58px;
    --mobile-picker-height: clamp(190px, 34dvh, 280px);
    --mobile-collapsed-sheet: 126px;
    --mobile-sheet-handle-height: 54px;
    --mobile-hidden-sheet: calc(var(--mobile-sheet-handle-height) + var(--mobile-safe-bottom));
    --mobile-sheet-share-gap: 14px;
    --mobile-sheet-current-height: calc(var(--mobile-collapsed-sheet) + var(--mobile-safe-bottom));
  }

  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .app {
    position: fixed;
    inset: 0;
    display: block;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .app::before {
    display: none;
  }

  .map-area {
    position: fixed;
    inset: 0;
    height: auto;
    min-height: 0;
  }

  #map {
    position: absolute;
    inset: 0;
  }

  .leaflet-control-zoom {
    display: none;
  }

  .map-label,
  .legend,
  .risk-help {
    display: none;
  }

  .project-hero {
    position: fixed;
    z-index: 1200;
    top: var(--mobile-safe-top);
    right: var(--mobile-edge);
    left: var(--mobile-edge);
    margin: 0;
    padding: 0;
    overflow: visible;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .project-hero .eyebrow,
  .project-hero h1,
  .project-hero .lead {
    display: none;
  }

  .school-picker {
    position: static;
  }

  .school-card {
    min-height: var(--mobile-school-height);
    padding: 10px 12px;
    background: #fff;
    border: 1px solid rgb(218 226 238 / 95%);
    border-radius: 16px;
    box-shadow: 0 10px 28px rgb(15 27 45 / 16%);
  }

  .school-icon {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
  }

  .school-card-text {
    min-width: 0;
  }

  .school-card strong,
  .school-card span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .school-card strong {
    font-size: 14px;
  }

  .school-card span {
    font-size: 12px;
  }

  .school-arrow {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
  }

  .school-picker-panel {
    position: fixed;
    z-index: 1220;
    top: calc(var(--mobile-safe-top) + var(--mobile-school-height) + 8px);
    right: var(--mobile-edge);
    left: var(--mobile-edge);
    max-height: var(--mobile-picker-height);
    margin: 0;
    overflow: hidden;
    background: #fff;
    border: 1px solid #dce9fb;
    border-radius: 16px;
    box-shadow: 0 14px 34px rgb(44 96 167 / 24%);
  }

  .school-search-input {
    height: 42px;
    padding: 0 38px 0 12px;
    font-size: 16px;
  }

  .school-list {
    max-height: calc(var(--mobile-picker-height) - 62px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar {
    position: fixed;
    z-index: 1050;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100vw;
    height: calc(var(--mobile-collapsed-sheet) + var(--mobile-safe-bottom));
    padding: 8px 12px calc(12px + var(--mobile-safe-bottom));
    overflow: hidden;
    overscroll-behavior: contain;
    touch-action: pan-y;
    background: #fff;
    border: 0;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -12px 34px rgb(15 27 45 / 18%);
    transform: none;
    transition: height 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    -webkit-overflow-scrolling: touch;
  }

  .sidebar.is-mobile-dragging {
    transition: none;
  }

  .sidebar.is-mobile-snapping {
    transition: height 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .sidebar.is-mobile-hidden {
    --mobile-sheet-current-height: var(--mobile-hidden-sheet);
    height: var(--mobile-hidden-sheet);
    padding-bottom: var(--mobile-safe-bottom);
    overflow: hidden;
  }

  body:not(.has-start-point) .sidebar.is-mobile-expanded {
    --mobile-sheet-current-height: auto;
    height: auto;
    max-height: calc(100dvh - var(--mobile-safe-top) - 86px);
    overflow-x: hidden;
    overflow-y: auto;
  }
  .sidebar.is-mobile-expanded {
    --mobile-sheet-current-height: min(68dvh, 560px);
    height: min(68dvh, 560px);
    max-height: calc(100dvh - var(--mobile-safe-top) - 86px);
    padding: 8px 12px calc(14px + var(--mobile-safe-bottom));
    overflow-x: hidden;
    overflow-y: auto;
  }

  .mobile-sheet-toggle {
    position: relative;
    display: grid;
    flex: 0 0 auto;
    width: 100%;
    min-height: 44px;
    color: #1f2a44;
    cursor: pointer;
    background: #fff;
    border: 0;
    align-items: center;
    justify-items: center;
    font: inherit;
    font-size: 14px;
    font-weight: 900;
    padding: 20px 14px 5px;
    overflow: hidden;
    line-height: 1.05;
    text-align: center;
    text-overflow: ellipsis;
    touch-action: none;
    user-select: none;
    white-space: nowrap;
  }

  .mobile-sheet-toggle span {
    display: none;
  }

  .mobile-sheet-toggle::after {
    position: absolute;
    top: 4px;
    left: 50%;
    width: 8px;
    height: 8px;
    border-right: 2px solid #202124;
    border-bottom: 2px solid #202124;
    display: block;
    content: "";
    transform: translateX(-50%) rotate(225deg);
  }

  .sidebar.is-mobile-expanded .mobile-sheet-toggle::after {
    transform: translateX(-50%) rotate(45deg);
  }

  .sidebar.is-mobile-expanded .mobile-sheet-toggle {
    position: sticky;
    z-index: 20;
    top: -8px;
    width: calc(100% + 24px);
    margin: -8px -12px 4px;
    padding: 20px 14px 5px;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 8px 14px rgb(255 255 255 / 94%);
  }

  .address-section {
    flex: 0 0 auto;
    padding: 0;
    background: #fff;
  }

  .address-section h2,
  .address-hint {
    display: none;
  }

  .address-form {
    align-items: center;
    gap: 7px;
    padding: 0;
    overflow: visible;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .address-form input {
    font-size: 14px;
  }

  .school-search-input {
    font-size: 16px;
  }

  .address-form input {
    height: 44px;
    padding: 0 38px 0 12px;
    appearance: none;
    -webkit-appearance: none;
    background: #fff;
    border: 1px solid #dce3ee;
    border-radius: 12px;
    box-shadow: none;
  }

  .address-form input:focus {
    outline: 0;
    border-color: var(--blue);
    box-shadow: none;
  }

  .address-form > button {
    height: 44px;
    padding: 0 13px;
    border: 0;
    border-radius: 12px;
    box-shadow: none;
    font-size: 13px;
    white-space: nowrap;
  }

  .address-suggestions {
    display: grid;
    max-height: min(42dvh, 360px);
    margin-top: 8px;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgb(15 27 45 / 14%);
    -webkit-overflow-scrolling: touch;
  }

  .sidebar.is-mobile-address-searching > .route-build-section,
  .sidebar.is-mobile-address-searching > .manual-signs-panel,
  .sidebar.is-mobile-address-searching > #route-options-section,
  .sidebar.is-mobile-address-searching > .share-button-host,
  body:not(.has-start-point) .sidebar.is-mobile-expanded > .route-build-section,
  body:not(.has-start-point) .sidebar.is-mobile-expanded > #route-options-section,
  body:not(.has-start-point) .sidebar.is-mobile-expanded > .legend,
  body:not(.has-start-point) .sidebar.is-mobile-expanded > .risk-help,
  .sidebar.is-mobile-hidden > .address-section,
  .sidebar.is-mobile-hidden > section:not(.address-section),
  .sidebar.is-mobile-hidden > #route-options-section,
  .sidebar.is-mobile-hidden > .legend,
  .sidebar.is-mobile-hidden > .risk-help,
  .sidebar:not(.is-mobile-expanded) > section:not(.address-section),
  .sidebar:not(.is-mobile-expanded) > #route-options-section,
  .sidebar:not(.is-mobile-expanded) > .legend,
  .sidebar:not(.is-mobile-expanded) > .risk-help {
    display: none;
  }

  .sidebar.is-mobile-expanded > section:not(.address-section),
  .sidebar.is-mobile-expanded > #route-options-section {
    display: block;
  }

  .sidebar.is-mobile-expanded > #route-options-section[hidden],
  .sidebar.is-mobile-expanded > .manual-signs-panel[hidden] {
    display: none;
  }

  .sidebar h2 {
    margin: 0 0 8px;
    color: #263447;
    font-size: 13px;
  }

  .sidebar > section:not(.address-section),
  .sidebar > #route-options-section {
    padding: 12px;
    background: #fff;
    border: 1px solid #edf1f7;
    border-radius: 16px;
    box-shadow: 0 4px 14px rgb(15 27 45 / 6%);
  }

  .info-card p {
    color: #334155;
    font-size: 13px;
    line-height: 1.35;
  }

  .route-progress {
    gap: 6px;
    margin-top: 10px;
  }

  .route-reasons {
    margin-top: 10px;
    font-size: 11px;
  }
#route-options-section h2 {
    display: none;
  }

  .routes {
    gap: 8px;
  }

  .route {
    padding: 11px 12px;
    border-color: #e5ebf4;
    border-radius: 14px;
    box-shadow: none;
  }

  .route.active {
    background: #eef5ff;
    box-shadow: inset 0 0 0 1px var(--blue);
  }

  .route-top {
    gap: 10px;
    font-size: 13px;
  }

  .route small {
    margin-top: 3px;
    font-size: 11px;
  }

  .badge {
    padding: 3px 7px;
    font-size: 10px;
  }

  .manual-signs-panel {
    margin-top: 0;
  }

  .add-sign-toggle {
    min-height: 40px;
    padding: 0 38px 0 12px;
    border-radius: 12px;
    font-size: 13px;
  }

  .sign-picker {
    gap: 8px;
    padding: 8px;
    border-radius: 14px;
  }

  .sign-picker p {
    display: none;
  }

  .sign-options {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .sign-option {
    min-height: 58px;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    padding: 9px 7px;
    text-align: center;
    border-radius: 13px;
    font-size: 11px;
    line-height: 1.15;
  }

  .sign-picker-actions {
    gap: 8px;
    margin-top: 10px;
    padding-top: 2px;
  }

  .cancel-sign-mode,
  .clear-manual-signs {
    min-height: 36px;
    flex: 1;
    justify-content: center;
    padding: 0 8px;
    color: #526176;
    background: #fff;
    border: 1px solid #e5ebf4;
    border-radius: 11px;
    text-decoration: none;
    font-size: 11px;
  }

  .clear-manual-signs {
    color: #c5221f;
    background: #fff7f6;
  }
}

@media (max-width: 390px) {
  :root {
    --mobile-edge: 8px;
    --mobile-school-height: 54px;
    --mobile-collapsed-sheet: 118px;
  }

  .school-card {
    gap: 9px;
    padding: 8px 10px;
  }

  .school-icon {
    flex-basis: 34px;
    width: 34px;
    height: 34px;
  }

  .school-card strong {
    font-size: 13px;
  }

  .school-card span {
    font-size: 11px;
  }

  .sidebar {
    padding-right: 10px;
    padding-left: 10px;
  }

  .address-form {
    gap: 6px;
  }

  .address-form input {
    height: 42px;
    padding: 0 36px 0 10px;
  }

  .address-form > button {
    height: 42px;
    padding: 0 10px;
    font-size: 12px;
  }

  body:not(.has-start-point) .sidebar.is-mobile-expanded {
    height: auto;
    max-height: calc(100dvh - var(--mobile-safe-top) - 86px);
    overflow-y: auto;
  }
  .sidebar.is-mobile-expanded {
    height: min(70dvh, 520px);
    max-height: calc(100dvh - var(--mobile-safe-top) - 78px);
  }
}






