:root {
  --bg: #f4f1eb;
  --paper: #fbfaf6;
  --paper-soft: #ffffff;
  --ink: #43372d;
  --muted: #786450;
  --line: rgba(67, 55, 45, 0.1);
  --accent: #b48a3d;
  --accent-soft: rgba(180, 138, 61, 0.12);
  --accent-text: #6c4e1e;
  --chord: #b91c1c;
  --danger: #b91c1c;
  --shadow: 0 12px 30px rgba(67, 55, 45, 0.05);
  --font: "Lora", "Inter", -apple-system, sans-serif;
  --serif: "EB Garamond", Georgia, serif;
  --lyrics-font-size: 1.05rem;
  --chords-font-size: 1.05rem;
  --max-width: 1180px;

  /* Elegant Warm Tab Theme Variables */
  --tab-bg-1: #b07e6b; /* Terracotta */
  --tab-bg-2: #c69b5c; /* Antique Gold */
  --tab-bg-3: #8a9c72; /* Sage Green */
  --tab-bg-4: #6b8ca2; /* Slate Blue */
  --tab-bg-5: #a2856b; /* Warm Leather */
  --tab-bg-default: #988f86; /* Warm Gray */
  --tab-border: rgba(67, 55, 45, 0.15);
  --tab-border-active: rgba(67, 55, 45, 0.35);
  --tab-color: rgba(67, 55, 45, 0.85);
  --tab-color-active: rgba(45, 38, 31, 0.98);
}

:root[data-theme="dark"] {
  --bg: #1e1916;
  --paper: #2c241f;
  --paper-soft: #393029;
  --ink: #f2e6d6;
  --muted: #a69482;
  --line: rgba(242, 230, 214, 0.12);
  --accent: #d2a04b;
  --accent-soft: rgba(210, 160, 75, 0.18);
  --accent-text: #f0c36d;
  --chord: #f43f5e;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);

  /* elegant Dark Tab Theme Variables */
  --tab-bg-1: #805749; /* Deep Terracotta */
  --tab-bg-2: #9b723a; /* Deep Bronze */
  --tab-bg-3: #657453; /* Forest Sage */
  --tab-bg-4: #4e6b7f; /* Deep Slate Blue */
  --tab-bg-5: #7f6652; /* Deep Leather */
  --tab-bg-default: #6f6760; /* Dark Warm Gray */
  --tab-border: rgba(0, 0, 0, 0.45);
  --tab-border-active: rgba(0, 0, 0, 0.65);
  --tab-color: rgba(242, 230, 214, 0.8);
  --tab-color-active: rgba(255, 255, 255, 0.98);
}

:root[data-theme="dark"] .app-nav::before {
  background:
    linear-gradient(180deg,
      rgba(0, 0, 0, 0.4) 0 1px,
      transparent 1px 2px,
      rgba(0, 0, 0, 0.25) 2px 3px,
      transparent 3px 4px,
      rgba(0, 0, 0, 0.15) 4px 5px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  touch-action: manipulation;
}

body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.15) 0%, transparent 100%);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.45;
  touch-action: manipulation;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
a,
input,
select,
textarea {
  touch-action: manipulation;
}

button:focus,
button:focus-visible,
a:focus,
a:focus-visible,
[role="button"]:focus,
[role="button"]:focus-visible,
summary:focus,
summary:focus-visible,
*:focus:not(input):not(select):not(textarea):not(.search-box__controls),
*:focus-visible:not(input):not(select):not(textarea):not(.search-box__controls) {
  outline: none !important;
  box-shadow: none !important;
}

.hidden {
  display: none !important;
}

.app-shell {
  position: relative;
  width: min(calc(100% - 28px), var(--max-width));
  margin: 0 auto;
  padding: 18px 0 56px;
  background: var(--paper);
}

.book-body {
  position: relative;
}

.app-nav {
  position: absolute;
  right: -44px;
  top: 0;
  bottom: 0;
  z-index: 150;
  display: grid;
  align-content: start;
  gap: 0;
  width: 46px;
  padding: max(45px, calc(env(safe-area-inset-top) + 21px)) 0 max(18px, env(safe-area-inset-bottom));
  background: transparent;
  pointer-events: none;
}

.app-nav::before {
  content: "";
  position: absolute;
  top: 18px;
  bottom: 18px;
  left: 0;
  width: 5px;
  background:
    linear-gradient(90deg,
      rgba(67, 55, 45, 0.2) 0 1px,
      transparent 1px 2px,
      rgba(67, 55, 45, 0.11) 2px 3px,
      transparent 3px 4px,
      rgba(67, 55, 45, 0.07) 4px 5px);
  border-radius: 999px;
  display: none;
}

.app-nav__item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  width: 46px;
  min-height: 108px;
  padding: 0;
  color: var(--tab-color);
  pointer-events: auto;
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  filter: drop-shadow(4px 4px 12px rgba(67, 55, 45, 0.08));
  z-index: var(--tab-z-index, 10);
}

.app-nav__item:nth-child(1) {
  --tab-bg: var(--tab-bg-1);
}

.app-nav__item:nth-child(2) {
  --tab-bg: var(--tab-bg-2);
}

.app-nav__item:nth-child(3) {
  --tab-bg: var(--tab-bg-3);
}

.app-nav__item:nth-child(4) {
  --tab-bg: var(--tab-bg-4);
}

.app-nav__item:nth-child(5) {
  --tab-bg: var(--tab-bg-5);
}

.app-nav__item:nth-child(n+6) {
  --tab-bg: var(--tab-bg-default);
}

.app-nav__item::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-color: var(--tab-border); /* Dynamic border color */
  clip-path: polygon(0 0, calc(100% - 4px) 11px, 100% 16px, 100% calc(100% - 16px), calc(100% - 4px) calc(100% - 11px), 0 100%);
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.app-nav__item::after {
  content: "";
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  left: 0;
  z-index: 2;
  pointer-events: none;
  background-color: var(--tab-bg);
  background-image: linear-gradient(90deg, rgba(255, 255, 255, 0.12), transparent 58%);
  clip-path: polygon(0 0, calc(100% - 4px) 11px, 100% 16px, 100% calc(100% - 16px), calc(100% - 4px) calc(100% - 11px), 0 100%);
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.app-nav__item:hover,
.app-nav__item:focus-visible {
  color: var(--tab-color-active);
  filter: saturate(1.15) contrast(1.02) drop-shadow(6px 6px 16px rgba(67, 55, 45, 0.14));
  z-index: calc(var(--tab-z-index, 10) + 2);
}

.app-nav__item:hover::after,
.app-nav__item:focus-visible::after {
  background-image: linear-gradient(90deg, rgba(255, 255, 255, 0.28), transparent 58%);
}

.app-nav__item.is-active {
  color: var(--tab-color-active);
  filter: saturate(1.15) contrast(1.02) drop-shadow(8px 8px 18px rgba(67, 55, 45, 0.18));
  z-index: 100 !important;
}

.app-nav__item.is-active::before {
  background-color: var(--tab-border-active); /* Darker active border */
}

.app-nav__item.is-active::after {
  background-image: linear-gradient(90deg, rgba(255, 255, 255, 0.28), transparent 58%);
}

.app-nav__item + .app-nav__item {
  margin-top: -15px;
}

.app-nav__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  position: relative;
  z-index: 3;
}

.app-nav__label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.app-nav__icon svg {
  width: 27px;
  height: 27px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

/* Navigation User Profile Badge (Floating Circle) */
.app-nav__user-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--paper-soft);
  border: 1.5px solid var(--accent);
  box-shadow: 0 4px 10px rgba(67, 55, 45, 0.15);
  cursor: pointer;
  pointer-events: auto;
  margin: auto auto max(24px, env(safe-area-inset-bottom)) auto; /* Center horizontally in vertical nav column */
  align-self: center; /* Center horizontally aligned with other nav items */
  padding: 0;
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 200; /* Float above the book border shadow and lines */
  text-decoration: none !important;
  flex-shrink: 0;
  box-sizing: border-box;
}

.app-nav__user-badge:hover {
  transform: scale(1.15);
  box-shadow: 0 6px 14px rgba(180, 138, 61, 0.3);
}

.app-nav__user-badge svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-nav__user-badge img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.app-nav__user-badge-initial {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: var(--accent);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
}

@media (max-width: 480px) {
  .app-nav__user-badge {
    margin: auto 0 auto auto; /* Push to the rightmost side with 0 right margin (12px parent padding) */
    align-self: center;
    position: relative;
    left: 8px;
    top: -3px;
  }
}

@media (min-width: 481px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .app-shell {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    transform: none;
    border: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
  }

  .app-nav {
    right: 2px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding-bottom: 0;
  }

  .app-nav__user-badge {
    position: relative;
    left: 5px;
    margin-bottom: 4px;
  }

  .app-nav__item {
    flex: 0 1 108px;
    max-height: 108px;
    min-height: 60px;
  }

  .book-body {
    flex: 1 1 auto;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding-top: 24px;
    padding-bottom: 56px;
    margin-right: 46px;
    border-right: 1px solid var(--line);
    box-shadow: 
      1px 0 0 #ffffff,
      2px 0 0 rgba(67, 55, 45, 0.08),
      3px 0 0 #ffffff,
      4px 0 0 rgba(67, 55, 45, 0.08),
      5px 0 0 #ffffff,
      6px 0 0 rgba(67, 55, 45, 0.08);
    border-radius: inherit;
    scroll-behavior: smooth;
    direction: rtl;
  }

  :root[data-theme="dark"] .book-body {
    box-shadow: 
      1px 0 0 #2a211a,
      2px 0 0 rgba(0, 0, 0, 0.35),
      3px 0 0 #2a211a,
      4px 0 0 rgba(0, 0, 0, 0.35),
      5px 0 0 #2a211a,
      6px 0 0 rgba(0, 0, 0, 0.35);
  }


  .book-body > * {
    direction: ltr;
  }

  .book-body::-webkit-scrollbar {
    width: 8px;
  }

  .book-body::-webkit-scrollbar-track {
    background: transparent;
  }

  .book-body::-webkit-scrollbar-thumb {
    background-color: rgba(67, 55, 45, 0.15);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
  }

  .book-body::-webkit-scrollbar-thumb:hover {
    background-color: rgba(67, 55, 45, 0.3);
  }
}

.detail-panel {
  border: 1px solid var(--line);
  background: var(--paper-soft);
  border-radius: 14px;
  box-shadow: 0 4px 12px rgba(67, 55, 45, 0.03);
}

:root[data-theme="dark"] .detail-panel {
  background: var(--paper-soft);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  width: 100%;
}

.empty-state h3 {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--ink);
  margin: 0 0 8px 0;
  opacity: 0.85;
}

.empty-state p {
  font-size: 0.9rem;
  color: var(--muted);
  max-width: 420px;
  margin: 0;
  line-height: 1.5;
}

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 96px;
  padding: 24px;
  color: var(--muted);
  font-weight: 700;
}

.loading-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(116, 93, 67, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: loading-spin 0.8s linear infinite;
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

.song-list-item__meta,
.song-list-item__footer,
.section-heading,
.detail-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 3px 10px;
  border: 1px solid rgba(180, 138, 61, 0.3);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.detail-hero h1,
.section-heading h2,
.song-list-item h3 {
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 800;
  letter-spacing: 0;
}

.section-heading p,
.song-list-item__excerpt,
.song-list-item__composers,
.results-count,
.empty-state p,
.detail-panel p {
  color: var(--muted);
}

.theme-toggle,
.favorite-button,
.primary-button,
.secondary-button,
.danger-button,
.primary-link,
.secondary-link,
.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.28);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.theme-toggle {
  width: 44px;
  padding: 0;
}

.favorite-button {
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 50%;
  color: var(--accent-text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 1.15rem;
  line-height: 1;
  transition: transform 0.2s, background-color 0.2s, border-color 0.2s;
}

.favorite-button.is-favorite {
  border-color: rgba(214, 31, 58, 0.3);
  background: rgba(214, 31, 58, 0.1);
  color: var(--chord);
}


.lyrics-toolbar svg,
.theme-toggle svg,
.search-box__submit svg,
.toolbar-icon-button--columns svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primary-button {
  background: var(--accent);
  color: #fff7e8;
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.danger-button {
  color: #fee2e2;
  background: var(--danger);
}

.search-box {
  position: relative;
  display: grid;
  gap: 10px;
  max-width: 860px;
  margin: 24px auto 0;
  text-align: left;
  min-width: 0;
}

.book-controls {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.book-controls .search-box {
  width: 100%;
  max-width: 600px;
  margin: 0;
}

.book-controls .filter-bar {
  width: 100%;
  max-width: 600px;
  margin: 0;
}

.control-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 600px;
  margin: 8px 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  user-select: none;
}

.control-divider::before,
.control-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
  opacity: 0.5;
}

.control-divider::before {
  margin-right: 16px;
}

.control-divider::after {
  margin-left: 16px;
}

.search-box label,
.filter-field span,
.eyebrow {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}


.search-box__controls {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 2px 4px rgba(67, 55, 45, 0.06);
  transition: all 0.25s cubic-bezier(0.25, 1, 0.5, 1);
  min-width: 0;
}

.search-box__controls:focus-within {
  border-color: var(--accent);
  box-shadow: 
    inset 0 2px 4px rgba(67, 55, 45, 0.06),
    0 0 0 3px var(--accent-soft);
}

:root[data-theme="dark"] .search-box__controls {
  background: rgba(0, 0, 0, 0.15);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.35);
}

:root[data-theme="dark"] .search-box__controls:focus-within {
  box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.35),
    0 0 0 3px var(--accent-soft);
}

.search-box__type-label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.search-box__type {
  flex: 0 1 auto;
  width: 132px;
  min-width: 0 !important;
  max-width: 100% !important;
  min-height: 38px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 999px 0 0 999px;
  background:
    linear-gradient(45deg, transparent 50%, currentColor 50%) calc(100% - 18px) 50% / 6px 6px no-repeat,
    linear-gradient(135deg, currentColor 50%, transparent 50%) calc(100% - 12px) 50% / 6px 6px no-repeat,
    transparent;
  color: var(--accent-text);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  outline: none;
  padding: 0 30px 0 12px;
  appearance: none;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.filter-field input,
.filter-field select {
  width: 100%;
  min-width: 0 !important;
  max-width: 100% !important;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  color: var(--ink);
  padding: 10px 16px;
  font: inherit;
  outline: none;
  box-shadow: inset 0 2px 4px rgba(67, 55, 45, 0.05);
  transition: all 0.25s cubic-bezier(0.25, 1, 0.5, 1);
}

.filter-field input:focus {
  border-color: var(--accent);
  box-shadow: 
    inset 0 2px 4px rgba(67, 55, 45, 0.05),
    0 0 0 3px var(--accent-soft);
}

:root[data-theme="dark"] .filter-field input,
:root[data-theme="dark"] .filter-field select {
  background-color: rgba(0, 0, 0, 0.15);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.35);
}

.filter-field select {
  appearance: none;
  min-height: 46px;
  padding-right: 46px;
  background-color: rgba(255, 255, 255, 0.45);
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%),
    linear-gradient(90deg, transparent, rgba(67, 55, 45, 0.1));
  background-position:
    calc(100% - 24px) 50%,
    calc(100% - 18px) 50%,
    calc(100% - 44px) 50%;
  background-repeat: no-repeat;
  background-size: 6px 6px, 6px 6px, 1px 24px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 600;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.filter-field select:hover {
  border-color: rgba(180, 138, 61, 0.3);
  background-color: rgba(255, 255, 255, 0.55);
}

.filter-field select:focus {
  border-color: var(--accent);
  box-shadow: 
    inset 0 2px 4px rgba(67, 55, 45, 0.05),
    0 0 0 3px var(--accent-soft);
}

:root[data-theme="dark"] .filter-field select {
  background-color: rgba(255, 255, 255, 0.06);
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%),
    linear-gradient(90deg, transparent, rgba(242, 230, 214, 0.14));
}

:root[data-theme="dark"] .filter-field select:hover {
  background-color: rgba(255, 255, 255, 0.09);
}

.search-box input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0 12px;
  font: inherit;
  outline: none;
}

.search-box input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.search-box__clear {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 1.35rem;
  line-height: 1;
  padding: 0;
}

.search-box__clear:hover,
.search-box__clear:focus-visible {
  background: rgba(67, 55, 45, 0.08);
  color: var(--ink);
}

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

:root[data-theme="dark"] .search-box__clear:hover,
:root[data-theme="dark"] .search-box__clear:focus-visible {
  background: rgba(255, 255, 255, 0.1);
}

.search-box__submit {
  flex: 0 0 auto;
  width: 38px;
  min-height: 38px;
  padding: 0;
}

.search-suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  z-index: 70;
  display: grid;
  max-height: min(320px, 52vh);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper-soft) !important;
  box-shadow: 0 18px 40px rgba(67, 55, 45, 0.18);
  padding: 6px;
}

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

.search-suggestions__item {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-align: left;
  padding: 10px 14px;
}

.search-suggestions__item:hover,
.search-suggestions__item:focus-visible,
.search-suggestions__item.is-active {
  background: var(--accent-soft);
  color: var(--accent-text);
  outline: none;
}

:root[data-theme="dark"] .search-suggestions {
  background: var(--paper-soft) !important;
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  max-width: 860px;
  margin: 14px auto 0;
  text-align: left;
}

@media (max-width: 767px) {
  .book-controls {
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
  }
}

.filter-field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.section-heading {
  align-items: baseline;
  flex-wrap: nowrap;
  margin: 34px 0 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.section-heading > div {
  min-width: 0;
  flex: 1 1 auto;
}

.section-heading h2 {
  margin: 4px 0 0;
  font-size: clamp(1.45rem, 2.6vw, 2.05rem);
}

.results-count {
  margin: 0;
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 0.9rem;
}

.detail-layout > * {
  min-width: 0;
}

.song-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  counter-reset: toc;
}

.song-list-item-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(67, 55, 45, 0.08);
  counter-increment: toc;
  transition: all 0.25s cubic-bezier(0.25, 1, 0.5, 1);
  border-radius: 8px;
  margin: 0 -8px;
  padding: 0 8px;
}

.song-list-item-row:hover {
  background: rgba(180, 138, 61, 0.04);
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(67, 55, 45, 0.03);
}

:root[data-theme="dark"] .song-list-item-row:hover {
  background: rgba(210, 160, 75, 0.05);
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.12);
}

.song-list-item-row:last-child {
  border-bottom: 0;
}

.song-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(86px, auto);
  gap: 8px 16px;
  min-height: 0;
  align-content: start;
  padding: 15px 0 15px 38px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  box-shadow: none;
}

.song-list-item-row::before {
  content: counter(toc, decimal-leading-zero);
  position: absolute;
  left: 12px;
  top: 17px;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 0.82rem;
  font-weight: 800;
}

.song-list-item__view-badge {
  position: absolute;
  left: 9px;
  top: 36px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0.8;
}

.song-list-item__view-badge .icon {
  width: 11px;
  height: 11px;
  background-color: currentColor;
}

.song-list-item:hover,
.song-list-item:focus-visible {
  color: var(--accent-text);
}

.song-list-item h3 {
  grid-column: 1;
  grid-row: 2;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  background: transparent;
  font-size: clamp(1rem, 1.8vw, 1.22rem);
  line-height: 1.18;
}

.song-list-item h3::after {
  content: "";
  flex: 1;
  height: 1px;
  background-image: radial-gradient(currentColor 1px, transparent 1.5px);
  background-position: left center;
  background-repeat: repeat-x;
  background-size: 8px 2px;
  color: rgba(67, 55, 45, 0.26);
  opacity: 0.75;
}


.song-list-item__excerpt {
  grid-column: 1 / 3;
  display: -webkit-box;
  min-height: 0;
  margin: 2px 0 0;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 0.92rem;
}

.song-list-item__meta {
  grid-column: 1 / 3;
  justify-content: flex-start;
}

.song-list-item__info {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.song-list-item__sep {
  color: var(--muted);
  opacity: 0.4;
  font-size: 0.72rem;
}

.song-list-item__composers {
  color: var(--muted);
}

.song-list-item__rhythms {
  font-weight: 700;
  color: var(--ink);
}

.song-list-item__tone-meta {
  font-weight: 800;
  color: var(--accent-text);
}

.song-list-item__footer {
  grid-column: 2;
  grid-row: 2;
  position: relative;
  z-index: 1;
  align-self: center;
  justify-content: flex-end;
  gap: 10px;
  background: transparent;
}

.song-list-item__tone {
  color: var(--accent-text);
  font-weight: 800;
}

.song-list-item__favorite {
  margin-right: 10px;
}

.load-more-row {
  display: flex;
  justify-content: center;
  margin: 28px 0 4px;
}

.standard-page {
  min-height: calc(100dvh - 74px);
  padding: clamp(22px, 3.4vw, 42px) clamp(18px, 5vw, 64px) clamp(28px, 5vw, 64px);
  background: transparent;
}

.page-header {
  position: relative;
  padding-right: 56px;
}

.page-header h1 {
  margin: 6px 0 8px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  line-height: 1;
  letter-spacing: 0;
}

.page-header p:not(.eyebrow) {
  max-width: 660px;
  margin: 0;
  color: var(--muted);
}

.page-header .theme-toggle {
  position: absolute;
  top: 0;
  right: 0;
  width: 38px;
  min-height: 38px;
  border-radius: 50%;
  background: var(--paper-soft);
  box-shadow: 0 8px 18px rgba(67, 55, 45, 0.1);
}

.page-section {
  margin-top: 24px;
}

/* Detail sheet */
body:has(#detail-layout) .app-shell {
  padding-block: clamp(14px, 2.6vw, 32px) 12px; /* Reduced bottom padding from 72px to prevent accumulating whitespace */
}

body:has(#detail-layout) .detail-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: clamp(28px, 4.5vw, 56px) clamp(18px, 5vw, 64px) clamp(16px, 3vw, 24px);
  border: 0;
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
  background: var(--paper);
  box-shadow: none;
}

.detail-favorite {
  position: absolute;
  top: 18px;
  right: clamp(18px, 5vw, 64px);
  z-index: 2;
  background: var(--paper-soft);
  box-shadow: 0 8px 18px rgba(67, 55, 45, 0.1);
}

body:has(#detail-layout) .detail-hero h1 {
  width: 100%;
  max-width: 1000px;
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-style: italic;
  font-weight: 700;
  font-size: clamp(1.9rem, 4.5vw, 3.2rem);
  line-height: 1.1;
  text-align: center;
}

.detail-hero__divider {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 260px;
  margin: 14px auto;
  gap: 12px;
  color: var(--accent);
}

.detail-hero__divider-line {
  flex: 1;
  height: 1px;
  background: currentColor;
  opacity: 0.55;
  position: relative;
}

.detail-hero__divider-line::after {
  content: '';
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  top: 50%;
  transform: translateY(-50%);
}

.detail-hero__divider-line--left::after {
  left: 0;
}

.detail-hero__divider-line--right::after {
  right: 0;
}

.detail-hero__divider-diamond {
  width: 9px;
  height: 9px;
  background: currentColor;
  transform: rotate(45deg);
  flex-shrink: 0;
}

.detail-hero__meta {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  width: 100%;
  max-width: 800px;
  color: var(--muted);
  font-size: clamp(0.85rem, 1.2vw, 0.95rem);
  font-weight: 500;
  line-height: 1.4;
}

.detail-hero__meta-item {
  display: inline-flex;
  align-items: center;
}

.detail-hero__meta-label {
  margin-right: 6px;
  opacity: 0.82;
}

.detail-hero__meta-item:empty {
  display: none !important;
}

.detail-hero__meta-sep {
  color: var(--muted);
  opacity: 0.6;
  user-select: none;
}

.detail-hero__meta-item:empty + .detail-hero__meta-sep,
.detail-hero__meta-item.hidden + .detail-hero__meta-sep {
  display: none !important;
}

.detail-hero__meta-item a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s;
}

.detail-hero__meta-item a:hover {
  color: var(--accent-text);
}

.detail-filter-list {
  display: inline;
}

.detail-filter-link {
  text-decoration: none;
}

.hero-song-meta {
  grid-column: 2;
  grid-row: 3;
  display: grid;
  gap: 8px;
  margin-top: 0;
  font-family: var(--serif);
}

.hero-song-meta__item {
  display: block;
  width: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: clamp(0.92rem, 1.24vw, 1.02rem);
}

.hero-song-meta__item strong {
  display: inline;
  margin-right: 8px;
  color: var(--ink);
  font: inherit;
  letter-spacing: 0;
  text-transform: none;
}

.song-performers__disclosure {
  border-bottom: 1px solid var(--line);
  margin-top: 0;
}

.song-performers__summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  cursor: pointer;
  list-style: none;
  user-select: none;
  min-height: 48px;
}

.song-performers__summary::-webkit-details-marker {
  display: none;
}

.song-performers__label-text {
  flex: 0 0 auto;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.song-performers__chevron {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  margin-left: auto;
  color: var(--muted);
  transition: transform 160ms ease, color 0.2s;
}

.song-performers__summary:hover .song-performers__chevron {
  color: var(--accent-text);
}

#detail-performers-disclosure[open] .song-performers__chevron {
  transform: rotate(180deg);
}

/* YouTube full player in song performers */
.performers-player {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  
  /* Collapsed state by default */
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  margin-top: 0;
  padding: 0 12px;
  border: 0 solid transparent;
  pointer-events: none;
  
  background: var(--paper-soft);
  border-radius: 8px;
  
  /* Smooth butter-like transition */
  transition: 
    max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.25s ease-out,
    margin-top 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    padding 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    border-width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Expanded state when open */
.performers-player.active {
  max-height: 400px; /* Big enough to fit the video aspect ratio and paddings */
  opacity: 1;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  pointer-events: auto;
}

.performers-player__clip {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 6px;
  background: #000;
  position: relative;
}

.performers-player__frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.song-performers__grid-wrapper {
  width: 100%;
  padding-bottom: 16px;
}

.song-performers__list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 2px 24px;
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
}

.song-performers__item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
  transition: background-color 0.25s, padding 0.25s;
}

.song-performers__item--active {
  background: var(--paper-soft);
  border-radius: 8px;
  padding-inline: 12px;
  margin-inline: -12px;
  border-bottom-color: transparent;
}

.song-performers__row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  width: 100%;
}

.song-performers__item:last-child {
  border-bottom: none;
}

.song-performers__tone {
  flex-shrink: 0;
  min-width: 34px;
  min-height: 26px;
  padding: 3px 7px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  transition: background-color 0.2s, color 0.2s;
  cursor: pointer;
  border: 0;
  font: inherit;
  outline: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.song-performers__tone--original {
  background: var(--accent);
  color: #fff;
}

.song-performers__tone:hover {
  filter: brightness(0.95);
}

:root[data-theme="dark"] .song-performers__tone:hover {
  filter: brightness(1.1);
}

.song-performers__name {
  flex: 1;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.song-performers__name a {
  color: inherit;
  text-decoration: none;
}

.song-performers__name a:hover {
  text-decoration: underline;
}

.song-performers__play {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--accent-text);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
}

.song-performers__play:hover {
  background: var(--accent-soft);
  transform: scale(1.08);
}

.song-performers__play.playing {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-size: 0.7rem; /* Make the stop square look perfectly proportional */
  box-shadow: 0 0 10px rgba(var(--accent-rgb, 0, 0, 0), 0.2);
}

.song-performers__play.playing:hover {
  background: var(--accent-hover, var(--accent));
  transform: scale(1.08);
}



.detail-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 0;
  padding: 0 clamp(18px, 5vw, 64px) 16px; /* Reduced bottom padding from clamp(28px, 5vw, 64px) to 16px */
  border: 0;
  border-bottom-left-radius: inherit;
  border-bottom-right-radius: inherit;
  background: var(--paper);
  box-shadow: none;
}

.detail-panel {
  padding: 18px;
  border-radius: 14px;
}

.detail-panel--full {
  grid-column: 1 / -1;
}

.chord-library {
  padding: 0;
  border: 0;
  background: transparent !important;
  box-shadow: none !important;
}

.chord-library__disclosure {
  border-block: 1px solid var(--line);
  margin-bottom: 0;
}

.chord-library__disclosure,
.song-performers__disclosure {
  margin: 0;
}

.chord-library__summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  cursor: pointer;
  list-style: none;
  user-select: none;
  min-height: 48px;
}

.chord-library__summary:focus,
.chord-library__summary:focus-visible,
.song-performers__summary:focus,
.song-performers__summary:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

.chord-library__summary::-webkit-details-marker {
  display: none;
}

.chord-library__chevron {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  margin-left: auto;
  color: var(--muted);
  transition: transform 160ms ease, color 0.2s;
}

.chord-library__summary:hover .chord-library__chevron {
  color: var(--accent-text);
}

#chord-library-disclosure[open] .chord-library__chevron {
  transform: rotate(180deg);
}

.chord-pill-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.chord-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 0.82rem;
  font-weight: 800;
  transition: background-color 0.2s, color 0.2s;
}

.chord-pill--tonic {
  background: var(--accent);
  color: #fff;
}

.rhythm-guide {
  display: none !important; /* Temporarily hidden per user request */
  gap: 8px;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.24);
}

.rhythm-guide__label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.rhythm-guide__main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.rhythm-guide__title,
.rhythm-guide__count {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 800;
}

.rhythm-guide__pattern {
  color: var(--ink);
  font-weight: 800;
  letter-spacing: 0.08em;
}

.rhythm-guide__note {
  margin: 0;
  color: var(--muted);
}

.chord-list {
  list-style: none;
  margin: 16px 0 16px 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(116px, 1fr));
  gap: clamp(12px, 2.4vw, 24px);
}

.chord-card {
  display: grid;
  gap: 8px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.chord-card__title {
  margin: 0;
  color: var(--ink);
  font-family: Arial, sans-serif;
  font-size: 1.2rem;
  font-weight: 500;
  line-height: 1;
  text-align: left;
}

.chord-card__diagram {
  display: grid;
  place-items: start center;
  min-height: 118px;
}

.chord-card__diagram--fallback {
  display: grid;
  place-items: center;
  min-height: 100px;
  border: 1px dashed var(--line);
  color: var(--chord);
  font-weight: 800;
}

.chord-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--muted);
  width: 100%;
}

.chord-card__nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper-soft);
  color: var(--ink);
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}

.chord-card__nav:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--accent-text);
  transform: scale(1.1);
}

.chord-card__nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.chord-card__footer-label {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.65rem;
}

.chord-card__footer-count {
  font-weight: 700;
  color: var(--accent-text);
}

.chord-diagram {
  width: 100%;
  max-width: 110px;
  overflow: visible;
}

.chord-diagram__fret,
.chord-diagram__string,
.chord-diagram__nut {
  stroke: var(--ink);
  stroke-width: 1.4;
}

.chord-diagram__nut--thick {
  stroke-width: 3.2;
}

.chord-diagram__top-marker,
.chord-diagram__base-fret,
.chord-diagram__finger {
  font-family: var(--font);
  text-anchor: middle;
}

.chord-diagram__top-marker,
.chord-diagram__base-fret {
  fill: var(--ink);
  font-size: 0.9rem;
}

.chord-diagram__base-fret {
  text-anchor: start;
}

.chord-diagram__dot,
.chord-diagram__barre {
  fill: var(--ink);
  stroke: transparent;
}

.chord-diagram__finger {
  fill: var(--paper);
  font-size: 0.9rem;
  font-weight: 800;
}

/* Lyrics controls */
#lyrics-section {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.lyrics-toolbar {
  position: fixed;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 10px;
  width: calc(100% - 24px);
  max-width: 840px;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(16px);
  transform: translateX(-50%);
}

.lyrics-toolbar__scroll {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: none;
}

.lyrics-toolbar__scroll::-webkit-scrollbar {
  display: none;
}

.lyrics-toolbar__end,
.lyrics-toolbar__group,
.lyrics-toolbar__cluster {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.lyrics-toolbar__end {
  margin-left: auto;
}

.lyrics-toolbar__divider {
  flex: 0 0 auto;
  width: 1px;
  height: 20px;
  min-height: 20px;
  background: var(--line);
  align-self: center;
}

/* Auto-scroll is only visible in fullscreen/virtual-fullscreen modes */
.lyrics-toolbar__divider--auto-scroll,
.lyrics-toolbar__group--auto-scroll {
  display: none !important;
}

#lyrics-section:fullscreen .lyrics-toolbar__divider--auto-scroll,
#lyrics-section:-webkit-full-screen .lyrics-toolbar__divider--auto-scroll,
#lyrics-section.is-virtual-fullscreen .lyrics-toolbar__divider--auto-scroll {
  display: block !important;
}

#lyrics-section:fullscreen .lyrics-toolbar__group--auto-scroll,
#lyrics-section:-webkit-full-screen .lyrics-toolbar__group--auto-scroll,
#lyrics-section.is-virtual-fullscreen .lyrics-toolbar__group--auto-scroll {
  display: flex !important;
}

/* Mutual exclusion between 2-column mode and auto-scroll */
#lyrics-section.is-two-columns .lyrics-toolbar__divider--auto-scroll,
#lyrics-section.is-two-columns .lyrics-toolbar__group--auto-scroll {
  display: none !important;
}

#lyrics-section.is-auto-scroll-active .lyrics-toolbar__divider--columns,
#lyrics-section.is-auto-scroll-active .lyrics-toolbar__group--columns {
  display: none !important;
}

.lyrics-toolbar__cluster {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.03);
  padding: 0;
  height: 42px;
  box-sizing: border-box;
}

:root[data-theme="dark"] .lyrics-toolbar__cluster {
  background: rgba(255, 255, 255, 0.05);
}

.transpose-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 0 !important;
  height: 100% !important;
  padding: 0 !important;
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
}

.transpose-key {
  font-size: 0.88rem;
  font-weight: 600;
}

.transpose-rhythm {
  font-size: 0.58rem;
  color: var(--accent-text);
  font-weight: 500;
  white-space: nowrap;
}



.transpose-status--button {
  cursor: pointer;
}

.auto-scroll-status {
  position: relative !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 42px !important;
  min-width: 42px !important;
  padding: 0 !important;
}

.auto-scroll-status__icon {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 0.95rem !important;
  line-height: 1 !important;
  margin: 0 !important;
}

.auto-scroll-status__speed {
  position: absolute !important;
  bottom: 3px !important;
  left: 0 !important;
  right: 0 !important;
  text-align: center !important;
  font-size: 0.62rem !important;
  font-weight: 500 !important;
  opacity: 0.8;
  line-height: 1 !important;
  margin: 0 !important;
}

.transpose-button,
.font-size-button,
.display-mode-button,
.toolbar-icon-button {
  height: 100%;
  min-height: 0 !important;
  padding: 0 !important;
}

/* Global button styles for items inside a cluster */
.lyrics-toolbar__cluster button {
  height: 100% !important;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  margin: 0 !important;
  width: 42px !important;
  min-width: 42px !important;
  font-family: "Inter", -apple-system, sans-serif !important;
  font-weight: 800 !important;
  font-size: 1.05rem !important;
}

/* Don't bold chords (transpose status) and font size buttons (A+, A-) */
.lyrics-toolbar__cluster .font-size-button {
  font-weight: 500 !important;
}

.lyrics-toolbar__cluster .transpose-status {
  font-weight: 500 !important;
  width: 48px !important;
  min-width: 48px !important;
}

.lyrics-toolbar__cluster .transpose-status--with-rhythm {
  display: inline-flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  align-items: center !important;
  width: auto !important;
  min-width: 54px !important;
  padding: 0 8px !important;
  line-height: 1.15 !important;
  gap: 1px !important;
}

/* Rounded ends of the cluster capsule */
.lyrics-toolbar__cluster button:first-of-type {
  border-top-left-radius: 999px !important;
  border-bottom-left-radius: 999px !important;
}

.lyrics-toolbar__cluster button:last-of-type {
  border-top-right-radius: 999px !important;
  border-bottom-right-radius: 999px !important;
}

/* Thin vertical separator line between cluster buttons */
.lyrics-toolbar__cluster button:not(:first-of-type) {
  border-left: 1px solid var(--line) !important;
}

@media (hover: hover) {
  /* Hover style inside clusters */
  .lyrics-toolbar__cluster button:hover:not(:disabled):not([aria-pressed="true"]) {
    background: rgba(0, 0, 0, 0.05) !important;
  }

  :root[data-theme="dark"] .lyrics-toolbar__cluster button:hover:not(:disabled):not([aria-pressed="true"]) {
    background: rgba(255, 255, 255, 0.08) !important;
  }
}

/* Active style inside clusters */
.lyrics-toolbar__cluster button[aria-pressed="true"],
.lyrics-toolbar__cluster button[aria-pressed="true"]:hover {
  background: var(--accent-soft) !important;
  color: var(--accent-text) !important;
}

/* Active style for standalone buttons (outside clusters) */
.lyrics-toolbar > button[aria-pressed="true"],
.lyrics-toolbar__group > button[aria-pressed="true"],
.lyrics-toolbar__end > button[aria-pressed="true"] {
  background: var(--accent-soft) !important;
  color: var(--accent-text) !important;
}

/* Disable default focus outline/ring on click */
.lyrics-toolbar button:focus,
.lyrics-toolbar button:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

/* Clear background on focus only for INACTIVE buttons to prevent overriding active highlight */
.lyrics-toolbar button:focus:not([aria-pressed="true"]),
.lyrics-toolbar button:focus-visible:not([aria-pressed="true"]) {
  background: transparent !important;
}

.lyrics-toolbar button {
  -webkit-tap-highlight-color: transparent !important;
}

/* Standalone buttons styles (outside clusters) */
.lyrics-toolbar > button,
.lyrics-toolbar__group > button,
.lyrics-toolbar__end > button {
  border: 1px solid var(--line) !important;
  background: rgba(0, 0, 0, 0.03) !important;
  border-radius: 999px !important;
  height: 42px !important;
  width: 42px !important;
  min-width: 42px !important;
  min-height: 0 !important;
}

:root[data-theme="dark"] .lyrics-toolbar > button:not([aria-pressed="true"]),
:root[data-theme="dark"] .lyrics-toolbar__group > button:not([aria-pressed="true"]),
:root[data-theme="dark"] .lyrics-toolbar__end > button:not([aria-pressed="true"]) {
  background: rgba(255, 255, 255, 0.05) !important;
}

@media (hover: hover) {
  .lyrics-toolbar > button:hover:not(:disabled):not([aria-pressed="true"]),
  .lyrics-toolbar__group > button:hover:not(:disabled):not([aria-pressed="true"]),
  .lyrics-toolbar__end > button:hover:not(:disabled):not([aria-pressed="true"]) {
    background: rgba(0, 0, 0, 0.05) !important;
  }

  :root[data-theme="dark"] .lyrics-toolbar > button:hover:not(:disabled):not([aria-pressed="true"]),
  :root[data-theme="dark"] .lyrics-toolbar__group > button:hover:not(:disabled):not([aria-pressed="true"]),
  :root[data-theme="dark"] .lyrics-toolbar__end > button:hover:not(:disabled):not([aria-pressed="true"]) {
    background: rgba(255, 255, 255, 0.12) !important;
  }
}

.transpose-tooltip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  z-index: 40;
  width: min(280px, calc(100vw - 40px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

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

.transpose-tooltip__option {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.24);
  color: var(--ink);
  padding: 10px 8px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.transpose-tooltip__option.is-active {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.lyrics-card {
  margin: 0 auto;
  padding: 0 0 calc(48px + env(safe-area-inset-bottom)); /* Ultra-compact padding, perfectly calculated to display right above the toolbar */
  border: 0;
  background: transparent;
  box-shadow: none;
  font-family: var(--serif);
  font-weight: 700;
}

.lyrics-card.is-two-columns {
  column-count: 2;
  column-gap: 32px;
}

.lyrics-line {
  padding: 6px 0;
  border: 0;
  break-inside: avoid;
}


.lyrics-line--label {
  padding-top: 20px;
  color: var(--muted);
  font-family: var(--font);
  font-size: calc(var(--lyrics-font-size) * 0.82);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.lyrics-line--empty {
  display: block;
  height: 1.5em;
  padding: 0 !important;
  margin: 0 !important;
  min-height: 0 !important;
  border: 0 !important;
}


.lyrics-line__stacked {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  line-height: 1.4;
  margin-bottom: 0.8em;
}

.lyrics-line__segment {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  vertical-align: bottom;
}

.lyrics-line__segment-chord {
  display: block;
  min-height: 1.25em;
  color: var(--chord);
  font-size: var(--lyrics-font-size);
  font-weight: 800;
  line-height: 1.25;
  font-family: var(--serif);
  white-space: pre;
}

/* Remove brackets in stacked mode */
.lyrics-line__segment-chord:not(:empty)::before {
  content: none !important;
}

.lyrics-line__segment-chord:not(:empty)::after {
  content: none !important;
}

.lyrics-line__segment-chord--empty {
  visibility: hidden;
  display: block !important;
}

.lyrics-line__segment-text {
  display: block;
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--lyrics-font-size);
  font-weight: 700;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.lyrics-line__segment-space {
  display: inline;
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--lyrics-font-size);
  font-weight: 700;
  line-height: 1.4;
  white-space: pre-wrap;
}

.lyrics-line__inline,
.lyrics-line__lyrics-row,
.lyrics-line p {
  display: inline;
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--lyrics-font-size);
  font-weight: 700;
  line-height: 1.65;
  white-space: pre-wrap;
}

.lyrics-line__inline-chord,
.lyrics-line__chord {
  color: var(--chord);
  font-weight: 800;
  font-family: var(--serif);
  background: transparent;
  padding: 0;
  display: inline;
}

:root[data-theme="dark"] .lyrics-line__inline-chord,
:root[data-theme="dark"] .lyrics-line__chord {
  background: transparent;
}

.lyrics-line__chord {
  margin: 0 4px 0 0;
}

.lyrics-line__lyrics-row {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

html.is-lyrics-virtual-fullscreen,
body.is-lyrics-virtual-fullscreen {
  height: 100%;
  overflow: hidden;
}

/* Disable ancestor transforms in virtual fullscreen to allow position:fixed edge-to-edge layout */
html.is-lyrics-virtual-fullscreen main[data-page-outlet] > *,
html.is-lyrics-virtual-fullscreen .standard-page {
  transform: none !important;
  animation: none !important;
}

/* Hide app navigation bar in virtual fullscreen mode */
html.is-lyrics-virtual-fullscreen .app-nav {
  display: none !important;
}

#lyrics-section:fullscreen,
#lyrics-section:-webkit-full-screen,
#lyrics-section.is-virtual-fullscreen {
  width: 100% !important;
  max-width: none !important;
  height: 100dvh !important;
  margin: 0 !important;
  padding: max(12px, env(safe-area-inset-top)) 0 max(12px, env(safe-area-inset-bottom)) 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  background: var(--paper) !important;
  border: none !important;
  box-shadow: none !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Remove padding top when lyrics tabs are active to allow tabs to stick to the absolute top */
#lyrics-section.has-lyrics-tabs:fullscreen,
#lyrics-section.has-lyrics-tabs:-webkit-full-screen,
#lyrics-section.has-lyrics-tabs.is-virtual-fullscreen {
  padding-top: 0 !important;
}

#lyrics-section:fullscreen,
#lyrics-section:-webkit-full-screen {
  display: flex;
  flex-direction: column;
}

#lyrics-section.is-virtual-fullscreen {
  position: fixed;
  z-index: 99999 !important;
  inset: 0;
  display: flex;
  flex-direction: column;
}

#lyrics-section:fullscreen .lyrics-card,
#lyrics-section:-webkit-full-screen .lyrics-card,
#lyrics-section.is-virtual-fullscreen .lyrics-card {
  width: 100% !important;
  max-width: 860px !important;
  margin: 0 auto !important;
  padding-left: max(16px, env(safe-area-inset-left)) !important;
  padding-right: max(16px, env(safe-area-inset-right)) !important;
  padding-top: 0 !important;
  padding-bottom: calc(76px + env(safe-area-inset-bottom)) !important; /* Ultra-compact padding for fullscreen modes */
  overflow: visible !important;
  box-shadow: none !important;
  background: transparent !important;
}

#lyrics-section:fullscreen.is-auto-scrolling .lyrics-card,
#lyrics-section:-webkit-full-screen.is-auto-scrolling .lyrics-card,
#lyrics-section.is-virtual-fullscreen.is-auto-scrolling .lyrics-card {
  padding-top: 50dvh !important;
}


textarea {
  resize: vertical;
}



@media (max-width: 480px) {
  body {
    padding-bottom: 0;
  }

  .app-shell {
    width: 100%;
    padding-top: 0;
  }

  .app-shell > :not(.app-nav) {
    width: 100%;
  }

  .app-nav {
    position: sticky;
    top: 0;
    right: auto;
    bottom: auto;
    display: flex;
    flex-wrap: nowrap;
    justify-content: start;
    width: 100%;
    gap: 0;
    margin-bottom: 14px;
    padding: env(safe-area-inset-top) 12px 0;
    background: var(--paper);
    pointer-events: auto;
    border-top: 2px solid var(--bg);
  }

  .app-nav::before {
    display: block;
    left: 0;
    top: auto;
    bottom: 0;
    width: 100%;
    height: 5px;
    background:
      linear-gradient(180deg,
        rgba(67, 55, 45, 0.2) 0 1px,
        transparent 1px 2px,
        rgba(67, 55, 45, 0.11) 2px 3px,
        transparent 3px 4px,
        rgba(67, 55, 45, 0.07) 4px 5px);
    border-radius: 0;
  }

  .app-nav__item {
    position: relative;
    transform: translateZ(0);
    flex: 0 1 86px;
    max-width: 86px;
    min-width: 48px;
    min-height: 42px;
    max-height: none;
    margin: 0;
    border: none;
    box-shadow: none;
    background: transparent;
    filter: drop-shadow(0 8px 16px rgba(67, 55, 45, 0.14));
  }

  .app-nav__item + .app-nav__item {
    margin-top: 0;
    margin-left: -20px;
  }

  .app-nav__item::before {
    inset: 0;
    z-index: 1;
    background-color: rgba(67, 55, 45, 0.16);
    clip-path: polygon(0 100%, 11px 4px, 16px 0, calc(100% - 16px) 0, calc(100% - 11px) 4px, 100% 100%);
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  }

  .app-nav__item::after {
    content: "";
    position: absolute;
    top: 1px;
    right: 1px;
    bottom: 0;
    left: 1px;
    z-index: 2;
    background-color: var(--tab-bg);
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 58%);
    clip-path: polygon(0 100%, 11px 4px, 16px 0, calc(100% - 16px) 0, calc(100% - 11px) 4px, 100% 100%);
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  }

  .app-nav__item:hover::after,
  .app-nav__item:focus-visible::after {
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 58%);
  }

  .app-nav__item.is-active {
    transform: translateZ(0);
    box-shadow: none;
    filter: drop-shadow(0 12px 24px rgba(67, 55, 45, 0.22));
  }

  .app-nav__item.is-active::before {
    background-color: rgba(67, 55, 45, 0.35);
  }

  .app-nav__item.is-active::after {
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 58%);
  }

  .app-nav__icon {
    width: 30px;
    height: 30px;
  }

  .app-nav__icon svg {
    width: 24px;
    height: 24px;
  }

  .song-list-item {
    grid-template-columns: minmax(0, 1fr);
    padding: 14px 0 14px 36px;
  }

  .song-list-item-row {
    grid-template-columns: minmax(0, 1fr) 40px;
    gap: 6px;
  }

  .song-list-item h3::after {
    display: none;
  }

  .song-list-item h3,
  .song-list-item__footer,
  .song-list-item__meta,
  .song-list-item__excerpt {
    grid-column: 1;
    grid-row: auto;
  }

  .song-list-item h3,
  .song-list-item__footer {
    background: transparent;
  }

  .song-list-item__footer {
    justify-content: flex-start;
  }

  .song-list-item__favorite {
    margin-right: 4px;
  }


  .standard-page {
    padding: 18px 18px 28px;
  }

  .search-box__controls {
    gap: 4px;
  }

  .search-box__type {
    width: 112px;
    padding-left: 10px;
    padding-right: 26px;
    flex: 0 1 auto;
    min-width: 0;
  }


  .filter-bar {
    gap: 8px;
  }

  .filter-field select {
    padding-inline: 12px 36px;
    background-position:
      calc(100% - 20px) 50%,
      calc(100% - 14px) 50%,
      calc(100% - 34px) 50%;
  }

  body:has(#detail-layout) .app-shell {
    width: 100%;
    padding-top: 0;
  }

  body:has(#detail-layout) .detail-hero {
    padding: 28px 16px 16px;
  }

  .detail-favorite {
    top: 18px;
    right: 16px;
  }

  body:has(#detail-layout) .detail-hero h1 {
    font-size: clamp(1.7rem, 8.5vw, 2.40rem);
  }

  body:has(#detail-layout) .detail-layout {
    padding-inline: 16px;
  }

  .chord-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }

  .chord-diagram {
    max-width: 82px;
  }

  .lyrics-card.is-two-columns {
    column-count: 1;
  }

  #lyrics-section:fullscreen .lyrics-card,
  #lyrics-section:-webkit-full-screen .lyrics-card,
  #lyrics-section.is-virtual-fullscreen .lyrics-card {
    padding-bottom: calc(56px + env(safe-area-inset-bottom)) !important;
  }

  .lyrics-toolbar {
    left: 50%;
    bottom: 6px;
    width: min(calc(100% - 18px), var(--max-width));
    padding: 4px;
    gap: 6px;
    border-radius: 12px;
  }

  .lyrics-toolbar__scroll {
    gap: 6px;
  }

  .lyrics-toolbar__end,
  .lyrics-toolbar__group {
    gap: 4px;
  }

  .lyrics-toolbar__divider {
    height: 16px;
    min-height: 16px;
  }

  .lyrics-toolbar__cluster {
    padding: 0 !important;
    height: 36px !important;
    box-sizing: border-box;
    gap: 0 !important;
  }

  .transpose-status,
  .auto-scroll-status {
    min-height: 0 !important;
    height: 100% !important;
    font-size: 0.85rem;
  }

  .transpose-button,
  .font-size-button,
  .display-mode-button,
  .toolbar-icon-button {
    height: 100%;
    min-height: 0 !important;
    font-size: 0.85rem;
  }

  .auto-scroll-status {
    width: 36px !important;
    min-width: 36px !important;
    padding: 0 !important;
  }

  .auto-scroll-status__icon {
    font-size: 0.8rem !important;
    margin: 0 !important;
  }

  .auto-scroll-status__speed {
    bottom: 2px !important;
    font-size: 0.54rem !important;
  }

  .lyrics-toolbar__cluster .transpose-status {
    width: 42px !important;
    min-width: 42px !important;
  }

  /* Make all buttons inside a cluster exactly 36px wide on mobile to match the 36px height */
  .lyrics-toolbar__cluster button {
    width: 36px !important;
    min-width: 36px !important;
    font-family: "Inter", -apple-system, sans-serif !important;
    font-weight: 800 !important;
    font-size: 0.9rem !important;
  }



  /* Standalone buttons on mobile */
  .lyrics-toolbar > button,
  .lyrics-toolbar__group > button,
  .lyrics-toolbar__end > button {
    height: 36px !important;
    width: 36px !important;
    min-width: 36px !important;
    min-height: 0 !important;
  }
}

@keyframes pageFlipIn {
  0% {
    opacity: 0;
    transform: rotateY(-3deg) scale(0.98);
    transform-origin: left center;
  }
  100% {
    opacity: 1;
    transform: rotateY(0deg) scale(1);
    transform-origin: left center;
  }
}

main[data-page-outlet] > *,
.standard-page {
  animation: pageFlipIn 0.45s cubic-bezier(0.25, 1, 0.5, 1) both;
}

/* Fullscreen toolbar (after all media queries to ensure override) */
body:fullscreen .lyrics-toolbar,
body:-webkit-full-screen .lyrics-toolbar,
body.is-lyrics-virtual-fullscreen .lyrics-toolbar {
  bottom: max(8px, env(safe-area-inset-bottom)) !important;
}

/* Favorites Page Auth Banner & Status */
.favorites-auth-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.favorites-auth-banner.hidden {
  display: none !important;
}

.favorites-auth-banner__content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1;
}

.favorites-auth-banner__icon {
  color: var(--accent);
  margin-top: 2px;
  flex-shrink: 0;
}

.favorites-auth-banner__text h4 {
  margin: 0 0 4px 0;
  font-family: var(--font);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
}

.favorites-auth-banner__text p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.4;
}

.favorites-auth-banner__actions {
  flex-shrink: 0;
}

.favorites-auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--accent) !important;
  color: #ffffff !important;
  border: none !important;
  border-radius: 99px !important;
  font-family: var(--font);
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.favorites-auth-btn:hover {
  opacity: 0.9;
}

.favorites-auth-btn:active {
  transform: scale(0.98);
}

.favorites-auth-btn svg {
  flex-shrink: 0;
}



@media (max-width: 480px) {
  .favorites-auth-banner {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px;
  }
  
  .favorites-auth-banner__actions {
    display: flex;
    justify-content: stretch;
  }

  .favorites-auth-btn {
    width: 100%;
  }

}

/* Global User Badge on Top Right */
.user-badge {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper-soft);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 3px 12px 3px 3px;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(67, 55, 45, 0.08);
  font-family: var(--font);
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--ink);
  height: 32px;
  box-sizing: border-box;
  text-decoration: none !important;
  transition: background-color 0.2s, transform 0.1s;
}

.user-badge:hover {
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.user-badge:active {
  transform: translateY(0);
}

.user-badge__avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  overflow: hidden;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

.user-badge__name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Positioning inside page-header */
.page-header .user-badge {
  top: 3px;
  right: 48px;
}

/* Positioning inside detail-hero */
.detail-hero .user-badge {
  top: 21px;
  right: calc(clamp(18px, 5vw, 64px) + 48px);
}

@media (max-width: 480px) {
  /* On mobile, collapse to a circular avatar to save header space */
  .user-badge {
    padding: 0;
    width: 32px;
    height: 32px;
    justify-content: center;
    border-radius: 8px;
  }

  .user-badge__avatar {
    width: 26px;
    height: 26px;
  }
  
  .user-badge__name {
    display: none;
  }

  /* Adjust spacing on mobile */
  .page-header .user-badge {
    top: 3px;
    right: 44px;
  }

  .detail-hero .user-badge {
    top: 21px;
    right: calc(clamp(18px, 5vw, 64px) + 44px);
  }
}

/* Dialog and Embedded Song Detail View Styles */
.song-detail-dialog {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  max-height: 100dvh !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  overflow: hidden !important;
  z-index: 99999 !important;
  box-sizing: border-box !important;
}

.song-detail-dialog::backdrop {
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
}

.song-detail-dialog iframe {
  width: 100% !important;
  height: 100% !important;
  border: none !important;
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
}

body.is-detail-dialog-open {
  overflow: hidden;
}

/* Detail Back button style */
.detail-back {
  position: absolute;
  top: 18px;
  left: clamp(18px, 5vw, 64px);
  z-index: 2;
  background: var(--paper-soft);
  box-shadow: 0 8px 18px rgba(67, 55, 45, 0.1);
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 50%;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 0.2s, background-color 0.2s, border-color 0.2s;
}

.detail-back svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (hover: hover) {
  .detail-back:hover:not(:disabled) {
    background: var(--accent-soft);
    border-color: var(--accent);
    transform: scale(1.05);
  }
}

@media (max-width: 480px) {
  .detail-back {
    top: 18px;
    left: 16px;
  }

  .lyrics-toolbar__divider--columns,
  .lyrics-toolbar__group--columns {
    display: none !important;
  }
}

/* Embedded overrides to remove margins and borders */
body.is-embedded .app-shell {
  width: 100%;
  padding-top: 0;
  padding-right: 0 !important;
}

body.is-embedded .book-body {
  margin-right: 0 !important;
  border-right: none !important;
  box-shadow: none !important;
}

/* Compact toolbar for landscape mode / small height screens */
@media (max-height: 480px) {
  .lyrics-toolbar {
    bottom: max(0px, env(safe-area-inset-bottom)) !important;
    padding: 4px !important;
    gap: 6px !important;
    border-radius: 12px !important;
    max-width: 680px !important;
  }

  body:fullscreen .lyrics-toolbar,
  body:-webkit-full-screen .lyrics-toolbar,
  body.is-lyrics-virtual-fullscreen .lyrics-toolbar {
    bottom: max(0px, env(safe-area-inset-bottom)) !important;
    padding: 4px !important;
    gap: 6px !important;
  }

  .lyrics-toolbar__scroll {
    gap: 6px !important;
  }

  .lyrics-toolbar__end,
  .lyrics-toolbar__group {
    gap: 4px !important;
  }

  .lyrics-toolbar__divider {
    height: 16px !important;
    min-height: 16px !important;
  }

  .lyrics-toolbar__cluster {
    padding: 0 !important;
    height: 36px !important;
    gap: 0 !important;
  }

  .transpose-status,
  .auto-scroll-status {
    min-height: 0 !important;
    height: 100% !important;
    font-size: 0.85rem !important;
  }

  .transpose-button,
  .font-size-button,
  .display-mode-button,
  .toolbar-icon-button {
    height: 100% !important;
    min-height: 0 !important;
    font-size: 0.85rem !important;
  }

  .auto-scroll-status {
    width: 36px !important;
    min-width: 36px !important;
    padding: 0 !important;
  }

  .auto-scroll-status__icon {
    font-size: 0.8rem !important;
    margin: 0 !important;
  }

  .auto-scroll-status__speed {
    bottom: 2px !important;
    font-size: 0.54rem !important;
  }

  .lyrics-toolbar__cluster .transpose-status {
    width: 42px !important;
    min-width: 42px !important;
  }

  .lyrics-toolbar__cluster button {
    width: 36px !important;
    min-width: 36px !important;
    font-size: 0.9rem !important;
  }

  .lyrics-toolbar > button,
  .lyrics-toolbar__group > button,
  .lyrics-toolbar__end > button {
    height: 36px !important;
    width: 36px !important;
    min-width: 36px !important;
    min-height: 0 !important;
  }

  .lyrics-toolbar svg {
    width: 18px !important;
    height: 18px !important;
  }
  
  #lyrics-section:fullscreen .lyrics-card,
  #lyrics-section.is-virtual-fullscreen .lyrics-card {
    padding-bottom: 60px !important;
  }
}

/* Compact vertical navigation for mobile landscape */
@media (max-height: 480px) and (min-width: 481px) {
  .app-nav {
    position: fixed !important;
    right: 2px !important;
    width: 42px !important;
    height: 100% !important;
    padding-top: max(12px, env(safe-area-inset-top)) !important;
    padding-bottom: 0 !important;
    z-index: 9999 !important;
  }

  .app-nav::before {
    display: none !important;
  }
  
  .app-nav__item {
    width: 42px !important;
    height: 86px !important;
    min-height: 48px !important;
    max-height: 86px !important;
    flex: 0 1 86px !important;
  }
  
  .app-nav__item + .app-nav__item {
    margin-top: -20px !important;
  }

  .app-nav__user-badge {
    margin: auto auto 4px !important; /* Push to the bottom with 4px bottom spacing */
    align-self: center !important;
    left: 4px !important;
  }

  /* Reset layout constraints for body/shell when in landscape */
  .app-shell {
    padding-right: 44px !important;
    padding-top: 0 !important;
  }

  .app-shell > :not(.app-nav) {
    width: 100% !important;
  }

  .book-body {
    margin-right: 2px !important;
  }
}

/* Save Tone Banner for Favorites */
.detail-hero__top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: clamp(12px, 2.5vw, 24px);
  gap: 12px;
}

/* Force buttons inside top-bar to position static, override absolute styling */
.detail-hero__top-bar .detail-back,
.detail-hero__top-bar .detail-favorite {
  position: static !important;
  flex-shrink: 0;
  margin: 0 !important;
}

.detail-tone-alert {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  max-width: 420px;
  min-height: 38px;
  animation: alertFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
  margin-left: auto;
}

.detail-tone-alert.hidden {
  display: none !important;
}

.detail-tone-alert .save-tone-banner__text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  text-align: left;
}

.detail-tone-alert .save-tone-banner__actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.detail-tone-alert .save-tone-banner__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.detail-tone-alert .save-tone-banner__btn:hover,
.detail-tone-alert .save-tone-banner__btn:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}

.detail-tone-alert .save-tone-banner__btn--yes {
  background: var(--accent);
  color: var(--paper);
  border-color: var(--accent);
}

.detail-tone-alert .save-tone-banner__btn--yes:hover,
.detail-tone-alert .save-tone-banner__btn--yes:focus-visible {
  background: var(--accent);
  color: var(--paper);
  filter: brightness(1.08);
}

@keyframes alertFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Ensure detail-hero layout fits nicely with the top bar */
body:has(#detail-layout) .detail-hero {
  padding-top: clamp(16px, 3vw, 24px) !important;
}

@media (max-width: 480px) {
  body:has(#detail-layout) .detail-hero {
    padding-top: 16px !important;
  }
  
  .detail-tone-alert {
    padding: 4px 10px;
    font-size: 0.76rem;
    gap: 8px;
  }
  
  .detail-tone-alert .save-tone-banner__btn {
    min-width: 38px;
    height: 22px;
    font-size: 0.72rem;
  }
}

/* Monochromatic Icon System using CSS Masks */
.icon {
  display: inline-flex;
  width: 1.25rem;
  height: 1.25rem;
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  vertical-align: middle;
}

.icon--lg {
  width: 1.5rem;
  height: 1.5rem;
}

.icon--sm {
  width: 1rem;
  height: 1rem;
}

.icon-home {
  -webkit-mask-image: url("/assets/icons/home.svg");
  mask-image: url("/assets/icons/home.svg");
}

.icon-favorite {
  -webkit-mask-image: url("/assets/icons/favorite.svg");
  mask-image: url("/assets/icons/favorite.svg");
}

.icon-medley {
  -webkit-mask-image: url("/assets/icons/medley.svg");
  mask-image: url("/assets/icons/medley.svg");
}

.icon-history {
  -webkit-mask-image: url("/assets/icons/history.svg");
  mask-image: url("/assets/icons/history.svg");
}

.icon-user {
  -webkit-mask-image: url("/assets/icons/user.svg");
  mask-image: url("/assets/icons/user.svg");
}

.icon-back {
  -webkit-mask-image: url("/assets/icons/back.svg");
  mask-image: url("/assets/icons/back.svg");
}

.icon-search {
  -webkit-mask-image: url("/assets/icons/search.svg");
  mask-image: url("/assets/icons/search.svg");
}

.icon-chevron {
  -webkit-mask-image: url("/assets/icons/chevron.svg");
  mask-image: url("/assets/icons/chevron.svg");
}

.icon-chord-inline {
  -webkit-mask-image: url("/assets/icons/chord-inline.svg");
  mask-image: url("/assets/icons/chord-inline.svg");
}

.icon-chord-above {
  -webkit-mask-image: url("/assets/icons/chord-above.svg");
  mask-image: url("/assets/icons/chord-above.svg");
}

.icon-chord-hidden {
  -webkit-mask-image: url("/assets/icons/chord-hidden.svg");
  mask-image: url("/assets/icons/chord-hidden.svg");
}

.icon-columns {
  -webkit-mask-image: url("/assets/icons/columns.svg");
  mask-image: url("/assets/icons/columns.svg");
}

.icon-swap-pronouns {
  -webkit-mask-image: url("/assets/icons/swap-pronouns.svg?v=5");
  mask-image: url("/assets/icons/swap-pronouns.svg?v=5");
}

.icon-fullscreen {
  -webkit-mask-image: url("/assets/icons/fullscreen.svg");
  mask-image: url("/assets/icons/fullscreen.svg");
}

.icon-info {
  -webkit-mask-image: url("/assets/icons/info.svg");
  mask-image: url("/assets/icons/info.svg");
}

.icon-google {
  -webkit-mask-image: url("/assets/icons/google.svg");
  mask-image: url("/assets/icons/google.svg");
}

.icon-sun {
  -webkit-mask-image: url("/assets/icons/sun.svg");
  mask-image: url("/assets/icons/sun.svg");
}

.icon-moon {
  -webkit-mask-image: url("/assets/icons/moon.svg");
  mask-image: url("/assets/icons/moon.svg");
}

.icon-eye {
  -webkit-mask-image: url("/assets/icons/eye.svg");
  mask-image: url("/assets/icons/eye.svg");
}

@media (min-width: 481px) {
  body:has(#detail-layout) .app-shell {
    padding: 0;
  }
}

/* Navigation User Profile container wrapper */
.app-nav__user-container {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  pointer-events: auto;
  margin: auto auto max(24px, env(safe-area-inset-bottom)) auto;
  align-self: center;
  flex-shrink: 0;
}

@media (min-width: 481px) {
  .app-nav__user-container {
    left: 5px;
    margin-bottom: 4px;
  }
}

.app-nav__user-badge {
  margin: 0 !important;
  left: 0 !important;
  top: 0 !important;
  position: relative !important;
}

@media (max-width: 480px) {
  .app-nav__user-container {
    margin: auto 0 auto auto;
    align-self: center;
    position: relative;
    left: 8px;
    top: -3px;
  }
}

@media (min-width: 481px) and (max-height: 480px) and (orientation: landscape) {
  .app-nav__user-container {
    margin: auto auto 4px !important;
    align-self: center !important;
    left: 4px !important;
  }
}

/* User Profile Dropdown */
.user-dropdown {
  position: absolute;
  z-index: 1000;
  width: 280px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px;
  display: none;
  flex-direction: column;
  gap: 12px;
  box-sizing: border-box;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.15s ease, transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: auto;
}

.user-dropdown.is-active {
  display: flex;
  opacity: 1;
  transform: scale(1);
}

/* Dropdown Sub-components */
.user-dropdown__profile {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.user-dropdown__avatar {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--paper-soft);
  border: 1.5px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.user-dropdown__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-dropdown__avatar svg,
.user-dropdown__avatar .icon-user {
  width: 24px;
  height: 24px;
  background-color: var(--accent);
}

.user-dropdown__info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-dropdown__name {
  margin: 0;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-dropdown__email {
  margin: 2px 0 0 0;
  font-family: var(--font);
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-dropdown__divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}

.user-dropdown__theme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--ink);
  font-weight: 500;
}

.user-dropdown__theme-row span {
  user-select: none;
}

.user-dropdown__theme-row .theme-toggle {
  position: static;
  margin: 0;
}

.user-dropdown__auth-btn {
  width: 100%;
  padding: 10px 16px;
  border-radius: 8px;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  outline: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  box-sizing: border-box;
}

.user-dropdown__auth-btn--login {
  background: var(--accent);
  color: #fff7e8;
}

:root[data-theme="dark"] .user-dropdown__auth-btn--login {
  color: #1e1916;
}

.user-dropdown__auth-btn--login:hover {
  opacity: 0.9;
}

.user-dropdown__auth-btn--login .icon-google {
  background-color: currentColor;
}

.user-dropdown__auth-btn--logout {
  background: var(--paper-soft);
  border-color: var(--line);
  color: var(--muted);
}

.user-dropdown__auth-btn--logout:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-text);
}

/* Positioning rules relative to .app-nav__user-container */

/* Desktop (min-width: 481px) */
@media (min-width: 481px) {
  .user-dropdown {
    right: 42px;
    bottom: -6px;
    transform-origin: bottom right;
  }
}

/* Mobile portrait (max-width: 480px) */
@media (max-width: 480px) {
  .user-dropdown {
    right: -4px;
    top: 36px;
    transform-origin: top right;
  }
}

/* Mobile landscape */
@media (min-width: 481px) and (max-height: 480px) and (orientation: landscape) {
  .user-dropdown {
    right: 42px;
    bottom: -6px;
    top: auto;
    transform-origin: bottom right;
  }
}

/* Hide the redundant theme toggle button inside the page headers */
.page-header .theme-toggle {
  display: none !important;
}

/* Override fixed width on mobile/desktop for transpose status when rhythm is present */
#transpose-status.transpose-status--with-rhythm {
  width: auto !important;
  min-width: 54px !important;
  padding: 0 8px !important;
  flex-shrink: 0 !important;
}

/* Lyrics Version Tabs */
.lyrics-tabs {
  display: flex;
  flex-shrink: 0;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0;
  overflow-x: auto;
  scrollbar-width: none; /* Hide standard scrollbar */
  -ms-overflow-style: none;
}

.lyrics-tabs::-webkit-scrollbar {
  display: none; /* Hide scrollbar for Safari/Chrome */
}

.lyrics-tab {
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 10px 16px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  white-space: nowrap;
  flex-shrink: 0;
}

.lyrics-tab:hover {
  color: var(--ink);
}

.lyrics-tab--active {
  color: var(--accent-text);
  font-weight: 700;
}

.lyrics-tab--active::after {
  content: "";
  position: absolute;
  bottom: -1px; /* sits perfectly on the 1px border-bottom */
  left: 16px;
  right: 16px;
  height: 3px;
  background-color: var(--accent);
  border-radius: 3px 3px 0 0;
}

.lyrics-line--version-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 32px 0;
  position: relative;
  width: 100%;
}

.lyrics-version-separator {
  border: none;
  border-top: 2px dashed var(--line);
  width: 60%;
  margin: 0;
  opacity: 0.8;
}

/* Fullscreen Alignment for Version Tabs */
#lyrics-section:fullscreen .lyrics-tabs:not(.hidden),
#lyrics-section:-webkit-full-screen .lyrics-tabs:not(.hidden),
#lyrics-section.is-virtual-fullscreen .lyrics-tabs:not(.hidden) {
  display: flex !important;
  flex-shrink: 0 !important;
  width: 100% !important;
  max-width: 860px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: max(16px, env(safe-area-inset-left)) !important;
  padding-right: max(16px, env(safe-area-inset-right)) !important;
  box-sizing: border-box;

  /* Sticky Pinning to Top in Fullscreen */
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--paper) !important;
  padding-top: env(safe-area-inset-top) !important;
  margin-top: 0 !important;
  margin-bottom: 12px !important;
}

/* Favorites Page Grouping Select & Header */
.heading-select {
  appearance: none;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent-text);
  background: transparent;
  border: none;
  padding: 0 24px 0 0;
  margin: 0;
  cursor: pointer;
  outline: none;
  min-height: auto;
  height: auto;
  box-shadow: none;
  
  /* Custom small elegant arrow on the right */
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 10px) calc(50% + 1px),
    calc(100% - 6px) calc(50% + 1px);
  background-repeat: no-repeat;
  background-size: 4px 4px, 4px 4px;
}

.heading-select:focus-visible {
  outline: 2px solid var(--accent-soft);
  border-radius: 4px;
}

.song-group-header {
  position: sticky;
  top: 0;
  z-index: 5;
  grid-column: 1 / -1;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-text);
  background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--paper);
  padding: 8px 16px;
  border-radius: 6px;
  margin-top: 0;
  margin-bottom: 0.5rem;
  list-style: none;
  border-left: 4px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.song-list-item-row:has(+ .song-group-header) {
  margin-bottom: 1.5rem;
}

/* Favorites and Home page adjustments for flush sticky elements */
body[data-page="favorites"] .book-body,
body[data-page="favorites"] .standard-page,
body[data-page="home"] .book-body,
body[data-page="home"] .standard-page {
  padding-top: 0 !important;
}

body[data-page="favorites"] .page-header,
body[data-page="home"] .page-header {
  padding-top: clamp(22px, 3.4vw, 42px);
}

@media (max-width: 767px) {
  body[data-page="favorites"] .page-header,
  body[data-page="home"] .page-header {
    padding-top: 24px;
  }
}

/* Search Area Tabs */
.search-tabs {
  display: flex;
  gap: 16px;
  background: transparent;
  border: none;
  padding: 0;
  margin-bottom: 6px;
  width: fit-content;
  align-self: center;
}

.search-tab-button {
  background: transparent;
  border: none;
  padding: 2px 0 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  border-bottom: 2px solid transparent;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.search-tab-button:hover {
  color: var(--ink);
}

.search-tab-button.is-active {
  color: var(--accent) !important;
  border-bottom-color: var(--accent);
}

.search-tab-content {
  width: 100%;
  max-width: 600px;
  display: none;
}

.search-tab-content.is-active {
  display: block;
  animation: fadeInTab 0.25s ease-out;
}

@keyframes fadeInTab {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Always sticky search area on home page */
body[data-page="home"] .book-controls {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--paper);
  margin-top: 26px;
  padding-top: 16px;
  padding-bottom: 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

@media (max-width: 767px) {
  body[data-page="home"] .book-controls {
    margin-top: 20px;
    padding-top: 16px;
    gap: 12px;
  }
}




