/* Shared page containers for the mobile UI; desktop panels retain their styles. */
.upload-preview {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  margin: 16px 0;
  padding: 12px;
  border: 1px solid #ffffff13;
  border-radius: 8px;
  background: #ffffff04;
}

.upload-preview-video {
  display: block;
  width: 100px;
  height: 136px;
  border-radius: 5px;
  background: #080809;
  object-fit: contain;
}

.upload-preview-summary {
  min-width: 0;
  margin: 0;
  color: #a6a6b3;
  font-size: 12px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

.upload-topic {
  min-height: 34px;
  margin-top: 8px;
  padding: 4px 10px;
  border: 0;
  border-radius: 5px;
  background: #ffffff09;
  color: #d0d0db;
  font-size: 12px;
  line-height: 20px;
}

.upload-status {
  margin: 12px 0;
  color: #ff849e;
  font-size: 12px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

html[data-ui="mobile"] body.mobile-page-open .mobile-topbar,
html[data-ui="mobile"] body.mobile-page-open .account-login-trigger {
  visibility: hidden;
  pointer-events: none;
}

html[data-ui="mobile"] body.mobile-page-open .workspace {
  pointer-events: none;
}

html[data-ui="mobile"] body.mobile-page-open:not(.mobile-profile-root) .mobile-tabbar {
  display: none;
}

html[data-ui="mobile"] body.mobile-profile-root .mobile-tabbar {
  display: grid;
}

html[data-ui="mobile"] body.mobile-page-open.mobile-profile-menu-open .mobile-tabbar {
  display: grid;
  z-index: 58;
}

html[data-ui="mobile"] body.mobile-profile-menu-open .sheet-backdrop {
  right: min(340px, 86vw);
}

/* JS marks normal mobile pages; comments/share/more keep the existing sheet UI. */
html[data-ui="mobile"] #drawer[data-mobile-page="true"] {
  position: fixed;
  display: flex;
  flex-direction: column;
  inset: 0;
  bottom: var(--xme-keyboard-inset, 0px);
  z-index: 60;
  width: 100%;
  max-width: none;
  height: auto;
  max-height: none;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #17171b;
  color: #f1f1f6;
  box-shadow: none;
  transform: none;
  isolation: isolate;
  overscroll-behavior: contain;
}

html[data-ui="mobile"] #drawer[data-mobile-page="true"][hidden] {
  display: none !important;
}

html[data-ui="mobile"] body.mobile-profile-root #drawer[data-mobile-page="true"] {
  bottom: max(var(--mobile-nav-height, calc(54px + env(safe-area-inset-bottom, 0px))), var(--xme-keyboard-inset, 0px));
}

html[data-ui="mobile"] #drawer[data-mobile-page="true"].is-entering {
  animation: mobile-page-enter 260ms cubic-bezier(.2, .75, .25, 1) both;
}

html[data-ui="mobile"] #drawer[data-mobile-page="true"][data-page-transition="root"].is-entering {
  animation: mobile-root-enter 150ms ease-out both;
}

@keyframes mobile-root-enter {
  from { opacity: .55; }
  to { opacity: 1; }
}

html[data-ui="mobile"] #drawer[data-mobile-page="true"].is-returning {
  animation: mobile-page-return 220ms cubic-bezier(.2, .75, .25, 1) both;
}

html[data-ui="mobile"] #drawer[data-mobile-page="true"].is-closing {
  pointer-events: none;
  animation: mobile-page-leave 220ms ease-in both;
}

html[data-ui="mobile"] #drawer[data-mobile-page="true"] > .drawer-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  gap: 12px;
  min-height: calc(56px + env(safe-area-inset-top, 0px));
  margin: 0;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 62px 12px;
  border: 0;
  border-bottom: 1px solid #ffffff09;
  background: #17171b;
  touch-action: none;
}

html[data-ui="mobile"] #drawer[data-mobile-page="true"] > .drawer-header h2 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: #f0f0f5;
  font-size: 17px;
  font-weight: 600;
  line-height: 31px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html[data-ui="mobile"] #drawer[data-mobile-page="true"] #drawer-close {
  position: absolute;
  top: calc(6px + env(safe-area-inset-top, 0px));
  right: auto;
  left: max(5px, env(safe-area-inset-left, 0px));
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #ececf3;
}

html[data-ui="mobile"] #drawer[data-mobile-page="true"] #drawer-close svg {
  width: 24px;
  height: 24px;
  transform: rotate(180deg);
}

html[data-ui="mobile"] #drawer[data-mobile-page="true"] > .drawer-body {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 0;
  max-height: none;
  margin: 0;
  padding: 17px max(18px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-block: 18px 28px;
  -webkit-overflow-scrolling: touch;
}

html[data-ui="mobile"] body.mobile-profile-open #drawer[data-mobile-page="true"] > .drawer-header {
  display: none;
}

html[data-ui="mobile"] body.mobile-profile-open #drawer[data-mobile-page="true"] > .drawer-body {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
  overflow: hidden;
  background: #16161a;
}

html[data-ui="mobile"] body.mobile-profile-open #drawer .xmp-profile {
  flex: 1 1 auto;
  min-height: 0;
}

html[data-ui="mobile"] #drawer[data-mobile-page="true"] .mobile-menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  margin: 0;
  padding: 13px 1px;
  border: 0;
  border-bottom: 1px solid #ffffff0b;
  border-radius: 0;
  background: transparent;
  color: #dedee7;
  font-size: 15px;
  font-weight: 400;
  line-height: 24px;
  text-align: left;
}

html[data-ui="mobile"] #drawer[data-mobile-page="true"] .mobile-menu-row::after {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-top: 1.5px solid #6f6f7b;
  border-right: 1.5px solid #6f6f7b;
  content: "";
  transform: rotate(45deg);
}

html[data-ui="mobile"] #drawer[data-mobile-page="true"] .mobile-menu-row:last-child {
  border-bottom: 0;
}

html[data-ui="mobile"] #drawer[data-mobile-page="true"] .drawer-item {
  min-height: 80px;
  padding-top: 13px;
  padding-bottom: 13px;
}

html[data-ui="mobile"] #drawer[data-mobile-page="true"] .drawer-item strong {
  font-size: 14px;
  line-height: 1.6;
}

html[data-ui="mobile"] #drawer[data-mobile-page="true"] .drawer-item-copy > span,
html[data-ui="mobile"] #drawer[data-mobile-page="true"] .drawer-item small {
  font-size: 12px;
  line-height: 1.7;
}

html[data-ui="mobile"] #drawer[data-mobile-page="true"] .drawer-item p {
  font-size: 12px;
  line-height: 1.7;
}

html[data-ui="mobile"] #drawer[data-mobile-page="true"] .drawer-tabs {
  position: sticky;
  top: -17px;
  z-index: 2;
  margin: 0 -18px 16px;
  padding: 0 18px;
  background: #17171b;
}

html[data-ui="mobile"] #drawer[data-mobile-page="true"] .drawer-tabs button {
  min-height: 48px;
  padding: 0 10px;
  border-top: 0;
  border-right: 0;
  border-left: 0;
  border-radius: 0;
  background: transparent;
  font-size: 14px;
}

html[data-ui="mobile"] #drawer[data-mobile-page="true"] .drawer-search-form input,
html[data-ui="mobile"] #drawer[data-mobile-page="true"] .comment-input,
html[data-ui="mobile"] #drawer[data-mobile-page="true"] .report-select,
html[data-ui="mobile"] #drawer[data-mobile-page="true"] .report-details,
html[data-ui="mobile"] #drawer[data-mobile-page="true"] .field-label input,
html[data-ui="mobile"] #drawer[data-mobile-page="true"] .field-label textarea {
  font-size: 16px;
}

html[data-ui="mobile"] #drawer[data-mobile-page="true"] .empty-state {
  padding-top: 65px;
  padding-bottom: 65px;
  font-size: 13px;
}

html[data-ui="mobile"] #drawer[data-mobile-page="true"] .empty-state svg {
  width: 42px;
  height: 42px;
}

/* The phone publishes in its own white, full-height page inside the native dialog. */
html[data-ui="mobile"] #upload-dialog {
  --upload-pad-left: max(18px, env(safe-area-inset-left, 0px));
  --upload-pad-right: max(18px, env(safe-area-inset-right, 0px));
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100dvh;
  max-height: none;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: #202026;
  box-shadow: none;
  color-scheme: light;
}

html[data-ui="mobile"] #upload-dialog[open] {
  display: flex;
  flex-direction: column;
}

html[data-ui="mobile"] #upload-dialog:not([open]) {
  display: none;
}

html[data-ui="mobile"] #upload-dialog::backdrop {
  background: #fff;
  backdrop-filter: none;
}

html[data-ui="mobile"] #upload-dialog > .drawer-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-height: calc(58px + env(safe-area-inset-top, 0px));
  padding: calc(12px + env(safe-area-inset-top, 0px)) 62px 12px;
  border-bottom: 1px solid #ededf0;
  background: #fff;
}

html[data-ui="mobile"] #upload-dialog > .drawer-header h2 {
  margin: 0;
  color: #19191f;
  font-size: 17px;
  font-weight: 650;
  line-height: 32px;
}

html[data-ui="mobile"] #upload-dialog #upload-close {
  position: absolute;
  top: calc(7px + env(safe-area-inset-top, 0px));
  right: auto;
  left: max(5px, env(safe-area-inset-left, 0px));
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #25252b;
}

html[data-ui="mobile"] #upload-dialog #upload-close > span {
  display: none;
}

html[data-ui="mobile"] #upload-dialog #upload-close::before {
  display: block;
  width: 12px;
  height: 12px;
  margin-left: 5px;
  border-bottom: 2px solid currentColor;
  border-left: 2px solid currentColor;
  content: "";
  transform: rotate(45deg);
}

html[data-ui="mobile"] #upload-dialog > .dialog-description {
  flex: 0 0 auto;
  margin: 0;
  padding: 12px max(18px, env(safe-area-inset-right, 0px)) 5px max(18px, env(safe-area-inset-left, 0px));
  color: #8c8c95;
  font-size: 12px;
  line-height: 20px;
}

html[data-ui="mobile"] #upload-dialog #upload-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  gap: 0;
  width: 100%;
  min-height: 0;
  max-height: none;
  margin: 0;
  padding: 0 var(--upload-pad-right) 0 var(--upload-pad-left);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

html[data-ui="mobile"] #upload-dialog .field-label {
  display: block;
  flex: 0 0 auto;
  order: 5;
  margin: 0;
  padding: 13px 0;
  border-bottom: 1px solid #efeff2;
  color: #43434c;
  font-size: 14px;
  font-weight: 500;
  line-height: 22px;
}

html[data-ui="mobile"] #upload-dialog .field-label:has(#upload-title) {
  order: 1;
}

html[data-ui="mobile"] #upload-dialog .field-label:has(#upload-description) {
  order: 2;
  border-bottom: 0;
}

html[data-ui="mobile"] #upload-dialog .field-label:has(#upload-mode) {
  order: 6;
}

html[data-ui="mobile"] #upload-dialog .field-label input,
html[data-ui="mobile"] #upload-dialog .field-label select,
html[data-ui="mobile"] #upload-dialog .field-label textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 7px;
  padding: 10px 11px;
  border: 0;
  border-radius: 5px;
  outline-offset: -2px;
  background: #f6f6f8;
  color: #292930;
  font-size: 16px;
  font-weight: 400;
  line-height: 24px;
}

html[data-ui="mobile"] #upload-dialog .field-label input::placeholder,
html[data-ui="mobile"] #upload-dialog .field-label textarea::placeholder {
  color: #aaaab3;
}

html[data-ui="mobile"] #upload-dialog .field-label textarea {
  min-height: 112px;
  max-height: 200px;
  background: #fafafb;
  resize: vertical;
}

html[data-ui="mobile"] #upload-dialog .upload-topic {
  min-height: 34px;
  margin: 8px 0 0;
  padding: 4px 10px;
  border: 0;
  border-radius: 4px;
  background: #f2f2f5;
  color: #5d5d6b;
  font-size: 12px;
  font-weight: 400;
  line-height: 22px;
}

html[data-ui="mobile"] #upload-dialog .upload-drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  order: 3;
  gap: 7px;
  min-height: 120px;
  margin: 1px 0 16px;
  padding: 16px 12px;
  overflow: hidden;
  border: 1px dashed #d4d4dc;
  border-radius: 7px;
  background: #fafafb;
  color: #43434f;
  cursor: pointer;
}

html[data-ui="mobile"] #upload-dialog .upload-drop > span:first-child,
html[data-ui="mobile"] #upload-dialog .upload-drop svg {
  width: 27px;
  height: 27px;
  color: #ff3159;
}

html[data-ui="mobile"] #upload-dialog .upload-drop strong {
  color: #4b4b56;
  font-size: 14px;
  font-weight: 500;
  line-height: 22px;
}

html[data-ui="mobile"] #upload-dialog .upload-drop > span {
  color: #9b9ba5;
  font-size: 11px;
  font-weight: 400;
  line-height: 18px;
}

html[data-ui="mobile"] #upload-dialog .upload-drop input[type="file"] {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
}

html[data-ui="mobile"] #upload-dialog .upload-drop:focus-within {
  outline: 2px solid #ff7b98;
  outline-offset: 2px;
}

html[data-ui="mobile"] #upload-dialog #upload-preview {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  flex: 0 0 auto;
  order: 4;
  gap: 14px;
  margin: 0 0 8px;
  padding: 12px;
  border: 1px solid #ededf2;
  border-radius: 7px;
  background: #fafafb;
}

html[data-ui="mobile"] #upload-dialog #upload-preview[hidden],
html[data-ui="mobile"] #upload-dialog #upload-status[hidden] {
  display: none !important;
}

html[data-ui="mobile"] #upload-dialog #upload-preview-video {
  width: 92px;
  height: 126px;
  border-radius: 5px;
  background: #0d0d10;
  object-fit: contain;
}

html[data-ui="mobile"] #upload-dialog .upload-preview-summary {
  color: #72727f;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.8;
}

html[data-ui="mobile"] #upload-dialog #upload-form:has(#upload-preview:not([hidden])) .upload-drop {
  flex-direction: row;
  gap: 9px;
  min-height: 54px;
  margin-bottom: 12px;
  padding: 11px;
}

html[data-ui="mobile"] #upload-dialog #upload-form:has(#upload-preview:not([hidden])) .upload-drop > span:last-of-type {
  display: none;
}

html[data-ui="mobile"] #upload-dialog .local-note {
  flex: 0 0 auto;
  order: 7;
  margin: 0;
  padding: 15px 0 20px;
  color: #a0a0aa;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.8;
}

html[data-ui="mobile"] #upload-dialog #upload-status {
  flex: 0 0 auto;
  order: 8;
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 6px;
  background: #fff2f5;
  color: #d24565;
  font-size: 12px;
  line-height: 1.8;
}

html[data-ui="mobile"] #upload-dialog .dialog-actions {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  flex: 0 0 auto;
  order: 9;
  align-items: center;
  gap: 10px;
  width: calc(100% + var(--upload-pad-left) + var(--upload-pad-right));
  margin: auto calc(-1 * var(--upload-pad-right)) 0 calc(-1 * var(--upload-pad-left));
  padding: 12px var(--upload-pad-right) calc(12px + env(safe-area-inset-bottom, 0px)) var(--upload-pad-left);
  border-top: 1px solid #f0f0f3;
  background: #fff;
}

html[data-ui="mobile"] #upload-dialog .dialog-actions > button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 46px;
  padding: 10px 12px;
  border: 0;
  border-radius: 5px;
  font-size: 15px;
  font-weight: 600;
  line-height: 24px;
}

html[data-ui="mobile"] #upload-dialog .dialog-actions .secondary-btn {
  background: #f1f1f4;
  color: #646471;
}

html[data-ui="mobile"] #upload-dialog .dialog-actions .primary-btn {
  background: #ff2d55;
  color: #fff;
}

html[data-ui="mobile"] #upload-dialog button:disabled {
  cursor: default;
  opacity: .5;
}

html[data-ui="mobile"] #upload-dialog button:focus-visible,
html[data-ui="mobile"] #upload-dialog input:focus-visible,
html[data-ui="mobile"] #upload-dialog select:focus-visible,
html[data-ui="mobile"] #upload-dialog textarea:focus-visible {
  outline: 2px solid #ff7b98;
}

@keyframes mobile-page-enter {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes mobile-page-return {
  from { transform: translateX(-20px); opacity: .6; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes mobile-page-leave {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: .8; }
}

@media (max-height: 500px) {
  html[data-ui="mobile"] #upload-dialog > .dialog-description {
    padding-top: 6px;
    padding-bottom: 0;
    font-size: 11px;
  }

  html[data-ui="mobile"] #upload-dialog > .drawer-header,
  html[data-ui="mobile"] #drawer[data-mobile-page="true"] > .drawer-header {
    min-height: calc(48px + env(safe-area-inset-top, 0px));
    padding-top: calc(8px + env(safe-area-inset-top, 0px));
    padding-bottom: 8px;
  }

  html[data-ui="mobile"] #upload-dialog #upload-close,
  html[data-ui="mobile"] #drawer[data-mobile-page="true"] #drawer-close {
    top: calc(2px + env(safe-area-inset-top, 0px));
  }

  html[data-ui="mobile"] #upload-dialog .dialog-actions {
    padding-top: 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }

  html[data-ui="mobile"] #upload-dialog .dialog-actions > button {
    min-height: 42px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html[data-ui="mobile"] #drawer[data-mobile-page="true"].is-entering,
  html[data-ui="mobile"] #drawer[data-mobile-page="true"].is-returning,
  html[data-ui="mobile"] #drawer[data-mobile-page="true"].is-closing {
    animation: none !important;
  }

  html[data-ui="mobile"] #upload-dialog button {
    transition: none;
  }
}

/* Auxiliary actions use a phone sheet; the channel directory opens as a page. */
html[data-ui="mobile"] #service-dialog {
  inset: auto 0 0;
  width: 100%;
  max-width: none;
  max-height: calc(100dvh - max(20px, env(safe-area-inset-top, 0px)));
  margin: 0;
  overflow: hidden;
  border: 0;
  border-radius: 18px 18px 0 0;
  background: #202024;
  overscroll-behavior: contain;
}

html[data-ui="mobile"] #service-dialog[open] {
  display: flex;
  flex-direction: column;
  animation: mobile-sheet-in 260ms var(--mobile-touch-easing) both;
}

html[data-ui="mobile"] #service-dialog > .drawer-header {
  flex: 0 0 auto;
  min-height: 60px;
  padding: 10px max(12px, env(safe-area-inset-right, 0px)) 10px max(20px, env(safe-area-inset-left, 0px));
}

html[data-ui="mobile"] #service-dialog #service-close {
  width: 44px;
  height: 44px;
}

html[data-ui="mobile"] #service-dialog .service-body {
  min-height: 0;
  padding: 8px max(20px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

html[data-ui="mobile"] #service-dialog:has(.service-channels) {
  inset: 0;
  height: 100dvh;
  max-height: none;
  border-radius: 0;
  background: #161618;
}

html[data-ui="mobile"] #service-dialog:has(.service-channels)[open] {
  animation: mobile-page-enter 260ms var(--mobile-touch-easing) both;
}

html[data-ui="mobile"] #service-dialog:has(.service-channels) > .drawer-header {
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  border: 0;
}

html[data-ui="mobile"] .service-channels {
  gap: 14px 10px;
  padding-top: 12px;
}

html[data-ui="mobile"] .service-channels button {
  height: 66px;
  border-radius: 10px;
  background: #ffffff09;
  font-size: 15px;
  touch-action: manipulation;
}

html[data-ui="mobile"] .service-channels button:active {
  background: #ffffff16;
  transform: scale(.97);
}

html[data-ui="mobile"] #drawer[data-mobile-page="true"] :is(input, textarea, select) {
  scroll-margin-block: 72px 30px;
}

@media (max-height: 500px) and (orientation: landscape) {
  html[data-ui="mobile"] .service-channels {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  html[data-ui="mobile"] #service-dialog[open] {
    animation: none !important;
  }
}
