/* AutoChords: light dashboard layout (white sidebar, results in white cards on a light gray canvas),
   one font (Inter), AutoChords blue for actions. ChordChord promos use ChordChord's own logo
   gradient (#3d4ff7 -> #c145ed) so the two brands never blur together. */
:root {
  --bg: #f6f6f8;
  --surface: #ffffff;
  --cell: #f7f8fa;
  --cell-hover: #eef0f4;
  --line: #e4e6eb;
  --line-strong: #d5d8de;
  --text: #1a1f36;
  --muted: #697386;
  --faint: #a3acb9;
  /* AutoChords blue, sampled from the AutoChords icon */
  --accent: #3c85f2;
  --accent-hover: #2a6fd6;
  --cc-a: #3d4ff7;
  --cc-b: #c145ed;
  --cc-grad: linear-gradient(100deg, var(--cc-a), var(--cc-b));
  --cc-bg: #14142a;
  --cc-text: #f4f4f8;
  --cc-soft: #b9bad0;
  --radius: 8px;
  --card: 0 2px 5px rgba(60, 66, 87, 0.08), 0 1px 1px rgba(0, 0, 0, 0.05);
  --font: Inter, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --loop: 4s;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}

/* Type scale: 12 / 13 / 14 / 16 / 18px. Weights: 400 / 500 / 600. */
h1,
h2,
h3,
strong,
b {
  font-weight: 600;
}

body.has-sticky {
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

button,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- Top bar */
.topbar {
  height: 56px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
}

.brand a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}

.brand img {
  border-radius: 7px;
}

/* ---------------------------------------------------------------- Layout */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: 'controls' 'results' 'promo';
  gap: 8px;
  padding: 0 16px;
  max-width: 1600px;
  margin: 0 auto;
}

.controls {
  grid-area: controls;
  padding: 20px 0 8px;
}

.results {
  grid-area: results;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

/* Each results section is its own white card */
.results-col {
  min-width: 0;
  padding: 20px 20px 8px;
  background: var(--surface);
  border-radius: 10px;
  box-shadow: var(--card);
}

.promo {
  grid-area: promo;
  padding: 8px 0 24px;
}

/* Desktop: full-height white sidebar (controls + ChordChord card), results cards on the canvas */
@media (min-width: 900px) {
  .layout {
    grid-template-columns: 350px minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas: 'controls results' 'promo results';
    gap: 0;
    max-width: none;
    min-height: calc(100vh - 56px);
    padding: 0;
  }
  .controls,
  .promo {
    padding-left: 24px;
    padding-right: 24px;
    background: var(--surface);
    border-right: 1px solid var(--line);
  }
  .controls {
    padding-top: 24px;
  }
  .promo {
    padding-top: 20px;
  }
  .results {
    align-self: start;
    padding: 24px;
  }
}

@media (min-width: 1280px) {
  .results {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  }
}

/* ---------------------------------------------------------------- Type */
.section-title {
  margin: 0 0 4px;
  font-size: 18px;
  line-height: 1.3;
  font-weight: 600;
}

/* Section header: title + "?" button. Help text stays in the page (as on the original site)
   but is hidden until the title is hovered or the "?" is tapped. */
.section-head {
  position: relative;
  margin-bottom: 14px;
}

.section-head-spaced {
  margin-top: 28px;
}

.section-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title-row .section-title {
  margin: 0;
}

.help-toggle {
  flex: none;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--faint);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  transition:
    color 0.15s,
    border-color 0.15s;
}

.help-toggle:hover,
.section-head.is-open .help-toggle {
  color: var(--accent);
  border-color: var(--accent);
}

.section-help {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 40;
  width: min(420px, calc(100vw - 32px));
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 12px 32px -12px rgba(24, 24, 27, 0.25);
  color: var(--muted);
  font-size: 13px;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition:
    opacity 0.15s,
    transform 0.15s;
}

@media (hover: hover) {
  .section-title-row:hover + .section-help {
    opacity: 1;
    transform: none;
    transition-delay: 0.15s;
  }
}

.section-head.is-open .section-help {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.section-help h3 {
  margin: 0 0 4px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.section-help p {
  margin: 0 0 6px;
}

.section-help p:last-child {
  margin-bottom: 0;
}

/* ---------------------------------------------------------------- Form */
.field-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.field-row-3 > .field {
  flex: 1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.field-grow {
  flex: 1;
}

.field > span {
  font-size: 13px;
  font-weight: 500;
  line-height: 18px;
  color: var(--muted);
}

.field select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 40px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235d6f92'/%3E%3C/svg%3E")
    no-repeat right 10px center;
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.field select:hover {
  border-color: #9fb6df;
}

.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(60, 133, 242, 0.18);
}

/* ---------------------------------------------------------------- Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  transition:
    background 0.15s,
    transform 0.1s,
    filter 0.15s;
}

.btn:active {
  transform: translateY(1px);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  height: 36px;
  padding: 0 14px;
}

.btn-primary {
  margin-top: 8px;
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-cc {
  background: var(--cc-grad);
  background-size: 160% 100%;
  color: #fff;
}

.btn-cc::after {
  /* Arrow drawn as an icon (the → character isn't in the Inter web font) */
  content: '';
  width: 14px;
  height: 14px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2 8h11M9 4l4 4-4 4' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2 8h11M9 4l4 4-4 4' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.btn-cc:hover {
  background-position: 100% 0;
  filter: brightness(1.08);
}

/* ---------------------------------------------------------------- Panels */
.panel {
  margin: 0 0 14px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  min-height: 36px;
}

.panel-title {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.panel-title strong {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-title span {
  font-size: 13px;
  color: var(--muted);
}

.btn-play {
  width: 44px;
  height: 36px;
  padding: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  flex: none;
}

/* Play/stop icon is block-level so no text baseline space pushes it up */
.btn-play .icon-play {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
}

.btn-play svg {
  display: block;
}

.btn-play:hover {
  background: var(--accent-hover);
}

.btn-play .i-stop,
.panel.is-playing .btn-play .i-play {
  display: none;
}

.panel.is-playing .btn-play .i-stop {
  display: inline;
}

/* Chord grid */
.chord-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

/* "All chords in key" (7 chords): 4 per row on phones and where its column is narrow (laptops) */
@media (max-width: 560px), (min-width: 1280px) and (max-width: 1799px) {
  #all-chords .chord-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  #all-chords .chord-cell:last-child {
    grid-column: span 2;
  }
}

.chord-cell {
  display: flex;
  min-width: 0;
}

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

.chord {
  flex: 1;
  min-width: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 54px;
  padding: 8px 4px;
  border: 0;
  background: var(--cell);
  transition: background 0.12s;
}

.chord:hover {
  background: var(--cell-hover);
}

.chord.is-playing {
  background: var(--accent);
  color: #fff;
}

.chord-name {
  font-size: 16px;
  font-weight: 600;
}

.chord-numeral {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 11px;
  color: var(--faint);
}

.chord.is-playing .chord-numeral {
  color: rgba(255, 255, 255, 0.85);
}

/* ---------------------------------------------------------------- Chord notes tooltip */
.chord-tip {
  position: absolute;
  z-index: 70;
  min-width: 120px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 10px 28px -12px rgba(26, 31, 54, 0.3);
  color: var(--text);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -4px);
  transition:
    opacity 0.12s,
    transform 0.12s;
}

.chord-tip.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.chord-tip::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  border-left: 1px solid var(--line);
  border-top: 1px solid var(--line);
  background: var(--surface);
  transform: rotate(45deg);
}

.chord-tip-title {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.chord-tip-notes {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.chord-tip-notes span {
  min-width: 32px;
  padding: 5px 6px;
  border-radius: 6px;
  background: var(--cell);
  font-size: 14px;
  font-weight: 600;
}

/* ---------------------------------------------------------------- ChordChord logo: the gradient "cc" mark from chordchord.com */
.cc-logo {
  display: block;
  flex: none;
}

.cc-logo-sm {
  width: 22px;
  height: 22px;
}

.cc-logo-lg {
  width: 40px;
  height: 40px;
}

/* App-icon style tile: gradient "cc" on white */
.cc-tile {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #fff;
}

.cc-tile img {
  width: 26px;
  height: 26px;
}

/* ---------------------------------------------------------------- Shared dark promo surface */
.cc-card {
  position: relative;
  overflow: hidden;
  color: var(--cc-text);
  text-decoration: none;
  border-radius: 14px;
  background:
    radial-gradient(90% 70% at 100% 0%, rgba(106, 63, 242, 0.32), transparent 70%),
    radial-gradient(80% 70% at 0% 100%, rgba(27, 143, 227, 0.3), transparent 70%),
    var(--cc-bg);
  border: 1px solid rgba(106, 63, 242, 0.35);
  transition:
    border-color 0.2s,
    transform 0.2s;
}

.cc-card:hover {
  border-color: rgba(160, 110, 255, 0.75);
  transform: translateY(-1px);
}

.cc-label {
  align-self: flex-start;
  padding: 3px 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--cc-soft);
  font-size: 12px;
  font-weight: 500;
}

.cc-title {
  font-weight: 600;
  line-height: 1.25;
}

.cc-title em {
  font-style: normal;
  color: #b9a6ff;
}

.cc-text {
  color: var(--cc-soft);
  font-size: 14px;
}

/* ---------------------------------------------------------------- Layers banner (under main progression, static)
   Soft lavender tint so it reads as a separate ChordChord block on the white card. */
.cc-layers {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  align-items: center;
  gap: 20px;
  margin: 4px 0 8px;
  padding: 18px;
  border-radius: 14px;
  color: var(--text);
  text-decoration: none;
  background: #f7f5ff;
  border: 1px solid #e6e0fb;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.cc-layers:hover {
  border-color: #d5cbf7;
  box-shadow: 0 8px 24px -16px rgba(91, 60, 230, 0.35);
}

.cc-layers-copy {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.cc-layers-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #6b6884;
  font-size: 13px;
  font-weight: 500;
}

.cc-layers-title {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.25;
}

.cc-layers-title em {
  font-style: normal;
  color: #7b4ff0;
}

.cc-layers-text {
  color: #6b6884;
  font-size: 14px;
}

.cc-layers .btn {
  align-self: flex-start;
  height: 38px;
  margin-top: 4px;
}

.cc-tracks {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cc-track {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.cc-track b {
  color: #6b6884;
  font-size: 13px;
  font-weight: 500;
}

.cc-track-empty {
  display: flex;
  align-items: center;
  height: 30px;
  padding: 0 10px;
  border: 1px dashed #d9d0f5;
  border-radius: 7px;
  background: #ffffff;
  color: #6b5fa8;
  font-size: 13px;
  font-weight: 500;
}

.cc-track-done b {
  color: var(--text);
}

.cc-track-chords {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.cc-track-chords i {
  display: grid;
  place-items: center;
  height: 34px;
  border-radius: 7px;
  background: var(--cc-grad);
  color: #fff;
  font-style: normal;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
}

@media (max-width: 640px) {
  .cc-layers {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .cc-layers-copy {
    display: contents;
  }
  .cc-tracks {
    order: 1;
    margin-top: 2px;
  }
  .cc-layers .btn {
    order: 2;
    align-self: stretch;
  }
}

/* ---------------------------------------------------------------- Sidebar card */
.cc-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
}

.cc-card .cc-title {
  font-size: 20px;
}

.cc-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

.cc-list span::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 10px;
  border-radius: 2px;
  background: var(--cc-grad);
  vertical-align: 1px;
}

.cc-card .btn {
  margin-top: 4px;
}

/* ---------------------------------------------------------------- Animated piano roll
   The playhead sweeps once per --loop; chords, melody notes and drum hits light up as it passes. */
.cc-roll {
  position: relative;
  display: grid;
  grid-template-rows: 54px 30px 14px;
  gap: 6px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.cc-roll-melody {
  position: relative;
}

.cc-roll-melody i {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--w);
  height: 9px;
  border-radius: 3px;
  background: #a03ad0;
  animation: cc-note var(--loop) linear infinite;
  animation-delay: var(--d);
}

.cc-roll-chords,
.cc-roll-drums {
  display: grid;
  gap: 4px;
}

.cc-roll-chords {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.cc-roll-chords i {
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: rgba(61, 79, 247, 0.55);
  font-style: normal;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  animation: cc-chord var(--loop) linear infinite;
  animation-delay: var(--d);
}

.cc-roll-drums {
  grid-template-columns: repeat(8, 1fr);
}

.cc-roll-drums i {
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.16);
  animation: cc-drum var(--loop) linear infinite;
  animation-delay: var(--d);
}

.cc-roll-drums i:nth-child(odd) {
  background: rgba(255, 255, 255, 0.28);
}

.cc-roll-track {
  position: absolute;
  inset: 6px 10px;
  pointer-events: none;
}

.cc-roll-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  margin-left: -1px;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.9);
  animation: cc-playhead var(--loop) linear infinite;
}

@keyframes cc-playhead {
  from {
    left: 0;
  }
  to {
    left: 100%;
  }
}

@keyframes cc-chord {
  0%,
  24% {
    background: #4d5cff;
    box-shadow: 0 0 16px rgba(77, 92, 255, 0.8);
  }
  25%,
  100% {
    background: rgba(61, 79, 247, 0.55);
    box-shadow: none;
  }
}

@keyframes cc-note {
  0%,
  9% {
    background: #e07bff;
    box-shadow: 0 0 10px rgba(224, 123, 255, 0.9);
  }
  10%,
  100% {
    background: #a03ad0;
    box-shadow: none;
  }
}

@keyframes cc-drum {
  0%,
  5% {
    background: rgba(255, 255, 255, 0.85);
  }
  8%,
  100% {
    background: rgba(255, 255, 255, 0.2);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cc-roll *,
  .cc-roll-playhead {
    animation: none !important;
  }
}

/* ---------------------------------------------------------------- Mobile sticky bar */
.cc-sticky {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 12px;
  border-radius: 14px;
  color: var(--cc-text);
  background:
    linear-gradient(#17182a, #17182a) padding-box,
    var(--cc-grad) border-box;
  border: 1px solid transparent;
  box-shadow: 0 12px 40px rgba(24, 24, 27, 0.3);
  animation: cc-rise 0.3s ease-out;
}

.cc-sticky[hidden] {
  display: none;
}

.cc-sticky-copy {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--cc-soft);
}

.cc-sticky-copy > * {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cc-sticky-copy strong {
  color: var(--cc-text);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cc-sticky-close {
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: var(--cc-soft);
  font-size: 18px;
  line-height: 1;
}

@keyframes cc-rise {
  from {
    transform: translateY(120%);
  }
}

@media (min-width: 900px) {
  .cc-sticky {
    display: none !important;
  }
}

/* ---------------------------------------------------------------- Toast */
.toast {
  position: fixed;
  left: 50%;
  top: 76px;
  z-index: 60;
  transform: translate(-50%, -12px);
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s,
    transform 0.2s;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.noscript {
  padding: 24px;
  text-align: center;
}

@media (max-width: 480px) {
  .topbar {
    padding: 0 16px;
  }
}
