/* Instagram 风格样式 */
:root {
  --primary-color: #0095f6;
  --primary-hover: #1877f2;
  --bg-primary: #ffffff;
  --bg-secondary: #fafafa;
  --bg-card: #ffffff;
  --text-primary: #262626;
  --text-secondary: #8e8e8e;
  --border-color: #dbdbdb;
  --danger-color: #ed4956;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* Header */
.header {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 935px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
}

.logo-icon {
  font-size: 28px;
}

.nav {
  display: flex;
  gap: 16px;
}

.nav-link {
  color: var(--text-primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  transition: background 0.2s;
  cursor: pointer;
  background: none;
  border: none;
}

.nav-link:hover {
  background: var(--bg-secondary);
}

/* Main */
.main {
  flex: 1;
  max-width: 935px;
  margin: 0 auto;
  padding: 30px 20px;
  width: 100%;
}

/* Gallery */
.gallery-container {
  position: relative;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

@media (max-width: 768px) {
  .gallery {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

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

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.gallery-item:hover img {
  transform: scale(1.02);
}

.gallery-item .overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.gallery-item:hover .overlay {
  opacity: 1;
}

/* Loader */
.loader {
  display: flex;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Empty */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty p {
  font-size: 18px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
}

.modal-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  background: var(--bg-primary);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-content img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  font-size: 24px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.8);
}

.modal-info {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
}

.modal-info p {
  font-size: 14px;
  margin-bottom: 8px;
}

.modal-info span {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Auth */
.auth-container {
  display: flex;
  justify-content: center;
  padding: 60px 20px;
}

.auth-form {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 350px;
}

.auth-form h2 {
  text-align: center;
  margin-bottom: 30px;
  font-size: 20px;
  color: var(--text-primary);
}

.form-group {
  margin-bottom: 12px;
}

.form-group input {
  width: 100%;
  padding: 12px 10px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg-secondary);
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.btn-primary {
  width: 100%;
  padding: 10px 16px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

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

.error-msg {
  color: var(--danger-color);
  font-size: 12px;
  text-align: center;
  margin-top: 16px;
}

/* Generate Section */
.generate-section {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}

.generate-section h2 {
  font-size: 18px;
  margin-bottom: 16px;
}

.generate-form textarea {
  width: 100%;
  min-height: 100px;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 12px;
}

.generate-form textarea:focus {
  outline: none;
  border-color: var(--primary-color);
}

.generate-options {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.generate-options select {
  padding: 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg-primary);
  cursor: pointer;
  min-width: 120px;
}

.generate-options .btn-primary {
  width: auto;
  flex: 1;
}

/* Advanced Options */
.advanced-toggle {
  width: 100%;
  padding: 8px 16px;
  margin-top: 12px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}

.advanced-toggle:hover {
  color: var(--text-primary);
}

.advanced-options {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.advanced-options .form-group {
  margin-bottom: 12px;
}

.advanced-options label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.advanced-options input,
.advanced-options textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}

.advanced-options input:focus,
.advanced-options textarea:focus {
  outline: none;
  border-color: var(--primary-color);
}

.advanced-row {
  display: flex;
  gap: 12px;
}

.advanced-row .form-group {
  flex: 1;
}

/* Model Badge */
.gallery-item-info {
  position: absolute;
  top: 8px;
  left: 8px;
  opacity: 0;
  transition: opacity 0.2s;
}

.gallery-item:hover .gallery-item-info {
  opacity: 1;
}

.model-badge {
  display: inline-block;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 11px;
  border-radius: 4px;
  white-space: nowrap;
}

.generate-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  margin-top: 16px;
}

.generate-status .spinner {
  width: 20px;
  height: 20px;
}

/* Divider */
.divider {
  height: 1px;
  background: var(--border-color);
  margin: 24px 0;
}

/* Gallery Section */
.gallery-section h2 {
  font-size: 18px;
  margin-bottom: 16px;
}

/* Admin Gallery Item */
.gallery-item-actions {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.gallery-item:hover .gallery-item-actions {
  opacity: 1;
}

.btn-icon {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.btn-icon:hover {
  background: white;
}

.btn-icon.danger:hover {
  color: var(--danger-color);
}

/* Hidden */
.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 600px) {
  .generate-options {
    flex-direction: column;
  }

  .generate-options .btn-primary {
    width: 100%;
  }
}