/* ============================================
   Echo 回声 — Styles
   Design System: Preset 14 (暮蓝 Twilight Blue)
   ============================================ */

/* --- CSS Variables (Preset 14) --- */
:root {
  /* Primary palette */
  --twilight-blue: #23314A;
  --dusty-rose: #DB8084;
  --blue-gray: #8FA1B1;
  --neutral-gray: #E5E5E5;
  --lavender: #D8BFD8;
  --deep-magenta: #C71585;

  /* Surface colors */
  --bg-deep: #0F1923;
  --bg-primary: #162231;
  --bg-card: #1C2D40;
  --bg-card-hover: #223750;
  --bg-input: #1A2838;

  /* Text colors */
  --text-primary: #F0F2F5;
  --text-secondary: #8FA1B1;
  --text-muted: #5C6E80;
  --text-accent: #DB8084;
  --text-magenta: #C71585;

  /* Borders */
  --border-subtle: rgba(143, 161, 177, 0.15);
  --border-card: rgba(143, 161, 177, 0.2);

  /* Shadows */
  --shadow-card: 0 1px 4px rgba(0, 0, 0, 0.2), 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-card-hover: 0 2px 8px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.2);
  --shadow-rose: 0 4px 16px rgba(219, 128, 132, 0.15);
  --shadow-modal: 0 0 0 1px rgba(143, 161, 177, 0.08), 0 16px 48px rgba(0, 0, 0, 0.4);

  /* Gradients */
  --gradient-twilight: linear-gradient(135deg, #23314A 0%, #DB8084 100%);
  --gradient-purple: linear-gradient(135deg, #23314A 0%, #C71585 100%);
  --gradient-card: linear-gradient(180deg, rgba(219, 128, 132, 0.05) 0%, rgba(35, 49, 74, 0.3) 100%);

  /* State colors */
  --success: #5A9A7A;
  --warning: #DBA060;
  --error: #C71585;

  /* Spacing (6px base) */
  --space-xs: 3px;
  --space-sm: 6px;
  --space-md: 18px;
  --space-lg: 36px;
  --space-xl: 72px;
  --space-2xl: 144px;

  /* Border radius */
  --radius-btn: 4px;
  --radius-card: 8px;
  --radius-modal: 12px;
  --radius-input: 4px;
  --radius-full: 9999px;

  /* Typography */
  --font-display: 'Playfair Display', 'Noto Serif SC', serif;
  --font-body: 'Inter', 'Noto Sans SC', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Transitions */
  --transition-fast: 200ms ease;
  --transition-normal: 350ms ease;
  --transition-slow: 600ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-weight: 300;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-deep);
  min-height: 100vh;
  overflow-x: hidden;
}

/* --- Particle Canvas --- */
#particle-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* --- App Container --- */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Header --- */
.header {
  text-align: center;
  padding: var(--space-xl) 0 var(--space-lg);
}

.logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
}

.logo-zh {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  background: var(--gradient-twilight);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-en {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 500;
  font-style: italic;
  color: var(--text-secondary);
  letter-spacing: 0.25em;
  text-transform: uppercase;
}

.tagline {
  margin-top: var(--space-sm);
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 300;
  letter-spacing: 0.05em;
}

/* --- Mode Tabs --- */
.mode-tabs {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  padding: var(--space-xs);
  background: var(--bg-primary);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

.mode-tab {
  flex: 1;
  max-width: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-sm) var(--space-md);
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-body);
  transition: all var(--transition-normal);
  position: relative;
}

.mode-tab:hover {
  color: var(--text-primary);
  background: rgba(143, 161, 177, 0.08);
}

.mode-tab.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
}

.mode-tab.active .mode-icon {
  transform: scale(1.1);
}

.mode-icon {
  font-size: 1.2rem;
  transition: transform var(--transition-fast);
}

.mode-label {
  font-size: 0.85rem;
  font-weight: 500;
  font-family: var(--font-body);
}

.mode-sub {
  font-size: 0.6rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

/* --- Views --- */
.view {
  display: none;
  flex: 1;
}

.view.active {
  display: block;
}

/* --- Input View --- */
.input-container {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: var(--space-lg);
  box-shadow: var(--shadow-card);
}

.input-prompt {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--space-md);
  font-style: italic;
  transition: all var(--transition-normal);
}

.echo-textarea {
  width: 100%;
  min-height: 120px;
  padding: var(--space-md);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-input);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 300;
  line-height: 1.8;
  resize: vertical;
  transition: border-color var(--transition-fast);
  outline: none;
}

.echo-textarea::placeholder {
  color: var(--text-muted);
  font-weight: 300;
}

.echo-textarea:focus {
  border-color: var(--dusty-rose);
  box-shadow: 0 0 0 3px rgba(219, 128, 132, 0.1);
}

.input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-md);
}

.char-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 300;
}

.btn-generate {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  border: none;
  border-radius: var(--radius-btn);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-normal);
  background: var(--gradient-twilight);
  color: white;
  box-shadow: var(--shadow-rose);
}

.btn-generate:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(219, 128, 132, 0.25);
}

.btn-generate:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-generate .btn-icon {
  font-size: 0.9rem;
  transition: transform var(--transition-fast);
}

.btn-generate:hover:not(:disabled) .btn-icon {
  transform: translateX(3px);
}

/* --- Loading View --- */
.loading-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl) 0;
  text-align: center;
}

.loading-view.hidden {
  display: none;
}

.loading-animation {
  position: relative;
  width: 120px;
  height: 120px;
  margin-bottom: var(--space-lg);
}

.loading-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--dusty-rose);
  border-right-color: var(--deep-magenta);
  border-radius: 50%;
  animation: spin 2s linear infinite;
}

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

.loading-particle-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
}

.loading-text {
  font-family: var(--font-display);
  font-size: 1rem;
  font-style: italic;
  color: var(--text-secondary);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* --- Result View --- */
.result-view {
  text-align: center;
}

.result-view.hidden {
  display: none;
}

.artwork-frame {
  position: relative;
  display: inline-block;
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-modal);
  margin-bottom: var(--space-lg);
  max-width: 100%;
}

.artwork-frame img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-card);
}

.artwork-glow {
  position: absolute;
  inset: -2px;
  border-radius: var(--radius-card);
  padding: 2px;
  background: var(--gradient-twilight);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.artwork-info {
  max-width: 480px;
  margin: 0 auto var(--space-lg);
}

.emotion-tag {
  display: inline-block;
  padding: var(--space-xs) var(--space-md);
  background: rgba(219, 128, 132, 0.12);
  color: var(--dusty-rose);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-md);
}

.artwork-interpretation {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 500;
  font-style: italic;
  color: var(--text-primary);
  line-height: 1.8;
  margin-bottom: var(--space-sm);
}

.artwork-quote {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 300;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
}

.btn-share, .btn-retry {
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-btn);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-normal);
}

.btn-share {
  border: none;
  background: var(--gradient-twilight);
  color: white;
  box-shadow: var(--shadow-rose);
}

.btn-share:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(219, 128, 132, 0.25);
}

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

.btn-retry:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
  background: rgba(143, 161, 177, 0.05);
}

/* --- Gallery View --- */
.gallery-header {
  text-align: center;
  padding: var(--space-md) 0 var(--space-lg);
}

.gallery-header h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.gallery-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 300;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-md);
  padding-bottom: var(--space-lg);
}

/* --- Echo Card --- */
.echo-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-card);
}

.echo-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  border-color: rgba(219, 128, 132, 0.3);
}

.echo-card-image {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.echo-card-body {
  padding: var(--space-md);
}

.echo-card-emotion {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--dusty-rose);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: var(--space-xs);
}

.echo-card-text {
  font-size: 0.82rem;
  font-weight: 300;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- Gallery Loading --- */
.gallery-loading {
  text-align: center;
  padding: var(--space-lg);
}

.gallery-loading.hidden {
  display: none;
}

.loading-ring.small {
  width: 32px;
  height: 32px;
  border-width: 2px;
  margin: 0 auto;
}

.btn-load-more {
  display: block;
  margin: 0 auto;
  padding: var(--space-sm) var(--space-lg);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-btn);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-normal);
}

.btn-load-more.hidden {
  display: none;
}

.btn-load-more:hover {
  border-color: var(--dusty-rose);
  color: var(--dusty-rose);
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 25, 35, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}

.modal-overlay.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-modal);
  padding: var(--space-lg);
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-modal);
  text-align: center;
  position: relative;
}

.modal-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(143, 161, 177, 0.1);
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: rgba(219, 128, 132, 0.15);
  color: var(--dusty-rose);
}

.modal-content h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: var(--space-lg);
  color: var(--text-primary);
}

.share-card-preview {
  border-radius: var(--radius-card);
  overflow: hidden;
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-card);
}

.share-card-preview canvas {
  display: block;
  width: 100%;
  height: auto;
}

.share-actions {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.btn-download, .btn-copy-link {
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-btn);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-normal);
}

.btn-download {
  border: none;
  background: var(--gradient-twilight);
  color: white;
  box-shadow: var(--shadow-rose);
}

.btn-download:hover {
  transform: translateY(-1px);
}

.btn-copy-link {
  border: 1px solid var(--border-card);
  background: transparent;
  color: var(--text-secondary);
}

.btn-copy-link:hover {
  border-color: var(--dusty-rose);
  color: var(--dusty-rose);
}

.share-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 300;
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: var(--space-lg);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-full);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 400;
  box-shadow: var(--shadow-modal);
  border: 1px solid var(--border-card);
  transition: all var(--transition-normal);
  pointer-events: none;
}

.toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(10px);
}

/* --- Footer --- */
.footer {
  text-align: center;
  padding: var(--space-xl) 0 var(--space-lg);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 300;
  line-height: 2;
}

.footer-sub {
  color: var(--text-muted);
  opacity: 0.6;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .app-container {
    padding: var(--space-md);
  }

  .header {
    padding: var(--space-lg) 0 var(--space-md);
  }

  .logo-zh {
    font-size: 2rem;
  }

  .mode-tabs {
    gap: 2px;
  }

  .mode-tab {
    padding: var(--space-sm) var(--space-sm);
  }

  .mode-label {
    font-size: 0.78rem;
  }

  .mode-sub {
    display: none;
  }

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

  .input-container {
    padding: var(--space-md);
  }

  .result-actions {
    flex-direction: column;
    align-items: center;
  }
}

@media (max-width: 480px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }

  .logo-zh {
    font-size: 1.75rem;
  }

  .echo-textarea {
    min-height: 100px;
    font-size: 0.9rem;
  }
}

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