/* Native WebView adjustments. These rules are activated only after native-runtime.js
   marks the document as a Capacitor app. */
html.native-app {
  --native-safe-top: max(env(safe-area-inset-top, 0px), 28px);
  --native-safe-bottom: max(env(safe-area-inset-bottom, 0px), 48px);
}

.native-app .topbar {
  height: calc(72px + var(--native-safe-top));
  padding-top: calc(12px + var(--native-safe-top));
}

.native-app .app-shell {
  padding-bottom: calc(80px + var(--native-safe-bottom));
}

.native-app .bottom-nav {
  height: calc(72px + var(--native-safe-bottom));
  padding-bottom: calc(7px + var(--native-safe-bottom));
}

/* WKWebView can mispaint a translucent fixed layer while the root document is
   momentum-scrolling. Keep the iOS nav as a simple viewport-fixed opaque layer,
   explicitly anchored on both horizontal edges instead of relying on its static
   position inside the centered app shell. */
html.native-ios body {
  display: block;
  width: 100%;
}

html.native-ios .app-shell {
  margin-left: auto;
  margin-right: auto;
}

html.native-ios .bottom-nav {
  position: fixed !important;
  left: 0;
  right: 0;
  top: auto !important;
  bottom: 0 !important;
  width: min(100%, 480px);
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
  transform: none !important;
  -webkit-transform: none !important;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background: rgba(255,253,247,.995);
}

.native-app body.modal-open {
  overflow: hidden;
}

.native-app body.modal-open #appShell {
  pointer-events: none;
}

.native-app body.modal-open #modalRoot {
  pointer-events: auto;
}

.native-app .modal-backdrop {
  z-index: 10000;
  pointer-events: auto;
  isolation: isolate;
}

.native-app .modal {
  position: relative;
  z-index: 1;
  max-height: calc(100dvh - var(--native-safe-top));
  padding-bottom: calc(22px + var(--native-safe-bottom));
  pointer-events: auto;
  touch-action: pan-y;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.native-app .modal button,
.native-app .modal .button-link,
.native-app .modal label {
  touch-action: manipulation;
}

.native-app .native-finish-open .bottom-nav {
  display: none;
}

.native-app .native-finish-open .app-shell {
  padding-bottom: var(--native-safe-bottom);
}

.native-app .native-finish-screen {
  width: 100%;
  padding: 4px 0 calc(28px + var(--native-safe-bottom));
}

.native-app .native-finish-head {
  position: sticky;
  top: calc(72px + var(--native-safe-top));
  z-index: 8;
  margin: -4px -2px 16px;
  padding: 10px 2px;
  background: var(--cream);
}

.native-app .native-finish-save {
  width: 100%;
  min-height: 56px;
  font-size: 17px;
}

.native-app .native-finish-screen button,
.native-app .native-finish-screen input,
.native-app .native-finish-screen textarea,
.native-app .native-finish-screen label {
  pointer-events: auto;
  touch-action: manipulation;
}

.native-app .toast {
  bottom: calc(95px + var(--native-safe-bottom));
}

.native-app .success-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  flex-wrap: nowrap;
}

.native-app .success-actions > * {
  min-width: 0;
  padding-left: 8px;
  padding-right: 8px;
  white-space: nowrap;
}

/* Map: radius and period stay on one responsive row instead of wrapping. */
.native-app .map-mode-switch + .card .field > .chip-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  width: 100%;
}

.native-app .map-mode-switch + .card .field > .chip-row .filter-chip {
  min-width: 0;
  min-height: 40px;
  padding: 0 3px;
  font-size: 12px;
  white-space: nowrap;
}

/* Feed: preserve the photographer's whole frame instead of forcing a 16:9 crop. */
.native-app .feed-photo {
  width: 100%;
  height: auto;
  aspect-ratio: auto;
  object-fit: contain;
  background: #e7ece7;
}

/* Compact home keeps the primary actions visible above the fold on typical phones,
   while still allowing normal scrolling on smaller screens / larger accessibility text. */
.native-app .home-page {
  display: grid;
  gap: 8px;
}

.native-app .home-page .hero {
  padding: 16px 18px;
  border-radius: 22px;
}

.native-app .home-page .hero h1 {
  margin: 4px 0;
  font-size: 24px;
  line-height: 1.06;
}

.native-app .home-page .hero p {
  font-size: 13px;
  line-height: 1.3;
}

.native-app .home-page .hero-actions {
  margin-top: 11px;
}

.native-app .home-page .hero-actions button {
  min-height: 42px;
  padding: 9px 13px;
}

.native-app .home-page .section-head {
  margin: 8px 2px 4px;
}

.native-app .home-page .section-head h2 {
  font-size: 17px;
}

.native-app .home-page .stats-grid {
  gap: 6px;
}

.native-app .home-page .stat-card {
  padding: 9px 7px;
  border-radius: 14px;
}

.native-app .home-page .stat-card strong {
  font-size: 17px;
}

.native-app .home-page .stat-card span {
  margin-top: 2px;
  font-size: 11px;
}

.native-app .home-page .micro-note {
  margin-top: 2px;
  font-size: 11px;
}

.native-app .home-page .quick-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.native-app .home-page .quick-card {
  min-height: 72px;
  padding: 8px 4px;
  border-radius: 14px;
  text-align: center;
}

.native-app .home-page .quick-card .qicon {
  margin-bottom: 5px;
  font-size: 20px;
}

.native-app .home-page .quick-card strong {
  font-size: 11px;
  line-height: 1.15;
}

.native-app .home-page .quick-card small {
  display: none;
}

.native-app .home-page .trip-card {
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 14px;
}

.native-app .home-page .trip-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 19px;
}

.native-app .home-page .trip-title,
.native-app .home-page .trip-score strong {
  font-size: 13px;
}

.native-app .home-page .trip-meta,
.native-app .home-page .trip-score small {
  font-size: 10px;
}

.native-app .home-page .empty {
  padding: 13px 10px;
  font-size: 12px;
}

.native-app .home-page .empty .big {
  display: inline;
  margin: 0 6px 0 0;
  font-size: 18px;
}

/* Atlas gets a deliberately generic botanical illustration instead of the platform emoji.
   It is decorative only and must not be interpreted as a species-identification image. */
.native-app .atlas-species-symbol {
  position: relative;
  overflow: hidden;
  font-size: 0;
  background: linear-gradient(180deg, #eef3ea 0%, #e2e9df 100%);
  border: 1px solid rgba(23,60,44,.10);
}

.native-app .atlas-species-symbol::before {
  content: '';
  position: absolute;
  left: 18%;
  right: 18%;
  top: 18%;
  height: 39%;
  border-radius: 50% 50% 42% 42% / 72% 72% 28% 28%;
  background: linear-gradient(180deg, #b66d50, #91533f);
  box-shadow: inset 0 -2px 0 rgba(255,255,255,.18), 0 2px 4px rgba(23,60,44,.12);
}

.native-app .atlas-species-symbol::after {
  content: '';
  position: absolute;
  left: 42%;
  width: 16%;
  top: 50%;
  bottom: 13%;
  border-radius: 45% 45% 35% 35%;
  background: linear-gradient(90deg, #e9dfc6, #fff8e7 50%, #ddd0b5);
  box-shadow: 0 1px 2px rgba(23,60,44,.10);
}

.native-app .atlas-species-row:has(.atlas-category-red) .atlas-species-symbol::before,
.native-app .atlas-detail-header:has(.atlas-category-red) .atlas-species-symbol::before {
  background: linear-gradient(180deg, #c76355, #944337);
}

.native-app .atlas-species-row:has(.atlas-category-green) .atlas-species-symbol::before,
.native-app .atlas-detail-header:has(.atlas-category-green) .atlas-species-symbol::before {
  background: linear-gradient(180deg, #aa7952, #795338);
}

.native-app .atlas-species-row:has(.atlas-category-amber) .atlas-species-symbol::before,
.native-app .atlas-detail-header:has(.atlas-category-amber) .atlas-species-symbol::before {
  background: linear-gradient(180deg, #c58c4e, #966331);
}

.native-app .atlas-species-symbol-large {
  width: 68px;
  height: 68px;
  min-width: 68px;
  border-radius: 18px;
}

@media (max-width: 360px) {
  .native-app .map-mode-switch + .card .field > .chip-row .filter-chip {
    font-size: 11px;
    padding: 0 2px;
  }

  .native-app .home-page .quick-card strong {
    font-size: 10px;
  }
}
