/* ═══════════════════════════════════════════════════════════
   SONG LAB PAGE
   ═══════════════════════════════════════════════════════════ */

.song-main {
  padding: 24px 40px 40px;
  display: grid;
  gap: 20px;
}

.song-panel {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 20px 22px;
  background: var(--surface);
  min-width: 0;
}

.panel-title {
  font-family: 'Jost', sans-serif;
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.hint { font-size: 13px; color: var(--text-muted); }

/* Buttons & fields */
.btn {
  font-family: 'Jost', sans-serif;
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 1px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: progress; }
.btn-primary, .btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover { background: var(--accent-hover); }

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  flex: 1 1 180px;
}
.field input, .field-label + textarea {
  font-family: 'Jost', sans-serif;
  font-size: 16px; /* under 16px, iOS Safari zooms the page when the field is focused */
  letter-spacing: 0;
  text-transform: none;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--surface-3);
  color: var(--text);
  min-height: 40px;
}
.field-label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }

.option-row, .meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-top: 14px;
}
.meta-row { align-items: flex-end; }

.check, .range {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.range input { accent-color: var(--accent); width: 110px; }

/* Source tabs */
.source-tabs { display: flex; margin-bottom: 14px; }
.source-tab {
  font-family: 'Jost', sans-serif;
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 8px 16px;
  min-height: 40px;
  border: 1px solid var(--border);
  border-right: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.source-tab:last-child { border-right: 1px solid var(--border); }
.source-tab[aria-selected="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  padding: 32px 16px;
  border: 2px dashed var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.drop-zone:hover, .drop-zone.over { background: var(--accent-subtle); border-color: var(--accent); }
.drop-zone:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.drop-main { font-size: 17px; }
.drop-sub { font-size: 13px; color: var(--text-muted); max-width: 46ch; }

.sheet-input {
  width: 100%;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 16px; /* avoids iOS zoom-on-focus */
  line-height: 1.45;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--surface-3);
  color: var(--text);
  resize: vertical;
}

.lyrics-paste { margin-top: 12px; }
.lyrics-paste summary { cursor: pointer; font-size: 14px; color: var(--text-muted); padding: 6px 0; }
.lyrics-paste textarea { margin-top: 8px; }

.status { margin-top: 14px; font-size: 14px; min-height: 1.4em; }
.status.error { color: #b3261e; }
[data-theme="dark"] .status.error { color: #f2b8b5; }

.progress { height: 4px; background: var(--surface-2); margin-top: 8px; border-radius: 2px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }

/* Key & transpose */
.song-controls { position: sticky; top: 0; z-index: 20; box-shadow: 0 6px 12px -10px rgba(0,0,0,0.4); }
/* On phones (and any short screen, e.g. a phone in landscape) the sticky panel
   would cover a third to half of the view, hiding the Now/Next diagrams. */
@media (max-width: 599px), (max-height: 699px) {
  .song-controls { position: static; box-shadow: none; }
}
.key-line { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.key-box { display: flex; flex-direction: column; }
.key-caption { font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--text-muted); }
.key-value { font-size: 22px; font-weight: 600; }
.key-arrow { font-size: 22px; color: var(--text-muted); }
.transpose { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.btn.step { width: 44px; min-height: 44px; font-size: 20px; padding: 0; }
.tr-value { min-width: 3ch; text-align: center; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.capo-note { margin-top: 10px; font-size: 14px; color: var(--text-muted); min-height: 1.2em; }

/* Player */
#audio { width: 100%; }
.now-next { display: flex; gap: 24px; margin-top: 16px; align-items: flex-start; flex-wrap: wrap; }
.now, .next { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.nn-caption { font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--text-muted); }
.nn-name { font-size: 32px; font-weight: 600; line-height: 1.1; }
.next .nn-name { font-size: 22px; color: var(--text-muted); }
.nn-diagram { cursor: default; }
.nn-diagram:hover { transform: none; }
.now .nn-diagram svg { width: 164px; height: 224px; }
.next .nn-diagram svg { width: 110px; height: 150px; opacity: 0.8; }
.no-diagram {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  width: 110px; height: 150px; line-height: 1.3;
  border: 1px dashed var(--border); border-radius: 3px; color: var(--text-muted); font-size: 14px;
}
.lyric-offset { max-width: 160px; margin-top: 14px; }

/* Palette */
.palette { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.palette-card { display: flex; flex-direction: column; align-items: center; gap: 4px; line-height: 1.2; padding: 4px; }
.palette-card svg { width: 98px; height: 134px; }
.pc-name { font-size: 16px; font-weight: 600; color: var(--text); }
.pc-count { font-size: 11px; color: var(--text-muted); }
.palette-card:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Sheet */
.sheet-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.sheet-head .panel-title { margin-bottom: 0; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.timeline {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 12px 2px;
  margin-top: 8px;
  scroll-snap-type: x proximity;
}
.timeline:empty { display: none; }
.seg {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 56px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface-3);
  color: var(--text);
  font-family: 'Jost', sans-serif;
  cursor: pointer;
  scroll-snap-align: center;
}
.seg:hover { background: var(--surface-2); }
.seg.nc .seg-name { color: var(--text-muted); font-weight: 400; }
.seg.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.seg.active .seg-time { color: inherit; }
.seg-time { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.seg-name { font-size: 17px; font-weight: 600; }
.seg-edit { cursor: default; }
.seg-input {
  font-family: 'Jost', sans-serif;
  font-size: 16px;
  font-weight: 600;
  width: 6ch;
  text-align: center;
  padding: 2px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.seg-input.invalid { border-color: #b3261e; }

.sheet {
  margin-top: 12px;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 15px;
  line-height: 1.35;
  overflow-x: auto;
}
.row { padding: 4px 8px; border-left: 3px solid transparent; white-space: pre; }
.row.blank { height: 0.9em; }
.row[data-time] { cursor: pointer; }
.row[data-time]:hover { background: var(--surface-2); }
.row.active { border-left-color: var(--accent); background: var(--accent-subtle); }
.row-chords { color: var(--accent); font-weight: 700; }
.print-progression { display: none; }
.sheet .hint { font-family: 'Jost', sans-serif; white-space: normal; margin-bottom: 10px; }

@media (max-width: 640px) {
  .song-main { padding: 16px; }
  .song-panel { padding: 16px; }
  .transpose { margin-left: 0; }
  .now .nn-diagram svg { width: 132px; height: 180px; }
  .sheet { font-size: 13px; }
}

/* Touch screens: give small controls a finger-sized hit area (~44px) */
@media (any-pointer: coarse) {
  .btn, .source-tab { min-height: 44px; }
  .check { min-height: 44px; }
  .lyrics-paste summary { padding: 12px 0; } /* keeps the native disclosure arrow */
  .seg { min-height: 48px; min-width: 60px; }
  .chord-card:hover { transform: none; } /* no sticky hover lift after a tap */
}

@media (prefers-reduced-motion: reduce) {
  .progress-bar { transition: none; }
}

@media print {
  .song-main { padding: 0; }
  .song-panel { border: none; padding: 0; }
  section[aria-labelledby="load-heading"], #player-panel, .sheet-actions, .timeline, .option-row, .transpose { display: none !important; }
  .song-controls { position: static; box-shadow: none; }
  .row.active { background: none; border-left-color: transparent; }
  .row-chords { color: #000; }
  .print-progression { display: block; margin-bottom: 12px; }
  .sheet .hint { display: none; }
}
