﻿:root {
  --blue: #4778f5;
  --blue-dark: #2f65ee;
  --ink: #171b27;
  --muted: #8b93a5;
  --line: #e8ecf4;
  --soft: #f7f9fd;
  --danger: #ff463f;
  --ok: #2f78ff;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #f7f8fb;
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

button,
label,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
  display: grid;
  place-items: center;
}

.phone-app {
  position: relative;
  width: min(100%, 390px);
  min-height: min(844px, calc(100vh - 36px));
  overflow: hidden;
  border: 1px solid #dfe4ee;
  border-radius: 32px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(20, 30, 55, 0.1);
}

.top-bar {
  height: 72px;
  padding: 0 16px;
  display: grid;
  grid-template-columns: 42px 1fr 78px;
  align-items: center;
}

.top-bar h1 {
  margin: 0;
  text-align: center;
  font-size: 17px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.top-bar h1 img {
  width: 24px;
  height: 24px;
  border-radius: 8px;
}

.icon-button,
.text-button,
.link-button {
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 31px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.text-button {
  color: #3f4756;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.danger {
  color: var(--danger);
}

.view {
  display: none;
  padding: 22px 22px 92px;
  animation: view-in 0.22s ease both;
}

.view.active {
  display: block;
}

.upload-box {
  min-height: 300px;
  border: 1.5px dashed rgba(71, 120, 245, 0.45);
  border-radius: 14px;
  background: linear-gradient(180deg, #fff, #fbfcff);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  text-align: center;
  cursor: pointer;
  transition: 0.18s ease;
}

.upload-box.dragging {
  border-color: var(--blue);
  background: #f3f7ff;
  transform: scale(0.99);
}

.upload-box input {
  display: none;
}

.upload-icon {
  width: 74px;
  height: 74px;
  color: var(--blue);
}

.upload-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.upload-box strong {
  margin-top: 6px;
  font-size: 18px;
  font-weight: 900;
}

.upload-box small,
.upload-box em {
  color: #8e96a7;
  font-style: normal;
  font-size: 13px;
}

.upload-box em {
  margin-top: 42px;
}

.usage-card {
  margin-top: 28px;
  padding: 20px 18px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(30, 42, 70, 0.06);
}

.usage-card strong {
  display: block;
  margin-bottom: 13px;
  font-size: 15px;
}

.usage-card p {
  margin: 9px 0;
  color: #4f5768;
  font-size: 12px;
  line-height: 1.7;
}

.usage-card span {
  display: inline-grid;
  width: 18px;
  color: var(--blue);
}

.privacy-note {
  position: absolute;
  right: 22px;
  bottom: 28px;
  left: 22px;
  margin: 0;
  color: #a7adba;
  font-size: 11px;
  text-align: center;
}

.manage-title {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.manage-title strong {
  font-size: 17px;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.preview-card,
.preview-add {
  position: relative;
  aspect-ratio: 1 / 1.16;
  overflow: hidden;
  border-radius: 12px;
  background: #f1f4f9;
}

.preview-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preview-card img.is-broken {
  opacity: 0;
}

.preview-card button {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 27px;
  height: 27px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #232633;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}

.preview-card span {
  position: absolute;
  bottom: 9px;
  left: 9px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #fff;
  background: rgba(0, 0, 0, 0.48);
  display: grid;
  place-items: center;
  font-weight: 900;
}

.preview-card small {
  position: absolute;
  right: 8px;
  bottom: 9px;
  max-width: calc(100% - 50px);
  padding: 5px 8px;
  border-radius: 999px;
  color: #fff;
  background: rgba(47, 101, 238, 0.82);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-card[data-status="failed"] small {
  background: rgba(255, 70, 63, 0.9);
}

.preview-card[data-status="uploading"]::after,
.preview-card[data-status="queued"]::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 20%, rgba(255, 255, 255, 0.48), transparent 80%);
  animation: sweep 1.2s ease-in-out infinite;
}

.preview-add {
  border: 1.5px dashed rgba(71, 120, 245, 0.48);
  color: var(--blue);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  cursor: pointer;
}

.preview-add span {
  font-size: 46px;
  font-weight: 300;
}

.preview-add strong {
  font-size: 14px;
}

.file-limit {
  margin: 14px 0 0;
  color: #a4abbb;
  font-size: 11px;
  text-align: center;
}

.feedback {
  min-height: 26px;
  margin: 12px 0 0;
  color: #737c8d;
  font-size: 13px;
  font-weight: 800;
}

.feedback[data-tone="ok"] {
  color: var(--ok);
}

.feedback[data-tone="bad"] {
  color: var(--danger);
}

.primary-button,
.secondary-button {
  min-height: 52px;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  border: 0;
  text-decoration: none;
  font-weight: 900;
  cursor: pointer;
}

.primary-button {
  color: #fff;
  background: linear-gradient(180deg, #557ff8, #356af1);
  box-shadow: 0 16px 34px rgba(53, 106, 241, 0.28);
}

.primary-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.secondary-button {
  color: var(--blue);
  background: #fff;
  border: 1px solid rgba(71, 120, 245, 0.45);
}

.fixed-action {
  position: absolute;
  right: 22px;
  bottom: 28px;
  left: 22px;
}

.processing-view {
  min-height: 751px;
  padding-top: 96px;
  color: #fff;
  background:
    radial-gradient(circle at 50% 32%, rgba(71, 120, 245, 0.17), transparent 170px),
    linear-gradient(155deg, #262d38, #1b2029);
}

.processing-view h2 {
  margin: 28px 0 44px;
  text-align: center;
  font-size: 16px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.86);
}

.processing-stage-card {
  width: min(298px, 100%);
  margin: -12px auto 28px;
  padding: 16px 16px 15px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  box-shadow:
    0 20px 48px rgba(3, 8, 20, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px);
}

.processing-stage-eyebrow {
  display: block;
  margin-bottom: 7px;
  color: rgba(255, 255, 255, 0.52);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.processing-stage-card strong {
  display: block;
  color: rgba(255, 255, 255, 0.96);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.45;
}

.processing-stage-bar {
  margin-top: 13px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.processing-stage-bar span {
  display: block;
  width: 8%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6fa2ff, #c6dcff);
  box-shadow: 0 0 22px rgba(111, 162, 255, 0.55);
  transition: width 0.28s ease;
}

.processing-stage-strip {
  display: none;
}

.processing-stage-strip b {
  display: none;
}

.progress-ring {
  --progress: 0;
  width: 160px;
  height: 160px;
  margin: 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle, #252c37 57%, transparent 58%),
    conic-gradient(#4f86ff calc(var(--progress) * 1%), rgba(84, 101, 125, 0.22) 0);
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
  animation: ring-breathe 1.8s ease-in-out infinite;
}

.progress-ring span {
  font-size: 40px;
  font-weight: 500;
}

.process-list {
  width: 230px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.process-list span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: rgba(255, 255, 255, 0.76);
  font-size: 14px;
}

.process-list span::after {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.18);
}

.process-list span.done::after {
  border-color: #4f86ff;
  background: #4f86ff;
  box-shadow: inset 0 0 0 4px #fff0;
}

.process-list span.active::after {
  border-top-color: #4f86ff;
  animation: spin 0.9s linear infinite;
}

.queue-summary {
  width: min(270px, 100%);
  margin: 34px auto 0;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.055);
  text-align: center;
  font-size: 12px;
  line-height: 1.7;
  position: relative;
  overflow: hidden;
}

.queue-summary::after {
  content: "";
  position: absolute;
  inset: auto 14px 8px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #4f86ff, transparent);
  animation: loading-line 1.45s linear infinite;
}

.processing-view small {
  position: absolute;
  bottom: 34px;
  right: 24px;
  left: 24px;
  text-align: center;
  color: rgba(255,255,255,0.62);
  font-size: 12px;
}

.result-view {
  padding-bottom: 36px;
}

.compare-box {
  position: relative;
  height: var(--compare-height, 548px);
  overflow: hidden;
  border-radius: 12px;
  background: #e9edf4;
  --compare-image-width: 100%;
  --compare-height: 548px;
}

.compare-box img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
}

.compare-box.result-only img {
  object-fit: contain;
}

.compare-box[data-image-state]::after {
  content: attr(data-image-message);
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 8;
  transform: translate(-50%, -50%);
  min-width: 168px;
  max-width: calc(100% - 48px);
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.84);
  color: #52627a;
  border: 1px solid rgba(112, 137, 180, 0.18);
  box-shadow: 0 16px 36px rgba(64, 87, 132, 0.14);
  font-size: 13px;
  font-weight: 900;
  text-align: center;
  backdrop-filter: blur(16px);
}

.compare-box[data-image-state="loading"]::before {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(50% - 46px);
  z-index: 8;
  width: 28px;
  height: 28px;
  margin-left: -14px;
  border-radius: 50%;
  border: 3px solid rgba(83, 125, 245, 0.18);
  border-top-color: #4f7df4;
  animation: spin 0.9s linear infinite;
}

.compare-box[data-image-state="failed"] {
  cursor: pointer;
}

.compare-box[data-image-state="failed"]::after {
  color: #d14949;
  background: rgba(255, 246, 246, 0.94);
  border-color: rgba(209, 73, 73, 0.18);
}

.after-layer {
  position: absolute;
  inset: 0 auto 0 0;
  width: 50%;
  overflow: hidden;
  border-right: 2px solid rgba(255,255,255,0.98);
}

.after-layer.pending {
  width: 0 !important;
  border-right: 0;
}

.compare-box.result-only .compare-handle {
  display: none;
}

.after-layer img {
  width: var(--compare-image-width, 100%);
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center center;
}

.compare-badge {
  position: absolute;
  z-index: 6;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(14, 20, 32, 0.54);
  color: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(14px);
  font-size: 12px;
  font-weight: 900;
}

.compare-badge.before {
  right: 12px;
  top: 12px;
}

.compare-badge.after {
  left: 12px;
  top: 12px;
}

.compare-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: block;
  background: rgba(255, 255, 255, 0.96);
  transform: translate(-50%, -50%);
  box-shadow:
    0 14px 34px rgba(16, 25, 44, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(116, 135, 172, 0.16);
  backdrop-filter: blur(16px);
  pointer-events: none;
}

.compare-handle::before,
.compare-handle::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 2px;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, #86a2ff, #5d7cf0);
  transform: translateY(-50%);
}

.compare-handle::before {
  left: 19px;
}

.compare-handle::after {
  right: 19px;
}

#compareSlider {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: ew-resize;
}

#compareSlider:disabled {
  cursor: default;
}

.link-button {
  width: 100%;
  margin: 20px 0;
  color: var(--blue);
  font-weight: 900;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.rating-card {
  margin-top: 28px;
  color: #333;
}

.rating-card span {
  display: block;
  margin-bottom: 13px;
  font-size: 14px;
}

.rating-stars {
  display: flex;
  gap: 8px;
}

.rating-stars button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  color: #cbd1dd;
  background: #f6f8fc;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.16s ease, color 0.16s ease, background 0.16s ease;
}

.rating-stars button.active {
  color: #fff;
  background: linear-gradient(180deg, #557ff8, #356af1);
  box-shadow: 0 10px 24px rgba(53, 106, 241, 0.24);
}

.rating-stars button:active {
  transform: scale(0.92);
}

.rating-card small {
  display: block;
  margin-top: 10px;
  color: #8b93a5;
  font-size: 12px;
}

.history-list {
  display: grid;
  gap: 14px;
}

.history-item {
  width: 100%;
  min-height: 92px;
  padding: 12px;
  border: 1px solid #edf0f5;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 12px 38px rgba(20, 30, 55, 0.05);
  display: grid;
  grid-template-columns: 100px 1fr minmax(34px, auto);
  align-items: center;
  gap: 12px;
  text-align: left;
  cursor: pointer;
}

.history-thumbs {
  display: block;
}

.history-thumbs img {
  width: 72px;
  height: 62px;
  border-radius: 8px;
  object-fit: cover;
  background: #f1f4f9;
}

.history-placeholder {
  width: 72px;
  height: 62px;
  border-radius: 8px;
  color: #7890c8;
  background: linear-gradient(180deg, #f4f7ff, #edf2ff);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 900;
}

.history-copy {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.history-copy strong {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 14px;
}

.history-copy small {
  color: #8b93a5;
  font-size: 12px;
}

.history-actions {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.history-open,
.history-retry {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.history-open {
  color: #a8afbd;
  background: transparent;
  font-size: 24px;
  line-height: 1;
}

.history-retry {
  padding: 6px 9px;
  border-radius: 999px;
  color: #fff;
  background: var(--danger);
  font-size: 11px;
  font-weight: 900;
  box-shadow: 0 8px 20px rgba(255, 70, 63, 0.18);
}

.history-retry:disabled {
  opacity: 0.48;
  cursor: wait;
}

.bottom-nav {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 70px;
  padding: 6px 64px max(8px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  background: rgba(255,255,255,0.94);
  border-top: 1px solid #edf0f5;
}

.bottom-nav button {
  border: 0;
  background: transparent;
  color: #9aa2b2;
  display: grid;
  gap: 3px;
  place-items: center;
  font-weight: 800;
  cursor: pointer;
}

.bottom-nav button.active {
  color: var(--blue);
}

.bottom-nav span {
  font-size: 12px;
}

.empty-text {
  padding: 80px 0;
  color: #8b93a5;
  text-align: center;
}

.hidden {
  display: none !important;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Refined mobile upload shell. Keep this block last so it overrides the legacy app styles. */
.app-shell {
  padding: 0;
  align-items: stretch;
  background:
    radial-gradient(circle at 30% 10%, rgba(71, 120, 245, 0.12), transparent 28%),
    linear-gradient(180deg, #fbfdff 0%, #f3f7ff 48%, #ffffff 100%);
}

.phone-app {
  width: min(100%, 430px);
  min-height: 100vh;
  margin: 0 auto;
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(circle at 78% 18%, rgba(86, 145, 255, 0.13), transparent 26%),
    linear-gradient(180deg, #ffffff 0%, #f8fbff 52%, #ffffff 100%);
  box-shadow: none;
}

.top-bar {
  min-height: 74px;
  height: auto;
  padding:
    max(10px, env(safe-area-inset-top))
    max(18px, calc(env(safe-area-inset-right) + 18px))
    8px
    max(18px, calc(env(safe-area-inset-left) + 18px));
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-bar h1 {
  flex: 1;
  min-width: 0;
  font-size: 17px;
  letter-spacing: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  text-align: left;
  overflow: hidden;
}

.top-bar h1 span {
  display: block;
  writing-mode: horizontal-tb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-bar h1 img {
  width: 22px;
  height: 22px;
}

.top-bar .hidden {
  display: none !important;
}

.top-bar .icon-button,
.top-bar .text-button {
  flex-shrink: 0;
}

.text-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(134, 153, 184, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: #3f69d8;
  box-shadow: 0 10px 28px rgba(70, 113, 190, 0.08);
}

.top-action-button {
  min-width: 64px;
  justify-content: center;
}

.view {
  padding: 18px 28px 106px;
}

.upload-view {
  padding-top: 6px;
}

.upload-hero-copy {
  margin: 4px 0 clamp(18px, 4vh, 28px);
}

.upload-hero-copy h2 {
  margin: 0;
  color: #121a2b;
  font-size: clamp(42px, 12vw, 58px);
  font-weight: 950;
  line-height: 0.98;
  letter-spacing: -0.08em;
}

.upload-hero-copy p {
  margin: 12px 0 0;
  color: #8f9cb2;
  font-size: clamp(18px, 5.2vw, 22px);
  font-weight: 800;
  letter-spacing: 0.05em;
}

.upload-hero-card {
  position: relative;
  min-height: clamp(408px, 56vh, 504px);
  padding: clamp(22px, 4.4vh, 34px) 28px 24px;
  overflow: visible;
  border: 1px solid rgba(198, 218, 255, 0.85);
  border-radius: 34px;
  background:
    radial-gradient(circle at 50% 34%, rgba(84, 143, 255, 0.16), transparent 26%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 252, 255, 0.94));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.72),
    0 26px 70px rgba(64, 112, 198, 0.13);
}

.upload-hero-card::before {
  content: "";
  position: absolute;
  inset: 20px;
  z-index: -1;
  border-radius: 34px;
  background: #d8e8ff;
  filter: blur(34px);
  opacity: 0.42;
}

.hero-photo-stack {
  position: relative;
  width: min(44vw, 174px);
  height: clamp(104px, 17vh, 140px);
  margin: 0 auto clamp(18px, 3vh, 24px);
  display: block;
}

.hero-photo-stack::before {
  content: "";
  position: absolute;
  width: 104px;
  height: 104px;
  right: 4px;
  top: 18px;
  border-radius: 18px;
  background: rgba(222, 234, 250, 0.78);
  transform: rotate(14deg);
  box-shadow: 0 18px 34px rgba(48, 88, 160, 0.12);
}

.hero-photo-stack img {
  position: absolute;
  left: 2px;
  top: 10px;
  width: min(32vw, 124px);
  height: auto;
  max-height: 96px;
  object-fit: cover;
  border: 8px solid #f6efe0;
  border-radius: 10px;
  transform: rotate(8deg);
  box-shadow: 0 18px 35px rgba(35, 51, 86, 0.18);
}

.upload-arrow {
  position: absolute;
  right: 15px;
  bottom: 2px;
  width: 78px;
  height: 78px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 7px solid rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.86);
  color: var(--blue);
  font-size: 42px;
  font-weight: 950;
  line-height: 1;
  box-shadow: 0 18px 42px rgba(68, 116, 205, 0.2);
}

.upload-hero-card > .upload-icon {
  display: none;
}

.upload-hero-card strong {
  margin-top: 0;
  color: #121a2b;
  font-size: clamp(28px, 8vw, 34px);
  font-weight: 950;
  letter-spacing: -0.05em;
}

.upload-hero-card small {
  margin-top: -2px;
  color: #98a6bb;
  font-size: clamp(16px, 4.6vw, 19px);
  font-weight: 800;
}

.upload-hero-card em {
  display: none;
}

.choose-photo-pill {
  width: min(100%, 252px);
  height: clamp(52px, 7vh, 58px);
  margin: clamp(18px, 3.4vh, 26px) auto 0;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(180deg, #4c83ff, #276df0);
  color: #fff;
  font-size: 20px;
  font-weight: 950;
  box-shadow: 0 20px 48px rgba(39, 109, 240, 0.28);
}

.repair-flow {
  width: 100%;
  margin-top: clamp(16px, 3vh, 24px);
  padding: 15px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 1px solid #e4ebf5;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.74);
  color: #95a1b3;
  font-size: 15px;
  font-weight: 900;
}

.repair-flow b:first-child {
  color: var(--blue);
}

.repair-flow i {
  font-style: normal;
  color: #b6c0ce;
}

.privacy-note {
  right: 28px;
  bottom: max(86px, calc(env(safe-area-inset-bottom) + 78px));
  left: 28px;
  color: #a6b1c2;
  font-size: 13px;
}

.bottom-nav {
  right: 0;
  bottom: 0;
  left: 0;
  height: max(84px, calc(env(safe-area-inset-bottom) + 74px));
  border-radius: 24px 24px 0 0;
  border: 1px solid #eaf0f8;
  border-bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
  box-shadow: 0 -18px 44px rgba(57, 92, 154, 0.08);
}

.bottom-nav button {
  color: #8794a8;
  font-weight: 900;
}

.bottom-nav button.active {
  color: var(--blue);
}

.processing-view {
  min-height: calc(100vh - 86px);
  padding-top: 42px;
  color: #fff;
  background:
    radial-gradient(circle at 50% 28%, rgba(75, 130, 255, 0.24), transparent 25%),
    linear-gradient(180deg, #20262f, #111720);
}

.processing-preview {
  position: relative;
  width: min(100%, 320px);
  margin: 0 auto 24px;
  aspect-ratio: 0.78;
  overflow: hidden;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)),
    #161d27;
  box-shadow:
    0 30px 68px rgba(3, 8, 20, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.processing-preview > img,
.processing-overlay img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.processing-preview > img {
  filter: saturate(0.94) contrast(0.96) brightness(0.9);
}

.processing-preview.no-source > img,
.processing-preview.no-source .processing-overlay,
.processing-preview.no-source .processing-divider {
  display: none;
}

.processing-preview.no-source::before {
  content: "";
  position: absolute;
  inset: 22px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 16px);
}

.processing-preview.no-source::after {
  content: "正在同步原图";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.76);
  font-size: 15px;
  font-weight: 900;
}

.processing-overlay {
  position: absolute;
  inset: 0 0 auto;
  height: 0%;
  overflow: hidden;
  border-bottom: 2px solid rgba(255, 255, 255, 0.92);
  transition: height 0.32s ease;
  will-change: height;
}

.processing-overlay img {
  filter: saturate(1.05) contrast(1.08) brightness(1.06);
  transform: scale(1.015);
  transform-origin: top center;
}

.processing-divider {
  position: absolute;
  top: 0%;
  right: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.96), transparent);
  box-shadow: 0 0 18px rgba(137, 187, 255, 0.44);
  cursor: ns-resize;
  transition: top 0.32s ease;
  will-change: top;
}

.processing-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 58px;
  height: 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow:
    0 10px 28px rgba(9, 15, 28, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.92);
  transform: translate(-50%, -50%);
}

.processing-divider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(73, 126, 255, 0.95);
  background: rgba(255, 255, 255, 0.98);
  transform: translate(-50%, -50%);
  z-index: 1;
}

.processing-divider.dragging::after {
  width: 64px;
}

.processing-preview-badge,
.processing-progress-float {
  position: absolute;
  z-index: 2;
  border-radius: 999px;
  backdrop-filter: blur(18px);
}

.processing-preview-badge {
  left: 14px;
  padding: 8px 12px;
  color: rgba(255, 255, 255, 0.92);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  background: rgba(12, 17, 28, 0.48);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.processing-preview-badge.top {
  top: 14px;
}

.processing-preview-badge.bottom {
  bottom: 14px;
}

.processing-progress-float {
  top: 14px;
  right: 14px;
  min-width: 68px;
  padding: 8px 12px;
  color: #fff;
  font-size: 20px;
  font-weight: 950;
  text-align: center;
  background: rgba(17, 25, 42, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 14px 34px rgba(2, 8, 18, 0.18);
}

.processing-view .queue-summary,
.processing-view small {
  color: rgba(255, 255, 255, 0.72);
}

.processing-view .queue-summary {
  margin-top: 18px;
}

.processing-view h2 {
  margin: 0 0 18px;
  text-align: center;
  color: rgba(255, 255, 255, 0.94);
  font-size: 22px;
  font-weight: 950;
  letter-spacing: 0.02em;
}

.processing-stage-card {
  width: min(320px, 100%);
  margin: 0 auto 22px;
}

.process-list {
  width: min(288px, 100%);
  gap: 14px;
}

.process-list span {
  padding: 0 4px;
}

.process-list span::after {
  transform: scale(0.96);
}

@media (max-width: 380px) {
  .view {
    padding-inline: 22px;
  }

  .top-bar {
    gap: 10px;
  }

  .top-bar h1 {
    font-size: 16px;
  }

  .upload-hero-copy h2 {
    font-size: 42px;
  }

  .upload-hero-card {
    min-height: clamp(388px, 55vh, 470px);
    border-radius: 30px;
  }

  .processing-preview {
    width: min(100%, 294px);
    border-radius: 24px;
  }

  .hero-photo-stack {
    width: min(42vw, 156px);
  }

  .repair-flow {
    gap: 8px;
    font-size: 14px;
  }
}

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

@keyframes sweep {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(100%);
  }
}

@keyframes ring-breathe {
  50% {
    box-shadow:
      0 0 0 12px rgba(79, 134, 255, 0.06),
      inset 0 0 0 1px rgba(255,255,255,0.08);
  }
}

@keyframes loading-line {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(100%);
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding: 0;
    display: block;
  }

  .phone-app {
    width: 100%;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .view {
    padding-right: 22px;
    padding-left: 22px;
  }

  .upload-box {
    min-height: min(45vh, 330px);
  }

  .compare-box {
    height: var(--compare-height, min(62vh, 560px));
  }

  .after-layer img {
    width: var(--compare-image-width, 100%);
    max-width: none;
  }
}

@media (max-width: 520px) {
  .upload-view {
    padding-right: clamp(18px, 6vw, 28px);
    padding-left: clamp(18px, 6vw, 28px);
  }

  .upload-box.upload-hero-card {
    min-height: clamp(394px, 54vh, 488px);
  }

  .processing-view {
    padding-right: 22px;
    padding-left: 22px;
  }
}

@media (max-height: 760px) {
  .top-bar {
    min-height: 58px;
    padding-top: max(6px, env(safe-area-inset-top));
  }

  .upload-hero-copy {
    margin-bottom: 14px;
  }

  .upload-hero-copy h2 {
    font-size: clamp(38px, 11vw, 52px);
  }

  .upload-hero-copy p {
    margin-top: 8px;
  }

  .upload-box.upload-hero-card {
    min-height: 374px;
    padding-top: 20px;
    padding-bottom: 18px;
  }

  .hero-photo-stack {
    transform: scale(0.82);
    margin-bottom: 2px;
  }

  .repair-flow {
    padding: 12px 10px;
  }
}

/* Processing stays honest: it shows the user's source photos only, no fake before/after wipe. */
.processing-preview {
  display: flex;
  align-items: stretch;
}

.processing-preview > #processingBaseImage,
.processing-preview .processing-overlay,
.processing-preview .processing-divider,
.processing-preview .processing-preview-badge {
  display: none !important;
}

.processing-preview-track {
  width: 100%;
  height: 100%;
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.processing-preview-track::-webkit-scrollbar {
  display: none;
}

.processing-photo-card {
  position: relative;
  min-width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: inherit;
  scroll-snap-align: center;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03)),
    #161d27;
}

.processing-photo-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: rgba(0, 0, 0, 0.18);
}

.processing-photo-index,
.processing-photo-status,
.processing-photo-placeholder {
  position: absolute;
  z-index: 3;
  border-radius: 999px;
  background: rgba(14, 20, 32, 0.54);
  color: rgba(255,255,255,0.92);
  border: 1px solid rgba(255,255,255,0.12);
  backdrop-filter: blur(14px);
  font-weight: 900;
}

.processing-photo-index {
  top: 14px;
  left: 14px;
  padding: 7px 11px;
  font-size: 12px;
}

.processing-photo-status {
  right: 14px;
  bottom: 14px;
  padding: 7px 11px;
  font-size: 12px;
}

.processing-photo-placeholder {
  inset: 50% auto auto 50%;
  padding: 10px 14px;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  font-size: 14px;
}

.processing-preview.no-source::before,
.processing-preview.no-source::after {
  display: none;
}

.processing-progress-float {
  z-index: 8;
}

.result-view {
  padding-bottom: 116px;
}

.result-switcher {
  margin: 0 0 14px;
  padding: 8px;
  border: 1px solid #e8ecf4;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.84);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  box-shadow: 0 12px 34px rgba(20, 30, 55, 0.06);
}

.result-switcher button {
  min-height: 38px;
  border: 0;
  border-radius: 12px;
  color: var(--blue);
  background: rgba(71, 120, 245, 0.08);
  font-weight: 900;
}

.result-switcher button:disabled {
  color: #b5bdcc;
  background: #f3f6fb;
}

.result-switcher span {
  color: #3f4756;
  font-size: 13px;
  font-weight: 900;
}

.compare-box.result-only .compare-badge.before {
  display: none;
}

.compare-box.result-only .compare-badge.after {
  left: 12px;
}

.bottom-nav {
  z-index: 30;
}

/* Keep navigation pinned while long history lists scroll inside the app viewport. */
.phone-app {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

.view.active {
  height: calc(100vh - 74px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.view.active::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.processing-view.active {
  padding-bottom: 22px;
}

@media (max-height: 760px) {
  .view.active {
    height: calc(100vh - 58px);
  }
}

/* Repair progress uses the same bright language as the upload home, not a dark mode detour. */
.top-bar .icon-button {
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(134, 153, 184, 0.18);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.68);
  color: #243047;
  font-size: 0;
  box-shadow: 0 10px 26px rgba(70, 113, 190, 0.08);
}

.top-bar .icon-button::before {
  content: "←";
  font-size: 31px;
  line-height: 1;
  transform: translateY(-1px);
}

.processing-view {
  color: var(--ink);
  background:
    radial-gradient(circle at 26% 12%, rgba(71, 120, 245, 0.11), transparent 28%),
    radial-gradient(circle at 80% 28%, rgba(186, 213, 255, 0.24), transparent 24%),
    linear-gradient(180deg, #ffffff 0%, #f6f9ff 56%, #ffffff 100%);
}

.processing-view h2 {
  margin: 18px 0 16px;
  color: #121a2b;
  font-size: 24px;
  letter-spacing: -0.04em;
}

.processing-preview {
  border: 1px solid rgba(198, 218, 255, 0.82);
  background:
    radial-gradient(circle at 50% 28%, rgba(84, 143, 255, 0.14), transparent 32%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 252, 255, 0.92));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.72),
    0 24px 64px rgba(64, 112, 198, 0.12);
}

.processing-photo-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(246, 250, 255, 0.92)),
    #f8fbff;
}

.processing-photo-card img {
  background: rgba(234, 242, 255, 0.6);
}

.processing-progress-float,
.processing-photo-index,
.processing-photo-status,
.processing-photo-placeholder {
  background: rgba(255, 255, 255, 0.72);
  color: #2f65ee;
  border-color: rgba(71, 120, 245, 0.16);
  box-shadow: 0 12px 28px rgba(67, 113, 206, 0.11);
}

.processing-stage-card {
  border: 1px solid rgba(198, 218, 255, 0.68);
  background: rgba(255, 255, 255, 0.76);
  color: #121a2b;
  box-shadow: 0 16px 42px rgba(64, 112, 198, 0.1);
}

.processing-stage-card strong {
  color: #172032;
}

.processing-stage-eyebrow,
.processing-view .queue-summary {
  color: #8f9cb2;
}

.processing-stage-bar {
  background: rgba(71, 120, 245, 0.12);
}

.processing-stage-bar span {
  background: linear-gradient(90deg, #6da0ff, #2f65ee);
}

/* Keep the immediate repair action visible when returning from history. */
#manageView {
  position: relative;
  padding-bottom: max(178px, calc(env(safe-area-inset-bottom) + 156px));
}

#manageView .fixed-action {
  right: 22px;
  bottom: max(104px, calc(env(safe-area-inset-bottom) + 94px));
  left: 22px;
  z-index: 46;
}

