/* ==================== CSS 变量 & 基础 ==================== */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: rgba(22, 22, 35, 0.85);
  --bg-card-hover: rgba(28, 28, 45, 0.9);
  --bg-input: rgba(15, 15, 25, 0.8);
  --border-color: rgba(120, 100, 255, 0.12);
  --border-active: rgba(120, 100, 255, 0.4);
  --text-primary: #e8e6f0;
  --text-secondary: #9490b0;
  --text-muted: #5e5a7a;
  --accent-purple: #8b5cf6;
  --accent-cyan: #06b6d4;
  --accent-pink: #ec4899;
  --accent-green: #22c55e;
  --accent-red: #ef4444;
  --gradient-main: linear-gradient(135deg, #8b5cf6, #06b6d4);
  --gradient-warm: linear-gradient(135deg, #ec4899, #8b5cf6);
  --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.15);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.3);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ==================== 背景动画 ==================== */
.bg-gradient {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none; overflow: hidden;
}

.bg-gradient .orb {
  position: absolute; border-radius: 50%; filter: blur(120px);
  opacity: 0.3; animation: float 20s ease-in-out infinite;
}

.bg-gradient .orb:nth-child(1) { width: 600px; height: 600px; background: var(--accent-purple); top: -200px; right: -100px; }
.bg-gradient .orb:nth-child(2) { width: 500px; height: 500px; background: var(--accent-cyan); bottom: -150px; left: -100px; animation-delay: -7s; }
.bg-gradient .orb:nth-child(3) { width: 400px; height: 400px; background: var(--accent-pink); top: 50%; left: 50%; transform: translate(-50%, -50%); animation-delay: -14s; }

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -40px) scale(1.05); }
  50% { transform: translate(-20px, 20px) scale(0.95); }
  75% { transform: translate(40px, 30px) scale(1.02); }
}

/* ==================== 主容器 ==================== */
.app-container { position: relative; z-index: 1; max-width: 960px; margin: 0 auto; padding: 40px 20px; }

/* ==================== 头部 ==================== */
.header { text-align: center; margin-bottom: 48px; }

.header-top {
  display: flex; align-items: center; justify-content: center;
  position: relative; margin-bottom: 16px;
}

.header-logo { display: inline-flex; align-items: center; gap: 12px; }

.header-icon {
  width: 52px; height: 52px; background: var(--gradient-main);
  border-radius: var(--radius-md); display: flex; align-items: center;
  justify-content: center; font-size: 26px;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.35);
}

.header h1 {
  font-size: 36px; font-weight: 800;
  background: var(--gradient-main); -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; background-clip: text; letter-spacing: -0.5px;
}

.header p { color: var(--text-secondary); font-size: 16px; margin-top: 8px; }

/* ==================== 用户区域 ==================== */
.user-area {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; gap: 10px;
}

.user-logged-in { display: flex; align-items: center; gap: 10px; }

.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--gradient-main); display: flex; align-items: center;
  justify-content: center; font-size: 16px;
}

.user-name { font-size: 14px; font-weight: 600; color: var(--text-primary); max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.user-balance {
  font-size: 12px; font-weight: 700; color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.12); border: 1px solid rgba(6, 182, 212, 0.2);
  padding: 3px 10px; border-radius: 20px; white-space: nowrap;
}

.profile-row.highlight { background: rgba(6, 182, 212, 0.08); border-color: rgba(6, 182, 212, 0.2); }
.profile-value.accent { color: var(--accent-cyan); font-size: 18px; font-weight: 800; }

.credit-amount-plus { color: var(--accent-green); font-weight: 700; }
.credit-amount-minus { color: var(--accent-red); font-weight: 700; }
.btn-sm { padding: 8px 16px; font-size: 13px; }

.btn-icon {
  background: none; border: 1px solid var(--border-color);
  color: var(--text-secondary); width: 32px; height: 32px;
  border-radius: 8px; cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}

.btn-icon:hover { border-color: var(--accent-red); color: var(--accent-red); }

/* ==================== 弹窗 ==================== */
.modal-overlay {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(8px);
  z-index: 100; align-items: center; justify-content: center;
}

.modal-overlay.show { display: flex; }

.modal {
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--radius-xl); padding: 32px; width: 100%;
  max-width: 420px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.modal-header h3 { font-size: 20px; font-weight: 700; }

.modal-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 18px; cursor: pointer; width: 32px; height: 32px;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}

.modal-close:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }

.auth-switch { text-align: center; margin-top: 16px; font-size: 14px; color: var(--text-muted); }
.auth-switch a { color: var(--accent-purple); text-decoration: none; font-weight: 600; margin-left: 4px; }
.auth-switch a:hover { text-decoration: underline; }

/* ==================== Tab 导航 ==================== */
.tab-nav {
  display: flex; gap: 4px; background: var(--bg-card);
  border: 1px solid var(--border-color); border-radius: var(--radius-lg);
  padding: 4px; margin-bottom: 32px; backdrop-filter: blur(20px);
}

.tab-btn {
  flex: 1; padding: 14px 24px; border: none; border-radius: var(--radius-md);
  background: transparent; color: var(--text-secondary); font-size: 15px;
  font-weight: 600; cursor: pointer; transition: var(--transition);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}

.tab-btn:hover { color: var(--text-primary); background: rgba(139, 92, 246, 0.08); }

.tab-btn.active {
  background: var(--gradient-main); color: white;
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.35);
}

.tab-btn .icon { font-size: 18px; }

/* ==================== 面板 ==================== */
.tab-panel { display: none; animation: fadeIn 0.4s ease; }
.tab-panel.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==================== 卡片 ==================== */
.card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-xl); padding: 28px; margin-bottom: 24px;
  backdrop-filter: blur(20px); box-shadow: var(--shadow-card);
  transition: var(--transition);
}

.card:hover { border-color: var(--border-active); box-shadow: var(--shadow-glow); }

.card-title {
  font-size: 18px; font-weight: 700; margin-bottom: 20px;
  display: flex; align-items: center; gap: 10px;
}

.card-title .badge {
  font-size: 11px; padding: 3px 10px; border-radius: 20px;
  background: var(--gradient-main); color: white; font-weight: 600;
}

/* ==================== 表单元素 ==================== */
.form-group { margin-bottom: 20px; }

.form-label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 8px;
  text-transform: uppercase; letter-spacing: 0.5px;
}

.form-input, .form-textarea, .form-select {
  width: 100%; padding: 12px 16px; background: var(--bg-input);
  border: 1px solid var(--border-color); border-radius: var(--radius-md);
  color: var(--text-primary); font-size: 14px; font-family: inherit;
  transition: var(--transition); outline: none;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--accent-purple); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.form-input::placeholder, .form-textarea::placeholder { color: var(--text-muted); }

.form-textarea { min-height: 140px; resize: vertical; line-height: 1.7; }

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239490b0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
  padding-right: 36px; cursor: pointer;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ==================== 开关 ==================== */
.switch-group {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--bg-input); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); cursor: pointer; transition: var(--transition);
}

.switch-group:hover { border-color: var(--border-active); }
.switch-group input[type="checkbox"] { display: none; }

.switch-toggle {
  width: 44px; height: 24px; background: var(--text-muted);
  border-radius: 12px; position: relative; transition: var(--transition); flex-shrink: 0;
}

.switch-toggle::after {
  content: ''; position: absolute; width: 18px; height: 18px;
  background: white; border-radius: 50%; top: 3px; left: 3px;
  transition: var(--transition);
}

.switch-group input:checked + .switch-toggle { background: var(--accent-purple); }
.switch-group input:checked + .switch-toggle::after { transform: translateX(20px); }

.switch-label { font-size: 14px; color: var(--text-secondary); }

/* ==================== 按钮 ==================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 14px 28px; border: none; border-radius: var(--radius-md);
  font-size: 15px; font-weight: 700; font-family: inherit;
  cursor: pointer; transition: var(--transition); position: relative; overflow: hidden;
}

.btn-primary {
  background: var(--gradient-main); color: white;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 28px rgba(139, 92, 246, 0.45); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: rgba(139, 92, 246, 0.12); color: var(--accent-purple);
  border: 1px solid rgba(139, 92, 246, 0.25);
}

.btn-secondary:hover { background: rgba(139, 92, 246, 0.2); border-color: rgba(139, 92, 246, 0.4); }

.btn-danger {
  background: rgba(239, 68, 68, 0.12); color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.25); padding: 6px 14px; font-size: 12px;
}

.btn-danger:hover { background: rgba(239, 68, 68, 0.2); }

.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

.btn .spinner {
  width: 18px; height: 18px; border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white; border-radius: 50%; animation: spin 0.8s linear infinite;
}

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

/* ==================== 结果展示 ==================== */
.result-area { display: none; margin-top: 24px; animation: fadeIn 0.4s ease; }
.result-area.show { display: block; }

.result-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.result-title { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }

.result-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }

.tag {
  font-size: 12px; padding: 4px 12px; border-radius: 20px;
  background: rgba(6, 182, 212, 0.12); color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.2);
}

.lyrics-display {
  background: var(--bg-input); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 20px; white-space: pre-wrap;
  line-height: 1.8; font-size: 14px; color: var(--text-primary);
  max-height: 400px; overflow-y: auto;
}

.lyrics-display::-webkit-scrollbar { width: 6px; }
.lyrics-display::-webkit-scrollbar-track { background: transparent; }
.lyrics-display::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }

/* ==================== 音频播放器 ==================== */
.audio-player {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(6, 182, 212, 0.08));
  border: 1px solid rgba(139, 92, 246, 0.2); border-radius: var(--radius-lg); padding: 24px; margin-top: 20px;
}

.audio-player-title { font-size: 14px; font-weight: 600; color: var(--text-secondary); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }

.audio-player audio { width: 100%; height: 44px; border-radius: 8px; outline: none; }

.audio-info { display: flex; gap: 20px; margin-top: 12px; font-size: 12px; color: var(--text-muted); }
.audio-info span { display: flex; align-items: center; gap: 4px; }

/* ==================== 一键作曲按钮 ==================== */
.transfer-btn-wrap { display: none; margin-top: 16px; }
.transfer-btn-wrap.show { display: block; }

.btn-transfer {
  background: var(--gradient-warm); color: white;
  box-shadow: 0 4px 20px rgba(236, 72, 153, 0.3);
}

.btn-transfer:hover { box-shadow: 0 6px 28px rgba(236, 72, 153, 0.45); transform: translateY(-2px); }

/* ==================== 会员中心 ==================== */
.empty-state { text-align: center; padding: 40px 20px; }
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; margin-bottom: 8px; }
.empty-state p { color: var(--text-secondary); margin-bottom: 20px; }

.profile-info { display: flex; flex-direction: column; gap: 12px; }

.profile-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--bg-input);
  border: 1px solid var(--border-color); border-radius: var(--radius-md);
}

.profile-label { font-size: 14px; color: var(--text-secondary); }
.profile-value { font-size: 14px; font-weight: 600; color: var(--text-primary); }

/* ==================== 记录 Tab ==================== */
.record-tabs {
  display: flex; gap: 4px; margin-bottom: 20px;
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 3px;
}

.record-tab {
  flex: 1; padding: 10px 16px; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-secondary); font-size: 14px;
  font-weight: 600; cursor: pointer; transition: var(--transition);
}

.record-tab:hover { color: var(--text-primary); }
.record-tab.active { background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); }

.record-panel { display: none; }
.record-panel.active { display: block; }

/* ==================== 记录卡片 ==================== */
.record-card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: 20px; margin-bottom: 12px;
  transition: var(--transition);
}

.record-card:hover { border-color: var(--border-active); }

.record-card-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;
}

.record-card-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.record-card-time { font-size: 12px; color: var(--text-muted); }

.record-card-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

.record-card-meta .tag { font-size: 11px; padding: 2px 10px; }

.record-card-content {
  background: var(--bg-input); border-radius: var(--radius-sm);
  padding: 12px 16px; font-size: 13px; color: var(--text-secondary);
  line-height: 1.6; max-height: 100px; overflow: hidden;
  white-space: pre-wrap; position: relative;
}

.record-card-content::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 30px;
  background: linear-gradient(transparent, var(--bg-input));
}

.record-card-actions { display: flex; gap: 8px; margin-top: 12px; justify-content: flex-end; }

.record-card audio { width: 100%; height: 36px; margin-top: 12px; border-radius: 6px; }

/* ==================== 分页 ==================== */
.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 20px; }

.page-btn {
  padding: 8px 14px; border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); background: transparent;
  color: var(--text-secondary); font-size: 13px; cursor: pointer;
  transition: var(--transition);
}

.page-btn:hover { border-color: var(--accent-purple); color: var(--accent-purple); }
.page-btn.active { background: var(--accent-purple); color: white; border-color: var(--accent-purple); }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.page-info { font-size: 13px; color: var(--text-muted); }

/* ==================== 提示/错误 ==================== */
.toast {
  position: fixed; top: 24px; right: 24px; padding: 14px 24px;
  border-radius: var(--radius-md); font-size: 14px; font-weight: 500;
  z-index: 1000; transform: translateX(120%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1); max-width: 400px;
}

.toast.show { transform: translateX(0); }
.toast.success { background: rgba(34, 197, 94, 0.15); border: 1px solid rgba(34, 197, 94, 0.3); color: #22c55e; }
.toast.error { background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.3); color: #ef4444; }

/* ==================== 卡密兑换 ==================== */
.redeem-area {
  display: flex;
  gap: 12px;
  align-items: center;
}
.redeem-area .form-input {
  margin-bottom: 0 !important;
  flex: 1;
}
.redeem-area .btn {
  width: auto;
  white-space: nowrap;
}

/* ==================== 响应式 ==================== */
@media (max-width: 640px) {
  .app-container { padding: 24px 16px; }
  .header h1 { font-size: 24px; }
  .header-top { flex-direction: column; gap: 12px; }
  .user-area { position: static; transform: none; }
  .card { padding: 20px; }
  .form-row { grid-template-columns: 1fr; }
  .tab-btn { padding: 12px 12px; font-size: 13px; }
  .tab-btn .icon { display: none; }
}
