/* v1.0.0-alpha.11.06: adaptive Create Letter scrolling for Outlook Mac/WebKit. */

/* Let the dialog itself use the available pane and scroll when the viewport is short. */
.letter-dialog {
  box-sizing: border-box !important;
  width: 100% !important;
  max-height: calc(100dvh - 12px) !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  overscroll-behavior-y: contain !important;
  display: block !important;
  min-height: 0 !important;
}

/* Do not allow a flex parent to collapse the template area behind the output panel. */
.letter-dialog .letter-section,
.letter-dialog .letter-template-section {
  min-height: 0 !important;
  overflow: visible !important;
}

/* The list always keeps a usable viewport and scrolls independently. */
.letter-template-list {
  display: block !important;
  box-sizing: border-box !important;
  height: clamp(150px, 31dvh, 300px) !important;
  min-height: 150px !important;
  max-height: 300px !important;
  flex: none !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  overscroll-behavior-y: contain !important;
  touch-action: pan-y !important;
  scrollbar-gutter: stable !important;
  position: relative !important;
  z-index: 1 !important;
}

/* Keep the destination/output panel in normal flow below the visible list. */
.letter-output {
  position: relative !important;
  inset: auto !important;
  z-index: 1 !important;
  margin-top: 10px !important;
  flex: none !important;
}

/* Compact address typography only; no structural UI changes. */
.letter-address,
.letter-address strong {
  font-size: 12px !important;
  line-height: 1.3 !important;
}

.letter-address span {
  display: block !important;
  margin-top: 3px !important;
  font-size: 12px !important;
  line-height: 1.35 !important;
  overflow-wrap: anywhere !important;
}

@media (max-height: 760px) {
  .letter-dialog {
    max-height: calc(100dvh - 6px) !important;
  }

  .letter-template-list {
    height: clamp(140px, 28dvh, 220px) !important;
    min-height: 140px !important;
  }
}

/* Fallback for hosts that do not support dynamic viewport units. */
@supports not (height: 100dvh) {
  .letter-dialog {
    max-height: calc(100vh - 12px) !important;
  }

  .letter-template-list {
    height: clamp(150px, 31vh, 300px) !important;
  }
}
