:root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1f2328;
  background: #f6f7f8;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: 0.55; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1rem;
  background: #fff;
  border-bottom: 1px solid #d8dee4;
}
.brand { font-size: 1.25rem; font-weight: 700; }
.header-actions { display: flex; gap: 0.5rem; align-items: center; }
.workspace-button, .account-button, .secondary, .icon-button {
  padding: 0.55rem 0.8rem;
  border: 1px solid #d0d7de;
  border-radius: 0.5rem;
  background: #fff;
  color: #1f2328;
}

.main-nav {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 1rem;
  background: #fff;
  border-bottom: 1px solid #d8dee4;
}
.main-nav button {
  padding: 0.6rem 0.9rem;
  border: 0;
  border-radius: 0.45rem;
  background: transparent;
}
.main-nav button.is-active { font-weight: 650; background: #eef1f4; }

.app-main { max-width: 70rem; margin: 0 auto; padding: 2rem 1rem; }
.panel {
  max-width: 42rem;
  margin: 2rem auto;
  padding: 2rem;
  background: #fff;
  border: 1px solid #d8dee4;
  border-radius: 0.75rem;
}
.empty-state { margin-top: 4rem; }
.panel h1, .dialog-header h2 { margin-top: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1.5rem 0; }
.actions button, #selectFolder {
  padding: 0.7rem 1rem;
  border: 1px solid #1f2328;
  border-radius: 0.5rem;
  background: #1f2328;
  color: #fff;
}
.notice, .muted { color: #59636e; }
.hidden { display: none !important; }

.folder-dialog {
  width: min(42rem, calc(100vw - 2rem));
  max-height: min(44rem, calc(100vh - 2rem));
  padding: 0;
  border: 1px solid #d0d7de;
  border-radius: 0.75rem;
}
.folder-dialog::backdrop { background: rgb(0 0 0 / 35%); }
.folder-dialog-inner { padding: 1rem; }
.dialog-header { display: flex; justify-content: space-between; gap: 1rem; }
.icon-button { width: 2.4rem; height: 2.4rem; padding: 0; font-size: 1.5rem; }
.folder-toolbar { display: flex; justify-content: space-between; gap: 0.75rem; margin: 1rem 0; }
.folder-list { border-top: 1px solid #d8dee4; }
.folder-row {
  width: 100%;
  padding: 0.85rem 0.25rem;
  text-align: left;
  border: 0;
  border-bottom: 1px solid #e6e9ec;
  background: #fff;
}
.folder-row:hover { background: #f6f7f8; }
.message { margin: 0.75rem 0; padding: 0.75rem; border-radius: 0.5rem; background: #f6f7f8; }
.message.error { background: #fff1f0; }
.message.success { background: #eef8f0; }

@media (max-width: 600px) {
  .app-header { align-items: flex-start; }
  .header-actions { flex-direction: column; align-items: stretch; }
  .main-nav { justify-content: space-between; }
  .main-nav button { flex: 1; }
  .empty-state { margin-top: 1rem; }
  .folder-toolbar { flex-direction: column; }
}

/* Milestone 2: song library and read-only song view */
.status-panel {
  max-width: 70rem;
  margin-top: 0;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
}
.status-panel.error { background: #fff1f0; }

.songs-layout {
  display: grid;
  grid-template-columns: minmax(14rem, 19rem) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.song-library,
.song-detail {
  background: #fff;
  border: 1px solid #d8dee4;
  border-radius: 0.75rem;
}

.song-library {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 8rem);
  overflow: auto;
}

.library-header {
  padding: 1rem;
  border-bottom: 1px solid #d8dee4;
}
.library-header h1 { margin: 0 0 0.9rem; font-size: 1.2rem; }
.lyrics-view-control { display: grid; gap: 0.3rem; font-size: 0.9rem; }
.lyrics-view-control select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #d0d7de;
  border-radius: 0.45rem;
  background: #fff;
  font: inherit;
}

.song-library .message { margin: 0.75rem; }
.song-list { border-top: 1px solid #eef0f2; }
.song-row {
  display: block;
  width: 100%;
  padding: 0.8rem 1rem;
  border: 0;
  border-bottom: 1px solid #eef0f2;
  background: #fff;
  color: inherit;
  text-align: left;
}
.song-row:hover { background: #f6f7f8; }
.song-row.is-selected { background: #eef1f4; font-weight: 650; }

.song-detail {
  min-height: 28rem;
  padding: clamp(1rem, 3vw, 2rem);
  overflow-x: auto;
}
.song-placeholder { color: #59636e; }
.song-header { padding-bottom: 1rem; border-bottom: 1px solid #d8dee4; }
.song-header h1 { margin: 0; }
.chord-set { margin-bottom: 0; }

.song-section {
  margin-top: 1.5rem;
  padding-top: 0.25rem;
  border-top: 3px solid #d8dee4;
}
.song-section h2 {
  margin: 0 0 1rem;
  padding-top: 0.6rem;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.song-line {
  min-width: 34ch;
  margin: 0 0 0.85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  line-height: 1.35;
}
.chord-line {
  position: relative;
  height: 1.35em;
  white-space: pre;
  color: #8a3d00;
  font-weight: 700;
}
.chord {
  position: absolute;
  top: 0;
  white-space: nowrap;
}
.lyric { white-space: pre; min-height: 1.35em; }
.harmony { font-style: italic; color: #586069; }

@media (max-width: 760px) {
  .app-main { padding: 1rem 0.75rem; }
  .songs-layout { grid-template-columns: 1fr; }
  .song-library { position: static; max-height: none; }
  .song-list { max-height: 14rem; overflow: auto; }
  .song-detail { min-height: 20rem; }
}

/* Milestone 3: song editing */
.library-title-row,
.song-heading-row,
.editor-toolbar,
.section-editor-header,
.editor-row-actions,
.editor-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.library-title-row,
.song-heading-row,
.editor-toolbar {
  justify-content: space-between;
}
.library-title-row h1,
.song-heading-row h1,
.editor-toolbar h1 { margin: 0; }
.small { padding: 0.4rem 0.6rem; font-size: 0.9rem; }
.primary {
  padding: 0.55rem 0.9rem;
  border: 1px solid #1f2328;
  border-radius: 0.5rem;
  background: #1f2328;
  color: #fff;
}
.danger {
  padding: 0.4rem 0.6rem;
  border: 1px solid #cf222e;
  border-radius: 0.45rem;
  background: #fff;
  color: #a40e26;
}
.song-meta { margin-bottom: 0; }
.song-editor { display: grid; gap: 1rem; }
.editor-card {
  padding: 1rem;
  border: 1px solid #d8dee4;
  border-radius: 0.65rem;
  background: #fff;
}
.editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}
.editor-field {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
  font-size: 0.9rem;
}
.editor-field > span,
.chord-editor-title { font-weight: 650; }
.editor-field input,
.editor-field select {
  width: 100%;
  min-width: 0;
  padding: 0.55rem 0.6rem;
  border: 1px solid #d0d7de;
  border-radius: 0.45rem;
  background: #fff;
  font: inherit;
}
.checkbox-field {
  display: flex;
  align-items: center;
  align-self: end;
  min-height: 2.55rem;
}
.section-editor { display: grid; gap: 0.8rem; }
.section-editor-header {
  display: grid;
  grid-template-columns: minmax(8rem, 0.8fr) minmax(10rem, 2fr) minmax(7rem, 0.7fr);
  align-items: end;
}
.editor-row-actions { justify-content: flex-end; }
.icon-action { min-width: 2.2rem; }
.line-editors { display: grid; gap: 0.8rem; }
.line-editor {
  display: grid;
  gap: 0.65rem;
  padding: 0.8rem;
  border: 1px solid #eef0f2;
  border-radius: 0.55rem;
  background: #fafbfc;
}
.line-editor-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}
.chord-editors { display: grid; gap: 0.45rem; }
.chord-editor-row {
  display: grid;
  grid-template-columns: minmax(7rem, 1fr) minmax(6rem, 0.6fr) auto;
  align-items: end;
  gap: 0.5rem;
}
.editor-add { justify-self: start; }

@media (max-width: 760px) {
  .section-editor-header,
  .editor-grid,
  .line-editor-fields { grid-template-columns: 1fr; }
  .editor-toolbar { align-items: flex-start; }
  .editor-toolbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .chord-editor-row { grid-template-columns: 1fr 7rem auto; }
}

/* Milestone 4: visual chord editor */
.chord-palette-card {
  position: sticky;
  top: 0.5rem;
  z-index: 8;
  box-shadow: 0 2px 10px rgb(31 35 40 / 8%);
}
.chord-palette-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.7rem;
}
.chord-palette-title,
.chord-inspector-title {
  font-weight: 700;
}
.chord-palette-help {
  font-size: 0.85rem;
}
.chord-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  min-height: 2.2rem;
  align-items: center;
}
.palette-chord,
.placed-chord {
  border: 1px solid #b65c00;
  border-radius: 0.45rem;
  background: #fff8f0;
  color: #7a3500;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-weight: 700;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.palette-chord {
  padding: 0.42rem 0.62rem;
}
.palette-chord:active,
.placed-chord:active {
  cursor: grabbing;
}
.visual-line-editor {
  overflow: hidden;
}
.visual-line {
  overflow-x: auto;
  padding: 0.2rem 0 0.45rem;
  -webkit-overflow-scrolling: touch;
}
.chord-drop-zone {
  position: relative;
  min-width: 32ch;
  max-width: none;
  padding: 0.35rem 0.2rem 0.4rem;
  border: 1px dashed #c7cdd3;
  border-radius: 0.45rem;
  background: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  line-height: 1.35;
  transition: border-color 120ms ease, background 120ms ease;
}
.chord-drop-zone.is-drag-target {
  border-color: #b65c00;
  background: #fff8f0;
}
.chord-position-guide {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.15;
  background-image: repeating-linear-gradient(
    to right,
    currentColor 0,
    currentColor 1px,
    transparent 1px,
    transparent 1ch
  );
}
.editor-chord-track {
  position: relative;
  height: 2rem;
  min-width: 32ch;
}
.placed-chord {
  position: absolute;
  top: 0.1rem;
  padding: 0.22rem 0.35rem;
  transform: translateX(-0.15rem);
  z-index: 2;
}
.placed-chord.is-selected {
  outline: 2px solid #1f6feb;
  outline-offset: 1px;
}
.visual-lyric {
  position: relative;
  min-height: 1.35em;
  white-space: pre;
  z-index: 1;
}
.visual-harmony {
  color: #586069;
  font-style: italic;
}
.chord-inspector {
  display: grid;
  grid-template-columns: minmax(7rem, 1fr) minmax(10rem, 1fr) auto;
  gap: 0.65rem;
  align-items: end;
  padding: 0.7rem;
  border: 1px solid #b6d1f2;
  border-radius: 0.5rem;
  background: #f6faff;
}
.chord-inspector-title {
  grid-column: 1 / -1;
}
.position-controls {
  display: grid;
  grid-template-columns: auto minmax(4.5rem, 1fr) auto;
  gap: 0.35rem;
  align-items: center;
}
.position-step {
  min-width: 2.2rem;
  min-height: 2.2rem;
  font-size: 1.1rem;
  padding: 0.35rem 0.55rem;
}
.chord-drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 9999;
  pointer-events: none;
  padding: 0.28rem 0.45rem;
  border: 1px solid #b65c00;
  border-radius: 0.4rem;
  background: #fff8f0;
  color: #7a3500;
  box-shadow: 0 4px 14px rgb(31 35 40 / 18%);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-weight: 700;
}

@media (max-width: 760px) {
  .chord-palette-card {
    top: 0.25rem;
  }
  .chord-palette-header {
    display: grid;
    gap: 0.25rem;
  }
  .chord-inspector {
    grid-template-columns: 1fr;
  }
  .chord-inspector-title {
    grid-column: auto;
  }
  .visual-line {
    margin-inline: -0.15rem;
  }
}

/* Milestone 5: set-list workflow */
.setlists-layout {
  display: grid;
  grid-template-columns: minmax(14rem, 19rem) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.setlist-library,
.setlist-detail {
  background: #fff;
  border: 1px solid #d8dee4;
  border-radius: 0.75rem;
}

.setlist-library {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 8rem);
  overflow: auto;
}

.setlist-refresh { margin-top: 0.75rem; }
.setlist-library .message { margin: 0.75rem; }
.setlist-list { border-top: 1px solid #eef0f2; }
.setlist-row {
  display: block;
  width: 100%;
  padding: 0.8rem 1rem;
  border: 0;
  border-bottom: 1px solid #eef0f2;
  background: #fff;
  color: inherit;
  text-align: left;
}
.setlist-row:hover { background: #f6f7f8; }
.setlist-row.is-selected { background: #eef1f4; font-weight: 650; }

.setlist-detail {
  min-height: 28rem;
  padding: clamp(1rem, 3vw, 2rem);
}
.setlist-header { padding-bottom: 1rem; border-bottom: 1px solid #d8dee4; }
.setlist-header h1 { margin: 0; }
.setlist-read-list {
  display: grid;
  gap: 0.45rem;
  margin: 1.25rem 0 0;
  padding-left: 2.4rem;
}
.setlist-read-list li { padding-left: 0.25rem; }
.setlist-song-link {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid #e1e5e9;
  border-radius: 0.5rem;
  background: #fff;
  text-align: left;
}
.setlist-song-link:hover { background: #f6f7f8; }
.setlist-missing-song { color: #a40e26; }

.setlist-editor { display: grid; gap: 1rem; }
.setlist-editor-toolbar,
.setlist-sequence-heading,
.setlist-available-row,
.setlist-entry,
.setlist-entry-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.setlist-editor-toolbar,
.setlist-sequence-heading,
.setlist-available-row { justify-content: space-between; }
.setlist-editor-toolbar h1,
.setlist-song-picker h2,
.setlist-sequence-card h2 { margin: 0; }
.setlist-name-field { max-width: 34rem; }
.setlist-editor-layout {
  display: grid;
  grid-template-columns: minmax(14rem, 0.8fr) minmax(18rem, 1.3fr);
  gap: 1rem;
  align-items: start;
}
.setlist-filter {
  width: 100%;
  margin: 0.8rem 0;
  padding: 0.55rem 0.6rem;
  border: 1px solid #d0d7de;
  border-radius: 0.45rem;
  font: inherit;
}
.setlist-available-list {
  display: grid;
  max-height: 30rem;
  overflow: auto;
  border-top: 1px solid #eef0f2;
}
.setlist-available-row {
  padding: 0.55rem 0;
  border-bottom: 1px solid #eef0f2;
}
.setlist-sequence { display: grid; gap: 0.45rem; margin-top: 0.8rem; }
.setlist-empty { margin-bottom: 0; }
.setlist-entry {
  display: grid;
  grid-template-columns: auto 2rem minmax(0, 1fr) auto;
  padding: 0.55rem;
  border: 1px solid #e1e5e9;
  border-radius: 0.5rem;
  background: #fff;
  transition: border-color 120ms ease, background 120ms ease;
}
.setlist-entry.is-drop-target {
  border-color: #1f6feb;
  background: #f3f8ff;
}
.setlist-entry.is-missing {
  border-color: #efb6b2;
  background: #fff8f7;
}
.setlist-entry-number {
  color: #59636e;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.setlist-entry-label { display: grid; min-width: 0; }
.setlist-entry-label strong,
.setlist-entry-label small {
  overflow-wrap: anywhere;
}
.setlist-entry-actions { justify-content: flex-end; }
.setlist-drag-handle {
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border: 1px solid #d0d7de;
  border-radius: 0.45rem;
  background: #fff;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.setlist-drag-handle:active { cursor: grabbing; }

@media (max-width: 760px) {
  .setlists-layout,
  .setlist-editor-layout { grid-template-columns: 1fr; }
  .setlist-library { position: static; max-height: none; }
  .setlist-list { max-height: 14rem; overflow: auto; }
  .setlist-detail { min-height: 20rem; }
  .setlist-entry {
    grid-template-columns: auto 2rem minmax(0, 1fr);
  }
  .setlist-entry-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
}


/* Milestone 5.1: set-list parts */
.setlist-read-sequence {
  display: grid;
  gap: 0.8rem;
  margin-top: 1.25rem;
}
.setlist-read-sequence .setlist-read-list {
  margin-top: 0;
}
.setlist-part-heading {
  margin: 0.8rem 0 0;
  padding: 0.65rem 0.8rem;
  border-top: 2px solid #59636e;
  border-bottom: 1px solid #d8dee4;
  font-size: 1rem;
  letter-spacing: 0.025em;
}
.setlist-entry-part {
  border-color: #b7bec6;
  background: #f6f7f8;
}
.setlist-entry-part .setlist-entry-label {
  display: block;
}
.setlist-part-name {
  width: 100%;
  min-width: 8rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid #b7bec6;
  border-radius: 0.4rem;
  background: #fff;
  font: inherit;
  font-weight: 700;
}

/* Milestone 8: Performance UX */
.play-view { min-width: 0; }
.play-content { min-width: 0; }
.player-chooser,
.player-empty {
  max-width: 48rem;
  margin: 2rem auto;
  padding: clamp(1rem, 3vw, 2rem);
  background: #fff;
  border: 1px solid #d8dee4;
  border-radius: 0.75rem;
}
.player-chooser h1,
.player-empty h1 { margin-top: 0; }
.player-setlist-list { display: grid; gap: 0.55rem; margin-top: 1.25rem; }
.player-setlist-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid #d8dee4;
  border-radius: 0.55rem;
  background: #fff;
  color: inherit;
  text-align: left;
}
.player-setlist-row:hover { background: #f6f7f8; }
.setlist-header-actions { display: flex; gap: 0.5rem; align-items: center; }
.primary {
  padding: 0.55rem 0.8rem;
  border: 1px solid #1f2328;
  border-radius: 0.5rem;
  background: #1f2328;
  color: #fff;
}

body.is-playing { background: #fff; }
body.is-playing .app-header,
body.is-playing .main-nav,
body.is-playing #workspaceStatus { display: none !important; }
body.is-playing .app-main {
  max-width: none;
  padding: 0;
}
body.is-playing .play-view { display: block !important; }

.player-shell {
  --player-font-scale: 1;
  min-height: 100vh;
  padding-bottom: 5.7rem;
  background: #f3f4f6;
}
/* Visual BPM pulse: one continuous colour field fading inward from the viewport edge. */
.player-shell.has-visual-pulse::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  background: conic-gradient(
    from 32deg,
    #008fb3 0deg,
    #004fd6 82deg,
    #6420c9 170deg,
    #c71878 258deg,
    #008fb3 360deg
  );
  /*
   * A single mask makes the colour fully present at the physical screen edge
   * and continuously fades the same colour field to transparency inward.
   * Multiple mask layers are additive, so corners remain continuous rather
   * than forming a second visible ring.
   */
  -webkit-mask:
    linear-gradient(to bottom, #000 0, rgb(0 0 0 / 96%) 4px, rgb(0 0 0 / 72%) 11px, rgb(0 0 0 / 38%) 21px, transparent 34px) top / 100% 34px no-repeat,
    linear-gradient(to top, #000 0, rgb(0 0 0 / 96%) 4px, rgb(0 0 0 / 72%) 11px, rgb(0 0 0 / 38%) 21px, transparent 34px) bottom / 100% 34px no-repeat,
    linear-gradient(to right, #000 0, rgb(0 0 0 / 96%) 4px, rgb(0 0 0 / 72%) 11px, rgb(0 0 0 / 38%) 21px, transparent 34px) left / 34px 100% no-repeat,
    linear-gradient(to left, #000 0, rgb(0 0 0 / 96%) 4px, rgb(0 0 0 / 72%) 11px, rgb(0 0 0 / 38%) 21px, transparent 34px) right / 34px 100% no-repeat;
  mask:
    linear-gradient(to bottom, #000 0, rgb(0 0 0 / 96%) 4px, rgb(0 0 0 / 72%) 11px, rgb(0 0 0 / 38%) 21px, transparent 34px) top / 100% 34px no-repeat,
    linear-gradient(to top, #000 0, rgb(0 0 0 / 96%) 4px, rgb(0 0 0 / 72%) 11px, rgb(0 0 0 / 38%) 21px, transparent 34px) bottom / 100% 34px no-repeat,
    linear-gradient(to right, #000 0, rgb(0 0 0 / 96%) 4px, rgb(0 0 0 / 72%) 11px, rgb(0 0 0 / 38%) 21px, transparent 34px) left / 34px 100% no-repeat,
    linear-gradient(to left, #000 0, rgb(0 0 0 / 96%) 4px, rgb(0 0 0 / 72%) 11px, rgb(0 0 0 / 38%) 21px, transparent 34px) right / 34px 100% no-repeat;
  opacity: 0.018;
  filter: saturate(1.3);
}

.player-shell.has-visual-pulse.is-beat::before {
  animation: player-edge-field-beat 300ms cubic-bezier(.18,.72,.28,1) both;
}

@keyframes player-edge-field-beat {
  0% {
    opacity: 1;
    filter: saturate(1.75) brightness(0.98);
  }
  24% {
    opacity: 0.88;
    filter: saturate(1.68) brightness(1);
  }
  100% {
    opacity: 0.018;
    filter: saturate(1.3) brightness(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .player-shell.has-visual-pulse.is-beat::before { animation: none; }
}

.player-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: auto minmax(7rem, 1fr) auto;
  align-items: center;
  gap: 0.55rem;
  min-height: 3.4rem;
  padding: 0.45rem max(0.65rem, env(safe-area-inset-right)) 0.45rem max(0.65rem, env(safe-area-inset-left));
  border-bottom: 1px solid #d8dee4;
  background: rgb(243 244 246 / 97%);
  backdrop-filter: blur(10px);
}
.player-exit {
  width: 2.6rem;
  min-width: 2.6rem;
  min-height: 2.6rem;
  padding: 0;
  font-size: 1.35rem;
}
.player-identity-button {
  display: grid;
  justify-items: center;
  min-width: 0;
  padding: 0.3rem 0.55rem;
  border: 0;
  border-radius: 0.45rem;
  background: transparent;
  color: inherit;
  text-align: center;
}
.player-identity-button:hover { background: #f6f7f8; }
.player-identity-button strong,
.player-identity-button span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-identity-button strong { font-size: 0.9rem; }
.player-identity-button span { font-size: 0.8rem; }
.player-top-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  min-width: 0;
}
.player-bpm {
  display: inline-flex;
  align-items: center;
  min-height: 2.6rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid #d0d7de;
  border-radius: 999px;
  background: #fff;
  color: inherit;
  font-size: 0.82rem;
  white-space: nowrap;
}
.player-bpm.is-enabled {
  border-color: #7d84a1;
  background: #eef0f6;
}
.player-font-controls {
  display: grid;
  grid-template-columns: 2.45rem auto 2.45rem;
  align-items: center;
  border: 1px solid #d0d7de;
  border-radius: 0.5rem;
  overflow: hidden;
}
.player-font-step {
  min-width: 2.45rem;
  min-height: 2.6rem;
  padding: 0;
  border: 0;
  border-radius: 0;
}
.player-font-label {
  min-width: 1.7rem;
  text-align: center;
  font-weight: 700;
}

.player-song-heading,
.player-song {
  width: min(60rem, calc(100vw - 2rem));
  margin-inline: auto;
}
.player-song-heading { padding: 0.85rem 0 0.45rem; }
.player-song-heading h1 {
  margin: 0;
  font-size: clamp(1.65rem, 4.5vw, 2.7rem);
}
.player-song {
  font-size: calc(1.1rem * var(--player-font-scale));
}
.player-section {
  margin-top: 1.3em;
  padding-top: 0.4em;
  border-top: 3px solid #d8dee4;
}
.player-section h2 {
  margin: 0 0 0.7em;
  font-size: 0.92em;
}
.player-song-line {
  min-width: max-content;
  padding: 0.3em 0.45em;
  border-radius: 0.4rem;
  transition: background 140ms ease, box-shadow 140ms ease;
}
.player-song-line.is-current {
  background: #fff8d8;
  box-shadow: inset 3px 0 0 #9a6700;
}
.player-song-line .lyric,
.player-song-line .chord-line {
  font-size: 1em;
}

.player-controls {
  position: fixed;
  z-index: 40;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: minmax(6rem, 1fr) minmax(8rem, auto) minmax(6rem, 1fr);
  gap: 0.55rem;
  padding: 0.65rem max(0.7rem, env(safe-area-inset-right)) calc(0.65rem + env(safe-area-inset-bottom)) max(0.7rem, env(safe-area-inset-left));
  border-top: 1px solid #d8dee4;
  background: rgb(255 255 255 / 98%);
  backdrop-filter: blur(10px);
}
.player-controls button { min-height: 3.25rem; }
.player-nav-button { width: 100%; }
.player-autoscroll { min-width: 9rem; }

.player-setlist-dialog {
  width: min(40rem, calc(100vw - 1.5rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  border: 1px solid #b7bec6;
  border-radius: 0.75rem;
  background: #fff;
  box-shadow: 0 14px 44px rgb(31 35 40 / 24%);
}
.player-setlist-dialog::backdrop { background: rgb(31 35 40 / 48%); }
.player-setlist-panel { display: grid; min-height: 0; max-height: calc(100vh - 2rem); }
.player-setlist-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid #d8dee4;
}
.player-setlist-dialog-header h2,
.player-setlist-dialog-header p { margin: 0; }
.player-dialog-close {
  width: 2.75rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0;
  font-size: 1.35rem;
}
.player-performance-settings {
  display: grid;
  gap: 0.2rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid #e6e9ec;
  background: #f8f9fa;
}
.player-setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: 2.75rem;
}
.player-setting-row input { width: 1.25rem; height: 1.25rem; }
.player-overlay-list {
  min-height: 0;
  overflow: auto;
  padding: 0.45rem;
}
.player-overlay-part {
  padding: 0.8rem 0.65rem 0.35rem;
  border-top: 1px solid #e6e9ec;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.045em;
  color: #59636e;
}
.player-overlay-part:first-child { border-top: 0; }
.player-overlay-song {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 0.55rem;
  align-items: center;
  width: 100%;
  min-height: 2.9rem;
  padding: 0.55rem 0.65rem;
  border: 0;
  border-radius: 0.45rem;
  background: transparent;
  color: inherit;
  text-align: left;
}
.player-overlay-song:hover,
.player-overlay-song.is-current { background: #eef1f4; }
.player-overlay-song.is-current { font-weight: 750; }
.player-overlay-number { color: #59636e; text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 680px) {
  .player-topbar {
    grid-template-columns: auto minmax(5rem, 1fr) auto;
    gap: 0.3rem;
    padding-right: max(0.4rem, env(safe-area-inset-right));
    padding-left: max(0.4rem, env(safe-area-inset-left));
  }
  .player-bpm { padding-inline: 0.4rem; font-size: 0.76rem; }
  .player-font-controls { grid-template-columns: 2.35rem 1.4rem 2.35rem; }
  .player-font-step { min-width: 2.35rem; }
  .player-song-heading,
  .player-song { width: calc(100vw - 1rem); }
  .player-controls { grid-template-columns: 1fr 1.15fr 1fr; gap: 0.3rem; padding-inline: 0.4rem; }
  .player-controls button { padding-inline: 0.35rem; font-size: 0.88rem; }
  .player-autoscroll { min-width: 0; }
  .setlist-header-actions { flex-wrap: wrap; justify-content: flex-end; }
}

/* Milestone 6.1: text import */
.editor-import-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}
.editor-import-row .muted {
  flex: 1 1 20rem;
}
.text-import-dialog {
  width: min(46rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  border: 1px solid #b7bec6;
  border-radius: 0.75rem;
  box-shadow: 0 12px 40px rgb(31 35 40 / 22%);
}
.text-import-dialog::backdrop {
  background: rgb(31 35 40 / 40%);
}
.text-import-form {
  display: grid;
  gap: 1rem;
  padding: 1.25rem;
}
.text-import-form h2,
.text-import-form p {
  margin: 0;
}
.text-import-area {
  width: 100%;
  min-height: 20rem;
  resize: vertical;
  padding: 0.75rem;
  border: 1px solid #b7bec6;
  border-radius: 0.5rem;
  font: 0.95rem/1.45 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}


/* Milestone 7: connection and offline state */
.connection-status {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.3rem 0.55rem;
  border: 1px solid #b7bec6;
  border-radius: 999px;
  background: #f6f7f8;
  color: #42526b;
  font-size: 0.82rem;
  white-space: nowrap;
}
.connection-status.is-offline {
  border-color: #d8a35d;
  background: #fff7e6;
  color: #6b4400;
}


/* Milestone 7.1: reduce accidental double-tap zoom on controls */
button,
input,
select,
textarea,
summary,
[role="button"] {
  touch-action: manipulation;
}

/* Private notes */
.private-note-card {
  margin: 1rem 0 0;
  padding: 0.9rem;
  border: 1px solid #d8dee4;
  border-radius: 0.65rem;
  background: #fafbfc;
}
.private-note-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}
.private-note-heading h2 { margin: 0; font-size: 1rem; }
.private-note-status {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  font: inherit;
  font-size: 0.82rem;
}
.private-note-status:not(:disabled) {
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}
.private-note-status:disabled { opacity: 1; }
.private-note-card textarea,
.player-private-note textarea {
  width: 100%;
  resize: vertical;
  padding: 0.65rem 0.7rem;
  border: 1px solid #d0d7de;
  border-radius: 0.5rem;
  background: #fff;
  font: inherit;
  line-height: 1.4;
}
.private-note-conflict { margin-top: 0.7rem; }
.private-note-conflict summary { cursor: pointer; font-weight: 650; }
.private-note-conflict pre {
  white-space: pre-wrap;
  padding: 0.65rem;
  border-radius: 0.45rem;
  background: #fff;
  border: 1px solid #e6e9ec;
}
.player-private-note {
  width: min(100%, 70rem);
  margin: 0 auto 0.5rem;
  padding: 0 0.5rem;
}
.player-private-note summary {
  cursor: pointer;
  padding: 0.4rem 0;
  font-weight: 650;
}
.player-private-note textarea { min-height: 4.5rem; }
