/* ===== Reset & Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: #333;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px 80px;
  position: relative;
}

/* ===== Header ===== */
.header {
  text-align: center;
  padding: 24px 0 16px;
}
.header-title {
  font-size: 1.5rem;
  color: #fff;
  font-weight: 700;
  text-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.header-sub {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.8);
  margin-top: 4px;
}

/* ===== Section ===== */
.section {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.section-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #444;
  margin-bottom: 12px;
}
.optional {
  font-size: 0.75rem;
  color: #aaa;
  font-weight: 400;
}

/* ===== Scene Grid ===== */
.scene-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.scene-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px;
  border-radius: 12px;
  border: 2px solid #f0f0f0;
  cursor: pointer;
  transition: all 0.2s;
  background: #fafafa;
}
.scene-item:active { transform: scale(0.95); }
.scene-item.active {
  border-color: #667eea;
  background: linear-gradient(135deg, #667eea10, #764ba210);
}
.scene-icon { font-size: 1.5rem; margin-bottom: 4px; }
.scene-name { font-size: 0.75rem; color: #666; }
.scene-item.active .scene-name { color: #667eea; font-weight: 600; }

/* ===== Type Tabs ===== */
.type-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.type-tab {
  flex: 1;
  min-width: 0;
  padding: 8px 4px;
  border: 2px solid #f0f0f0;
  border-radius: 10px;
  background: #fafafa;
  font-size: 0.8rem;
  color: #666;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  white-space: nowrap;
}
.type-tab:active { transform: scale(0.95); }
.type-tab.active {
  border-color: #667eea;
  background: #667eea;
  color: #fff;
}

/* ===== Technique List ===== */
.technique-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.technique-item {
  padding: 6px 12px;
  border-radius: 20px;
  border: 1.5px solid #e8e8e8;
  background: #f8f8f8;
  font-size: 0.78rem;
  color: #666;
  cursor: pointer;
  transition: all 0.2s;
}
.technique-item:active { transform: scale(0.95); }
.technique-item.active {
  border-color: #764ba2;
  background: #764ba2;
  color: #fff;
}

/* ===== Target Input ===== */
.target-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #e8e8e8;
  border-radius: 10px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}
.target-input:focus { border-color: #667eea; }

/* ===== Context Input ===== */
.context-input-wrap {
  position: relative;
}
.context-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #e8e8e8;
  border-radius: 10px;
  font-size: 0.9rem;
  outline: none;
  resize: none;
  transition: border-color 0.2s;
}
.context-input:focus { border-color: #667eea; }
.voice-btn-wrap {
  margin-top: 10px;
  text-align: center;
}
.voice-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  border: 1.5px solid #667eea;
  border-radius: 20px;
  background: #fff;
  color: #667eea;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  -webkit-user-select: none;
}
.voice-btn:active, .voice-btn.recording {
  background: #667eea;
  color: #fff;
}
.voice-icon { font-size: 1.1rem; }

/* ===== Generate Button ===== */
.generate-wrap {
  padding: 8px 0 16px;
  text-align: center;
}
.generate-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 40px;
  border: none;
  border-radius: 28px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(102,126,234,0.4);
  transition: all 0.2s;
}
.generate-btn:active {
  transform: scale(0.96);
  box-shadow: 0 2px 8px rgba(102,126,234,0.3);
}
.generate-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.generate-icon { font-size: 1.2rem; }

/* ===== Result ===== */
.result-item {
  background: linear-gradient(135deg, #f8f9ff, #f3f0ff);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  position: relative;
  border-left: 4px solid #667eea;
}
.result-text {
  font-size: 0.92rem;
  line-height: 1.6;
  color: #333;
  word-break: break-all;
}
.result-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.72rem;
  color: #999;
}
.result-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  background: #667eea20;
  color: #667eea;
  font-size: 0.7rem;
}
.result-actions {
  display: flex;
  gap: 12px;
  margin-top: 10px;
}
.result-action {
  padding: 4px 12px;
  border-radius: 14px;
  border: 1px solid #ddd;
  background: #fff;
  font-size: 0.75rem;
  color: #666;
  cursor: pointer;
  transition: all 0.2s;
}
.result-action:active { transform: scale(0.95); }
.result-action.fav-active {
  border-color: #f5a623;
  color: #f5a623;
}

/* ===== Bottom Nav ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  background: #fff;
  border-top: 1px solid #eee;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
  z-index: 100;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  text-decoration: none;
  color: #999;
  font-size: 0.7rem;
  transition: color 0.2s;
}
.nav-item.active { color: #667eea; }
.nav-icon { font-size: 1.2rem; margin-bottom: 2px; }

/* ===== Favorites Page ===== */
.favorites-page {
  padding: 0 16px 80px;
}
.fav-item {
  background: #fff;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  position: relative;
}
.fav-content {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #333;
}
.fav-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 0.72rem;
  color: #aaa;
}
.fav-delete {
  color: #e74c3c;
  cursor: pointer;
  font-size: 0.75rem;
}
.empty-tip {
  text-align: center;
  padding: 40px 0;
  color: rgba(255,255,255,0.7);
  font-size: 0.9rem;
}

/* ===== Voice Overlay ===== */
.voice-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.voice-recording {
  text-align: center;
  color: #fff;
}
.voice-wave {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: radial-gradient(circle, #667eea, #764ba2);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.8; }
}
.voice-hint {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.6);
  margin-top: 8px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 0.85rem;
  z-index: 300;
  pointer-events: none;
}

/* ===== Loading ===== */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Responsive ===== */
@media (max-width: 360px) {
  .scene-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .scene-item { padding: 8px 2px; }
  .type-tabs { gap: 6px; }
  .type-tab { font-size: 0.72rem; padding: 6px 2px; }
}
