:root {
  color-scheme: light;
  --bg: #f4f6f7;
  --panel: #ffffff;
  --ink: #172026;
  --muted: #65727b;
  --line: #d8e0e5;
  --soft: #eef3f5;
  --accent: #0f766e;
  --accent-2: #2563eb;
  --warn: #c2410c;
  --good: #16803c;
  --shadow: 0 18px 42px rgba(24, 39, 51, 0.08);
  --nav-h: 0px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  border-color: #9fb0b8;
}

button.primary,
button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.recording {
  background: var(--warn);
  border-color: var(--warn);
  color: #fff;
}

button.error {
  border-color: #ef4444;
  color: #991b1b;
  background: #fee2e2;
}

.app {
  width: min(1580px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 18px 0 24px;
}

.topbar,
.upload-strip,
.warmup-panel,
.workspace,
.visual-grid,
.panel-head,
.player-head,
.transport,
.controls,
.mixers,
.lyrics-actions,
.player-actions {
  display: flex;
  gap: 12px;
}

.lyrics-actions {
  align-items: center;
}

.lyrics-actions span {
  max-width: 150px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.auth-widget {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.auth-user {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.auth-btn {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.auth-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.auth-btn:hover {
  border-color: #9fb0b8;
}

.home-link {
  flex: none;
  align-self: center;
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.home-link:hover {
  border-color: var(--accent);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 15px;
  letter-spacing: 0;
}

.topbar p,
.label,
.panel-head span,
.upload-strip span {
  color: var(--muted);
  font-size: 12px;
}

.upload-strip {
  align-items: end;
  flex-wrap: wrap;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.upload-strip > * {
  min-width: 0;
}

.warmup-panel {
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.warmup-panel > div {
  min-width: 220px;
}

.warmup-panel p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.warmup-panel label {
  display: grid;
  gap: 6px;
  min-width: 150px;
}

.warmup-panel select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 0 10px;
}

.warmup-desc {
  flex-basis: 100%;
  width: 100%;
  grid-column: 1 / -1;
  margin: -2px 0 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.warmup-desc b {
  color: var(--ink, #0f172a);
  font-weight: 700;
}

.warmup-meta {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  opacity: 0.8;
}

.warmup-desc:empty {
  display: none;
}

.setup-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.setup-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.setup-tabs button {
  min-height: 36px;
}

.setup-pane {
  display: none;
  gap: 12px;
  align-items: end;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.setup-pane.active {
  display: grid;
}

.setup-pane label,
.setup-pane .library-picker {
  min-width: 0;
}

.setup-pane input[type="file"],
.setup-pane select {
  width: 100%;
  max-width: 100%;
}

.setup-panel .action-stack {
  display: grid;
  gap: 8px;
  justify-self: end;
  width: min(280px, 100%);
}

.library-picker small {
  display: block;
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.practice-mode {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.practice-mode button {
  min-height: 34px;
  padding: 0 12px;
}

.practice-mode output {
  width: 190px;
  min-width: 190px;
  max-width: 190px;
  color: var(--ink);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.download-link {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  text-decoration: none;
}

.download-link[hidden] {
  display: none;
}

.player-panel {
  margin-bottom: 14px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.player-head {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 16px;
  flex-wrap: wrap;
}

.player-head span,
.time-pair span {
  color: var(--muted);
  font-size: 12px;
}

.time-pair {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.time-pair strong {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

/* Резервируем ширину под время, чтобы смена цифр не двигала раскладку. */
#playerTime {
  min-width: 84px;
  display: inline-block;
  text-align: right;
}

#playerDuration {
  min-width: 70px;
  display: inline-block;
}

.player-actions {
  align-items: center;
  justify-content: center;
  flex: 1;
  flex-wrap: wrap;
  gap: 8px;
}

.icon-btn {
  width: 46px;
  min-width: 46px;
  height: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-color: #cdd8de;
  background: linear-gradient(180deg, #ffffff, #eef5f7);
  box-shadow: 0 8px 18px rgba(24, 39, 51, 0.07);
}

.icon-btn svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

.icon-btn svg .cut {
  fill: none;
  stroke: #ffffff;
  stroke-width: 1.3;
}

.icon-btn.primary,
.icon-btn.active {
  background: linear-gradient(180deg, #11a095, #0f766e);
  border-color: #0f766e;
  color: #fff;
}

.icon-btn.key-action {
  border-color: #9fc8ff;
  background: linear-gradient(180deg, #ffffff, #e8f2ff);
}

.icon-btn.key-action.active {
  border-color: #2563eb;
  background: linear-gradient(180deg, #3b82f6, #1d4ed8);
  color: #fff;
}

.icon-btn.rec-action {
  color: #c2410c;
}

.icon-btn.rec-action.recording {
  background: linear-gradient(180deg, #ef4444, #b91c1c);
  border-color: #b91c1c;
  color: #fff;
}

#waveCanvas {
  height: 120px;
  cursor: pointer;
  background: #f8fafb;
}

.mixers {
  align-items: center;
  flex-wrap: wrap;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.transpose-panel {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #edf0f2;
  color: var(--muted);
  font-size: 12px;
}

.transpose-panel label:not(.transpose-link) {
  display: grid;
  grid-template-columns: 105px minmax(120px, 1fr) 32px;
  align-items: center;
  gap: 8px;
  min-width: 260px;
}

.transpose-panel input[type="range"] {
  width: 100%;
}

.transpose-panel output {
  color: var(--ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.transpose-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mic-filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #edf0f2;
  color: var(--muted);
  font-size: 12px;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.seg button {
  min-height: 34px;
  border: none;
  border-radius: 0;
  background: #fff;
  color: var(--muted);
  padding: 0 14px;
  box-shadow: none;
}

.seg button + button {
  border-left: 1px solid var(--line);
}

.seg button.active {
  background: var(--accent);
  color: #fff;
}

.seg button:hover {
  border-color: transparent;
}

.mixers label {
  display: grid;
  grid-template-columns: 58px minmax(130px, 1fr) 42px;
  align-items: center;
  gap: 8px;
  min-width: 250px;
  padding: 8px 10px;
  border: 1px solid #e5ebef;
  border-radius: 8px;
  background: #fbfcfd;
}

.mixers input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.mixers output {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

input[type="range"] {
  appearance: none;
  height: 18px;
  background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #0f766e, #2563eb);
  box-shadow: inset 0 0 0 1px rgba(23, 32, 38, 0.08);
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -5px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #172026;
  box-shadow: 0 3px 10px rgba(24, 39, 51, 0.25);
}

input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #0f766e, #2563eb);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #172026;
}

.upload-strip label {
  display: grid;
  gap: 6px;
  min-width: min(220px, 100%);
  max-width: 100%;
  flex: 1 1 220px;
}

.library-picker {
  min-width: 220px;
  max-width: 340px;
  flex: 1 1 280px;
}

.library-picker select {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 0 10px;
}

.library-picker small {
  min-height: 16px;
  color: var(--muted);
  font-size: 11px;
}

input[type="file"] {
  width: 100%;
  border: 1px dashed #a9b7be;
  border-radius: 7px;
  padding: 9px;
  background: #fbfcfd;
  color: var(--muted);
}

.action-stack {
  width: 230px;
  min-width: 230px;
  flex: 0 0 230px;
  display: grid;
  gap: 8px;
}

/* Разделение — первый шаг сценария «загрузил песню, спел под минус»,
   поэтому кнопка выделена, а её статус живёт отдельной строкой. */
#separateBtn {
  background: linear-gradient(135deg, var(--accent, #7c3aed), #2563eb);
  color: #fff;
  border: none;
}

#separateBtn:disabled {
  opacity: 0.6;
  cursor: progress;
}

.separate-status {
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
  min-height: 1em;
}

.progress,
.volume-bar {
  height: 8px;
  width: 100%;
  overflow: hidden;
  border-radius: 999px;
  background: var(--soft);
}

.progress div,
.volume-bar div {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 120ms linear;
}

.workspace {
  align-items: stretch;
  flex-direction: column;
}

.lyrics-panel,
.pitch-card,
.flow-card,
.piano-card,
.meters > div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.lyrics-panel {
  width: min(720px, 100%);
  flex: 0 0 auto;
  align-self: center;
  margin-bottom: 14px;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.lyrics-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  min-height: 52px;
  margin-bottom: 0;
}

.lyrics-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  padding: 0;
  min-height: 0;
  cursor: pointer;
  box-shadow: none;
  color: var(--ink);
  text-align: left;
  flex: 1;
}

.lyrics-toggle:hover {
  background: none;
  border-color: transparent;
}

.lyrics-toggle h2 {
  font-size: 15px;
}

.chevron {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 220ms ease;
  flex-shrink: 0;
}

.lyrics-panel.open .chevron {
  transform: rotate(180deg);
}

.lyrics-status-badge {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.lyrics-body {
  border-top: 1px solid var(--line);
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lyrics-body[hidden] {
  display: none;
}

.lyrics-body-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.panel-head {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  min-height: 48px;
}

.visual-grid .panel-head {
  align-items: flex-start;
}

.lyrics-body textarea {
  width: 100%;
  min-height: 86px;
  max-height: 126px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
}

.lyrics-view {
  overflow: auto;
  flex: 1;
  min-height: 230px;
  max-height: 330px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 36px 18px;
  background: linear-gradient(180deg, rgba(248, 250, 251, 0.92), rgba(255, 255, 255, 0.98)), #fff;
  scroll-behavior: smooth;
  text-align: center;
}

/* Караоке-подсветка по словам. Слова активной строки: спетые приглушены,
   текущее выделено цветом. Работает, когда у текста есть пословные таймкоды. */
.lyric-word {
  transition: color 120ms ease, opacity 120ms ease;
}

.lyric-line.active .lyric-word {
  opacity: 0.55;
}

.lyric-line.active .lyric-word.sung {
  opacity: 0.75;
  color: var(--ink, #0f172a);
}

.lyric-line.active .lyric-word.current {
  opacity: 1;
  color: var(--accent, #7c3aed);
  font-weight: 700;
}

.lyric-line {
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 18px;
  line-height: 1.42;
  opacity: 0.58;
  transform: scale(0.96);
  transition: color 180ms ease, opacity 180ms ease, transform 180ms ease, background 180ms ease;
}

.lyric-line.active {
  color: var(--ink);
  background: #e7f4f2;
  opacity: 1;
  transform: scale(1.04);
  font-weight: 800;
}

.trainer {
  min-width: 0;
  flex: 1;
  width: 100%;
}

.meters {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.meters > div {
  padding: 12px;
  min-width: 0;
}

.meters strong {
  display: block;
  margin-top: 5px;
  font-size: 19px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.visual-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.8fr);
  gap: 14px;
  align-items: stretch;
}

.pitch-card {
  grid-column: 1 / -1;
}

.flow-card,
.piano-card {
  grid-column: 1 / -1;
}

.pitch-card,
.flow-card,
.piano-card {
  padding: 12px;
  min-width: 0;
}

canvas {
  width: 100%;
  height: 500px;
  display: block;
  border: 1px solid #edf0f2;
  border-radius: 7px;
  background: #fbfcfd;
}

#flowCanvas {
  height: 230px;
}

.controls {
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  justify-content: flex-end;
  max-width: 70%;
}

.controls input[type="range"] {
  width: 110px;
  vertical-align: middle;
}

.piano {
  position: relative;
  height: 230px;
  border: 1px solid #cdd6db;
  border-radius: 7px;
  overflow: hidden;
  background:
    linear-gradient(to right, rgba(23, 32, 38, 0.05) 0 1px, transparent 1px) 0 0 / calc(100% / 61) 100%,
    #fff;
}

.key {
  position: absolute;
  top: 0;
  height: 100%;
  border-right: 1px solid #d7dee2;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 8px;
  color: #5e6a71;
  font-size: 0;
  overflow: hidden;
  isolation: isolate;
  --note-progress: 0;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.72);
  transition: background 120ms ease, color 120ms ease, outline-color 120ms ease;
}

.key-label {
  position: relative;
  z-index: 3;
  font-size: 10px;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transform: translateY(1px);
  white-space: nowrap;
}

.key.octave .key-label {
  opacity: 0.72;
}

.key.target .key-label,
.key.mic .key-label,
.key.sounding .key-label {
  opacity: 1;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.78);
  border-radius: 4px;
  padding: 2px 3px;
}

.key::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: calc(var(--note-progress, 0) * 100%);
  background: linear-gradient(0deg, rgba(20, 184, 166, 0.38), rgba(37, 99, 235, 0.36));
  opacity: 0;
  pointer-events: none;
  transition: height 90ms linear, opacity 120ms ease;
  z-index: 0;
}

.key.white {
  background: rgba(255, 255, 255, 0.72);
}

.key.black {
  top: 0;
  height: 62%;
  background: #172026;
  color: #fff;
  z-index: 2;
  border-radius: 0 0 4px 4px;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.75);
}

.key.black .key-label {
  background: rgba(15, 23, 42, 0.78);
}

.key.black::after {
  background: linear-gradient(0deg, rgba(250, 204, 21, 0.72), rgba(37, 99, 235, 0.48));
}

.key.target {
  background: #99f6e4;
  color: #073b36;
}

.key.mic {
  outline: 3px solid #f97316;
  outline-offset: -3px;
}

.key.sounding {
  box-shadow: inset 0 0 0 999px rgba(37, 99, 235, 0.28);
}

.key.holding::after {
  opacity: 1;
}

a {
  color: var(--accent);
}

/* ─── Mobile nav (hidden on desktop) ─── */
.mobile-nav {
  display: none;
}

.mobile-section {
  display: contents;
}

/* Общая кнопка анализа под вкладками настройки — на всю ширину панели. */
.setup-panel .action-stack.setup-action-shared {
  width: 100%;
  max-width: none;
  justify-self: stretch;
  margin-top: 4px;
}

.setup-action-shared #analyzeBtn {
  width: 100%;
  min-height: 44px;
  font-weight: 600;
}

.setup-action-shared[hidden] {
  display: none;
}

/* ─── Floating mini-transport (mobile only) ─── */
.mini-transport {
  display: none;
}

/* ─── Breakpoints ─── */

@media (max-width: 1180px) {
  .workspace {
    flex-direction: column;
  }

  .lyrics-panel {
    width: auto;
    flex-basis: auto;
    min-height: 360px;
  }

  .visual-grid {
    grid-template-columns: 1fr;
  }

  .piano {
    height: 210px;
  }

  #flowCanvas {
    height: 210px;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    margin-bottom: 10px;
  }

  .topbar p {
    display: none;
  }

  h1 {
    font-size: 20px;
  }

  /* ── Tab navigation ── */
  :root {
    --nav-h: 64px;
  }

  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--panel);
    border-top: 1px solid var(--line);
    box-shadow: 0 -4px 16px rgba(24, 39, 51, 0.10);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .mobile-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 56px;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--muted);
    font-size: 10px;
    font-weight: 500;
    padding: 6px 4px 4px;
    box-shadow: none;
  }

  .mobile-tab svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mobile-tab.active {
    color: var(--accent);
    background: transparent;
  }

  .mobile-tab.active svg {
    stroke: var(--accent);
  }

  /* ── Section show/hide ── */
  .mobile-section {
    display: none;
  }

  .mobile-section.active {
    display: block;
  }

  /* ── App container ── */
  .app {
    width: 100%;
    padding: 12px 12px calc(var(--nav-h) + 8px);
  }

  /* ── Upload strip ── */
  .upload-strip {
    flex-direction: column;
    gap: 10px;
  }

  .upload-strip label {
    flex: none;
    min-width: 0;
    width: 100%;
  }

  .action-stack {
    width: 100%;
    min-width: 0;
    flex: none;
  }

  .action-stack button {
    width: 100%;
    min-height: 46px;
    font-size: 15px;
  }

  .library-picker {
    min-width: 0;
    max-width: 100%;
    flex: none;
    width: 100%;
  }

  /* ── Warmup panel ── */
  .warmup-panel {
    flex-direction: column;
    gap: 10px;
  }

  .warmup-panel > div {
    min-width: 0;
  }

  .warmup-panel label {
    min-width: 0;
    width: 100%;
  }

  .warmup-panel select {
    width: 100%;
    min-height: 44px;
    font-size: 15px;
  }

  #loadWarmupBtn {
    width: 100%;
    min-height: 46px;
    font-size: 15px;
  }

  /* ── Player ── */
  .player-head {
    flex-wrap: wrap;
    gap: 8px 12px;
    align-items: center;
  }

  /* Блок режима/обратной связи — отдельной строкой, фиксированной высоты,
     чтобы меняющийся текст не сдвигал кнопки плеера. */
  .practice-mode {
    order: 3;
    width: 100%;
    flex-wrap: nowrap;
    min-height: 34px;
  }

  .practice-mode output {
    flex: 1;
    width: auto;
    min-width: 0;
    max-width: none;
  }

  .player-actions {
    gap: 6px;
    justify-content: center;
    margin: 12px 0;
  }

  .icon-btn {
    width: 48px;
    min-width: 48px;
    height: 48px;
  }

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

  .player-actions {
    gap: 4px;
  }

  .time-pair strong {
    font-size: 17px;
  }

  #waveCanvas {
    height: 80px;
  }

  /* ── Mixers — full-width stacked ── */
  .mixers {
    flex-direction: column;
    gap: 6px;
    align-items: stretch;
  }

  .mixers label {
    width: 100%;
    min-width: 0;
    grid-template-columns: 68px 1fr 42px;
    padding: 10px 12px;
    min-height: 48px;
  }

  .mixers input[type="range"]::-webkit-slider-thumb {
    width: 22px;
    height: 22px;
    margin-top: -7px;
  }

  /* ── Transpose ── */
  .transpose-panel {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .transpose-panel label:not(.transpose-link) {
    min-width: 0;
    grid-template-columns: 100px 1fr 32px;
    width: 100%;
  }

  /* ── Переключатель фильтра нот ── */
  .mic-filter-row {
    flex-direction: column;
    align-items: stretch;
  }

  .seg {
    width: 100%;
  }

  .seg button {
    flex: 1;
    min-height: 44px;
    font-size: 14px;
  }

  /* ── Meters ── */
  .meters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .meters > div {
    padding: 10px;
  }

  .meters strong {
    font-size: 16px;
  }

  /* ── Canvases ── */
  canvas {
    height: 280px;
  }

  #flowCanvas {
    height: 180px;
  }

  .piano {
    height: 160px;
  }

  /* ── Controls ── */
  .controls {
    max-width: 100%;
    gap: 8px;
  }

  .panel-head {
    flex-wrap: wrap;
    min-height: 0;
    gap: 8px;
  }

  /* ── Lyrics ── */
  .lyrics-panel {
    width: 100%;
    min-height: 0;
  }

  .lyrics-panel-head {
    padding: 10px 12px;
  }

  .lyrics-body {
    padding: 0 12px 12px;
  }

  .lyrics-body textarea {
    min-height: 100px;
    max-height: 160px;
    font-size: 14px;
  }

  .lyrics-view {
    min-height: 260px;
    max-height: none;
    padding: 24px 12px;
  }

  .lyric-line {
    font-size: 20px;
  }

  /* ── File inputs ── */
  input[type="file"] {
    padding: 12px;
    font-size: 14px;
  }

  /* ── Selects ── */
  select {
    min-height: 44px;
    font-size: 15px;
  }

  /* ── Floating mini-transport ── */
  .mini-transport {
    display: flex;
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(var(--nav-h) + 10px + env(safe-area-inset-bottom, 0px));
    z-index: 99;
    align-items: center;
    gap: 8px;
    padding: 6px 8px 6px 6px;
    background: rgba(23, 32, 38, 0.94);
    border-radius: 999px;
    box-shadow: 0 10px 30px rgba(24, 39, 51, 0.30);
    backdrop-filter: blur(8px);
    animation: mini-rise 220ms ease;
  }

  .mini-transport[hidden] {
    display: none;
  }

  @keyframes mini-rise {
    from { opacity: 0; transform: translate(-50%, 12px); }
    to { opacity: 1; transform: translate(-50%, 0); }
  }

  .mini-btn {
    width: 42px;
    min-width: 42px;
    height: 42px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    box-shadow: none;
  }

  .mini-btn:hover {
    border: none;
    background: rgba(255, 255, 255, 0.22);
  }

  .mini-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
  }

  .mini-btn.primary {
    background: linear-gradient(180deg, #11a095, #0f766e);
  }

  .mini-btn.ghost {
    width: 36px;
    min-width: 36px;
    height: 36px;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
  }

  .mini-btn.ghost svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  /* Иконка play/pause переключается классом is-playing на контейнере. */
  .mini-btn .ic-pause {
    display: none;
  }

  .mini-transport.is-playing .ic-play {
    display: none;
  }

  .mini-transport.is-playing .ic-pause {
    display: inline;
  }

  .mini-time {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    min-width: 58px;
    text-align: center;
  }
}
