/* css/editor.css — editor surface */

.editor-main {
  flex: 1;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
}

.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.doc-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.doc-title {
  font-family: var(--font-serif);
  font-size: var(--text-2xl);
  font-weight: 600;
  border: none;
  background: transparent;
  width: 100%;
  color: var(--ink);
}
.doc-title::placeholder { color: var(--ink-mute); }

.doc-artist {
  font-family: var(--font-serif);
  font-size: var(--text-base);
  border: none;
  background: transparent;
  width: 100%;
  color: var(--ink-dim);
}
.doc-artist::placeholder { color: var(--ink-mute); }

.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.transpose-row {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.icon-btn {
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius);
  border: 1px solid var(--rule);
  background: var(--card);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-3);
}
.icon-btn:hover {
  background: var(--paper-2);
  border-color: var(--rule-strong);
}
.icon-btn:active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ── Bottom sheet ───────────────────────────────────────────────────── */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .4);
  z-index: 300;
  display: none;
  animation: fade-in var(--motion-normal);
}
.scrim.visible { display: block; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--card);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-4) var(--space-4) calc(var(--space-5) + env(safe-area-inset-bottom));
  z-index: 301;
  display: none;
  flex-direction: column;
  gap: var(--space-4);
  transform: translateY(100%);
  transition: transform var(--motion-normal);
}
.sheet.visible {
  display: flex;
  transform: translateY(0);
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--rule-strong);
  border-radius: 2px;
  margin: 0 auto;
}

.sheet-title {
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--ink);
  text-align: center;
}

.sheet-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
  flex-wrap: wrap;
}

.btn-primary, .btn-secondary, .btn-cancel {
  min-height: 44px;
  padding: 0 var(--space-4);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  border: 1px solid var(--rule-strong);
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary {
  background: var(--card);
  color: var(--danger);
  border-color: var(--danger);
}
.btn-cancel {
  background: var(--card);
  color: var(--ink-dim);
}

/* ── Meta chips ─────────────────────────────────────────────────────── */
.meta-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius);
  background: var(--paper-2);
  border: 1px solid var(--rule);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--ink-dim);
  min-height: 28px;
}
.capo-chip,
.key-chip {
  cursor: pointer;
  background: transparent;
  border-style: dashed;
}
.capo-chip:hover,
.key-chip:hover { background: var(--paper-2); }

/* ── Meta popover fields ────────────────────────────────────────────── */
.meta-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--ink-dim);
}
.meta-field .meta-input {
  height: 44px;
  padding: 0 var(--space-3);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--paper-2);
  font-family: var(--font-mono);
  font-size: var(--text-base);
  color: var(--ink);
  width: 100%;
}
.meta-field .meta-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-ring);
}

/* ── Capo stepper ───────────────────────────────────────────────────── */
.capo-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
}
.stepper-btn {
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  border: 1px solid var(--rule-strong);
  background: var(--card);
  font-size: 24px;
  color: var(--ink);
}
.stepper-btn:active { background: var(--accent-soft); }

.capo-fret-input {
  width: 80px;
  height: 56px;
  font-family: var(--font-mono);
  font-size: 28px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--paper-2);
  color: var(--ink);
}

.capo-preview {
  text-align: center;
  font-family: var(--font-serif);
  font-size: var(--text-base);
  color: var(--ink-dim);
}

@keyframes fade-in { from { opacity: 0 } to { opacity: 1 } }

/* ── Singers legend ─────────────────────────────────────────────────── */
.singers-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px solid var(--rule);
}
.legend-label {
  font-family: var(--font-sans);
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.singer-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px 8px;
  border-radius: var(--radius);
  border: 1.5px solid;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--ink);
}
.pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pill-remove {
  background: none;
  color: inherit;
  font-size: 14px;
  padding: 0 2px;
}
.add-singer-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  border: 1px dashed var(--rule-strong);
  background: var(--card);
  color: var(--ink-mute);
  font-size: 16px;
}
.add-singer-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ── Singer highlights in editor ────────────────────────────────────── */
.singer-highlight {
  border-radius: 3px;
  padding: 0 2px;
  display: inline;
}
.singer-highlight.sh-hl1  { background: rgba(254,240,138,.4); }
.singer-highlight.sh-hl2  { background: rgba(96,165,250,.3); }
.singer-highlight.sh-hl3  { background: rgba(251,146,180,.3); }
.singer-highlight.sh-hl4  { background: rgba(134,239,172,.3); }
.singer-highlight.sh-hl5  { background: rgba(196,181,253,.3); }
.singer-highlight.sh-hl6  { background: rgba(248,113,113,.3); }
.singer-highlight.sh-hl7  { background: rgba(251,191,36,.3); }
.singer-highlight.sh-hl8  { background: rgba(45,212,191,.3); }
.singer-highlight.sh-hl9  { background: rgba(167,139,250,.3); }
.singer-highlight.sh-hl10 { background: rgba(244,114,182,.3); }

.fmt-singer-group {
  display: inline-flex;
  gap: 4px;
}
.fmt-singer-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--card);
  box-shadow: 0 0 0 1px var(--rule-strong);
}

/* ── BV highlights ──────────────────────────────────────────────────── */
.bv-highlight {
  display: inline;
  text-decoration: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 2px;
}
.bv-highlight.bv-1 { text-decoration-color: #06b6d4; }
.bv-highlight.bv-2 { text-decoration-color: #f97316; }
.bv-highlight.bv-3 { text-decoration-color: #a855f7; }
.bv-highlight.bv-4 { text-decoration-color: #ec4899; }
.bv-highlight.bv-5 { text-decoration-color: #14b8a6; }

.bv-pill { background: transparent; }

.fmt-bv-group {
  display: inline-flex;
  gap: 4px;
}
.fmt-bv-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  border: 2px solid;
  background: var(--card);
}

@media (min-width: 640px) {
  .doc-title { font-size: var(--text-3xl); }
  .doc-artist { font-size: var(--text-lg); }
}

/* ── Section ────────────────────────────────────────────────────────── */
.section-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.section-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 10px;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #fff;
}
.repeat-badge {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  background: rgba(255,255,255,.25);
  padding: 1px 5px;
  border-radius: 3px;
}

.section-menu-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  color: var(--ink-mute);
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.section-menu-btn:hover { background: var(--paper-2); }

.section-comment {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--text-sm);
  color: var(--ink-mute);
}

.section-content {
  font-family: var(--font-serif);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--ink);
  border-left: 3px solid;
  padding-left: var(--space-3);
  white-space: pre-wrap;
  outline: none;
  min-height: 1.5em;
  overscroll-behavior: contain;
}
.section-content:focus { box-shadow: none; }

.section-content .chord-line {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--accent-hover);
  font-weight: 500;
  display: block;
}
@media (min-width: 640px) {
  .section-content { font-size: var(--text-lg); }
  .section-content .chord-line { font-size: var(--text-base); }
}

.sections-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.add-section {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--card);
  border: 1px dashed var(--rule-strong);
  border-radius: var(--radius-lg);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-mute);
  transition: all var(--motion-fast);
}
.add-section:hover {
  background: var(--paper-2);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Format toolbar ─────────────────────────────────────────────────── */
.format-toolbar {
  position: fixed;
  background: var(--card);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  padding: 4px;
  display: none;
  gap: 2px;
  box-shadow: 0 4px 12px rgba(15,23,42,.08);
  z-index: 100;
}
.format-toolbar.visible { display: flex; }
.format-toolbar.toolbar-bottom {
  left: 0 !important;
  right: 0 !important;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-bottom: none;
  justify-content: center;
  padding: var(--space-2) var(--space-3) calc(var(--space-2) + env(safe-area-inset-bottom));
}

.fmt-btn {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--ink-dim);
  background: transparent;
  min-height: 36px;
}
.fmt-btn:hover { background: var(--paper-2); }
.fmt-btn:active { background: var(--accent-soft); color: var(--accent); }

.fmt-sep {
  display: inline-block;
  width: 1px;
  align-self: stretch;
  background: var(--rule);
  margin: 4px 2px;
}

.section-content .annot {
  display: inline-block;
  font-style: italic;
  font-size: var(--text-xs);
  color: var(--ink-mute);
  margin: 0 4px;
  background: var(--paper-2);
  padding: 0 4px;
  border-radius: 3px;
}
.section-content .key-change {
  display: block;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--accent);
  margin: var(--space-2) 0;
}
.section-content strong { font-weight: 700; color: var(--ink); }
.section-content em { font-style: italic; }

/* ── Section type dropdown + ⋯ menu ─────────────────────────────────── */
.section-type-dropdown,
.section-menu {
  position: absolute;
  background: var(--card);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  padding: 4px;
  display: none;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 6px 16px rgba(15,23,42,.12);
  z-index: 200;
  min-width: 180px;
}
.section-type-dropdown.visible,
.section-menu.visible { display: flex; }

.section-type-item, .section-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--ink);
  text-align: left;
  background: transparent;
}
.section-type-item:hover, .section-menu-item:hover { background: var(--paper-2); }
.section-type-item.selected { background: var(--accent-soft); color: var(--accent); }
.section-menu-item.danger { color: var(--danger); }
.section-menu-item:disabled { opacity: 0.4; cursor: not-allowed; }

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

.section-type-custom {
  border-top: 1px solid var(--rule);
  padding: var(--space-2) 4px 0;
  margin-top: 4px;
}
.section-type-custom .meta-input {
  height: 36px;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 0 8px;
  background: var(--card);
  color: var(--ink);
}
.section-type-custom .meta-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Drag-and-drop ──────────────────────────────────────────────────── */
.section-card { position: relative; }
.section-drag-handle {
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  color: var(--ink-mute);
  opacity: 0;
  transition: opacity var(--motion-fast);
  user-select: none;
  font-size: 12px;
}
.section-card:hover .section-drag-handle { opacity: 1; }
.section-drag-handle:active { cursor: grabbing; }

.section-card.dragging { opacity: 0.4; }
.section-card.drag-over { box-shadow: 0 -2px 0 var(--accent); }

@media (hover: none) {
  .section-drag-handle { opacity: 0.4; }
}
