/* Mobile generation experience overlay and result polish */
:root {
  --mge-ink: #101828;
  --mge-muted: #667085;
  --mge-line: rgba(15, 23, 42, 0.08);
  --mge-mint: #0e9f76;
  --mge-mint-2: #12b981;
  --mge-warm: #ffb85c;
}

@media (max-width: 760px) {
  html { scroll-behavior: smooth; }

  body {
    -webkit-tap-highlight-color: transparent;
    text-rendering: optimizeLegibility;
  }

  input,
  textarea,
  select {
    font-size: 16px !important;
  }

  button,
  .btn,
  .floating-gen-btn,
  .quick-download-btn,
  .tune-btn,
  [role="button"],
  input[type="submit"] {
    min-height: 44px;
    touch-action: manipulation;
  }

  .chat-container {
    max-width: 100%;
    background:
      radial-gradient(circle at 18% -5%, rgba(18, 185, 129, 0.12), transparent 30%),
      linear-gradient(180deg, #f7fbfa 0%, #f2f5f4 100%);
  }

  .chat-messages {
    gap: 10px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .msg {
    max-width: 92%;
    border-radius: 17px;
  }

  .msg.ai {
    border-color: rgba(15, 23, 42, 0.07);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
  }

  .floating-gen-bar {
    position: fixed !important;
    left: 10px;
    right: 10px;
    bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 40;
    margin: 0 !important;
    padding: 10px;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    background: rgba(255, 255, 255, 0.82) !important;
    box-shadow: 0 18px 46px rgba(15, 23, 42, 0.14);
    backdrop-filter: blur(18px) saturate(1.2);
    -webkit-backdrop-filter: blur(18px) saturate(1.2);
  }

  .floating-gen-bar .hint-text {
    margin-bottom: 7px !important;
    color: var(--mge-muted) !important;
    font-size: 11px !important;
  }

  .floating-gen-btn {
    width: 100%;
    border-radius: 16px !important;
    background: linear-gradient(135deg, var(--mge-mint), var(--mge-mint-2)) !important;
    box-shadow: 0 12px 26px rgba(14, 159, 118, 0.26) !important;
    animation: none !important;
  }

  .floating-gen-btn.banner-btn {
    margin: 8px 0 0 !important;
    background: #101828 !important;
    box-shadow: 0 10px 24px rgba(16, 24, 40, 0.16) !important;
  }

  .progress-box.compact-progress,
  .generation-status-card {
    width: min(336px, calc(100vw - 54px)) !important;
    border-radius: 20px !important;
    border-color: rgba(255, 255, 255, 0.82) !important;
    background:
      radial-gradient(circle at 16% 8%, rgba(255, 184, 92, 0.18), transparent 34%),
      linear-gradient(145deg, rgba(255, 255, 255, 0.94), rgba(242, 251, 248, 0.86)) !important;
    box-shadow: 0 16px 42px rgba(15, 23, 42, 0.12) !important;
  }

  .quick-result-card {
    width: min(100%, 430px);
    overflow: hidden;
    border-radius: 24px !important;
    border: 1px solid rgba(255, 255, 255, 0.78);
    background:
      radial-gradient(circle at 10% 0%, rgba(18, 185, 129, 0.10), transparent 30%),
      #fff;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.10);
  }

  .quick-result-preview,
  .panel-card img,
  img[data-mge-ready="1"] {
    content-visibility: auto;
    transition: opacity 0.28s ease, transform 0.28s ease, filter 0.28s ease;
  }

  img[data-mge-ready="1"]:not([data-mge-loaded="1"]) {
    opacity: 0.08;
    filter: blur(10px);
    transform: scale(0.985);
  }

  .quick-result-preview {
    border-radius: 16px !important;
    background: #f8fafc;
  }

  .panel-strip {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
    overflow: visible !important;
  }

  .panel-card {
    min-width: 0 !important;
    border-radius: 16px !important;
    background: #f8fafc !important;
  }
}

.mge-progress {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 2147483000;
  display: none;
  color: #fff;
  padding: 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: linear-gradient(135deg, rgba(16, 24, 40, 0.96), rgba(24, 42, 38, 0.94));
  box-shadow: 0 22px 70px rgba(15, 23, 42, 0.34);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
}

.mge-progress.is-active {
  display: block;
  animation: mgeIn 0.34s cubic-bezier(.2,.85,.2,1) forwards;
}

.mge-progress.is-done {
  animation: mgeDone 0.5s ease forwards;
}

.mge-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mge-orbit {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: conic-gradient(from 90deg, var(--mge-warm), #ff7a59, var(--mge-mint-2), #8bd3ff, var(--mge-warm));
  position: relative;
  animation: mgeSpin 1.6s linear infinite;
}

.mge-orbit::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: #162026;
}

.mge-title {
  font-size: 14px;
  font-weight: 850;
  line-height: 1.25;
}

.mge-sub {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  line-height: 1.35;
}

.mge-bar {
  height: 7px;
  margin-top: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.14);
}

.mge-bar span {
  display: block;
  width: 8%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffe08a, #ff9c6a, #69e6a8);
  transition: width 0.45s cubic-bezier(.2,.8,.2,1);
}

.mge-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 11px;
  color: rgba(255, 255, 255, 0.44);
  font-size: 11px;
}

.mge-steps span.is-on {
  color: #ffe8a8;
}

@keyframes mgeIn {
  to { transform: translateY(0); opacity: 1; }
}

@keyframes mgeDone {
  70% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(14px); opacity: 0; }
}

@keyframes mgeSpin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .mge-progress,
  .mge-orbit,
  img[data-mge-ready="1"] {
    animation: none !important;
    transition: none !important;
  }
}
