/* Final mobile layer: loaded after every other stylesheet. */
html,
body,
#app,
.app-shell,
.main-layout,
.content {
  min-width: 320px;
  background-color: var(--bg) !important;
}

.content {
  isolation: isolate;
}

.content > .view,
.content > .view > .profile-card,
.content > .view > .post-card,
.content > .view > article.post-card,
.content .post-card,
.content .profile-card.profile-card--styled {
  background-color: var(--bg) !important;
}

.content .profile-card.profile-card--styled {
  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;
}

.modal-backdrop {
  overscroll-behavior: contain;
}

.profile-editor,
.story-editor {
  max-width: 520px;
  max-height: calc(100dvh - 24px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}

.profile-editor .form-stack,
.story-editor .form-stack {
  min-height: 0;
}

.profile-editor .field input,
.profile-editor .field textarea,
.story-editor .field input,
.story-editor .field textarea,
.profile-editor select,
.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: 10;
  padding-top: 12px;
  padding-bottom: max(4px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--panel) 28%);
}

.story-video-upload {
  display: grid;
  gap: 5px;
}

.story-video-upload strong {
  color: var(--text);
}

.story-video-upload span {
  color: var(--muted);
  font-size: 11px;
}

.story-video-ready video {
  display: block;
  width: 100%;
  max-height: 280px;
  border-radius: 12px;
  background: #08080b;
  object-fit: contain;
}

@media (max-width: 600px) {
  body.kolmar-modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
  }

  .modal-backdrop {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-x: hidden;
    overflow-y: auto;
    padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
  }

  .profile-editor,
  .story-editor {
    width: 100%;
    height: calc(100dvh - max(16px, env(safe-area-inset-top) + env(safe-area-inset-bottom)));
    max-height: none;
    margin: 0;
    padding: 16px;
    border-radius: 18px;
    scroll-padding-top: 16px;
    scroll-padding-bottom: 112px;
  }

  .profile-editor .editor-head,
  .story-editor .editor-head {
    position: sticky;
    top: -16px;
    z-index: 11;
    margin: -16px -16px 16px;
    padding: 16px;
    background: var(--panel);
  }

  .profile-editor .editor-actions,
  .story-editor .editor-actions {
    margin-right: -16px;
    margin-left: -16px;
    padding-right: 16px;
    padding-left: 16px;
  }

  .profile-editor .editor-actions button,
  .story-editor .editor-actions button {
    min-height: 44px;
    flex: 1 1 0;
  }
}

@media (max-width: 380px) {
  .profile-editor,
  .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) {
  .profile-editor,
  .story-editor {
    max-height: calc(100vh - 24px);
  }

  @media (max-width: 600px) {
    .profile-editor,
    .story-editor {
      height: calc(100vh - 16px);
    }
  }
}
