*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #101827 0, #020617 45%, #020617 100%);
  color: #e5e7eb;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.page {
  width: 100%;
  max-width: 960px;
}

.card {
  background: rgba(15, 23, 42, 0.96);
  border-radius: 24px;
  padding: 28px 24px 24px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow:
    0 24px 60px rgba(15, 23, 42, 0.9),
    0 0 0 1px rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(18px);
}

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

.card-header-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.title {
  margin: 0 0 4px;
  font-size: 28px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.subtitle {
  margin: 0;
  font-size: 14px;
  color: #9ca3af;
}

.auth-button {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: radial-gradient(circle at top left, rgba(248, 250, 252, 0.06), transparent);
  color: #e5e7eb;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(12px);
  transition:
    background 0.12s ease-out,
    border-color 0.12s ease-out,
    transform 0.08s ease-out,
    box-shadow 0.08s ease-out;
}

.auth-button:hover {
  border-color: rgba(248, 250, 252, 0.9);
  background: radial-gradient(circle at top left, rgba(248, 250, 252, 0.12), transparent);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.8);
  transform: translateY(-0.5px);
}

.inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: auto auto auto;
  gap: 16px 20px;
  align-items: end;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-label {
  font-size: 13px;
  color: #e5e7eb;
  font-weight: 500;
}

.field-hint {
  margin: 0;
  font-size: 12px;
  color: #6b7280;
}

.file-input,
.select-input {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  border-radius: 10px;
  border: 1px solid rgba(55, 65, 81, 0.9);
  background: rgba(15, 23, 42, 0.9);
  color: #e5e7eb;
}

.file-input::file-selector-button {
  margin-right: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(55, 65, 81, 0.9);
  background: rgba(15, 23, 42, 0.9);
  color: #e5e7eb;
  cursor: pointer;
  font-size: 12px;
}

.file-input:hover::file-selector-button {
  border-color: #38bdf8;
}

.select-input:focus,
.file-input:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.4);
}

.primary-btn {
  grid-column: 2 / 3;
  padding: 10px 16px;
  border-radius: 999px;
  border: none;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  background: linear-gradient(135deg, #22c55e, #22c55e, #0ea5e9);
  color: #020617;
  box-shadow:
    0 14px 30px rgba(34, 197, 94, 0.4),
    0 0 0 1px rgba(15, 23, 42, 0.9);
  transition:
    transform 0.08s ease-out,
    box-shadow 0.08s ease-out,
    filter 0.08s ease-out,
    opacity 0.08s ease-out,
    background 0.08s ease-out;
  justify-self: end;
}

.primary-btn:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
}

.primary-btn:not(:disabled):hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
  box-shadow:
    0 18px 40px rgba(34, 197, 94, 0.5),
    0 0 0 1px rgba(15, 23, 42, 0.9);
}

.primary-btn:not(:disabled):active {
  transform: translateY(0);
  box-shadow:
    0 10px 22px rgba(34, 197, 94, 0.35),
    0 0 0 1px rgba(15, 23, 42, 0.9);
}

/* 生成中：显示为「停止生成」红色按钮 */
.primary-btn.primary-btn--stop {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 12px 28px rgba(239, 68, 68, 0.4);
}
.primary-btn.primary-btn--stop:hover {
  filter: brightness(1.08);
  box-shadow: 0 18px 40px rgba(239, 68, 68, 0.5);
}

.status-text {
  grid-column: 1 / -1;
  margin: 0;
  min-height: 18px;
  font-size: 12px;
  color: #9ca3af;
}

.status-text--error {
  color: #fca5a5;
}

.status-text--success {
  color: #4ade80;
}

.status-text--loading {
  color: #fbbf24;
}

.result {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(31, 41, 55, 0.9);
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.result-title {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: #e5e7eb;
}

.secondary-btn {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(55, 65, 81, 0.9);
  background: rgba(15, 23, 42, 0.7);
  color: #e5e7eb;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition:
    background 0.08s ease-out,
    border-color 0.08s ease-out,
    opacity 0.08s ease-out;
}

.secondary-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.secondary-btn:not(:disabled):hover {
  background: rgba(15, 23, 42, 0.95);
  border-color: rgba(148, 163, 184, 0.9);
}

.result-body {
  border-radius: 18px;
  border: 1px dashed rgba(55, 65, 81, 0.9);
  background: radial-gradient(circle at top left, #0f172a 0, #020617 50%);
  min-height: 260px;
  max-height: 420px;
  padding: 12px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  overflow-y: auto;
}

.result-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
  align-items: flex-start;
  justify-content: flex-start;
}

.result-placeholder {
  border-radius: 14px;
  border: 1px dashed rgba(75, 85, 99, 0.9);
  color: #6b7280;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

#resultGallery > div {
  /* 覆盖 JS 内联样式中的小边框与尺寸 */
  max-width: none !important;
  width: calc(33.333% - 10px) !important;
  border: none !important;
  border-radius: 12px !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden;
}

#resultGallery img {
  width: 100% !important;
  border-radius: 12px !important;
  display: block;
}

.result-image {
  max-width: 100%;
  max-height: 420px;
  border-radius: 14px;
  display: block;
  margin: 0 auto;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.85);
}

/* Auth modal */

.auth-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  z-index: 40;
}

.auth-modal-overlay.auth-modal-overlay--visible {
  opacity: 1;
  pointer-events: auto;
}

.auth-modal {
  width: 100%;
  max-width: 380px;
  border-radius: 22px;
  background: rgba(248, 250, 252, 0.92);
  backdrop-filter: blur(22px);
  box-shadow:
    0 26px 70px rgba(15, 23, 42, 0.9),
    0 0 0 1px rgba(148, 163, 184, 0.25);
  padding: 20px 22px 18px;
  color: #020617;
  position: relative;
}

.auth-modal-title {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #020617;
}

.auth-modal-subtitle {
  margin: 0 0 16px;
  font-size: 13px;
  color: #6b7280;
}

.auth-modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: none;
  background: rgba(15, 23, 42, 0.06);
  color: #020617;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.1s ease-out,
    transform 0.08s ease-out;
}

.auth-modal-close:hover {
  background: rgba(15, 23, 42, 0.12);
  transform: translateY(-0.5px);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.auth-label {
  font-size: 12px;
  font-weight: 500;
  color: #4b5563;
}

.auth-input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(209, 213, 219, 0.9);
  background: rgba(255, 255, 255, 0.96);
  font-size: 13px;
  color: #020617;
}

.auth-input:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.35);
}

.auth-primary-btn {
  margin-top: 4px;
  width: 100%;
  padding: 9px 14px;
  border-radius: 999px;
  border: none;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  background: linear-gradient(135deg, #22c55e, #0ea5e9);
  color: #f9fafb;
  box-shadow: 0 12px 30px rgba(34, 197, 94, 0.35);
  transition:
    transform 0.08s ease-out,
    box-shadow 0.08s ease-out,
    filter 0.08s ease-out;
}

.auth-primary-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
  box-shadow: 0 16px 36px rgba(34, 197, 94, 0.45);
}

.auth-primary-btn:active {
  transform: translateY(0);
  box-shadow: 0 10px 24px rgba(34, 197, 94, 0.3);
}

.auth-secondary {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.auth-secondary-text {
  font-size: 12px;
  color: #6b7280;
}

.auth-link-btn {
  border: none;
  background: transparent;
  color: #0ea5e9;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.auth-link-btn:hover {
  color: #0284c7;
}

@media (max-width: 768px) {
  body {
    padding: 16px;
    align-items: stretch;
  }

  .card {
    padding: 20px 16px 18px;
    border-radius: 20px;
  }

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

  .primary-btn {
    grid-column: 1 / -1;
    width: 100%;
    justify-content: center;
  }

  .auth-modal {
    margin: 0 16px;
  }
}

/* 预览模态框 */
.preview-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  cursor: zoom-out;
}

.preview-modal.active {
  display: flex;
}

.preview-modal img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 8px;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

/* 图片容器基础样式（叠加到上面的宽度/圆角等基础样式上） */
#resultGallery img {
  position: relative;
  cursor: context-menu;
}

/* 桌面端：右键保存提示 */
#resultGallery img::after {
  content: "右键保存图片";
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.75);
  color: #ffffff;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

/* 移动端：长按保存提示 */
@media (max-width: 768px) {
  #resultGallery img::after {
    content: "长按图片保存";
  }
}

#resultGallery img:hover::after,
#resultGallery img:active::after {
  opacity: 1;
}
