:root {
  color-scheme: light;
  --ink: #20322d;
  --muted: #6c756f;
  --paper: #f6f4ec;
  --panel: #ffffff;
  --line: #d8ded4;
  --green: #2f6c4f;
  --blue: #3e6c7f;
  --clay: #b75d2a;
  --shadow: 0 22px 70px rgba(32, 50, 45, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--paper);
  background:
    linear-gradient(135deg, rgba(62, 108, 127, 0.13), transparent 36%),
    linear-gradient(315deg, rgba(183, 93, 42, 0.12), transparent 32%),
    var(--paper);
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1240px, calc(100vw - 48px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 48px;
  align-items: center;
  padding: 34px 0;
}

.preview-panel {
  display: flex;
  justify-content: center;
  width: 100%;
}

.preview-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 999 / 1332;
  background: #f4f3f3;
  border: 1px solid rgba(32, 50, 45, 0.14);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.poster-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center;
}

.poster-image[src=""] {
  opacity: 0;
}

.poster-image:not([src]) {
  opacity: 0;
}

.poster-image.is-color-sampling {
  cursor: crosshair;
  outline: 3px solid rgba(47, 108, 79, 0.68);
  outline-offset: -3px;
  touch-action: manipulation;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 32px;
  color: var(--muted);
  background: #f4f3f3;
  text-align: center;
}

.empty-state-art {
  display: block;
  width: min(86%, 340px);
  max-height: 72%;
  object-fit: contain;
}

.empty-state-message {
  display: none;
  max-width: 260px;
}

.empty-state.has-message .empty-state-message {
  display: block;
}

.empty-state.is-loading .empty-state-art {
  display: none;
}

.empty-state.is-hidden {
  display: none;
}

.loading-mark {
  display: none;
  width: 34px;
  height: 34px;
  border: 3px solid rgba(47, 108, 79, 0.18);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.empty-state.is-loading .loading-mark {
  display: block;
}

.control-panel {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(32, 50, 45, 0.12);
  border-radius: 20px;
  box-shadow: 0 18px 48px rgba(32, 50, 45, 0.1);
  padding: 32px;
}

.brand-row {
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(32px, 4vw, 48px);
  line-height: 1;
  letter-spacing: 0;
}

.subtitle {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.composer-form {
  display: grid;
  gap: 14px;
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.field-actions,
.upload-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.text-button {
  min-height: auto;
  padding: 0;
  color: var(--blue);
  background: transparent;
  border-radius: 0;
  font-size: 14px;
  font-weight: 800;
}

.upload-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.upload-label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.upload-file-name {
  max-width: 150px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

textarea {
  width: 100%;
  min-height: 156px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  color: var(--ink);
  background: #fbfbf7;
  line-height: 1.7;
  outline: none;
}

textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 108, 79, 0.14);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  color: var(--ink);
  cursor: pointer;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0 4px;
}

.color-label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.color-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.chip-button,
.color-picker-button {
  min-height: 38px;
  padding: 0 12px;
  color: var(--ink);
  background: #fbfbf7;
  border: 1px solid var(--line);
  font-size: 14px;
}

.chip-button.is-active,
.color-picker-button.is-active {
  border-color: rgba(47, 108, 79, 0.54);
  box-shadow: 0 0 0 3px rgba(47, 108, 79, 0.1);
}

.color-picker-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.color-dot {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border: 1px solid rgba(32, 50, 45, 0.18);
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 50%, rgba(32, 50, 45, 0.08) 0),
    linear-gradient(transparent 50%, rgba(32, 50, 45, 0.08) 0),
    #fff;
  background-size: 8px 8px;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 4px;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  color: #fff;
  background: var(--green);
  font-weight: 800;
}

button:hover:not(:disabled) {
  filter: brightness(0.96);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

button.is-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

button.is-loading::before {
  content: "";
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.secondary-button {
  color: var(--ink);
  background: #e5ece6;
}

.site-footer {
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 0 8px calc(16px + env(safe-area-inset-bottom));
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

.site-footer a {
  color: rgba(32, 50, 45, 0.62);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--green);
  text-decoration: underline;
}

.toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  max-width: min(calc(100vw - 40px), 360px);
  padding: 12px 18px;
  color: #fff;
  background: rgba(32, 50, 45, 0.94);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(32, 50, 45, 0.2);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

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

@media (prefers-reduced-motion: reduce) {
  .loading-mark,
  button.is-loading::before {
    animation-duration: 1.6s;
  }
}

@media (max-width: 860px) {
  body {
    background: var(--paper);
  }

  .app-shell {
    width: min(100vw - 32px, 620px);
    grid-template-columns: 1fr;
    gap: 24px;
    align-items: start;
    padding: 20px 0 28px;
  }

  .site-footer {
    width: min(100vw - 32px, 620px);
  }

  .preview-panel {
    order: 2;
  }

  .control-panel {
    order: 1;
    padding: 24px;
  }

  .preview-frame {
    width: 100%;
  }
}

@media (max-width: 460px) {
  .app-shell {
    width: min(100vw - 20px, 420px);
  }

  .site-footer {
    width: min(100vw - 20px, 420px);
  }

  .button-row {
    grid-template-columns: 1fr;
  }

  .upload-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .upload-actions {
    width: 100%;
    justify-content: flex-start;
  }
}
