/* ---------- окна пульта убираются на полку справа (panels.js) ---------- */
:root { --rail-w: 58px; --pn-ease: cubic-bezier(.32, .72, 0, 1); }

/* кнопка «убрать на полку» в углу окна: стрелка в черту справа — туда окно и уедет */
.stow {
  display: inline-grid; place-items: center; flex: none; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 8px;
  background: transparent; color: var(--faint); cursor: pointer;
  transition: background-color .15s ease, color .15s ease, transform .15s ease;
}
.stow svg { display: block; width: 15px; height: 15px; }
.stow:hover { background: var(--glass-2); color: var(--text); }
.stow:active { transform: scale(.92); }
.stow .un, .win.min .stow .to { display: none; }
.win.min .stow .un { display: block; }
.roll-wrap > .stow {
  position: absolute; top: 8px; right: 8px; z-index: 2; width: 34px; height: 34px; border-radius: 10px; color: var(--muted);
  background: rgba(0, 0, 0, .55); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.roll-wrap > .stow:hover { background: rgba(0, 0, 0, .75); color: var(--text); }
.roll-wrap > .roll-view { right: 48px; }
.phase { right: 128px; }
.line-wrap { position: relative; min-width: 0; margin-top: 8px; }
.line-wrap > .stow { position: absolute; top: 6px; right: 6px; }
.line-wrap > .lyric-line { margin-top: 0; padding-right: 40px; }
.line-wrap:has(> .lyric-line:empty) { display: none; }

/* вокальный тюнер — карточка одного размера, где бы она ни стояла: так её легко узнать */
:root { --tuner-w: 152px; --tuner-h: 150px; }
.now-wrap {
  position: relative; display: flex; flex-direction: column; flex: none; width: var(--tuner-w); height: var(--tuner-h);
  background: var(--surface); border-radius: 12px; overflow: hidden;
}
.now-head {
  display: flex; align-items: center; gap: 2px; flex: none; height: 30px; padding: 2px 3px 0 10px;
  font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.now-head > span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.now-head .nh-short { display: none; }
.now-wrap > .readout { flex: 1 1 auto; min-height: 0; gap: 3px; padding: 0 8px 8px; background: none; border-radius: 0; }
.now-wrap .ro-label { display: none; }
.now-wrap .ro-sub { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* место первое: справа от нот, внизу у клавиатуры; ноты занимают всё остальное */
.stage { grid-template-columns: minmax(0, 1fr) var(--tuner-w); align-items: end; }
.dock.min-roll .stage, .dock.min-now .stage { grid-template-columns: minmax(0, 1fr); }
.dock.min-now .now-wrap, .dock.min-line .line-wrap { display: none; }

/* ноты убраны: «Слушай / Пой» и отсчёт всплывают над пультом слева, не наезжая на тюнер */
.dock.min-roll .roll-wrap { display: contents; }
.dock.min-roll .roll-wrap > :not(.phase):not(.gap-count) { display: none; }
.dock.min-roll .phase, .dock.min-roll .gap-count { top: auto; bottom: calc(100% + 12px); z-index: 3; box-shadow: var(--shadow); }
.dock.min-roll .phase { right: auto; left: 16px; }

/* место второе: ноты на полке — тюнер встаёт справа от строки слов и плеера, по высоте как они вместе */
.dock.min-roll:not(.min-now):not(.min-line) .dock-inner { display: grid; grid-template-columns: minmax(0, 1fr) var(--tuner-w); column-gap: 8px; }
.dock.min-roll:not(.min-now):not(.min-line) .dock-inner > * { grid-column: 1 / -1; }
.dock.min-roll:not(.min-now):not(.min-line) .stage { display: contents; }
.dock.min-roll:not(.min-now):not(.min-line) #selbar { grid-row: 1; }
.dock.min-roll:not(.min-now):not(.min-line) #takebar { grid-row: 2; }
.dock.min-roll:not(.min-now):not(.min-line) .now-wrap { grid-column: 2; grid-row: 3 / span 2; align-self: start; margin-top: 8px; }
.dock.min-roll:not(.min-now):not(.min-line) .dock-inner > .line-wrap { grid-column: 1; grid-row: 3; align-self: start; }
.dock.min-roll:not(.min-now):not(.min-line) .dock-inner > .transport { grid-column: 1; grid-row: 4; align-self: end; }
.dock.min-roll:not(.min-now):not(.min-line) .dock-inner > .wins { grid-row: 5; }

/* место третье: рядом с тюнером на пульте пусто — он стоит на пульте слева от полки */
.tuner-float { position: fixed; z-index: 31; right: calc(var(--rail-w) + 16px); bottom: calc(var(--dock-h, 80px) + 16px); }
.tuner-float:empty { display: none; }
.tuner-float > .now-wrap { border: 1px solid var(--border); box-shadow: 0 8px 40px rgba(0, 0, 0, .5); }

/* окна с кнопками держат ширину, какая у них, когда все три в ряду (её меряет panels.js), и не растягиваются,
   когда соседнее ушло на полку */
.win:not(.min) { flex: 0 0 auto; width: var(--win-w, auto); }
.wins.pn-measure .win { flex: 1 1 auto; width: auto; }
.pn-slide { box-shadow: none; }

/* убранное окно прячется, а открытое с полки выезжает слева от своего значка */
.wins { position: static; }
.wins.stowed { margin-top: 0; }
.win.min { display: none; }
.win.min.open { display: contents; }
.win.min.open .win-body {
  display: grid; position: absolute; z-index: 20; right: calc(var(--rail-w) + 8px); bottom: var(--fly-b, 100%); height: auto;
  width: max-content; min-width: 300px; max-width: calc(100vw - var(--rail-w) - 48px); padding: 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 16px 48px rgba(0, 0, 0, .65);
  transform-origin: right bottom; animation: pn-fly .24s var(--pn-ease);
}
.win.min.open .win-body .seg { background: var(--glass-2); }
@keyframes pn-fly { from { opacity: 0; transform: translateX(18px) scale(.96); } }

/* главная кнопка в строке плеера: всё на полку и обратно */
.dock.all-min .win-fold { color: var(--text); background: var(--glass); }

/* полка: столбик значков справа, стоит прямо на пульте и поднимается и опускается вместе с ним */
.rail {
  position: fixed; z-index: 31; right: 8px; bottom: calc(var(--dock-h, 300px) + 16px);
  display: flex; flex-direction: column; gap: 6px; padding: 6px;
  background: color-mix(in srgb, var(--dock) 92%, transparent); border: 1px solid var(--border); border-radius: 999px;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); box-shadow: 0 8px 40px rgba(0, 0, 0, .5);
  transition: opacity .32s var(--pn-ease), transform .38s var(--pn-ease), visibility 0s;
}
body:not(.rail-on) .rail {
  opacity: 0; transform: translateX(calc(100% + 16px)); visibility: hidden; pointer-events: none;
  transition: opacity .25s ease, transform .3s var(--pn-ease), visibility 0s .3s;
}
/* текст песни отодвигается и не прячется под полкой */
main { transition: margin-right .38s var(--pn-ease); }
body.rail-on main { margin-right: calc(var(--rail-w) + 16px); }

.rail-tab {
  --gc: var(--text);
  position: relative; display: grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  background: var(--glass); color: var(--gc); cursor: pointer;
  transition: background-color .15s ease, transform .2s var(--pn-ease), box-shadow .2s ease;
}
.rail-tab[hidden] { display: none; }
.rail-tab > svg { width: 19px; height: 19px; }
.rail-tab:hover { background: color-mix(in srgb, var(--gc) 18%, transparent); transform: scale(1.07); }
.rail-tab:active { transform: scale(.94); }
.rail-tab.open { background: color-mix(in srgb, var(--gc) 22%, transparent); box-shadow: inset 0 0 0 1.5px var(--gc); }
.rt-dot {
  position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--gc);
  box-shadow: 0 0 0 2px var(--dock), 0 0 10px var(--gc); opacity: 0; transform: scale(.4);
  transition: opacity .2s ease, transform .25s var(--pn-ease);
}
.rail-tab.on .rt-dot { opacity: 1; transform: none; }
/* «Сейчас» на полке — звучащая нота её цветом и со свечением */
.rt-note {
  display: grid; place-items: center; min-width: 36px; height: 36px; padding: 0 3px; border-radius: 18px;
  font: 700 12px/1 var(--mono); letter-spacing: -.02em; background: var(--nc); color: var(--nt);
  box-shadow: 0 0 18px color-mix(in srgb, var(--nc) 60%, transparent); transition: background-color .15s ease, box-shadow .15s ease;
}
.rt-note.none { background: transparent; color: var(--faint); box-shadow: none; }
/* подпись выезжает слева при наведении: что за окно и что в нём включено */
.rail .tip {
  position: absolute; right: calc(100% + 14px); top: 50%; translate: 8px -50%; opacity: 0; pointer-events: none;
  display: flex; align-items: baseline; gap: 8px; padding: 8px 12px; border-radius: 12px; white-space: nowrap;
  background: var(--surface-3); color: var(--text); font-size: 12px; box-shadow: var(--shadow);
  transition: opacity .15s ease, translate .2s var(--pn-ease);
}
.rail .tip b { font-size: 13px; font-weight: 600; }
.rail .tip span { color: var(--muted); }
.rail .tip span:empty { display: none; }
.rail-tab:hover .tip, .rail-tab:focus-visible .tip { opacity: 1; translate: 0 -50%; }
.rail-tab.open .tip { display: none; }

/* значок вырастает, пока к нему летит окно, и вспыхивает, когда оно «влетело» */
.rail-tab.arriving { animation: pn-tab-in .46s var(--pn-ease) both; }
.rail-tab.leaving { animation: pn-tab-out .3s var(--pn-ease) both; pointer-events: none; }
.rail-tab.landed { animation: pn-land .7s ease-out; }
@keyframes pn-tab-in { from { opacity: 0; transform: scale(.3); margin-bottom: -50px; } 55% { opacity: 1; } }
@keyframes pn-tab-out { to { opacity: 0; transform: scale(.3); margin-bottom: -50px; } }
@keyframes pn-land {
  from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--gc) 75%, transparent); background: color-mix(in srgb, var(--gc) 30%, transparent); }
  to { box-shadow: 0 0 0 16px transparent; }
}

/* снимок окна, который летит на полку или с неё */
.dock.pn-layer {
  position: fixed; inset: 0; z-index: 45; pointer-events: none; background: none; border: 0; border-radius: 0; box-shadow: none;
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
.pn-ghost { position: absolute; overflow: hidden; border-radius: 14px; transform-origin: 0 0; will-change: transform, opacity; box-shadow: 0 18px 50px rgba(0, 0, 0, .55); }
.pn-wait { visibility: hidden; }
/* пока пульт меняет высоту, он растёт и убывает сверху, а плеер стоит на месте */
.dock.anim { overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; }
.dock.anim > .dock-inner { flex: none; width: 100%; }

body.has-dock .toast { bottom: calc(var(--dock-h, 316px) + 24px); }
.rail-all { display: none; }

/* невысокий экран: ноты ниже, и тюнер с ними одной высоты — без подписи ноты и строки «вы поёте» */
@media (max-height: 820px) {
  :root { --tuner-h: 128px; }
  .now-wrap .ro-sub, .now-wrap .tn-you { display: none; }
}

/* телефон: полка — ряд значков над пультом, окна выезжают листом во всю ширину */
@media (max-width: 700px) {
  body.rail-on main { margin-right: 6px; }
  .rail { flex-direction: row; bottom: calc(var(--dock-h, 200px) + 8px); gap: 4px; padding: 4px; }
  body:not(.rail-on) .rail { transform: translateY(calc(100% + 16px)); }
  .rail-tab { width: 40px; height: 40px; }
  /* «убрать всё» отделена от значков чертой */
  .rail-all {
    display: grid; place-items: center; width: 40px; height: 40px; margin-left: 4px; padding: 0; border: 0; border-radius: 50%;
    background: transparent; color: var(--muted); cursor: pointer; box-shadow: -5px 0 0 -4px var(--border-2);
  }
  .rail-all svg { width: 18px; height: 18px; }
  .dock.all-min ~ .rail .rail-all, .rail-all:active { color: var(--text); background: var(--glass); }
  .rail .tip { display: none; }
  .win.min .stow { display: none; }
  .win.min.open .win-body {
    left: 8px; right: 8px; bottom: calc(100% + 66px); width: auto; min-width: 0; max-width: none; transform-origin: right bottom;
  }
  .phase { right: 122px; }
  .line-wrap { margin-top: 6px; }
  /* тюнер узкий: короткий заголовок, рядом со строкой слов, а плеер под ними во всю ширину */
  :root { --tuner-w: 70px; --tuner-h: 116px; }
  .now-head { height: 26px; padding: 2px 0 0 7px; font-size: 11px; }
  .now-head .nh-long, .now-wrap .tn-you { display: none; }
  .now-head .nh-short { display: inline; }
  .now-head .stow { width: 22px; height: 22px; }
  .now-wrap > .readout { padding: 0 4px 6px; }
  .dock.min-roll:not(.min-now):not(.min-line) .now-wrap { grid-row: 3; margin-top: 6px; }
  .dock.min-roll:not(.min-now):not(.min-line) .dock-inner { column-gap: 6px; }
  .dock.min-roll:not(.min-now):not(.min-line) .dock-inner > .transport { grid-column: 1 / -1; }
  .tuner-float { right: 8px; bottom: calc(var(--dock-h, 200px) + 66px); }
  @keyframes pn-tab-in { from { opacity: 0; transform: scale(.3); margin-right: -44px; } 55% { opacity: 1; } }
  @keyframes pn-tab-out { to { opacity: 0; transform: scale(.3); margin-right: -44px; } }
}

@media (prefers-reduced-motion: reduce) {
  .rail, body:not(.rail-on) .rail, main, .rail-tab, .rail .tip, .rt-dot { transition: none; }
  .rail-tab.arriving, .rail-tab.leaving, .rail-tab.landed, .win.min.open .win-body { animation: none; }
}
