/* CHANTIFA — protest-poster look: black, paper, signal red. */

/* Barlow (body) and Barlow Condensed (display), SIL OFL 1.1, see fonts/OFL.txt.
   Self-hosted so every platform gets the same type. Just the weights the app uses. */
@font-face {
  font-family: 'Barlow';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/barlow-400.woff2') format('woff2');
}

@font-face {
  font-family: 'Barlow';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/barlow-500.woff2') format('woff2');
}

@font-face {
  font-family: 'Barlow';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/barlow-600.woff2') format('woff2');
}

@font-face {
  font-family: 'Barlow';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/barlow-700.woff2') format('woff2');
}

@font-face {
  font-family: 'Barlow Condensed';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/barlow-condensed-700.woff2') format('woff2');
}

@font-face {
  font-family: 'Barlow Condensed';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('../fonts/barlow-condensed-800.woff2') format('woff2');
}

:root {
  --bg: #0d0d0d;
  --bg-2: #181716;
  --paper: #f3eee4;
  --ink: #0d0d0d;
  --red: #e4002b;
  --red-dark: #a8001f;
  --muted: #9b968c;
  --line: #2c2a27;

  --font-display: 'Barlow Condensed', sans-serif;
  --font-body: 'Barlow', sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    /* Sized to one viewport so the glow looks the same regardless of page height. */
    radial-gradient(circle at 100% 0%, rgb(228 0 43 / 0.18), transparent 45%) 100% 0 / 100% 100dvh
      no-repeat,
    radial-gradient(rgb(255 255 255 / 0.035) 1px, transparent 1.5px) 0 0 / 6px 6px,
    var(--bg);
  color: var(--paper);
  font-family: var(--font-body);
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

body.has-player {
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 3px;
}

/* ------------------------------------------------------------------------ */
/* Home                                                                      */
/* ------------------------------------------------------------------------ */

.home {
  max-width: 960px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 28px) calc(var(--safe-right) + 20px) calc(var(--safe-bottom) + 40px)
    calc(var(--safe-left) + 20px);
}

/* Logo (img/chantifa.svg); font-size sets its scale, so contexts can resize it with font-size. */
.wordmark {
  display: block;
  margin: 0;
  font-size: clamp(3.2rem, 17vw, 7rem);
  line-height: 0;
}

.wordmark img {
  display: block;
  width: auto;
  height: 0.9em;
  max-width: 100%;
  object-fit: contain;
  object-position: left center;
}

.tagline {
  margin: 14px 0 0;
  max-width: 30ch;
  color: var(--muted);
  font-size: 1.05rem;
}

.toolbar {
  display: grid;
  gap: 12px;
  margin: 28px 0 8px;
}

.search {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--bg-2);
  font-size: 1.05rem;
  -webkit-appearance: none;
  appearance: none;
}

.search:focus {
  border-color: var(--red);
  outline: none;
}

/* Our own clear button replaces the browser's native one (start page and chant picker). */
.search-field input::-webkit-search-cancel-button {
  display: none;
}

.search-field {
  position: relative;
}

.search-field input {
  padding-right: 56px;
}

.search-clear {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-clear[hidden] {
  display: none;
}

.search-clear svg {
  width: 18px;
  height: 18px;
}

@media (hover: hover) {
  .search-clear:hover {
    color: var(--paper);
  }
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Language filter is hidden for now. Delete this rule to bring it back. */
.chips,
.toolbar:has(> .chips:only-child) {
  display: none;
}

.chip {
  min-width: 48px;
  min-height: 40px;
  padding: 6px 14px;
  border: 2px solid var(--line);
  background: transparent;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
}

.chip[aria-pressed='true'] {
  border-color: var(--paper);
  background: var(--paper);
  color: var(--ink);
}

.section-title {
  margin: 28px 0 14px;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.category-grid,
.match-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 18px 14px;
}

.category-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  min-height: 128px;
  height: 100%;
  padding: 16px 14px 14px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 5px 5px 0 var(--red);
  transform: rotate(var(--tilt, 0deg));
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card-link {
  display: block;
  color: inherit;
  text-decoration: none;
  outline: none;
}

/* Stretch the list link over the whole card; the play button sits above it. */
.card-link::after {
  content: '';
  position: absolute;
  inset: 0;
}

.card-link:focus-visible::after {
  outline: 3px solid var(--paper);
  outline-offset: 4px;
}

.category-card:active {
  transform: rotate(0deg) translate(3px, 3px);
  box-shadow: 2px 2px 0 var(--red);
}

@media (hover: hover) {
  .category-card:hover {
    transform: rotate(0deg) scale(1.03);
  }
}

.card-play {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
}

.card-play svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.card-play:active {
  background: var(--red);
}

.category-card--red .card-play {
  background: var(--paper);
  color: var(--red);
}

.category-card--red {
  background: var(--red);
  color: var(--paper);
  box-shadow: 5px 5px 0 var(--paper);
}

.category-card--red:active {
  box-shadow: 2px 2px 0 var(--paper);
}

.category-card.is-empty {
  opacity: 0.45;
}

/* Dashed card that creates a new custom list */
.category-card--new {
  width: 100%;
  border: 3px dashed var(--muted);
  background: transparent;
  color: var(--paper);
  box-shadow: none;
  text-align: left;
  cursor: pointer;
}

.category-card--new:active {
  box-shadow: none;
  border-color: var(--red);
}

.category-name {
  display: block;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1;
  text-transform: none;
}

/* Long titles: hyphenate only long words (German compounds), never short ones
   like "Justice". js/fit-text.js shrinks whatever still overflows. */
.category-name,
.list-title {
  overflow-wrap: normal;
  hyphens: auto;
  -webkit-hyphens: auto;
  hyphenate-limit-chars: 10 4 4;
  -webkit-hyphenate-limit-before: 4;
  -webkit-hyphenate-limit-after: 4;
}

/* Last resort after shrinking to the minimum size. */
.is-squeezed {
  overflow-wrap: anywhere;
}

.category-count {
  font-size: 0.85rem;
  font-weight: 500;
  opacity: 0.75;
}

.match-list {
  display: grid;
  gap: 10px;
}

.match {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-left: 5px solid var(--red);
  background: var(--bg-2);
  text-decoration: none;
}

/* Call and response look the same apart from the colour, like lines of one text. */
.match-call,
.match-response {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  text-transform: none;
}

.match-response {
  color: var(--red);
}

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

.list-nav {
  margin-bottom: 22px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  text-decoration: none;
}

.back-link svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: square;
}

.back-link .wordmark {
  font-size: 1.6rem;
}

.list-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px 16px;
  margin-bottom: 18px;
}

.list-title {
  grid-column: 1 / -1;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 11vw, 4.5rem);
  font-weight: 800;
  line-height: 0.95;
  text-transform: uppercase;
}

.list-count {
  grid-column: 1;
  grid-row: 2;
  margin: 0;
  color: var(--muted);
}

.list-actions {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.icon-btn.edit-btn,
.share-btn {
  box-shadow: inset 0 0 0 2px var(--paper);
}

.icon-btn.edit-btn svg,
.share-btn svg {
  width: 20px;
  height: 20px;
  stroke-linejoin: round;
}

.list-title-edit {
  grid-column: 1 / -1;
  margin: 0;
}

.list-rename {
  width: 100%;
  padding: 8px 12px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--bg-2);
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 8vw, 3rem);
  font-weight: 800;
  line-height: 1.05;
  text-transform: uppercase;
  -webkit-appearance: none;
  appearance: none;
}

.list-rename:focus {
  border-color: var(--red);
  outline: none;
}

/* Round like the share / edit buttons next to it, but filled red. */
.icon-btn.play-btn {
  background: var(--red);
  color: var(--paper);
}

.icon-btn.play-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  stroke: none;
  translate: 1px 0; /* optically center the triangle */
}

.icon-btn.play-btn:active svg {
  transform: scale(0.85);
}

ol.match-list {
  counter-reset: chant;
}

ol.match-list .match {
  position: relative;
  padding-left: 44px;
  counter-increment: chant;
}

ol.match-list .match::before {
  content: counter(chant);
  position: absolute;
  top: 15px;
  left: 8px;
  width: 26px;
  color: var(--muted);
  font-family: var(--font-display);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Counter hidden for now, but kept in the code: drop these two rules to show it again. */
ol.match-list .match {
  padding-left: 16px;
}

ol.match-list .match::before {
  display: none;
}

.match-call,
.match-response {
  white-space: pre-line;
}

/* Calls and responses (all rounds) follow each other like lines of one text:
   cancel the row's grid gap between them. */
.match :is(.match-call, .match-response) + .match-response,
.match .match-response + .match-call {
  margin-top: -4px;
}

.picker-text :is(.match-call, .match-response) + .match-response,
.picker-text .match-response + .match-call {
  margin-top: -2px;
}

/* Optional note on a chant (lists + player). */
.chant-comment {
  display: flex;
  --comment-leading: 1.35;
  gap: 8px;
  align-items: flex-start;
  margin: 8px 0 0;
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 400;
  line-height: var(--comment-leading);
  text-transform: none;
  opacity: 0.85;
}

.chant-comment::before {
  content: 'i';
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 1.25em;
  height: 1.25em;
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  font-family: Georgia, serif;
  font-size: 0.85em;
  font-style: italic;
  font-weight: 700;
  line-height: 1;
  /* Center the badge on the first line box, independent of font metrics:
     (line height in the badge's own em − badge height) / 2. */
  margin-top: calc((var(--comment-leading) * 1em / 0.85 - 1.25em) / 2);
}

.slide-comment {
  max-width: 60ch;
  padding-top: 14px;
  font-size: 0.95rem;
  transition: opacity 0.2s ease;
}

.player.is-immersive .slide-comment {
  opacity: 0;
}

/* Favorite (heart) toggle and "add to list" button */
.fav-btn,
.list-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--paper);
  cursor: pointer;
}

.fav-btn svg,
.list-btn svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linejoin: round;
  transition: transform 0.15s ease;
}

.fav-btn[aria-pressed='true'],
.icon-btn.fav-btn[aria-pressed='true'] {
  background: transparent;
  color: var(--red);
}

.fav-btn[aria-pressed='true'] svg {
  fill: currentColor;
}

.list-btn svg {
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.list-btn[aria-pressed='true'],
.icon-btn.list-btn[aria-pressed='true'] {
  background: transparent;
  color: var(--red);
}

.list-btn[aria-pressed='true'] svg {
  stroke-width: 3;
}

.fav-btn:active svg,
.list-btn:active svg {
  transform: scale(0.85);
}

.match-item {
  position: relative;
}

.match-item .match {
  padding-right: 94px;
}

.match-fav,
.match-list-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 1;
  color: var(--muted);
}

.match-list-btn {
  right: 44px;
}

/* Rows without heart / list buttons (shared lists) */
.match-item .match--plain {
  padding-right: 16px;
}

/* Shared list (standalone view) */

/* Hidden for now, but kept in the code: "Open a shared list" on the start page, and on the
   shared list page the save/open button, the home-screen hint with "Copy link" and the
   category tags under the chants, in the list and in the player (.match--plain and
   .player--plain mark the shared list's rows and player). Delete this rule to bring them back. */
.open-shared-btn,
.shared-save,
.shared-hint,
.match--plain .match-tags,
.player--plain .slide-tags {
  display: none !important;
}

.shared-brand {
  cursor: default;
}

.shared-kicker {
  display: inline-block;
  margin: 0 0 10px;
  padding: 3px 8px;
  background: var(--red);
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.shared-save {
  margin: 0 0 22px;
}

.shared-hint {
  display: grid;
  gap: 8px;
  justify-items: start;
  margin: 0 0 22px;
  padding: 12px 14px;
  border-left: 4px solid var(--muted);
  background: var(--bg-2);
  color: var(--muted);
  font-size: 0.9rem;
}

.shared-hint p {
  margin: 0;
}

.shared-hint .text-btn {
  color: var(--paper);
}

/* Text-style button with an icon ("Open a shared list", "Copy link") */
.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-decoration: underline;
  text-decoration-color: var(--red);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  text-transform: uppercase;
  cursor: pointer;
}

.text-btn svg {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}

.open-shared-btn {
  margin-top: 14px;
}

.sheet-text--muted {
  color: var(--muted);
  font-weight: 400;
}

.shared-exit {
  margin: 32px 0 0;
}

.shared-exit a {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-decoration-color: var(--red);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  text-transform: uppercase;
}

@media (max-width: 600px) {
  .shared-save {
    width: 100%;
  }
}

/* Custom list in edit mode: move / remove controls instead of the play link */
.match-list--edit .edit-item {
  display: flex;
  background: var(--bg-2);
}

.match-list--edit .match {
  flex: 1;
  min-width: 0;
  padding-right: 8px;
}

.edit-ctrls {
  flex: none;
  display: grid;
  grid-template-columns: 44px 44px;
  grid-template-rows: 44px 44px;
  align-self: center;
  padding: 4px;
}

.edit-ctrl[data-action='remove'] {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
}

.edit-ctrl:hover:not(:disabled) {
  color: var(--red);
}

.match-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.match-tags .tag {
  font-size: 0.72rem;
}

/* Start-page content sections (data/content.json) */
.content-section {
  margin-top: 40px;
}

.content-body {
  max-width: 62ch;
  padding: 18px 20px;
  border-left: 5px solid var(--red);
  background: var(--bg-2);
  line-height: 1.5;
}

.content-body > * {
  margin: 0;
}

.content-body > * + * {
  margin-top: 0.8em;
}

.content-body p {
  white-space: pre-line;
}

.content-body ul {
  padding-left: 1.2em;
}

.content-body li + li {
  margin-top: 0.4em;
}

.content-body li::marker {
  color: var(--red);
}

.content-body a {
  color: var(--paper);
  text-decoration-color: var(--red);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

/* Headings inside content (start-page sections and pages) */
.content-heading {
  margin-top: 1.6em !important;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.content-body > .content-heading:first-child {
  margin-top: 0 !important;
}

/* Content pages (legal notice, privacy policy) */
.page-title {
  margin: 0 0 22px;
  font-family: var(--font-display);
  font-size: clamp(2rem, 9vw, 3.6rem);
  font-weight: 800;
  line-height: 0.95;
  text-transform: uppercase;
  hyphens: auto;
  -webkit-hyphens: auto;
}

.page-body {
  max-width: 70ch;
  overflow-wrap: break-word;
}

/* Footer links */
.site-footer {
  margin-top: 56px;
  padding-top: 18px;
  border-top: 2px solid var(--line);
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
}

.site-footer a {
  display: inline-block;
  padding: 8px 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--paper);
}

.load-error {
  display: grid;
  gap: 18px;
  max-width: 34rem;
}

.btn {
  justify-self: start;
  padding: 12px 22px;
  border: 0;
  background: var(--red);
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

.btn--ghost {
  background: transparent;
  color: var(--paper);
  box-shadow: inset 0 0 0 2px var(--paper);
}

.btn--ghost[aria-pressed='true'] {
  background: var(--paper);
  color: var(--ink);
}

.btn--danger {
  margin-top: 28px;
  background: transparent;
  color: var(--red);
  box-shadow: inset 0 0 0 2px var(--red);
}

.btn--danger:active {
  background: var(--red);
  color: var(--paper);
}

/* ------------------------------------------------------------------------ */
/* Dialogs: "add to list" sheet, list name, confirmation                     */
/* ------------------------------------------------------------------------ */

.sheet {
  /* --keyboard-inset: height of the on-screen keyboard (set by js/list-sheet.js), so the
     dialog moves up above it instead of being covered (iOS doesn't resize the viewport). */
  bottom: var(--keyboard-inset, 0px);
  width: min(100% - 32px, 28rem);
  max-height: calc(100dvh - var(--keyboard-inset, 0px) - 48px);
  padding: 0;
  border: 0;
  background: var(--bg-2);
  color: var(--paper);
  box-shadow: 6px 6px 0 var(--red);
}

.sheet::backdrop {
  background: rgb(0 0 0 / 0.7);
}

.sheet-body {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.sheet-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.sheet-text {
  margin: 0;
  font-weight: 600;
}

.sheet-lists {
  display: grid;
  gap: 4px;
  max-height: 45dvh;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.sheet-option {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 8px 12px;
  background: var(--bg);
  font-weight: 600;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.sheet-option input {
  flex: none;
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--red);
}

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

.sheet-new {
  display: flex;
  gap: 8px;
}

.text-input {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--bg);
  font-size: 1rem;
  -webkit-appearance: none;
  appearance: none;
}

.text-input:focus {
  border-color: var(--red);
  outline: none;
}

/* Share sheet: QR code (black on white, quiet zone is part of the SVG) + link actions */
.share-qr {
  justify-self: center;
  width: min(100%, 18rem);
  aspect-ratio: 1;
  background: #fff;
}

.share-qr svg {
  display: block;
  width: 100%;
  height: 100%;
}

.share-caption {
  display: grid;
  gap: 4px;
  text-align: center;
}

.share-caption p {
  margin: 0;
}

.share-name {
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.share-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.share-links .btn {
  flex: 1 1 10rem;
}

.share-status {
  margin: 0;
  color: var(--paper);
  font-weight: 600;
  text-align: center;
}

.share-status:empty {
  display: none;
}

.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

/* "Add chants" picker: header, search, chips and actions stay put; only the chant list scrolls. */
.sheet--picker {
  height: min(calc(100dvh - var(--keyboard-inset, 0px) - 48px), 44rem);
}

.sheet--picker .sheet-body {
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 12px;
  height: 100%;
  box-sizing: border-box;
}

.picker-head {
  display: grid;
  gap: 6px;
}

.picker-list-name {
  overflow-wrap: anywhere;
}

.picker-chips {
  display: flex;
  gap: 8px;
  margin: 0 -20px;
  padding: 0 20px;
  overflow-x: auto;
  scrollbar-width: none;
}

.picker-chips::-webkit-scrollbar {
  display: none;
}

.picker-chips .chip {
  flex: none;
  white-space: nowrap;
}

.picker-list {
  display: grid;
  align-content: start;
  gap: 4px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}

.picker-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 10px 12px;
  border-left: 5px solid var(--red);
  background: var(--bg);
  cursor: pointer;
}

.picker-item input {
  flex: none;
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--red);
}

.picker-item.is-in-list {
  border-left-color: var(--line);
  opacity: 0.55;
  cursor: default;
}

.picker-text {
  display: grid;
  gap: 2px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.picker-text .match-call,
.picker-text .match-response {
  font-size: 1.05rem;
}

.picker-note {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.picker-confirm:disabled {
  cursor: default;
}

/* "Add chants" button below a custom list (or its "still empty" text) */
.add-chants-btn {
  margin-top: 18px;
  color: var(--paper);
  box-shadow: 4px 4px 0 var(--paper);
}

.add-chants-btn:active {
  translate: 2px 2px;
  box-shadow: 2px 2px 0 var(--paper);
}

/* Phones: slide up from the bottom edge. */
@media (max-width: 600px) {
  .sheet {
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - var(--keyboard-inset, 0px) - 24px);
    margin: auto 0 0;
    /* The home indicator area only matters while the keyboard is closed. */
    padding-bottom: max(0px, var(--safe-bottom) - var(--keyboard-inset, 0px));
    box-shadow: 0 -6px 0 var(--red);
  }
}

/* ------------------------------------------------------------------------ */
/* Chant suggestions                                                         */
/* ------------------------------------------------------------------------ */

.suggest-btn {
  display: inline-block;
  color: var(--paper);
  text-decoration: none;
  box-shadow: 4px 4px 0 var(--paper);
}

.suggest-btn:active {
  translate: 2px 2px;
  box-shadow: 2px 2px 0 var(--paper);
}

.suggest-cta-text {
  max-width: 62ch;
  margin: 0 0 18px;
  color: var(--muted);
}

.results > .empty + .suggest-btn {
  margin-top: 4px;
}

.suggest-intro,
.suggest-note,
.suggest-email {
  max-width: 62ch;
  margin: 0 0 14px;
  line-height: 1.5;
}

.suggest-note,
.suggest-email {
  color: var(--muted);
}

.suggest-email {
  margin-top: 28px;
}

.suggest-email a {
  color: var(--paper);
  text-decoration-color: var(--red);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.suggest-form,
.suggest-done {
  display: grid;
  gap: 12px;
  max-width: 62ch;
  margin-top: 24px;
}

.suggest-label {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.suggest-text {
  width: 100%;
  min-height: 9em;
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--bg-2);
  font-size: 1.05rem;
  line-height: 1.45;
  resize: vertical;
  -webkit-appearance: none;
  appearance: none;
}

.suggest-text:focus {
  border-color: var(--red);
  outline: none;
}

.form-status:empty {
  display: none;
}

.form-status {
  margin: 0;
  padding-left: 12px;
  border-left: 4px solid var(--red);
  font-weight: 600;
}

.suggest-thanks {
  margin: 0;
  padding: 18px 20px;
  border-left: 5px solid var(--red);
  background: var(--bg-2);
  font-weight: 600;
}

.suggest-done:focus {
  outline: none;
}

/* Honeypot field: off-screen for people, still present for bots. */
.hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ------------------------------------------------------------------------ */
/* Player                                                                    */
/* ------------------------------------------------------------------------ */

.player {
  position: fixed;
  inset: 0;
  z-index: 10;
  height: 100dvh;
  background: var(--bg);
  color: var(--paper);
}

.player-bar {
  position: absolute;
  inset: 0 0 auto;
  z-index: 2;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: calc(var(--safe-top) + 8px) calc(var(--safe-right) + 8px) 8px calc(var(--safe-left) + 8px);
  background: linear-gradient(var(--bg) 55%, transparent);
}

.player-title {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.player-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-counter {
  flex: none;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.player-actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.icon-btn svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.icon-btn:active {
  background: rgb(255 255 255 / 0.1);
}

.icon-btn[aria-pressed='true'] {
  background: var(--red);
}

.icon-btn:disabled {
  opacity: 0.25;
  cursor: default;
}

.track {
  display: flex;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  outline: none;
}

.track::-webkit-scrollbar {
  display: none;
}

.slide {
  display: flex;
  flex: 0 0 100%;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding: calc(var(--safe-top) + 68px) calc(var(--safe-right) + 22px) calc(var(--safe-bottom) + 20px)
    calc(var(--safe-left) + 22px);
  scroll-snap-align: start;
  scroll-snap-stop: always;
  user-select: none;
  -webkit-user-select: none;
}

.slide-box {
  display: flex;
  flex: 1;
  align-items: center;
  min-height: 0;
  overflow: hidden;
}

.chant {
  width: 100%;
  font-family: var(--font-display);
  font-weight: 800;
  line-height: 0.98;
  text-transform: none;
  hyphens: manual;
}

.chant p {
  margin: 0;
  white-space: pre-line;
  text-wrap: balance;
}

.chant-line {
  display: block;
}

/* Hard line breaks get more room than soft wraps within a line. */
.chant-line + .chant-line {
  margin-top: 0.25em;
}

.chant-response {
  color: var(--red);
}

/* Second and later rounds of a call-and-response chant ("When do we want it?"). */
.chant-call--next {
  margin-top: 0.3em !important;
  padding-top: 0.25em;
  border-top: 0.04em solid var(--muted);
}

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

.slide-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
}

.slide-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Colour key for call-and-response chants: ■ Call ■ Response */
.call-key {
  display: flex;
  gap: 14px;
  margin: 0 0 0 auto;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.call-key-item {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.call-key-item::before {
  content: '';
  width: 0.8em;
  height: 0.8em;
  background: var(--paper);
}

.call-key-item--response::before {
  background: var(--red);
}

.tag {
  padding: 3px 9px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.tag:nth-child(odd) {
  transform: rotate(-2deg);
}

.tag:nth-child(even) {
  transform: rotate(1.5deg);
}

.tag--lang {
  display: none;
  background: transparent;
  color: var(--muted);
  box-shadow: inset 0 0 0 2px var(--line);
}

.slide--empty {
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: none;
  width: 56px;
  height: 56px;
  translate: 0 -50%;
  background: rgb(255 255 255 / 0.06);
}

.nav--prev {
  left: calc(var(--safe-left) + 10px);
}

.nav--next {
  right: calc(var(--safe-right) + 10px);
}

@media (hover: hover) and (pointer: fine) and (min-width: 700px) {
  .nav {
    display: inline-grid;
  }

  .slide {
    padding-left: calc(var(--safe-left) + 84px);
    padding-right: calc(var(--safe-right) + 84px);
  }
}

.player-progress {
  position: absolute;
  inset: auto 0 0;
  z-index: 2;
  height: 5px;
  background: var(--line);
}

.player-progress-bar {
  height: 100%;
  background: var(--red);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.25s ease;
}

.swipe-hint {
  position: absolute;
  right: calc(var(--safe-right) + 22px);
  bottom: calc(var(--safe-bottom) + 18px);
  z-index: 2;
  padding: 8px 14px;
  background: var(--red);
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  animation: nudge 1.4s ease-in-out 0.6s 3 both;
}

@keyframes nudge {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-14px); }
}

.player-bar,
.nav,
.slide-tags,
.call-key,
.swipe-hint {
  transition: opacity 0.2s ease;
}

.player.is-immersive .player-bar,
.player.is-immersive .nav,
.player.is-immersive .slide-tags,
.player.is-immersive .call-key,
.player.is-immersive .swipe-hint {
  opacity: 0;
  pointer-events: none;
}

/* ------------------------------------------------------------------------ */
/* Toast                                                                     */
/* ------------------------------------------------------------------------ */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 20px);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 4px 4px 0 var(--red);
  translate: -50% 0;
}

/* Keep toasts clear of the swipe hint and tags while the player is open. */
.has-player .toast {
  top: calc(var(--safe-top) + 64px);
  bottom: auto;
}

.toast-action {
  padding: 6px 12px;
  border: 0;
  background: var(--red);
  color: var(--paper);
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
