:root {
  color-scheme: light;
  font-family: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  --accent: #FFC600;
  --accent-soft: #FFF4B3;
  --border: #E8D98C;
  --text: #111111;
  --muted: #6b7280;
  --background: #FFFBE6;        /* warm base */
  --surface: #ffffff;
  --brace: #1A8F1A;
  --comment-value: #B742F6;
  --bracket: #2C6AFF;
  --chord: #FF7A00;
  --max-width: 1200px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background-color: var(--background);   /* warm backdrop */
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

/* --- top logo strip blends with hero --- */
.site-logo {
  display: flex;
  justify-content: center;
  padding: 28px 24px 0;
  background: var(--background);
}

.site-logo img {
  width: 200px;
  height: auto;
  max-width: 100%;
}

/* --- hero --- */
header.hero {
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 24px 72px;
  background: var(--background);
}

.hero-content {
  max-width: 720px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.hero-title {
  font-size: clamp(2.85rem, 6vw, 4.35rem);
  font-weight: 800;
  margin: 0;
  line-height: 1.05;
}

.hero-subtitle {
  font-size: clamp(1.18rem, 2.4vw, 1.55rem);
  color: var(--muted);
  margin: 0;
  line-height: 1.55;
}

.hero-cta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--accent);
  color: var(--text);
  padding: 18px 32px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 1.05rem;
  transition: transform 0.18s ease, box-shadow 0.22s ease;
}

.hero-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(17, 17, 17, 0.12);
}

/* --- core sections sit on white cards --- */
main {
  background: var(--surface);
  border-radius: 40px 40px 0 0;
  margin-top: -24px;                 /* overlap hero curve */
  padding-top: 48px;
  display: flex;
  flex-direction: column;
  gap: 80px;
}

section {
  padding: 0 24px;
}

.converter-section {
  padding-bottom: 80px;
}

.converter-wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.converter-grid {
  display: grid;
  gap: 24px;
  min-height: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  background: var(--surface);
  border-radius: 24px;
  padding: clamp(24px, 3vw, 32px);
  border: 1.5px solid var(--border);
  box-shadow: 0 16px 32px rgba(17, 17, 17, 0.08);
}

@media (max-width: 960px) {
  .converter-grid {
    grid-template-columns: 1fr;
  }
}

.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

label {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 10px;
}

textarea {
  width: 100%;
  flex: 1;
  min-height: 0;
  resize: none;
  overflow-y: auto;
  font-family: "Fira Code", "Fira Mono", "Source Code Pro", monospace;
  font-size: 0.95rem;
  line-height: 1.45;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  background-color: var(--surface);
  color: inherit;
  transition: border 0.18s ease, box-shadow 0.18s ease;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 198, 0, 0.22);
}

textarea::placeholder {
  color: var(--muted);
}

.output-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#outputDisplay {
  flex: 1;
  overflow-y: auto;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  background-color: var(--surface);
  font-family: "Fira Code", "Fira Mono", "Source Code Pro", monospace;
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre;
  word-break: break-word;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) rgba(17, 17, 17, 0.08);
}

#outputDisplay::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

#outputDisplay::-webkit-scrollbar-track {
  background: rgba(17, 17, 17, 0.05);
  border-radius: 999px;
}

#outputDisplay::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 999px;
}

.brace {
  color: var(--brace);
}

.comment-label {
  color: var(--brace);
  font-weight: 600;
}

.comment-value {
  color: var(--comment-value);
  font-weight: 600;
}

.bracket {
  color: var(--bracket);
  font-weight: 600;
}

.chord {
  color: var(--chord);
  font-weight: 600;
}

.buttons {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

button {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  font-size: 0.95rem;
  font-weight: 600;
  background-color: var(--accent);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

button:hover:not(:disabled) {
  box-shadow: 0 10px 20px rgba(17, 17, 17, 0.12);
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 6px 14px rgba(17, 17, 17, 0.15);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  box-shadow: none;
  transform: none;
}

button.secondary {
  background-color: var(--surface);
  border: 1.5px solid var(--border);
}

button.secondary.active {
  background-color: var(--accent);
  color: var(--text);
  border-color: var(--accent);
}

.transpose-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background-color: var(--accent-soft);
  font-size: 0.95rem;
}

.transpose-label {
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.transpose-value {
  min-width: 38px;
  text-align: center;
  font-weight: 600;
  color: var(--text);
}

button.transpose-step {
  background-color: #FFE37A;
  color: var(--text);
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  font-weight: 600;
  border: none;
}

button.transpose-step:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.status {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
  min-height: 1em;
}

.converter-instructions {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.6;
  text-align: center;
}

.features-section {
  padding-bottom: 80px;
}

.section-header {
  max-width: var(--max-width);
  margin: 0 auto 28px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

@media (max-width: 720px) {
  .section-header {
    align-items: center;
    text-align: center;
  }
}

.section-title {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 700;
}

.section-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.6;
  max-width: 640px;
}

.features-grid {
  max-width: var(--max-width);
  margin: 0 auto;
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.feature-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 24px;
  border: 1.5px solid var(--border);
  box-shadow: 0 16px 28px rgba(17, 17, 17, 0.08);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feature-icon {
  width: 55px;
  height: 55px;
  border-radius: 16px;
  background: var(--accent-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.feature-icon img {
  width: 100%;
  height: 100%;
}

/* -------------- feature request -------------- */
.feature-request-section {
  padding-bottom: 80px;
}

.feature-request-card {
  max-width: var(--max-width);
  margin: 0 auto;
  background: var(--surface);
  border-radius: 24px;
  padding: 44px clamp(24px, 4vw, 64px);
  border: 1.5px solid var(--border);
  box-shadow: 0 16px 32px rgba(17, 17, 17, 0.08);
}

#featureRequestForm {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label {
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--text);
}

input[type="text"],
input[type="email"],
select,
textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  font: inherit;
  color: inherit;
  background: var(--surface);
  transition: border 0.18s ease, box-shadow 0.18s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 198, 0, 0.22);
}

select {
  cursor: pointer;
}

textarea {
  resize: vertical;
}

.primary-button {
  align-self: flex-start;
  padding: 14px 26px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s ease;
}

@media (max-width: 720px) {
  .feature-request-card {
    align-items: stretch;
    text-align: left;
  }

  .primary-button {
    align-self: stretch;
    text-align: center;
    justify-content: center;
  }
}

@media (max-width: 720px) {
  .donation-card {
    align-items: center;
    text-align: center;
  }
}

footer {
  padding: 28px 24px 64px;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
  background: var(--surface);
  border-radius: 0 0 40px 40px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  border: 0;
  padding: 0;
  white-space: nowrap;
  clip-path: inset(50%);
  clip: rect(0 0 0 0);
  overflow: hidden;
}

.chord {
  cursor: pointer;
}

.audio-loading-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  transition: all 0.3s ease;
  opacity: 1;
  max-height: 60px;
  overflow: hidden;
}

.audio-loading-indicator.hidden {
  opacity: 0;
  max-height: 0;
  padding: 0;
  margin: 0;
}

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

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

.loading-text {
  font-size: 14px;
  font-weight: 500;
}

/* --- Fix mobile converter layout --- */
@media (max-width: 960px) {
  /* Adjust main padding on mobile */
  main {
    padding-top: 24px;
    gap: 40px;
  }

  .converter-section {
    padding-bottom: 40px;
  }

  .converter-grid {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 20px;
  }

  /* Give each pane a reasonable minimum height on mobile */
  .pane {
    min-height: 400px;
  }

  /* Ensure textarea and output display have proper height */
  textarea,
  #outputDisplay {
    min-height: 350px;
    font-size: 0.9rem;
  }
}

/* --- Better mobile header --- */
@media (max-width: 640px) {
  .site-logo img {
    width: 160px;
  }

  header.hero {
    min-height: auto;
    padding: 32px 20px 48px;
  }

  .hero-title {
    font-size: 2rem;
    line-height: 1.1;
  }

  .hero-subtitle {
    font-size: 1.1rem;
  }

  .hero-cta {
    padding: 14px 24px;
    font-size: 1rem;
  }
}

/* --- Fix button layout on mobile --- */
@media (max-width: 480px) {
  .buttons {
    flex-direction: column;
    align-items: stretch;
  }

  .buttons button {
    width: 100%;
    justify-content: center;
  }

  .transpose-controls {
    width: 100%;
    justify-content: center;
  }

  /* Stack controls vertically on very small screens */
  .converter-wrapper {
    gap: 16px;
  }

  /* Reduce padding further on small screens */
  .converter-grid {
    padding: 16px;
  }

  section {
    padding: 0 16px;
  }
}

/* --- Fix loading indicator on mobile --- */
@media (max-width: 640px) {
  .audio-loading-indicator {
    padding: 12px;
    font-size: 0.9rem;
  }

  .loading-spinner {
    width: 16px;
    height: 16px;
  }

  .loading-text {
    font-size: 13px;
  }
}

/* --- Ensure output display is scrollable --- */
#outputDisplay {
  overflow-y: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

/* --- Fix feature cards on mobile --- */
@media (max-width: 640px) {
  .features-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .feature-card {
    padding: 20px;
  }

  .section-title {
    font-size: 1.75rem;
  }
}

/* --- Improve button touch targets on mobile --- */
@media (hover: none) and (pointer: coarse) {
  button {
    min-height: 44px; /* iOS recommended touch target */
    min-width: 44px;
  }

  .transpose-step {
    width: 44px;
    height: 44px;
  }

  /* Make chord elements easier to tap */
  .chord {
    padding: 2px 4px;
    margin: -2px -4px;
    display: inline-block;
  }
}

/* --- Fix viewport height issues on mobile --- */
@media (max-width: 960px) {
  /* Use viewport height carefully to avoid issues with mobile browser chrome */
  header.hero {
    min-height: 50vh;
  }

  /* Ensure converter section is visible */
  .converter-section {
    min-height: auto;
  }
}

/* --- Prevent horizontal scroll --- */
html {
  overflow-x: hidden;
}

body {
  overflow-x: hidden;
  position: relative;
}

/* --- Fix text wrapping in output --- */
#outputDisplay {
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}

/* --- Ensure proper spacing between sections on mobile --- */
@media (max-width: 640px) {
  main {
    border-radius: 24px 24px 0 0;
  }

  .features-section,
  .feature-request-section {
    padding-bottom: 40px;
  }
}

/* --- Feature Request Section --- */
.feature-request-section {
  padding-bottom: 80px;
}

.feature-request-card {
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
  background: var(--surface);
  border-radius: 24px;
  padding: 48px clamp(24px, 4vw, 64px);
  border: 1.5px solid var(--border);
  box-shadow: 0 16px 32px rgba(17, 17, 17, 0.08);
}

.mailto-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--accent);
  color: var(--text);
  padding: 16px 32px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 1.05rem;
  text-decoration: none;
  margin: 28px 0 20px;
  transition: transform 0.18s ease, box-shadow 0.22s ease;
}

.mailto-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(17, 17, 17, 0.12);
}

.mailto-button:active {
  transform: translateY(0);
}

.feature-request-subtext {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
}

@media (max-width: 640px) {
  .feature-request-card {
    padding: 32px 20px;
  }
  
  .mailto-button {
    font-size: 1rem;
    padding: 14px 24px;
  }
}