/* ===== BPM Counter — Global Styles ===== */
/* Language Switcher */
.lang-switcher {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  gap: 0.4rem;
}
.lang-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.2s;
}
.lang-btn:hover {
  background: var(--accent-1);
  transform: scale(1.1);
}

/* Cross-links footer */
.cross-links {
  text-align: center;
  padding: 1rem 0;
  margin-bottom: 1rem;
  border-bottom: 1px solid #2a2a3a;
  font-size: 0.85rem;
  line-height: 1.8;
}
.cross-links a {
  color: var(--accent-2);
  text-decoration: none;
  margin: 0 0.2rem;
}
.cross-links a:hover {
  text-decoration: underline;
}
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #181825;
  --accent-1: #ec4899;
  --accent-2: #8b5cf6;
  --accent-gradient: linear-gradient(135deg, #ec4899, #8b5cf6);
  --text-primary: #ffffff;
  --text-secondary: #a0a0b8;
  --text-muted: #6b6b80;
  --border: #2a2a3a;
  --success: #22c55e;
  --warning: #eab308;
  --danger: #ef4444;
  --radius: 12px;
  --radius-lg: 24px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent-1);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--accent-2);
}

/* ===== Header / Navigation ===== */
header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

nav {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  font-size: 1.35rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
  align-items: center;
}

.nav-links a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  transition: all 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

/* ===== Main Content ===== */
main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ===== Footer ===== */
footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem 1rem;
  text-align: center;
  margin-top: auto;
}

footer .footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

footer .footer-links a {
  color: var(--text-muted);
  font-size: 0.85rem;
}

footer .footer-links a:hover {
  color: var(--accent-1);
}

footer .footer-copy {
  color: var(--text-muted);
  font-size: 0.8rem;
}

footer .ad-placeholder {
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  margin: 1.5rem auto;
  max-width: 728px;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

/* ===== BPM Counter Page ===== */
.bpm-container {
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
}

.bpm-container h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.bpm-subtitle {
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

/* BPM Display */
.bpm-display {
  font-size: 5rem;
  font-weight: 800;
  font-family: var(--font-mono);
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
  transition: transform 0.1s;
  min-height: 6rem;
}

.bpm-display.pulse {
  transform: scale(1.05);
}

.bpm-label {
  font-size: 1.1rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 3px;
  margin-bottom: 0.25rem;
}

/* Metronome LED */
.metronome-led {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-card);
  margin: 1.5rem auto;
  border: 2px solid var(--border);
  transition: all 0.05s;
  position: relative;
}

.metronome-led.flash {
  background: var(--accent-1);
  box-shadow: 0 0 30px var(--accent-1), 0 0 60px rgba(236, 72, 153, 0.4);
  border-color: var(--accent-1);
}

/* Tap Button */
.tap-btn {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: 3px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
  margin: 1.5rem auto;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.tap-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--accent-gradient);
  opacity: 0;
  transition: opacity 0.15s;
}

.tap-btn:hover {
  border-color: var(--accent-1);
  transform: scale(1.03);
  box-shadow: 0 0 40px rgba(236, 72, 153, 0.2);
}

.tap-btn:active,
.tap-btn.tapped {
  transform: scale(0.95);
}

.tap-btn:active::before,
.tap-btn.tapped::before {
  opacity: 0.15;
}

.tap-btn .tap-text {
  position: relative;
  z-index: 1;
}

.tap-btn .key-hint {
  position: absolute;
  bottom: 28px;
  z-index: 1;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* BPM Stats */
.bpm-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 1.5rem 0;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.stat-card .stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 0.25rem;
}

/* Genre suggestion */
.genre-suggestion {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 1.5rem 0;
  min-height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.genre-suggestion .genre-label {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.genre-suggestion .genre-name {
  font-size: 1.3rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.genre-suggestion .genre-range {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Tap History */
.tap-history {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 1.5rem 0;
}

.tap-history h3 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.75rem;
  text-align: left;
}

.history-list {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.history-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  text-align: center;
  min-width: 60px;
  animation: fadeIn 0.3s ease;
}

.history-item .h-tap {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.history-item .h-ms {
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.history-item .h-bpm {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--accent-1);
}

.tap-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0.75rem 0 0;
  text-align: left;
}

/* Interval Bar Chart */
.interval-chart {
  display: flex;
  gap: 3px;
  align-items: flex-end;
  height: 60px;
  margin: 1rem 0 0;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.bar {
  flex: 1;
  background: var(--accent-gradient);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: height 0.3s ease;
  position: relative;
  opacity: 0.8;
}

.bar:hover {
  opacity: 1;
}

/* Reset Button */
.reset-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.6rem 2rem;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 0.5rem;
}

.reset-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(239, 68, 68, 0.08);
}

/* ===== Tools Pages ===== */
.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 600px;
  margin: 0 auto;
}

.tool-card h1 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
  text-align: center;
}

.tool-card .tool-desc {
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.form-group select,
.form-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: var(--font-mono);
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a0a0b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 2.5rem;
}

.form-group select:focus,
.form-group input:focus {
  outline: none;
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.15);
}

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

.result-display {
  text-align: center;
  padding: 1.5rem;
  margin-top: 1.5rem;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.result-display .result-value {
  font-size: 3rem;
  font-weight: 800;
  font-family: var(--font-mono);
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.result-display .result-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: 0.25rem;
}

.result-display .result-formula {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  font-family: var(--font-mono);
}

/* ===== Legal Pages ===== */
.legal-content {
  max-width: 700px;
  margin: 0 auto;
}

.legal-content h1 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.legal-content .last-updated {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 2rem;
}

.legal-content h2 {
  font-size: 1.2rem;
  color: var(--text-primary);
  margin: 1.5rem 0 0.75rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

.legal-content p,
.legal-content li {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.7;
}

.legal-content ul {
  padding-left: 1.5rem;
  margin: 0.5rem 0;
}

.legal-content li {
  margin-bottom: 0.3rem;
}

.placeholder {
  color: var(--danger) !important;
  font-weight: 600;
  font-family: var(--font-mono);
  background: rgba(239, 68, 68, 0.1);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  display: inline-block;
}

.contact-form label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.contact-form input,
.contact-form textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.95rem;
  margin-bottom: 1rem;
  transition: border-color 0.2s;
}

.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.15);
}

.contact-form textarea {
  min-height: 120px;
  resize: vertical;
}

.submit-btn {
  background: var(--accent-gradient);
  color: white;
  border: none;
  padding: 0.75rem 2rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.submit-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(236, 72, 153, 0.3);
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 10px rgba(236, 72, 153, 0.3); }
  50% { box-shadow: 0 0 30px rgba(236, 72, 153, 0.6); }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  header {
    padding: 0 1rem;
  }

  main {
    padding: 1.25rem 1rem;
  }

  .bpm-display {
    font-size: 3.5rem;
  }

  .tap-btn {
    width: 160px;
    height: 160px;
    font-size: 1.6rem;
  }

  .tap-btn .key-hint {
    bottom: 22px;
    font-size: 0.65rem;
  }

  .bpm-stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
  }

  .stat-card {
    padding: 0.75rem;
  }

  .stat-card .stat-value {
    font-size: 1.1rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .nav-links {
    gap: 0.8rem;
  }

  .nav-links a {
    font-size: 0.8rem;
    padding: 0.3rem 0.4rem;
  }

  .history-item {
    min-width: 48px;
    padding: 0.35rem 0.5rem;
  }

  .history-item .h-bpm,
  .history-item .h-ms {
    font-size: 0.7rem;
  }

  .result-display .result-value {
    font-size: 2.2rem;
  }
}

@media (max-width: 480px) {
  .bpm-display {
    font-size: 2.8rem;
  }

  .tap-btn {
    width: 140px;
    height: 140px;
    font-size: 1.4rem;
  }

  .bpm-stats {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .nav-links a {
    font-size: 0.72rem;
  }
}