:root {
  --rose-900: #412231;
  --rose-700: #8f4264;
  --rose-500: #f36fae;
  --rose-300: #ffb8d6;
  --rose-200: #ffdce9;
  --rose-100: #fff2f8;
  --cream: #fff8ed;
  --paper: rgba(255, 251, 244, 0.92);
  --mint: #c9ef9a;
  --mint-2: #f0fbdc;
  --lemon: #fff4a8;
  --line: rgba(143, 66, 100, 0.18);
  --shadow: 0 22px 70px rgba(203, 77, 134, 0.22);
  --soft-shadow: 0 12px 36px rgba(203, 77, 134, 0.14);
  font-family: "Avenir Next Rounded", "Nunito", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--rose-900);
  background:
    linear-gradient(90deg, rgba(255, 184, 214, 0.22) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 184, 214, 0.16) 1px, transparent 1px),
    linear-gradient(135deg, #fff0f7 0%, #fff8f0 48%, #f5ffe1 100%);
  background-size: 34px 34px, 34px 34px, auto;
}

body::before {
  content: "♡ ✦ ♡ ✧ ♡ ✦ ♡";
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 0;
  width: min(920px, 92vw);
  transform: translateX(-50%);
  color: rgba(243, 111, 174, 0.22);
  font-size: clamp(28px, 4vw, 48px);
  letter-spacing: 22px;
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.login-card {
  position: fixed;
  inset: 50% auto auto 50%;
  width: min(430px, calc(100vw - 30px));
  transform: translate(-50%, -50%) rotate(-1deg);
  padding: 36px 32px 32px;
  border: 2px solid rgba(255, 255, 255, 0.84);
  border-radius: 38px;
  background:
    radial-gradient(circle at 90% 12%, rgba(201, 239, 154, 0.22), transparent 32%),
    linear-gradient(var(--paper), var(--paper)) padding-box,
    linear-gradient(135deg, var(--rose-300), var(--mint), var(--lemon)) border-box;
  box-shadow: var(--shadow);
  text-align: center;
  z-index: 10;
}

.login-card::before,
.creator-panel::before,
.result-card::before {
  content: "";
  position: absolute;
  width: 84px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255, 216, 232, 0.78);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
  transform: rotate(-8deg);
}

.login-card::before {
  top: -12px;
  left: 36px;
}

.app:not(.is-locked) .login-card {
  display: none;
}

.brand-badge {
  display: inline-grid;
  place-items: center;
  width: 82px;
  height: 82px;
  margin-bottom: 18px;
  border: 4px solid #fff;
  border-radius: 32px 32px 24px 32px;
  background: linear-gradient(135deg, #ff78b7, #ffd1e6 55%, #cdef8f);
  color: white;
  font-size: 23px;
  font-weight: 1000;
  box-shadow: 0 16px 34px rgba(243, 111, 174, 0.32);
  text-shadow: 0 2px 10px rgba(143, 66, 100, 0.28);
}

.login-card h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0;
}

.login-card p {
  margin: 12px 0 24px;
  color: var(--rose-700);
  line-height: 1.7;
}

.login-form {
  display: flex;
  gap: 10px;
}

.login-form input,
.prompt-box textarea,
.control-row select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--rose-900);
  outline: none;
  box-shadow: inset 0 2px 10px rgba(143, 66, 100, 0.04);
}

.login-form input {
  min-width: 0;
  padding: 15px 18px;
}

.login-form button,
#submitButton {
  padding: 14px 24px;
  border: 3px solid #fff;
  border-radius: 999px;
  color: white;
  font-weight: 1000;
  background: linear-gradient(135deg, #ff6caf, #ff9ccd 54%, #ffcfdf);
  box-shadow: 0 13px 24px rgba(243, 111, 174, 0.32), inset 0 -2px 0 rgba(143, 66, 100, 0.08);
  white-space: nowrap;
}

.login-form button:hover,
#submitButton:hover {
  transform: translateY(-1px);
}

.studio {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

.app.is-locked .studio {
  pointer-events: none;
  filter: blur(8px);
  opacity: 0.32;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px clamp(16px, 4vw, 50px) 18px;
}

.topbar > div {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar strong {
  font-size: 30px;
  font-weight: 1000;
  text-shadow: 0 4px 0 rgba(255, 220, 233, 0.9);
}

.topbar small {
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--rose-700);
  font-weight: 800;
}

.brand-dot {
  width: 28px;
  height: 28px;
  border: 4px solid #fff;
  border-radius: 50% 50% 38% 50%;
  background: linear-gradient(135deg, var(--rose-500), var(--mint));
  box-shadow: 0 0 0 7px rgba(255, 184, 214, 0.24);
}

.ghost-button,
.tiny-button {
  border: 2px solid #fff;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--rose-700);
  font-weight: 900;
  box-shadow: var(--soft-shadow);
}

.ghost-button {
  padding: 11px 17px;
}

.tiny-button {
  padding: 8px 13px;
  font-size: 13px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.03fr) minmax(340px, 0.97fr);
  gap: 24px;
  width: min(1450px, 100%);
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 50px) 42px;
}

.creator-panel,
.result-card,
.history-card {
  position: relative;
  border: 2px solid rgba(255, 255, 255, 0.8);
  background:
    radial-gradient(circle at 92% 8%, rgba(201, 239, 154, 0.22), transparent 34%),
    linear-gradient(var(--paper), var(--paper)) padding-box,
    linear-gradient(135deg, rgba(255, 184, 214, 0.9), rgba(255, 244, 168, 0.6), rgba(205, 239, 143, 0.82)) border-box;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.creator-panel {
  padding: 26px;
  border-radius: 42px;
}

.creator-panel::before {
  top: -11px;
  right: 78px;
  transform: rotate(7deg);
}

.result-card::before {
  top: -10px;
  left: 74px;
}

.panel-head,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-head h2 {
  display: inline-block;
  margin: 0 0 8px;
  padding: 4px 12px 8px;
  border-radius: 20px 24px 18px 24px;
  background: linear-gradient(180deg, transparent 52%, rgba(255, 216, 232, 0.88) 52%);
  font-size: 31px;
  font-weight: 1000;
  letter-spacing: 0;
}

.panel-head p {
  margin: 0;
  color: var(--rose-700);
  line-height: 1.6;
}

.count-badge {
  flex: 0 0 auto;
  padding: 12px 16px;
  border: 3px solid #fff;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--mint-2), var(--cream));
  color: #6c852e;
  font-weight: 1000;
  box-shadow: var(--soft-shadow);
}

.drop-zone {
  display: flex;
  align-items: center;
  gap: 17px;
  min-height: 118px;
  margin: 24px 0;
  padding: 20px;
  border: 2px dashed rgba(243, 111, 174, 0.5);
  border-radius: 34px;
  background:
    linear-gradient(135deg, rgba(255, 242, 248, 0.9), rgba(255, 250, 242, 0.82), rgba(240, 251, 220, 0.3)),
    repeating-linear-gradient(-45deg, transparent 0 12px, rgba(255, 184, 214, 0.22) 12px 14px);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.drop-zone:hover {
  transform: translateY(-2px);
  box-shadow: var(--soft-shadow);
}

.drop-zone input {
  display: none;
}

.drop-plus {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 3px solid #fff;
  border-radius: 26px 28px 22px 28px;
  background: linear-gradient(135deg, #fff, #ffe5f0);
  color: var(--rose-500);
  font-size: 36px;
  font-weight: 1000;
  box-shadow: var(--soft-shadow);
}

.drop-zone div {
  display: grid;
  gap: 6px;
}

.drop-zone strong,
.section-head strong,
.prompt-box > span,
.control-row span {
  font-weight: 1000;
}

.drop-zone span,
.status-text,
.history-meta,
.prompt-box > span,
.control-row span,
.section-head span {
  color: var(--rose-700);
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 13px;
  margin-bottom: 20px;
}

.preview-grid.is-empty {
  display: none;
}

.preview-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border: 4px solid #fff;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 10px 22px rgba(143, 66, 100, 0.12);
  transform: rotate(-0.5deg);
}

.preview-item:nth-child(even) {
  transform: rotate(0.8deg);
}

.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-item button {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: rgba(255, 242, 248, 0.94);
  color: #b53a70;
  font-weight: 1000;
  box-shadow: var(--soft-shadow);
}

.preview-item small {
  position: absolute;
  left: 8px;
  bottom: 8px;
  max-width: calc(100% - 16px);
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--rose-700);
  font-size: 11px;
  font-weight: 800;
}

.prompt-box {
  display: grid;
  gap: 10px;
}

.prompt-box textarea {
  min-height: 178px;
  resize: vertical;
  padding: 18px;
  line-height: 1.75;
  border-radius: 30px;
}

.prompt-box textarea:focus,
.control-row select:focus,
.login-form input:focus {
  border-color: rgba(243, 111, 174, 0.68);
  box-shadow: 0 0 0 5px rgba(255, 184, 214, 0.24), inset 0 2px 10px rgba(143, 66, 100, 0.04);
}

.control-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 13px;
  align-items: end;
  margin-top: 17px;
}

.control-row label {
  display: grid;
  gap: 8px;
}

.control-row select {
  height: 52px;
  padding: 0 15px;
}

#submitButton {
  height: 52px;
}

#submitButton:disabled,
.login-form button:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.result-panel {
  display: grid;
  gap: 20px;
  grid-template-rows: minmax(370px, auto) minmax(230px, 1fr);
}

.result-card,
.history-card {
  min-width: 0;
  padding: 20px;
  border-radius: 38px;
}

.section-head strong {
  font-size: 18px;
}

.result-view {
  display: grid;
  place-items: center;
  min-height: 320px;
  margin-top: 15px;
  overflow: hidden;
  border: 8px solid #fff;
  border-radius: 32px;
  background:
    linear-gradient(135deg, rgba(255, 250, 252, 0.82), rgba(255, 248, 237, 0.78), rgba(240, 251, 220, 0.22)),
    repeating-linear-gradient(90deg, transparent 0 18px, rgba(255, 184, 214, 0.12) 18px 20px);
  box-shadow: inset 0 0 0 1px rgba(143, 66, 100, 0.08);
}

.empty-state {
  padding: 30px;
  color: var(--rose-700);
  text-align: center;
  line-height: 1.7;
}

.loading-state {
  display: grid;
  gap: 13px;
  place-items: center;
  color: var(--rose-700);
  font-weight: 900;
}

.loading-heart {
  width: 46px;
  height: 46px;
  border: 4px solid #fff;
  border-radius: 18px 18px 14px 18px;
  background: linear-gradient(135deg, var(--rose-500), var(--rose-300), var(--mint));
  box-shadow: var(--soft-shadow);
  animation: pulse 1.2s infinite ease-in-out;
}

@keyframes pulse {
  0%, 100% { transform: scale(0.9) rotate(-7deg); opacity: 0.75; }
  50% { transform: scale(1.06) rotate(7deg); opacity: 1; }
}

.result-image {
  width: 100%;
  padding: 10px;
}

.result-image img {
  display: block;
  width: 100%;
  max-height: 68vh;
  object-fit: contain;
  border: 6px solid #fff;
  border-radius: 28px;
  box-shadow: 0 18px 42px rgba(143, 66, 100, 0.14);
}

.result-actions {
  display: flex;
  justify-content: center;
  padding-top: 14px;
}

.download-button {
  padding: 11px 18px;
  border: 3px solid #fff;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--mint-2), #fff);
  color: #65841f;
  font-weight: 1000;
  text-decoration: none;
  box-shadow: var(--soft-shadow);
}

.error-state {
  padding: 24px;
  color: #b53a70;
  font-weight: 900;
  text-align: center;
}

.history-list {
  display: grid;
  gap: 11px;
  max-height: 430px;
  margin-top: 13px;
  overflow: auto;
  padding-right: 4px;
}

.history-item {
  display: grid;
  gap: 9px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 8px 18px rgba(143, 66, 100, 0.07);
}

.history-item.is-active {
  border-color: rgba(243, 111, 174, 0.56);
  box-shadow: 0 0 0 5px rgba(255, 184, 214, 0.24), 0 8px 18px rgba(143, 66, 100, 0.07);
}

.history-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 1000;
}

.history-prompt {
  display: -webkit-box;
  overflow: hidden;
  color: var(--rose-700);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-height: 1.48;
}

.history-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.history-actions button {
  padding: 8px 12px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #fff2f8;
  color: #a84773;
  font-size: 13px;
  font-weight: 1000;
  box-shadow: 0 6px 14px rgba(143, 66, 100, 0.08);
}

.history-actions button:first-child {
  background: var(--mint-2);
  color: #65841f;
}

.status-text {
  min-height: 22px;
  margin-top: 12px;
  font-size: 14px;
  font-weight: 800;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .result-panel {
    grid-template-rows: auto auto;
  }
}

@media (max-width: 620px) {
  body::before {
    top: 8px;
    letter-spacing: 10px;
  }

  .topbar {
    padding: 16px;
  }

  .topbar strong {
    font-size: 27px;
  }

  .topbar small {
    display: none;
  }

  .workspace {
    padding: 0 12px 28px;
  }

  .creator-panel,
  .result-card,
  .history-card {
    border-radius: 30px;
  }

  .creator-panel {
    padding: 17px;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-head h2 {
    font-size: 27px;
  }

  .drop-zone {
    min-height: 106px;
  }

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

  .login-form {
    flex-direction: column;
  }

  .login-card {
    padding: 28px 24px;
    border-radius: 32px;
  }
}
