:root {
  --bg-deep: #0a0807;
  --bg-warm: #14100c;
  --bg-mid: #1c1612;
  --bg-glass: rgba(20, 16, 12, 0.55);
  --bg-glass-strong: rgba(15, 12, 10, 0.78);
  --gold: #c9a875;
  --gold-bright: #e3c896;
  --gold-deep: #8a6f44;
  --gold-faint: rgba(201, 168, 117, 0.22);
  --teal: #6dc4c8;
  --teal-bright: #8fdde0;
  --teal-faint: rgba(109, 196, 200, 0.28);
  --copper-light: #e8b07a;
  --ivory-1: #f5ecd9;
  --ivory-2: #e8dbc1;
  --ivory-shadow: #b9a888;
  --key-black-1: #0e0a08;
  --key-black-2: #2a211c;
  --key-black-hi: #4a3d34;
  --led-red: #c2342d;
  --led-red-glow: #ff5a4a;
  --led-dark: #1d1816;
  --casing-1: #1a1410;
  --casing-2: #0c0907;
  --font-display: 'Cinzel', 'Cormorant Garamond', serif;
  --font-body: 'Cormorant Garamond', 'Cinzel', serif;
  --font-thin: 'Jost', system-ui, sans-serif;
  --font-arabic: 'Amiri', 'Noto Naskh Arabic', serif;
  --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.45);
  --shadow-deep: 0 24px 60px rgba(0, 0, 0, 0.6);
  --glow-gold: 0 0 22px rgba(201, 168, 117, 0.35);
  --glow-teal: 0 0 18px rgba(109, 196, 200, 0.30);
  --radius-lg: 22px;
  --radius-md: 12px;
}

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

html,
body {
  width: 100%;
  min-height: 100vh;
  background: var(--bg-deep);
  color: var(--ivory-1);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, #1c1410 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 50% 100%, #15100c 0%, transparent 70%),
    var(--bg-deep);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

select {
  font-family: inherit;
}

.app {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: row;
}

.navbar {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto auto auto auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 14px 26px;
  background: var(--bg-glass-strong);
  border: 1px solid var(--gold-faint);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow:
    var(--shadow-soft),
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    inset 0 0 0 1px rgba(201, 168, 117, 0.05);
  z-index: 10;
}

.navbar::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 14%;
  right: 14%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  grid-column: 1;
  justify-self: start;
}

.brand__logo {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 10px rgba(201, 168, 117, 0.35));
}

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: 0.18em;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(201, 168, 117, 0.25);
}

.brand__subtitle {
  font-family: var(--font-thin);
  font-weight: 300;
  font-size: 11px;
  letter-spacing: 0.32em;
  color: var(--gold);
  margin-top: 6px;
}

.selector {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 240px;
}

.selector__label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0 6px;
  font-family: var(--font-thin);
  font-size: 10.5px;
  letter-spacing: 0.28em;
  color: var(--teal);
  text-shadow: 0 0 10px rgba(109, 196, 200, 0.25);
}

.selector__label .arabic {
  font-family: var(--font-arabic);
  font-size: 13px;
  letter-spacing: 0;
  color: var(--teal-bright);
  opacity: 0.95;
}

.selector__field {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0 18px;
  height: 44px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(0, 0, 0, 0.25)),
    var(--bg-mid);
  border: 1px solid var(--gold-faint);
  border-radius: 10px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4),
    inset 0 0 20px rgba(0, 0, 0, 0.35);
  transition: border-color .25s ease, box-shadow .25s ease;
}

.selector__field:hover {
  border-color: rgba(201, 168, 117, 0.55);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4),
    inset 0 0 20px rgba(0, 0, 0, 0.35),
    0 0 16px rgba(201, 168, 117, 0.12);
}

.selector__select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  outline: none;
  width: 100%;
  height: 100%;
  padding-right: 32px;
  color: var(--ivory-1);
  font-family: var(--font-body);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-align: center;
  cursor: pointer;
}

.selector__select option {
  background: var(--bg-mid);
  color: var(--ivory-1);
  font-family: var(--font-body);
}

.selector__chevron {
  position: absolute;
  right: 14px;
  pointer-events: none;
  color: var(--teal);
  opacity: 0.85;
  filter: drop-shadow(0 0 6px rgba(109, 196, 200, 0.4));
}

.settings-btn {
  grid-column: 5;
  justify-self: end;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--gold-faint);
  background: rgba(0, 0, 0, 0.25);
  display: grid;
  place-items: center;
  color: var(--gold);
  transition: all .25s ease;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  display: none;
}

.settings-btn:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
  box-shadow: var(--glow-gold), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transform: rotate(45deg);
}

.settings-btn svg {
  width: 20px;
  height: 20px;
}

.hero {
  position: relative;
  margin-top: 18px;
  height: 340px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(ellipse 55% 70% at 88% 55%, rgba(180, 130, 70, 0.18) 0%, transparent 60%),
    radial-gradient(circle 80px at 12% 45%, rgba(255, 165, 80, 0.35) 0%, transparent 70%),
    radial-gradient(circle 60px at 22% 35%, rgba(255, 145, 70, 0.22) 0%, transparent 70%),
    radial-gradient(circle 50px at 32% 50%, rgba(255, 155, 75, 0.18) 0%, transparent 70%),
    radial-gradient(circle 40px at 60% 22%, rgba(255, 200, 130, 0.25) 0%, transparent 70%),
    radial-gradient(circle 40px at 65% 30%, rgba(255, 200, 130, 0.18) 0%, transparent 70%),
    radial-gradient(ellipse 60% 80% at 50% 60%, rgba(10, 8, 6, 0.55) 0%, transparent 70%),
    linear-gradient(180deg, #1a120c 0%, #0e0a08 100%);
  box-shadow:
    inset 0 0 0 1px var(--gold-faint),
    inset 0 0 80px rgba(0, 0, 0, 0.6),
    var(--shadow-soft);
}

.hero__lanterns {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hero__strings {
  position: absolute;
  top: 0;
  right: 0;
  width: 50%;
  height: 100%;
  pointer-events: none;
  opacity: 0.55;
}

.hero__wave {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100px;
  pointer-events: none;
  opacity: 0.5;
}

.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 90% 80% at 50% 50%, transparent 30%, rgba(0, 0, 0, 0.55) 100%),
    linear-gradient(180deg, transparent 60%, rgba(0, 0, 0, 0.4) 100%);
  pointer-events: none;
  z-index: 1;
}

.hero__content {
  position: relative;
  z-index: 3;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  padding: 0 24px;
}

.hero__ornament {
  display: none;
  width: 70px;
  height: 70px;
  margin-bottom: 10px;
  filter: drop-shadow(0 0 14px rgba(109, 196, 200, 0.45));
}

.hero__title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(38px, 7vw, 78px);
  letter-spacing: 0.14em;
  color: var(--gold);
  text-shadow:
    0 0 28px rgba(201, 168, 117, 0.35),
    0 2px 6px rgba(0, 0, 0, 0.6);
  line-height: 1;
}

.hero__subtitle {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 14px;
  font-family: var(--font-thin);
  font-weight: 300;
  font-size: clamp(13px, 1.3vw, 18px);
  letter-spacing: 0.5em;
  color: var(--teal);
  text-shadow: 0 0 14px rgba(109, 196, 200, 0.4);
  padding-left: 0.5em;
}

.hero__subtitle::before,
.hero__subtitle::after {
  content: '';
  width: 60px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--teal), transparent);
  opacity: 0.7;
}

.hero__subtitle::before {
  background: linear-gradient(90deg, transparent, var(--teal));
}

.hero__subtitle::after {
  background: linear-gradient(90deg, var(--teal), transparent);
}

.piano-wrap {
  margin-top: 18px;
  position: relative;
  border-radius: var(--radius-lg);
  padding: 0;
  background: linear-gradient(180deg, #0e0a08 0%, #050403 100%);
  border: 1px solid rgba(201, 168, 117, 0.18);
  box-shadow:
    var(--shadow-deep),
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    inset 0 -2px 8px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.piano-wrap::before {
  content: '';
  position: absolute;
  top: 0;
  left: 8%;
  right: 8%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(201, 168, 117, 0.4), transparent);
  z-index: 2;
}

#piano {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
}

/* ---------------------------------------------------------
       MAQAM SCALE COLOR SYSTEM
       ---------------------------------------------------------
       Every note in the active maqam scale is tinted a single red.
       Notes outside the maqam stay neutral. JS sets data-degree on
       each in-scale key; CSS applies one consistent red regardless
       of degree (degree is still tracked for labels/logic).
       --------------------------------------------------------- */
:root {
  --scale-red: rgb(0 161 115 / 62%);
}

.scale-tint {
  opacity: 0;
  transition: opacity 480ms cubic-bezier(0.22, 0.61, 0.36, 1),
    fill 480ms cubic-bezier(0.22, 0.61, 0.36, 1);
  pointer-events: none;
}

/* All in-scale keys share one red tint */
.piano-key[data-degree] .scale-tint {
  fill: var(--scale-red);
}

/* Subtle blend so the tint sits naturally over the keys. */
.piano-key--white[data-degree] .scale-tint {
  opacity: 0.82;
  mix-blend-mode: multiply;
}

.piano-key--black[data-degree] .scale-tint {
  opacity: 0.78;
  mix-blend-mode: screen;
}

/* ---------------------------------------------------------
       Note labels — bottom-center of each key.
       --------------------------------------------------------- */
.key-label {
  font-family: var(--font-thin);
  font-weight: 400;
  pointer-events: none;
  text-anchor: middle;
  dominant-baseline: middle;
  user-select: none;
}

.key-label--white {
  font-size: 22px;
  fill: #000000;
  letter-spacing: 0.02em;
}

.key-label--black {
  font-size: 15px;
  fill: #d9c39a;
  /* soft gold, reads on dark keys */
  letter-spacing: 0.02em;
}

.quarter-tone-marker {
  opacity: 0;
  transition: opacity 700ms cubic-bezier(0.22, 0.61, 0.36, 1);
  pointer-events: none;
}

.piano-key[data-quarter-tone="true"] .quarter-tone-marker {
  opacity: 1;
}

.qt-halo {
  fill: url(#qtHaloGrad);
  transform-box: fill-box;
  transform-origin: center;
}

.piano-key[data-quarter-tone="true"] .qt-halo {
  animation: qt-halo-breathe 2.8s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

@keyframes qt-halo-breathe {

  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.78);
  }

  50% {
    opacity: 0.85;
    transform: scale(1.12);
  }
}

.qt-core {
  fill: white;
}

.piano-key[data-quarter-tone="true"] .qt-core {
  animation: qt-core-pulse 2.8s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

@keyframes qt-core-pulse {

  0%,
  100% {
    opacity: 0.85;
  }

  50% {
    opacity: 1;
  }
}

@media (max-width: 1100px) {
  .navbar {
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto auto;
    row-gap: 14px;
  }

  .brand {
    grid-column: 1;
    grid-row: 1;
  }

  .settings-btn {
    grid-column: 3;
    grid-row: 1;
  }

  .selector--tonic {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .selector--maqam {
    grid-column: 1 / -1;
    grid-row: 3;
  }

  .selector {
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 720px) {
  .app {
    padding: 12px 12px 18px;
  }

  .navbar {
    padding: 12px 16px;
    gap: 14px;
  }

  .brand__title {
    font-size: 18px;
    letter-spacing: 0.14em;
  }

  .brand__subtitle {
    font-size: 9.5px;
    letter-spacing: 0.28em;
  }

  .brand__logo {
    width: 36px;
    height: 36px;
  }

  .settings-btn {
    width: 38px;
    height: 38px;
  }

  .hero {
    height: 240px;
  }

  .hero__ornament {
    width: 52px;
    height: 52px;
    margin-bottom: 4px;
  }

  .hero__subtitle {
    letter-spacing: 0.32em;
    gap: 10px;
  }

  .hero__subtitle::before,
  .hero__subtitle::after {
    width: 30px;
  }

  .selector__field {
    height: 40px;
  }

  .selector__select {
    font-size: 15px;
  }
}

@media (max-width: 480px) {
  .hero {
    height: 200px;
  }

  .hero__subtitle::before,
  .hero__subtitle::after {
    display: none;
  }
}

.main-content {
  flex: 1;
  padding: 18px 22px 28px;
}

.right-sidebar {
  position: relative;
  width: 260px;
  min-height: 100vh;
  background: rgba(7, 5, 3, 0.97);
  border-left: 1px solid rgba(200, 134, 74, 0.13);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 0;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 26px;
  padding: 0 12px;
}

.sidebar-logo-icon {
  position: relative;
  width: 70px;
  height: 70px;
}

.sidebar-logo-icon::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(200, 134, 74, 0.4);
  background: repeating-conic-gradient(rgba(200, 134, 74, 0.18) 0deg 6deg, transparent 6deg 12deg);
}

.sidebar-logo-icon::after {
  content: '';
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 45% 38%, rgba(10, 65, 50, 0.95), rgba(2, 14, 10, 0.99));
  border: 1px solid rgba(62, 207, 170, 0.25);
}

.mic-inner {
  position: absolute;
  inset: 9px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.mic-inner svg {
  width: 24px;
  height: 24px;
}

.sidebar-logo-text {
  font-family: 'Cinzel', serif;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 2.5px;
  color: var(--copper-light);
  text-align: center;
  line-height: 1.55;
  text-transform: uppercase;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 2px;
  padding: 0 12px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 12px;
  border-radius: 9px;
  color: white;
  text-decoration: none;
  transition: .2s;
}

.nav-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: rgb(241 241 241 / 45%);
  stroke-width: 1.8;
}

.nav-btn:hover {
  color: #e8b07a;
  background: rgba(200, 134, 74, 0.05);
}

.nav-btn.active {
  color: #e8f8f4;
  background: rgba(15, 75, 58, 0.62);
  border: 1px solid rgba(62, 207, 170, 0.28);
}

.bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  .right-sidebar {
    display: none;
  }

  .main-content {
    width: 100%;
    padding-bottom: 90px;
    padding: 0px !important;
  }

  .navbar {
    border-radius: 10px !important;
  }

  .hero {
    height: 150px;
    border-radius: 4px;
  }

  .selector__field {
    height: 28px;
    border-radius: 4px !important;
  }

  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 72px;
    background: radial-gradient(140% 160% at 50% 6%, rgba(8, 41, 102, 0.42), rgba(8, 24, 20, 0) 62%), linear-gradient(115deg, #08201b 0%, #0c2a23 50%, #081d18 100%);
    border-top: 1px solid rgba(200, 134, 74, 0.18);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    align-items: stretch;
    justify-content: space-around;
    z-index: 9999;
  }

  .bottom-nav .nav-btn {
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 4px 10px;
    border-radius: 0;
    border: none;
    background: none;
    font-size: 10px;
    letter-spacing: 0.8px;
    color: white;
    font-family: 'Cinzel';
    font-style: normal;
    font-weight: 400;
  }

  .bottom-nav .nav-btn svg {
    width: 22px;
    height: 22px;
  }

  .bottom-nav .nav-btn:hover {
    background: rgba(200, 134, 74, 0.04);
    color: #e8b07a;
  }

  .bottom-nav .nav-btn.active {
    color: #3ecfaa;
    position: relative;
  }

  .bottom-nav .nav-btn.active svg {
    stroke: #3ecfaa;
    filter: drop-shadow(0 0 5px rgba(62, 207, 170, 0.6));
  }

  .nav-mandala {
    position: relative;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: -6px;
  }

  .nav-mandala::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background:
      repeating-conic-gradient(rgba(200, 134, 74, 0.22) 0deg 6deg,
        transparent 6deg 12deg);
    border: 1px solid rgba(200, 134, 74, 0.45);
  }

  .nav-mandala::after {
    content: '';
    position: absolute;
    inset: 5px;
    border-radius: 50%;
    background:
      radial-gradient(circle at 45% 38%,
        rgba(10, 65, 50, 0.92),
        rgba(2, 14, 10, 0.98));
    border: 1px solid rgba(62, 207, 170, 0.22);
  }

  .nav-mandala svg {
    position: relative;
    z-index: 1;
    width: 20px !important;
    height: 20px !important;
  }

  .piano-wrap {
    border-radius: 4px;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .app {
    padding: 0px;
    max-height: 100vh;
  }

  .hero__content {
    display: none;
  }

  .hero {
    height: 120px;
    display: none;
  }

  .piano-wrap {
    margin-top: -10px;
    transform: scaleY(0.65);
    transform-origin: top center;
  }

  #piano {
    height: 320px;
  }

  .main-content {
    padding-bottom: 12px;
    padding: 0px !important;
  }

  .navbar {
    display: flex;
    align-items: center;
    gap: 14px;
    height: 62px;
    padding: 10px 18px;
    overflow: hidden;
    border-radius: 10px !important;
  }

  .brand {
    gap: 10px;
    min-width: 210px;
  }

  .brand__logo {
    width: 32px;
    height: 32px;
  }

  .brand__title {
    font-size: 16px;
    letter-spacing: 0.18em;
  }

  .brand__subtitle {
    font-size: 8px;
  }

  .selector {
    flex: 1;
    min-width: 0;
  }

  .selector.selector--tonic {
    flex: 0.6 !important;

  }

  .selector__label {
    font-size: 9px;
    margin-bottom: 2px;
  }

  .selector__field {
    height: 40px;
    padding: 0px 9px;
  }

  .selector__select {
    font-size: 15px;
  }

  .selector--tonic,
  .selector--maqam {
    grid-column: auto;
    grid-row: auto;
    flex-direction: row;
    align-items: center;
  }

  .navbar {
    display: flex;
    align-items: center;
    gap: 14px;
    height: 85px;
    padding: 7px 15px;
    overflow: hidden;
  }

  .brand {
    gap: 10px;
    min-width: 150px;
  }

  .brand__logo {
    width: 32px;
    height: 32px;
  }

  .brand__title {
    font-size: 16px;
    letter-spacing: 0.18em;
  }

  .selector__field {
    height: 55px;
  }

  .brand__subtitle {
    font-size: 8px;
  }

  .selector {
    flex: 1;
    min-width: 0;
  }

  .selector__label {
    font-size: 9px;
    margin-bottom: 2px;
  }

  .selector__field {
    height: 30px;
  }

  .selector__select {
    font-size: 15px;
  }

  .selector--tonic,
  .selector--maqam {
    grid-column: auto;
    grid-row: auto;
  }

  .main-content {
    padding-bottom: 45px;
    padding-top: 0px;
  }

  .bottom-nav {
    height: 55px;
  }
}

/* ════════════════════════════════════════════════════════
       TOP HEADER — copied from index.html
       ════════════════════════════════════════════════════════ */
:root {
  --hdr-h: 80px;
  --copper: #c8864a;
}

/* language switcher base (used by the header switch) */
.lang-switch {
  position: absolute;
  top: 26px;
  left: 28px;
  z-index: 60;
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 18px;
  border: 1px solid rgba(200, 134, 74, 0.4);
  background: rgba(8, 6, 3, 0.55);
  backdrop-filter: blur(8px);
}

.lang-btn {
  border: none;
  background: none;
  cursor: pointer;
  padding: 5px 11px;
  border-radius: 14px;
  font-family: 'Cinzel', serif;
  font-size: 11px;
  letter-spacing: 0.6px;
  color: rgba(200, 134, 74, 0.7);
  transition: background .2s, color .2s;
}

.lang-btn:hover {
  color: var(--copper-light);
}

.lang-btn.active {
  background: rgba(200, 134, 74, 0.22);
  color: var(--copper-light);
}

.top-header {
  display: none;
}

@media (min-width: 769px) {
  .top-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: var(--hdr-h);
    z-index: 100;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 38px;
    background:
      radial-gradient(140% 160% at 50% 6%, rgba(8, 41, 102, 0.42), rgba(8, 24, 20, 0) 62%),
      linear-gradient(115deg, #08201b 0%, #0c2a23 50%, #081d18 100%);
  }

  /* clear the absolute header so the controls sit below the notch */
  .main-content {
    padding-top: calc(var(--hdr-h) + 52px);
  }

  .hdr-nav {
    display: flex;
    align-items: center;
    gap: 34px;
  }

  .hdr-left {
    justify-content: flex-end;
    padding-right: 30px;
  }

  .hdr-right {
    justify-content: flex-start;
    padding-left: 30px;
    gap: 34px;
  }

  .hdr-link {
    font-family: 'Cinzel', serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-decoration: none;
    color: rgb(255 227 201 / 82%);
    transition: color .2s, text-shadow .2s;
  }

  .hdr-link:hover {
    color: var(--copper-light);
    text-shadow: 0 0 14px rgba(200, 134, 74, 0.45);
  }

  .hdr-link.active {
    color: #ffffff;
    text-shadow: 0 0 14px rgba(200, 134, 74, 0.5);
  }

  /* center brand tab */
  .hdr-brand {
    position: relative;
    display: block;
    width: 100px;
    height: var(--hdr-h);
    text-decoration: none;
  }

  .hdr-oud {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    height: 80px;
    filter: drop-shadow(0 0 12px rgba(200, 134, 74, 0.4));
  }

  .hdr-oud img {
    display: block;
    height: 100%;
    width: auto;
  }

  .hdr-brand-name {
    position: absolute;
    top: calc(var(--hdr-h) + 7px);
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Cinzel', serif !important;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 3px;
    color: rgb(255 227 201 / 82%);
    text-shadow: 0 0 16px rgba(200, 134, 74, 0.45);
    white-space: nowrap;
  }

  /* hairline rule with center notch */
  .hdr-rule {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(var(--hdr-h) - 3px);
    height: 46px;
    display: flex;
    align-items: flex-start;
    pointer-events: none;
  }

  .hdr-rule-line {
    flex: 1;
    margin-top: 2.4px;
    height: 1.2px;
    background: linear-gradient(to right, rgba(200, 134, 74, 0), rgba(200, 134, 74, 0.6));
  }

  .hdr-rule-line:last-child {
    background: linear-gradient(to left, rgba(200, 134, 74, 0), rgba(200, 134, 74, 0.6));
  }

  .hdr-rule-notch {
    width: 260px;
    height: 46px;
    flex: 0 0 auto;
  }

  .lang-switch.lang-switch-hdr {
    position: absolute;
    left: auto;
    right: 38px;
    top: 50%;
    transform: translateY(-50%);
  }

  /* hide mobile bottom-nav on desktop */
  .bottom-nav {
    display: none !important;
  }
}

/* ════════════════════════════════════════════════════════
       MUSICAL STAFF PANEL  (replaces the hero content)
       ════════════════════════════════════════════════════════ */

/* new page background image */
body {
  background:
    linear-gradient(180deg, rgba(5, 11, 11, 0.55) 0%, rgba(5, 10, 10, 0.78) 100%),
    url('/piano-bg-desktop.png') center center / cover no-repeat fixed,
    var(--bg-deep);
}

/* turn the hero into a transparent stage for the glass panel */
.hero {
  background: none;
  box-shadow: none;
  height: auto;
  overflow: visible;
  isolation: auto;
}

.hero__lanterns,
.hero__strings,
.hero__wave,
.hero::after {
  display: none !important;
}

.hero__content {
  height: auto;
  padding: 0;
}

.staff-panel {
  width: 100%;
  border-radius: 22px;
  border: 1px solid rgba(140, 200, 190, 0.16);
  background:
    radial-gradient(120% 140% at 50% 0%, rgba(20, 70, 60, 0.30), rgba(8, 22, 20, 0) 60%),
    linear-gradient(180deg, rgba(11, 34, 30, 0.55) 0%, rgba(7, 20, 18, 0.5) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.03),
    inset 0 0 60px rgba(10, 50, 42, 0.25),
    0 24px 60px rgba(0, 0, 0, 0.45);
  padding: 20px 30px 14px;
}

.staff-title {
  text-align: center;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(15px, 1.9vw, 24px);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-bright);
  text-shadow: 0 0 22px rgba(201, 168, 117, 0.3);
  margin-bottom: 4px;
}

.staff-stage {
  width: 100%;
  position: relative;
}

.staff-stage svg {
  display: block;
  width: 100%;
  height: auto;
}

/* Upper-jins selector — match tonic/maqam */
@media (max-width: 768px) {
  .selector--jins {
    grid-column: 1 / -1;
    grid-row: 4;
  }
}

/* ════════════════════════════════════════════════════════
       DESKTOP: fit header + controls + staff + piano in one view
       (no page scroll). The staff panel flexes into the leftover
       space and its SVG scales to fit, so it never pushes the
       piano off-screen.
       ════════════════════════════════════════════════════════ */
@media (min-width: 769px) {

  html,
  body {
    height: 100%;
  }

  .app {
    height: 100vh;
  }

  .main-content {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .navbar {
    flex: 0 0 auto;
  }

  .hero {
    flex: 1 1 auto;
    min-height: 0;
    margin-top: 14px;
    display: flex;
    flex-direction: column;
  }

  .hero__content {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .staff-panel {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 400px;
    /* don't balloon on tall monitors */
    margin: auto 0;
    /* center vertically when capped */
    display: flex;
    flex-direction: column;
  }

  .staff-stage {
    flex: 1 1 auto;
    min-height: 0;
  }

  /* SVG scales to fit the available height (viewBox keeps ratio) */
  .staff-stage svg {
    width: 100%;
    height: 100%;
  }

  .piano-wrap {
    flex: 0 0 auto;
  }
}

/* ════════════════════════════════════════════════════════
       MAQAM PAGE — left maqam library, compact controls, play
       ════════════════════════════════════════════════════════ */

/* left maqam library (desktop) */
.maqam-sidebar {
  flex: 0 0 230px;
  width: 230px;
  height: 100vh;
  background: radial-gradient(140% 160% at 50% 6%, rgba(8, 41, 102, 0.42), rgba(8, 24, 20, 0) 62%), linear-gradient(115deg, #08201b 0%, #0c2a23 50%, #081d18 100%);
  border-right: 1px solid rgba(200, 134, 74, 0.14);
  padding: calc(var(--hdr-h) + 22px) 14px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.maqam-sidebar__title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--gold);
  text-transform: uppercase;
  padding: 0 8px 12px;
  border-bottom: 1px solid rgba(200, 134, 74, 0.14);
}

.maqam-sidebar__title span {
  font-family: var(--font-arabic);
  font-size: 15px;
  letter-spacing: 0;
  color: var(--teal);
}

.maqam-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.maqam-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.015);
  color: var(--ivory-2);
  text-align: left;
  transition: background .18s, border-color .18s, color .18s;
}

.maqam-item__en {
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 0.06em;
}

.maqam-item__ar {
  font-family: var(--font-arabic);
  font-size: 16px;
  color: var(--gold);
  opacity: 0.82;
}

.maqam-item:hover {
  background: rgba(200, 134, 74, 0.06);
  border-color: rgba(200, 134, 74, 0.2);
}

.maqam-item.active {
  background: rgba(0, 161, 115, 0.16);
  border-color: rgba(62, 207, 170, 0.45);
  color: #eafff8;
}

.maqam-item.active .maqam-item__ar {
  color: var(--teal-bright);
  opacity: 1;
}

/* staff top bar: title + tonic + play */
.staff-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.staff-title {
  text-align: left;
  margin-bottom: 0;
}

.staff-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tonic-mini {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tonic-mini__label {
  font-family: var(--font-thin);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--teal);
  text-transform: uppercase;
}

.tonic-mini__field {
  position: relative;
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 28px 0 14px;
  border-radius: 9px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(0, 0, 0, 0.25)), var(--bg-mid);
  border: 1px solid var(--gold-faint);
  transition: border-color .2s;
}

.tonic-mini__field:hover {
  border-color: rgba(201, 168, 117, 0.55);
}

.tonic-mini__field select {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  outline: none;
  color: var(--ivory-1);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
}

.tonic-mini__field select option {
  background: var(--bg-mid);
  color: var(--ivory-1);
}

.tonic-mini__chevron {
  position: absolute;
  right: 10px;
  pointer-events: none;
  color: var(--teal);
}

.play-scale-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 38px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid rgba(62, 207, 170, 0.5);
  background: linear-gradient(180deg, rgba(20, 92, 70, 0.92), rgba(13, 66, 50, 0.92));
  color: #eafff8;
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 0 20px rgba(62, 207, 170, 0.25), inset 0 1px 0 rgba(180, 255, 235, 0.16);
  transition: border-color .18s, transform .12s, box-shadow .18s;
}

.play-scale-btn:hover {
  border-color: var(--teal);
  transform: translateY(-1px);
  box-shadow: 0 0 28px rgba(62, 207, 170, 0.4), inset 0 1px 0 rgba(180, 255, 235, 0.22);
}

.play-ico {
  width: 17px;
  height: 17px;
  fill: #d6fff2;
}

.play-ico-stop {
  display: none;
}

.play-scale-btn.is-playing .play-ico-play {
  display: none;
}

.play-scale-btn.is-playing .play-ico-stop {
  display: inline;
}

/* currently-playing note — RED on the piano */
.piano-key.is-playing .scale-tint {
  opacity: 1 !important;
  fill: rgb(233 69 60) !important;
}

.piano-key.is-playing {
  filter: drop-shadow(0 0 9px rgba(233, 69, 60, 0.9));
}

/* currently-playing note — GREEN on the staff */
.staff-note.is-playing ellipse {
  fill: rgb(38 214 152);
  stroke: rgb(170 255 224);
}

.staff-note.is-playing path,
.staff-note.is-playing line {
  fill: rgb(38 214 152);
  stroke: rgb(38 214 152);
}

.staff-note.is-playing {
  filter: drop-shadow(0 0 6px rgba(38, 214, 152, 0.95));
}

/* hover / click interactivity */
.staff-note {
  cursor: pointer;
}

.staff-note.hover:not(.is-playing) {
  filter: drop-shadow(0 0 5px rgba(143, 221, 224, 0.95));
}

.staff-note.struck ellipse {
  fill: rgb(38 214 152);
  stroke: rgb(170 255 224);
}

.staff-note.struck {
  filter: drop-shadow(0 0 6px rgba(38, 214, 152, 0.95));
}

.staff-tip {
  position: absolute;
  transform: translate(-50%, -100%);
  display: inline-flex;
  align-items: center;
  background: rgba(7, 20, 18, 0.96);
  border: 1px solid rgba(62, 207, 170, 0.55);
  color: #eafff8;
  font-family: 'Jost', 'Lato', sans-serif;
  font-size: 13px;
  letter-spacing: 0.4px;
  padding: 3px 9px;
  border-radius: 7px;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.12s ease;
  z-index: 6;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.staff-tip__txt {
  vertical-align: middle;
}

.staff-tip__acc {
  vertical-align: middle;
  margin-left: 4px;
}

.staff-tip::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(7, 20, 18, 0.96);
}

.staff-tip.show {
  opacity: 1;
}

/* 1-octave piano: keep it compact and centered */
.piano-wrap {
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

@media (min-width: 769px) {
  .piano-wrap {
    max-height: 300px;
  }

  .piano-wrap #piano {
    max-height: 300px;
  }
}

/* ── mobile: sidebar becomes a horizontal strip of pills ── */
@media (max-width: 768px) {
  .app {
    flex-direction: column;
  }

  .maqam-sidebar {
    flex: 0 0 auto;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: none;
    border-bottom: 1px solid rgba(200, 134, 74, 0.14);
  }

  .maqam-sidebar__title {
    display: none;
  }

  .maqam-list {
    flex-direction: row;
    gap: 8px;
  }

  .maqam-item {
    flex: 0 0 auto;
    width: auto;
    padding: 8px 16px;
    border-radius: 10px;
    border: 1px solid rgba(200, 134, 74, 0.2);
  }

  .maqam-item__ar {
    display: none;
  }

  .main-content {
    padding-bottom: 90px !important;
  }

  .piano-wrap {
    max-width: 100%;
  }

  .staff-top {
    gap: 10px;
  }
}

/* ════════════════════════════════════════════════════════
       SONGS SECTION — youtube clip player + sortable list
       ════════════════════════════════════════════════════════ */
.lower-zone {
  display: flex;
  flex-direction: row;
  gap: 18px;
  align-items: stretch;
  margin-top: 16px;
}

.songs-panel {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  gap: 14px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(140, 200, 190, 0.16);
  background:
    radial-gradient(120% 140% at 50% 0%, rgba(20, 70, 60, 0.22), rgba(8, 22, 20, 0) 60%),
    linear-gradient(180deg, rgba(11, 34, 30, 0.5) 0%, rgba(7, 20, 18, 0.45) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.songs-player {
  flex: 1 1 56%;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.songs-player__frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  /* height derived from width */
  border-radius: 12px;
  overflow: hidden;
  background: #050b0b;
  border: 1px solid rgba(140, 200, 190, 0.18);
}

.songs-player__frame #ytFrame,
.songs-player__frame iframe {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  border: 0;
}

.songs-player__empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: rgba(143, 221, 224, 0.6);
  font-family: var(--font-thin);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-align: center;
  padding: 0 18px;
  pointer-events: none;
}

.songs-player.has-video .songs-player__empty {
  display: none;
}

.songs-listcol {
  flex: 1 1 44%;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.songs-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.songs-tab {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(200, 134, 74, 0.18);
  background: rgba(255, 255, 255, 0.015);
  color: var(--ivory-2);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: .18s;
}

.songs-tab:hover {
  border-color: rgba(200, 134, 74, 0.4);
  color: var(--gold-bright);
}

.songs-tab.active {
  background: rgba(0, 161, 115, 0.18);
  border-color: rgba(62, 207, 170, 0.45);
  color: #eafff8;
}

.songs-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 4px;
}

/* slim scrollbar */
.songs-list::-webkit-scrollbar {
  width: 8px;
}

.songs-list::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
}

.songs-list::-webkit-scrollbar-thumb {
  background: rgba(62, 207, 170, 0.35);
  border-radius: 8px;
}

.songs-list::-webkit-scrollbar-thumb:hover {
  background: rgba(62, 207, 170, 0.55);
}

.songs-list {
  scrollbar-width: thin;
  scrollbar-color: rgba(62, 207, 170, 0.4) rgba(0, 0, 0, 0.2);
}

.song-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.02);
  color: var(--ivory-1);
  text-align: left;
  transition: background .15s, border-color .15s;
}

.song-row:hover {
  background: rgba(200, 134, 74, 0.07);
  border-color: rgba(200, 134, 74, 0.22);
}

.song-row.playing {
  background: rgba(0, 161, 115, 0.18);
  border-color: rgba(62, 207, 170, 0.5);
}

.song-row__meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.song-row__title {
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-row__sub {
  font-family: var(--font-thin);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--teal);
  opacity: 0.85;
}

.song-row__time {
  flex: 0 0 auto;
  font-family: var(--font-thin);
  font-size: 11px;
  color: var(--gold);
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
}

.songs-empty {
  padding: 22px 14px;
  text-align: center;
  color: rgba(232, 219, 193, 0.55);
  font-family: var(--font-thin);
  font-size: 12.5px;
  line-height: 1.5;
}

.songs-empty code {
  color: var(--gold-bright);
  font-size: 12px;
}

/* ── desktop: lock to one screen — staff = top half, songs+piano = bottom half ── */
@media (min-width: 769px) {

  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .app {
    height: 100vh;
    align-items: stretch;
  }

  .maqam-sidebar {
    position: static;
  }

  .main-content {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  /* TOP HALF — musical staff */
  .hero {
    flex: 1 1 0;
    min-height: 0;
    margin-top: 0;
    display: flex;
    flex-direction: column;
  }

  .hero__content {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .staff-panel {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    margin: 0;
    display: flex;
    flex-direction: column;
  }

  .staff-stage {
    flex: 1 1 auto;
    min-height: 0;
  }

  .staff-stage svg {
    width: 100%;
    height: 100%;
  }

  /* BOTTOM HALF — songs + piano */
  .lower-zone {
    flex: 1 1 0;
    min-height: 0;
    margin-top: 16px;
    align-items: stretch;
  }

  .songs-panel {
    min-height: 0;
  }

  .songs-player {
    flex: 1 1 56%;
    min-width: 0;
    max-width: 620px;
    min-height: 0;
    justify-content: center;
  }

  .songs-player__frame {
    max-height: 100%;
  }

  .songs-listcol {
    flex: 1 1 44%;
    min-width: 0;
    min-height: 0;
  }

  .songs-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
  }

  .piano-wrap {
    flex: 0 0 320px;
    max-width: 320px;
    max-height: none;
    margin: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .piano-wrap #piano {
    max-height: 100%;
    width: 100%;
    height: auto;
  }
}

/* ── mobile: stack player over list; piano above songs ── */
@media (max-width: 768px) {
  .lower-zone {
    flex-direction: column;
    gap: 14px;
  }

  .piano-wrap {
    order: -1;
  }

  .songs-panel {
    flex-direction: column;
  }

  .songs-player,
  .songs-listcol {
    flex: 1 1 auto;
  }

  .songs-list {
    max-height: 240px;
  }
}