/* ── Apple Style CSS ───────────────────────────────── */

:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #161616;
  --bg-card: rgba(255, 255, 255, 0.05);
  --bg-card-hover: rgba(255, 255, 255, 0.08);
  --text: #f5f5f7;
  --text-muted: #86868b;
  --border: rgba(255, 255, 255, 0.1);
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --success: #30d158;
  --error: #ff453a;
  --warning: #ff9f0a;
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.3);
  --radius: 16px;
  --radius-large: 24px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ── Hero ── */
.hero {
  text-align: center;
  padding: 32px 20px;
}

.logo-container {
  margin-bottom: 16px;
}

.logo {
  width: 64px;
  height: 64px;
  opacity: 0.9;
}

.hero h1 {
  font-size: 48px;
  font-weight: 600;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #f5f5f7 0%, #86868b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-badge {
  display: inline-block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  padding: 8px 20px;
  border-radius: 20px;
  letter-spacing: 0.5px;
  border: 1px solid var(--border);
}

/* ── Navigation ── */
.nav-bar {
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(20px);
  border-radius: var(--radius);
  margin: 0 auto 24px;
  width: fit-content;
}

.nav-link {
  padding: 10px 24px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
}

.nav-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.nav-link.active {
  color: var(--accent);
  background: rgba(0, 113, 227, 0.15);
}

/* ── Layout ── */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 24px 48px;
  width: 100%;
}

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

/* ── Cards ── */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-large);
  padding: 24px;
  transition: var(--transition);
}

.card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

.card-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text);
}

/* ── Form Grid ── */
.form-grid {
  display: grid;
  gap: 16px;
}

.form-grid.two-cols {
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 600px) {
  .form-grid.two-cols {
    grid-template-columns: 1fr;
  }
}

/* ── Fields ── */
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field > span {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}

.field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.strength-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  min-width: 50px;
  text-align: right;
}

/* ── Selects ── */
select {
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

select:hover {
  background-color: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

/* 下拉菜单选项样式 */
select option {
  background: #161616;
  color: #f5f5f7;
  padding: 8px 12px;
}

select option:hover {
  background: rgba(0, 113, 227, 0.2);
}

/* ── Textarea ── */
textarea {
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  min-height: 120px;
  transition: var(--transition);
  line-height: 1.5;
}

textarea::placeholder {
  color: var(--text-muted);
}

textarea:hover {
  background-color: rgba(255, 255, 255, 0.08);
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.1);
}

/* ── Size Note ── */
.size-note {
  font-size: 12px;
  color: var(--text-muted);
  margin: 8px 0 16px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  line-height: 1.5;
}

/* ── Reference Area (即梦风格) ── */
.reference-area {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.reference-preview {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.03);
  border: 2px dashed var(--border);
  transition: var(--transition);
}

.reference-preview:hover {
  border-color: var(--accent);
  background: rgba(0, 113, 227, 0.05);
}

.reference-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.add-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  transition: var(--transition);
}

.reference-preview:hover .add-icon {
  background: var(--accent);
  color: white;
  transform: scale(1.1);
}

.add-icon svg {
  width: 20px;
  height: 20px;
}

.reference-placeholder span {
  font-size: 12px;
  color: var(--text-muted);
}

.reference-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reference-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.reference-remove:hover {
  background: rgba(239, 68, 68, 0.9);
}

.reference-remove svg {
  width: 14px;
  height: 14px;
}

/* ── AI Optimize Button ── */
.btn-optimize {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.btn-optimize:hover {
  background: rgba(0, 113, 227, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-optimize svg {
  width: 14px;
  height: 14px;
}

.btn-optimize:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Prompt Examples ── */
.prompt-examples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}

.examples-label {
  font-size: 12px;
  color: var(--text-muted);
}

.example-tag {
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.example-tag:hover {
  background: rgba(0, 113, 227, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Strength Slider ── */
.strength-field input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.strength-field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.4);
}

.strength-field input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 113, 227, 0.5);
}

.strength-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── Actions ── */
.actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

/* ── Buttons ── */
.btn-primary {
  padding: 14px 24px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  letter-spacing: 0.3px;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(0, 113, 227, 0.3);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Status ── */
.status {
  font-size: 13px;
  text-align: center;
  padding: 8px;
  border-radius: 8px;
  transition: var(--transition);
}

.status[data-type="default"] {
  color: var(--text-muted);
}

.status[data-type="loading"] {
  color: var(--accent);
}

.status[data-type="success"] {
  color: var(--success);
}

.status[data-type="error"] {
  color: var(--error);
}

/* ── Results ── */
.results {
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius);
}

.results.empty {
  color: var(--text-muted);
  font-size: 14px;
}

.result-group {
  width: 100%;
}

.result-prompt {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-grid {
  display: grid;
  gap: 12px;
}

.image-grid.single {
  grid-template-columns: 1fr;
}

.image-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
}

.image-card img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  max-height: 500px;
}

.download-btn {
  display: block;
  text-align: center;
  padding: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
}

.download-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* ── Queue Toast ── */
.queue-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 24px;
  min-width: 300px;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.queue-toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(20px);
  pointer-events: none;
}

.queue-message {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 10px;
}

.queue-progress {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.queue-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #00d4ff);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 32px 20px;
  border-top: 1px solid var(--border);
}

.footer p {
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.7;
}

.footer-links {
  margin-top: 12px;
}

.footer-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
  margin: 0 12px;
  transition: var(--transition);
}

.footer-link:hover {
  color: var(--text);
  text-decoration: underline;
}

.footer-divider {
  color: var(--border);
}

/* ── Gallery Styles ── */
.content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 48px;
  width: 100%;
}

.card-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 8px;
}

.gallery-container {
  margin-top: 16px;
}

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

.gallery-item {
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
}

.gallery-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-card);
}

.gallery-item img {
  width: 100%;
  height: 180px;
  object-fit: cover;
}

.gallery-item-info {
  padding: 12px;
}

.gallery-prompt {
  margin: 0;
  font-size: 12px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-time {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--text-muted);
}

.gallery-loading,
.gallery-empty {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

/* ── Page Cards ── */
.page .card {
  margin-bottom: 16px;
}

.page .card h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 16px;
}

.page .card h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 16px 0 8px;
  color: var(--text);
}

.page .card p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}

.page .card ul {
  margin: 8px 0 16px 20px;
}

.page .card li {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .hero h1 {
    font-size: 32px;
  }

  .nav-link {
    padding: 8px 16px;
    font-size: 13px;
  }

  .layout {
    padding: 0 16px 32px;
  }

  .card {
    padding: 16px;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}
