/* Noten's own styles, on top of Bootstrap 5 (static/vendor/bootstrap). Bootstrap does the
   general look (navbar, cards, buttons, forms) and the light/dark themes
   (data-bs-theme on <html>, see js/theme.js); this file only styles the app's own
   components, with Bootstrap's color variables so they follow the theme. The Noten app
   (client/) loads the same two files. */

:root {
  --noten-accent: #4f8cff;
  --noten-note: #e00000;
  --noten-shared-note: #1f5fd6;
  --noten-mark: #e08a00;
}

[data-bs-theme="dark"] {
  --noten-shared-note: #6f9dff;
}

/* The footer (imprint, privacy policy, feedback) stays at the window's bottom on short
   pages: the body is a column whose main takes the room left. Its box is never taller
   than a tenth of the window, so its top never comes above 90% of the window's height
   (a line wrapping on a low window spills below it, the page scrolling a little). Main
   and footer are .container-xxl, whose auto margins would shrink a flex item to its
   content, hence the width. */
body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

body > main {
  flex: 1 0 auto;
  width: 100%;
}

body > .site-footer {
  flex-shrink: 0;
  width: 100%;
  max-height: 10vh;
  max-height: 10dvh;
}

main {
  padding-bottom: 3rem;
}

.navbar-brand .bi {
  color: var(--noten-accent);
}

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

/* --- Overview tiles (home page, library) --- */

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  flex-wrap: wrap;
  margin: 2rem 0 0.75rem;
}

.section-head h2 {
  font-size: 1.25rem;
  margin: 0;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: 1rem;
}

.tile {
  height: 100%;
  overflow: hidden;
  transition: border-color 0.15s;
}

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

/* The top third of the piece's first page, always on white like paper. */
.tile-preview {
  display: block;
  aspect-ratio: 2 / 1;
  background: #fff;
  border-bottom: 1px solid var(--bs-border-color);
  overflow: hidden;
}

.tile-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.tile-preview.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bs-tertiary-bg);
  color: var(--bs-secondary-color);
  font-size: 2rem;
}

.tile .card-body {
  padding: 0.6rem 0.75rem 0.75rem;
}

.tile-title {
  font-weight: 600;
  line-height: 1.25;
  margin-bottom: 0.15rem;
}

.tile-title a {
  color: inherit;
  text-decoration: none;
}

.tile-sub {
  font-size: 0.85rem;
  color: var(--bs-secondary-color);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.5rem;
}

.voice-links .btn {
  --bs-btn-padding-y: 0.1rem;
  --bs-btn-padding-x: 0.45rem;
  --bs-btn-font-size: 0.8rem;
}

.setlist-tile .tile-preview {
  aspect-ratio: 3 / 1;
}

/* --- The search banner (search_bar.js, templates/_search.html): a text box, filter chips
   under it, a chip's list of values dropping down from it. --- */

.search-banner {
  position: relative;
  margin-bottom: 1rem;
}

.search-box {
  position: relative;
  max-width: 40rem;
}

.search-box > .bi-search {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--bs-secondary-color);
  pointer-events: none;
}

.search-box input {
  padding-left: 2.4rem;
}

.search-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.search-chip,
.search-chip-group > .btn {
  border-radius: 50rem;
}

.search-chip-group > .search-chip {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.search-chip-group > .search-chip-clear {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.35);
  padding-inline: 0.45rem;
}

.search-chip .bi-chevron-down {
  font-size: 0.7em;
  margin-left: 0.15rem;
}

.search-pop {
  position: absolute;
  z-index: 1060;
  width: min(22rem, 100%);
  max-height: min(60vh, 26rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.5rem;
}

/* "Show n pieces": stays in view at the list's foot while it scrolls. */
.search-pop-done {
  position: sticky;
  bottom: 0;
  margin-top: 0.5rem;
}

.search-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: 0;
  border-radius: var(--bs-border-radius);
  background: none;
  color: inherit;
  text-align: start;
}

.search-option:hover,
.search-option:focus-visible {
  background: var(--bs-tertiary-bg);
}

.search-option.chosen .bi {
  color: var(--bs-primary);
}

.search-option-label {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.search-option-count {
  color: var(--bs-secondary-color);
  font-size: 0.85em;
  font-variant-numeric: tabular-nums;
}

/* --- The Library page's views (library_views.js): the Tiles / Details / Table switch and
   its toolbar, the Details tree, and the Table with toggleable and special columns. --- */

.library-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.library-view-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* Details: a piece, then its voices (a file manager's details view). */
.library-details {
  display: flex;
  flex-direction: column;
}

.lib-detail + .lib-detail {
  border-top: 1px solid var(--bs-border-color);
}

.lib-detail-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.4rem 0.25rem;
}

.lib-detail-head.expandable {
  cursor: pointer;
  border-radius: var(--bs-border-radius);
}

.lib-detail-head.expandable:hover {
  background: var(--bs-tertiary-bg);
}

.lib-caret {
  flex: 0 0 auto;
  width: 1.5rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--bs-secondary-color);
}

.lib-detail-title {
  font-weight: 600;
  color: inherit;
  text-decoration: none;
}

.lib-detail-title:hover {
  text-decoration: underline;
}

.lib-detail-meta {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
}

.lib-detail-pages {
  flex: 0 0 auto;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.lib-detail-voices {
  display: flex;
  flex-direction: column;
  padding: 0 0 0.3rem 2.2rem;
}

.lib-voice-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
  color: inherit;
  text-decoration: none;
  border-radius: var(--bs-border-radius);
}

.lib-voice-row:hover {
  background: var(--bs-tertiary-bg);
}

.lib-voice-name {
  flex: 1 1 auto;
}

.lib-voice-pages {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

/* Table: the metadata as a grid. */
.library-table-wrap {
  overflow-x: auto;
}

.library-table {
  margin-bottom: 0;
}

.library-table th {
  white-space: nowrap;
  vertical-align: bottom;
}

.library-table .lib-col-title {
  font-weight: 600;
}

.library-table .lib-col-title a {
  color: inherit;
  text-decoration: none;
}

.library-table .lib-col-title a:hover {
  text-decoration: underline;
}

.lib-sort {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
}

.lib-sort:hover {
  color: var(--bs-primary);
}

.lib-voices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
}

.lib-voice-link {
  text-decoration: none;
}

.lib-col-has .bi {
  font-size: 1.05rem;
}

.lib-special-head {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.lib-filter,
.lib-col-rm {
  padding: 0 0.15rem;
  border: 0;
  background: none;
  color: var(--bs-secondary-color);
  line-height: 1;
}

.lib-filter-include {
  color: var(--bs-success);
}

.lib-filter-exclude {
  color: var(--bs-danger);
}

.lib-col-rm:hover {
  color: var(--bs-danger);
}

.lib-col-add {
  width: 1px; /* shrink to the + button */
}

/* The column picker and the + chooser. */
.library-pop {
  position: absolute;
  z-index: 1060;
  width: min(20rem, calc(100vw - 1rem));
  max-height: min(60vh, 24rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.5rem;
}

.library-pop-head {
  font-weight: 600;
  padding: 0.15rem 0.35rem 0.4rem;
}

.library-pop-facets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.4rem;
}

.library-pop-values {
  display: flex;
  flex-direction: column;
  margin-top: 0.4rem;
}

.library-pop-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: 0;
  border-radius: var(--bs-border-radius);
  background: none;
  color: inherit;
  text-align: start;
}

.library-pop-row:hover,
.library-pop-row:focus-visible {
  background: var(--bs-tertiary-bg);
}

/* --- Upload --- */

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem 1rem;
  border: 2px dashed var(--bs-border-color);
  border-radius: var(--bs-border-radius-lg);
  background: var(--bs-tertiary-bg);
  text-align: center;
  max-width: 520px;
  transition: border-color 0.15s, background 0.15s;
}

.drop-zone.drag-over {
  border-color: var(--noten-accent);
  background: color-mix(in srgb, var(--noten-accent) 12%, var(--bs-tertiary-bg));
}

.drop-zone-hint {
  margin: 0;
  color: var(--bs-secondary-color);
}

.selected-files {
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
  max-width: 360px;
  text-align: left;
}

.selected-files li {
  padding: 0.2rem 0;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

#zoom-label {
  font-size: 0.85rem;
  color: var(--bs-secondary-color);
  min-width: 3.5rem;
  text-align: center;
}

/* --- Sorting pages (upload_sort.js): unsorted pages left, pieces right --- */

#sort {
  --sort-thumb: 100px;
}

.sort-layout {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: 1.25rem;
  align-items: start;
}

/* On a wide enough screen the page itself doesn't scroll: it fills the window, and each
   side (and the chat) scrolls on its own, so both stay in view while dragging between them
   and scrolling one never moves the others. */
.sort-panel {
  padding: 0 0.25rem 0.5rem;
}

@media (min-width: 801px) and (min-height: 480px) {
  body.sort-page {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  body.sort-page > main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding-bottom: 0.75rem;
  }

  body.sort-page #sort {
    flex: 1;
    min-height: 0;
  }

  body.sort-page .sort-workspace,
  body.sort-page .sort-layout {
    height: 100%;
  }

  body.sort-page .sort-layout {
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
  }

  body.sort-page .sort-panel {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

.sort-panel-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0;
  margin-bottom: 0.5rem;
  background: var(--bs-body-bg);
  border-bottom: 1px solid var(--bs-border-color);
}

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

}

.sort-unsorted.drop-over {
  outline: 2px dashed var(--noten-accent);
  outline-offset: -2px;
}

/* Dropping PDF/image files from the computer onto the sorting page (upload_sort.js): the
   target zone lights up like an internal page drag; this is the upload's progress bar. */
.sort-upload-progress {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1085;
  width: min(360px, calc(100vw - 2rem));
  padding: 0.75rem 1rem;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  box-shadow: var(--bs-box-shadow);
}

.sort-group {
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  margin-bottom: 0.5rem;
}

.sort-group-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  min-width: 0;
}

.sort-group-toggle {
  min-width: 0;
}

.sort-group-toggle:disabled {
  opacity: 0.6;
}

.sort-grid,
.sort-zone-pages {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--sort-thumb), 1fr));
  gap: 0.4rem;
}

.sort-grid {
  padding: 0 0.5rem 0.5rem;
}

.sort-thumb {
  position: relative;
  margin: 0;
  border: 2px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  padding: 0.15rem;
  background: #fff;
  color: #555;
  font-size: 0.72rem;
  min-width: 0;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.sort-thumb:focus-visible {
  outline: 2px solid var(--noten-accent);
  outline-offset: 1px;
}

.sort-thumb.selected {
  border-color: var(--noten-accent);
  box-shadow: 0 0 0 2px var(--noten-accent) inset;
  background: color-mix(in srgb, var(--noten-accent) 12%, #fff);
}

.sort-thumb.dragging {
  opacity: 0.35;
}

/* Where the dragged pages would go: in front of this one. */
.sort-thumb.insert-before::before {
  content: "";
  position: absolute;
  left: -0.3rem;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 2px;
  background: var(--noten-accent);
}

.sort-thumb-img {
  position: relative;
}

.sort-thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1.414;
  object-fit: contain;
  background: #f4f4f4;
}

.sort-thumb img[src] {
  background: none;
}

/* ⤢ ↺ ↻ over the page: on hover, always on touch screens. */
.sort-thumb-tools {
  position: absolute;
  top: 0.15rem;
  right: 0.15rem;
  display: flex;
  gap: 0.1rem;
  opacity: 0;
  transition: opacity 0.15s;
}

.sort-thumb-tools .btn {
  font-size: 0.7rem;
  line-height: 1.2;
}

.sort-thumb:hover .sort-thumb-tools,
.sort-thumb-tools:focus-within {
  opacity: 1;
}

@media (hover: none) {
  .sort-thumb-tools {
    opacity: 1;
  }
}

.sort-turned {
  position: absolute;
  left: 0.15rem;
  bottom: 0.15rem;
  font-size: 0.6rem;
}

.sort-thumb figcaption {
  display: flex;
  gap: 0.3rem;
  padding-top: 0.1rem;
  min-width: 0;
}

.sort-new-piece {
  flex: 1 1 14rem;
  max-width: 22rem;
}

.chip-field-sm {
  padding: 0.1rem 0.2rem;
}

.chip-field-sm input {
  font-size: 0.875rem;
  padding: 0.15rem 0.25rem;
}

.chip-field-sm .chips:not(:empty) {
  margin-bottom: 0.1rem;
}

.chip-field-sm .chip {
  font-size: 0.8rem;
  padding: 0.05rem 0.45rem;
}

.sort-piece.drop-over,
.sort-zone.drop-over,
.sort-new-target.drop-over,
.sort-dropped.drop-over {
  border-color: var(--noten-accent);
  box-shadow: 0 0 0 2px var(--noten-accent);
}

.sort-title {
  flex: 1 1 12rem;
  min-width: 10rem;
}

.sort-piece-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem;
}

.sort-tag {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1 1 12rem;
  min-width: 0;
}

.sort-tag .chip-field {
  flex: 1;
  min-width: 0;
}

/* A piece's fields on the board (fields.py): the library's fields and the copyright notice. */
.sort-piece-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.sort-field {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1 1 9rem;
  min-width: 7rem;
}

.sort-field-input {
  position: relative;
  flex: 1;
  min-width: 0;
}

/* Wider than a narrow field when its values need it. */
.sort-field-input .suggestions {
  right: auto;
  min-width: 100%;
  white-space: nowrap;
}

.sort-field-label {
  font-size: 0.8rem;
  color: var(--bs-secondary-color);
  white-space: nowrap;
}

.sort-field-copyright {
  flex: 2 1 18rem;
}

.sort-field-copyright select {
  flex: 0 1 auto;
  width: auto;
  max-width: 14rem;
}

/* Shown under a piece's title: its fields and copyright notice (_fields.html). */
.copyright-line .bi {
  margin-right: 0.15rem;
}

.sort-zones {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sort-zone {
  border: 1px dashed var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  padding: 0.35rem 0.45rem 0.45rem;
}

.sort-zone-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
  min-width: 0;
}

.sort-zone-voice {
  flex: 0 1 14rem;
}

.sort-zone-new {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.45rem;
}

.sort-zone-empty {
  grid-column: 1 / -1;
  color: var(--bs-secondary-color);
  font-size: 0.8rem;
  padding: 0.4rem 0;
  text-align: center;
}

.sort-zone-new .sort-zone-empty {
  padding: 0;
}

.sort-new-target {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border: 2px dashed var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  color: var(--bs-secondary-color);
  text-align: center;
  font-size: 0.9rem;
}

.sort-dropped .sort-zone-pages {
  min-height: 2.5rem;
}

/* While dragging: "Not kept" at the bottom of the window. */
.sort-trash-target {
  display: none;
  position: fixed;
  left: 50%;
  bottom: 1rem;
  z-index: 1500;
  transform: translateX(-50%);
  padding: 0.6rem 1.5rem;
  border: 2px dashed var(--bs-danger);
  border-radius: 999px;
  background: var(--bs-body-bg);
  color: var(--bs-danger-text-emphasis);
  box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.25);
}

body.sort-dragging .sort-trash-target {
  display: block;
}

.sort-trash-target.drop-over {
  background: var(--bs-danger-bg-subtle);
}

/* The pages being dragged, under the pointer. */
.sort-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 2000;
  pointer-events: none;
  width: 60px;
}

.sort-ghost img {
  display: block;
  width: 100%;
  border: 2px solid var(--noten-accent);
  border-radius: var(--bs-border-radius);
  background: #fff;
  box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.3);
}

.sort-ghost .badge {
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
}

body.sort-dragging,
body.sort-dragging * {
  cursor: grabbing !important;
  user-select: none;
}

/* The chat: a column on the right that slides in, the two lists making room for it. Its
   inside keeps its width while the column grows, so nothing reflows during the slide. */
.sort-workspace {
  --sort-chat-width: 380px;
  display: flex;
  align-items: stretch;
}

.sort-workspace > .sort-layout {
  flex: 1;
  min-width: 0;
}

.sort-chat {
  flex: 0 0 auto;
  width: 0;
  overflow: hidden;
  transition: width 0.35s ease, margin-left 0.35s ease;
}

.sort-chat-inner {
  width: var(--sort-chat-width);
  height: 100%;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s ease;
}

#sort.chat-open .sort-chat {
  width: var(--sort-chat-width);
  margin-left: 1.25rem;
}

#sort.chat-open .sort-chat-inner {
  transform: none;
}

@media (max-width: 1100px) {
  .sort-workspace {
    --sort-chat-width: 320px;
  }
}

/* Small screens: no room beside the lists, so it comes over them. */
@media (max-width: 800px) {
  .sort-chat,
  #sort.chat-open .sort-chat {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1040;
    width: min(100vw, 420px);
    height: 100vh;
    margin: 0;
    overflow: visible;
    pointer-events: none;
  }

  .sort-chat-inner {
    width: 100%;
    border-radius: 0;
    box-shadow: -0.5rem 0 1.5rem rgba(0, 0, 0, 0.3);
  }

  #sort.chat-open .sort-chat-inner {
    pointer-events: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sort-chat,
  .sort-chat-inner {
    transition: none;
  }
}

.sort-chat-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* The AI at work: music notes going up and down in a wave. */
.sort-thinking {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* dialogs.js: questions drawn in the page (the desktop app) in place of confirm()/alert(). */
.noten-dialog {
  max-width: min(28rem, calc(100vw - 2rem));
  padding: 1.25rem;
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius-lg);
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  box-shadow: var(--bs-box-shadow-lg);
}
.noten-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}
.noten-dialog-text {
  margin-bottom: 1.25rem;
  white-space: pre-line;
}
.noten-dialog-buttons {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.sort-notes {
  display: inline-flex;
  gap: 0.15rem;
  height: 1.6rem;
  align-items: flex-end;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--noten-accent);
}

.sort-notes span {
  display: inline-block;
  animation: sort-note-wave 1.2s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.15s);
}

@keyframes sort-note-wave {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.55;
  }
  50% {
    transform: translateY(-0.55rem);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sort-notes span {
    animation: sort-note-fade 1.6s ease-in-out infinite;
    animation-delay: calc(var(--i) * 0.2s);
  }

  @keyframes sort-note-fade {
    0%,
    100% {
      opacity: 0.4;
    }
    50% {
      opacity: 1;
    }
  }
}

.sort-msg {
  max-width: 90%;
  padding: 0.4rem 0.7rem;
  border-radius: var(--bs-border-radius-lg);
  white-space: pre-wrap;
}

.sort-msg-user {
  align-self: flex-end;
  background: color-mix(in srgb, var(--noten-accent) 22%, var(--bs-body-bg));
}

.sort-msg-assistant {
  align-self: flex-start;
  background: var(--bs-secondary-bg);
}

.sort-msg-note {
  align-self: center;
  font-size: 0.85rem;
  color: var(--bs-secondary-color);
}

/* The large view: full screen, like a gallery — the page as tall as the screen, what it is
   in a column beside it, ←/→ at the screen's edges. */
.sort-large {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #111;
  color: #eee;
}

.sort-large[open] {
  display: flex;
}

.sort-large::backdrop {
  background: #111;
}

.sort-large-stage {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.sort-large-stage img {
  display: block;
  height: 100vh;
  max-width: 100%;
  object-fit: contain;
  background: #fff;
}

.sort-large-stage img:not([src]) {
  aspect-ratio: 1 / 1.414;
  background: #2a2a2a;
}

.sort-large-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 3.5rem;
  height: 3.5rem;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, opacity 0.15s;
}

.sort-large-arrow:hover,
.sort-large-arrow:focus-visible {
  background: rgba(0, 0, 0, 0.8);
}

.sort-large-arrow:disabled {
  opacity: 0;
  pointer-events: none;
}

.sort-large-prev {
  left: 1rem;
}

.sort-large-next {
  right: 1rem;
}

.sort-large-info {
  flex: 0 0 22rem;
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  background: #1c1c1c;
  border-left: 1px solid #333;
  overflow-y: auto;
}

.sort-large-info .text-body-secondary {
  color: #aaa !important;
}

.sort-large-facts dt {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #999;
}

.sort-large-facts dd {
  margin-bottom: 0.9rem;
  overflow-wrap: anywhere;
}

.sort-large-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.sort-large-actions:not(:has(> :not([hidden]))) {
  display: none;
}

/* The side panel's fields (a piece's page). */
.sort-large-edit {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 0.75rem 0 1rem;
}

.sort-large-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sort-large-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #999;
}

.sort-large-edit .sort-title,
.sort-large-edit .sort-zone-voice {
  flex: none;
  min-width: 0;
}

.sort-large-edit .form-select {
  width: 100% !important;
}

/* A tag filing adds to an existing piece (next to its own). */
.chip.chip-adding {
  border-color: var(--noten-accent);
  border-style: dashed;
}

.chip.chip-adding::before {
  content: "+";
  font-weight: 600;
  color: var(--noten-accent);
}

/* Over the page's foot: Trash and Correct. */
.sort-large-bar {
  position: absolute;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  display: flex;
  gap: 0.75rem;
  padding: 0.5rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  white-space: nowrap;
}

.sort-large-bar .btn {
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.sort-large-bar:not(:has(> :not([hidden]))) {
  display: none;
}

.sort-large-info #large-status a {
  color: #9ec5fe;
}

/* Beside the page: all of its voice's pages, small (upload_sort.js drawStrip sets the
   columns and width so they fit the screen's height where they can). */
.sort-large-strip {
  flex: none;
  display: grid;
  grid-template-columns: repeat(var(--strip-cols, 1), var(--strip-w, 7rem));
  align-content: safe center;
  gap: 0.5rem;
  padding: 0.75rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #161616;
  border-right: 1px solid #333;
}

.sort-large-strip[hidden] {
  display: none;
}

.sort-large-strip-head {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.5rem;
  min-width: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: #aaa;
  white-space: nowrap;
}

.sort-large-strip-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sort-large-strip-count {
  flex: none;
  margin-left: auto;
  font-weight: 400;
  color: #888;
}

.sort-large-strip-page {
  position: relative;
  display: block;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 4px;
  background: none;
  opacity: 0.75;
  transition: opacity 0.15s, border-color 0.15s;
}

.sort-large-strip-page:hover,
.sort-large-strip-page:focus-visible {
  opacity: 1;
}

.sort-large-strip-page.current {
  border-color: var(--noten-accent);
  opacity: 1;
}

.sort-large-strip-page img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1.414;
  object-fit: contain;
  background: #fff;
  border-radius: 2px;
}

.sort-large-strip-page img:not([src]) {
  background: #2a2a2a;
}

.sort-large-strip-n {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 0 0.3rem;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.7rem;
  line-height: 1.4;
}

/* Portrait screens: the page on top, what it is in a band below. */
@media (max-aspect-ratio: 1/1) {
  .sort-large[open] {
    flex-direction: column;
  }

  .sort-large-stage img {
    height: auto;
    max-height: 55vh;
    width: auto;
  }

  .sort-large-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }

  /* The voice's pages: a row under the page. */
  .sort-large-strip {
    order: 1;
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 4rem;
    justify-content: safe center;
    align-content: start;
    padding: 0.4rem 0.75rem;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: 0;
    border-top: 1px solid #333;
  }

  .sort-large-strip-head {
    display: none;
  }

  .sort-large:has(.sort-large-strip:not([hidden])) .sort-large-stage img {
    max-height: calc(55vh - 6.5rem);
  }

  .sort-large-info {
    order: 2;
    flex: 0 0 auto;
    max-height: 45vh;
    border-left: 0;
    border-top: 1px solid #333;
    padding: 0.75rem 1rem;
  }

  .sort-large-info h2 {
    margin: 0.25rem 0 0.5rem !important;
    font-size: 1.1rem;
  }

  .sort-large-facts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0 0.75rem;
    margin: 0;
  }

  .sort-large-facts dd {
    margin-bottom: 0.2rem;
  }

  .sort-large-info > p:last-child {
    display: none;
  }
}

/* --- Toasts (toasts.js): short notices in a corner, over the page --- */

.noten-toasts {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1090;
  width: max-content;
  max-width: min(28rem, calc(100vw - 2rem));
  pointer-events: none;
}

.noten-toast {
  margin: 0;
  pointer-events: auto;
  box-shadow: var(--bs-box-shadow);
  animation: noten-toast-in 0.2s ease-out;
  transition: opacity 0.25s, transform 0.25s;
}

.noten-toast.leaving {
  opacity: 0;
  transform: translateY(0.5rem);
}

@keyframes noten-toast-in {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
}

@media (max-width: 575.98px) {
  .noten-toasts {
    left: 1rem;
    width: auto;
    max-width: none;
  }
}

.chip .badge {
  font-size: 0.65rem;
}

/* --- Autocomplete / chips (chips.js) --- */

.chip-field {
  position: relative;
  border: var(--bs-border-width) solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  padding: 0.3rem;
  background: var(--bs-body-bg);
}

.chip-field:focus-within {
  border-color: var(--noten-accent);
  box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--noten-accent) 25%, transparent);
}

.chip-field input {
  border: none;
  outline: none;
  width: 100%;
  padding: 0.25rem;
  font-size: 1rem;
  background: transparent;
  color: var(--bs-body-color);
}

.chips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0;
  margin: 0;
}

.chips:not(:empty) {
  margin-bottom: 0.25rem;
}

.chip {
  background: var(--bs-secondary-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.9rem;
}

.chip button {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  color: inherit;
}

.suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 1000;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  box-shadow: var(--bs-box-shadow);
  list-style: none;
  margin: 2px 0 0;
  padding: 0.2rem 0;
  max-height: 240px;
  overflow-y: auto;
}

.suggestions li {
  padding: 0.35rem 0.6rem;
  cursor: pointer;
}

.suggestions li.active,
.suggestions li:hover {
  background: var(--bs-tertiary-bg);
}

/* --- Viewer --- */

.viewer-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.viewer-page-count-controls,
.viewer-zoom-controls,
.viewer-annotate-controls,
.viewer-page-controls:not([hidden]) {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.page-count-btn.active,
.annotate-tool-btn.active {
  color: #fff;
}

.page-count-btn.active {
  background: var(--noten-accent);
  border-color: var(--noten-accent);
}

.annotate-tool-btn.active {
  background: var(--noten-note);
  border-color: var(--noten-note);
}

#page-label {
  min-width: 6rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

#annotate-status {
  font-size: 0.8rem;
  color: var(--bs-secondary-color);
}

#annotate-status.error {
  color: var(--bs-danger-text-emphasis);
}

/* Pages are centered with "safe" alignment throughout: centered while they fit, but
   start-aligned once zoomed past the frame — plain "center" would push the overflow past
   the left/top edge, where scrolling can't reach it. (The plain value is the fallback for
   browsers without "safe".) */
#viewer-canvas-wrap {
  display: flex;
  justify-content: center;
  justify-content: safe center;
  align-items: flex-start;
  gap: 1rem;
  overflow: auto;
  max-height: 82vh;
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  background: var(--bs-tertiary-bg);
  /* Horizontal swipes turn pages... */
  touch-action: pan-y;
}

/* ...unless a zoomed page is wider than the frame: then a finger pans it sideways, and
   swipes only turn the page from the edge (viewer.js updatePannable). */
#viewer-canvas-wrap.pannable-x {
  touch-action: pan-x pan-y;
}

#viewer-canvas-wrap.halves-mode {
  flex-direction: column;
  align-items: center;
  align-items: safe center;
  gap: 0;
}

/* Only shown when the top and bottom slots come from different pages — no seam needed
   when both halves belong to the same page. */
#page-canvas-2.half-divider {
  border-top: 1px solid var(--bs-border-color);
}

#page-canvas,
#page-canvas-2,
#page-canvas-3 {
  display: block;
}

#viewer:fullscreen {
  display: flex;
  flex-direction: column;
  background: #000;
  color: #fff;
  padding: 0.75rem;
}

#viewer:fullscreen .viewer-toolbar {
  flex: none;
  margin-bottom: 0.5rem;
}

#viewer:fullscreen #viewer-canvas-wrap {
  flex: 1;
  max-height: none;
  border: none;
  background: #000;
  display: flex;
  align-items: center;
  align-items: safe center;
  justify-content: center;
  justify-content: safe center;
  gap: 1rem;
  /* Scrollable once zoomed in past the screen. */
  overflow: auto;
}

#viewer:fullscreen #viewer-canvas-wrap.halves-mode {
  flex-direction: column;
  gap: 0;
}

/* Touchscreen device (no hover, coarse pointer — i.e. phone/tablet, not mouse/trackpad)
   in fullscreen and rotated to landscape: put the toolbar in a sidebar on the left instead
   of a top bar, since a wide-short screen has little spare height for it up top. */
@media (hover: none) and (pointer: coarse) and (orientation: landscape) {
  #viewer:fullscreen {
    flex-direction: row;
  }

  #viewer:fullscreen .viewer-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    margin-bottom: 0;
    margin-right: 0.75rem;
    max-width: 140px;
    overflow-y: auto;
  }

  #viewer:fullscreen .viewer-zoom-controls,
  #viewer:fullscreen .viewer-page-count-controls {
    flex-wrap: wrap;
  }
}

/* Each page canvas sits in a slot with its notes SVG laid exactly over it (viewer.js wraps
   the canvases at startup). */
.page-slot {
  position: relative;
  flex: none;
  line-height: 0;
}

.page-slot > svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

/* A drawing tool is active: the overlay takes the pointer (and touch, so a finger draws
   instead of scrolling/swiping). */
#viewer-canvas-wrap.drawing .page-slot > svg.annotatable {
  pointer-events: auto;
  touch-action: none;
  cursor: crosshair;
}

#viewer-canvas-wrap.drawing.erasing .page-slot > svg.annotatable {
  cursor: cell;
}

/* A pen hovering over the pages (viewer.js): it writes without a tool picked, so the
   overlays take it and nothing pans under it. */
#viewer-canvas-wrap.pen-near,
#viewer-canvas-wrap.pen-near .page-slot > svg.annotatable {
  touch-action: none;
}

#viewer-canvas-wrap.pen-near .page-slot > svg.annotatable {
  pointer-events: auto;
  cursor: crosshair;
}

/* Switches for notes layers others shared (viewer.js fills them). */
.shared-notes-controls:not([hidden]) {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 0.6rem;
  font-size: 0.85rem;
  color: var(--noten-shared-note);
}

.shared-notes-controls label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
}

.page-mark-btn.active {
  background: var(--noten-mark);
  border-color: var(--noten-mark);
  color: #fff;
}

/* Comments side panel (viewer.js); inside #viewer, so it also shows in fullscreen. */
.comments-panel:not([hidden]) {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1050;
  width: min(22rem, 90vw);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1rem;
  overflow-y: auto;
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  border-left: 1px solid var(--bs-border-color);
  box-shadow: var(--bs-box-shadow-lg);
}

.comments-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.comments-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.comment {
  border-bottom: 1px solid var(--bs-border-color);
  padding-bottom: 0.5rem;
}

.comment-meta {
  font-size: 0.8rem;
  color: var(--bs-secondary-color);
}

.comment-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.comment-actions {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.3rem;
}

.comment textarea {
  width: 100%;
}

.comments-hint {
  font-size: 0.8rem;
}

/* Shown when a notes save hits notes changed elsewhere (viewer.js askWhichNotes). */
.notes-conflict {
  max-width: min(36rem, calc(100vw - 2rem));
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius-lg);
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
}

.notes-conflict::backdrop {
  background: rgb(0 0 0 / 0.5);
}

.notes-conflict-choices {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
}

.notes-conflict-choices figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.notes-conflict-preview {
  position: relative;
  max-width: 100%;
  border: 1px solid var(--bs-border-color);
  background: #fff;
}

.notes-conflict-preview canvas,
.notes-conflict-preview svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* --- Setlists --- */

.setlist-add {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.25rem;
}

.setlist-add .search-banner {
  flex: 1 1 340px;
  min-width: 0;
  margin-bottom: 0;
}

.setlist-items {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: setlist-counter;
}

.setlist-items li {
  counter-increment: setlist-counter;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--bs-border-color);
}

.setlist-items li:last-child {
  border-bottom: none;
}

.setlist-items li::before {
  content: counter(setlist-counter);
  font-weight: 600;
  color: var(--bs-secondary-color);
  min-width: 1.5rem;
}

.setlist-item-title {
  flex: 1;
}

.placeholder-item .setlist-item-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-style: italic;
}

.placeholder-name {
  font: inherit;
  flex: 0 1 20rem;
  min-width: 0;
  padding: 0.2rem 0.4rem;
  border: 1px dashed var(--bs-border-color);
  border-radius: var(--bs-border-radius-sm);
  background: transparent;
  color: inherit;
}

.placeholder-note {
  font-size: 0.85em;
  color: var(--bs-secondary-color);
  white-space: nowrap;
}

.setlist-item-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* --- Downloads (/downloads) --- */

.download-list {
  list-style: none;
  padding: 0;
}

.download-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--bs-border-color);
}

.download-hint {
  flex-basis: 100%;
}

/* --- Associations --- */

.how-it-works .bi {
  font-size: 1.5rem;
  color: var(--noten-accent);
}

.invite-link {
  font-family: var(--bs-font-monospace);
}

/* --- The Noten app's own pages (client/www), which share this file --- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--bs-border-color);
  margin-bottom: 1rem;
  background: var(--bs-tertiary-bg);
}

.topbar .brand {
  font-weight: 700;
  font-size: 1.2rem;
  text-decoration: none;
  color: inherit;
}

.app-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 24rem;
}

/* --- Camera scan (upload/new.html, upload_scan.js) --- */
.scan-thumb {
  position: relative;
  aspect-ratio: 3 / 4;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bs-tertiary-bg);
  border-radius: var(--bs-card-inner-border-radius) var(--bs-card-inner-border-radius) 0 0;
  overflow: hidden;
}

.scan-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #fff;
}

.scan-spinner {
  position: absolute;
}

.scan-number {
  position: absolute;
  top: 0.35rem;
  left: 0.35rem;
}

/* --- Profile pictures (avatars.py) --- */

.avatar {
  border-radius: 50%;
  object-fit: cover;
  background: var(--bs-secondary-bg);
}

.avatar-sm {
  width: 1.5em;
  height: 1.5em;
  vertical-align: -0.4em;
}

.avatar-lg {
  width: 4.5rem;
  height: 4.5rem;
  flex: none;
}

i.avatar-lg {
  font-size: 4.5rem;
  line-height: 1;
}

/* --- Footer: the imprint --- */

.site-footer {
  padding: 0.75rem 0.75rem 1rem;
  font-size: 0.85rem;
  line-height: 1.5;
  text-align: center;
}

.site-footer a {
  color: var(--bs-secondary-color);
}

.site-footer-sep {
  margin: 0 0.5rem;
  color: var(--bs-secondary-color);
}

/* The newsletter on the website (newsletter/archive.html, show.html). */
.newsletter-page {
  max-width: 40rem;
}

.newsletter-body {
  overflow-wrap: anywhere;
}

.newsletter-teaser {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Feedback as sent (admin/feedback.html): its line breaks kept. */
.feedback-message {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* The sorting page fills the window exactly. */
body.sort-page .site-footer {
  display: none;
}

.imprint {
  max-width: 36rem;
}

.privacy {
  max-width: 44rem;
}

/* The navbar's EN | DE switch. */
.language-switch {
  display: flex;
}

.language-switch .nav-link {
  padding-left: 0.3rem;
  padding-right: 0.3rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.language-switch .nav-link:not(.active) {
  opacity: 0.6;
}

/* --- The welcome page (welcome.html): Noten for visitors without an account --- */

.welcome {
  --welcome-panel: color-mix(in srgb, var(--noten-accent) 7%, var(--bs-tertiary-bg));
  --welcome-ai: #b07cff;
  margin-top: -1.5rem; /* the navbar's mb-4: the hero starts right under it */
  padding-bottom: 0;
  overflow-x: clip;
}

.welcome > .alert {
  max-width: 1320px;
  margin: 1rem auto;
}

.welcome-hero {
  padding: 4rem 0 4.5rem;
  background:
    radial-gradient(60rem 30rem at 85% 10%, color-mix(in srgb, var(--noten-accent) 22%, transparent), transparent 70%),
    radial-gradient(40rem 24rem at 0% 100%, color-mix(in srgb, var(--welcome-ai) 14%, transparent), transparent 70%);
}

.welcome-title {
  font-size: clamp(2rem, 4.5vw, 3.25rem);
  font-weight: 750;
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-wrap: balance;
  margin-bottom: 1.25rem;
}

.welcome-lead {
  max-width: 36rem;
  font-size: 1.15rem;
  color: var(--bs-secondary-color);
  margin-bottom: 1.75rem;
}

/* A page of sheet music: the real one (an image, cut to A4) or a drawn one. */
.welcome-sheet {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 210 / 297;
  object-fit: cover;
  object-position: top;
  background: #fff;
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

/* The hero's tablet with the piece open (a pen note on it), and the AI's card over it. */
.welcome-stage {
  position: relative;
  max-width: 34rem;
  margin: 0 auto;
  padding: 1rem 1.5rem 2.5rem;
}

.welcome-tablet {
  padding: 0.6rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 1.25rem;
  background: var(--bs-body-bg);
  box-shadow: 0 1.5rem 3rem rgba(0, 0, 0, 0.3);
  transform: rotate(-1.5deg);
}

.welcome-tablet-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.4rem 0.6rem;
  font-size: 0.85rem;
}

.welcome-tablet-pages {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  padding: 0.4rem;
  border-radius: 0.6rem;
  background: #3a3f46;
}

.welcome-noted {
  position: relative;
}

.welcome-pen {
  position: absolute;
  left: 52%;
  top: 30%;
  width: 34%;
  height: 7%;
  border: 2px solid #e00000;
  border-radius: 50%;
  transform: rotate(-4deg);
}

.welcome-float {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.75rem;
  background: var(--bs-body-bg);
  box-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.25);
  font-size: 0.9rem;
}

.welcome-float .bi {
  font-size: 1.3rem;
}

.welcome-float-ai {
  left: 0;
  bottom: 0;
  max-width: 21rem;
}

.welcome-float-ai .bi {
  color: var(--welcome-ai);
}

.welcome-section-title {
  font-size: clamp(1.6rem, 3vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  text-align: center;
  margin-bottom: 1rem;
}

.welcome-section-lead {
  margin: 0 auto 3rem;
  text-align: center;
}

.welcome-step-num {
  display: inline-grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  margin-right: 0.35rem;
  border-radius: 50%;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--welcome-ai);
  vertical-align: 0.15rem;
}

/* The AI: three steps side by side (stacked on phones), each with its picture. */
.welcome-ai {
  padding: 4.5rem 0 4rem;
  background: var(--welcome-panel);
  border-block: 1px solid var(--bs-border-color-translucent);
}

.welcome-flow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
  gap: 2rem;
  list-style: none;
  padding: 0;
  margin: 0 0 2.5rem;
}

.welcome-flow h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 1.25rem 0 0.5rem;
}

.welcome-flow p {
  color: var(--bs-secondary-color);
  margin: 0;
}

.welcome-flow-art {
  position: relative;
  height: 16rem;
  padding: 1rem;
  border: 1px solid var(--bs-border-color-translucent);
  border-radius: 1rem;
  background: var(--bs-body-bg);
  overflow: hidden;
}

/* 1: a pile of mixed pages. */
.welcome-pile .welcome-sheet {
  position: absolute;
  width: 7.5rem;
  left: calc(50% - 3.75rem);
  top: 1.25rem;
}

.welcome-pile .welcome-sheet:nth-child(1) {
  transform: translate(-4.5rem, 0.5rem) rotate(-14deg);
}

.welcome-pile .welcome-sheet:nth-child(2) {
  transform: translate(4rem, 0.25rem) rotate(11deg);
}

.welcome-pile .welcome-sheet:nth-child(3) {
  transform: translate(-1.5rem, 1.25rem) rotate(-5deg);
}

.welcome-pile .welcome-sheet:nth-child(4) {
  transform: translate(1.5rem, 1.75rem) rotate(4deg);
}

/* 2: a page being read, and what was read off it. */
.welcome-read {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 1rem;
  align-items: start;
}

.welcome-read-page {
  position: relative;
}

.welcome-scan-line {
  position: absolute;
  left: -4%;
  right: -4%;
  top: 8%;
  height: 3px;
  border-radius: 2px;
  background: var(--welcome-ai);
  box-shadow: 0 0 12px var(--welcome-ai);
  animation: welcome-scan 3s ease-in-out infinite alternate;
}

@keyframes welcome-scan {
  to {
    top: 92%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .welcome-scan-line {
    animation: none;
  }
}

.welcome-read-card {
  margin: 0;
  font-size: 0.8rem;
}

.welcome-read-card dt {
  font-weight: 500;
  color: var(--bs-secondary-color);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.welcome-read-card dd {
  margin: 0 0 0.3rem;
  line-height: 1.3;
  padding: 0.1rem 0.4rem;
  border-radius: 0.3rem;
  font-weight: 600;
  background: color-mix(in srgb, var(--welcome-ai) 16%, transparent);
}

/* 3: the piece on the sorting page, a zone per voice. */
.welcome-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  align-content: start;
}

.welcome-board-head {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
}

.welcome-chip {
  padding: 0.05rem 0.45rem;
  border-radius: 1rem;
  font-size: 0.7rem;
  background: var(--bs-secondary-bg);
}

.welcome-zone {
  padding: 0.35rem;
  border: 1px dashed var(--bs-border-color);
  border-radius: 0.5rem;
}

.welcome-zone-name {
  margin-bottom: 0.3rem;
  font-size: 0.65rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.welcome-zone-pages {
  display: grid;
}

/* A voice's further pages lie under its first, just peeking out. */
.welcome-zone-pages .welcome-sheet + .welcome-sheet {
  margin-top: calc(-141.4% + 0.4rem);
  position: relative;
  z-index: -1;
  transform: translate(0.25rem);
}

.welcome-zone-pages {
  isolation: isolate;
}

.welcome-checks {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0 0;
}

.welcome-checks li {
  position: relative;
  padding-left: 1.75rem;
  margin-bottom: 0.5rem;
}

.welcome-checks li::before {
  content: "\f272"; /* bi-check2 */
  font-family: "bootstrap-icons";
  position: absolute;
  left: 0;
  top: 0.05rem;
  color: var(--noten-accent);
  font-weight: 700;
}

.welcome-checks-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 2.5rem;
}

/* Devices, backup, association: text and picture side by side (alternating), stacked on
   phones. */
.welcome-features {
  padding: 4.5rem 0 1rem;
}

.welcome-feature {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  align-items: center;
  margin-bottom: 4.5rem;
}

@media (min-width: 992px) {
  .welcome-feature {
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
  }

  .welcome-feature-flip .welcome-feature-text {
    order: 2;
  }
}

.welcome-feature h3 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.welcome-feature p {
  font-size: 1.05rem;
  color: var(--bs-secondary-color);
}

.welcome-feature-icon {
  display: inline-grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  margin-bottom: 1rem;
  border-radius: 0.85rem;
  font-size: 1.4rem;
  color: var(--tone);
  background: color-mix(in srgb, var(--tone) 16%, transparent);
}

.welcome-art {
  position: relative;
  min-height: 18rem;
  padding: 2rem;
  border: 1px solid var(--bs-border-color-translucent);
  border-radius: 1.25rem;
  background: var(--welcome-panel);
}

/* Devices: a monitor, a tablet and a phone with the same part. */
.welcome-art-devices {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.9rem;
}

.welcome-monitor {
  width: 52%;
}

.welcome-monitor-screen {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
  padding: 0.45rem;
  border: 0.35rem solid #1d2026;
  border-radius: 0.45rem;
  background: #3a3f46;
  box-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.3);
}

.welcome-monitor-stand {
  width: 22%;
  height: 1.3rem;
  margin: 0 auto;
  background: linear-gradient(#2b2f36, #1d2026);
  clip-path: polygon(30% 0, 70% 0, 100% 100%, 0 100%);
}

.welcome-device-tablet,
.welcome-device-phone {
  border: 0.4rem solid #1d2026;
  background: #1d2026;
  box-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.3);
}

.welcome-device-tablet {
  width: 26%;
  border-width: 0.45rem 0.45rem 0.7rem;
  border-radius: 0.7rem;
}

.welcome-device-phone {
  width: 13%;
  border-width: 0.5rem 0.25rem;
  border-radius: 0.8rem;
}

.welcome-device-phone .welcome-sheet {
  aspect-ratio: 9 / 18;
}

/* Backup: a stack of pages under a lock. */
.welcome-art-backup {
  display: grid;
  place-items: center;
}

.welcome-stack {
  position: relative;
  width: 9.5rem;
}

.welcome-stack .welcome-sheet:not(:first-child) {
  position: absolute;
  inset: 0;
}

.welcome-stack .welcome-sheet:nth-child(1) {
  transform: rotate(-8deg) translateX(-1.5rem);
}

.welcome-stack .welcome-sheet:nth-child(2) {
  transform: rotate(5deg) translateX(1.25rem);
}

.welcome-lock {
  position: absolute;
  right: calc(50% - 7.5rem);
  bottom: 1.5rem;
  display: grid;
  place-items: center;
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  font-size: 1.75rem;
  color: #fff;
  background: #3fb27f;
  box-shadow: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.3);
}

/* The association: its library, and each member's own voice of the piece. */
.welcome-art-association {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.welcome-association-name {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.1rem;
  border-radius: 0.85rem;
  background: #f0a020;
  color: #1f2328;
  box-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.25);
}

.welcome-association-name > .bi {
  font-size: 1.6rem;
}

.welcome-members {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.9rem;
  width: 100%;
}

.welcome-member {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.welcome-member-voice {
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}

.welcome-member-voice .bi {
  color: #f0a020;
}

/* The plans (welcome.html #plans): Free and the two paid ones, named like dynamics. */
.welcome-brand {
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.85rem;
  color: var(--noten-accent);
  margin-bottom: 0.75rem;
}

.welcome-plans {
  padding: 4rem 0 1rem;
}

.welcome-plan {
  border: 1px solid var(--bs-border-color);
  border-radius: 1rem;
  padding: 1.5rem;
  background: var(--bs-body-bg);
}

.welcome-plan-paid {
  background: var(--welcome-panel);
  border-color: color-mix(in srgb, var(--noten-accent) 35%, var(--bs-border-color));
}

.welcome-plan-name {
  font-size: 1.5rem;
  font-weight: 650;
}

.welcome-plan-name .dynamic {
  font-size: 1.35em;
  line-height: 0; /* the bigger sign mustn't make the line taller than Free's */
  margin-right: 0.2em;
}

.welcome-plan-for {
  color: var(--bs-secondary-color);
}

.welcome-closing {
  padding: 2.5rem 0 4rem;
}

@media (max-width: 575.98px) {
  .welcome-hero {
    padding-top: 2.5rem;
  }

  .welcome-art {
    padding: 1.25rem;
    min-height: 14rem;
  }

  .welcome-float-ai {
    max-width: 16rem;
  }
}

/* My shares (shares.html): a share link to click and copy (js/copy.js). */
.share-link-copy {
  display: block;
  width: 100%;
  margin: 0.4rem 0;
  padding: 0.35rem 0.5rem;
  border: 1px dashed var(--bs-border-color);
  border-radius: 0.35rem;
  background: var(--bs-tertiary-bg);
  color: inherit;
  text-align: start;
  font-size: 0.85rem;
}

.share-link-copy:hover {
  border-color: var(--noten-accent);
}

.share-link-copy.copied {
  border-style: solid;
  border-color: var(--bs-success);
}

.share-link-copy.copied .bi {
  color: var(--bs-success);
}

/* Plans (templates/_plan.html): the paid ones are dynamics, their sign set like in a score. */
.dynamic {
  font-family: "Times New Roman", Georgia, serif;
  font-style: italic;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.plan-badge .dynamic { font-size: 1.15em; margin-right: 0.15em; }

/* The admin Plan control (_plan.html plan_control): the badge is a dropdown toggle. */
.plan-control-toggle {
  line-height: 1;
  cursor: pointer;
}
.plan-control-toggle .bi-caret-down-fill {
  font-size: 0.6em;
  margin-left: 0.2rem;
  color: var(--bs-secondary-color);
  vertical-align: middle;
}
.plan-menu {
  min-width: 15rem;
}
.plan-menu .dynamic {
  font-size: 1.1em;
  margin-right: 0.1em;
}

/* The navbar (base.html): between lg and xl the links show only their icons. */
@media (min-width: 992px) and (max-width: 1199.98px) {
  .navbar .nav-label {
    display: none;
  }
}

/* The captcha's honeypot field (templates/auth/_captcha.html): out of sight, not display:none
   (some bots skip fields that are). */
.hp-field {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Admin: sign-ups per day (templates/admin/users.html), confirmed at the bottom of each
   bar, never confirmed (mostly bots) above it. */
.signup-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 120px;
  border-bottom: 1px solid var(--bs-border-color);
}
.signup-day {
  flex: 1 1 0;
  height: 100%;
  display: flex;
  align-items: flex-end;
  min-width: 0;
}
.signup-day:hover .signup-bar,
.signup-day:focus .signup-bar {
  opacity: 0.75;
}
.signup-bar {
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.signup-bar > div {
  flex-basis: 0;
  min-height: 2px;
}
.signup-bar > div:first-child {
  border-radius: 4px 4px 0 0;
}
.signup-bar .confirmed,
.signup-key.confirmed {
  background: var(--bs-primary);
}
.signup-bar .unconfirmed,
.signup-key.unconfirmed {
  background: var(--bs-secondary-color);
}
.signup-legend {
  display: flex;
  gap: 1rem;
}
.signup-key {
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  border-radius: 2px;
  vertical-align: -0.05em;
}

/* Export page (library/export.html): the pieces to choose, scrolling on their own. */
.archive-list {
  max-height: 60vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* --- /admin/update (admin/update.html) --- */
.update-log {
  max-height: 28rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.8rem;
  background: var(--bs-tertiary-bg);
  border-radius: var(--bs-border-radius);
  padding: 0.75rem;
}
.update-info dt { font-weight: 500; color: var(--bs-secondary-color); }

/* --- /admin/opens (admin/opens.html, admin_opens.js) ---
   Each app keeps its colour (validated categorical slots, light and dark); the heatmap is
   one blue ramp, light → dark (dark mode: dark → light, so more is always more contrast). */
:root {
  --app-web: #2a78d6;
  --app-electron: #eb6834;
  --app-android: #1baf7a;
  --app-ios: #eda100;
  --app-tolino: #e87ba4;
  --app-other: #5f656d; /* "Other": a neutral gray, darker (light) or lighter (dark) than the Tolino's pink, which it would otherwise match for protan eyes */
  --usage-bar: #6f55c4; /* /admin/usage's bars not split by app: a hue no app has */
  --seq-0: var(--bs-tertiary-bg);
  --seq-1: #cde2fb;
  --seq-2: #9ec5f4;
  --seq-3: #6da7ec;
  --seq-4: #3987e5;
  --seq-5: #256abf;
  --seq-6: #184f95;
}
[data-bs-theme="dark"] {
  --app-web: #3987e5;
  --app-electron: #d95926;
  --app-android: #199e70;
  --app-ios: #c98500;
  --app-tolino: #d55181;
  --app-other: #9aa0a8;
  --usage-bar: #9a85e0;
  --seq-1: #104281;
  --seq-2: #1c5cab;
  --seq-3: #2a78d6;
  --seq-4: #5598e7;
  --seq-5: #86b6ef;
  --seq-6: #cde2fb;
}
.opens-key {
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  border-radius: 2px;
  vertical-align: -0.05em;
}
.opens-key[data-app="web"] { background: var(--app-web); }
.opens-key[data-app="electron"] { background: var(--app-electron); }
.opens-key[data-app="android"] { background: var(--app-android); }
.opens-key[data-app="ios"] { background: var(--app-ios); }
.opens-key[data-app="tolino"] { background: var(--app-tolino); }
.opens-key[data-app="other"] { background: var(--app-other); }
.opens-legend { display: flex; flex-wrap: wrap; gap: 1rem; }
.opens-chart { min-height: 200px; }
.opens-svg { display: block; max-width: 100%; }
.opens-svg .tick { font-size: 11px; fill: var(--bs-secondary-color); font-variant-numeric: tabular-nums; }
.opens-svg .grid { stroke: var(--bs-border-color-translucent); stroke-width: 1; }
.opens-svg .axis { stroke: var(--bs-border-color); stroke-width: 1; }
.opens-svg .hit { fill: transparent; }
.opens-svg .hit:hover { fill: var(--bs-secondary-bg); fill-opacity: 0.35; }
.opens-svg rect:not(.hit):hover { stroke: var(--bs-body-color); stroke-width: 1.5; }
.opens-bars { display: flex; flex-direction: column; gap: 0.35rem; }
.opens-bar-row {
  display: grid;
  grid-template-columns: minmax(8rem, 2fr) 3fr 4.5rem 5.5rem;
  align-items: center;
  gap: 0.5rem;
  padding: 0.15rem 0.25rem;
  border-radius: 4px;
}
.opens-bar-row-short { grid-template-columns: minmax(8rem, 2fr) 3fr 4.5rem; }
.opens-bar-row:not(.opens-bar-head):hover,
.opens-bar-row:focus-visible { background: var(--bs-tertiary-bg); }
.opens-bar-head { margin-bottom: 0.25rem; }
.opens-bar-name { min-width: 0; overflow-wrap: anywhere; line-height: 1.2; }
.opens-bar-track { min-width: 0; }
.opens-bar {
  display: flex;
  gap: 2px;
  height: 14px;
  min-width: 2px;
}
.opens-bar > div { flex-basis: 0; min-width: 2px; }
.opens-bar > div:last-child { border-radius: 0 4px 4px 0; }
.opens-bar-value { text-align: end; font-variant-numeric: tabular-nums; }
.opens-bar-time { text-align: end; white-space: nowrap; }
.opens-heat-table { font-size: 0.75rem; }

/* --- /admin/visitors (admin/visitors.html, admin_visitors.js): each kind of visit in one
   of the validated slots above (people green, bots orange, previews blue, scanners violet,
   no script gray). */
:root {
  --kind-human: var(--app-android);
  --kind-unknown: var(--app-other);
  --kind-bot: var(--app-electron);
  --kind-preview: var(--app-web);
  --kind-scanner: var(--usage-bar);
}
.opens-key[data-kind="human"] { background: var(--kind-human); }
.opens-key[data-kind="unknown"] { background: var(--kind-unknown); }
.opens-key[data-kind="bot"] { background: var(--kind-bot); }
.opens-key[data-kind="preview"] { background: var(--kind-preview); }
.opens-key[data-kind="scanner"] { background: var(--kind-scanner); }
.visitors-map { min-height: 120px; }
.visitors-map-svg { display: block; max-width: 100%; border-radius: var(--bs-border-radius); }
.visitors-map-svg .sea { fill: var(--bs-tertiary-bg); }
.visitors-map-svg .land { fill: var(--bs-secondary-bg); stroke: var(--bs-border-color); }
.visitors-map-svg .dot { fill-opacity: 0.7; stroke: var(--bs-body-bg); }
.visitors-map-svg .dot:hover { fill-opacity: 1; stroke: var(--bs-body-color); }
.visitors-map-svg .label { fill: var(--bs-body-color); pointer-events: none; paint-order: stroke; stroke: var(--bs-secondary-bg); }
.visitors-table td { vertical-align: top; }
.opens-tip {
  position: fixed;
  z-index: 1080;
  pointer-events: none;
  max-width: 20rem;
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
  color: var(--bs-body-color);
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  box-shadow: var(--bs-box-shadow-sm);
}
@media (max-width: 575.98px) {
  .opens-bar-row { grid-template-columns: minmax(6rem, 1fr) 1fr 4.2rem; }
  .opens-bar-time { display: none; }
}

/* --- /admin/usage (admin/usage.html, admin_usage.js): the opens page's marks, per
   section key figures and a grid of charts (columns and tables across it). --- */
.usage-toc { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }
.usage-toc a { text-decoration: none; white-space: nowrap; }
.usage-section { scroll-margin-top: 4.5rem; }
.usage-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 0.5rem; }
.usage-kpi { background: var(--bs-tertiary-bg); border-radius: var(--bs-border-radius); padding: 0.5rem 0.75rem; }
.usage-kpi-value { font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.usage-kpi-label { line-height: 1.2; }
.usage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 26rem), 1fr)); gap: 1.5rem 2rem; }
.usage-chart { min-width: 0; }
.usage-wide { grid-column: 1 / -1; }
.usage-table summary { cursor: pointer; }

/* The large view's column is narrow: the copyright notice's text under its select. */
.sort-large-edit .sort-field-copyright {
  flex-wrap: wrap;
}

.sort-large-edit .sort-field-copyright select {
  flex: 1 1 auto;
  max-width: none;
}

.sort-large-edit .sort-field-copyright input {
  flex: 1 1 100%;
}

/* --- Colours of the parts of the app (data-section; the app's start page and pages) and of
   the viewer menu's actions. --sec is for icons and lines, --sec-rgb for tints. */

[data-section="library"] { --sec: #6ea8ff; --sec-rgb: 110, 168, 255; }
[data-section="recent"] { --sec: #f5b041; --sec-rgb: 245, 176, 65; }
[data-section="downloads"] { --sec: #45c98a; --sec-rgb: 69, 201, 138; }
[data-section="setlists"] { --sec: #b48cf7; --sec-rgb: 180, 140, 247; }
[data-section="add"] { --sec: #3cc8d8; --sec-rgb: 60, 200, 216; }
[data-section="edit"] { --sec: #f27aa0; --sec-rgb: 242, 122, 160; }
[data-section="settings"] { --sec: #9aa4b1; --sec-rgb: 154, 164, 177; }
/* Not parts of the app, but actions in the menus (.sheet-actions, .piece-menu-actions). */
[data-section="notes"] { --sec: #ff7b7b; --sec-rgb: 255, 123, 123; }
[data-section="share"] { --sec: #3cc8d8; --sec-rgb: 60, 200, 216; }
[data-section="flashcards"] { --sec: #ffca2c; --sec-rgb: 255, 202, 44; }

[data-bs-theme="light"] [data-section="library"], [data-bs-theme="light"][data-section="library"] { --sec: #1f63d6; --sec-rgb: 31, 99, 214; }
[data-bs-theme="light"] [data-section="recent"], [data-bs-theme="light"][data-section="recent"] { --sec: #b36b00; --sec-rgb: 230, 145, 20; }
[data-bs-theme="light"] [data-section="downloads"], [data-bs-theme="light"][data-section="downloads"] { --sec: #17834f; --sec-rgb: 30, 160, 98; }
[data-bs-theme="light"] [data-section="setlists"], [data-bs-theme="light"][data-section="setlists"] { --sec: #6c3fd1; --sec-rgb: 124, 77, 230; }
[data-bs-theme="light"] [data-section="add"], [data-bs-theme="light"][data-section="add"] { --sec: #0b7f8c; --sec-rgb: 20, 165, 182; }
[data-bs-theme="light"] [data-section="edit"], [data-bs-theme="light"][data-section="edit"] { --sec: #c2335f; --sec-rgb: 222, 72, 118; }
[data-bs-theme="light"] [data-section="settings"], [data-bs-theme="light"][data-section="settings"] { --sec: #56606c; --sec-rgb: 110, 120, 132; }
[data-bs-theme="light"] [data-section="notes"], [data-bs-theme="light"][data-section="notes"] { --sec: #c62828; --sec-rgb: 220, 60, 60; }
[data-bs-theme="light"] [data-section="share"], [data-bs-theme="light"][data-section="share"] { --sec: #0b7f8c; --sec-rgb: 20, 165, 182; }
[data-bs-theme="light"] [data-section="flashcards"], [data-bs-theme="light"][data-section="flashcards"] { --sec: #a87700; --sec-rgb: 200, 145, 0; }

/* --- The full-screen viewer (viewer_sheet.js: the apps and the website): the page fills the
   screen, everything else is in a menu sliding in from the bottom (from the right in
   landscape), opened at a narrow edge, or (`.viewer-buttons`) from round buttons over the page. */

.sheet-viewer {
  --sheet-edge: 2.1rem;
  --viewer-bg: #000;
}

.sheet-viewer[data-bs-theme="light"] {
  --viewer-bg: var(--bs-secondary-bg);
}

.sheet-viewer body {
  overflow: hidden;
  background: var(--viewer-bg);
  /* No long-press text selection / callouts while turning pages (a long press opens the
     menu, viewer_sheet.js). */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Until viewer_sheet.js has moved the viewer out of them. */
.sheet-viewer body > nav,
.sheet-viewer body > main,
.sheet-viewer body > .site-footer {
  display: none;
}

.sheet-viewer #viewer {
  position: fixed;
  inset: 0 0 var(--sheet-edge) 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sheet-viewer #viewer > .viewer-toolbar {
  display: none;
}

.sheet-viewer #viewer-canvas-wrap {
  flex: 1;
  max-height: none;
  border: 0;
  border-radius: 0;
  background: var(--viewer-bg);
  align-items: center;
  align-items: safe center;
  /* viewer.js fits side-by-side pages to 98% of the width; a wider gap would overflow. */
  gap: 2px;
}

.viewer-loading {
  position: fixed;
  inset: 0 0 var(--sheet-edge) 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sheet-edge {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--sheet-edge);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bs-body-bg);
  border-top: 1px solid var(--bs-border-color);
  touch-action: none;
  cursor: pointer;
}

.sheet-grip {
  display: block;
  width: 3rem;
  height: 5px;
  border-radius: 3px;
  background: var(--bs-secondary-color);
  opacity: 0.7;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1035;
  background: rgb(0 0 0 / 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.sheet-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.viewer-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1040;
  max-height: 75vh;
  display: flex;
  flex-direction: column;
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  border-radius: 1rem 1rem 0 0;
  box-shadow: 0 -0.5rem 1.5rem rgb(0 0 0 / 0.35);
  user-select: none;
  -webkit-user-select: none;
  transform: translateY(100%);
  visibility: hidden;
  transition: transform 0.25s ease, visibility 0s linear 0.25s;
}

.viewer-sheet.open,
.viewer-sheet.dragging {
  transform: none;
  visibility: visible;
  transition: transform 0.25s ease;
}

.viewer-sheet.dragging {
  transition: none;
}

.sheet-grab {
  flex: none;
  display: flex;
  justify-content: center;
  padding: 0.6rem 0 0.8rem;
  touch-action: none;
  cursor: grab;
}

.sheet-body {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 1rem 1rem;
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.sheet-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
  padding-top: 0.35rem;
  overflow-wrap: anywhere;
}

.sheet-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.sheet-nav #page-label {
  flex: 1;
}

.sheet-section {
  margin-top: 1rem;
}

/* The menu's actions (Draw notes, Save, Edit, Share): a list, one row each. */
.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.sheet-actions .btn {
  --bs-btn-font-size: 0.95rem;
  width: 100%;
  padding: 0.6rem 0.85rem;
  text-align: start;
}

.sheet-actions .btn .bi {
  margin-right: 0.35rem;
}

/* The menus' actions in their colour (data-section on each button), filled softly — or
   solid when switched on (Saved on this device: btn-success; drawing: #draw-open.active). */
.sheet-actions .btn[data-section],
.piece-menu-actions .btn[data-section] {
  --bs-btn-color: var(--sec);
  --bs-btn-bg: rgba(var(--sec-rgb), 0.14);
  --bs-btn-border-color: transparent;
  --bs-btn-hover-color: var(--sec);
  --bs-btn-hover-bg: rgba(var(--sec-rgb), 0.24);
  --bs-btn-hover-border-color: transparent;
  --bs-btn-active-color: var(--sec);
  --bs-btn-active-bg: rgba(var(--sec-rgb), 0.32);
  --bs-btn-active-border-color: transparent;
  --bs-btn-disabled-color: var(--sec);
  --bs-btn-disabled-bg: rgba(var(--sec-rgb), 0.1);
  --bs-btn-disabled-border-color: transparent;
  font-weight: 500;
}

.sheet-actions .btn.btn-success[data-section] {
  --bs-btn-color: var(--bs-body-bg);
  --bs-btn-bg: var(--sec);
  --bs-btn-hover-color: var(--bs-body-bg);
  --bs-btn-hover-bg: var(--sec);
  --bs-btn-active-color: var(--bs-body-bg);
  --bs-btn-active-bg: var(--sec);
}

#draw-open.active {
  background: var(--noten-note);
  border-color: var(--noten-note);
  color: #fff;
}

/* Layout buttons as pictures (layouts.js), also on the Settings page. */
.sheet-viewer .layout-picker,
.layout-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(3.3rem, 1fr));
  gap: 0.35rem;
}

.layout-picker .btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.35rem 0.15rem 0.25rem;
}

.layout-icon {
  width: 2.4rem;
  height: auto;
  overflow: visible;
}

.layout-label {
  font-size: 0.68rem;
  line-height: 1.1;
  white-space: nowrap;
}

.sheet-section .form-switch {
  margin-bottom: 0.5rem;
}

.sheet-label {
  margin-bottom: 0.35rem;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bs-secondary-color);
}

/* A setlist has no voice to switch. */
.sheet-voice:has(#item-voice:empty) {
  display: none;
}


.sheet-viewer #item-error:not([hidden]),
.sheet-viewer #item-note:not([hidden]) {
  margin: 0.75rem 0 0;
}

/* Drawing tools, floating over the top of the page while "Draw notes" is on. */
.draw-bar:not([hidden]) {
  position: fixed;
  top: 0.5rem;
  left: 50%;
  z-index: 1030;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  max-width: calc(100vw - 1rem);
  padding: 0.3rem 0.4rem;
  border-radius: 2rem;
  background: var(--bs-body-bg);
  box-shadow: 0 0.25rem 1rem rgb(0 0 0 / 0.4);
}

.draw-bar .viewer-annotate-controls {
  flex-wrap: wrap;
  justify-content: center;
}

.draw-bar #annotate-status:empty {
  display: none;
}

/* The desktop app's buttons over the page (viewer_sheet.js desktopButtons): back at the top
   left, full screen and the menu at the top right, the turns at the sides. The menu opens
   only from its button there: no edge to tap or drag. */
.viewer-buttons.sheet-viewer {
  --sheet-edge: 0px;
}

.viewer-buttons .sheet-edge,
.viewer-buttons .sheet-grab {
  display: none;
}

.viewer-float-btn {
  position: fixed;
  z-index: 1030;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border-radius: 50%;
  font-size: 1.25rem;
  color: #fff;
  background: rgb(33 37 41 / 0.6);
  border: 1px solid rgb(255 255 255 / 0.2);
}

.viewer-float-btn:hover,
.viewer-float-btn:focus-visible {
  color: #fff;
  background: rgb(33 37 41 / 0.85);
}

.viewer-float-btn:disabled {
  opacity: 0.25;
}

#float-back {
  top: 0.75rem;
  left: 0.75rem;
}

#float-menu {
  top: 0.75rem;
  right: 0.75rem;
}

#float-full {
  top: 0.75rem;
  right: 4rem;
}

#float-prev,
#float-next {
  top: calc(50% - var(--sheet-edge) / 2);
  transform: translateY(-50%);
  height: 4.5rem;
  border-radius: 1.4rem;
}

#float-prev {
  left: 0.75rem;
}

#float-next {
  right: 0.75rem;
}

@media (orientation: landscape) {
  .sheet-viewer #viewer,
  .viewer-loading {
    inset: 0 var(--sheet-edge) 0 0;
  }

  .sheet-edge {
    top: 0;
    left: auto;
    width: var(--sheet-edge);
    height: auto;
    border-top: 0;
    border-left: 1px solid var(--bs-border-color);
  }

  .sheet-edge .sheet-grip,
  .sheet-grab .sheet-grip {
    width: 5px;
    height: 3rem;
  }

  .viewer-sheet {
    top: 0;
    left: auto;
    width: min(24rem, 75vw);
    max-height: none;
    flex-direction: row;
    border-radius: 1rem 0 0 1rem;
    box-shadow: -0.5rem 0 1.5rem rgb(0 0 0 / 0.35);
    transform: translateX(100%);
  }

  .sheet-grab {
    align-items: center;
    padding: 0 0.6rem;
  }

  .sheet-body {
    padding: 1rem 1rem 1rem 0;
  }
}

/* Without the grab handle beside it (desktop), the menu's own margin on the left. */
.viewer-buttons .sheet-body {
  padding: 1rem;
}

/* The piece's metadata in the menu (piece_info.js): label and value in two columns. */
.sheet-info {
  margin: -0.25rem 0 0.75rem;
  font-size: 0.875rem;
}

.piece-meta-title {
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.piece-meta-title .bi {
  color: var(--bs-secondary-color);
}

.piece-meta {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.15rem 0.75rem;
  margin: 0;
}

.piece-meta dt {
  font-weight: normal;
  color: var(--bs-secondary-color);
}

.piece-meta dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* The website's switches for notes others shared, in the menu (only while there are any). */
.sheet-layers:not(:has(#shared-notes:not([hidden]))) {
  display: none;
}

.sheet-layers #shared-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
}

.sheet-layers #shared-notes > span:first-child {
  display: none; /* "Notes from:", the section's label says it */
}

/* The page head waits hidden (with <main>) until viewer_sheet.js has moved it. */
.viewer-head {
  display: none;
}

.sheet-viewer :is(input, textarea, [contenteditable]) {
  user-select: text;
  -webkit-user-select: text;
}

/* The 404 page (templates/errors/404.html): a multi-bar rest of 404 bars. */
.not-found {
  max-width: 32rem;
  margin: 2rem auto 3rem;
  text-align: center;
}

.not-found-rest {
  display: block;
  width: min(100%, 18rem);
  margin: 0 auto 1.5rem;
}

.not-found-staff line {
  stroke: var(--bs-secondary-color);
  stroke-width: 1.4;
}

.not-found-bar {
  fill: var(--bs-body-color);
}

.not-found-count {
  font-family: "Times New Roman", Georgia, serif;
  font-weight: 700;
  font-size: 28px;
  fill: var(--noten-accent);
}

/* ---- Flashcards (flashcards_editor.js in the viewer, flashcards/study.html) ---- */
/* The two menu buttons sit in the menu's column like the others. */
.flashcards-actions { display: contents; }
.flashcard-box {
  fill: rgba(255, 193, 7, 0.12);
  stroke: #ffc107;
  stroke-width: 2px;
  vector-effect: non-scaling-stroke;
}
.flashcard-box.drawing { stroke-dasharray: 6 4; }
#viewer-canvas-wrap.flashcards-editing,
#viewer-canvas-wrap.flashcards-editing .page-slot { touch-action: none; cursor: crosshair; }
.flashcards-bar {
  position: fixed;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  max-width: calc(100vw - 2rem);
  padding: 0.4rem 0.6rem;
  border-radius: 0.5rem;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  box-shadow: 0 0.25rem 1rem rgba(0, 0, 0, 0.3);
}
.flashcards-bar[hidden] { display: none; }

.study-page { position: relative; max-width: 900px; margin: 0 auto; }
.study-page img { display: block; width: 100%; height: auto; background: #fff; border-radius: 0.25rem; }
.study-page svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.study-cover { fill: var(--bs-secondary-bg); stroke: #ffc107; stroke-width: 2px; vector-effect: non-scaling-stroke; }
.study-shown { fill: rgba(255, 193, 7, 0.15); stroke: #ffc107; stroke-width: 3px; vector-effect: non-scaling-stroke; }
.study-other { fill: none; stroke: rgba(255, 193, 7, 0.45); stroke-width: 1px; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.study-cover-label { fill: var(--bs-body-color); font-weight: 600; }
.study-controls { position: sticky; bottom: 0; padding: 0.75rem 0; background: var(--bs-body-bg); z-index: 5; }
.study-controls .btn { min-width: 6.5rem; }
.study-rate[hidden] { display: none !important; }
/* The app's flashcards list (client/www/js/flashcards_page.js). */
.flashcards-figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.5rem; margin-bottom: 1rem; }
.flashcards-figure { padding: 0.5rem 0.65rem; border: 1px solid var(--bs-border-color); border-radius: 0.5rem; }
@media (max-width: 480px) { .flashcards-figures { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.study .min-w-0, .flashcards-modes + * .min-w-0 { min-width: 0; }
/* Key hints only where there's a keyboard. */
@media (pointer: coarse) { .study-key { display: none; } }
.study-crop svg { position: static; display: block; width: 100%; height: auto; }
.study-crop-paper { fill: #fff; }
.study-question .display-6 { overflow-wrap: anywhere; }

/* Contrast in the sorting/Edit page's large view (upload_sort.js, contrast.py): a round
   button at the page's top left opens the panel over the page. */
.sort-large-contrast-toggle {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 3;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(20, 20, 20, 0.75);
  color: #fff;
  font-size: 1.25rem;
}
.sort-large-contrast-toggle:hover, .sort-large-contrast-toggle.active { background: var(--bs-primary); }
.sort-large-contrast {
  position: absolute;
  top: 4.5rem;
  left: 1rem;
  z-index: 3;
  width: min(22rem, calc(100% - 2rem));
  padding: 0.75rem;
  border-radius: 0.5rem;
  background: rgba(20, 20, 20, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
}
.sort-large-contrast[hidden] { display: none; }
.sort-large-slider {
  display: grid;
  grid-template-columns: 7rem 1fr 3.5rem;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}
.sort-large-slider output { text-align: right; font-variant-numeric: tabular-nums; }

/* Flashcard statistics (flashcards/stats.html): lightweight, theme-aware CSS charts. */
.fc-cols {
  display: flex;
  align-items: flex-end;
  gap: 2px;
}
.fc-col {
  flex: 1 1 0;
  min-width: 3px;
  height: 100%;
  display: flex;
  flex-direction: column-reverse; /* first child sits at the bottom, segments stack up */
  justify-content: flex-start;
  gap: 1px;
}
.fc-seg {
  width: 100%;
  border-radius: 3px;
  min-height: 0;
}
.fc-labels {
  display: flex;
  gap: 2px;
  margin-top: 0.25rem;
}
.fc-labels > span {
  flex: 1 1 0;
  min-width: 3px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
}
/* A single horizontal bar split into maturity segments. */
.fc-stack {
  display: flex;
  height: 1.75rem;
  gap: 2px;
  border-radius: 5px;
  overflow: hidden;
}
.fc-stack-seg { min-width: 2px; border-radius: 3px; }
.fc-legend { display: inline-flex; align-items: center; gap: 0.35rem; }
.fc-swatch {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 3px;
  flex: 0 0 auto;
}
/* Horizontal rank bars (how cards were rated). */
.fc-track {
  background: var(--bs-secondary-bg);
  border-radius: 4px;
  height: 0.9rem;
  overflow: hidden;
}
.fc-fill { height: 100%; border-radius: 4px; min-width: 2px; }

/* Colours, from the Bootstrap theme so light and dark both work. */
.fc-primary { background: var(--bs-primary); }
.fc-info { background: var(--bs-info); }
.fc-success { background: var(--bs-success); }
.fc-today { background: var(--bs-warning); }
.fc-m-new { background: var(--bs-secondary); }
.fc-m-learning { background: var(--bs-info); }
.fc-m-young { background: var(--bs-primary); }
.fc-m-mature { background: var(--bs-success); }
.fc-r-again { background: var(--bs-danger); }
.fc-r-hard { background: var(--bs-warning); }
.fc-r-good { background: var(--bs-primary); }
.fc-r-easy { background: var(--bs-success); }
