/* ai08 mobile shell */
:root {
  --mobile-bg: #1d1a28;
  --mobile-card: #252232;
  --mobile-border: #3a3648;
  --mobile-accent: #3b82f6;
  --mobile-text: #f4f4f5;
  --mobile-muted: #a1a1aa;
  --mobile-nav-h: 4.25rem;
}

html {
  height: 100%;
}

html, body.mobile-body {
  margin: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  min-height: 100dvh;
  background: var(--mobile-bg);
  color: var(--mobile-text);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.mobile-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
}

/* Design page: scrollable templates + fixed My Model dock above bottom nav */
.mobile-shell--design {
  padding-bottom: 0;
  height: 100dvh;
  overflow: hidden;
}

.mobile-design-main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 1rem 1rem;
  /* room for collapsed My Model dock */
  padding-bottom: calc(var(--mobile-model-dock-h, 3.25rem) + 0.75rem);
  box-sizing: border-box;
}

.mobile-model-dock {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  max-width: none;
  bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px));
  z-index: 35;
  background: #1a1824;
  border-top: 1px solid var(--mobile-border);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.45);
  box-sizing: border-box;
}

.mobile-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.5rem;
}

.mobile-page-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.mobile-content {
  flex: 1;
  min-height: 0;
  width: 100%;
  padding: 0 1rem 1rem;
  box-sizing: border-box;
}

.mobile-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  width: 100%;
  max-width: none;
  margin: 0;
  height: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #12101a;
  border-top: 1px solid var(--mobile-border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: center;
  box-sizing: border-box;
}

.mobile-nav-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  color: var(--mobile-muted);
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 500;
  padding: 0.35rem 0;
}

.mobile-nav-badge {
  position: absolute;
  top: 0.15rem;
  left: calc(50% + 0.35rem);
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.62rem;
  line-height: 1rem;
  text-align: center;
  font-weight: 700;
}

.mobile-nav-item svg {
  width: 1.35rem;
  height: 1.35rem;
}

.mobile-nav-item.active {
  color: var(--mobile-accent);
}

.mobile-filter-tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.25rem 0 0.75rem;
  scrollbar-width: none;
}

.mobile-filter-tabs::-webkit-scrollbar { display: none; }

.mobile-filter-tab {
  flex-shrink: 0;
  padding: 0.4rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  border: none;
  background: #2a2738;
  color: var(--mobile-muted);
  cursor: pointer;
}

.mobile-filter-tab.active {
  background: #fff;
  color: #111;
}

.mobile-template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  width: 100%;
}

@media (min-width: 640px) {
  .mobile-template-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .mobile-template-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.mobile-template-card {
  position: relative;
  border-radius: 0.65rem;
  overflow: hidden;
  background: var(--mobile-card);
  border: 2px solid transparent;
  cursor: pointer;
  text-align: left;
}

.mobile-template-card.selected {
  border-color: #22c55e;
}

.mobile-template-thumb {
  position: relative;
  aspect-ratio: 3 / 4;
  background: #1a1824;
  overflow: hidden;
}

.mobile-template-thumb img,
.mobile-template-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mobile-template-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.25);
}

.mobile-template-play svg {
  width: 2.5rem;
  height: 2.5rem;
  color: rgba(255,255,255,0.9);
}

.mobile-template-promo {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  left: auto;
  z-index: 2;
  max-width: 4.5rem;
  background: #e11d48;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.18rem 0.45rem;
  border-radius: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-template-promo ~ .mobile-template-select-dot {
  top: 1.85rem;
}

.mobile-template-badge {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 0.65rem;
  padding: 0.15rem 0.45rem;
  border-radius: 9999px;
}

.mobile-template-select-dot {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 9999px;
  border: 2px solid rgba(255,255,255,0.8);
  background: transparent;
}

.mobile-template-card.selected .mobile-template-select-dot {
  background: #22c55e;
  border-color: #22c55e;
  box-shadow: inset 0 0 0 2px #1d1a28;
}

.mobile-template-credits {
  position: absolute;
  bottom: 0.4rem;
  right: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  background: rgba(0,0,0,0.6);
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: 9999px;
}

.mobile-template-name {
  padding: 0.45rem 0.35rem 0.55rem;
  font-size: 0.72rem;
  color: #93c5fd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-template-skeleton {
  pointer-events: none;
}

.mobile-template-skeleton .mobile-template-thumb {
  background: #2a2738;
}

.mobile-template-skeleton-line {
  display: block;
  height: 0.72rem;
  width: 68%;
  border-radius: 0.25rem;
  background: #3a3648;
}

.mobile-model-panel {
  margin-top: 0;
  border-radius: 0;
  background: transparent;
  border: none;
  overflow: hidden;
}

.mobile-model-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  cursor: pointer;
  user-select: none;
  min-height: var(--mobile-model-dock-h, 3.25rem);
  box-sizing: border-box;
}

.mobile-model-header-history {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--mobile-muted);
  pointer-events: none;
}

.mobile-model-chevron {
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.mobile-model-dock.is-expanded .mobile-model-chevron {
  transform: rotate(180deg);
}

.mobile-model-header-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.mobile-upload-zone {
  margin: 0 1rem 1rem;
  border: 1.5px dashed var(--mobile-border);
  border-radius: 0.65rem;
  min-height: 9rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--mobile-muted);
  font-size: 0.85rem;
  position: relative;
  background: #1e1c28;
}

.mobile-upload-zone.has-image {
  border-style: solid;
  padding: 0.5rem;
}

.mobile-upload-zone img {
  max-height: 10rem;
  max-width: 100%;
  border-radius: 0.5rem;
  object-fit: contain;
}

.mobile-upload-clear {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 9999px;
  border: none;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.mobile-start-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: calc(100% - 2rem);
  margin: 0 1rem 1rem;
  padding: 0.85rem 1rem;
  border: none;
  border-radius: 0.65rem;
  background: var(--mobile-accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}

.mobile-start-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.mobile-start-btn .credit-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: rgba(0,0,0,0.2);
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.mobile-credits-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #2a2738;
  border-radius: 9999px;
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.mobile-credits-badge .star {
  color: #fbbf24;
}

.mobile-alert-banner {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  padding: 0.65rem 0.75rem;
  margin-bottom: 1rem;
  border-radius: 0.5rem;
  background: rgba(180, 83, 9, 0.2);
  border: 1px solid rgba(251, 191, 36, 0.25);
  color: #fcd34d;
  font-size: 0.75rem;
  line-height: 1.4;
}

.mobile-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1rem;
  color: var(--mobile-muted);
  text-align: center;
  gap: 0.75rem;
}

.mobile-empty-state svg {
  width: 4rem;
  height: 4rem;
  opacity: 0.35;
}

.mobile-balance-card {
  background: linear-gradient(135deg, #1e3a5f 0%, #2d1b4e 100%);
  border-radius: 0.85rem;
  padding: 1.25rem 1rem;
  margin-bottom: 1rem;
}

.mobile-plan-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem;
  margin-bottom: 0.65rem;
  border-radius: 0.75rem;
  background: var(--mobile-card);
  border: 2px solid transparent;
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.mobile-plan-card.selected {
  background: rgba(59, 130, 246, 0.12);
  border-color: var(--mobile-accent);
}

.mobile-plan-amount {
  color: var(--mobile-accent);
  font-size: 0.875rem;
  font-weight: 500;
}

.mobile-plan-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.5rem;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.mobile-bonus-badge {
  display: inline-block;
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  border-radius: 0.25rem;
  margin-left: 0.35rem;
}

.mobile-card {
  background: var(--mobile-card);
  border-radius: 0.85rem;
  border: 1px solid var(--mobile-border);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.mobile-menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.95rem 1rem;
  background: var(--mobile-card);
  border-radius: 0.65rem;
  margin-bottom: 0.5rem;
  border: none;
  width: 100%;
  color: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  text-align: left;
}

.mobile-menu-row svg.chevron {
  width: 1rem;
  height: 1rem;
  color: var(--mobile-muted);
}

.mobile-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.mobile-modal-backdrop.sheet {
  align-items: flex-end;
  padding: 0;
}

.mobile-modal {
  background: #2a2738;
  border-radius: 1rem;
  padding: 1.25rem;
  width: 100%;
  max-width: min(24rem, 100%);
  max-height: 90vh;
  overflow-y: auto;
  box-sizing: border-box;
}

.mobile-modal.sheet {
  max-width: none;
  width: 100%;
  border-radius: 1rem 1rem 0 0;
  padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
}

.mobile-modal h3 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.mobile-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 1.25rem;
}

.mobile-modal-actions button {
  background: none;
  border: none;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--mobile-muted);
  font-weight: 600;
}

.mobile-modal-actions button.primary {
  color: var(--mobile-accent);
}

.mobile-hidden { display: none !important; }

.mobile-settings-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  background: var(--mobile-card);
  border: none;
  color: #fff;
  cursor: pointer;
  margin-right: 0.5rem;
}

.mobile-toggle {
  width: 2.75rem;
  height: 1.5rem;
  border-radius: 9999px;
  background: var(--mobile-accent);
  position: relative;
  border: none;
  cursor: pointer;
}

.mobile-toggle::after {
  content: '';
  position: absolute;
  top: 0.15rem;
  right: 0.15rem;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 9999px;
  background: #fff;
}

.mobile-history-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  width: 100%;
}

@media (min-width: 640px) {
  .mobile-history-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .mobile-history-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.mobile-history-item {
  border-radius: 0.65rem;
  overflow: hidden;
  background: var(--mobile-card);
  cursor: pointer;
}

.mobile-history-thumb {
  aspect-ratio: 3/4;
  background: #1a1824;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-history-thumb img,
.mobile-history-fallback {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mobile-history-fallback {
  background: #2a2738;
}

.mobile-history-meta {
  padding: 0.4rem 0.45rem 0.5rem;
}

.mobile-history-title {
  font-size: 0.75rem;
  color: #e4e4e7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-history-sub {
  margin-top: 0.1rem;
  font-size: 0.65rem;
  color: #a1a1aa;
}

.mobile-task-badge {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  z-index: 2;
  border-radius: 999px;
  padding: 0.12rem 0.45rem;
  font-size: 0.62rem;
  font-weight: 700;
  color: #fff;
}

.mobile-task-badge.is-running { background: #2563eb; }
.mobile-task-badge.is-ready { background: #16a34a; }
.mobile-task-badge.is-failed { background: #dc2626; }

.mobile-task-detail,
.mobile-task-retry {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 0.68rem;
  text-align: center;
  padding: 0.28rem 0.4rem;
}

.mobile-task-retry {
  text-decoration: none;
  font-weight: 700;
  color: #fecaca;
}

.mobile-history-item.is-blocked {
  cursor: default;
}

.mobile-active-jobs {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 8.5rem;
  overflow-y: auto;
  padding: 0.55rem 0.75rem 0.2rem;
}

.mobile-active-job {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: inherit;
  background: #12101a;
  border-radius: 0.55rem;
  padding: 0.35rem 0.5rem;
}

.mobile-active-job img,
.mobile-active-job-fallback {
  width: 2.2rem;
  height: 2.9rem;
  object-fit: cover;
  border-radius: 0.35rem;
  background: #2a2738;
  flex-shrink: 0;
}

.mobile-active-job-copy {
  min-width: 0;
}

.mobile-active-job-copy strong,
.mobile-active-job-copy span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-active-job-copy strong {
  font-size: 0.78rem;
  font-weight: 600;
}

.mobile-active-job-copy span {
  margin-top: 0.1rem;
  font-size: 0.68rem;
  color: #a1a1aa;
}

.mobile-status-toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--mobile-nav-h) + var(--mobile-model-dock-h, 3.25rem) + 1rem);
  z-index: 120;
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  max-width: 90%;
  text-align: center;
}

/* Google OAuth shortcut button */
.mobile-google-btn {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  border-radius: 0.75rem;
  border: 1px solid #52525b;
  background: #fff;
  color: #1f1f1f;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.8rem 1rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.mobile-google-btn:hover {
  background: #f4f4f5;
  border-color: #a1a1aa;
}
.mobile-google-btn-icon {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}
.mobile-auth-or {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.1rem 0;
  color: #71717a;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.mobile-auth-or::before,
.mobile-auth-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #3f3f46;
}
.mobile-auth-or span {
  flex-shrink: 0;
}
