/* Build 730: direct, premium Life Chapter editing without covering the story photo. */

/* Home keeps the editing control in the card footer, beside the primary journey action. */
html body .app-shell .map-stage.home-focus #homeJourney .life-chapter-actions,
html body main.app-shell section.map-stage.home-focus #homeJourney .life-chapter-actions {
  display: grid !important;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr) !important;
  align-items: center !important;
  width: 100% !important;
  gap: 8px !important;
}

html body .app-shell .map-stage.home-focus #homeJourney .life-chapter-actions .life-chapter-completion-status,
html body main.app-shell section.map-stage.home-focus #homeJourney .life-chapter-actions .life-chapter-completion-status {
  grid-column: 1 / -1 !important;
}

/* The old focus-only control is replaced by the labeled Edit chapter action. */
html body .app-shell .map-stage.home-focus #homeJourney .life-chapter-actions .life-chapter-adjust-cover,
html body main.app-shell section.map-stage.home-focus #homeJourney .life-chapter-actions .life-chapter-adjust-cover {
  display: none !important;
}

html body .app-shell .map-stage.home-focus #homeJourney .life-chapter-actions :is(
  .life-chapter-edit,
  .life-chapter-edit-cover,
  [data-life-chapter-edit]
),
html body main.app-shell section.map-stage.home-focus #homeJourney .life-chapter-actions :is(
  .life-chapter-edit,
  .life-chapter-edit-cover,
  [data-life-chapter-edit]
) {
  position: static !important;
  grid-column: 1 !important;
  display: inline-flex !important;
  width: 100% !important;
  min-width: 0 !important;
  min-height: 44px !important;
  margin: 0 !important;
  padding: 10px 12px !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 7px !important;
  border: 1px solid rgba(8, 92, 105, 0.17) !important;
  border-radius: 999px !important;
  color: #075769 !important;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(226, 246, 239, 0.88)) !important;
  box-shadow: 0 7px 16px rgba(4, 67, 78, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.94) !important;
  font: inherit !important;
  font-size: 0.72rem !important;
  font-weight: 820 !important;
  line-height: 1.05 !important;
  white-space: nowrap !important;
  cursor: pointer !important;
  touch-action: manipulation !important;
}

html body .app-shell .map-stage.home-focus #homeJourney .life-chapter-actions :is(
  .life-chapter-edit,
  .life-chapter-edit-cover,
  [data-life-chapter-edit]
) svg,
html body main.app-shell section.map-stage.home-focus #homeJourney .life-chapter-actions :is(
  .life-chapter-edit,
  .life-chapter-edit-cover,
  [data-life-chapter-edit]
) svg {
  width: 16px !important;
  height: 16px !important;
  flex: 0 0 16px !important;
  stroke-width: 2.15 !important;
}

html body .app-shell .map-stage.home-focus #homeJourney .life-chapter-actions .life-chapter-relive,
html body main.app-shell section.map-stage.home-focus #homeJourney .life-chapter-actions .life-chapter-relive {
  grid-column: 2 !important;
  width: 100% !important;
  min-width: 0 !important;
  min-height: 44px !important;
  margin: 0 !important;
}

html body .app-shell .map-stage.home-focus #homeJourney .life-chapter-actions :is(
  .life-chapter-edit,
  .life-chapter-edit-cover,
  [data-life-chapter-edit]
):focus-visible,
html body main.app-shell section.map-stage.home-focus #homeJourney .life-chapter-actions :is(
  .life-chapter-edit,
  .life-chapter-edit-cover,
  [data-life-chapter-edit]
):focus-visible,
html body .app-shell .life-chapter-editor-dialog :is(button, input, textarea):focus-visible {
  outline: 3px solid rgba(76, 218, 180, 0.58) !important;
  outline-offset: 2px !important;
}

@media (hover: hover) {
  html body .app-shell .map-stage.home-focus #homeJourney .life-chapter-actions :is(
    .life-chapter-edit,
    .life-chapter-edit-cover,
    [data-life-chapter-edit]
  ):hover,
  html body main.app-shell section.map-stage.home-focus #homeJourney .life-chapter-actions :is(
    .life-chapter-edit,
    .life-chapter-edit-cover,
    [data-life-chapter-edit]
  ):hover {
    color: #043f52 !important;
    border-color: rgba(8, 112, 114, 0.27) !important;
    background: linear-gradient(145deg, #ffffff, #dcf5ea) !important;
    box-shadow: 0 9px 19px rgba(4, 67, 78, 0.12), inset 0 1px 0 #fff !important;
    transform: translateY(-1px) !important;
  }
}

/* One responsive Edit Life Chapter surface for title, exact cover, framing and detail. */
html body .app-shell .life-chapter-editor-dialog {
  width: min(620px, calc(100vw - 32px)) !important;
  max-width: 620px !important;
  max-height: min(88dvh, 790px) !important;
  margin: auto !important;
  overflow: visible !important;
  border-radius: 28px !important;
}

html body .app-shell .life-chapter-editor-panel {
  width: 100% !important;
  max-height: min(88dvh, 790px) !important;
  padding: 22px !important;
  gap: 16px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain !important;
  border-radius: 28px !important;
  background:
    radial-gradient(circle at 8% 0%, rgba(117, 232, 197, 0.18), transparent 34%),
    radial-gradient(circle at 96% 24%, rgba(66, 183, 216, 0.1), transparent 31%),
    linear-gradient(150deg, #fffefa 0%, #f5fbf7 54%, #eaf6f3 100%) !important;
  scrollbar-width: thin !important;
  scrollbar-color: rgba(12, 119, 112, 0.28) transparent !important;
}

html body .app-shell .life-chapter-editor-panel > header {
  gap: 18px !important;
}

html body .app-shell .life-chapter-editor-panel h2 {
  color: #073f4d !important;
  font-size: clamp(1.45rem, 3vw, 1.85rem) !important;
  font-weight: 860 !important;
  letter-spacing: -0.035em !important;
}

html body .app-shell .life-chapter-editor-intro {
  max-width: 56ch !important;
  margin: -4px 0 0 !important;
  color: rgba(10, 68, 78, 0.7) !important;
  font-size: 0.82rem !important;
  font-weight: 640 !important;
  line-height: 1.45 !important;
}

html body .app-shell .life-chapter-editor-dialog[data-mode="personalize"] .life-chapter-completion-steps {
  display: none !important;
}

html body .app-shell .life-chapter-title-field,
html body .app-shell .life-chapter-detail-field {
  gap: 8px !important;
  color: #235963 !important;
  font-size: 0.74rem !important;
  font-weight: 830 !important;
}

html body .app-shell .life-chapter-title-field input,
html body .app-shell .life-chapter-detail-field textarea {
  border-color: rgba(13, 101, 104, 0.17) !important;
  border-radius: 16px !important;
  color: #0d414c !important;
  background: rgba(255, 255, 252, 0.88) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.98), 0 7px 18px rgba(8, 73, 79, 0.05) !important;
}

html body .app-shell .life-chapter-cover-field {
  display: grid !important;
  padding: 15px !important;
  gap: 12px !important;
  border: 1px solid rgba(10, 116, 108, 0.14) !important;
  border-radius: 21px !important;
  color: #245b64 !important;
  background:
    radial-gradient(circle at 90% 0%, rgba(72, 216, 177, 0.12), transparent 34%),
    rgba(255, 255, 252, 0.68) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.96), 0 10px 24px rgba(7, 68, 74, 0.06) !important;
}

html body .app-shell .life-chapter-cover-field > :is(
  div:first-child,
  .life-chapter-cover-heading,
  .life-chapter-cover-field-heading
) {
  display: flex !important;
  min-width: 0 !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
}

html body .app-shell :is(.life-chapter-cover-heading, .life-chapter-cover-field-heading) > :is(div, span),
html body .app-shell .life-chapter-cover-field > div:first-child:not(.life-chapter-cover-heading):not(.life-chapter-cover-field-heading) {
  display: grid !important;
  min-width: 0 !important;
  gap: 3px !important;
}

html body .app-shell #lifeChapterCoverLabel {
  color: #0a4c58 !important;
  font-size: 0.8rem !important;
  font-weight: 850 !important;
}

html body .app-shell .life-chapter-cover-field small {
  color: rgba(13, 72, 80, 0.62) !important;
  font-size: 0.68rem !important;
  font-weight: 640 !important;
  line-height: 1.35 !important;
}

html body .app-shell .life-chapter-cover-adjust,
html body .app-shell .life-chapter-adjust-framing,
html body .app-shell [data-life-chapter-adjust-framing] {
  display: inline-flex !important;
  min-width: 0 !important;
  min-height: 44px !important;
  padding: 9px 12px !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 7px !important;
  border: 1px solid rgba(7, 99, 107, 0.17) !important;
  border-radius: 999px !important;
  color: #075b68 !important;
  background: linear-gradient(145deg, #ffffff, #e5f5ef) !important;
  box-shadow: 0 7px 15px rgba(6, 76, 82, 0.08) !important;
  font: inherit !important;
  font-size: 0.7rem !important;
  font-weight: 820 !important;
  white-space: nowrap !important;
  cursor: pointer !important;
  touch-action: manipulation !important;
}

html body .app-shell :is(
  .life-chapter-cover-adjust,
  .life-chapter-adjust-framing,
  [data-life-chapter-adjust-framing]
) svg {
  width: 16px !important;
  height: 16px !important;
  flex: 0 0 16px !important;
}

html body .app-shell :is(
  .life-chapter-cover-adjust,
  .life-chapter-adjust-framing,
  [data-life-chapter-adjust-framing]
):disabled,
html body .app-shell :is(
  .life-chapter-cover-adjust,
  .life-chapter-adjust-framing,
  [data-life-chapter-adjust-framing]
)[aria-disabled="true"] {
  opacity: 0.48 !important;
  box-shadow: none !important;
  cursor: default !important;
}

html body .app-shell .life-chapter-cover-selection {
  display: grid !important;
  grid-template-columns: minmax(0, 1.35fr) minmax(150px, 0.65fr) !important;
  min-width: 0 !important;
  align-items: center !important;
  gap: 13px !important;
  padding: 10px !important;
  border: 1px solid rgba(10, 101, 105, 0.12) !important;
  border-radius: 18px !important;
  background: rgba(245, 251, 247, 0.86) !important;
}

html body .app-shell .life-chapter-cover-selection-media {
  position: relative !important;
  display: grid !important;
  width: 100% !important;
  min-width: 0 !important;
  aspect-ratio: 16 / 10 !important;
  place-items: center !important;
  overflow: hidden !important;
  border: 1px solid rgba(115, 177, 171, 0.28) !important;
  border-radius: 15px !important;
  background: linear-gradient(145deg, #dceee9, #c8e2de) !important;
  box-shadow: 0 9px 20px rgba(6, 64, 71, 0.09) !important;
}

html body .app-shell .life-chapter-cover-selection-media img {
  position: absolute !important;
  inset: 0 !important;
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  object-fit: cover !important;
  object-position: var(--home-photo-position, center center) !important;
}

html body .app-shell .life-chapter-cover-selection-copy {
  display: grid !important;
  min-width: 0 !important;
  gap: 5px !important;
}

html body .app-shell .life-chapter-cover-selection-copy > span {
  color: #0a8179 !important;
  font-size: 0.63rem !important;
  font-weight: 850 !important;
  letter-spacing: 0.09em !important;
  text-transform: uppercase !important;
}

html body .app-shell .life-chapter-cover-selection-copy > strong {
  color: #0a4854 !important;
  font-size: 0.84rem !important;
  font-weight: 820 !important;
  line-height: 1.3 !important;
  overflow-wrap: anywhere !important;
}

/* Desktop shows every available photo as a calm, scrollable gallery. */
html body .app-shell .life-chapter-cover-picker {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)) !important;
  grid-auto-flow: row !important;
  grid-auto-columns: unset !important;
  width: 100% !important;
  max-height: 252px !important;
  padding: 4px 5px 7px 3px !important;
  gap: 9px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain !important;
  scroll-snap-type: none !important;
  scrollbar-width: thin !important;
  scrollbar-color: rgba(12, 119, 112, 0.28) transparent !important;
}

html body .app-shell .life-chapter-cover-picker::-webkit-scrollbar {
  display: block !important;
  width: 6px !important;
  height: 6px !important;
}

html body .app-shell .life-chapter-cover-picker::-webkit-scrollbar-track {
  background: transparent !important;
}

html body .app-shell .life-chapter-cover-picker::-webkit-scrollbar-thumb {
  border-radius: 999px !important;
  background: rgba(12, 119, 112, 0.26) !important;
}

html body .app-shell .life-chapter-cover-option {
  position: relative !important;
  display: grid !important;
  width: 100% !important;
  height: auto !important;
  min-width: 0 !important;
  min-height: 76px !important;
  aspect-ratio: 1 / 1 !important;
  place-items: center !important;
  padding: 0 !important;
  overflow: hidden !important;
  scroll-snap-align: none !important;
  border: 2px solid transparent !important;
  border-radius: 16px !important;
  background: #e4f2ee !important;
  box-shadow: 0 7px 16px rgba(8, 65, 70, 0.08) !important;
  cursor: pointer !important;
  touch-action: manipulation !important;
}

html body .app-shell .life-chapter-cover-option img {
  position: absolute !important;
  inset: 0 !important;
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  object-position: var(--home-photo-position, center center) !important;
}

html body .app-shell .life-chapter-cover-option:is(.selected, [aria-pressed="true"], [aria-checked="true"]) {
  border-color: #0e8b7b !important;
  box-shadow: 0 0 0 3px rgba(14, 139, 123, 0.14), 0 10px 21px rgba(8, 65, 70, 0.14) !important;
}

html body .app-shell .life-chapter-cover-option:is(.selected, [aria-pressed="true"], [aria-checked="true"])::after {
  content: "\2713" !important;
  position: absolute !important;
  z-index: 3 !important;
  top: 7px !important;
  right: 7px !important;
  display: grid !important;
  width: 22px !important;
  height: 22px !important;
  place-items: center !important;
  border: 2px solid rgba(255, 255, 255, 0.92) !important;
  border-radius: 50% !important;
  color: #fff !important;
  background: linear-gradient(145deg, #27b98e, #087c78) !important;
  box-shadow: 0 4px 10px rgba(3, 54, 60, 0.24) !important;
  font-size: 0.72rem !important;
  font-weight: 900 !important;
  line-height: 1 !important;
}

html body .app-shell .life-chapter-cover-option.automatic {
  padding: 9px !important;
  align-content: center !important;
  gap: 6px !important;
  color: #155d65 !important;
  background:
    radial-gradient(circle at 30% 18%, rgba(86, 226, 181, 0.24), transparent 38%),
    linear-gradient(145deg, #fbfffc, #dcefeb) !important;
}

html body .app-shell .life-chapter-cover-option.automatic strong {
  max-width: 10ch !important;
  font-size: 0.64rem !important;
  line-height: 1.15 !important;
  text-align: center !important;
}

html body .app-shell .life-chapter-cover-option:focus-visible {
  outline: 3px solid rgba(65, 210, 172, 0.58) !important;
  outline-offset: 2px !important;
}

/* The footer remains available while a long photo collection scrolls. */
html body .app-shell .life-chapter-editor-panel > footer {
  position: sticky !important;
  z-index: 8 !important;
  bottom: 0 !important;
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr) !important;
  min-height: 66px !important;
  margin: 0 -22px -22px !important;
  padding: 11px 22px max(12px, env(safe-area-inset-bottom, 0px)) !important;
  align-items: center !important;
  gap: 10px !important;
  border-top: 1px solid rgba(9, 100, 99, 0.12) !important;
  background: rgba(248, 252, 247, 0.9) !important;
  box-shadow: 0 -10px 26px rgba(8, 62, 68, 0.07) !important;
  backdrop-filter: blur(14px) saturate(1.08) !important;
  -webkit-backdrop-filter: blur(14px) saturate(1.08) !important;
}

html body .app-shell .life-chapter-editor-panel > footer > span {
  display: flex !important;
  min-width: 0 !important;
  justify-content: flex-end !important;
  gap: 9px !important;
}

html body .app-shell .life-chapter-editor-panel > footer button {
  min-height: 44px !important;
  border-radius: 999px !important;
}

@media (max-width: 720px), (hover: none) and (pointer: coarse) and (max-width: 1024px) {
  html body .app-shell .map-stage.home-focus #homeJourney .life-chapter-actions,
  html body main.app-shell section.map-stage.home-focus #homeJourney .life-chapter-actions {
    grid-template-columns: minmax(0, 0.94fr) minmax(0, 1.06fr) !important;
  }

  html body .app-shell .map-stage.home-focus #homeJourney .life-chapter-actions :is(
    .life-chapter-edit,
    .life-chapter-edit-cover,
    [data-life-chapter-edit]
  ),
  html body main.app-shell section.map-stage.home-focus #homeJourney .life-chapter-actions :is(
    .life-chapter-edit,
    .life-chapter-edit-cover,
    [data-life-chapter-edit]
  ) {
    min-height: 46px !important;
    padding-inline: 10px !important;
    font-size: 0.7rem !important;
  }

  html body .app-shell .map-stage.home-focus #homeJourney .life-chapter-actions .life-chapter-relive,
  html body main.app-shell section.map-stage.home-focus #homeJourney .life-chapter-actions .life-chapter-relive {
    min-height: 46px !important;
  }

  html body .app-shell .life-chapter-editor-dialog {
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
    max-height: calc(var(--mymappi-visible-height, 100dvh) - 16px) !important;
    border-radius: 25px !important;
  }

  html body .app-shell .life-chapter-editor-panel {
    max-height: calc(var(--mymappi-visible-height, 100dvh) - 16px) !important;
    padding:
      max(18px, env(safe-area-inset-top, 0px))
      16px
      16px !important;
    gap: 14px !important;
    border-radius: 25px !important;
  }

  html body .app-shell .life-chapter-cover-field {
    padding: 13px !important;
    border-radius: 19px !important;
  }

  html body .app-shell .life-chapter-cover-field > :is(
    div:first-child,
    .life-chapter-cover-heading,
    .life-chapter-cover-field-heading
  ) {
    align-items: flex-start !important;
  }

  html body .app-shell .life-chapter-cover-adjust,
  html body .app-shell .life-chapter-adjust-framing,
  html body .app-shell [data-life-chapter-adjust-framing] {
    min-height: 44px !important;
    padding-inline: 10px !important;
  }

  html body .app-shell .life-chapter-cover-selection {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  html body .app-shell .life-chapter-cover-selection-media {
    aspect-ratio: 16 / 9 !important;
  }

  html body .app-shell .life-chapter-cover-picker {
    grid-template-columns: none !important;
    grid-auto-flow: column !important;
    grid-auto-columns: 84px !important;
    max-height: none !important;
    padding: 4px 4px 10px !important;
    gap: 9px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    overscroll-behavior-inline: contain !important;
    scroll-snap-type: x proximity !important;
    scrollbar-width: none !important;
    touch-action: pan-x pinch-zoom !important;
  }

  html body .app-shell .life-chapter-cover-picker::-webkit-scrollbar {
    display: none !important;
  }

  html body .app-shell .life-chapter-cover-option {
    width: 84px !important;
    min-width: 84px !important;
    min-height: 84px !important;
    aspect-ratio: 1 / 1 !important;
    scroll-snap-align: start !important;
  }

  html body .app-shell .life-chapter-editor-panel > footer {
    bottom: 0 !important;
    grid-template-columns: minmax(0, 1fr) !important;
    min-height: 0 !important;
    margin: 0 -16px -16px !important;
    padding: 11px 16px max(12px, env(safe-area-inset-bottom, 0px)) !important;
    gap: 8px !important;
  }

  html body .app-shell .life-chapter-editor-panel > footer > span {
    display: grid !important;
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr) !important;
    width: 100% !important;
  }

  html body .app-shell .life-chapter-editor-reset {
    justify-self: center !important;
  }
}

@media (max-width: 380px) {
  html body .app-shell .map-stage.home-focus #homeJourney .life-chapter-actions :is(
    .life-chapter-edit,
    .life-chapter-edit-cover,
    [data-life-chapter-edit]
  ) {
    gap: 5px !important;
    padding-inline: 8px !important;
    font-size: 0.66rem !important;
  }

  html body .app-shell .life-chapter-cover-field > :is(
    div:first-child,
    .life-chapter-cover-heading,
    .life-chapter-cover-field-heading
  ) {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
  }

  html body .app-shell .life-chapter-cover-adjust,
  html body .app-shell .life-chapter-adjust-framing,
  html body .app-shell [data-life-chapter-adjust-framing] {
    width: 100% !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  html body .app-shell .map-stage.home-focus #homeJourney .life-chapter-actions button,
  html body .app-shell .life-chapter-editor-dialog,
  html body .app-shell .life-chapter-editor-dialog *,
  html body .app-shell .life-chapter-editor-dialog *::before,
  html body .app-shell .life-chapter-editor-dialog *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }
}
