/* TWA / standalone chrome — bottom sheet, hide store banners. Menu stays a half-width drawer. */

:root {
  --btn-dark: #0d0d0d;
  --btn-dark-fg: #fafafa;
}

html[data-theme="dark"] {
  --btn-dark: #fafafa;
  --btn-dark-fg: #0d0d0d;
}

html.is-twa [data-twa-hide],
html.is-standalone [data-twa-hide],
html.is-twa .store-banner,
html.is-twa .bazaar-install-banner,
html.is-twa .get-app-banner,
html.is-twa .install-app-banner {
  display: none !important;
}

.menu-close {
  display: none;
  margin-inline-start: auto;
}

.overlay {
  transition: visibility 0.32s, opacity 0.32s ease;
}
.overlay.show {
  transition: visibility 0s, opacity 0.32s ease;
}

@media (max-width: 980px) {
  html.is-twa .sidebar,
  html.is-standalone .sidebar,
  .sidebar {
    width: min(300px, 86vw) !important;
    max-width: 300px !important;
    inset: 0 0 0 auto !important;
  }
  .overlay {
    align-items: flex-end;
    justify-content: center;
    padding: 0;
  }
  .sheet {
    width: 100%;
    max-width: 100%;
    max-height: min(92dvh, 920px);
    border-radius: 24px 24px 0 0;
    border-bottom: 0;
    padding-top: 12px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    transform: translateY(110%);
    transition: transform 0.34s cubic-bezier(0.32, 0.72, 0, 1);
  }
  .sheet.wide { width: 100%; }
  .overlay.show .sheet { transform: translateY(0); }
  .sheet::before {
    content: "";
    display: block;
    width: 36px;
    height: 4px;
    border-radius: 999px;
    background: var(--stroke);
    margin: 4px auto 16px;
  }
  .overlay:has(.sheet.sheet-auth) {
    align-items: stretch !important;
  }
  .sheet.sheet-auth {
    height: 100% !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border: 0 !important;
    padding-top: calc(20px + env(safe-area-inset-top, 0px)) !important;
    padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px)) !important;
    transform: translateY(0) !important;
  }
  .sheet.sheet-auth::before {
    display: none !important;
  }
}

.instant-skel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.instant-skel-head h3 { margin: 0; }
.instant-spin {
  width: 18px;
  height: 18px;
  border: 2px solid var(--stroke);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: instant-spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes instant-spin { to { transform: rotate(360deg); } }
.instant-skel-card {
  height: 88px;
  border-radius: 18px;
  margin-bottom: 10px;
  background: linear-gradient(90deg, var(--hover) 0%, var(--card) 45%, var(--hover) 100%);
  background-size: 200% 100%;
  animation: instant-shine 1.15s ease infinite;
}
.instant-skel-card-short { height: 56px; width: 72%; }
@keyframes instant-shine {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
html[data-theme="dark"] .instant-skel-card {
  background: linear-gradient(90deg, #262626 0%, #1f1f1f 45%, #262626 100%);
  background-size: 200% 100%;
}

.sub-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sub-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  text-align: start;
  padding: 16px 16px 14px;
  border-radius: 20px;
  border: 1px solid var(--stroke);
  background: var(--card);
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
}
.sub-card.is-rec {
  border-color: #3b82f6;
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.25);
}
.sub-card-badge {
  position: absolute;
  top: 12px;
  inset-inline-end: 12px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #1d4ed8;
  color: #fafafa;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
}
.sub-card b { font-size: 16px; }
.sub-card-price {
  font-size: 20px;
  font-weight: 700;
}
.sub-card-price small {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}
.sub-card-hint { font-size: 13px; color: var(--muted); }
.sub-card-go {
  margin-top: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--btn-dark, #0d0d0d);
  color: var(--btn-dark-fg, #fafafa);
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
}
.sub-card:active { transform: scale(0.99); }

.sub-flow {
  text-align: start;
}
.sub-flow h3,
.sub-flow .sub {
  text-align: start;
}

.sub-compare-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 14px;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 999px;
  border: none;
  background: var(--btn-dark, #0d0d0d);
  color: var(--btn-dark-fg, #fafafa);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  -webkit-appearance: none;
  appearance: none;
}
.sub-compare-btn:active { transform: scale(0.99); }
.sub-pane-compare { display: none; }
.sheet.is-comparing .sub-pane-plans { display: none; }
.sheet.is-comparing .sub-pane-compare {
  display: block;
  animation: subPaneIn 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes subPaneIn {
  from { opacity: 0; transform: translateX(-16px); }
  to { opacity: 1; transform: none; }
}
.sub-compare-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.sub-compare-bar b { font-size: 16px; }
.sub-compare-back {
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--hover);
  border: 1px solid var(--stroke);
  font-size: 13px;
  font-weight: 600;
}
.sub-compare-scroll {
  overflow: auto;
  max-height: min(62dvh, 540px);
  -webkit-overflow-scrolling: touch;
  margin: 0 -8px;
  padding: 0 8px;
  border-radius: 16px;
  border: 1px solid var(--stroke);
  background: var(--card);
}
.sub-cmp {
  width: 100%;
  min-width: 420px;
  border-collapse: collapse;
  font-size: 12px;
}
.sub-cmp th,
.sub-cmp td {
  padding: 9px 6px;
  text-align: center;
  border-bottom: 1px solid var(--stroke);
  color: var(--ink);
}
.sub-cmp thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--card);
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
}
.sub-cmp .sub-cmp-feat {
  text-align: start;
  font-weight: 500;
  padding-inline-start: 10px;
}
.sub-cmp-yes { color: #2563eb; font-weight: 700; }
html[data-theme="dark"] .sub-cmp-yes { color: #93c5fd; }
.sub-cmp-no { color: var(--muted); }
.sub-cmp-model {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sub-cmp-model img {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  object-fit: contain;
}
.cmp-msg-equiv {
  display: inline-block;
  margin-inline-start: 4px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  background: rgba(100, 116, 139, 0.14);
  white-space: nowrap;
  vertical-align: middle;
}

#instantWarm { display: none !important; }

/* TWA / iPhone home-screen: edge-to-edge composer only on phones.
   Desktop Chrome (fullscreen or installed PWA) must keep the centered web width. */
@media (max-width: 980px) {
  html.is-twa .main:not(.is-empty) .composer-wrap,
  html.is-twa .main.is-empty .composer-wrap {
    padding-inline: 18px;
  }

  html.is-twa .main:not(.is-empty) .composer,
  html.is-twa .main.is-empty .composer {
    width: 100%;
    max-width: 100%;
  }

  html.is-twa .messages {
    padding-inline: 18px;
  }
}

@media (min-width: 981px) {
  html.is-twa .main.is-empty .composer,
  html.is-standalone .main.is-empty .composer {
    width: min(768px, calc(100% - 48px));
    max-width: 768px;
  }
  html.is-twa .main:not(.is-empty) .composer,
  html.is-standalone .main:not(.is-empty) .composer {
    width: min(768px, calc(100% - 48px));
    max-width: 768px;
  }
}

html.is-twa .msg-row.assistant.msg-row--gen-image .msg-col,
html.is-standalone .msg-row.assistant.msg-row--gen-image .msg-col {
  align-items: stretch;
  width: 100%;
  max-width: 100%;
}

html.is-twa .msg-row.assistant.msg-row--gen-image .creating-image-box--video,
html.is-standalone .msg-row.assistant.msg-row--gen-image .creating-image-box--video,
html.is-twa .msg-row.assistant.msg-row--gen-image .media-video-card,
html.is-standalone .msg-row.assistant.msg-row--gen-image .media-video-card {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 220px;
  align-self: stretch;
}

html.is-twa .creating-image-box--video video,
html.is-standalone .creating-image-box--video video {
  max-height: min(380px, 62vh);
}

/* TWA: composer stays at the bottom on new/empty chat (web keeps GPT-style center). */
html.is-twa .main.is-empty .chat-stage {
  flex: 1 1 auto;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

html.is-twa .main.is-empty .composer-wrap {
  flex: 0 0 auto;
  min-height: 0;
  justify-content: center;
  padding-top: 0;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px) + var(--kb-inset, 0px));
}

html.is-twa .main.is-empty .empty-hero {
  padding-bottom: 16px;
}

/* TWA: block Chrome image long-press (Lens / Download / Share) — use in-app actions. */
html.is-twa img,
html.is-twa .msg-image,
html.is-twa .msg-image img,
html.is-twa .gal-item img,
html.is-twa #viewerImg,
html.is-twa [data-zoom] img {
  -webkit-touch-callout: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
  -webkit-user-drag: none;
  touch-action: manipulation;
}

html.is-twa {
  touch-action: manipulation;
}
