/* ── Themes ──
   Each theme sets the base colours; the rest are mixed from them.
   Slides (present-screen) are coloured separately in present.css.
   docs/themes.md (its colours in docs/_static/palettes.js) compares the
   themes and their contrast. */

:root {
  /* Port de nuit (default) */
  --header-bg: #0b2239;
  --header-border: #06172a;
  --nav-accent: #7fd0e6;
  --page-bg: #f1f4f7;
  --surface: #ffffff;
  --text: #0f1c27;
  --text-muted: #4a5a68;
  --accent: #0b6a85;
  --accent-soft: #e2f0f4;

  --surface-alt: var(--page-bg);
  --surface-hover: color-mix(in srgb, var(--accent) 9%, var(--surface));
  --border: color-mix(in srgb, var(--text) 9%, var(--surface));
  --border-strong: color-mix(in srgb, var(--text) 19%, var(--surface));
  --text-subtle: color-mix(in srgb, var(--text-muted) 70%, var(--surface));
  --text-faint: color-mix(in srgb, var(--text-muted) 50%, var(--surface));
  --accent-hover: color-mix(in srgb, var(--accent) 88%, #000);
  --accent-light: color-mix(in srgb, var(--accent) 40%, #fff);
  --accent-tint: color-mix(in srgb, var(--accent) 10%, transparent);
  --accent-ring: color-mix(in srgb, var(--accent) 35%, transparent);
}

:root[data-theme="songbook"] {
  --header-bg: #1a1a2e;
  --header-border: #0d0d1a;
  --nav-accent: #6ea8fe;
  --page-bg: #f5f5f5;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #555555;
  --accent: #1a73e8;
  --accent-soft: #eef3fd;
}

:root[data-theme="lanterne"] {
  --header-bg: #2a1c12;
  --header-border: #1b110a;
  --nav-accent: #f2b155;
  --page-bg: #f6f2ec;
  --surface: #ffffff;
  --text: #21170f;
  --text-muted: #5e5045;
  --accent: #a4500c;
  --accent-soft: #f8eadb;
}

:root[data-theme="phare"] {
  --header-bg: #1d2228;
  --header-border: #121519;
  --nav-accent: #ff8a7a;
  --page-bg: #f4f4f2;
  --surface: #ffffff;
  --text: #1a1d21;
  --text-muted: #565b61;
  --accent: #b42318;
  --accent-soft: #fbe9e7;
}

:root[data-theme="feu-vert"] {
  --header-bg: #0f2e26;
  --header-border: #081d17;
  --nav-accent: #7ddcaa;
  --page-bg: #f2f6f3;
  --surface: #ffffff;
  --text: #13201b;
  --text-muted: #4b5c55;
  --accent: #1d7650;
  --accent-soft: #e1f1e8;
}

:root[data-theme="crepuscule"] {
  --header-bg: #251d3d;
  --header-border: #17112a;
  --nav-accent: #b9a6ff;
  --page-bg: #f5f4f9;
  --surface: #ffffff;
  --text: #1b1726;
  --text-muted: #57526a;
  --accent: #5a3fc0;
  --accent-soft: #ece8fa;
}

/* ── Typefaces (brand/README.md): Lexend for the app and slides, Fraunces
   for display. Declared in fonts.css. ── */

:root {
  --font-ui: "Lexend", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-code: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text);
  background: var(--page-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */

.header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  padding: 0 0.75rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header .container {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: 1200px;
  margin: 0 auto;
  height: 56px;
}

.header .logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

/* The lantern alone, without the wordmark: a symbol beside the nav rather
   than a second line of text for it to line up with. */
.header .logo img {
  display: block;
  height: 40px;
  width: auto;
}

/* Signed out, the full lockup: 43px tall makes it 123px wide, and the
   brand's minimum is 120px. */
.header .logo img.logo-lockup {
  height: 43px;
}

.header nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  height: 100%;
  flex: 1;
}

.nav-selectors {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border-left: 1px solid rgba(255, 255, 255, 0.15);
  padding-left: 1rem;
}

/* Signed in: the organization (switched from its page), and the account */
.nav-account {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 12px;
  white-space: nowrap;
}

.nav-account a,
.nav-logout button {
  color: rgba(255, 255, 255, 0.65);
  text-decoration: none;
  transition: color 0.15s;
}

.nav-account a:hover,
.nav-logout button:hover {
  color: #fff;
}

.nav-account .nav-org {
  color: #fff;
  font-weight: 600;
}

/* The organization's menu: the others to switch to, and managing it */
.nav-org-menu {
  position: relative;
}

.nav-org-menu summary {
  list-style: none;
  cursor: pointer;
}

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

.nav-org-menu summary:hover {
  color: rgba(255, 255, 255, 0.85);
}

.nav-menu {
  position: absolute;
  top: calc(100% + 0.6rem);
  left: 0;
  z-index: 110;
  min-width: 14rem;
  padding: 0.35rem 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.18);
  font-size: 13px;
}

.nav-menu-heading {
  padding: 0.3rem 0.8rem;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.nav-account .nav-menu-item,
.nav-menu-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: 0.4rem 0.8rem;
  font: inherit;
  text-align: left;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
}

.nav-account .nav-menu-item:hover,
.nav-menu-item:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.nav-menu-note {
  color: var(--text-muted);
}

.nav-menu hr {
  margin: 0.35rem 0;
  border: none;
  border-top: 1px solid var(--border);
}

.nav-logout button {
  font: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.nav-select {
  appearance: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: 0.04em;
  padding: 0.25rem 1.6rem 0.25rem 0.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='rgba(255,255,255,0.4)'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.45rem center;
  transition: border-color 0.15s, color 0.15s, background-color 0.15s;
}

.nav-select-notation,
.nav-select-theme {
  min-width: 6rem;
}

.nav-select:hover {
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
}

.nav-select:focus {
  outline: none;
  border-color: var(--nav-accent);
  color: #fff;
}

.nav-select option {
  background: var(--header-bg);
  color: #fff;
  font-weight: normal;
}

.header nav a {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 0.875rem;
  color: rgba(255, 255, 255, 0.65);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.header nav a:hover {
  color: #fff;
}

.header nav a.active {
  color: #fff;
  border-bottom-color: var(--nav-accent);
}

/* ── Main ── */

.main {
  flex: 1;
  padding: 1.25rem 0.75rem;
}

.main .container {
  max-width: 1200px;
  margin: 0 auto;
}

/* ── Tables ── */

table {
  border-collapse: collapse;
  width: 100%;
  background: var(--surface);
}

table td,
table th {
  padding: 0.35em 0.75em;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

thead td,
thead th {
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  background: var(--surface);
  position: sticky;
  top: 56px; /* height of the header */
  z-index: 1;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

thead td:hover,
thead th:hover {
  background: var(--surface-alt);
  color: var(--text);
}

tbody tr:hover td {
  background: var(--surface-hover);
}

tbody.even {
  background: var(--surface-alt);
}

tbody.odd {
  background: var(--surface);
}

tbody.even tr td {
  background: inherit;
}

tbody.odd tr td {
  background: inherit;
}

tbody.even tr:hover td,
tbody.odd tr:hover td {
  background: var(--surface-hover);
}

/* ── Links in tables ── */

table a {
  color: var(--accent);
  text-decoration: none;
}

table a:hover {
  text-decoration: underline;
}

/* ── Tags / key spans ── */

table td span {
  display: inline-block;
  margin-right: 0.35em;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  padding: 0.1em 0.45em;
  border-radius: 3px;
}

/* ── Song list filter bar ── */

.filter-bar {
  margin-bottom: 0.75em;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75em;
  align-items: center;
}

.filter-label {
  display: flex;
  align-items: center;
  gap: 0.3em;
  font-size: 12px;
  color: var(--text-muted);
}

.filter-select {
  font-size: 12px;
  padding: 0.15em 0.4em;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  background: var(--surface);
  cursor: pointer;
}

.filter-search {
  font-size: 12px;
  padding: 0.15em 0.4em;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  min-width: 14em;
}

.filter-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3em 0.4em;
}

.filter-tag-btn {
  font-size: 12px;
  padding: 0.1em 0.5em;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
  cursor: pointer;
  white-space: nowrap;
}

.filter-tag-btn--off {
  background: var(--surface-hover);
  color: var(--text-muted);
}

.filter-tag-btn--include {
  background: #d4edda;
  border-color: #5a9e6f;
  color: #1a5c30;
}

.filter-tag-btn--exclude {
  background: #f8d7da;
  border-color: #c0616a;
  color: #7a1c24;
}

@media (max-width: 600px) {
  .filter-bar {
    gap: 0.6em;
  }

  .filter-label {
    font-size: 14px;
    align-items: flex-start;
    flex-direction: column;
  }

  .filter-checkboxes {
    gap: 0.4em 0.5em;
  }

  .filter-tag-btn {
    font-size: 14px;
    padding: 0.4em 0.75em;
    min-height: 36px;
  }

  .filter-search {
    font-size: 16px; /* prevents iOS auto-zoom */
    padding: 0.4em 0.5em;
    min-height: 36px;
    width: 100%;
  }

  .filter-select {
    font-size: 16px; /* prevents iOS auto-zoom */
    padding: 0.4em 0.5em;
    min-height: 36px;
  }
}

thead td.filter-only {
  cursor: default;
}

/* ── Footer ── */

.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 0.75rem 0.75rem;
}

.footer .container {
  max-width: 1200px;
  margin: 0 auto;
  color: var(--text-faint);
  font-size: 12px;
}

/* ── Flash messages ── */

.flashed-messages {
  margin-bottom: 1rem;
}

.flashed-messages p {
  padding: 0.6rem 1rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
  font-size: 13px;
}

.flashed-messages .error   { background: #fdecea; color: #c0392b; }
.flashed-messages .warning { background: #fff8e1; color: #856404; }
.flashed-messages .info    { background: #e8f4fd; color: #0c5460; }

/* ── Home: dictionary entry for "fanal" ── */

.home-logo {
  display: block;
  width: 220px;
  max-width: 60%;
  height: auto;
  margin: 1.5rem auto 0;
}

.home-entry {
  max-width: 40rem;
  margin: 1.5rem auto 2rem;
  padding: 1.75rem 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font-ui);
  line-height: 1.5;
}

.home-entry-headword {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  color: var(--header-bg);
  line-height: 1.2;
}

.home-entry-pos {
  margin-top: 0.15rem;
  color: var(--accent);
  font-style: italic;
}

.home-entry-etymology {
  margin-top: 0.5rem;
  color: var(--text-muted);
  font-size: 15px;
}

.home-entry-definitions {
  margin-top: 1.25rem;
  padding-left: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 17px;
}

.home-entry-definitions li::marker {
  color: var(--accent);
  font-weight: 700;
}

.home-entry-source {
  margin-top: 1.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-family: var(--font-ui);
  font-size: 12px;
}

.home-entry-source a {
  color: var(--text-subtle);
}

/* ── Song view ── */

.song-view {
  max-width: 800px;
}

/* ── In-page nav layout (set + song views) ── */

.page-with-nav {
  display: grid;
  grid-template-columns: minmax(0, 800px) 280px;
  justify-content: space-between;
  gap: 2rem;
  align-items: start;
}

.page-main {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
}

.page-nav {
  grid-column: 2;
  grid-row: 1;
  position: sticky;
  top: calc(56px + 1.25rem);
  max-height: calc(100vh - 56px - 2.5rem);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 0.9rem;
}

.page-nav-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
  padding-bottom: 0.75rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.page-nav-header {
  margin-bottom: 0.4rem;
}

.page-nav-set-title {
  font-size: 14px;
  font-weight: 700;
}

.page-nav-set-date {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
}

.page-nav-copy {
  text-align: right;
  margin-top: 0.5rem;
}

.btn-copy-summary {
  background: none;
  border: none;
  cursor: pointer;
}

.icon-clipboard-check {
  display: none;
}

.copied .icon-clipboard-check {
  display: inline;
}

.page-nav-list {
  list-style: none;
}

.page-nav-list a {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.4rem;
  padding: 0.3rem 0.4rem;
  margin: 0 -0.4rem;
  border-radius: 4px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
}

.page-nav-list li:nth-child(odd) a {
  background: var(--surface-alt);
}

.page-nav-list li a:hover {
  background: var(--accent-tint);
}

.page-nav-order {
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
  min-width: 1.2em;
}

.page-nav-title {
  font-weight: 600;
}

.page-nav-key {
  margin-left: auto;
  font-weight: 600;
}

.page-nav-empty {
  color: var(--text-subtle);
  font-size: 13px;
}

.page-nav-nums {
  flex-basis: 100%;
  text-align: right;
  color: var(--text-muted);
  font-size: 12px;
}

.set-song {
  scroll-margin-top: calc(56px + 1rem);
}

.set-song + .set-song {
  margin-top: 4rem;
  padding-top: 4rem;
  border-top: 1px solid var(--border);
}

.song-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.song-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.song-artist {
  color: var(--text-muted);
  font-size: 1rem;
  margin-top: 0.2rem;
}

.song-export-actions {
  display: flex;
  gap: 0.2rem;
  align-items: center;
}

.song-export-link {
  display: inline-flex;
  align-items: center;
  color: var(--accent);
  text-decoration: none;
  padding: 3px;
  border-radius: 4px;
  transition: background 0.15s;
}

.song-export-link:hover {
  background: var(--accent-tint);
}

.song-back-link {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

.song-back-link:hover {
  text-decoration: underline;
}

.song-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-bottom: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.song-meta-group {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.6rem 0.9rem;
}


.song-meta-group--books {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
}

.song-meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.song-meta-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
}

.song-meta-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.song-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
}

.song-tag {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  padding: 0.15em 0.5em;
  border-radius: 3px;
}

.song-sheet {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
}

.song-variant-name {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
  margin-bottom: 1rem;
}

.song-variants {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
}

.song-variant-tab {
  font-size: 12px;
  padding: 0.3em 0.7em;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.song-variant-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.song-variant-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.song-key-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.key-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.key-btn {
  font-size: 11px;
  padding: 0.25em 0.6em;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

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

.key-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.song-sheet-tools {
  display: flex;
  align-items: stretch;
  gap: 0.25rem;
  margin-left: auto;
}

.accidental-toggle-btn,
.sheet-tool-btn {
  font-size: 14px;
  padding: 0.2em 0.5em;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  transition: border-color 0.15s, color 0.15s;
}

.sheet-tool-btn {
  display: inline-flex;
  align-items: center;
}

.sheet-tool-btn svg {
  width: 14px;
  height: 14px;
}

.accidental-toggle-btn:hover,
.sheet-tool-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.song-no-content {
  color: var(--text-subtle);
  font-style: italic;
  padding: 1rem 0;
}

/* ── ChordPro rendering ── */

.chordpro {
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.4;
}

.cp-header {
  margin-bottom: 0.75rem;
  font-family: var(--font-ui);
}

.cp-title,
.cp-artist {
  display: none;
}

.cp-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.cp-album,
.cp-composer {
  font-size: 12px;
  color: var(--text-subtle);
  margin-bottom: 0.2rem;
}

.cp-meta {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.45rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 0.25rem;
}

.cp-footer {
  margin-top: 1rem;
}

.cp-copyright {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text-faint);
}

.cp-section {
  margin-bottom: 1.25rem;
}

.cp-section[data-section="chorus"],
.cp-section[data-section="bridge"],
.cp-section[data-section="prechorus"],
.cp-section[data-section="pre_chorus"] {
  padding-left: 1.5rem;
  border-left: 3px solid var(--border-strong);
}

.cp-section-label {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  margin-bottom: 0.35rem;
}

.cp-line {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 0.1rem;
}

.cp-unit {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
}

.cp-chord {
  font-weight: 700;
  color: var(--accent);
  font-size: 12px;
  line-height: 1.3;
  white-space: pre;
  padding-right: 0.2em;
}

.cp-lyric {
  white-space: pre;
  color: var(--text);
}

.cp-lyric-only {
  white-space: pre;
  color: var(--text);
  align-self: flex-end;
}

.cp-lyric-line {
  color: var(--text);
  white-space: pre-wrap;
  margin-top: 1.45em; /* push down to align with lyric row when no chord above */
  margin-bottom: 0.1rem;
}

.cp-break {
  height: 0.6rem;
}

.cp-comment {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text-subtle);
  font-style: italic;
  margin-bottom: 0.3rem;
}

/* ── Toggle chords button ── */

.btn-toggle-chords {
  font-size: 12px;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}

.btn-toggle-chords:hover {
  text-decoration: underline;
}

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  font: inherit;
  font-size: 13px;
  padding: 0.45em 0.9em;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s;
}

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

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-danger {
  color: #c0392b;
  border-color: #e6b0aa;
}

.btn-danger:hover {
  background: #fdecea;
  border-color: #c0392b;
}

.list-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

/* ── Bible tab ── */

.bible-lookup {
  display: grid;
  grid-template-columns: minmax(0, 20rem) minmax(0, 1fr) auto;
  gap: 0.5rem 1rem;
  align-items: end;
  margin-bottom: 1.5rem;
}

@media (max-width: 700px) {
  .bible-lookup {
    grid-template-columns: minmax(0, 1fr);
  }
}

.bible-passage .song-sheet {
  margin-top: 0.75rem;
}

.bible-passage sup {
  font-size: 0.65em;
  color: var(--text-subtle);
}

.bible-copyright {
  margin-top: 0.5rem;
}

.bible-add {
  margin-top: 1.5rem;
  max-width: 40rem;
}

/* ── Accounts: signing in, organizations, members ── */

.account-page {
  max-width: 28rem;
  margin: 2rem auto;
}

/* Signing in to the mobile app, already signed in here: one thing to do */
.app-sign-in .app-sign-in-continue {
  display: block;
  width: 100%;
  margin-top: 1.5rem;
  padding: 0.85rem 1rem;
  font-size: 16px;
}

.app-sign-in-others {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.account-page--wide {
  max-width: 48rem;
}

.account-page h1 {
  margin-bottom: 1rem;
}

.account-page h2 {
  font-size: 1rem;
  margin: 2rem 0 0.75rem;
}

.org-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.org-list button {
  width: 100%;
  justify-content: space-between;
  font-size: 15px;
  padding: 0.75em 1em;
}

.org-role {
  color: var(--text-subtle);
  font-size: 12px;
}

.member-table {
  width: 100%;
}

.member-table td {
  vertical-align: middle;
}

.member-table form {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
}

.member-add {
  display: grid;
  grid-template-columns: 2fr 2fr 1fr auto;
  gap: 0.5rem 0.75rem;
  align-items: end;
}

@media (max-width: 700px) {
  .member-add {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ── Song import: files dropped on the page ── */

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border: 3px dashed var(--accent);
  pointer-events: none;
}

.drop-overlay[hidden] {
  display: none;
}

.drop-overlay p {
  margin: 0;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.15);
}

/* ── Song import review ── */

.import-summary {
  margin: 0 0 1rem;
  padding-left: 1.2rem;
}

.import-problems {
  margin-bottom: 0.75rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border);
  border-left: 4px solid #e0a800;
  border-radius: 6px;
  background: var(--surface);
}

.import-problems--error {
  border-left-color: #c0392b;
}

.import-problems summary {
  font-weight: 600;
  cursor: pointer;
}

.import-problems ul {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
  font-size: 14px;
}

.import-problems li + li {
  margin-top: 0.2rem;
}

.import-problems .form-help {
  margin: 0.4rem 0 0;
}

.import-sets {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
}

.import-sets .form-help {
  display: block;
  margin-top: 0.2rem;
  font-weight: 400;
}

.import-hide-imported {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 14px;
  cursor: pointer;
}

.edit-form:has(.import-hide-imported input:checked) .import-item--imported {
  display: none;
}

.import-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.import-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
}

.import-item-choice {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  width: 17em;
  flex-shrink: 0;
}

.import-item-choice select,
.import-variant-field input {
  font: inherit;
  font-size: 13px;
  padding: 0.3em 0.4em;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  width: 100%;
}

.import-variant {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

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

.import-variant-field {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.import-variant-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 16rem;
  overflow-y: auto;
  margin: 2px 0 0;
  padding: 0.25rem 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.12);
  font-size: 13px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
}

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

.import-variant-results li {
  padding: 0.3rem 0.6rem;
  cursor: pointer;
}

.import-variant-results li[aria-selected="true"],
.import-variant-results li:hover {
  background: var(--surface-hover);
}

.import-variant-results .import-variant-meta {
  color: var(--text-muted);
  font-size: 12px;
}

.import-variant-results .import-variant-empty {
  color: var(--text-muted);
  cursor: default;
}

.import-item--blocked {
  opacity: 0.75;
}

.import-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.75rem;
}

.import-item-title {
  font-weight: 600;
}

.import-item-artist,
.import-item-file {
  color: var(--text-subtle);
  font-size: 12px;
}

.import-item-key {
  font-weight: 600;
  font-size: 12px;
}

.import-item-file {
  margin-left: auto;
}

.import-item-notes {
  flex-basis: 100%;
  list-style: none;
  font-size: 12px;
}

.import-note--warning {
  color: #856404;
}

.import-note--error {
  color: #c0392b;
}

.page-nav-edit {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.2rem 0.8rem;
}

.page-nav-variant {
  font-style: italic;
}

.song-variant-plays {
  opacity: 0.75;
}

.set-list-variant {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Edit forms ── */

.edit-page {
  max-width: 1100px;
}

.form-intro {
  color: var(--text-muted);
  margin-bottom: 1rem;
  max-width: 60em;
}

.form-consequences {
  padding-left: 1.2em;
}

/* Make Variant of…: the song search, whose suggestions drop below it */
.song-search {
  position: relative;
}

/* Make Variant of…: this song's chart beside the chosen song's */
.compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 2rem;
  align-items: start;
}

.compare-side {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

.compare-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
}

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

.compare-key {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin-left: 0.3em;
}

.compare .song-sheet {
  margin-top: 0.3rem;
  overflow: auto;
  max-height: 60em;
}

@media (max-width: 700px) {
  .compare {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* A song list row's "Make Variant of…" link, shown on hovering the row. */
.song-row-action {
  margin-left: 0.4em;
  color: var(--text-faint);
  text-decoration: none;
  opacity: 0;
}

.song-row-action::before {
  content: "⤷";
}

tr:hover .song-row-action,
.song-row-action:focus-visible {
  opacity: 1;
}

.song-row-action:hover {
  color: var(--accent);
}

/* No hover on touch screens: always show it. */
@media (hover: none) {
  .song-row-action {
    opacity: 1;
  }
}

.edit-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.75rem 1rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.form-field--wide {
  grid-column: span 3;
}

.form-field--full {
  grid-column: 1 / -1;
}

.form-field label,
.form-field legend,
.form-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.form-field input,
.form-field select,
.form-field textarea,
.set-item-select,
.set-item-note-title,
.set-add-search input {
  font: inherit;
  font-size: 14px;
  padding: 0.4em 0.55em;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus,
.set-item-select:focus,
.set-item-note-title:focus,
.set-add-search input:focus {
  outline: 2px solid var(--accent-ring);
  border-color: var(--accent);
}

.form-help {
  font-size: 12px;
  color: var(--text-subtle);
}

.form-books {
  border: none;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 8em));
  gap: 0.5rem 1rem;
}

.form-books legend {
  margin-bottom: 0.25rem;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
}

.form-danger-zone {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.flashed-messages > div {
  padding: 0.6rem 1rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
  font-size: 13px;
}

/* ChordPro textarea beside its live preview */
.chordpro-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: stretch;
}

.chordpro-editor-input {
  font-family: var(--font-code) !important;
  font-size: 13px !important;
  line-height: 1.5;
  tab-size: 4;
  resize: vertical;
  min-height: 30em;
}

.chordpro-editor-preview {
  overflow: auto;
  max-height: 46em;
}

/* ── Set editor ── */

.set-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.set-items-empty {
  color: var(--text-subtle);
  padding: 0.75rem 0;
}

.set-item {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
}

.set-item.is-dragging {
  border-style: dashed;
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* While sorting, keep the grab cursor and don't select text along the way. */
html.is-sorting,
html.is-sorting * {
  cursor: grabbing !important;
  user-select: none;
}

.set-item-handle {
  cursor: grab;
  color: var(--text-faint);
  font: inherit;
  font-size: 18px;
  line-height: 1.6;
  padding: 0 0.15em;
  border: none;
  border-radius: 4px;
  background: none;
  user-select: none;
  touch-action: none; /* a touch on the handle drags, rather than scrolls */
}

.set-item-handle:hover,
.set-item-handle:focus-visible {
  color: var(--accent);
}

.set-item-order {
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
  min-width: 1.6em;
  line-height: 2.1;
}

.set-item-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #856404;
  background: #fff8e1;
  border-radius: 3px;
  padding: 0.2em 0.5em;
  margin-top: 0.45em;
}

.set-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1rem;
}

.set-item--note .set-item-body {
  flex-direction: column;
  align-items: stretch;
}

.set-item-title {
  flex: 1 1 14em;
  min-width: 0;
  line-height: 2.1;
}

.set-item-artist {
  color: var(--text-subtle);
  font-size: 12px;
  margin-left: 0.5em;
}

.set-item-controls {
  display: flex;
  gap: 0.4rem;
}

.set-item-select {
  width: auto;
  font-size: 13px;
  padding: 0.3em 0.4em;
}

.set-item-note-heading {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.set-item-note-editor {
  background: var(--surface);
}

.set-item-note-editor .ql-editor {
  min-height: 5em;
  font-size: 14px;
}

.set-item-note-text {
  width: 100%;
  font: inherit;
  padding: 0.4em;
}

.set-item-actions {
  display: flex;
  gap: 0.15rem;
}

.set-item-btn {
  font: inherit;
  font-size: 13px;
  width: 2em;
  height: 2em;
  border: 1px solid transparent;
  border-radius: 4px;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}

.set-item-btn:hover:not(:disabled) {
  border-color: var(--border-strong);
  color: var(--accent);
}

.set-item-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.set-add {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
  align-items: flex-start;
}

.set-add-search {
  position: relative;
  flex: 1;
  max-width: 32em;
}

.set-add-results {
  position: absolute;
  z-index: 10;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  max-height: 22em;
  overflow-y: auto;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.set-add-result {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
}

.set-add-result.active {
  background: var(--accent-tint);
}

.set-add-result--variant {
  padding-left: 1.6rem;
  font-style: italic;
}

.set-add-result--variant::before {
  content: "↳";
  color: var(--text-faint);
  font-style: normal;
}

.set-add-result-artist {
  color: var(--text-subtle);
  font-size: 12px;
}

.set-add-result-key {
  margin-left: auto;
  font-weight: 600;
  font-size: 12px;
}

.set-add-none {
  padding: 0.5rem 0.6rem;
  color: var(--text-subtle);
}

/* ── Responsive / Mobile ── */

@media (max-width: 640px) {
  /* ── Header ──
     Allow the single-row flex container to wrap so nav links,
     the external link, and the selectors don't overflow. */
  .header .container {
    height: auto;
    min-height: 48px;
    flex-wrap: wrap;
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
    gap: 0.4rem;
  }

  .header nav {
    width: 100%;
    height: auto;
    gap: 0;
  }

  .header nav a {
    padding: 0 0.6rem;
    height: 36px;
    font-size: 13px;
  }

  .header nav .logo {
    height: auto;
    padding: 0.2rem 0.6rem 0.2rem 0;
  }

  .nav-selectors {
    border-left: none;
    padding-left: 0;
    gap: 0.3rem;
  }

  /* ── Main ── */
  .main {
    padding: 0.75rem 0.5rem;
  }

  /* ── Tables ──
     The sticky thead uses `top: 56px` (fixed header height).
     On mobile the header wraps and is taller, so disable sticky
     thead to prevent it overlapping content at the wrong offset. */
  thead td,
  thead th {
    position: static;
  }

  /* Tighter cell padding on small screens */
  table td,
  table th {
    padding: 0.3em 0.5em;
  }

  /* Wrap the table in a scrollable container.
     The songs list has 12 columns; only the first 3 are shown
     (Name/Date, Artist/Name, Key/Song). The sets list has 4
     columns; col 4 (Key) is hidden so Date/Name/Song remain. */
  .complete {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .complete table td:nth-child(n+4),
  .complete table th:nth-child(n+4) {
    display: none;
  }

  /* ── Song / Set view header ──
     Stack title above action links on mobile. */
  .song-header {
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
  }

  .song-title {
    font-size: 1.25rem;
  }

  /* ── Key selector ──
     Smaller buttons so all 12 keys fit on narrow screens. */
  .song-key-selector {
    gap: 0.35rem;
  }

  .key-buttons {
    gap: 0.2rem;
  }

  .key-btn {
    font-size: 10px;
    padding: 0.3em 0.45em;
  }

  /* ── In-page nav: stacks above the content instead of sticking ── */
  .page-with-nav {
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
  }

  .page-nav {
    grid-column: 1;
    position: static;
    max-height: none;
  }

  .page-main {
    grid-row: 2;
  }

  /* Song view: nav goes below the song instead */
  .page-with-nav--nav-below .page-main {
    grid-row: 1;
  }

  .page-with-nav--nav-below .page-nav {
    grid-row: 2;
  }

  /* ── Set view: song dividers ── */
  .set-song + .set-song {
    margin-top: 2rem;
    padding-top: 2rem;
  }

  /* ── Song sheet ──
     Tighter padding; horizontal scroll lets wide chord sheets
     stay readable without breaking the monospace alignment. */
  .song-sheet {
    padding: 0.75rem;
    overflow-x: auto;
  }

  .chordpro {
    font-size: 12px;
    min-width: max-content;
  }

  /* ── Edit forms: one column ── */
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-field--wide {
    grid-column: 1 / -1;
  }

  .form-books {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .chordpro-editor {
    grid-template-columns: minmax(0, 1fr);
  }

  .chordpro-editor-input {
    min-height: 18em;
  }

  .set-item {
    flex-wrap: wrap;
  }

  .set-add {
    flex-wrap: wrap;
  }

  .import-item {
    flex-wrap: wrap;
  }

  .import-item-choice {
    width: 100%;
  }
}
