/* Field controls also remain usable on desktop. No location is requested until a click. */
.geolocate-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid #c5d2bf;
  border-radius: 8px;
  background: #fafcf3f5;
  color: #163f32;
  box-shadow: 0 3px 15px #2b462211;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.geolocate-icon { font-size: 22px; line-height: 1; }
.geolocation-status {
  position: fixed;
  z-index: 470;
  right: 25px;
  top: 80px;
  width: min(310px, calc(100vw - 40px));
  margin: 0;
  padding: 12px 14px;
  border: 1px solid #bfceb7;
  border-radius: 10px;
  background: #f9fcf3f7;
  color: #254333;
  box-shadow: 0 3px 18px #243a2426;
  font-size: 12px;
  line-height: 1.5;
}
.geolocation-status.error { border-color: #e1c1a9; background: #fff5edf7; color: #70411f; }

@media (min-width: 601px) and (max-width: 1000px) {
  .map-top { gap: 8px; }
  .basemap-control { gap: 4px; padding: 4px 6px; }
  .basemap-control select { width: 72px; padding: 4px; }
  .geolocate-button { padding: 6px 8px; font-size: 11px; gap: 4px; }
  .map-button { padding: 8px 10px; min-height: 44px; font-size: 10px; }
}
@media (min-width: 601px) and (max-width: 850px) {
  #fit-map { padding: 0; width: 44px; min-width: 44px; font-size: 0; }
  #fit-map span { margin: 0; font-size: 22px; }
}
@media (min-width: 601px) and (max-width: 720px) {
  .geolocate-button { width: 44px; min-width: 44px; }
  .geolocate-button > span:last-child { display: none; }
}

@media (max-width: 600px) {
  :root { --field-panel-height: 42dvh; }
  html, body { width: 100%; height: 100%; overflow: hidden; }
  #map { width: 100%; height: 100dvh; }
  .sidebar {
    max-height: var(--field-panel-height);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -5px 28px #193a2524;
  }
  .app-header { min-height: 74px; padding: 4px 15px; }
  .about-button { width: 48px; min-height: 48px; font-size: 10px; }
  .about-icon { width: 30px; height: 30px; }
  .app-title { font-size: 13px; line-height: 1.35; }
  .sidebar-scroll { padding: 16px 18px 26px; }
  .origin-controls h1 { font-size: 23px; }
  .intro { font-size: 15px; line-height: 1.6; }
  .point-hint, .search-status, .no-results { font-size: 13px; line-height: 1.55; }
  .field-label, .mode-toggle, .indicators-section summary, .coordinate-controls summary { font-size: 14px; }
  input[type="search"], input[type="number"], select { font-size: 16px!important; min-height: 44px; }
  .place-search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .place-search-row input { width: 100%; min-width: 0; }
  .place-search-row button { min-width: 68px; min-height: 44px; font-size: 14px; }
  .place-search-results button { min-height: 48px; font-size: 14px; }
  .text-button, .icon-button, .ai-zone-button, .popup-link { min-height: 44px; }
  .icon-button { min-width: 44px; }
  .origin-actions .text-button { padding: 10px 0; }
  .indicator-option { min-height: 44px; font-size: 14px; }
  .indicator-option input { width: 20px; height: 20px; }
  .candidate-card { padding: 16px 0; }
  .candidate-name { font-size: 15px; }
  .candidate-region { font-size: 12px; line-height: 1.5; }
  .candidates-heading { gap: 8px; flex-wrap: wrap; }
  .candidates-heading h3 { font-size: 14px; margin: 0; }
  .result-actions { margin-left: auto; }
  .result-actions .text-button { font-size: 13px; }

  .map-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px;
    align-items: stretch;
    gap: 8px;
    top: max(10px, env(safe-area-inset-top, 0px));
    left: 10px;
    right: 10px;
  }
  .basemap-control { min-width: 0; min-height: 44px; padding: 3px 6px; gap: 4px; font-size: 11px; }
  .basemap-control select { min-width: 0; width: 100%; font-size: 13px!important; padding: 3px; border: 0; }
  .geolocate-button { width: 100%; min-width: 0; padding: 6px; gap: 4px; font-size: 12px; }
  .geolocate-icon { font-size: 20px; }
  #fit-map { margin: 0; padding: 0; font-size: 0; width: 44px; min-height: 44px; }
  #fit-map span { margin: 0; font-size: 22px; }
  .leaflet-top.leaflet-right { top: 66px; right: 10px; }
  .leaflet-control-zoom a { width: 44px!important; height: 44px!important; line-height: 44px!important; }
  .map-explanation {
    top: calc(max(10px, env(safe-area-inset-top, 0px)) + 56px);
    left: 10px;
    width: calc(100vw - 74px);
    max-height: 115px;
    overflow: auto;
    padding: 10px 12px;
    border-radius: 10px;
  }
  .map-explanation strong { font-size: 14px; }
  .map-explanation p { font-size: 13px; line-height: 1.45; margin: 6px 0 0; }
  .map-explanation small { display: none; }
  .geolocation-status {
    top: calc(max(10px, env(safe-area-inset-top, 0px)) + 56px);
    left: 10px;
    right: 74px;
    width: auto;
    font-size: 13px;
  }
  .timeline {
    display: block;
    left: 10px;
    right: 10px;
    width: auto;
    bottom: calc(var(--field-panel-height) + 58px);
    margin: 0;
    padding: 10px 14px 8px;
    border-radius: 12px;
    box-shadow: 0 2px 16px #1b3b242a;
  }
  .timeline-label { gap: 8px; }
  .timeline-label>span:first-child { font-size: 13px; }
  .timeline-label strong { font-size: 28px; }
  .timeline-label>span:last-child { font-size: 10px; }
  .timeline input { margin: 5px 0; min-height: 36px; }
  .year-ticks { font-size: 12px; }
  .mobile-toggle {
    right: 12px;
    bottom: calc(var(--field-panel-height) + 7px);
    min-height: 44px;
    min-width: 130px;
    padding: 8px 14px;
    font-size: 12px;
  }
  .sidebar-collapsed .sidebar { transform: translateY(calc(100% - 74px - env(safe-area-inset-bottom, 0px))); }
  .sidebar-collapsed .mobile-toggle { bottom: calc(83px + env(safe-area-inset-bottom, 0px)); }
  .sidebar-collapsed .timeline { bottom: calc(134px + env(safe-area-inset-bottom, 0px)); }
  .map-legend { display: none; }
  .vineyard-status {
    left: 10px;
    right: 10px;
    bottom: calc(var(--field-panel-height) + 177px);
    max-width: none;
    width: fit-content;
    max-height: 34px;
    overflow: auto;
    font-size: 10px;
    line-height: 1.4;
  }
  .sidebar-collapsed .vineyard-status { bottom: calc(254px + env(safe-area-inset-bottom, 0px)); }
  .leaflet-bottom.leaflet-right { bottom: var(--field-panel-height); }
  .sidebar-collapsed .leaflet-bottom.leaflet-right { bottom: calc(74px + env(safe-area-inset-bottom, 0px)); }
  .leaflet-control-attribution { font-size: 8px!important; }
  .leaflet-popup-content { max-width: calc(100vw - 90px); font-size: 15px!important; }
  .popup-name { font-size: 20px; }
  .popup-caption { font-size: 13px; }
  .popup-actions { gap: 10px; flex-wrap: nowrap; }
  .popup-actions .popup-link { display: inline-flex; align-items: center; font-size: 13px; }
  .ai-zone-button { padding: 0; font-size: 13px; }
  dialog { max-width: calc(100vw - 20px); max-height: 86dvh; padding: 28px 18px 22px; border-radius: 16px; }
  .dialog-close { top: 8px; right: 8px; }
  .insight-dialog, .detail-dialog, .info-dialog { width: calc(100vw - 20px); }
  .insight-dialog h2 { margin-right: 40px; padding-right: 0; font-size: 26px; }
  .insight-context { font-size: 14px; }
  .insight-content { font-size: 17px; }
  .insight-description { line-height: 1.7; }
}

@media (max-width: 600px) and (max-height: 700px) {
  :root { --field-panel-height: 38dvh; }
  .map-explanation { max-height: 91px; }
  .vineyard-status { display: none; }
}

@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
  .sidebar { width: 310px; left: 0; top: 0; bottom: 0; max-height: none; border-radius: 0 14px 14px 0; }
  .sidebar-collapsed .sidebar { transform: translateX(calc(-100% + 54px)); }
  .map-top { left: 324px; right: 12px; top: 10px; gap: 6px; }
  .sidebar-collapsed .map-top { left: 66px; }
  .map-explanation { left: 324px; top: 66px; width: min(280px, calc(100vw - 394px)); max-height: 100px; overflow: auto; }
  .sidebar-collapsed .map-explanation { left: 66px; width: min(280px, calc(100vw - 136px)); }
  .timeline { display: block; left: 324px; right: 12px; bottom: 12px; width: auto; transform: none; padding: 8px 14px; }
  .sidebar-collapsed .timeline { left: 66px; bottom: 12px; }
  .mobile-toggle { display: block; position: fixed; min-height: 44px; left: 318px; right: auto; top: auto; bottom: 122px; font-size: 11px; }
  .sidebar-collapsed .mobile-toggle { left: 62px; bottom: 122px; }
  .vineyard-status, .map-legend { display: none; }
}
