/* InstaHit Mini App — neon dark theme */

:root {
  --bg: #05030f;
  --text: #EDEBFF;
  --text-dim: rgba(237, 235, 255, .55);
  --card-bg: rgba(255, 255, 255, .045);
  --card-border: rgba(139, 92, 246, .30);
  --grad: linear-gradient(135deg, #22D3EE 0%, #8B5CF6 55%, #E04DFF 100%);
  --glow: 0 0 24px rgba(139, 92, 246, .45);
  --radius: 20px;
  --tabbar-h: 72px;
  --topbar-h: 52px;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  min-height: 100%;
  overscroll-behavior: none;
}

h1, h2, h3, .font-display { font-family: 'Unbounded', 'Inter', sans-serif; }

.hidden { display: none !important; }

/* ── background ── */
#bg-gradients {
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background:
    radial-gradient(620px 480px at 8% -4%, rgba(34, 211, 238, .12), transparent 65%),
    radial-gradient(680px 560px at 96% 104%, rgba(139, 92, 246, .14), transparent 65%);
}
#stars { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
#stars .star {
  position: absolute; border-radius: 50%; background: #fff;
  animation: twinkle 4s ease-in-out infinite;
}
@keyframes twinkle { 0%,100% { opacity: .15; } 50% { opacity: .7; } }

/* ── layout ── */
#screen-root {
  padding: calc(var(--topbar-h) + 14px) 16px calc(var(--tabbar-h) + 28px);
  max-width: 560px; margin: 0 auto;
  min-height: 100vh;
}

/* ── topbar ── */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: rgba(8, 5, 22, .82);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(139, 92, 246, .22);
}
.topbar-logo { font-family: 'Unbounded'; font-weight: 700; font-size: 15px; }
.balance-pill {
  border: 1px solid var(--card-border); cursor: pointer;
  background: rgba(34, 211, 238, .12); color: #7EE8FA;
  font-family: 'Unbounded'; font-weight: 700; font-size: 13.5px;
  border-radius: 999px; padding: 7px 14px;
  box-shadow: 0 0 14px rgba(34, 211, 238, .25);
  transition: transform .2s;
}
.balance-pill:active { transform: scale(.94); }

/* balance modal packages */
.pkg-list { margin-top: 12px; }
.pkg-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 2px; font-size: 13.5px;
  border-bottom: 1px solid rgba(139, 92, 246, .15);
}
.pkg-row:last-child { border-bottom: none; }
.pkg-name { flex: 1; }
.pkg-credits { color: #7EE8FA; font-weight: 700; }
.pkg-price { color: var(--text-dim); min-width: 56px; text-align: right; }

.screen { animation: screenIn .25s ease both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ── cards ── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 16px;
  transition: transform .2s, border-color .2s, box-shadow .2s;
}
.card.appear { animation: cardIn .35s ease both; }
@keyframes cardIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.card.tappable:active { transform: scale(.97); }

/* ── buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; cursor: pointer;
  font-family: 'Inter', sans-serif; font-weight: 600; font-size: 15px;
  border-radius: 16px; padding: 14px 22px;
  color: #fff; width: 100%;
  transition: transform .2s, opacity .2s, box-shadow .2s;
}
.btn:active { transform: scale(.97); }
.btn-cta { background: var(--grad); box-shadow: var(--glow); }
.btn-ghost {
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--card-border);
  color: var(--text);
}
.btn:disabled { opacity: .45; pointer-events: none; }

/* ── chips ── */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, .05);
  color: var(--text-dim);
  border-radius: 999px; padding: 9px 16px;
  font-size: 13.5px; font-weight: 500; cursor: pointer;
  transition: all .2s; font-family: 'Inter', sans-serif;
}
.chip-more {
  border-style: dashed !important;
  border-color: rgba(139, 92, 246, .5) !important;
  color: #C9B8FF !important;
}
.chip.active {
  background: var(--grad); color: #fff; border-color: transparent;
  box-shadow: 0 0 16px rgba(139, 92, 246, .4);
}

/* ── home: action cards ── */
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.action-card {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 12px; cursor: pointer;
}
.action-card .ac-emoji { font-size: 26px; flex-shrink: 0; filter: drop-shadow(0 0 12px rgba(139,92,246,.55)); }
.action-card .ac-name { font-family: 'Unbounded'; font-weight: 600; font-size: 12.5px; line-height: 1.3; }
.action-card .ac-sub { color: var(--text-dim); font-size: 11px; margin-top: 3px; }

.section-title { font-family: 'Unbounded'; font-size: 15px; font-weight: 600; margin: 0 0 12px; }
.screen-sub { color: var(--text-dim); font-size: 13.5px; margin: -8px 0 14px; }

/* ── generation rows ── */
.gen-row { padding: 13px 14px; margin-bottom: 10px; }
.gen-main { display: flex; align-items: center; gap: 12px; }
.gen-ico { font-size: 21px; flex-shrink: 0; }
.gen-info { flex: 1; min-width: 0; }
.gen-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gen-sub { color: var(--text-dim); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gen-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 11px; }
.gen-act {
  background: rgba(255, 255, 255, .06); color: var(--text);
  border: 1px solid var(--card-border); border-radius: 12px;
  padding: 7px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  font-family: 'Inter'; transition: transform .15s;
}
.gen-act:active { transform: scale(.95); }
.gen-act-magic {
  background: var(--grad); border-color: transparent; color: #fff;
  box-shadow: 0 0 14px rgba(139, 92, 246, .35);
}
.empty-note { color: var(--text-dim); font-size: 13.5px; text-align: center; padding: 22px 10px; }

/* ── trends ── */
.trend-catalog { margin-top: 16px; }
.trend-topic-header {
  font-family: 'Unbounded', 'Inter', sans-serif;
  font-size: 17px; font-weight: 600; line-height: 1.25;
  margin-top: 26px;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  filter: drop-shadow(0 0 14px rgba(139, 92, 246, .35));
}
.trend-catalog > .trend-topic-header:first-child { margin-top: 4px; }
.trend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.trend-card { padding: 0; overflow: hidden; cursor: pointer; }
.trend-preview {
  width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block;
  background: #0a0618;
}
.trend-preview-fallback {
  width: 100%; aspect-ratio: 3/4;
  display: flex; align-items: center; justify-content: center; font-size: 42px;
  background: linear-gradient(150deg, rgba(34,211,238,.18), rgba(139,92,246,.25) 55%, rgba(224,77,255,.18));
}
.trend-name { padding: 10px 12px 4px; font-weight: 600; font-size: 13.5px; line-height: 1.35; }
.trend-model-tag {
  padding: 0 12px 11px; font-size: 11px; font-weight: 600;
  color: #C9B8FF; letter-spacing: .2px;
}
.trend-cat-tag {
  position: absolute; top: 8px; left: 8px;
  background: rgba(5, 3, 15, .65); backdrop-filter: blur(6px);
  border-radius: 999px; padding: 4px 9px; font-size: 11px;
}
.trend-price-tag {
  position: absolute; top: 8px; right: 8px;
  background: rgba(5, 3, 15, .65); backdrop-filter: blur(6px);
  border-radius: 999px; padding: 4px 9px; font-size: 11px;
  color: #7EE8FA; font-weight: 700;
}
.trend-card-wrap { position: relative; }

/* trend detail */
.trend-detail-preview { width: 100%; border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; border: 1px solid var(--card-border); }
.trend-detail-preview img, .trend-detail-preview .trend-preview-fallback { width: 100%; display: block; }
.trend-detail h2 { font-size: 19px; margin-bottom: 8px; }
.trend-detail .t-desc { color: var(--text-dim); font-size: 14px; line-height: 1.55; margin-bottom: 14px; }
.price-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(34, 211, 238, .12); border: 1px solid rgba(34, 211, 238, .35);
  color: #7EE8FA; border-radius: 999px; padding: 7px 14px; font-size: 13.5px; font-weight: 600;
  margin-bottom: 16px;
}
.model-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(139, 92, 246, .14); border: 1px solid rgba(139, 92, 246, .4);
  color: #C9B8FF; border-radius: 999px; padding: 7px 14px; font-size: 13px;
  margin: 0 8px 10px 0;
}
.model-pill b { color: #E0D4FF; }
details.prompt-spoiler { margin-bottom: 18px; }
details.prompt-spoiler summary {
  cursor: pointer; color: var(--text-dim); font-size: 13.5px; padding: 6px 0;
  list-style: none;
}
details.prompt-spoiler summary::before { content: "▸ "; }
details.prompt-spoiler[open] summary::before { content: "▾ "; }
details.prompt-spoiler .prompt-text {
  background: rgba(255, 255, 255, .04); border: 1px solid var(--card-border);
  border-radius: 14px; padding: 12px; font-size: 13px; color: var(--text-dim);
  white-space: pre-wrap; margin-top: 8px;
}

/* ── create ── */
.step-label { color: var(--text-dim); font-size: 12.5px; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 8px; }
.create-h { font-size: 19px; margin-bottom: 18px; }
.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.type-card { text-align: center; padding: 28px 12px; cursor: pointer; }
.type-card .t-emoji { font-size: 38px; display: block; margin-bottom: 10px; filter: drop-shadow(0 0 14px rgba(139,92,246,.6)); }
.type-card .t-name { font-family: 'Unbounded'; font-size: 15px; font-weight: 600; }
.type-card .t-price { color: var(--text-dim); font-size: 12.5px; margin-top: 5px; }

.model-card { display: flex; align-items: center; gap: 12px; margin-bottom: 11px; cursor: pointer; }
.model-card .m-info { flex: 1; min-width: 0; }
.model-card .m-name { font-weight: 600; font-size: 14.5px; }
.model-card .m-badge {
  display: inline-block; margin-top: 5px;
  background: var(--grad); border-radius: 999px;
  font-size: 10.5px; font-weight: 700; padding: 3px 9px; color: #fff;
}
.model-card .m-price { color: #7EE8FA; font-weight: 700; font-size: 13.5px; white-space: nowrap; }

.form-block { margin-bottom: 18px; }
.form-label { font-weight: 600; font-size: 13.5px; margin-bottom: 9px; display: block; }
textarea.prompt-input {
  width: 100%; min-height: 110px; resize: vertical;
  background: rgba(255, 255, 255, .05); border: 1px solid var(--card-border);
  border-radius: 16px; color: var(--text); padding: 13px 14px;
  font-family: 'Inter', sans-serif; font-size: 14.5px; line-height: 1.5;
  outline: none; transition: border-color .2s, box-shadow .2s;
}
textarea.prompt-input:focus { border-color: #8B5CF6; box-shadow: 0 0 14px rgba(139, 92, 246, .3); }

.upload-zone {
  border: 1.5px dashed var(--card-border); border-radius: 16px;
  padding: 22px 14px; text-align: center; cursor: pointer;
  color: var(--text-dim); font-size: 13.5px; transition: border-color .2s;
}
.upload-zone:active { border-color: #8B5CF6; }
.upload-thumb-wrap { display: flex; align-items: center; gap: 12px; }
.upload-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 14px; border: 1px solid var(--card-border); }
.upload-replace { color: #7EE8FA; font-size: 13px; cursor: pointer; background: none; border: none; font-family: 'Inter'; }

/* multi-photo upload (1-4 фото) */
.upload-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px;
}
.upload-grid-cell { position: relative; aspect-ratio: 1 / 1; }
.upload-grid-cell img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 12px;
  border: 1px solid var(--card-border);
}
.upload-del {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px;
  border-radius: 50%; border: none; cursor: pointer;
  background: rgba(8, 5, 20, .92); color: #fff; font-size: 12px; line-height: 1;
  box-shadow: 0 0 8px rgba(139, 92, 246, .5);
}
.upload-del:active { background: #8B5CF6; }
.upload-add { margin-top: 2px; }

/* ✨ улучшить промпт через ИИ — same look as .prompt-edit-btn */
.prompt-ai-btn {
  background: rgba(139, 92, 246, .14); color: #C4B5FD;
  border: 1px solid rgba(139, 92, 246, .4); border-radius: 999px;
  padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer;
  font-family: 'Inter'; white-space: nowrap;
}
.prompt-ai-btn:disabled { opacity: .6; cursor: default; }
.improve-preview {
  background: rgba(255, 255, 255, .04); border: 1px solid var(--card-border);
  border-radius: 14px; padding: 13px; font-size: 13px; color: var(--text);
  line-height: 1.55; white-space: pre-wrap; word-break: break-word;
  max-height: 42vh; overflow-y: auto; margin-top: 6px;
}

.total-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; margin-top: 4px;
}
.total-row .tt { color: var(--text-dim); font-size: 13.5px; }
.total-row .tv { font-family: 'Unbounded'; font-weight: 700; font-size: 18px; }

/* progress */
.progress-screen { text-align: center; padding-top: 36px; }
.spinner {
  width: 74px; height: 74px; margin: 0 auto 22px; border-radius: 50%;
  border: 3px solid rgba(139, 92, 246, .2); border-top-color: #22D3EE;
  animation: spin 1s linear infinite;
  filter: drop-shadow(0 0 16px rgba(34, 211, 238, .5));
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-screen h2 { font-size: 18px; margin-bottom: 10px; }
.progress-screen p { color: var(--text-dim); font-size: 13.5px; line-height: 1.6; max-width: 320px; margin: 0 auto 22px; }
.result-emoji { font-size: 56px; margin-bottom: 14px; filter: drop-shadow(0 0 18px rgba(139,92,246,.6)); }

/* ── history ── */
.status-dot { font-size: 15px; }

/* ── chat ── */
.chat-screen { display: flex; flex-direction: column; min-height: calc(100vh - var(--tabbar-h) - 60px); }
.chat-msgs { flex: 1; display: flex; flex-direction: column; gap: 10px; padding-bottom: 16px; }
.bubble {
  max-width: 82%; padding: 11px 14px; border-radius: 18px;
  font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
  animation: cardIn .25s ease both;
}
.bubble.user {
  align-self: flex-end; background: var(--grad); color: #fff;
  border-bottom-right-radius: 6px; box-shadow: 0 0 18px rgba(139, 92, 246, .3);
}
.bubble.assistant {
  align-self: flex-start; background: var(--card-bg);
  border: 1px solid var(--card-border); border-bottom-left-radius: 6px;
  backdrop-filter: blur(12px);
}
.typing { display: inline-flex; gap: 5px; padding: 4px 2px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim); animation: bounce 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,60%,100% { transform: none; opacity: .4; } 30% { transform: translateY(-5px); opacity: 1; } }

.chat-input-row {
  position: sticky; bottom: calc(var(--tabbar-h) + 6px);
  display: flex; gap: 9px; padding-top: 8px;
  background: linear-gradient(transparent, var(--bg) 35%);
}
.chat-input {
  flex: 1; background: rgba(255, 255, 255, .06); border: 1px solid var(--card-border);
  border-radius: 999px; color: var(--text); padding: 13px 17px;
  font-family: 'Inter'; font-size: 14.5px; outline: none;
}
.chat-input:focus { border-color: #8B5CF6; }
.chat-send {
  width: 48px; height: 48px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--grad); color: #fff; font-size: 18px; flex-shrink: 0;
  box-shadow: var(--glow); display: flex; align-items: center; justify-content: center;
}

/* ── tabbar ── */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  background: rgba(8, 5, 22, .82);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid rgba(139, 92, 246, .22);
}
.tab {
  flex: 1; background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--text-dim); font-family: 'Inter'; font-size: 10.5px; font-weight: 500;
  transition: color .2s;
}
.tab svg { width: 23px; height: 23px; transition: all .2s; }
.tab.active { color: var(--text); }
.tab.active svg { stroke: url(#tabgrad); filter: drop-shadow(0 0 8px rgba(139, 92, 246, .8)); }
.tab.active span {
  background: var(--grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; font-weight: 700;
}

/* ── gate ── */
.gate { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; }
.gate-card { text-align: center; max-width: 330px; padding: 36px 24px; }
.gate-emoji { font-size: 46px; margin-bottom: 16px; }
.gate-card h2 { font-size: 17px; margin-bottom: 10px; }
.gate-card p { color: var(--text-dim); font-size: 13.5px; line-height: 1.6; }

/* ── modal ── */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 26px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(3, 2, 10, .7); backdrop-filter: blur(4px); }
.modal-card { position: relative; max-width: 340px; width: 100%; padding: 24px 20px; animation: cardIn .25s ease both; }
.modal-card h3 { font-size: 16px; margin-bottom: 10px; }
.modal-card p { color: var(--text-dim); font-size: 14px; line-height: 1.55; }
.modal-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }

/* ── collapsed prompt (template screen) ── */
.prompt-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.prompt-head .form-label { margin-bottom: 0; }
.prompt-edit-btn {
  background: rgba(255, 255, 255, .06); color: #7EE8FA;
  border: 1px solid var(--card-border); border-radius: 999px;
  padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer;
  font-family: 'Inter';
}
.prompt-collapsed {
  background: rgba(255, 255, 255, .04); border: 1px solid var(--card-border);
  border-radius: 14px; padding: 12px; font-size: 12.5px; color: var(--text-dim);
  line-height: 1.5; max-height: 78px; overflow: hidden; position: relative;
  white-space: pre-wrap; word-break: break-word;
}
.prompt-collapsed::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 34px;
  background: linear-gradient(transparent, var(--bg));
  border-radius: 0 0 14px 14px;
}

/* ── identity block (Seedance раскадровка лица) ── */
.identity-block { margin-bottom: 18px; border-color: rgba(34, 211, 238, .4); }
.identity-head { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.identity-opt {
  font-size: 10.5px; font-weight: 600; color: var(--text-dim);
  border: 1px solid var(--card-border); border-radius: 999px; padding: 2px 8px;
}
.identity-desc { color: var(--text-dim); font-size: 12.5px; line-height: 1.55; margin: 8px 0 12px; }
.identity-skip { color: var(--text-dim); font-size: 11.5px; text-align: center; margin-top: 8px; }
.identity-progress { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-dim); padding: 6px 2px; }
.identity-fail { color: #FF9B9B; font-size: 12.5px; margin-bottom: 10px; line-height: 1.5; }
.identity-ready { border-color: rgba(34, 211, 238, .45); }

/* ── смена модели в деталке шаблона: предупреждение ── */
.model-warn {
  background: rgba(245, 158, 11, .12);
  border: 1px solid rgba(245, 158, 11, .42);
  color: #FFD79B;
  border-radius: 14px;
  padding: 11px 14px;
  font-size: 12.5px;
  line-height: 1.5;
  margin: 0 0 14px;
}
.tpl-model-toggle { margin: 2px 0 10px; }
.tpl-model-chips { margin-bottom: 4px; }

.spinner-sm {
  width: 26px; height: 26px; margin: 0; border-width: 2.5px; flex-shrink: 0;
}

/* ── music / progress stages ── */
.stage-list { max-width: 320px; margin: 0 auto 22px; text-align: left; }
.stage {
  color: var(--text-dim); font-size: 13.5px; padding: 8px 0 8px 4px;
  border-bottom: 1px solid rgba(139, 92, 246, .12);
}
.stage:last-child { border-bottom: none; }
.stage.active { color: var(--text); font-weight: 600; }
.stage.done { color: #7EE8FA; }

/* ── result image + animate ── */
.result-img {
  width: 100%; max-width: 320px; border-radius: var(--radius);
  border: 1px solid var(--card-border); display: block; margin: 6px auto 0;
  box-shadow: 0 0 28px rgba(139, 92, 246, .3);
  cursor: pointer;
}
.result-video {
  width: 100%; max-width: 340px; max-height: 52vh; border-radius: var(--radius);
  border: 1px solid var(--card-border); display: block; margin: 6px auto 0;
  background: #000;
}

/* ── история: превью генерации ── */
.gen-thumb {
  width: 56px; height: 56px; border-radius: 12px; object-fit: cover;
  flex-shrink: 0; cursor: pointer; border: 1px solid var(--card-border);
}

/* ── треки на экране результата (web) ── */
.track-row { display: flex; align-items: center; gap: 8px; }
.track-row audio { flex: 1; min-width: 0; height: 36px; }
.track-name { font-size: 12.5px; color: var(--text-dim); flex-shrink: 0; }
.track-dl { padding: 8px 10px; flex-shrink: 0; }

/* ── лайтбокс: просмотр на весь экран + скачать ── */
.lightbox {
  position: fixed; inset: 0; z-index: 300;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 18px;
}
.lightbox.hidden { display: none; }
.lb-backdrop { position: absolute; inset: 0; background: rgba(2, 0, 12, .94); }
.lb-body {
  position: relative; max-width: 96vw; max-height: 76vh;
  display: flex; align-items: center; justify-content: center;
}
.lb-body img, .lb-body video {
  max-width: 96vw; max-height: 76vh; border-radius: 14px; object-fit: contain;
}
.lb-bar { position: relative; display: flex; gap: 10px; }
.lb-dl { text-decoration: none; }
.animate-list { margin-top: 12px; max-height: 52vh; overflow-y: auto; }
.animate-list .model-card { cursor: pointer; }
.m-durs { color: var(--text-dim); font-size: 11px; margin-top: 5px; line-height: 1.4; }
.track-link { text-decoration: none; }

.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }

/* ── web mode: login screen ── */
.login-card { max-width: 360px; width: 100%; padding: 34px 26px; }
.login-logo { font-size: 46px; margin-bottom: 8px; filter: drop-shadow(0 0 18px rgba(139, 92, 246, .7)); }
.login-title { font-size: 21px; margin-bottom: 6px; }
.login-sub { color: var(--text-dim); font-size: 13.5px; margin-bottom: 22px; }
.tg-widget-box { display: flex; justify-content: center; min-height: 44px; }
.login-divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--text-dim); font-size: 12px; margin: 18px 0;
}
.login-divider::before, .login-divider::after {
  content: ""; flex: 1; height: 1px; background: rgba(139, 92, 246, .25);
}
#email-form, #code-form { display: flex; flex-direction: column; gap: 10px; }
.login-code-note { color: var(--text-dim); font-size: 12.5px; line-height: 1.5; }
.login-code-note b { color: var(--text); word-break: break-all; }
.code-input { text-align: center; letter-spacing: 8px; font-size: 18px; font-weight: 700; }
.login-error { color: #FF9B9B; font-size: 12.5px; margin-top: 14px; line-height: 1.5; }

/* ── web mode: topbar back/logout + bottom CTA (MainButton fallback) ── */
body.web-mode #topbar { justify-content: flex-start; }
body.web-mode .balance-pill { margin-left: auto; }
#web-back-btn, #logout-btn {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; cursor: pointer;
  border: 1px solid var(--card-border); background: rgba(255, 255, 255, .06);
  color: var(--text); display: flex; align-items: center; justify-content: center;
  transition: transform .15s;
}
#web-back-btn:active, #logout-btn:active { transform: scale(.92); }
#web-back-btn { margin-right: 10px; font-size: 22px; line-height: 1; padding-bottom: 3px; }
#logout-btn { margin-left: 10px; }
#logout-btn svg { width: 17px; height: 17px; }
#web-main-btn {
  position: fixed; left: 16px; right: 16px; z-index: 60; width: auto;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 12px);
}
body.has-web-main-btn #screen-root { padding-bottom: calc(var(--tabbar-h) + 110px); }

/* ── web mode: desktop — телефонная колонка по центру ── */
@media (min-width: 700px) {
  #screen-root { max-width: 480px; }
  #topbar, #tabbar {
    left: 50%; right: auto; transform: translateX(-50%); width: 480px;
    border-left: 1px solid rgba(139, 92, 246, .22);
    border-right: 1px solid rgba(139, 92, 246, .22);
  }
  #web-main-btn { left: 50%; right: auto; transform: translateX(-50%); width: 448px; }
}

/* ── music: полный flow на одном экране ── */
.mode-row { margin-bottom: 14px; }
.text-input {
  width: 100%;
  background: rgba(255, 255, 255, .05); border: 1px solid var(--card-border);
  border-radius: 14px; color: var(--text); padding: 12px 14px;
  font-family: 'Inter', sans-serif; font-size: 14.5px; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.text-input:focus { border-color: #8B5CF6; box-shadow: 0 0 14px rgba(139, 92, 246, .3); }
.label-hint { color: var(--text-dim); font-size: 11px; font-weight: 500; }
.lyrics-card { margin-top: 14px; border-color: rgba(34, 211, 238, .4); }
textarea.lyrics-ta { min-height: 150px; resize: none; overflow: hidden; }
textarea.refine-ta, textarea.style-ta { min-height: 64px; resize: none; overflow: hidden; }
.btn-row { display: flex; gap: 10px; margin-top: 13px; }
.btn-sm { padding: 11px 14px; font-size: 13.5px; border-radius: 14px; }
.refine-box { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.tweak-block { margin-top: 10px; }
.tweak-block .tweak-toggle { display: inline-block; }
.gen-wait {
  display: flex; align-items: center; gap: 12px; margin-top: 14px;
  font-size: 13.5px; color: var(--text-dim);
}
.collapse-toggle {
  background: none; border: none; cursor: pointer; padding: 6px 0;
  color: #7EE8FA; font-family: 'Inter'; font-size: 13.5px; font-weight: 600;
}
#mu-style-box { margin-top: 8px; }
.field-hint { color: var(--text-dim); font-size: 11.5px; margin-top: 7px; }

/* ── видео-превью в карточках трендов: анимация + play-значок ── */
.preview-wrap { position: relative; width: 100%; line-height: 0; }
.trend-preview-video {
  width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block;
  background: #0a0618;
}
.play-badge {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 46px; height: 46px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5, 3, 15, .55); backdrop-filter: blur(6px);
  border: 1.5px solid rgba(237, 235, 255, .55);
  color: #fff; font-size: 17px; padding-left: 3px;
  box-shadow: 0 0 18px rgba(139, 92, 246, .45);
  pointer-events: none;
}
.trend-detail-preview .play-badge { width: 60px; height: 60px; font-size: 22px; }

/* ── Seedance: степпер длительности (5..15 сек) ── */
.dur-stepper {
  display: flex; align-items: center; gap: 14px;
  background: rgba(255, 255, 255, .05); border: 1px solid var(--card-border);
  border-radius: 16px; padding: 10px 14px; width: fit-content;
}
.step-btn {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  border: 1px solid var(--card-border); background: rgba(255, 255, 255, .06);
  color: var(--text); font-size: 22px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, opacity .2s;
}
.step-btn:active { transform: scale(.9); }
.step-btn:disabled { opacity: .35; cursor: default; }
.step-val { font-family: 'Unbounded', 'Inter'; font-weight: 700; font-size: 17px; min-width: 78px; text-align: center; }

/* ── СБП пополнение в Mini App (MAX/web) ── */
.topup-pkgs { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.topup-pkg {
  display: flex; align-items: center; gap: 12px; width: 100%; cursor: pointer;
  padding: 15px 16px; text-align: left; color: var(--text);
  font-family: 'Inter', sans-serif; transition: transform .15s;
}
.topup-pkg:active { transform: scale(.98); }
.topup-pkg-name { font-family: 'Unbounded'; font-weight: 600; font-size: 14px; flex: 1; }
.topup-pkg-cr { color: #7EE8FA; font-weight: 700; font-size: 14px; }
.topup-pkg-price { color: var(--text-dim); font-size: 13px; min-width: 56px; text-align: right; }
.topup-result { margin-top: 18px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.topup-result .btn { text-decoration: none; }
.topup-amount { font-family: 'Unbounded'; font-weight: 700; font-size: 18px; }

/* ── MAX → Telegram: поле кода привязки ── */
.link-code-input {
  width: 100%; margin-top: 14px; text-align: center;
  letter-spacing: 4px; text-transform: uppercase; font-weight: 700; font-size: 17px;
  background: rgba(255, 255, 255, .05); border: 1px solid var(--card-border);
  border-radius: 14px; color: var(--text); padding: 12px 14px;
  font-family: 'Inter', sans-serif; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.link-code-input:focus { border-color: #8B5CF6; box-shadow: 0 0 14px rgba(139, 92, 246, .3); }
.link-err { color: #FF9B9B; padding: 8px 4px 0 !important; text-align: left; }
