:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --text: #1d1b18;
  --muted: #6b665d;
  --border: #ddd8cc;
  --accent: #b4521f;
  --accent-text: #ffffff;
  --accent-soft: #f6e3d6;
  --danger: #b3261e;
  --success: #2e7d32;
  --ink: #1d1b18;
  --ghost: #b4521f80;
  --radius: 8px;
  /* editor layout (rail, inspector, status bar) */
  --surface-2: #fbfaf7;
  --divider: #eeeae2;
  --icon-ink: #3a362f;
  --faint: #8a857b;
  --accent-ink: #8a3b12;
  --hover: #f4f2ed;
  --check-border: #cfc9bd;
  --disabled-bg: #faf9f6;
  --disabled-border: #ebe7de;
  --disabled-text: #b9b3a8;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1917;
    --surface: #24221f;
    --text: #ece8e0;
    --muted: #a39d92;
    --border: #3a3732;
    --accent: #e98a55;
    --accent-text: #1a1917;
    --accent-soft: #3d2a1f;
    --danger: #f2817a;
    --success: #81c995;
    --ghost: #e98a5580;
    --surface-2: #201e1b;
    --divider: #302d29;
    --icon-ink: #d8d3ca;
    --faint: #8a857b;
    --accent-ink: #f2b089;
    --hover: #2e2b27;
    --check-border: #5a554d;
    --disabled-bg: #1f1d1a;
    --disabled-border: #34312c;
    --disabled-text: #6f6a61;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

a {
  color: var(--accent);
}

h1 {
  font-size: 1.6rem;
  margin: 0;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

main.narrow {
  max-width: 560px;
}

.muted {
  color: var(--muted);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--accent);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

/* unsaved changes: a dot after the label (editor Save button) */
.btn.unsaved::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.btn.ghost {
  background: transparent;
}

.btn.danger {
  color: var(--danger);
}

.btn.small {
  padding: 3px 10px;
  font-size: 0.9rem;
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

input,
select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
}

input:focus,
select:focus,
button:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
  color: var(--muted);
}

label.toggle {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

label.transpose-select select {
  padding: 4px 6px;
}

label.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

.error {
  color: var(--danger);
  margin: 8px 0;
}

/* auth pages */
.auth {
  max-width: 380px;
  padding-top: 10vh;
}

.auth h1 {
  text-align: center;
  margin-bottom: 20px;
}

.auth form,
.auth .auth-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth h2 {
  margin: 0;
  font-size: 1.2rem;
}

.auth .btn {
  justify-content: center;
}

/* Turnstile widget: keeps its height while it loads, so the form doesn't jump. */
.auth .captcha {
  min-height: 65px;
}

.auth [hidden] {
  display: none;
}

.auth p {
  margin: 0;
}

.auth .forgot {
  align-self: flex-end;
  font-size: 0.9rem;
  margin-top: -6px;
}

/* dev outbox (/dev/mail) */
.dev-mail {
  margin-bottom: 16px;
}

.dev-mail h2 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

.dev-mail pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: inherit;
  margin: 12px 0 0;
}

/* account page */
.account form,
.account section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}

.account h2 {
  margin: 0;
  font-size: 1.1rem;
}

.account .btn {
  align-self: flex-start;
}

.account-email {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.account .small {
  margin: 0;
  font-size: 0.85rem;
}

.success {
  color: var(--success);
  margin: 0;
}

.account .error {
  margin: 0;
}

.topbar nav a.muted {
  max-width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
}

.topbar nav a.muted:hover {
  color: var(--text);
  text-decoration: underline;
}

/* page header */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.page-head p {
  margin: 4px 0 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* song list */
.song-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.song-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 16px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.song-title {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
}

.song-card .muted {
  grid-column: 1;
  font-size: 0.9rem;
}

.song-card .actions {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.empty {
  padding: 32px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* score */
.score-container {
  background: #fffdf8;
  color: #1d1b18;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  overflow: hidden;
}

.score-container .score {
  display: block;
  max-width: 100%;
  height: auto;
  user-select: none;
  touch-action: none;
}

.score text {
  font-family: Georgia, 'Times New Roman', serif;
}

.score text.pos {
  font-family: system-ui, sans-serif;
  fill: #8a3d14;
  font-weight: 600;
}

.score .sel {
  color: #d0581b;
}

.score text.lage {
  font-family: system-ui, sans-serif;
  font-style: italic;
  fill: #8a3d14;
}

.score text.pos.sel {
  fill: #d0581b;
}

.score .ghost {
  color: #d0581b;
  opacity: 0.45;
  pointer-events: none;
}

.score .fill-track {
  color: #e7e1d4;
}

.score .fill-full {
  color: #5f8f4e;
}

.score .fill-open {
  color: #c98a1b;
}

.score .fill-over {
  color: #c0392b;
}

.score text.fill-label {
  font-family: system-ui, sans-serif;
  font-weight: 600;
}

.score text.fill-open {
  fill: #9a6510;
}

.score .deleting {
  color: #c0392b;
}

.score text.deleting,
.score text.name.deleting {
  fill: #c0392b;
}

.score text.value {
  font-family: system-ui, sans-serif;
  fill: #6b665d;
}

.score text.name {
  font-family: system-ui, sans-serif;
  fill: #3d5a80;
}

.score text.value.sel,
.score text.value.preview,
.score text.name.sel,
.score text.name.preview {
  fill: #d0581b;
}

.score .preview {
  color: #d0581b;
  opacity: 0.6;
}

.score text.pos.preview {
  fill: #d0581b;
}

.score .ghost .remove {
  color: #c0392b;
}

.legend {
  font-size: 0.9rem;
}

/* Small caps label in front of a row (view page "Show"). */
.row-label {
  min-width: 3.2rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/*
 * Editor: one viewport-high page. Under the top bar, a header row (title, song fields, actions),
 * then a grid of tool rail | score with status bar | inspector. Only the score scrolls, and its
 * place never depends on the tool, so switching tools doesn't move the music.
 */
.editor-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.editor-page main.editor-main {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0;
}

/* --- header --- */
.editor-head {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 0 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.editor-head .btn,
.head-back {
  flex: none;
  white-space: nowrap;
}

.head-back {
  padding: 0 6px;
  line-height: 32px;
  color: var(--muted);
  text-decoration: none;
}

.head-back:hover {
  color: var(--text);
}

.head-title {
  flex: 1 1 200px;
  min-width: 200px;
  height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
}

/* A bordered box holding a muted label word and a borderless select or input. */
.field-box {
  flex: none;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 4px 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* The key's names are long: its box gives way first, so the title keeps its room. */
.field-key {
  flex: 0 1 250px;
  min-width: 130px;
}

.field-key select {
  flex: 1 1 auto;
  min-width: 0;
  width: 0;
  text-overflow: ellipsis;
}

.field-box select,
.field-box input {
  height: 28px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
}

.field-box:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.field-box select:focus,
.field-box input:focus {
  outline: none;
}

.field-tempo {
  padding-right: 10px;
}

.field-tempo input {
  width: 2.2em;
  text-align: center;
  -moz-appearance: textfield;
}

.field-tempo input::-webkit-inner-spin-button,
.field-tempo input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.head-btn {
  height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 13px;
}

.head-btn.primary {
  padding: 0 14px;
}

/* On wide windows the actions group is invisible and its buttons sit in the header row. */
.head-actions {
  display: contents;
}

.head-spacer {
  flex: 1;
}

.head-more,
.head-break {
  display: none;
}

.editor-error {
  margin: 0 0 8px;
}

/* --- body grid --- */
.editor-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 300px;
}

/* --- tool rail --- */
.tool-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.tool-rail button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--icon-ink);
  font: 500 17px system-ui, sans-serif;
  cursor: pointer;
  transition: background-color 120ms;
}

.tool-rail button:hover:not(:disabled) {
  background: var(--hover);
}

.tool-rail button.danger {
  color: var(--danger);
}

.tool-rail button[aria-pressed='true'] {
  background: var(--accent);
  color: var(--accent-text);
}

.tool-rail button.danger[aria-pressed='true'] {
  background: var(--danger);
  color: #fff;
}

/* a selected tool stays selected-looking under the mouse */
.tool-rail button[aria-pressed='true']:hover:not(:disabled) {
  background: var(--accent);
  filter: brightness(1.08);
}

.tool-rail button.danger[aria-pressed='true']:hover:not(:disabled) {
  background: var(--danger);
}

.rail-spacer {
  flex: 1;
}

/* Tooltip with the tool's name and key, to the right of the rail. */
.tool-rail button[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  font: 12px system-ui, sans-serif;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms;
}

.tool-rail button[data-tip]:hover::after,
.tool-rail button[data-tip]:focus-visible::after {
  opacity: 1;
  transition-delay: 300ms;
}

/* A drawn bar line, since the text glyph is too thin to read at button size. */
.bar-icon {
  display: inline-block;
  width: 3px;
  height: 18px;
  border-radius: 1px;
  background: currentColor;
}

/* Music symbols drawn as inline SVG, so they don't depend on the system's fonts. */
.icon-svg {
  width: 1.2em;
  height: 1.2em;
}

/* --- score and status bar --- */
.score-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 12px;
}

.editor-page .score-container {
  flex: 1 1 auto;
  min-height: 160px;
  overflow-y: auto;
  scrollbar-gutter: stable;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
}

.status-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 34px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  font-size: 13px;
  white-space: nowrap;
}

.status-tool {
  flex: none;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.status-hint {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--icon-ink);
}

.status-hint.error-hint {
  color: var(--danger);
}

.status-stats {
  flex: none;
  color: var(--muted);
}

/* --- inspector --- */
.inspector {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
}

.inspector-toggle {
  display: none;
}

.inspector-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 16px;
  border-bottom: 1px solid var(--divider);
}

.inspector-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.inspector-head kbd {
  font-size: 11px;
  color: var(--muted);
}

.inspector-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 14px 16px;
}

.insp-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.insp-section[hidden],
.inspector [hidden] {
  display: none;
}

.insp-label {
  margin: 0;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.insp-label label {
  display: inline;
  font: inherit;
  color: inherit;
}

/* Every section uses the same grid, so the buttons line up from section to section. */
.insp-grid {
  display: grid;
  gap: 4px;
}

.insp-grid.cols-1 { grid-template-columns: 1fr; }
.insp-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.insp-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.insp-grid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.opt {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: 500 13px system-ui, sans-serif;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  transition: background-color 120ms;
}

.opt:hover:not(:disabled) {
  background: var(--hover);
  border-color: var(--check-border);
}

.opt .sym {
  flex: none;
  min-width: 14px;
  text-align: center;
  display: inline-flex;
  justify-content: center;
}

.opt .sym-text {
  font-size: 11px;
  font-weight: 600;
}

.opt .mono {
  font-family: ui-monospace, monospace;
  font-weight: 700;
}

.compact .opt {
  justify-content: center;
}

/* ♯ ♭ ♮ are drawn small in most fonts */
.compact [data-accidental] .sym {
  font-size: 17px;
  line-height: 1;
}

.opt[aria-pressed='true'],
.opt[aria-pressed='true']:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.opt:disabled {
  opacity: 1;
  background: var(--disabled-bg);
  border-color: var(--disabled-border);
  color: var(--disabled-text);
  cursor: default;
}

.insp-input {
  grid-column: 1 / -1;
  height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 13px;
}

.insp-input.invalid {
  border-color: var(--danger);
  outline-color: var(--danger);
}

.insp-select {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.insp-select select {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 13px;
}

.inspector-show {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--divider);
}

.show-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 8px;
}

label.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 26px;
  font-size: 13px;
  line-height: 1.2;
  color: var(--text);
  cursor: pointer;
}

label.check input {
  flex: none;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

/* Every editor control gets the same focus ring. */
.editor-main button:focus-visible,
.editor-main a:focus-visible,
.editor-main input:focus-visible,
.editor-main select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Medium windows: a narrower inspector, and the song fields move into a second header row. */
@media (max-width: 1199px) {
  .editor-body {
    grid-template-columns: 56px minmax(0, 1fr) 260px;
  }
  .editor-head {
    flex-wrap: wrap;
    row-gap: 0;
    padding-top: 12px;
  }
  .editor-head > *,
  .head-actions > * {
    margin-bottom: 12px;
  }
  .head-break {
    display: block;
    flex-basis: 100%;
    order: 4;
    margin: 0;
  }
  .editor-head .field-box {
    order: 5;
  }
}

/*
 * Phones: the rail becomes a bar at the bottom, the inspector a sheet above it (opened by the
 * Options handle, with Show inside), and the header keeps title and Save, the rest in "⋯".
 */
@media (max-width: 759px) {
  .editor-head {
    padding: 8px 12px 0;
    gap: 6px;
  }
  .editor-head > * {
    margin-bottom: 8px;
  }
  .head-actions > * {
    margin-bottom: 0;
  }
  .head-back {
    padding: 0 2px;
  }
  .head-title {
    flex-basis: 100px;
    min-width: 80px;
  }
  .head-more {
    display: inline-flex;
    justify-content: center;
    min-width: 36px;
    padding: 0;
  }
  .head-actions {
    display: none;
  }
  .editor-head.more-open .head-actions {
    position: absolute;
    top: 46px;
    right: 12px;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgb(40 30 20 / 0.14);
  }
  .head-actions .head-spacer {
    display: none;
  }
  .head-actions .btn {
    justify-content: flex-start;
    border: 0;
  }
  .editor-head .field-box {
    flex: 1 1 auto;
  }
  .editor-head .field-box select {
    min-width: 0;
    max-width: 100%;
  }
  .editor-body {
    display: flex;
    flex-direction: column;
  }
  .score-column {
    flex: 1 1 auto;
    padding: 8px 8px 0;
  }
  .status-bar {
    gap: 8px;
  }
  .status-stats {
    display: none;
  }
  .tool-rail {
    order: 3;
    flex-direction: row;
    justify-content: space-around;
    gap: 0;
    padding: 2px 4px;
    border-right: 0;
    border-top: 1px solid var(--border);
  }
  .tool-rail button {
    width: 44px;
    height: 44px;
  }
  /* undo, shortcuts and help aren't needed on a touch screen's tool bar */
  .rail-spacer,
  .tool-rail .rail-util:not(#undo) {
    display: none;
  }
  .tool-rail button[data-tip]::after {
    display: none;
  }
  .inspector {
    order: 2;
    flex: none;
    border-left: 0;
  }
  .inspector-toggle {
    display: block;
    width: 100%;
    height: 32px;
    border: 0;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--muted);
    font: 600 12px system-ui, sans-serif;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
  }
  .inspector-toggle::after {
    content: ' ▴';
  }
  .inspector.open .inspector-toggle::after {
    content: ' ▾';
  }
  .inspector:not(.open) > :not(.inspector-toggle) {
    display: none;
  }
  .inspector.open {
    max-height: 55vh;
  }
  .inspector-head {
    display: none;
  }
  .inspector-body {
    padding: 10px 12px;
    gap: 12px;
  }
}

kbd {
  font: 0.8rem ui-monospace, monospace;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

.modal {
  width: min(800px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

/* Padding sits inside, so a click on the dialog element itself is a backdrop click. */
.modal-body {
  padding: 20px 24px;
}

.modal::backdrop {
  background: rgb(0 0 0 / 0.35);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.modal h2 {
  margin: 0;
  font-size: 1.2rem;
}

/* "Save as a new song" */
.save-as {
  width: min(440px, calc(100vw - 32px));
}

.save-as-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* "Transpose" */

.transpose {
  width: min(520px, calc(100vw - 32px));
}

.transpose-choices {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin: 12px 0;
}

.transpose-choices input[type="number"] {
  width: 80px;
  padding: 4px 6px;
}

.transpose-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.transpose-summary {
  min-height: 3em;
  margin: 12px 0;
  font-size: 0.95rem;
}

/* "Import from a photo" */
.import {
  width: min(560px, calc(100vw - 32px));
}

.import p {
  margin: 8px 0;
}

.import-mode {
  font-weight: 600;
}

.import-pick {
  max-width: 100%;
}

.import-ai {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 8px 0 0;
}

.import-ai[hidden] {
  display: none;
}

.import-ai label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.85rem;
}

.import-results {
  margin: 6px 0;
  padding-left: 20px;
  font-size: 0.88rem;
}

.import-list {
  margin: 6px 0;
  padding-left: 24px;
  font-size: 0.92rem;
}

.import-list:empty {
  display: none;
}

.import-warnings {
  max-height: 30vh;
  overflow: auto;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.import-warnings ul {
  margin: 0;
  padding-left: 20px;
}

.import-note {
  font-size: 0.85rem;
}

.import-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

/* "How the editor works": the former help list below the staff */
.help ul {
  margin: 0;
  padding-left: 20px;
  font-size: 0.92rem;
}

.help li + li {
  margin-top: 6px;
}

.shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px 28px;
}

.shortcuts h3 {
  margin: 12px 0 6px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.shortcuts dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 5px 12px;
  margin: 0;
  font-size: 0.92rem;
}

.shortcuts dt {
  white-space: nowrap;
  color: var(--muted);
}

.shortcuts dd {
  margin: 0;
}

.shortcuts p {
  margin: 6px 0 0;
  font-size: 0.85rem;
}

@media (max-width: 640px) {
  .song-card {
    grid-template-columns: 1fr;
  }
  .song-card .actions {
    grid-column: 1;
    grid-row: auto;
  }
}

.score-container .score:focus {
  outline: none;
}

/* toast: a short confirmation at the bottom of the page */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 12px);
  padding: 8px 18px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 4px 16px #0003;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.shown {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* View page: the display options in one row under the title, like the editor's Show row. */
.view-show {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  margin: 0 0 12px;
}

/* keep the top bar on one line on phones: the display name shrinks instead */
.brand,
.topbar .btn {
  white-space: nowrap;
}

.topbar nav,
.topbar nav a.muted {
  min-width: 0;
}

/* top bar dropdown (Admin menu) */
.menu {
  position: relative;
}

.menu > summary {
  list-style: none;
  padding: 5px 12px;
}

.menu > summary::-webkit-details-marker {
  display: none;
}

.menu > summary::after {
  content: "▾";
  font-size: 0.8em;
}

.menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  min-width: 140px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px #0003;
}

.menu-list a {
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
}

.menu-list a:hover,
.menu-list a:focus-visible {
  background: var(--accent-soft);
}

/* admin: user list */
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table.users {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

table.users th,
table.users td {
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.users tbody tr:last-child td {
  border-bottom: 0;
}

table.users th {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

table.users .num {
  text-align: right;
}

.user-cell {
  display: grid;
  min-width: 160px;
  max-width: 260px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.user-name {
  font-weight: 600;
}

.user-email {
  font-size: 0.85rem;
}

.badge {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid currentColor;
}

.badge.ok {
  color: var(--success);
}

.badge.warn {
  color: var(--danger);
}

.badge.admin {
  color: var(--accent);
}

table.users .actions {
  flex-wrap: nowrap;
}
