:root {
  --bg: oklch(0.96 0.018 84);
  --surface: oklch(0.99 0.012 88);
  --ink: oklch(0.22 0.025 74);
  --muted: oklch(0.48 0.035 72);
  --line: oklch(0.84 0.025 82);
  --brand: oklch(0.53 0.13 42);
  --brand-strong: oklch(0.43 0.13 38);
  --green: oklch(0.53 0.11 148);
  --blue: oklch(0.47 0.08 228);
  --shadow: 0 20px 60px color-mix(in oklch, var(--ink), transparent 88%);
  --radius: 8px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100svh;
  color: var(--ink);
  background:
    linear-gradient(180deg, oklch(0.98 0.018 92), var(--bg) 42%, oklch(0.94 0.022 76)),
    var(--bg);
  font-family: ui-rounded, "SF Pro Rounded", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

.app-shell {
  width: min(100%, 560px);
  margin: 0 auto;
  padding: max(var(--space-xl), env(safe-area-inset-top)) var(--space-lg)
    max(var(--space-2xl), env(safe-area-inset-bottom));
  display: grid;
  gap: var(--space-lg);
}

.topbar,
.step-panel,
.result-panel {
  background: color-mix(in oklch, var(--surface), transparent 5%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.topbar {
  padding: var(--space-lg) var(--space-xl);
}

.eyebrow {
  margin: 0 0 var(--space-xs);
  color: var(--muted);
  font-size: 1rem;
  font-weight: 750;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 1.85rem;
  line-height: 1.05;
}

h2 {
  font-size: 1.35rem;
  line-height: 1.2;
}

.step-panel {
  padding: var(--space-md);
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: var(--space-md);
}

.step-number {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--surface);
  font-size: 1.1rem;
  font-weight: 900;
}

.step-content {
  display: grid;
  gap: var(--space-md);
  min-width: 0;
}

.upload-box {
  min-height: 150px;
  border: 2px dashed color-mix(in oklch, var(--brand), transparent 45%);
  border-radius: var(--radius);
  background: oklch(0.97 0.025 82);
  display: grid;
  place-items: center;
  gap: var(--space-sm);
  padding: var(--space-lg);
  text-align: center;
  cursor: pointer;
}

.upload-box input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.upload-icon {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--brand);
  color: oklch(0.99 0.01 90);
  display: grid;
  place-items: center;
  font-size: 2.1rem;
  line-height: 1;
}

.upload-main {
  display: block;
  font-size: 1.28rem;
  font-weight: 900;
}

.upload-sub,
.helper-text {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.45;
}

.preview-wrap {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: oklch(0.18 0.015 70);
  min-height: 190px;
}

.preview-wrap img,
.result-image-frame img {
  width: 100%;
  display: block;
}

.small-button {
  border: 0;
  border-radius: 999px;
  min-height: 48px;
  padding: 0 18px;
  background: oklch(0.94 0.018 85);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 850;
}

textarea {
  width: 100%;
  min-height: 88px;
  resize: vertical;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-lg);
  color: var(--ink);
  background: oklch(0.99 0.008 90);
  font-size: 1.16rem;
  line-height: 1.45;
}

textarea:focus,
button:focus-visible,
.download-button:focus-visible,
.upload-box:focus-within {
  outline: 4px solid color-mix(in oklch, var(--blue), transparent 55%);
  outline-offset: 3px;
}

.action-area {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin: 0 calc(var(--space-lg) * -1);
  padding: var(--space-md) var(--space-lg) max(var(--space-md), env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--bg) 24%);
  display: grid;
  gap: var(--space-sm);
}

.primary-button {
  width: 100%;
  min-height: 66px;
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: oklch(0.99 0.01 90);
  font-size: 1.45rem;
  font-weight: 950;
  box-shadow: 0 12px 24px color-mix(in oklch, var(--brand), transparent 70%);
}

.primary-button:disabled {
  background: oklch(0.78 0.02 80);
  color: oklch(0.48 0.02 80);
  box-shadow: none;
}

.helper-text {
  margin: 0;
  text-align: center;
}

.scroll-result-button {
  min-height: 54px;
  border: 1px solid color-mix(in oklch, var(--green), transparent 35%);
  border-radius: 999px;
  background: oklch(0.94 0.04 142);
  color: oklch(0.32 0.09 144);
  font-size: 1.12rem;
  font-weight: 900;
}

.result-panel {
  padding: var(--space-lg);
  display: grid;
  gap: var(--space-lg);
}

.result-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
}

.download-button {
  min-height: 60px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  padding: 0 20px;
  background: var(--green);
  color: oklch(0.99 0.01 120);
  text-decoration: none;
  font-size: 1.3rem;
  font-weight: 900;
}

.result-image-frame {
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: oklch(0.18 0.015 70);
}

.toast {
  position: static;
  border-radius: var(--radius);
  padding: var(--space-md);
  background: oklch(0.91 0.035 88);
  color: var(--brand-strong);
  text-align: center;
  font-size: 1.05rem;
  font-weight: 850;
  box-shadow: none;
}

.hidden {
  display: none;
}

@media (min-width: 680px) {
  .app-shell {
    padding-top: 48px;
  }
}
