/* Final mobile layer. Keep colors on theme variables so every skin remains visible. */
:root,
html,
body,
#app,
.app-shell,
.main-layout,
.content,
.content > .view {
  background-color: var(--bg) !important;
}

.content > .view {
  min-width: 0;
}

.content .post-card,
.content .profile-card,
.content .profile-card.profile-card--styled,
.content .empty-state {
  background-color: var(--bg) !important;
  background-image: none !important;
  border-color: transparent !important;
  box-shadow: none !important;
}

.content .profile-card.profile-card--styled > *:not(.profile-banner),
.content .profile-card.profile-card--styled .profile-top,
.content .profile-card.profile-card--styled .profile-identity,
.content .profile-card.profile-card--styled .profile-bio,
.content .profile-card.profile-card--styled .profile-stats,
.content .profile-card.profile-card--styled .spark-card,
.content .profile-card.profile-card--styled .profile-actions {
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
}

.content .profile-card.profile-card--styled .profile-banner {
  background-color: transparent;
}

/* Sharing is a panel, not a gray page-sized surface. */
.share-backdrop {
  background: rgba(8, 8, 12, .58) !important;
}

body.light-theme .share-backdrop {
  background: rgba(57, 42, 74, .18) !important;
}

.share-modal {
  background: var(--panel) !important;
  color: var(--text);
}

.share-preview,
.share-chat-list,
.share-chat {
  background-color: transparent !important;
}

.share-preview {
  border-color: var(--line) !important;
}

.share-chat:hover,
.share-chat:focus-visible {
  background-color: var(--panel-2) !important;
}

/* A modal owns its scroll; the page behind it never traps the save button. */
.modal-backdrop {
  position: fixed;
  inset: 0;
  display: flex !important;
  align-items: flex-start !important;
  justify-content: center;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.modal-backdrop > .profile-editor,
.modal-backdrop > .story-editor {
  display: block;
  width: min(100%, 520px);
  min-height: 0;
  max-height: calc(100dvh - max(16px, env(safe-area-inset-top) + env(safe-area-inset-bottom)));
  margin: 0 auto;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  scrollbar-gutter: stable;
}

.profile-editor .form-stack,
.story-editor .form-stack {
  min-height: 0;
  padding-bottom: 10px;
}

.profile-editor input,
.profile-editor textarea,
.story-editor input,
.story-editor textarea,
.story-editor select {
  font-size: 16px;
}

.profile-editor .upload-zone,
.story-editor .upload-zone,
.story-camera-launch {
  min-height: 56px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.profile-editor .editor-actions,
.story-editor .editor-actions {
  position: sticky;
  bottom: -1px;
  z-index: 20;
  display: flex;
  gap: 8px;
  margin-right: -22px;
  margin-left: -22px;
  padding: 14px 22px max(6px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent 0, var(--panel) 30%);
}

.profile-editor .editor-actions button,
.story-editor .editor-actions button {
  min-height: 44px;
  min-width: 0;
  flex: 1 1 0;
}

.story-video-ready video {
  display: block;
  width: 100%;
  max-height: 280px;
  border-radius: 12px;
  background: var(--bg);
  object-fit: contain;
}

.verification-card {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}
.verification-card > span,
.verification-request small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.verification-request { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.verification-request > span { min-width: 0; flex: 1 1 140px; display: grid; gap: 3px; }
.verification-request button { min-height: 38px; padding-inline: 10px; }
.reposts-view { display: grid; gap: 14px; }
.repost-feed-item { display: grid; gap: 5px; }
.repost-feed-credit { margin: 0; color: var(--muted); font-size: 13px; font-weight: 700; }

@media (max-width: 600px) {
  .modal-backdrop {
    padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
  }

  .modal-backdrop > .profile-editor,
  .modal-backdrop > .story-editor {
    width: 100%;
    height: auto;
    max-height: calc(100dvh - max(16px, env(safe-area-inset-top) + env(safe-area-inset-bottom)));
    padding: 16px;
    border-radius: 18px;
    margin: 0;
    scroll-padding-top: 72px;
    scroll-padding-bottom: 112px;
  }

  .profile-editor .editor-head,
  .story-editor .editor-head {
    position: sticky;
    top: -16px;
    z-index: 21;
    margin: -16px -16px 16px;
    padding: 16px;
    background: var(--panel) !important;
  }

  .profile-editor .editor-actions,
  .story-editor .editor-actions {
    margin-right: -16px;
    margin-left: -16px;
    padding-right: 16px;
    padding-left: 16px;
  }
}

@media (max-width: 380px) {
  .modal-backdrop > .profile-editor,
  .modal-backdrop > .story-editor {
    padding: 12px;
  }

  .profile-editor .editor-head,
  .story-editor .editor-head {
    top: -12px;
    margin: -12px -12px 14px;
    padding: 12px;
  }

  .profile-editor .editor-actions,
  .story-editor .editor-actions {
    margin-right: -12px;
    margin-left: -12px;
    padding-right: 12px;
    padding-left: 12px;
  }
}

@supports not (height: 100dvh) {
  .modal-backdrop > .profile-editor,
  .modal-backdrop > .story-editor {
    max-height: calc(100vh - 16px);
  }
}
