/* Интерфейс SelfMusicPlay — как в мобильном приложении */
:root {
  --m-bg: #0b0b0f;
  --m-panel: #14141b;
  --m-panel-2: #1c1c25;
  --m-line: #26262f;
  --m-fg: #f2f2f5;
  --m-sub: #8a8a99;
  --m-accent: #ffd60a;
  --m-danger: #ff5f57;
}

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

html, body { height: 100%; margin: 0; }

.m-body {
  background: var(--m-bg);
  color: var(--m-fg);
  font: 15px/1.4 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior-y: none;
  /* clip, а не hidden: hidden превращает body во вложенный скролл
     и на телефонах ломает протягивание страницы */
  overflow-x: clip;
}

.m-app {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

/* ---------- шапка ---------- */
.m-top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: rgba(11, 11, 15, .92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--m-line);
}
.m-top-titles { flex: 1; min-width: 0; }
.m-top-title { margin: 0; font-size: 19px; font-weight: 700; }
.m-top-sub { margin: 2px 0 0; font-size: 12px; color: var(--m-sub); }
.m-icon-btn {
  background: none; border: 0; color: var(--m-fg);
  font-size: 20px; line-height: 1; padding: 8px 10px; border-radius: 12px; cursor: pointer;
  font-family: inherit; font-variant-emoji: text;
}
.m-icon-btn:active { background: var(--m-panel-2); }
.m-big { font-size: 26px; }

/* ---------- экраны ---------- */
.m-view { flex: 1; padding: 12px 14px 8px; }
.m-view[hidden] { display: none; }

/* ---------- поиск ---------- */
.m-searchbar { display: flex; gap: 8px; margin-bottom: 10px; }
.m-input {
  flex: 1; min-width: 0; background: var(--m-panel); color: var(--m-fg);
  border: 1px solid var(--m-line); border-radius: 14px; padding: 12px 14px; font-size: 15px;
}
.m-input:focus { outline: none; border-color: var(--m-accent); }
.m-btn-accent {
  background: var(--m-accent); color: #10100f; border: 0; border-radius: 14px;
  padding: 12px 16px; font-weight: 700; cursor: pointer;
}
.m-btn {
  background: var(--m-panel); color: var(--m-fg); border: 1px solid var(--m-line);
  border-radius: 12px; padding: 10px 14px; cursor: pointer; text-decoration: none;
  display: inline-block; font-size: 14px;
}
.m-row { margin: 6px 0 12px; }
.m-row-wrap { display: flex; flex-wrap: wrap; gap: 8px; }

.m-tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.m-tab {
  flex: 1; background: var(--m-panel); color: var(--m-sub);
  border: 1px solid var(--m-line); border-radius: 12px; padding: 9px 0;
  font-weight: 600; cursor: pointer;
}
.m-tab.is-active { color: var(--m-fg); border-color: var(--m-accent); background: var(--m-panel-2); }

.m-note {
  background: var(--m-panel); border: 1px solid var(--m-line); color: var(--m-sub);
  border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; font-size: 13px;
}

/* ---------- страны (языки) поиска Suno ---------- */
.m-langs { margin: -2px 0 10px; }
.m-langs-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  gap: 8px; background: var(--m-panel); border: 1px solid var(--m-line);
  color: var(--m-fg); border-radius: 12px; padding: 9px 12px;
  font-size: 13px; font-family: inherit; cursor: pointer;
}
.m-langs-toggle b { color: var(--m-accent); font-weight: 600; }
.m-langs-chev { color: var(--m-sub); transition: transform .15s; }
.m-langs-toggle.is-open .m-langs-chev { transform: rotate(180deg); }
.m-langs-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  gap: 2px 10px; border: 1px solid var(--m-line); border-top: 0;
  border-radius: 0 0 12px 12px; padding: 8px 12px 10px;
  background: var(--m-panel);
}
.m-lang {
  display: flex; align-items: center; gap: 7px; padding: 6px 2px;
  font-size: 13.5px; cursor: pointer; min-width: 0;
}
.m-lang input {
  width: 17px; height: 17px; flex: none; margin: 0; accent-color: var(--m-accent);
}
.m-lang span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* «Показать ещё» внизу списка: догрузка только по нажатию */
.m-more { display: block; width: 100%; margin-top: 10px; text-align: center; }

/* ---------- списки треков ---------- */
.m-list { display: flex; flex-direction: column; gap: 2px; }
.m-item {
  display: flex; align-items: center; gap: 12px; padding: 8px 4px;
  border-radius: 12px; cursor: pointer;
}
.m-item:active { background: var(--m-panel-2); }
.m-item.is-playing { background: var(--m-panel-2); }
.m-item-art {
  width: 52px; height: 52px; border-radius: 10px; object-fit: cover; flex: none;
  background: linear-gradient(135deg, #2a2a36, #1a1a22);
}
.m-item-text { flex: 1; min-width: 0; overflow: hidden; }
.m-item-title {
  font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.m-item.is-playing .m-item-title { color: var(--m-accent); }
.m-item-sub {
  font-size: 12px; color: var(--m-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.m-item-dur { font-size: 12px; color: var(--m-sub); flex: none; }
.m-item-more {
  flex: none; background: none; border: 0; color: var(--m-sub);
  font-size: 20px; padding: 6px 8px; cursor: pointer; border-radius: 10px;
}
.m-badge {
  display: inline-block; font-size: 10px; font-weight: 700; color: #10100f;
  background: var(--m-accent); border-radius: 5px; padding: 1px 5px; margin-right: 5px;
  vertical-align: 1px;
}
/* отметка «трек скачан для офлайна» */
.m-badge-dl {
  background: transparent; color: var(--m-accent);
  border: 1px solid var(--m-accent); margin-right: 4px;
}
/* пять вкладок поиска (Suno/VK/Zaycev/Яндекс/Эфир) в один ряд */
.m-tab { white-space: nowrap; padding-left: 4px; padding-right: 4px; }

/* ---------- жанры ---------- */
.m-chips { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.m-chip {
  background: var(--m-panel); border: 1px solid var(--m-line); color: var(--m-fg);
  border-radius: 999px; padding: 9px 14px; cursor: pointer; font-size: 14px;
  max-width: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.m-chip:active { border-color: var(--m-accent); }
.m-chip b { color: var(--m-sub); font-weight: 500; margin-left: 6px; font-size: 12px; }

/* ---------- плейлисты ---------- */
.m-pl-cover {
  width: 52px; height: 52px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, #34343f, #20202a);
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}

/* ---------- настройки ---------- */
.m-card { background: var(--m-panel); border: 1px solid var(--m-line); border-radius: 16px; overflow: hidden; }
.m-card-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-bottom: 1px solid var(--m-line); font-size: 14px;
}
.m-card-row:last-child { border-bottom: 0; }
.m-card-row b { color: var(--m-sub); font-weight: 600; }
.m-hint { color: var(--m-sub); font-size: 12px; margin-top: 12px; }

/* ---------- плеер во всю страницу ---------- */
.m-now {
  position: fixed; inset: 0; z-index: 60; background: #07070a;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: calc(14px + env(safe-area-inset-top)) 22px calc(22px + env(safe-area-inset-bottom));
  overflow-y: auto;
}
/* на широком экране колонка не растягивается */
.m-now > * { width: 100%; max-width: 460px; }
.m-now[hidden] { display: none; }
.m-now-top { display: flex; align-items: center; justify-content: space-between; }
.m-now-labels { text-align: center; }
.m-now-from { margin: 0; font-size: 11px; letter-spacing: .12em; color: var(--m-sub); text-transform: uppercase; }
.m-now-src { margin: 2px 0 0; font-size: 12px; color: var(--m-accent); }
.m-now-art {
  width: min(74vw, 74vh, 340px); height: min(74vw, 74vh, 340px);
  margin: 14px auto 6px; border-radius: 20px; object-fit: cover; background: #14141b;
}
.m-now-title { margin: 0; font-size: 20px; font-weight: 700; text-align: center; }
.m-now-author {
  margin: 4px 0 10px; color: var(--m-sub); font-size: 13px; text-align: center;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; line-height: 1.35;
}
.m-seek { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--m-sub); }
.m-seek input { flex: 1; min-width: 0; }
.m-now-controls { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 14px 0 6px; }
.m-play {
  width: 62px; height: 62px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--m-accent); color: #10100f; font-size: 24px; flex: none;
}
.m-volume { display: flex; align-items: center; gap: 10px; }
.m-volume input { flex: 1; min-width: 0; }

/* ---------- адаптив для узких экранов ---------- */
@media (max-width: 420px) {
  .m-view { padding: 10px 10px 8px; }
  .m-top-title { font-size: 17px; }
  .m-input { padding: 10px 12px; font-size: 14px; }
  .m-btn-accent { padding: 11px 12px; font-size: 13px; }
  .m-tab { font-size: 13px; padding: 8px 0; }
  .m-item-art { width: 44px; height: 44px; border-radius: 9px; }
  .m-item-title { font-size: 14px; }
  .m-item-sub { font-size: 11px; }
  .m-item-dur { font-size: 11px; }
  .m-mini-art { width: 36px; height: 36px; }
  .m-now > * { max-width: 100%; }
  .m-now-art { width: min(64vw, 60vh, 260px); height: min(64vw, 60vh, 260px); }
  .m-now-controls { gap: 4px; }
  .m-play { width: 54px; height: 54px; font-size: 21px; }
  .m-tile { flex: 0 0 108px; }
}

/* совсем узкие телефоны: ужимаем подписи и кнопки */
@media (max-width: 340px) {
  .m-item-more { padding: 4px 4px; }
  .m-item-dur { display: none; }
  .m-tile { flex: 0 0 96px; }
  .m-searchbar { gap: 6px; }
  .m-btn-accent { padding: 10px 9px; font-size: 12px; }
}

/* ---------- обложка-заглушка, когда картинки нет ---------- */
.m-art-ph {
  display: flex; align-items: center; justify-content: center;
  color: rgba(255, 255, 255, .82); font-weight: 700; overflow: hidden;
}
.m-now-art.m-art-ph span { font-size: 72px; }
.m-mini-art.m-art-ph span { font-size: 16px; }
.m-item-art.m-art-ph span { font-size: 18px; }
/* у VK обложек нет — показываем подпись «VK» */
.m-vk-label {
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: rgba(255, 255, 255, .8); letter-spacing: .02em;
}
.m-now-art.m-vk-label { font-size: 40px; }
.m-mini-art.m-vk-label { font-size: 11px; }
.m-item-art.m-vk-label { font-size: 13px; }
.m-tile-art.m-vk-label { font-size: 18px; }

/* ---------- обзор VK ---------- */
.m-browse { margin-bottom: 10px; }
.m-browse[hidden] { display: none; }
.m-sub { font-size: 12px; color: var(--m-sub); margin: 12px 0 8px; }
.m-rows { display: flex; flex-direction: column; gap: 14px; }
.m-row-head {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; cursor: pointer;
}
.m-row-title { font-size: 15px; font-weight: 700; }
.m-row-sub { font-size: 11px; color: var(--m-sub); }
.m-row-more { margin-left: auto; font-size: 11px; color: var(--m-accent); }
.m-row-items {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
}
.m-row-items::-webkit-scrollbar { height: 0; }
.m-tile {
  flex: 0 0 124px; scroll-snap-align: start; cursor: pointer;
  background: var(--m-panel); border: 1px solid var(--m-line); border-radius: 12px;
  padding: 8px; text-align: left;
}
.m-tile-art {
  width: 100%; aspect-ratio: 1; border-radius: 8px; object-fit: cover; margin-bottom: 6px;
}
.m-tile-title {
  font-size: 12px; font-weight: 600; line-height: 1.25; max-height: 2.5em;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.m-tile-sub { font-size: 10px; color: var(--m-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-browse-back { display: inline-block; color: var(--m-accent); font-size: 13px; padding: 6px 0; cursor: pointer; }
.m-browse-back[hidden] { display: none; }

input[type=range] { -webkit-appearance: none; appearance: none; height: 4px; border-radius: 4px; background: var(--m-line); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--m-accent);
}

/* ---------- мини-плеер ---------- */
.m-mini {
  position: fixed; left: 0; right: 0; bottom: calc(60px + env(safe-area-inset-bottom));
  z-index: 40; max-width: 720px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--m-panel-2); border-top: 1px solid var(--m-line);
}
.m-mini[hidden] { display: none; }
.m-mini-bar { position: absolute; top: 0; left: 0; right: 0; height: 2px; background: var(--m-line); }
.m-mini-bar i { display: block; height: 100%; width: 0; background: var(--m-accent); }
.m-mini-art { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex: none; background: #22222c; }
.m-mini-text { flex: 1; min-width: 0; display: flex; flex-direction: column; cursor: pointer; }
.m-mini-text b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-mini-text span { font-size: 11px; color: var(--m-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- нижняя навигация ---------- */
.m-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; max-width: 720px; margin: 0 auto;
  display: flex; background: rgba(12, 12, 16, .96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--m-line); padding-bottom: env(safe-area-inset-bottom);
}
.m-nav-item {
  flex: 1; background: none; border: 0; cursor: pointer; padding: 8px 0 10px;
  color: var(--m-sub); display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.m-nav-item i { font-style: normal; font-size: 18px; }
.m-nav-item span { font-size: 11px; }
.m-nav-item.is-active { color: var(--m-accent); }

/* ---------- шторки ---------- */
.m-sheet {
  position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, .6);
  display: flex; align-items: flex-end; justify-content: center;
}
.m-sheet[hidden] { display: none; }
.m-sheet-card {
  width: 100%; max-width: 720px; background: var(--m-panel);
  border-radius: 18px 18px 0 0; padding: 8px 0 calc(10px + env(safe-area-inset-bottom));
  max-height: 80vh; overflow-y: auto;
}
.m-sheet-title { padding: 12px 16px; font-weight: 700; font-size: 15px; }
.m-sheet-item {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  color: var(--m-fg); font-size: 15px; padding: 13px 16px; cursor: pointer;
}
.m-sheet-item:active { background: var(--m-panel-2); }
.m-danger { color: var(--m-danger); }

/* ---------- служебное ---------- */
.m-loader { text-align: center; color: var(--m-sub); font-size: 13px; padding: 16px 0; }
.m-loader[hidden] { display: none; }
.m-spin {
  display: inline-block; width: 12px; height: 12px; margin-right: 6px;
  border: 2px solid var(--m-line); border-top-color: var(--m-accent);
  border-radius: 50%; animation: m-spin .8s linear infinite; vertical-align: -2px;
}
@keyframes m-spin { to { transform: rotate(360deg); } }
.m-empty { text-align: center; color: var(--m-sub); font-size: 14px; padding: 30px 10px; }
.m-toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(130px + env(safe-area-inset-bottom)); z-index: 90;
  background: var(--m-panel-2); border: 1px solid var(--m-line); color: var(--m-fg);
  border-radius: 12px; padding: 10px 16px; font-size: 13px; max-width: 90vw;
}
.m-toast[hidden] { display: none; }

/* ---------- баннер связи ---------- */
.m-net {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(8px + env(safe-area-inset-top)); z-index: 95;
  background: var(--m-danger); color: #fff; border-radius: 12px;
  padding: 8px 16px; font-size: 13px; max-width: 92vw; text-align: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
}
.m-net[hidden] { display: none; }
.m-net.is-warn { background: #d98c00; }
