/* ══════════════════════════════════════
   SECTIONS
══════════════════════════════════════ */
.section {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 5px;
  overflow: clip;
}
.sec-head {
  padding: 6px 11px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.sec-label {
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  flex: 1;
  outline: none;
}
.sec-label:focus { color: var(--text); }
.sec-type {
  font-size: 10px;
  color: var(--border);
  letter-spacing: 1px;
  font-family: var(--font-sans);
}
.sec-btns { display: flex; align-items: center; gap: 2px; }
.sec-btns button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  padding: 0 4px;
  border-radius: 3px;
  box-shadow: none;
  font-family: var(--font-sans);
}
.sec-btns button:hover { color: var(--accent); }
.sec-repeat {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
  font-family: var(--font-sans);
}

/* ══════════════════════════════════════
   CHORD ROW
══════════════════════════════════════ */
.chord-row {
  padding: 12px;
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  min-height: 70px;
  align-items: stretch;
  position: relative;
}
.chord-row-foot {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
  padding: 0 12px 10px;
}
.add-chord-btn {
  border: 1px dashed var(--border);
  padding: 6px 10px;
  color: var(--muted);
  font-size: 13px;
  background: none;
  align-self: center;
  border-radius: 5px;
  box-shadow: none;
}
.add-chord-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ══════════════════════════════════════
   CHORD BLOCK
   Fixed 144px width for all chord and riff blocks.
   Beat length shown in the bottom bar; riff width
   can be dragged from 144px up to 288px.
══════════════════════════════════════ */
.cb {
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: relative;
  cursor: pointer;
  user-select: none;
  background: var(--surface);
  border-radius: 5px;
  box-shadow: 0 2px 5px var(--shadow);
  transition: border-color .12s, box-shadow .12s;
  flex-shrink: 0;
  overflow: visible;
  padding-bottom: 14px;
  width: 144px;
  min-height: 135px;
}
.cb:hover  { border-color: var(--accent); box-shadow: 0 3px 10px var(--shadow-md); }
.cb.dragging   { opacity: .3; border-style: dashed; }
.cb.drag-over  { outline: 2px solid var(--accent); }
.cb.selected   { border-color: var(--accent); background: color-mix(in srgb,var(--accent) 8%,var(--surface)); }

/* Left: chord info */
.cb-content {
  padding: 7px 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  min-width: 0;
}
.cb-name {
  font-size: 14px;
  color: var(--accent);
  text-align: center;
  line-height: 1.2;
  font-family: var(--font-mono);
  font-weight: bold;
  cursor: pointer;
  white-space: nowrap;
}
.cb-name:hover { text-decoration: underline; }
.cb-diag {
  font-size: 9px;
  line-height: 1.3;
  color: var(--text);
  white-space: pre;
  text-align: left;
  margin-top: 4px;
  font-family: var(--font-mono);
}
.cb-voicing {
  font-size: 9px;
  color: var(--muted);
  margin-top: 3px;
  letter-spacing: 1px;
  font-family: var(--font-mono);
}

/* Hover actions overlay */
.cb-actions {
  display: none;
  position: absolute;
  top: 2px;
  right: 2px;
  gap: 2px;
  z-index: 2;
}
.cb:hover .cb-actions { display: flex; }
.cb-actions button {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 4px;
  box-shadow: none;
  font-family: var(--font-sans);
}
.cb-actions button:hover { color: var(--accent); border-color: var(--accent); }

/* ══════════════════════════════════════
   CHORD GROUPS
══════════════════════════════════════ */
.chord-group {
  border: 1px solid var(--accent-soft);
  border-radius: 6px;
  padding: 6px 8px;
  position: relative;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
  background: color-mix(in srgb, var(--accent) 4%, var(--bg));
  transition: outline .1s;
}
.chord-group.drag-over { outline: 2px solid var(--accent); }
.chord-group-badge {
  position: absolute;
  top: -10px;
  right: 8px;
  background: var(--accent);
  color: var(--bg);
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 10px;
  font-family: var(--font-sans);
  font-weight: 600;
  cursor: pointer;
}
.chord-group-badge:hover { background: var(--accent-soft); }
.group-select-btn {
  background: var(--surface);
  border: 1px dashed var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  box-shadow: none;
  font-family: var(--font-sans);
}
.group-select-btn:hover { background: var(--surface2); }

/* ══════════════════════════════════════
   TAB GRID EDITOR
══════════════════════════════════════ */
.tab-grid-outer { padding: 10px; overflow-x: auto; }
.tab-grid { display: grid; gap: 0; width: max-content; }
.tg-str-lbl {
  width: 22px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 5px;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--font-mono);
  height: 32px;
}
.tg-cell {
  width: 26px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-family: var(--font-mono);
  cursor: pointer;
  position: relative;
  border-bottom: 1px solid var(--muted);
  color: var(--text);
  font-weight: bold;
}
.tg-cell.empty { color: transparent; }
.tg-cell.empty::after { content: '─'; color: var(--muted); font-size: 11px; }
.tg-cell:hover { background: var(--surface2); }
.tg-cell.editing { border-bottom-color: var(--accent); }
.tg-cell input {
  width: 100%;
  height: 100%;
  text-align: center;
  background: var(--accent);
  color: var(--bg);
  border: none;
  outline: none;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: bold;
  border-radius: 3px;
}
.tg-add-col {
  width: 28px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 16px;
  cursor: pointer;
  border-bottom: 1px dashed var(--border);
  border-radius: 0 4px 4px 0;
}
.tg-add-col:hover { background: var(--surface2); }

/* ══════════════════════════════════════
   ROW ADD BUTTONS
══════════════════════════════════════ */
.row-add-btns {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-self: center;
  flex-shrink: 0;
}
.add-riff-btn {
  border: 1px dashed var(--border);
  padding: 4px 8px;
  color: var(--muted);
  font-size: 11px;
  background: none;
  border-radius: 4px;
  box-shadow: none;
  font-family: var(--font-sans);
}
.add-riff-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ══════════════════════════════════════
   RIFF BLOCK (inline in chord row)
══════════════════════════════════════ */
.riff-block {
  padding: 8px 6px 14px;
  cursor: pointer;
  flex-shrink: 0;
  width: 144px; /* overridden by JS for 2-bar riffs */
  overflow: hidden;
  align-items: center;
  justify-content: center;
}
.riff-mini-label {
  font-size: 10px;
  color: var(--muted);
  font-family: var(--font-sans);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 6px;
  text-align: center;
}

/* ── RIFF INLINE TAB GRID ── */
.riff-inline-grid {
  display: grid;
  gap: 0;
  width: max-content;
}
.riff-tg-lbl {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
}
.riff-tg-cell {
  width: 15px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-family: var(--font-mono);
  color: transparent;
  border-bottom: 1px solid var(--muted);
  position: relative;
}
.riff-tg-cell::after {
  content: '─';
  color: var(--border);
  font-size: 9px;
  position: absolute;
}
.riff-tg-cell.has-note {
  color: var(--text);
  font-weight: bold;
}
.riff-tg-cell.has-note::after { display: none; }

/* ── SLIDE INDICATORS ── */
.tg-cell.tg-slide-src { overflow: visible; }
.tg-slide-char {
  font-size: 9px;
  color: var(--accent);
  line-height: 1;
  vertical-align: super;
  margin-left: 1px;
  font-weight: bold;
}
.tg-cell.tg-slide-mid {
  color: var(--accent);
  opacity: 0.65;
  font-size: 13px;
  font-weight: bold;
}
.tg-cell.tg-slide-preview {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ══════════════════════════════════════
   TEXT / LYRICS EDITOR
══════════════════════════════════════ */
.text-editor { padding: 10px; }
.text-editor textarea {
  width: 100%;
  background: var(--bg);
  border: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  resize: vertical;
  outline: none;
  min-height: 100px;
  padding: 4px;
}
.text-editor textarea::placeholder { color: var(--muted); }

/* ══════════════════════════════════════
   AUTH BADGE (toolbar)
══════════════════════════════════════ */
#auth-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.auth-username {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--accent);
  letter-spacing: 0.5px;
}
.auth-logout {
  font-size: 11px;
  padding: 2px 8px;
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
}
.auth-logout:hover { color: var(--danger); border-color: var(--danger); }
.auth-login-btn {
  font-size: 12px;
  padding: 3px 11px;
  background: var(--accent);
  border: none;
  color: #fff;
  border-radius: 4px;
}
.auth-login-btn:hover { background: var(--accent-soft); }

/* ══════════════════════════════════════
   DRAG & DROP
══════════════════════════════════════ */

/* Group-merge target highlight */
.cb.cb-group-target {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 16%, transparent);
}

/* ── CHORD SECTION ROWS WRAPPER ── */
.chord-section-rows {
  display: flex;
  flex-direction: column;
}

/* ── ADD ROW BUTTON ── */
.add-row-btn {
  display: block;
  width: calc(100% - 24px);
  margin: 0 12px 10px;
  border: 1px dashed var(--border);
  padding: 4px 10px;
  color: var(--muted);
  font-size: 11px;
  background: none;
  border-radius: 4px;
  box-shadow: none;
  text-align: left;
  font-family: var(--font-sans);
}
.add-row-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── CHORD ROW SCROLL WRAPPER ── */
.chord-row-wrap {
  overflow-x: auto;
  overflow-y: visible;
}
/* hide scrollbar on non-hover */
.chord-row-wrap::-webkit-scrollbar { height: 4px; }
.chord-row-wrap::-webkit-scrollbar-track { background: transparent; }
.chord-row-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── CHORD / RIFF RESIZE HANDLE ── */
.cb-resize-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 14px;
  border-top: 1px solid var(--border);
  border-radius: 0 0 4px 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: var(--surface2);
  font-size: 9px;
  font-family: var(--font-sans);
  color: var(--muted);
  letter-spacing: 0.5px;
  user-select: none;
  transition: background 0.12s;
}
.cb-resize-bar:hover { background: var(--border); color: var(--text); }

/* ── DRAG ANIMATIONS ── */
@keyframes ghostIn {
  from { opacity: 0; transform: rotate(0deg) scale(1); }
  to   { opacity: 0.82; transform: rotate(1.5deg) scale(1.04); }
}
.cb-ghost {
  animation: ghostIn 0.12s ease forwards;
  box-shadow: 0 10px 32px rgba(0,0,0,0.30);
  cursor: grabbing;
  transition: opacity 0.14s ease, transform 0.14s ease;
}
@keyframes placeholderIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.cb-placeholder {
  border: 2.5px dashed var(--accent);
  border-radius: 5px;
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  flex-shrink: 0;
  pointer-events: none;
  box-sizing: border-box;
  animation: placeholderIn 0.13s ease forwards;
}
.new-row-placeholder {
  margin: 8px 12px;
  border: 2px dashed var(--accent);
  border-radius: 5px;
  padding: 8px 12px;
  color: var(--accent);
  font-size: 12px;
  text-align: center;
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  pointer-events: none;
  animation: placeholderIn 0.13s ease forwards;
}
