/* Новый интерфейс AlphaHit (v2) — караоке и рингтоны.
 * Страницы: templates/v2/karaoke.html, karaoke_make.html, ringtones.html, ringtone_make.html;
 * поведение — static/js/v2/karaoke.js и ringtones.js. Цвета и шрифты — токены из app.css
 * (--accent, --raise, --ink…), оба дизайна (кассета и стриминг) и обе темы работают без отдельных правил,
 * кроме мест с пометкой [data-skin]. Подключает templates/v2/base.html.
 */

/* ── Общее: надзаголовок, переключатель, «чип»-кнопка ── */
.eyebrow { margin: 0 0 6px; font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.chip { display: inline-grid; place-items: center; min-width: 40px; min-height: 32px; padding: 0 10px; border-radius: 999px; background: var(--raise); color: var(--ink); font: 700 13px/1 var(--f); font-variant-numeric: tabular-nums; transition: background-color 150ms ease, transform 100ms ease; touch-action: manipulation; user-select: none; }
.chip:active { transform: scale(0.95); }
@media (hover: hover) and (pointer: fine) { .chip:hover { background: var(--hover); } }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__ui { position: relative; flex: none; width: 42px; height: 24px; border-radius: 999px; background: var(--line); transition: background-color 180ms ease; }
.switch__ui::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.3); transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.switch input:checked + .switch__ui { background: var(--accent); }
.switch input:checked + .switch__ui::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__ui { outline: 2px solid var(--accent); outline-offset: 2px; }

.kar__intro { max-width: 70ch; margin: 16px 0 4px; font-size: 14px; line-height: 1.5; }
.kar__intro b { color: var(--ink); }

/* ── Список караоке: карточки с обложкой ── */
.kar__grid { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 18px 16px; }
.kar__skel { height: auto; aspect-ratio: 1; margin: 0; border-radius: var(--r); }
.kcard { position: relative; }
.kcard__a { width: 100%; display: grid; gap: 4px; padding: 10px; border-radius: var(--r); text-align: left; transition: background-color 180ms ease; }
.kcard__a:disabled { cursor: default; }
@media (hover: hover) and (pointer: fine) {
  .kcard__a:not(:disabled):hover { background: var(--raise); }
  .kcard__a:not(:disabled):hover .kcard__mic { opacity: 1; transform: none; }
}
.kcard__art { position: relative; display: block; aspect-ratio: 1; overflow: hidden; border-radius: var(--r-cover); box-shadow: var(--shadow); margin-bottom: 6px; }
.kcard__art img, .kcard__art .card__ph { width: 100%; height: 100%; object-fit: cover; }
.kcard__art .card__ph { display: grid; }
.kcard b { font: 700 15px/1.25 var(--f-title); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.kcard small { color: var(--ink-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kcard__mic { position: absolute; right: 8px; bottom: 8px; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: var(--on-accent);
  box-shadow: 0 8px 18px rgb(0 0 0 / 0.35); opacity: 0; transform: translateY(8px); transition: opacity 200ms ease, transform 200ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.kcard__mic .ic { width: 24px; height: 24px; }
@media (hover: none) { .kcard__mic { opacity: 1; transform: none; width: 40px; height: 40px; } }
.kcard__state { position: absolute; inset: auto 8px 8px 8px; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: rgb(0 0 0 / 0.72); color: #fff; font-size: 13px; font-weight: 700; backdrop-filter: blur(6px); }
.kcard__state--bad { background: #b3261e; }
.kcard.is-busy .kcard__art img { filter: saturate(0.4) brightness(0.8); }
.kcard__more { position: absolute; top: 16px; right: 16px; background: rgb(0 0 0 / 0.55); color: #fff; opacity: 0; transition: opacity 150ms ease; }
@media (hover: hover) and (pointer: fine) { .kcard:hover .kcard__more, .kcard__more:focus-visible { opacity: 1; } .kcard__more:hover { background: rgb(0 0 0 / 0.8); } }
@media (hover: none) { .kcard__more { opacity: 1; } }

/* Бегущие столбики «делается» (караоке и ожидание) */
.kmake__bars { display: inline-flex; align-items: flex-end; gap: 3px; height: 16px; }
.kmake__bars i { width: 3px; height: 100%; border-radius: 2px; background: currentColor; transform-origin: bottom; animation: kbar 1s ease-in-out infinite; }
.kmake__bars i:nth-child(2) { animation-delay: -0.8s; } .kmake__bars i:nth-child(3) { animation-delay: -0.55s; } .kmake__bars i:nth-child(4) { animation-delay: -0.3s; }
.kmake__bars i:nth-child(5) { animation-delay: -0.65s; } .kmake__bars i:nth-child(6) { animation-delay: -0.15s; } .kmake__bars i:nth-child(7) { animation-delay: -0.45s; }
@keyframes kbar { 0%, 100% { transform: scaleY(0.25); } 50% { transform: scaleY(1); } }

/* ── Сцена караоке ── */
html.is-kstage, html.is-kstage body { overflow: hidden; }
.kstage { position: fixed; inset: 0; z-index: 60; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; color: #fff; background: #0b0b10;
  opacity: 0; transform: scale(0.985); transition: opacity 240ms ease, transform 240ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.kstage.is-open { opacity: 1; transform: none; }
.kstage__bg { position: absolute; inset: 0; overflow: hidden; z-index: -1; background: radial-gradient(120% 80% at 50% 0%, #2a1a4a 0%, #0b0b10 70%); }
.kstage__bg img { position: absolute; inset: -10%; width: 120%; height: 120%; object-fit: cover; filter: blur(60px) saturate(1.4) brightness(0.45); }
.kstage__bg::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgb(0 0 0 / 0.25) 0%, rgb(0 0 0 / 0.1) 40%, rgb(0 0 0 / 0.7) 100%); }
.kstage .icon-btn { color: #fff; background: rgb(255 255 255 / 0.1); width: 44px; height: 44px; }
@media (hover: hover) and (pointer: fine) { .kstage .icon-btn:hover { background: rgb(255 255 255 / 0.2); } }
.kstage__top { display: flex; align-items: center; gap: 14px; padding: calc(14px + env(safe-area-inset-top, 0px)) 20px 10px; }
.kstage__song { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 12px; }
.kstage__song img { border-radius: 6px; box-shadow: 0 6px 16px rgb(0 0 0 / 0.4); }
.kstage__song span { display: grid; min-width: 0; }
.kstage__song b { font: 800 17px/1.2 var(--f-title); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kstage__song small { color: rgb(255 255 255 / 0.65); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.kstage__lyrics { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; padding: 30vh max(20px, calc(50% - 400px)) 45vh;
  mask-image: linear-gradient(180deg, transparent 0, #000 18%, #000 72%, transparent 100%); -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 18%, #000 72%, transparent 100%); }
.kstage__lyrics::-webkit-scrollbar { display: none; }
.kl { margin: 0 0 18px; font: 800 clamp(24px, 3.6vw, 40px)/1.28 var(--f-title); letter-spacing: -0.01em; color: rgb(255 255 255 / 0.38); text-wrap: balance;
  transform-origin: left center; transition: color 300ms ease, opacity 300ms ease, transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.kl.is-past { color: rgb(255 255 255 / 0.22); }
.kl.is-now { color: rgb(255 255 255 / 0.72); transform: scale(1.03); }
.kl--sec { margin: 34px 0 12px; font: 800 13px/1 var(--f); letter-spacing: 0.12em; text-transform: uppercase; color: rgb(255 255 255 / 0.4); }
.kl--wait { font-size: clamp(18px, 2.4vw, 26px); color: rgb(255 255 255 / 0.6); }
.kw { cursor: pointer; border-radius: 4px; }
.kw.is-past { color: #fff; }
/* Звучащее слово заливается слева направо по мере пения (--p — доля, считает KaraokeStage.paint) */
.kw.is-now { color: transparent; background: linear-gradient(90deg, #ffd166 0 var(--p, 0%), #fff var(--p, 0%) 100%); -webkit-background-clip: text; background-clip: text;
  text-shadow: 0 0 22px rgb(255 209 102 / 0.35); }
.kl.is-now .kw.is-past { color: #ffd166; }
@media (hover: hover) and (pointer: fine) { .kw[data-s]:hover { background-color: rgb(255 255 255 / 0.08); } .kw.is-now:hover { background-color: transparent; } }
.kstage__notime { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 0 0 28px; padding: 14px 16px; border-radius: 14px; background: rgb(255 255 255 / 0.1); font-size: 15px; }

.kstage__deck { display: grid; gap: 10px; padding: 12px max(20px, calc(50% - 460px)) calc(20px + env(safe-area-inset-bottom, 0px)); }
.kstage__seek { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 10px; font-size: 12px; font-variant-numeric: tabular-nums; color: rgb(255 255 255 / 0.7); }
.kstage__seek span:last-child { text-align: right; }
.kstage input[type="range"] { width: 100%; height: 22px; margin: 0; background: transparent; accent-color: #ffd166; cursor: pointer; touch-action: pan-y; }
.kstage__ctl { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; }
.kstage__main { display: flex; align-items: center; gap: 18px; }
.kstage__play { width: 68px; height: 68px; display: grid; place-items: center; border-radius: 50%; background: #fff; color: #0b0b10; box-shadow: 0 10px 30px rgb(0 0 0 / 0.4);
  transition: transform 120ms ease; touch-action: manipulation; }
.kstage__play:active { transform: scale(0.94); }
.kstage__play .ic { width: 30px; height: 30px; }
.kstage__play .ic--pause, .kstage[data-state="play"] .kstage__play .ic--play { display: none; }
.kstage[data-state="play"] .kstage__play .ic--pause { display: block; }
.kstage__mixes { display: grid; gap: 4px; max-width: 260px; }
.kstage__mix span { min-width: 4.6em; }
.kstage__mix { display: flex; align-items: center; gap: 8px; max-width: 260px; font-size: 13px; font-weight: 700; color: rgb(255 255 255 / 0.8); }
.kstage__mix .ic { flex: none; width: 18px; height: 18px; }
.kstage__lead { justify-self: end; display: flex; align-items: center; gap: 8px; font-size: 12px; color: rgb(255 255 255 / 0.7); text-align: center; }
.kstage__lead span { min-width: 7.5em; }
.kstage .chip { background: rgb(255 255 255 / 0.12); color: #fff; }
@media (hover: hover) and (pointer: fine) { .kstage .chip:hover { background: rgb(255 255 255 / 0.22); } }
@media (max-width: 700px) {
  .kstage__top { padding-inline: 12px; }
  .kstage__song img { display: none; }
  .kl { margin-bottom: 14px; }
  .kstage__ctl { grid-template-columns: 1fr 1fr; grid-template-areas: "main main" "mix lead"; row-gap: 10px; }
  .kstage__main { grid-area: main; justify-content: center; }
  .kstage__mixes { grid-area: mix; }
  .kstage__lead { grid-area: lead; }
  .kstage__lead span { min-width: 0; max-width: 8em; }
}

/* ── Создание караоке: подтверждение и ожидание ── */
.kmake__card { display: grid; grid-template-columns: minmax(180px, 280px) minmax(0, 1fr); gap: 36px; align-items: start; max-width: 960px; padding: 28px; border-radius: calc(var(--r) + 6px); background: var(--raise); }
.kmake__art { position: relative; aspect-ratio: 1; border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); background: linear-gradient(135deg, #5b3fd0, #d8452f); }
.kmake__art img { width: 100%; height: 100%; object-fit: cover; }
.kmake__ph { position: absolute; inset: 0; display: grid; place-items: center; color: rgb(255 255 255 / 0.9); }
.kmake__ph .ic { width: 38%; height: 38%; }
.kmake__art > .kmake__bars { position: absolute; left: 50%; bottom: 18px; height: 34px; gap: 5px; color: #fff; transform: translateX(-50%); opacity: 0; transition: opacity 300ms ease; filter: drop-shadow(0 2px 6px rgb(0 0 0 / 0.5)); }
.kmake__art > .kmake__bars i { width: 5px; animation-play-state: paused; }
.kmake.is-busy .kmake__art > .kmake__bars { opacity: 1; }
.kmake.is-busy .kmake__art > .kmake__bars i { animation-play-state: running; }
.kmake.is-busy .kmake__art img { filter: brightness(0.7); }
.kmake__body { display: grid; gap: 10px; align-content: start; }
.kmake__body[hidden] { display: none; }
.kmake__body .h1 { font-size: clamp(26px, 3vw, 38px); }
.kmake__what { list-style: none; margin: 10px 0 4px; padding: 0; display: grid; gap: 12px; }
.kmake__what li { display: flex; align-items: center; gap: 14px; }
.kmake__what span:last-child { display: grid; gap: 2px; }
.kmake__what small { color: var(--ink-2); font-size: 14px; }
.kmake__dot { flex: none; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: var(--c); color: #fff; }
.kmake__dot .ic { width: 22px; height: 22px; }
.kmake__price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 16px; }
.kmake__price b { font-size: 22px; }
.kmake__acts { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.kmake__acts[hidden] { display: none; }
.kmake__note { margin: 0; font-size: 13px; }
.kmake__progress { height: 8px; margin: 8px 0 4px; border-radius: 999px; background: var(--line); overflow: hidden; }
.kmake__progress i { display: block; width: 100%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), #ffb03b);
  transform: scaleX(0.06); transform-origin: left; transition: transform 800ms cubic-bezier(0.2, 0.8, 0.2, 1); }   /* долю задаёт KaraokeMake через transform */
.kmake.is-done .kmake__progress i { background: #1e9e5a; }
.kmake.is-bad .kmake__progress { display: none; }
@media (max-width: 760px) {
  .kmake__card { grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 18px; }
  .kmake__art { width: min(220px, 70%); justify-self: center; }
}
@media (prefers-reduced-motion: reduce) { .kmake__bars i { animation: none; transform: scaleY(0.6); } .kstage, .kl { transition: none; } }

/* ── Рингтоны: строки списка берут .row/.tr из app.css ── */
[data-page="ringtones"] .tr__main small { font-variant-numeric: tabular-nums; }

/* ── Редактор рингтона ── */
.rmake { --wave-on: var(--accent); --wave-off: color-mix(in srgb, var(--ink) 22%, transparent); max-width: 980px; }
.rmake__head { display: flex; align-items: center; gap: 18px; margin-bottom: 22px; }
.rmake__head img { border-radius: var(--r-cover); box-shadow: var(--shadow); object-fit: cover; }
.rmake__head .h1 { font-size: clamp(24px, 3vw, 36px); }
.rmake__deck { padding: 22px 22px 18px; border-radius: calc(var(--r) + 6px); background: var(--raise); }
.rmake__nums { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; font-size: 13px; color: var(--ink-2); }
.rmake__nums b { display: block; margin-top: 2px; color: var(--ink); font: 800 20px/1 var(--f); font-variant-numeric: tabular-nums; }
.rmake__nums span:last-child { text-align: right; }
.rmake__len { text-align: center; }
.rmake__len b { color: var(--accent); font-size: 26px; }
.wave { position: relative; height: 128px; border-radius: 12px; background: var(--panel); touch-action: pan-y; user-select: none; cursor: pointer; }
.wave canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.wave__shade { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--panel) 45%, transparent); pointer-events: none; }
.wave__shade--l { left: 0; border-radius: 12px 0 0 12px; }
.wave__shade--r { right: 0; border-radius: 0 12px 12px 0; }
.wave__sel { position: absolute; top: 0; bottom: 0; border-top: 3px solid var(--accent); border-bottom: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); cursor: grab; }
.wave.is-drag .wave__sel { cursor: grabbing; }
.wave__grip { position: absolute; top: -6px; bottom: -6px; width: 22px; margin-left: -11px; border-radius: 8px; background: var(--accent); cursor: ew-resize; touch-action: none;
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.3); transition: transform 120ms ease; }
.wave__grip::after { content: ''; position: absolute; left: 50%; top: 50%; width: 3px; height: 26px; margin: -13px 0 0 -1.5px; border-radius: 2px; background: rgb(255 255 255 / 0.85); }
.wave__grip:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.wave__grip:active { transform: scaleX(1.15); }
.wave__head { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--ink); border-radius: 1px; pointer-events: none; box-shadow: 0 0 0 1px var(--panel); }
.wave:not(.is-ready) .wave__sel, .wave:not(.is-ready) .wave__grip, .wave:not(.is-ready) .wave__shade { visibility: hidden; }
.wave__load { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 10px; color: var(--ink-2); font-size: 14px; }
.wave__load .skel { width: 60%; height: 40px; margin: 0; }
.rmake__hint { margin: 12px 0 0; font-size: 13px; }
.rmake__ctl { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; margin-top: 16px; }
.rmake__nudge { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.rmake__nudge:last-child { justify-self: end; }
.rmake__play { width: 60px; height: 60px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: var(--on-accent); box-shadow: 0 10px 24px -8px var(--accent); transition: transform 120ms ease; touch-action: manipulation; }
.rmake__play:active { transform: scale(0.94); }
.rmake__play .ic { width: 26px; height: 26px; }
.rmake__play .ic--pause, .rmake[data-state="play"] .rmake__play .ic--play { display: none; }
.rmake[data-state="play"] .rmake__play .ic--pause { display: block; }
.rmake__form { display: grid; gap: 18px; margin-top: 18px; padding: 22px; border-radius: calc(var(--r) + 6px); background: var(--raise); }
.rmake__form .fld input { min-height: 46px; font-size: 16px; }
.rmake__toggles { display: flex; flex-wrap: wrap; gap: 14px 28px; }
.rmake__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); }
@media (max-width: 700px) {
  .rmake__deck, .rmake__form { padding: 16px; }
  .wave { height: 104px; }
  .rmake__ctl { grid-template-columns: 1fr 1fr; grid-template-areas: "play play" "a b"; }
  .rmake__play { grid-area: play; justify-self: center; }
  .rmake__nudge:first-child { grid-area: a; }
  .rmake__nudge:last-child { grid-area: b; }
  .rmake__foot .btn { width: 100%; }
}

/* Переключатель «Мои / Все пользователи» (только админ, раздел «Караоке») */
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--raise); }
.seg__b { min-height: 34px; padding: 0 14px; border-radius: 999px; font: 700 13px/1 var(--f); color: var(--ink-2); transition: background-color 150ms ease, color 150ms ease; }
.seg__b[aria-pressed="true"] { background: var(--ink); color: var(--panel); }
@media (hover: hover) and (pointer: fine) { .seg__b[aria-pressed="false"]:hover { color: var(--ink); } }
