:root {
  --bg: #0f0f1a;
  --bg-card: #1a1a2e;
  --bg-input: #16213e;
  --primary: #e94560;
  --primary-hover: #ff6b81;
  --accent: #0f3460;
  --text: #eaeaea;
  --text-muted: #8899aa;
  --border: #2a2a4a;
  --success: #2ecc71;
  --warning: #f39c12;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

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

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

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* ====== Layout ====== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

header h1 {
  font-size: 1.25rem;
  color: var(--primary);
}

header nav a {
  margin-left: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
header nav a:hover { color: var(--text); }

header .user-info {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.btn {
  display: inline-block;
  padding: 0.6rem 1.4rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }

.btn-secondary { background: var(--accent); color: var(--text); }
.btn-secondary:hover { background: #1a4a7a; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.9; }

.btn-danger { background: #c0392b; color: #fff; }
.btn-danger:hover { opacity: 0.9; }

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-block { display: block; width: 100%; }

/* ====== Cards ====== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

/* ====== Form ====== */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
textarea,
select {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.2s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
}

/* ====== Login ====== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}
.login-card {
  width: 100%;
  max-width: 400px;
}
.login-card h2 {
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--primary);
}

/* ====== Category badges ====== */
.cat-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ====== Stats ====== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  text-align: center;
  padding: 1rem;
}
.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}
.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ====== Song card ====== */
.song-card {
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}
.song-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}
.song-card h3 { font-size: 1.05rem; margin-bottom: 0.25rem; }
.song-card .artist { font-size: 0.85rem; color: var(--text-muted); }
.song-card .meta {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.song-card .cat-badge { margin-top: 0.5rem; }

/* ====== Song Detail ====== */
.song-header {
  margin-bottom: 1.5rem;
}
.song-header h2 { font-size: 1.5rem; }
.song-header .artist { color: var(--text-muted); font-size: 1rem; }

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.5rem 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
}
.gallery-item {
  background: var(--bg-input);
  border-radius: 8px;
  overflow: hidden;
  padding: 0.5rem;
}
.gallery-item img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 6px;
}
.gallery-item .item-title {
  font-size: 0.8rem;
  padding: 0.3rem 0 0;
  text-align: center;
}

/* ====== Ratings ====== */
.rating-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.rating-bar .label {
  width: 140px;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.rating-bar .track {
  flex: 1;
  height: 8px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
}
.rating-bar .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--warning));
  border-radius: 4px;
  transition: width 0.5s ease;
}
.rating-bar .score {
  width: 40px;
  text-align: right;
  font-weight: 600;
  font-size: 0.85rem;
}

/* ====== Recording ====== */
.recorder-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 1rem 0;
}
.recorder-controls .status {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.recorder-controls .status.recording {
  color: var(--primary);
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.recording-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: var(--bg-input);
  border-radius: 8px;
  margin-bottom: 0.5rem;
}
.recording-list-item .info { flex: 1; }
.recording-list-item .date { font-size: 0.8rem; color: var(--text-muted); }
.recording-list-item audio { height: 40px; }

/* ====== Rating form slider ====== */
.rating-slider-group { margin-bottom: 0.75rem; }
.rating-slider-group label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.rating-slider-group input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

/* ====== Chart ====== */
.chart-container {
  background: var(--bg-input);
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
  height: 250px;
  position: relative;
}

/* ====== Timeline ====== */
.timeline {
  position: relative;
  padding-left: 2rem;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--bg-input);
  border-radius: 8px;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.65rem;
  top: 1rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--bg);
}

/* ====== Tabs ====== */
.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.tab-btn {
  padding: 0.5rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
}
.tab-btn.active {
  background: var(--bg-card);
  color: var(--text);
  border-bottom-color: var(--bg-card);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ====== Modal ====== */
.modal-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: 1000;
  padding: 1rem;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h3 { margin-bottom: 1rem; }

/* ====== Upload area ====== */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
}
.upload-area:hover { border-color: var(--primary); }
.upload-area p { color: var(--text-muted); font-size: 0.85rem; }

/* ====== Responsive ====== */
@media (max-width: 640px) {
  header { flex-direction: column; align-items: stretch; text-align: center; }
  header nav { display: flex; justify-content: center; flex-wrap: wrap; }
  header nav a { margin: 0.25rem 0.5rem; }
  .card-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .rating-bar .label { width: 100px; }
}