/* 全局样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: #0f0f1a;
  color: #e0e0e0;
  min-height: 100vh;
}

/* 头部 */
.header {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  padding: 24px 0;
  text-align: center;
  border-bottom: 1px solid #2a2a4a;
}

.header h1 {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.header p {
  color: #888;
  font-size: 14px;
}

/* 主容器 */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 16px;
}

/* 区块卡片 */
.section {
  background: #1a1a2e;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid #2a2a4a;
}

.section-title {
  font-size: 14px;
  color: #888;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* 和弦输入 */
.chord-input-wrapper {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: flex-start;
}

.chord-input-container {
  flex: 1;
  position: relative;
}

#chord-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 16px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #0f0f1a;
  color: #e0e0e0;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

#chord-input:focus {
  border-color: #667eea;
}

#chord-input.error {
  border-color: #e74c3c;
  animation: shake 0.3s;
}

/* 自动补全下拉 */
.chord-suggestions {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  background: #1a1a2e;
  border: 1px solid #444;
  border-top: none;
  border-radius: 0 0 8px 8px;
  z-index: 100;
}

.chord-suggestions.active {
  display: block;
}

.chord-suggestion-item {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
  color: #ccc;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chord-suggestion-item:hover,
.chord-suggestion-item.selected {
  background: #2a2a4a;
  color: #fff;
}

.chord-suggestion-item .chord-sug-name {
  font-weight: 600;
}

.chord-suggestion-item .chord-sug-desc {
  font-size: 12px;
  color: #888;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* 根音按钮 */
#root-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.root-btn {
  width: 48px;
  height: 40px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #0f0f1a;
  color: #ccc;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.root-btn:hover {
  border-color: #667eea;
  color: #fff;
}

.root-btn.active {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border-color: transparent;
}

/* 和弦类型选择器 */
#chord-type {
  width: 200px;
  flex-shrink: 0;
  padding: 10px 14px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #0f0f1a;
  color: #e0e0e0;
  font-size: 15px;
  cursor: pointer;
  outline: none;
}

#chord-type:focus {
  border-color: #667eea;
}

#chord-type option {
  background: #1a1a2e;
  color: #e0e0e0;
}

/* 和弦信息展示 */
.chord-display {
  text-align: center;
  padding: 16px 0;
}

#chord-name {
  font-size: 48px;
  font-weight: 800;
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#chord-chinese-name {
  font-size: 16px;
  color: #888;
  margin-top: 4px;
}

/* 组成音 */
#chord-notes {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 16px 0;
}

.note-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 14px;
  border-radius: 10px;
  background: #2a2a4a;
  min-width: 60px;
}

.note-badge strong {
  font-size: 20px;
  color: #e0e0e0;
}

.note-badge small {
  font-size: 10px;
  color: #888;
  margin-top: 2px;
}

.note-badge.root {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.note-badge.root strong {
  color: white;
}

.note-badge.root small {
  color: rgba(255, 255, 255, 0.7);
}

/* 播放按钮 */
.play-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 16px 0;
}

.play-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

#play-chord {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
}

#play-chord:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

#play-arpeggio {
  background: #2a2a4a;
  color: #ccc;
  border: 1px solid #3a3a5a;
}

#play-arpeggio:hover {
  background: #3a3a5a;
  color: white;
}

/* 图表区域 */
.diagrams {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.diagram-card {
  background: #0f0f1a;
  border-radius: 10px;
  padding: 16px;
  border: 1px solid #2a2a4a;
  text-align: center;
}

.diagram-card h3 {
  font-size: 14px;
  color: #888;
  margin-bottom: 10px;
}

.diagram-card svg {
  max-width: 100%;
  height: auto;
}

/* 五度圈布局 */
.cof-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.cof-container {
  flex-shrink: 0;
}

.cof-container svg {
  display: block;
}

.cof-side {
  flex: 1;
  min-width: 0;
}

.cof-side-title {
  font-size: 13px;
  color: #888;
  margin-bottom: 12px;
  font-weight: 500;
}

.cof-sector:hover {
  opacity: 0.8;
}

/* 调号选择栏 */
.key-selector-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.key-selector-bar .section-title {
  margin-bottom: 0;
}

.key-selector-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.key-label {
  font-size: 13px;
  color: #888;
  font-weight: 500;
}

#key-select {
  padding: 6px 14px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #0f0f1a;
  color: #e0e0e0;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

#key-select:focus {
  border-color: #667eea;
}

#key-select option {
  background: #1a1a2e;
  color: #e0e0e0;
}

/* 分隔线 */
.progression-divider {
  height: 1px;
  background: #2a2a4a;
  margin: 20px 0;
}

/* 下一个和弦推荐 */
.next-chords-section {
  margin-bottom: 16px;
}

#next-chords {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.suggestion-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 16px;
  border: 1px solid #3a3a5a;
  border-radius: 8px;
  background: #1e1e36;
  color: #ccc;
  cursor: pointer;
  transition: all 0.15s;
}

.suggestion-btn:hover {
  border-color: #667eea;
  color: white;
  background: #2a2a4a;
}

.suggestion-btn strong {
  font-size: 16px;
}

.suggestion-btn small {
  font-size: 11px;
  color: #888;
}

.hint {
  color: #666;
  font-size: 13px;
}

/* 和弦进行卡片 */
#progressions-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.progression-card {
  background: #0f0f1a;
  border: 1px solid #2a2a4a;
  border-radius: 10px;
  padding: 16px;
  transition: border-color 0.2s;
}

.progression-card:hover {
  border-color: #3a3a5a;
}

.progression-header {
  margin-bottom: 10px;
}

.progression-header strong {
  font-size: 16px;
  color: #e0e0e0;
}

.progression-en {
  color: #666;
  font-size: 12px;
  margin-left: 8px;
}

.progression-chords {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.prog-chord-btn {
  padding: 6px 12px;
  border: 1px solid #3a3a5a;
  border-radius: 6px;
  background: #1e1e36;
  color: #ddd;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.prog-chord-btn:hover {
  border-color: #667eea;
  color: white;
}

.prog-chord-btn small {
  font-size: 10px;
  color: #888;
}

.arrow {
  color: #555;
  font-size: 12px;
}

.progression-desc {
  font-size: 13px;
  color: #888;
  margin-bottom: 8px;
}

.progression-tags {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.tag {
  padding: 2px 8px;
  border-radius: 4px;
  background: #2a2a4a;
  color: #999;
  font-size: 11px;
}

.play-progression-btn {
  padding: 6px 14px;
  border: 1px solid #3a3a5a;
  border-radius: 6px;
  background: transparent;
  color: #888;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.play-progression-btn:hover {
  border-color: #667eea;
  color: #667eea;
}

.play-progression-btn.playing {
  color: #667eea;
  border-color: #667eea;
  animation: pulse 0.8s infinite;
}

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

/* 响应式 */
@media (max-width: 640px) {
  .diagrams {
    grid-template-columns: 1fr;
  }

  #chord-name {
    font-size: 36px;
  }

  .root-btn {
    width: 42px;
    height: 36px;
    font-size: 13px;
  }

  .progression-chords {
    gap: 4px;
  }

  .container {
    padding: 12px 10px;
  }

  .cof-layout {
    flex-direction: column;
    align-items: center;
  }

  .cof-container svg {
    max-width: 320px;
    height: auto;
  }

  .chord-input-wrapper {
    flex-direction: column;
  }

  #chord-type {
    width: 100%;
  }
}
