/* Mobile map workspace: map first, bottom navigation and a planner bottom sheet. */
.route-undo-toast[hidden] { display: none; }
.map-photo-upload { position: absolute; z-index: 1460; left: 50%; bottom: 24px; width: min(360px, calc(100% - 24px)); transform: translateX(-50%); padding: 12px 14px; border-radius: 16px; background: #26322cf5; color: #fff; box-shadow: 0 14px 38px #14201955; }
.map-photo-upload[hidden] { display: none; }
.map-photo-upload b,.map-photo-upload small { display: block; }
.map-photo-upload b { font-size: 12px; }
.map-photo-upload small { margin-top: 3px; color: #d7dfda; font-size: 10px; }
.map-photo-upload progress { width: 100%; height: 5px; margin-top: 8px; accent-color: #ffd45a; }
@media (min-width: 761px) { .route-undo-toast { position: absolute; z-index: 1450; right: 22px; bottom: 22px; display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 16px; border-radius: 15px; background: #26322c; color: #fff; box-shadow: 0 14px 38px #14201955; } .route-undo-toast button { min-height: 38px; padding: 0 13px; border-radius: 11px; background: #ffd45a; color: #272c29; font-weight: 850; } }
.workspace-bar .nav-icon { font-size: 17px; line-height: 1; }
.workspace-bar .nav-label { white-space: nowrap; }

@media (min-width: 761px) and (max-width: 820px) {
  .workspace-bar { gap: 6px; padding-inline: 10px; }
  .workspace-brand b { display: none; }
  .workspace-bar nav a, .workspace-bar nav button { padding-inline: 11px; }
  .local-status { width: 40px; height: 40px; padding: 0; justify-content: center; }
  .local-status span { display: none; }
}

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid #ffd45a;
  outline-offset: 2px;
}

@media (max-width: 760px) {
  :root { --mobile-header: 56px; --mobile-nav: calc(64px + env(safe-area-inset-bottom, 0px)); }
  html, body { width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
  button, a, input, select { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

  .workspace-bar {
    position: relative; z-index: 1550; height: var(--mobile-header); width: 100%;
    padding: 0 10px 0 12px; gap: 8px; border-bottom: 1px solid #ffffff14;
  }
  .workspace-brand { min-width: 0; gap: 8px; }
  .workspace-brand span { width: 30px; height: 30px; flex: 0 0 auto; }
  .workspace-brand b { overflow: hidden; font-size: 17px; text-overflow: ellipsis; white-space: nowrap; }
  .local-status {
    display: grid !important; place-items: center; width: 40px; height: 40px; flex: 0 0 auto;
    margin-left: auto; padding: 0; border-radius: 14px; background: #ffffff12; text-decoration: none;
  }
  .local-status i { width: 9px; height: 9px; margin: 0; }
  .local-status span { display: none; }

  .workspace-bar nav {
    position: fixed; z-index: 1550; right: 0; bottom: 0; left: 0; height: var(--mobile-nav);
    display: flex; align-items: stretch; justify-content: space-around; margin: 0;
    padding: 5px 6px env(safe-area-inset-bottom, 0px); border-top: 1px solid #dfe4e0;
    background: #fffffff7; box-shadow: 0 -8px 28px #17241d18; backdrop-filter: blur(18px);
  }
  .workspace-bar nav a, .workspace-bar nav button {
    min-width: 0; min-height: 54px; flex: 1 1 0; display: flex !important; flex-direction: column;
    align-items: center; justify-content: center; gap: 5px; padding: 4px 3px !important;
    border: 0 !important; border-radius: 13px; background: transparent !important;
    color: #66716a !important; font-size: 10px !important; font-weight: 750; text-decoration: none;
  }
  .workspace-bar nav a[hidden], .workspace-bar nav button[hidden] { display: none !important; }
  .workspace-bar nav .nav-icon { display: grid; place-items: center; width: 28px; height: 24px; font-size: 21px; }
  .workspace-bar nav .nav-label { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .workspace-bar nav a.active, .workspace-bar nav button.active { color: #1e7449 !important; background: #eaf5ee !important; }

  .app-shell, .app-shell.planning { height: calc(100dvh - var(--mobile-header)); }
  .map-stage, #map { height: 100%; min-height: 0; }

  .route-center-target {
    position: absolute; z-index: 590; top: calc((100% - var(--mobile-nav) - 86px) / 2); left: 50%;
    width: 25px; height: 25px; transform: translate(-50%, -50%); pointer-events: none;
    filter: drop-shadow(0 2px 3px #18251d40);
  }
  .route-center-target[hidden], .route-mobile-controls[hidden] { display: none; }
  .route-center-target::before, .route-center-target::after { content: ""; position: absolute; z-index: 1; border-radius: 2px; background: #18784a; box-shadow: 0 0 0 1px #fff, 0 0 3px #fff; }
  .route-center-target::before { top: 12px; left: 1px; width: 23px; height: 1px; }
  .route-center-target::after { top: 1px; left: 12px; width: 1px; height: 23px; }
  .route-center-target span { position: absolute; z-index: 2; top: 10px; left: 10px; width: 5px; height: 5px; border: 1px solid #fff; border-radius: 50%; background: #18784a; box-shadow: 0 0 0 1px #18784a; }

  .route-mobile-controls {
    position: absolute; z-index: 1250; right: 8px; bottom: calc(var(--mobile-nav) + 8px); left: 8px;
    padding: 7px; border: 1px solid #dfe5e0; border-radius: 18px; background: #fffffff7;
    box-shadow: 0 12px 38px #1420192e; backdrop-filter: blur(18px);
  }
  .route-mobile-controls > small { display: block; overflow: hidden; padding: 0 7px 6px; color: #59665e; font-size: 11px; font-weight: 700; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
  .route-mobile-controls > div { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
  .route-mobile-controls button { min-width: 0; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 3px 1px; border-radius: 12px; background: #f0f3f1; color: #4f5a53; font-size: 10px; font-weight: 780; }
  .route-mobile-controls button span { font-size: 18px; line-height: 1; }
  .route-mobile-controls button.primary-action { background: #1f7d4e; color: #fff; }
  .route-mobile-controls button:disabled { opacity: .38; }
  .route-mobile-controls #route-mobile-delete:not(:disabled) { color: #aa4b38; }
  .route-undo-toast { position: absolute; z-index: 1450; right: 12px; bottom: calc(var(--mobile-nav) + 104px); left: 12px; min-height: 52px; display: flex; align-items: center; gap: 10px; padding: 8px 9px 8px 15px; border-radius: 16px; background: #26322c; color: #fff; box-shadow: 0 14px 38px #14201955; }
  .route-undo-toast[hidden] { display: none; }
  .route-undo-toast span { min-width: 0; flex: 1; overflow: hidden; font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
  .route-undo-toast button { min-height: 38px; padding: 0 13px; border-radius: 11px; background: #ffd45a; color: #272c29; font-size: 11px; font-weight: 850; }
  .map-photo-upload { bottom: calc(var(--mobile-nav) + 12px); }

  .install-prompt {
    position: fixed; z-index: 1700; right: 10px; bottom: calc(var(--mobile-nav) + 10px); left: 10px;
    min-height: 72px; display: grid; grid-template-columns: 44px minmax(0,1fr) auto 32px; gap: 9px;
    align-items: center; padding: 10px; border: 1px solid #dfe5e0; border-radius: 19px;
    background: #fffffff8; box-shadow: 0 18px 50px #14201938; backdrop-filter: blur(18px);
  }
  .install-prompt[hidden] { display: none; }
  .install-app-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: #ffd45a; color: #292b30; font-size: 22px; transform: rotate(-12deg); }
  .install-copy { min-width: 0; }
  .install-copy b,.install-copy small { display: block; }
  .install-copy b { overflow: hidden; color: #2d3230; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
  .install-copy small { margin-top: 3px; color: #6f7973; font-size: 9px; line-height: 1.25; }
  .install-primary { min-height: 40px; padding: 0 11px; border-radius: 11px; background: #20784d; color: #fff; font-size: 10px; font-weight: 800; }
  .install-primary[hidden] { display: none; }
  .install-close { width: 32px; height: 40px; padding: 0; border-radius: 10px; background: transparent; color: #7b8580; font-size: 22px; }

  body.mobile-route-mode .map-stage > .photo-map-toggle { display: none; }
  body.mobile-route-mode .leaflet-bottom.leaflet-right { bottom: calc(var(--mobile-nav) + 96px); }
  body.mobile-route-mode .app-shell .map-tools { bottom: calc(var(--mobile-nav) + 220px) !important; }
  .river-stop.route-selected { filter: drop-shadow(0 0 5px #ffd45a) drop-shadow(0 3px 5px #17251d88); }
  .river-stop.route-selected .pin-head { box-shadow: 0 0 0 4px #ffd45a; }

  .map-stage > .map-layer-panel { top: 10px !important; right: 10px; width: 46px; }
  .layer-trigger { min-height: 46px; grid-template-columns: 36px; padding: 5px; border-radius: 14px; }
  .layer-selected-icon { width: 36px; height: 36px; border-radius: 10px; }
  .layer-selected-copy, .layer-trigger > i { display: none; }
  .layer-menu {
    position: fixed; top: calc(var(--mobile-header) + 8px); right: 8px; left: 8px;
    width: auto; max-height: calc(100dvh - var(--mobile-header) - var(--mobile-nav) - 16px);
    padding: 8px; border-radius: 18px;
  }
  .layer-option-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layer-option-grid button { min-height: 56px; }

  .app-shell .map-tools, .app-shell.planning .map-tools {
    top: auto !important; right: 10px !important; bottom: calc(var(--mobile-nav) + 132px) !important;
    left: auto !important; width: 46px; height: 46px; padding: 3px; overflow: visible;
  }
  .map-tools > button { width: 40px !important; height: 40px !important; min-width: 40px; padding: 0 !important; font-size: 22px !important; }
  .leaflet-bottom.leaflet-right { right: 10px; bottom: calc(var(--mobile-nav) + 8px); }
  .leaflet-control-zoom a { width: 42px !important; height: 42px !important; line-height: 42px !important; }
  .leaflet-bottom.leaflet-left { bottom: var(--mobile-nav); }

  .map-stage > .photo-map-toggle {
    left: 10px; bottom: calc(var(--mobile-nav) + 10px); min-height: 44px; max-width: 110px;
    padding: 6px; gap: 5px; border-radius: 15px;
  }
  .photo-map-toggle .photo-toggle-label { display: none; }
  .photo-map-toggle .photo-toggle-icon { width: 30px; height: 30px; }
  .photo-map-toggle i { width: 31px; height: 18px; }

  .planner-panel {
    position: absolute; z-index: 1300; top: auto !important; right: 0 !important;
    bottom: var(--mobile-nav) !important; left: 0 !important; width: 100% !important;
    height: min(72dvh, 680px); max-height: calc(100dvh - var(--mobile-header) - var(--mobile-nav) - 18px) !important;
    border: 0; border-radius: 22px 22px 0 0; box-shadow: 0 -18px 55px #1420193b;
  }
  .planner-panel::before {
    content: ""; position: absolute; z-index: 20; top: 6px; left: 50%; width: 42px; height: 4px;
    transform: translateX(-50%); border-radius: 3px; background: #d2d7d3;
  }
  .planner-title { min-height: 52px; padding: 17px 14px 7px; }
  .planner-title input { font-size: 18px; }
  .planner-title button { width: 40px; height: 40px; }
  .route-switcher { grid-template-columns: 6px minmax(0,1fr) 40px 40px 42px; margin: 0 10px 8px; padding: 7px 7px 7px 10px; }
  .route-switcher > button { width: 40px; height: 40px; }
  .planner-stats { grid-template-columns: repeat(4, 1fr); }
  .planner-stats div { min-width: 0; padding: 8px 2px; }
  .planner-stats b { font-size: 15px; }
  .workspace-tabs { margin: 0 9px 7px; padding: 3px; overflow-x: auto; }
  .workspace-tabs button { min-width: 68px; height: 38px; flex: 1 0 auto; }
  .workspace-view { padding: 11px 10px 18px; overscroll-behavior: contain; }
  .workspace-view .route-mode-settings { grid-template-columns: minmax(0,1fr) 108px; padding: 8px; }
  .workspace-view .route-edit-toolbar { grid-template-columns: 42px 42px repeat(3, minmax(0,1fr)); overflow-x: auto; }
  .workspace-view .route-edit-toolbar button { min-height: 42px; font-size: 10px; }
  .workspace-view .route-node-tools { grid-template-columns: repeat(3, minmax(0,1fr)); gap: 6px; }
  .workspace-view .route-node-tools .point-type { min-width: 0; height: 44px; padding: 0 5px; font-size: 10px; }
  .workspace-view .point-palette { grid-template-columns: repeat(5, minmax(0,1fr)); gap: 7px; }
  .workspace-view .point-palette button { min-width: 0; height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 3px; font-size: 23px; }
  .workspace-view .point-palette button small { display: block; width: 100%; overflow: hidden; color: #536159; font-size: 8px; line-height: 1.1; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
  .workspace-view .route-point-row { min-height: 46px; padding: 5px 6px; }
  .workspace-view .route-point-copy b { font-size: 11px; }
  .workspace-view .route-point-copy small { font-size: 9px; }
  .route-point-controls button { min-width: 34px; min-height: 34px; }
  .planner-actions { grid-template-columns: 1fr 1fr; gap: 7px; padding: 9px 10px calc(9px + env(safe-area-inset-bottom, 0px)); }
  .planner-actions .build-route { grid-column: 1 / -1; min-height: 45px; font-size: 12px; }
  .planner-actions #route-share, .planner-actions #river-export { min-height: 42px; font-size: 11px; }

  .point-dialog, .import-dialog { align-items: end; padding: 0; }
  .point-dialog form, .import-card { width: 100%; max-height: calc(100dvh - 18px); overflow-y: auto; padding: 23px 16px calc(18px + env(safe-area-inset-bottom, 0px)); border-radius: 22px 22px 0 0; }
  .point-dialog input, .point-dialog select, .point-dialog textarea { min-height: 44px; font-size: 16px; }
  .point-relative-actions button, .point-form-actions button { min-height: 44px; }
  .viewer { padding: 18px 12px 76px; }
  .viewer figure { max-width: 100%; width: 100%; }
  .viewer img { max-height: 68dvh; }
  .viewer-nav { top: auto; bottom: 18px; width: 48px; height: 48px; border-radius: 50%; background: #ffffff18; font-size: 38px; }
  .viewer-nav.prev { left: calc(50% - 58px); }
  .viewer-nav.next { right: calc(50% - 58px); }
  .viewer-close { top: 8px; right: 10px; width: 48px; height: 48px; border-radius: 50%; background: #10161280; }
}

@media (max-width: 380px) {
  .workspace-brand b { font-size: 15px; }
  .workspace-bar nav .nav-label { font-size: 9px; }
  .workspace-view .route-mode-settings { grid-template-columns: 1fr; }
  .workspace-view .point-palette { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .route-switcher { grid-template-columns: 5px minmax(0,1fr) 38px 38px 38px; gap: 4px; }
  .install-prompt { grid-template-columns: 40px minmax(0,1fr) 30px; }
  .install-app-icon { width: 40px; height: 40px; }
  .install-primary { grid-column: 2; min-height: 34px; }
  .install-close { grid-column: 3; grid-row: 1 / span 2; }
}

@media (max-width: 760px) and (max-height: 650px) {
  .planner-panel { height: calc(100dvh - var(--mobile-header) - var(--mobile-nav) - 8px); }
  .planner-title { display: none; }
  .route-switcher { margin-top: 14px; }
  .planner-stats div { padding-top: 5px; padding-bottom: 5px; }
  .workspace-tabs { margin-bottom: 4px; }
}

@media (max-width: 900px) and (orientation: landscape) {
  .planner-panel { height: calc(100dvh - var(--mobile-header) - var(--mobile-nav)); max-height: none !important; }
  .planner-title { padding-top: 11px; }
  .planner-panel::before { display: none; }
}
