:root {
  color-scheme: dark;
  --bg: #0c0e12;
  --surface: #14171d;
  --surface-raised: #1a1e25;
  --text: #f4f4f1;
  --muted: #969ba6;
  --faint: #666c78;
  --border: #2b3039;
  --border-strong: #434955;
  --accent: #ffad27;
  --accent-pressed: #e79511;
  --success: #45c96b;
  --danger: #ff626b;
  --shadow: 0 18px 44px rgb(0 0 0 / 30%);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  min-height: var(--tg-viewport-stable-height, 100%);
  margin: 0;
  background: var(--bg);
}

body {
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select { font: inherit; }

button,
select { -webkit-tap-highlight-color: transparent; }

button { cursor: pointer; }

.hidden { display: none !important; }

.app-shell {
  width: min(100%, 760px);
  min-height: var(--tg-viewport-stable-height, 100dvh);
  margin: 0 auto;
  padding-top: max(16px, env(safe-area-inset-top), var(--tg-content-safe-area-inset-top, 0px));
  padding-right: max(20px, env(safe-area-inset-right), var(--tg-content-safe-area-inset-right, 0px));
  padding-bottom: max(28px, env(safe-area-inset-bottom), var(--tg-content-safe-area-inset-bottom, 0px));
  padding-left: max(20px, env(safe-area-inset-left), var(--tg-content-safe-area-inset-left, 0px));
}

.utility-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 32px;
}

.brand-mark {
  width: 42px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
}

.brand-mark span {
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
}

.brand-mark span:nth-child(1),
.brand-mark span:nth-child(5) { height: 13px; }
.brand-mark span:nth-child(2),
.brand-mark span:nth-child(4) { height: 25px; }
.brand-mark span:nth-child(3) { height: 36px; }

.utility-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }

.utility-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
}

.utility-button svg {
  width: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.balance-button { padding: 0 11px; font-size: 12px; white-space: nowrap; }
.balance-button strong { color: var(--accent); font-size: 14px; }
.locale-button { min-width: 48px; padding: 0 10px; font-weight: 750; }
.icon-button { width: 44px; padding: 0; color: var(--muted); }

.loading-wave,
.processing-wave { display: flex; align-items: center; justify-content: center; gap: 3px; }

.loading-screen,
.not-found,
.processing-screen,
.error-screen {
  min-height: calc(var(--tg-viewport-stable-height, 100dvh) - 64px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.loading-screen p { margin-top: 18px; color: var(--muted); }

.loading-wave span,
.processing-wave span {
  width: 4px;
  border-radius: 4px;
  background: var(--accent);
  animation: wave 1s ease-in-out infinite;
}

.loading-wave span:nth-child(1),
.loading-wave span:nth-child(5),
.processing-wave span:nth-child(1),
.processing-wave span:nth-child(5) { height: 14px; }
.loading-wave span:nth-child(2),
.loading-wave span:nth-child(4),
.processing-wave span:nth-child(2),
.processing-wave span:nth-child(4) { height: 28px; animation-delay: 100ms; }
.loading-wave span:nth-child(3),
.processing-wave span:nth-child(3) { height: 40px; animation-delay: 200ms; }

.not-found-code {
  color: var(--accent);
  font-size: clamp(68px, 22vw, 112px);
  font-weight: 850;
  letter-spacing: -0.07em;
}

.not-found h1,
.error-screen h1 { margin: 8px 0; font-size: 26px; line-height: 1.15; }
.not-found p,
.error-screen p { max-width: 420px; margin: 0; color: var(--muted); }

.start-screen { max-width: 620px; margin: 0 auto; }

.beta-kicker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.beta-kicker span:first-child {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgb(69 201 107 / 10%);
}

.intro { margin-top: 19px; }
.intro h1 {
  margin: 0;
  font-size: clamp(35px, 10vw, 54px);
  line-height: 1.03;
  letter-spacing: -.052em;
}
.intro h1 em { color: var(--accent); font-style: normal; }
.intro p {
  max-width: 540px;
  margin: 17px 0 0;
  color: var(--muted);
  font-size: clamp(16px, 4.6vw, 20px);
  line-height: 1.5;
}

.benefit-list { margin-top: 31px; border-top: 1px solid var(--border); }
.benefit-row {
  position: relative;
  min-height: 76px;
  display: grid;
  grid-template-columns: 45px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.benefit-icon {
  width: 43px;
  height: 43px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--accent);
  background: var(--surface);
}
.benefit-icon svg {
  width: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.benefit-row strong { display: block; font-size: 15px; }
.benefit-row p { margin: 3px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.price-benefit { padding-right: 100px; }
.price-from { position: absolute; right: 0; color: var(--accent); font-size: 13px; font-weight: 750; }

.url-form { margin-top: 28px; }
.url-form > label {
  display: block;
  margin: 0 0 8px 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.input-shell {
  height: 60px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: 13px;
  background: transparent;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.input-shell:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(255 173 39 / 12%); }
.input-shell svg {
  width: 23px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.input-shell input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); }
.input-shell input::placeholder { color: #626875; }

.field-row { margin-top: 12px; }
.select-field,
.quote-language-field {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 15px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
}
.select-field > span,
.quote-language-field > span { color: var(--muted); font-size: 13px; }
select { max-width: 60%; border: 0; outline: 0; background: transparent; color: var(--text); font-weight: 700; text-align: right; }
select option { color: #111; }
.form-error { margin: 10px 3px 0; color: var(--danger); font-size: 13px; }

.primary-button,
.secondary-button {
  width: 100%;
  min-height: 58px;
  border-radius: 13px;
  font-size: 16px;
  font-weight: 780;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}
.primary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
  border: 0;
  background: var(--accent);
  color: #17120a;
}
.primary-button svg,
.secondary-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.primary-button:active,
.secondary-button:active,
.utility-button:active { transform: scale(.985); }
.primary-button:disabled { cursor: wait; opacity: .55; }
.secondary-button { border: 1px solid var(--border-strong); background: transparent; color: var(--muted); }
.url-form .primary-button svg { margin-left: auto; margin-right: 16px; }
.url-form .primary-button span { margin-left: auto; }

.recent-section { margin-top: 34px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.section-heading button { min-height: 44px; padding: 0; border: 0; background: transparent; color: var(--accent); }

.job-row {
  width: 100%;
  min-height: 80px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  margin-top: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}
.job-thumb { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 10px; background: var(--surface-raised); color: var(--accent); }
.job-thumb svg { width: 23px; fill: currentColor; }
.job-row strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-row p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.job-action { color: var(--accent); font-size: 13px; }

.back-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: -5px 0 17px -9px;
  padding: 0 9px;
  border: 0;
  background: transparent;
  color: var(--muted);
}
.back-button svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.quote-screen,
.wallet-screen,
.history-screen,
.player-screen { max-width: 620px; margin: 0 auto; }
.quote-screen h1,
.wallet-screen h1,
.history-screen h1 { margin: 0; font-size: 30px; line-height: 1.08; letter-spacing: -.035em; }
.quote-video {
  min-height: 94px;
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  align-items: center;
  gap: 15px;
  margin-top: 24px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}
.quote-video-icon { width: 68px; height: 58px; display: grid; place-items: center; border-radius: 10px; background: #090a0d; color: var(--accent); }
.quote-video-icon svg { width: 31px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.quote-video strong { display: block; font-size: 16px; line-height: 1.3; }
.quote-video p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.quote-language-field { margin-top: 12px; }
.quote-cost { margin-top: 28px; padding: 0 2px 25px; border-bottom: 1px dashed var(--border); }
.quote-cost > span { display: block; color: var(--muted); font-size: 14px; }
.quote-cost > strong { display: block; margin-top: 4px; color: var(--accent); font-size: clamp(48px, 15vw, 72px); font-weight: 750; line-height: 1; letter-spacing: -.05em; }
.quote-cost small { font-size: 20px; letter-spacing: 0; }
.quote-cost p { margin: 15px 0 0; color: var(--success); font-size: 14px; }

.trust-list { margin-top: 22px; }
.trust-list > div { display: grid; grid-template-columns: 46px minmax(0, 1fr); gap: 14px; align-items: start; padding: 11px 0; }
.trust-icon { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--accent); border-radius: 50%; color: var(--accent); }
.trust-icon.realtime { border-color: var(--success); color: var(--success); }
.trust-icon svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.trust-list p { margin: 0; }
.trust-list strong,
.trust-list p > span { display: block; }
.trust-list p > span { margin-top: 4px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.test-note { margin: 16px 0 0; padding: 12px 14px; border-left: 2px solid var(--accent); background: rgb(255 173 39 / 6%); color: var(--muted); font-size: 12px; }
.quote-screen .primary-button { margin-top: 22px; }
.quote-screen .secondary-button { margin-top: 10px; }

.processing-screen h1 { margin: 28px 0 9px; font-size: 28px; letter-spacing: -.03em; }
.processing-screen > p { max-width: 520px; margin: 0; color: var(--muted); }
.processing-visual { position: relative; width: 112px; height: 112px; display: grid; place-items: center; }
.processing-ring { position: absolute; inset: 0; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 1.4s linear infinite; }
.progress-block { width: 100%; margin-top: 38px; padding: 18px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.progress-meta { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-size: 13px; }
.progress-meta span { color: var(--muted); }
.progress-meta strong { color: var(--accent); font-size: 16px; }
.progress-track { height: 7px; margin-top: 13px; overflow: hidden; border-radius: 7px; background: #292e37; }
.progress-fill { width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width 420ms ease; }
.processing-note { max-width: 520px; margin-top: 17px; color: var(--faint); font-size: 12px; }

.error-icon { width: 68px; height: 68px; display: grid; place-items: center; border-radius: 50%; background: rgb(255 98 107 / 9%); color: var(--danger); }
.error-icon svg { width: 36px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.error-screen .secondary-button { max-width: 340px; margin-top: 28px; }

.player-screen { padding-top: 4px; }
.ready-heading h1 { margin: 0; font-size: clamp(22px, 6vw, 30px); line-height: 1.25; letter-spacing: -.025em; }
.ready-status { display: flex; align-items: center; gap: 7px; margin-top: 10px; color: var(--success); font-size: 13px; font-weight: 700; }
.ready-status svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.video-frame { position: relative; margin-top: 21px; overflow: hidden; border-radius: 16px; aspect-ratio: 16 / 9; background: #050607; box-shadow: var(--shadow); }
.video-frame video { width: 100%; height: 100%; display: block; object-fit: contain; background: #050607; }
.video-muted { position: absolute; top: 10px; left: 10px; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: rgb(10 12 16 / 78%); color: var(--text); backdrop-filter: blur(8px); pointer-events: none; }
.video-muted svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.playback-row { display: grid; grid-template-columns: 48px 45px minmax(80px, 1fr) 45px; align-items: center; gap: 9px; margin-top: 16px; }
.play-button { width: 48px; height: 48px; display: grid; place-items: center; border: 2px solid var(--accent); border-radius: 50%; background: transparent; color: var(--accent); }
.play-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.play-button .play-icon { margin-left: 2px; fill: currentColor; stroke: none; }
.time-label { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; text-align: center; }
.timeline { width: 100%; height: 24px; margin: 0; accent-color: var(--accent); }
.audio-panel,
.live-panel,
.transcript-panel { margin-top: 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.audio-panel,
.live-panel,
.transcript-panel { padding: 17px; }
.panel-title { font-size: 14px; font-weight: 750; }
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 13px; }
.mode-button { min-height: 52px; display: flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 11px; background: var(--surface-raised); color: var(--muted); font-size: 13px; font-weight: 700; }
.mode-button.selected { border-color: var(--accent); color: var(--accent); background: rgb(255 173 39 / 5%); }
.mode-button svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.live-indicator { display: flex; align-items: center; gap: 9px; }
.live-indicator strong { font-size: 13px; }
.live-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: #697080; box-shadow: 0 0 0 4px rgb(105 112 128 / 12%); }
.live-panel[data-state="connecting"] .live-dot { background: var(--accent); box-shadow: 0 0 0 4px rgb(255 173 39 / 14%); animation: live-pulse 1.1s ease-in-out infinite; }
.live-panel[data-state="active"] .live-dot { background: var(--success); box-shadow: 0 0 0 4px rgb(69 201 107 / 14%); }
.live-panel[data-state="error"] .live-dot { background: var(--danger); box-shadow: 0 0 0 4px rgb(255 98 107 / 14%); }
.live-panel[data-state="error"] .live-indicator strong { color: var(--danger); }
.live-panel p { margin: 8px 0 0 18px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.transcript-panel p { max-height: 150px; overflow: auto; margin: 9px 0 0; color: #d5d8de; font-size: 14px; line-height: 1.6; white-space: pre-wrap; }
.new-video { margin-top: 18px; }

.wallet-balance { margin-top: 24px; padding: 22px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.wallet-balance > span { display: block; color: var(--muted); font-size: 13px; }
.wallet-balance strong { display: block; margin-top: 3px; color: var(--accent); font-size: clamp(48px, 14vw, 68px); line-height: 1; letter-spacing: -.045em; }
.wallet-balance small { font-size: 19px; letter-spacing: 0; }
.wallet-balance p { margin: 13px 0 0; color: var(--muted); font-size: 13px; }
.wallet-screen h2 { margin: 27px 0 12px; font-size: 18px; }
.package-list { display: grid; gap: 10px; }
.package-row { position: relative; min-height: 88px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 15px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.package-row[data-best="true"] { border-color: var(--accent); }
.package-row strong { display: block; font-size: 18px; }
.package-row p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.package-row button { min-height: 46px; padding: 0 14px; border: 0; border-radius: 11px; background: var(--accent); color: #17120a; font-weight: 750; white-space: nowrap; }
.package-badge { position: absolute; top: -9px; left: 13px; padding: 2px 7px; border-radius: 8px; background: var(--accent); color: #17120a; font-size: 10px; font-weight: 800; }
.payment-status { margin: 14px 0 0; color: var(--muted); text-align: center; }
.wallet-terms {
  margin: 18px 4px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}
.wallet-terms a {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.history-list { margin-top: 21px; }
.history-empty { margin: 42px auto 0; max-width: 390px; color: var(--muted); text-align: center; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes wave { 0%, 100% { transform: scaleY(.62); } 50% { transform: scaleY(1); } }
@keyframes live-pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

@media (min-width: 620px) {
  .app-shell { padding-inline: 36px; }
}

@media (max-width: 430px) {
  .utility-bar { margin-bottom: 27px; }
  .balance-button > span > span:first-child { display: none; }
  .benefit-row p { font-size: 12px; }
  .price-benefit { padding-right: 88px; }
  .price-from { width: 82px; text-align: right; }
}

@media (max-width: 360px) {
  .app-shell { padding-inline: 15px; }
  .intro h1 { font-size: 33px; }
  .benefit-row { grid-template-columns: 41px minmax(0, 1fr); gap: 11px; }
  .benefit-icon { width: 40px; height: 40px; }
  .playback-row { grid-template-columns: 44px 39px minmax(62px, 1fr) 39px; gap: 5px; }
  .package-row { grid-template-columns: 1fr; }
  .package-row button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
.mixer-panel { margin-top: 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); padding: 17px; }
.mixer-row { display: flex; align-items: center; gap: 12px; margin-top: 13px; }
.mixer-row span { flex: 0 0 128px; font-size: 13px; color: var(--muted); }
.mixer-row input { flex: 1; height: 24px; margin: 0; accent-color: var(--accent); }
.mixer-row strong { flex: 0 0 48px; text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; }
