/* ---- Chord Library ---- */
/* Override tool-page max-width for full-width layout (match Circle of Fifths) */
.tool-page:has(.cl-layout) { max-width: 100%; }

#chord-panel h1 {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #fff;
  margin-bottom: 1.2rem;
  text-transform: uppercase;
}
.cl-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 0.8rem;
  align-items: center;
}
.cl-select-wrap {
  position: relative;
}
.cl-select {
  padding: 8px 32px 8px 12px;
  border: 1.5px solid #2a2d3a;
  border-radius: 10px;
  background: #1a1d27;
  color: #ccc;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  transition: border-color 0.15s;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 12px;
}
.cl-select:hover, .cl-select:focus { border-color: #3a3d4a; color: #fff; }
.cl-select option { background: #1a1d27; color: #ccc; }
.cl-select optgroup { color: #888; font-weight: 700; }

/* Fixed widths for consistent layout across chords/scales/modes */
#cl-instrument, #ls-instrument, #lm-instrument { width: 100px; }
.lib-type-select { width: 90px; }
.lib-root-select { width: 100px; }
.lib-cat-select { width: 175px; }

/* ---- Unified Panel (single card, diagram left | info right) ---- */
#lib-chords { width: 100%; }
#lib-scales { width: 100%; }
#lib-modes  { width: 100%; }
.cl-layout {
  display: flex;
  width: 100%;
  max-width: 960px;
  min-height: 540px;
  margin: 0 auto;
  background: #13151f;
  border: 1.5px solid #2a2d3a;
  border-radius: 10px;
  overflow: hidden;
}
.cl-diagram-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 28px;
  width: 50%;
  flex-shrink: 0;
}
.cl-diagram-side.ls-diagram-side {
  width: 50%;
}
.cl-info-side {
  width: 50%;
  min-width: 0;
  border-left: 2px solid #2a2d3a;
  padding: 20px 22px;
  font-size: 0.85rem;
  line-height: 1.55;
  color: #c0c4d0;
  overflow-y: auto;
}
.cl-chord-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
  min-height: 1.6em;
  line-height: 1.2;
}
.cl-chord-formula {
  font-size: 0.9rem;
  color: #7cb8ff;
  margin-bottom: 12px;
  min-height: 1.4em;
  line-height: 1.2;
  letter-spacing: 0.03em;
}
.cl-diagram-canvas {
  display: block;
  margin-bottom: 0.8rem;
}

/* Position navigation */
.cl-pos-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 0.5rem;
}
.cl-pos-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid #2a2d3a;
  background: #1a1d27;
  color: #888;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.cl-pos-btn:hover { border-color: #555; color: #fff; }
.cl-pos-btn:disabled { opacity: 0.3; cursor: default; }
.cl-pos-label {
  font-size: 0.75rem;
  color: #888;
  letter-spacing: 0.03em;
}

/* Center buttons (under diagram) */
.cl-center-btns {
  display: flex; gap: 8px; justify-content: center; margin-top: 10px;
}

/* Interval label inside note chip */
.cl-note-degree {
  display: block;
  font-size: 0.62rem;
  font-weight: 600;
  opacity: 0.7;
  letter-spacing: 0.03em;
  margin-bottom: 1px;
}

/* Click-to-play hint */
.cl-click-hint {
  font-size: 0.62rem;
  color: #555;
  margin-top: 8px;
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

/* Panel buttons (unified) */
.cl-btn-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}
.cl-btn-row + .cl-detail { margin-top: 10px; }
.cl-btn {
  padding: 7px 14px;
  border: 1.5px solid #2a2d3a;
  border-radius: 10px;
  background: #1a1d27;
  color: #ccc;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: background 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1 1 0;
  justify-content: center;
  white-space: nowrap;
}
a.cl-btn { text-decoration: none; color: #ccc; box-sizing: border-box; line-height: 1; }
.cl-btn:hover { background: #252836; border-color: #555; color: #fff; }
.cl-btn svg { width: 14px; height: 14px; fill: currentColor; }

/* ---- Section Title (non-collapsible, bold) ---- */
.cl-section-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  padding: 10px 0 6px;
}

/* ---- Accordion Sections ---- */
.cl-detail { border-top: 1.5px solid #2a2d3a; }
.cl-detail:first-of-type { border-top: none; }
.cl-detail summary {
  padding: 10px 0;
  font-size: 0.76rem;
  font-weight: 600;
  color: #888;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  transition: color 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.cl-detail summary::-webkit-details-marker { display: none; }
.cl-detail summary::after { content: '+'; font-size: 0.9rem; color: #555; transition: color 0.15s; }
.cl-detail[open] summary::after { content: '\2212'; }
.cl-detail summary:hover { color: #ccc; }
.cl-detail summary:hover::after { color: #888; }
.cl-detail[open] summary { color: #bbb; }
.cl-detail-body { padding: 0 0 12px; }
.cl-detail-body p { font-size: 0.78rem; color: #aaa; line-height: 1.55; margin: 0 0 6px; }
.cl-detail-body p:last-child { margin-bottom: 0; }
.cl-detail-body strong { color: #ccc; }

/* ---- Notes Display (clickable) ---- */
.cl-notes-display { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; }
.cl-note-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1 1 0;
  min-width: 0;
  padding: 6px 2px;
  border-radius: 10px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s;
  overflow: hidden;
}
.cl-note-chip:hover { transform: translateY(-2px); }
.cl-note-chip strong { font-size: 0.92rem; font-weight: 700; }
.cl-note-chip.cl-note-active { box-shadow: 0 0 10px rgba(124, 184, 255, 0.4); transform: translateY(-2px); }
/* Card colors matching circle of fifths */
.cl-note-chip.cl-card-major { background: #3a1818; border: 1px solid #c04040; color: #f0a0a0; }
.cl-note-chip.cl-card-minor { background: #142838; border: 1px solid #4088c0; color: #a0c8f0; }
.cl-note-chip.cl-card-dim   { background: #183818; border: 1px solid #408840; color: #a0e0a0; }
/* Fallback for non-scale chips */
.cl-note-root { background: #3a1818; border: 1px solid #c04040; color: #f0a0a0; }
.cl-note-tone { background: #142838; border: 1px solid #4088c0; color: #a0c8f0; }
.cl-note-fn { display: block; font-size: 0.52rem; opacity: 0.6; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Intervals / Formula Display ---- */
.cl-intervals-text { font-size: 0.78rem; color: #b0b8d0; line-height: 1.8; }
.cl-intervals-text span { color: #888; font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* ---- Degrees ---- */
.cl-degrees-display { font-size: 0.78rem; color: #aaa; line-height: 1.6; }

/* ---- Theory Description ---- */
.cl-theory-desc { font-size: 0.78rem; color: #a0a8c0; line-height: 1.55; }

/* ---- How to Play ---- */
.cl-howto-text { font-size: 0.78rem; color: #aaa; line-height: 1.55; }
.cl-howto-text strong { color: #ccc; }

/* ---- Learn More Links ---- */
.cl-links { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cl-links a {
  display: block; padding: 7px 10px; border-radius: 10px;
  font-size: 0.72rem; font-weight: 600; text-decoration: none; text-align: center;
  background: #1a1d27; border: 1px solid #2a3050; color: #7cb8ff;
  transition: all 0.15s;
}
.cl-links a:hover { background: #2a3a5a; border-color: #5a7ab0; color: #a0d0ff; }
.cl-links-full { display: block; margin-top: 8px; }
.cl-links-full a {
  display: block; width: 100%; padding: 7px 10px; border-radius: 10px;
  font-size: 0.72rem; font-weight: 600; text-decoration: none; text-align: center;
  background: #1e2a1e; border: 1px solid #2a5a3a; color: #7cffb8;
  transition: all 0.15s; box-sizing: border-box;
}
.cl-links-full a:hover { background: #2a3a2a; border-color: #5ab07a; color: #a0ffd0; }

/* Fretboard tool link button */
.cl-fretboard-link {
  display: flex; align-items: center; gap: 6px; justify-content: center;
  margin-top: 12px; padding: 8px 14px; border-radius: 10px;
  font-size: 0.75rem; font-weight: 600; text-decoration: none;
  background: #1a2a1e; border: 1px solid #2a5a3a; color: #7cffb8;
  transition: all 0.15s; letter-spacing: 0.03em;
}
.cl-fretboard-link:hover { background: #2a4a3a; border-color: #5ab07a; color: #a0ffd0; }
.cl-fretboard-link svg { width: 14px; height: 14px; fill: currentColor; flex-shrink: 0; }

/* Piano diagram */
.cl-piano-wrap {
  position: relative;
  width: 340px;
  height: 160px;
}

/* ---- Library Section Visibility ---- */
#lib-scales { display: none; }
#lib-scales.active { display: block; }
#lib-chords.active { display: block; }
#lib-modes { display: none; }
#lib-modes.active { display: block; }

/* ---- Info side panel: non-collapsible elements ---- */
.cl-info-side > .cl-notes-display { margin-bottom: 12px; }

/* ---- Audio toolbar button ---- */
.cl-audio-btn { color: #555; }
.cl-audio-btn.active { background: #1e2030 !important; border-color: #3a3d4a !important; color: #ccc !important; }
.cl-audio-btn .cl-audio-wave1,
.cl-audio-btn .cl-audio-wave2 { opacity: 0.3; }
.cl-audio-btn.active .cl-audio-wave1,
.cl-audio-btn.active .cl-audio-wave2 { opacity: 1; }

/* ---- Responsive: stack vertically on narrow screens ---- */
@media (max-width: 800px) {
  .cl-layout {
    flex-direction: column;
    min-height: 0;
  }
  .cl-info-side {
    width: 100%;
    max-height: none;
    border-left: none;
    border-top: 2px solid #2a2d3a;
  }
  .cl-diagram-side {
    width: 100%;
  }
  .cl-diagram-side.ls-diagram-side {
    width: 100%;
  }
  .cl-diagram-side.ls-diagram-side canvas {
    width: 100%;
    max-width: 420px;
  }
}
@media (max-width: 600px) {
  .cl-layout { border-radius: 10px; }
  .cl-diagram-side { padding: 16px 14px; }
  .cl-info-side { padding: 14px 16px; }
  .cl-diagram-side { width: 100%; }
  .cl-chord-name { font-size: 1.2rem; }
  .cl-controls { gap: 6px; }
  .cl-select { font-size: 0.75rem; padding: 6px 28px 6px 10px; }
  .cl-piano-wrap { width: 280px; height: 140px; }
}
