:root {
  --bg: #14141a;
  --surface: #1e1e27;
  --surface-hover: #26262f;
  --border: #33333f;
  --text: #f2f2f5;
  --text-dim: #9a9aa8;
  --accent: #ffc93c;
  --accent-dim: #4a3f1a;
  --danger: #ff6b6b;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.header {
  text-align: center;
  margin-bottom: 28px;
}

.header h1 {
  margin: 0 0 6px;
  font-size: 28px;
}

.subtitle {
  color: var(--text-dim);
  margin: 0;
  font-size: 14px;
}

.composer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

textarea {
  width: 100%;
  resize: vertical;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  line-height: 1.5;
}

.composer-options {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
}

.option select {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 13px;
  font-family: inherit;
}

.model-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-left: auto;
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 10px;
}

.status-text {
  color: var(--text-dim);
  font-size: 13px;
  flex: 1;
}

.status-text.error {
  color: var(--danger);
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.btn:active {
  transform: scale(0.97);
}

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

.btn.primary {
  background: var(--accent);
  color: #1a1a1a;
}

.btn.primary:hover:not(:disabled) {
  opacity: 0.9;
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn.ghost:hover:not(:disabled) {
  background: var(--surface-hover);
}

.btn.danger {
  background: var(--danger);
  color: #1a1a1a;
}

.btn.danger:hover:not(:disabled) {
  opacity: 0.9;
}

.preview-section {
  margin-top: 24px;
}

.preview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.preview-card img {
  max-width: 100%;
  max-height: 480px;
  border-radius: 8px;
  display: block;
  margin: 0 auto;
}

.preview-prompt {
  color: var(--text-dim);
  font-size: 13px;
  margin: 12px 0 0;
  text-align: left;
}

.preview-meta,
.lightbox-meta {
  color: var(--accent);
  font-size: 12px;
  margin: 6px 0 0;
  text-align: left;
}

.preview-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}

.gallery-section {
  margin-top: 40px;
}

.gallery-section h2 {
  font-size: 18px;
  margin-bottom: 14px;
}

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

.gallery-item {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  cursor: pointer;
}

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

.gallery-item .delete-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.gallery-item:hover .delete-btn {
  opacity: 1;
}

.gallery-item .delete-btn:hover {
  background: var(--danger);
}

.gallery-item .badge,
.gallery-item .cost-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.6);
  color: var(--accent);
}

.gallery-item .cost-badge {
  left: auto;
  right: 6px;
  top: 40px;
  color: #9dffb0;
}

.gallery-item .caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 6px 8px;
  font-size: 11px;
  color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75), transparent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-empty {
  color: var(--text-dim);
  font-size: 14px;
  text-align: center;
  padding: 40px 0;
}

.hidden {
  display: none !important;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.lightbox-content {
  max-width: 90vw;
  max-height: 90vh;
  text-align: center;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 8px;
}

.lightbox-content p {
  color: var(--text-dim);
  font-size: 13px;
  margin: 14px 0;
}

.confirm-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.confirm-content p {
  color: var(--text);
  font-size: 15px;
}
