.share-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
}

.share-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.share-modal__panel {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(100% - 24px, 560px);
  max-height: min(88vh, 760px);
  overflow: auto;
  transform: translate(-50%, -50%);
  border: var(--line);
  border-radius: 28px;
  background: var(--color-surface);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.16);
}

.share-modal__head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 20px 20px 0;
}

.share-modal__eyebrow {
  margin: 0 0 4px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--color-text-muted);
}

.share-modal__head h2 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.04em;
}

.share-modal__copy {
  margin: 0;
  padding: 0 20px;
  color: var(--color-text-muted);
  line-height: 1.5;
  font-size: 0.9rem;
}

#share-modal-status {
  margin: 14px 20px 0;
  border: var(--line);
}

.share-preview {
  padding: 16px 20px;
}

.share-preview__card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: var(--line);
  border-radius: 12px;
  background: var(--color-surface-muted);
}

.share-preview__meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.share-preview__avatar {
  width: 40px;
  height: 40px;
  border: var(--line);
  border-radius: 50%;
  background: var(--color-surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-weight: 700;
  color: var(--color-text-muted);
}

.share-preview__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.share-preview__identity {
  display: grid;
  gap: 2px;
}

.share-preview__identity strong {
  font-size: 0.92rem;
}

.share-preview__identity span {
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.share-preview__text {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.08rem;
  line-height: 1.5;
}

.share-preview__media {
  border: var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--color-surface-soft);
}

.share-preview__media img {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: cover;
}

.share-preview__media--split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  aspect-ratio: 16 / 9;
  max-height: 240px;
}

.share-preview__media--split .share-preview__media-slot {
  min-width: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-soft);
  position: relative;
  overflow: hidden;
}

.share-preview__media--split .share-preview__media-slot + .share-preview__media-slot {
  border-left: var(--line);
}

.share-preview__media--split .share-preview__media-slot img {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
  object-position: center;
  display: block;
}

.share-actions {
  display: grid;
  gap: 18px;
  padding: 18px 20px 24px;
}

.share-destinations {
  display: flex;
  gap: 14px;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  padding: 4px 2px 12px;
}

.share-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-text);
  text-decoration: none;
  font: inherit;
  cursor: pointer;
  flex: 0 0 68px;
  scroll-snap-align: start;
}

/* Shared destination tiles for take and profile sharing. */
.share-action__orb,
.profile-share-action__orb {
  --share-ink: var(--color-text);
  width: 58px;
  height: 58px;
  border-radius: 19px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex: 0 0 auto;
  color: var(--share-ink);
  background: color-mix(in srgb, var(--share-ink) 7%, var(--color-surface));
  border: 1px solid color-mix(in srgb, var(--share-ink) 10%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
  transition: background 160ms ease, transform 160ms ease;
}

.share-action__orb .app-icon,
.profile-share-action__orb .app-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  font-size: 29px;
}

:is(.share-action__orb--whatsapp, .profile-share-action__orb--whatsapp) { --share-ink: #168d48; }
:root[data-theme="dark"] :is(.share-action__orb--whatsapp, .profile-share-action__orb--whatsapp) { --share-ink: #52d584; }
:is(.share-action__orb--telegram, .profile-share-action__orb--telegram) { --share-ink: #1688be; }
:root[data-theme="dark"] :is(.share-action__orb--telegram, .profile-share-action__orb--telegram) { --share-ink: #58baf0; }
:is(.share-action__orb--instagram, .profile-share-action__orb--instagram) { --share-ink: #cd2879; }
:root[data-theme="dark"] :is(.share-action__orb--instagram, .profile-share-action__orb--instagram) { --share-ink: #f178b0; }
:is(.share-action__orb--reddit, .profile-share-action__orb--reddit) { --share-ink: #df430e; }
:root[data-theme="dark"] :is(.share-action__orb--reddit, .profile-share-action__orb--reddit) { --share-ink: #ff8d64; }
:is(.share-action__orb--facebook, .profile-share-action__orb--facebook) { --share-ink: #0866ff; }
:root[data-theme="dark"] :is(.share-action__orb--facebook, .profile-share-action__orb--facebook) { --share-ink: #75aaff; }

:is(.share-action__orb--instagram, .profile-share-action__orb--instagram) .app-icon::before {
  background: linear-gradient(35deg, #e89424, #dc2b75 45%, #9145d2);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

:root[data-theme="dark"] :is(.share-action__orb--instagram, .profile-share-action__orb--instagram) .app-icon::before {
  background-image: linear-gradient(35deg, #ffc06e, #ff73ad 45%, #ba94ff);
}

.share-action:hover .share-action__orb,
.profile-share-action:hover .profile-share-action__orb {
  background: color-mix(in srgb, var(--share-ink) 12%, var(--color-surface));
  transform: translateY(-2px);
}

.share-action:active .share-action__orb,
.profile-share-action:active .profile-share-action__orb { transform: scale(0.96); }

.share-action:focus-visible,
.profile-share-action:focus-visible { outline: none; }

.share-action:focus-visible .share-action__orb,
.profile-share-action:focus-visible .profile-share-action__orb {
  outline: 2px solid var(--color-text);
  outline-offset: 3px;
}

.share-action__label,
.profile-share-action__label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text);
  line-height: 1.3;
  text-align: center;
}

.share-action--utility {
  flex-direction: row;
  justify-content: center;
  min-height: 50px;
  padding: 10px 16px;
  border-radius: 16px;
  background: var(--color-surface-soft);
}

.share-action--utility .share-action__orb {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.share-action--utility .app-icon { font-size: 18px; }
.share-action--utility .share-action__label { font-size: 0.875rem; font-weight: 600; }
.share-action--utility:hover { background: var(--color-hover); }
.share-action--utility:hover .share-action__orb { background: transparent; transform: none; }
.share-action--utility:focus-visible { outline: 2px solid var(--color-text); outline-offset: 3px; }
.share-action--utility:focus-visible .share-action__orb { outline: none; }

:root[data-theme="dark"] .share-modal__backdrop {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

:root[data-theme="dark"] .share-modal__panel {
  background: var(--color-surface);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.5);
}

:root[data-theme="dark"] .share-preview__card {
  background: var(--color-surface-muted);
  box-shadow: none;
}

:root[data-theme="dark"] .share-preview__avatar {
  background: var(--color-surface-soft);
  border-color: var(--color-border-strong);
}

@media (max-width: 640px) {
  .share-modal__panel,
  .profile-share-modal__panel {
    left: 50%;
    right: auto;
    top: auto;
    bottom: max(8px, env(safe-area-inset-bottom));
    width: calc(100% - 16px);
    max-height: calc(100dvh - 24px - env(safe-area-inset-bottom));
    transform: translateX(-50%);
    border-radius: 28px;
    overscroll-behavior-y: contain;
  }

  .profile-share-modal__panel { transform: translateX(-50%) translateY(16px); }
  .profile-share-modal.is-open .profile-share-modal__panel { transform: translateX(-50%); }

  .share-modal__panel::before,
  .profile-share-modal__panel::before {
    content: "";
    display: block;
    width: 34px;
    height: 5px;
    margin: 10px auto 0;
    border-radius: 99px;
    background: color-mix(in srgb, var(--color-text) 18%, transparent);
  }

  .share-modal__head { padding-top: 14px; }
  .share-actions { padding-bottom: 20px; }
  .share-destinations { gap: 12px; }
  .profile-share-actions { padding-top: 4px; gap: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .share-action__orb,
  .profile-share-action__orb,
  .profile-share-modal__panel { transition: none; }
  .share-action:hover .share-action__orb,
  .profile-share-action:hover .profile-share-action__orb,
  .share-action:active .share-action__orb,
  .profile-share-action:active .profile-share-action__orb { transform: none; }
}

@media (forced-colors: active) {
  .share-action__orb,
  .profile-share-action__orb { border: 1px solid ButtonText; }
  :root :is(.share-action__orb--instagram, .profile-share-action__orb--instagram) .app-icon::before { background: none; color: ButtonText; }
}
