:root {
  --ink: #202327;
  --muted: #707982;
  --soft: #99a3ad;
  --line: rgba(132, 145, 157, 0.24);
  --paper: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f9fbfc;
  --blue-soft: #a2c6d4;
  --blue-deep: #547f8e;
  --accent: #ff9e7f;
  --accent-strong: #ed7d5d;
  --green: #7daea3;
  --danger: #b54b3f;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.10);
  --shadow-soft: 0 18px 46px rgba(86, 104, 118, 0.14);
  --radius: 18px;
  --radius-lg: 28px;
  --motion: 520ms cubic-bezier(0.32, 0.72, 0, 1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
  font-family: "Plus Jakarta Sans", "PingFang SC", "Microsoft YaHei", ui-sans-serif, system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 12%, rgba(162, 198, 212, 0.45), transparent 31%),
    radial-gradient(circle at 86% 6%, rgba(255, 158, 127, 0.22), transparent 28%),
    linear-gradient(145deg, #f7f3ee 0%, var(--paper) 42%, #edf3f5 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,0.32) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.28) 1px, transparent 1px);
  background-size: 42px 42px;
  opacity: 0.28;
}

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

button {
  border: 0;
  cursor: pointer;
}

h1,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.06;
  letter-spacing: -0.05em;
}

h3 {
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.logo {
  width: max-content;
  margin: 0 0 8px;
  padding: 7px 11px;
  border-radius: 999px;
  color: #355f69;
  background: rgba(162, 198, 212, 0.24);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.login-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(460px, 100%);
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-soft);
}

.login-panel h1 {
  margin-bottom: 26px;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 50px;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
  transition: border-color var(--motion), box-shadow var(--motion), transform var(--motion);
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(255, 158, 127, 0.9);
  box-shadow: 0 0 0 4px rgba(255, 158, 127, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.login-panel button,
.main-btn {
  min-height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  font-weight: 900;
  box-shadow: 0 14px 30px rgba(255, 126, 94, 0.25);
  transition: transform var(--motion), box-shadow var(--motion), filter var(--motion);
}

.login-panel button:hover,
.main-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 36px rgba(255, 126, 94, 0.29);
}

.login-panel button:active,
.main-btn:active {
  transform: scale(0.985);
}

button[disabled] {
  opacity: 0.58;
  cursor: not-allowed;
}

.app-shell {
  position: relative;
  min-height: 100dvh;
  padding: 34px 30px 40px;
}

.header {
  max-width: 1380px;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.icon-button {
  width: 48px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  position: relative;
  box-shadow: var(--shadow);
  transition: transform var(--motion), box-shadow var(--motion), background var(--motion);
}

.icon-button:hover {
  transform: translateY(-1px);
  background: #fff;
  box-shadow: 0 12px 24px rgba(85, 105, 120, 0.16);
}

.icon-button::before,
.icon-button::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.logout-btn::before {
  width: 15px;
  height: 15px;
  border: 2px solid var(--ink);
  border-right: 0;
  border-radius: 5px 0 0 5px;
  transform: translate(-62%, -50%);
}

.logout-btn::after {
  width: 13px;
  height: 2px;
  background: var(--ink);
  box-shadow: 5px -4px 0 -1px var(--ink), 5px 4px 0 -1px var(--ink);
  transform: translate(-8%, -50%);
}

.refresh-btn::before {
  width: 17px;
  height: 17px;
  border: 2px solid var(--ink);
  border-left-color: transparent;
  border-radius: 50%;
}

.workspace {
  max-width: 1380px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 22px;
}

.control-panel {
  flex: 0 0 390px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.history-panel {
  flex: 1 1 auto;
  min-width: 0;
}

.card {
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.params-card {
  padding: 22px;
  display: grid;
  gap: 14px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.dropdown {
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--blue-deep) 50%),
    linear-gradient(135deg, var(--blue-deep) 50%, transparent 50%),
    rgba(255, 255, 255, 0.92);
  background-position:
    calc(100% - 20px) 50%,
    calc(100% - 14px) 50%,
    0 0;
  background-size: 6px 6px, 6px 6px, 100% 100%;
  background-repeat: no-repeat;
}

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

.optimize-prompt {
  justify-self: end;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(162, 198, 212, 0.28);
  color: #406b76;
  font-weight: 900;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
  transition: transform var(--motion), background var(--motion);
}

.optimize-prompt:hover {
  transform: translateY(-1px);
  background: rgba(162, 198, 212, 0.40);
}

.segmented-control,
.style-selector {
  display: grid;
  gap: 8px;
}

.segmented-control {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 5px;
  border-radius: 16px;
  background: rgba(162, 198, 212, 0.18);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.66);
}

.segmented-control button,
.style-card {
  min-height: 40px;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
  transition: transform var(--motion), background var(--motion), color var(--motion), box-shadow var(--motion);
}

.segmented-control button:hover,
.style-card:hover {
  transform: translateY(-1px);
}

.segmented-control button.active,
.style-card.active {
  background: #fff;
  color: #2f6572;
  box-shadow: 0 10px 20px rgba(96, 124, 138, 0.14);
}

.style-selector {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.style-card {
  border: 1px solid rgba(132, 145, 157, 0.18);
  background: rgba(255, 255, 255, 0.58);
}

.model-preset-block,
.preset-block {
  display: grid;
  gap: 10px;
}

.model-preset-selector,
.flatlay-preset-selector {
  display: grid;
  gap: 10px;
}

.model-preset-selector {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.flatlay-preset-selector {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.model-preset-card,
.flatlay-preset-card {
  min-width: 0;
  padding: 6px;
  border: 1px solid rgba(132, 145, 157, 0.18);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
  display: grid;
  gap: 7px;
  text-align: center;
  font-size: 12px;
  font-weight: 900;
  position: relative;
  z-index: 1;
  transition: transform var(--motion), box-shadow var(--motion), border-color var(--motion), background var(--motion);
}

.model-preset-card:hover,
.flatlay-preset-card:hover {
  transform: translateY(-12px) scale(1.32);
  z-index: 20;
  background: #fff;
  box-shadow: 0 30px 64px rgba(84, 105, 120, 0.28);
}

.flatlay-preset-card:hover {
  transform: translateY(-8px) scale(1.12);
}

.model-preset-card.active,
.flatlay-preset-card.active {
  border-color: rgba(255, 158, 127, 0.74);
  background: #fff;
  color: #c76144;
  box-shadow: 0 12px 26px rgba(255, 126, 94, 0.17);
}

.model-preset-card img,
.flatlay-preset-card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: top center;
  border-radius: 12px;
  background: #edf3f5;
  transition: transform var(--motion), filter var(--motion);
}

.flatlay-preset-card img {
  aspect-ratio: 1 / 1;
}

.model-preset-card:hover img,
.flatlay-preset-card:hover img {
  transform: scale(1.08);
  filter: saturate(1.04) contrast(1.02);
}

.field-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.file-upload {
  position: relative;
  min-height: 124px;
  overflow: hidden;
  border: 1px dashed rgba(84, 127, 142, 0.42);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(162, 198, 212, 0.16), rgba(255, 255, 255, 0.70));
  transition: border-color var(--motion), box-shadow var(--motion), transform var(--motion);
}

.file-upload input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-upload.is-dragging {
  border-color: rgba(255, 158, 127, 0.84);
  box-shadow: 0 0 0 4px rgba(255, 158, 127, 0.16);
  transform: translateY(-1px);
}

.upload-empty,
.upload-preview {
  min-height: 124px;
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 18px;
  text-align: center;
  color: var(--muted);
}

.upload-empty span {
  color: var(--ink);
  font-weight: 900;
}

.upload-empty small {
  font-size: 12px;
}

.upload-preview {
  grid-template-columns: minmax(0, 1fr) 38px;
  place-items: center stretch;
  text-align: left;
}

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

.preview-item {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.preview-item img {
  width: 78px;
  height: 78px;
  border-radius: 16px;
  object-fit: cover;
  background: #e7edf0;
  box-shadow: 0 8px 20px rgba(76, 96, 108, 0.13);
}

.preview-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-weight: 900;
}

.remove-file {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
  position: relative;
  z-index: 2;
  box-shadow: var(--shadow);
}

.remove-file::before,
.remove-file::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 2px;
  left: 11px;
  top: 17px;
  background: var(--ink);
}

.remove-file::before {
  transform: rotate(45deg);
}

.remove-file::after {
  transform: rotate(-45deg);
}

.collapsible {
  display: grid;
  gap: 10px;
}

.toggle {
  min-height: 42px;
  border-radius: 14px;
  background: rgba(162, 198, 212, 0.18);
  color: var(--ink);
  font-weight: 900;
  text-align: left;
  padding: 0 14px;
}

.progress-bar-container {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(162, 198, 212, 0.28);
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--blue-soft));
  transition: width 360ms cubic-bezier(0.32, 0.72, 0, 1);
}

.progress-bar.is-running {
  width: 42%;
  animation: progress-pulse 1.3s cubic-bezier(0.32, 0.72, 0, 1) infinite alternate;
}

@keyframes progress-pulse {
  from { width: 28%; }
  to { width: 78%; }
}

.status,
.error {
  margin: 0;
  min-height: 22px;
  color: var(--muted);
  line-height: 1.5;
}

.error {
  margin-top: 14px;
  color: var(--danger);
}

.history-card {
  min-height: 620px;
  padding: 22px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.history-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.result-card {
  overflow: hidden;
  border: 1px solid rgba(132, 145, 157, 0.18);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transition: transform var(--motion), box-shadow var(--motion);
}

.result-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 32px rgba(84, 105, 120, 0.16);
}

.result-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: block;
  object-fit: cover;
  background: #e7edf0;
}

.card-info {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.info-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--soft);
  font-size: 12px;
}

.model {
  color: #426d77;
  font-weight: 900;
}

.prompt-summary {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.download-image {
  min-height: 40px;
  border-radius: 14px;
  background: rgba(255, 158, 127, 0.16);
  color: #c76144;
  font-weight: 900;
  text-decoration: none;
  display: grid;
  place-items: center;
  transition: transform var(--motion), background var(--motion);
}

.download-image:hover {
  transform: translateY(-1px);
  background: rgba(255, 158, 127, 0.24);
}

@media (max-width: 980px) {
  .app-shell {
    padding: max(16px, env(safe-area-inset-top)) 14px max(22px, env(safe-area-inset-bottom));
  }

  .header {
    margin-bottom: 16px;
    align-items: flex-start;
  }

  .workspace {
    flex-direction: column;
    gap: 14px;
  }

  .control-panel,
  .history-panel {
    width: 100%;
    flex: none;
  }

  .params-card,
  .history-card {
    padding: 16px;
  }

  .history-card {
    min-height: auto;
  }

  .segmented-control {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .style-selector {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .model-preset-selector {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  textarea {
    min-height: 150px;
  }

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

  .info-top {
    display: grid;
    gap: 3px;
  }
}

@media (max-width: 520px) {
  .login-shell {
    padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
    align-items: start;
    padding-top: 16dvh;
  }

  .login-panel {
    padding: 24px;
    border-radius: 24px;
  }

  .header {
    gap: 12px;
  }

  .logo {
    font-size: 10px;
  }

  h1 {
    font-size: 27px;
  }

  .icon-button {
    width: 44px;
    height: 42px;
  }

  .segmented-control {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .model-preset-selector,
  .flatlay-preset-selector {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .upload-preview {
    grid-template-columns: minmax(0, 1fr) 36px;
  }

  .preview-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .preview-item img {
    width: 68px;
    height: 68px;
  }
}
