.side-menu-bar {
  position: fixed;
  left: 0;
  top: 12px;
  width: 36px;
  height: auto;
  background: transparent;
  border: none;
  z-index: 1300;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 6px;
  pointer-events: none;
}

.side-menu-hamburger {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0);
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background-color 0.22s ease, color 0.22s ease, transform 0.22s ease;
  color: #000;
  padding: 0;
  pointer-events: auto;
  margin: 5px 0 10px 25px;
  border-radius: 50%;
  touch-action: manipulation;
}

.side-menu-hamburger.white {
  color: #fff;
}

.side-menu-hamburger:hover {
  background: rgba(255, 255, 255, 0.92);
  color: #111;
  transform: scale(1.06);
}

.side-menu-hamburger:active {
  transform: scale(0.96);
}

.side-menu-hamburger.open {
  background: transparent;
  color: #111;
}

.side-menu-hamburger span {
  width: 24px;
  height: 3px;
  background: currentColor;
  border-radius: 2px;
  transform-origin: center;
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.18s ease, width 0.22s ease;
}

.side-menu-hamburger:hover span:nth-child(1),
.side-menu-hamburger:hover span:nth-child(3) {
  width: 18px;
}

.side-menu-hamburger.open span:nth-child(1) {
  transform: translateY(10px) rotate(45deg);
}

.side-menu-hamburger.open span:nth-child(2) {
  opacity: 0;
}

.side-menu-hamburger.open span:nth-child(3) {
  transform: translateY(-10px) rotate(-45deg);
}

.side-menu-panel {
  position: fixed;
  left: 0;
  top: 0;
  width: 305px;
  height: 100vh;
  background: #fff;
  border-right: none;
  z-index: 1250;
  overflow: hidden;
  transform: translateX(-100%);
  transition: transform 0.3s ease, max-width 0.3s ease;
  box-shadow: none;
  will-change: transform;
}

.side-menu-panel.details-open {
  width: max-content;
  max-width: 980px;
}

.side-menu-panel.open {
  transform: translateX(0);
}

.side-menu-panel-header {
  padding: 0;
  border-bottom: none;
  font-weight: 700;
  text-transform: none;
  font-size: 1rem;
  color: #333;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  width: 100%;
  background: linear-gradient(180deg, #fff 0%, #fff 60%, rgba(255, 255, 255, 0) 100%);
  flex: 0 0 auto;
  pointer-events: auto;
  position: sticky;
  top: 0;
  z-index: 2;
  height: 120px;
  overflow: hidden;
}

.side-menu-close-btn {
  display: none;
}

.side-menu-panel-header .panel-cover {
  height: 120px;
  width: 120px;
  display: block;
  border-radius: 0;
  box-shadow: 0 20px 30px rgba(0, 0, 0, 0.2);
  pointer-events: auto;
  margin-left: 70px;
  margin-top: 0;
  background-size: cover;
  background-position: top center;
  flex-shrink: 0;
}

.side-menu-lang {
  position: absolute;
  left: 218px;
  top: 75px;
  transform: translateY(-50%);
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  z-index: 4;
}

.side-menu-lang a {
  color: #999;
  text-decoration: none;
  transition: color 0.2s ease;
}

.side-menu-lang a:hover,
.side-menu-lang a.active {
  color: #000;
}

.menu-chapter[data-color="pink"] .menu-chapter-title { color: #e84393; }
.menu-chapter[data-color="blue"] .menu-chapter-title { color: #3498db; }
.menu-chapter[data-color="green"] .menu-chapter-title { color: #27ae60; }
.menu-chapter[data-color="orange"] .menu-chapter-title { color: #e67e22; }
.menu-chapter[data-color="purple"] .menu-chapter-title { color: #9b59b6; }
.menu-chapter[data-color="red"] .menu-chapter-title { color: #e74c3c; }
.menu-chapter[data-color="teal"] .menu-chapter-title { color: #1abc9c; }
.menu-chapter[data-color="navy"] .menu-chapter-title { color: #2c3e50; }
.menu-chapter[data-color="cyan"] .menu-chapter-title { color: #00bcd4; }

.side-menu-panel-content {
  padding: 0;
  display: flex;
  width: 100%;
  height: 100%;
  margin-top: 0;
  overflow: hidden;
  transition: transform 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}

.side-menu-chapters {
  width: 305px;
  border-right: none;
  overflow-y: auto;
  padding: 0;
  background: #fff;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.side-menu-panel-header + .menu-chapter,
.side-menu-panel-header + .menu-chapters-separator {
  margin-top: 20px;
}

.menu-chapters-separator {
  height: 5px;
  min-height: 5px;
  flex-shrink: 0;
  width: 100%;
  background-color: #e84393;
}

.side-menu-details {
  display: flex;
  flex-direction: row;
  overflow: hidden;
  flex: 0 0 auto;
  max-width: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-22px);
  transition: max-width 0.34s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.22s ease, transform 0.34s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
}

.side-menu-details.open {
  max-width: 680px;
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.menu-column-section {
  flex: 0 0 340px;
  width: 340px;
  padding: 24px;
  border-right: none;
  overflow-y: auto;
  background: transparent;
  transition: background-color 0.22s ease;
  color: white !important;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.6;
}

.menu-column-section:empty {
  display: none;
}

.menu-column-section *,
.menu-column-section a {
  color: white !important;
  font-family: 'Montserrat', sans-serif;
}

.menu-column-section a:not(.menu-group-btn) {
  text-decoration: none;
  font-weight: 500;
  display: block;
  padding: 1px 0;
  transition: color 0.3s ease-in-out;
}

.menu-column-section a:not(.menu-group-btn) span {
  display: inline-block;
  position: relative;
  z-index: 0;
  overflow: hidden;
  padding: 0 0.25rem;
  margin: 0 -0.25rem;
}

.menu-column-section a:not(.menu-group-btn) span::before {
  content: '';
  position: absolute;
  inset: 0;
  background: white;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s ease-in-out;
  z-index: -1;
}

.menu-column-section a:not(.menu-group-btn):hover span::before {
  transform: scaleX(1);
}

.menu-column-section a:not(.menu-group-btn):hover,
.menu-column-section a:not(.menu-group-btn):hover span {
  color: var(--chapter-color, #333) !important;
}

.mobile-menu-back,
.mobile-menu-detail-title {
  display: none;
}

.menu-chapter-title {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  color: inherit;
  transition: background-color 0.16s ease, color 0.16s ease, transform 0.16s ease, padding-left 0.16s ease;
  user-select: none;
  border-radius: 0;
  width: 100%;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (hover: hover) {
  .menu-chapter-title:hover {
    background-color: var(--ch-color);
    color: white !important;
    transform: translateX(5px);
  }
}

.menu-chapter.expanded .menu-chapter-title {
  background-color: currentColor;
  color: white !important;
  transform: translateX(5px);
}

.menu-chapter-arrow {
  display: inline-block;
  transition: transform 0.3s ease;
  font-size: 0.8rem;
  color: #999;
}

.menu-chapter.expanded .menu-chapter-arrow {
  transform: rotate(180deg);
}


.menu-divider {
  height: 5px;
  min-height: 5px;
  flex-shrink: 0;
  width: 100%;
  background: rgba(0, 0, 0, 0.08);
  margin: 0;
}

.menu-social-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 18px 16px 22px;
  margin-top: 0px;
  border-top: 5px solid rgba(0, 0, 0, 0.08);
}

.menu-social-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #bbb;
  text-decoration: none;
  transition: color 0.2s ease, transform 0.2s ease;
  line-height: 1;
}

.menu-social-icon:hover {
  transform: scale(1.14);
}

.menu-social-ig:hover  { color: #e84393; }
.menu-social-yt:hover  { color: #e74c3c; }

.menu-social-glitch-t {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  width: 26px;
  height: 26px;
  overflow: visible;
  position: relative;
}

.menu-social-glitch-t:hover { color: #000; }

.menu-column {
  padding: 0;
  opacity: 0;
  transform: translateX(-14px);
  animation: menuColumnIn 0.34s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.menu-group {
  margin-top: 14px;
}

.menu-group:first-child {
  margin-top: 0;
}

.menu-group-heading {
  display: block;
  color: white !important;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.4;
  margin-bottom: 2px;
}

.menu-column-section a.menu-group-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: white;
  color: #e84393 !important;
  padding: 7px 18px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-decoration: none !important;
  margin-top: 4px;
  transition: background-color 0.15s ease, color 0.15s ease;
  opacity: 1 !important;
}

.menu-column-section a.menu-group-btn:hover {
  background-color: #27ae60 !important;
  color: white !important;
  opacity: 1 !important;
}

.menu-column-section a.menu-group-btn svg {
  stroke: #e84393 !important;
}

.menu-column-section a.menu-group-btn:hover svg {
  stroke: #fff !important;
}

.menu-column-section:nth-child(2) .menu-column {
  animation-delay: 0.06s;
}

.menu-column-title {
  color: white !important;
  font-family: 'Montserrat', sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 12px;
  display: block;
  padding-bottom: 6px;
}

.menu-column-title.menu-column-title-pdf,
.menu-column-title.menu-column-title-igraphic {
  display: flex;
  align-items: center;
  gap: 8px;
}

.menu-column-title.menu-column-title-pdf img,
.menu-column-title.menu-column-title-igraphic img {
  width: 28px;
  height: auto;
  display: block;
  flex: 0 0 auto;
}

.menu-chapter-title .menu-all-graphics-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex: 0 0 auto;
  margin: -4px 0;
}


.menu-column a {
  display: block;
  padding: 6px 0;
  font-size: 0.9rem;
  text-decoration: none;
  transition: color 0.2s ease;
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 2;
  opacity: 0;
  transform: translateY(6px);
  animation: menuItemIn 0.28s ease forwards;
}

.menu-column a:nth-child(2) { animation-delay: 0.04s; }
.menu-column a:nth-child(3) { animation-delay: 0.07s; }
.menu-column a:nth-child(4) { animation-delay: 0.10s; }
.menu-column a:nth-child(5) { animation-delay: 0.13s; }
.menu-column a:nth-child(6) { animation-delay: 0.16s; }
.menu-column a:nth-child(7) { animation-delay: 0.19s; }
.menu-column a:nth-child(8) { animation-delay: 0.22s; }
.menu-column a:nth-child(9) { animation-delay: 0.25s; }

.menu-column a:hover {
  
}

@keyframes menuColumnIn {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes menuItemIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.side-menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 198;
  display: none;
  transition: opacity 0.3s ease;
}

.side-menu-overlay.open {
  display: block;
}

@media (min-width: 901px) {
  body {
    margin-left: 0;
    padding-left: 0 !important;
  }
}

/* ── Top controls bar (BUY + IT/EN) ───────────────────────────────────────── */
body.open-menu .lang-toggle {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.lang-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1300;
  transition: opacity 0.2s ease;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  display: flex;
  gap: 8px;
  align-items: center;
}

.lang-toggle .lang-links {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: 12px;
}

.lang-toggle a:not(.buy-btn):not(.eartraining-top-btn) {
  color: #999;
  text-decoration: none;
  transition: color 0.2s;
}

.lang-toggle a:not(.buy-btn):not(.eartraining-top-btn):hover {
  color: #333;
}

.lang-toggle a.active {
  color: #000;
  font-weight: 600;
}

.lang-toggle.at-left {
  left: 65px;
  right: auto;
}

.lang-toggle .buy-btn {
  background: #e84393;
  color: white !important;
  text-decoration: none;
  padding: 6px 14px;
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: background 0.3s, transform 0.2s;
  order: -1;
}

.lang-toggle .buy-btn:hover {
  transform: scale(1.05);
}

@media (max-width: 768px) {
  .lang-toggle {
    top: 15px;
    font-size: 0.6rem;
  }
  .lang-toggle.at-left {
    left: 75px;
  }
  .lang-toggle .buy-btn {
    padding: 5px 10px;
  }
  .lang-toggle .lang-links {
    margin-left: 8px;
  }
}

@media (max-width: 900px) {
  .side-menu-bar {
    width: 50px;
    padding-top: 16px;
  }

  .side-menu-panel {
    left: 50px;
    width: 250px;
  }

  .side-menu-panel.details-open {
    width: max-content;
    max-width: 750px;
  }

  .side-menu-details.open {
    max-width: 450px;
  }

  .side-menu-chapters {
    width: 250px;
  }

  .menu-column-section {
    flex-basis: 250px;
    width: 250px;
  }
}

@media (max-width: 768px) {
  body.open-menu {
    overflow: hidden;
  }

  .side-menu-bar {
    left: 0;
    top: 10px;
    width: 58px;
    padding: 0;
  }

  .side-menu-hamburger {
    margin: 0 0 0 12px;
    background: rgba(255, 255, 255, 0.9);
    transition: none;
  }

  .side-menu-hamburger span {
    transition: transform 0.12s ease, opacity 0.08s ease, width 0.1s ease;
  }

  .side-menu-panel {
    transition: transform 0.15s ease;
  }

  .side-menu-hamburger.white {
    color: #000;
    background: rgba(255, 255, 255, 0.9);
  }

  .side-menu-panel,
  .side-menu-panel.details-open {
    left: 0;
    width: 100vw;
    max-width: none;
    height: 100dvh;
  }

  .side-menu-panel-header {
    height: 86px;
  }

  .side-menu-panel-header .panel-cover {
    height: 108px;
    width: 108px;
    margin-left: 64px;
  }

  .side-menu-lang {
    left: 188px;
    top: 54px;
    font-size: 0.66rem;
  }

  .side-menu-panel-content {
    width: 200vw;
    overflow: visible;
  }

  .side-menu-panel.details-open .side-menu-panel-content {
    transform: translateX(calc(-100vw + 52px));
  }

  .side-menu-chapters {
    flex: 0 0 100vw;
    width: 100vw;
    padding: 0 0 28px 0;
  }

  .menu-chapter-title {
    min-height: 46px;
    padding: 13px 20px 13px 24px;
    font-size: 0.9rem;
    font-weight: 700;
  }

  .side-menu-details {
    flex: 0 0 calc(100vw - 52px);
    width: calc(100vw - 52px);
    max-width: none;
    flex-direction: column;
    transform: none;
    overflow-y: auto;
    overflow-x: hidden;
    padding-top: 50px;
  }

  .side-menu-details.open {
    max-width: none;
    transform: none;
  }

  .menu-column-section {
    flex: 0 0 auto;
    width: calc(100vw - 52px);
    padding: 20px 22px 28px 24px;
    overflow: visible;
  }

  .mobile-menu-detail-title {
    display: block;
    padding: 0 68px 10px 24px;
    color: #fff;
    font-size: 1.5rem;
    font-weight: 900;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.02em;
  }

  .mobile-menu-back {
    position: absolute;
    right: 12px;
    top: 10px;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #fff;
    cursor: pointer;
    transform: rotate(180deg);
    transition: transform 0.22s ease, opacity 0.22s ease;
  }

  .mobile-menu-back::before,
  .mobile-menu-back::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 3px;
    background: currentColor;
    border-radius: 2px;
    transform-origin: right center;
  }

  .mobile-menu-back::before {
    transform: rotate(42deg);
  }

  .mobile-menu-back::after {
    transform: rotate(-42deg);
  }

  .mobile-menu-back:hover {
    transform: rotate(180deg) translateX(3px);
    opacity: 0.82;
  }

  .menu-column-section:not(:empty) + .menu-column-section:not(:empty) {
    padding-top: 20px;
  }

  .menu-column-title {
    font-size: 1rem;
  }

  .menu-column a {
    font-size: 0.92rem;
    line-height: 1.55;
    padding: 9px 0;
  }
}

/* ── Tommaso Rosati glitch button (bottom-right, all interactive pages) ───── */
.back-to-site {
  position: fixed;
  bottom: 0;
  right: 20px;
  z-index: 200;
  background: white;
  color: black !important;
  text-decoration: none !important;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  padding: 12px 20px;
  box-shadow: 0 -2px 15px rgba(0, 0, 0, 0.1);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  transition: box-shadow 0.2s;
}

.back-to-site:hover {
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
}

/* ── Ear Training link button (injected next to page titles) ─────────────── */

h1.red    { --h1-color: #e74c3c; }
h1.teal   { --h1-color: #1abc9c; }
h1.green  { --h1-color: #27ae60; }
h1.orange { --h1-color: #e67e22; }
h1.purple { --h1-color: #9b59b6; }

h1:has(.eartraining-link-btn) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.eartraining-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  background: var(--h1-color, #e84393);
  color: #ffffff;
  padding: 6px 14px;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  border: 2px solid var(--h1-color, #e84393);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  line-height: 1;
}

.eartraining-link-btn:hover {
  background: #27ae60;
  color: #fff;
  border-color: #27ae60;
}

.eartraining-link-btn svg {
  stroke: #fff !important;
  transition: stroke 0.15s ease;
}

.eartraining-link-btn:hover svg {
  stroke: #fff !important;
}

@media (max-width: 768px) {
  .eartraining-link-btn {
    display: none;
  }
}

.eartraining-top-btn {
  display: none;
}

@media (max-width: 768px) {
  .lang-toggle.at-left:has(.eartraining-top-btn) {
    right: 20px;
  }

  .eartraining-top-btn {
    display: inline-flex;
    align-items: center;
    align-self: stretch;
    gap: 5px;
    margin-left: auto;
    color: #ffffff !important;
    padding: 0 10px;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-decoration: none !important;
    line-height: 1;
    white-space: nowrap;
    transition: opacity 0.15s ease;
  }

  .eartraining-top-btn:hover {
    opacity: 0.82;
  }

  .eartraining-top-btn svg {
    stroke: #fff !important;
  }
}
