:root {
  color-scheme: dark;
  --bg: #000;
  --text: #f6f6f4;
  --muted: #898989;
  --muted-2: #5f5f5f;
  --faint: #363636;
  --surface: #1a1a1a;
  --surface-2: #0a0a0a;
  --line: #252525;
  --accent: #c8ff00;
  --danger: #ff5e5e;
  --radius: 18px;
  --pill: 999px;
  --nav-height: 68px;
  --tg-content-top: 0px;
  --tg-safe-bottom: 0px;
  --top-tap-guard: 12px;
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-bottom));
  --app-height: 100vh;
  --shell-top: max(env(safe-area-inset-top, 0px), calc(var(--tg-content-top) + var(--top-tap-guard)), 30px);
  --studio-bottom-space: 176px;
  --settings-menu-left: 0px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100vh;
  height: -webkit-fill-available;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow: hidden;
  overscroll-behavior: none;
  background: #000;
}

body {
  position: fixed;
  inset: 0;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.25 "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body.studio-active,
body.result-active,
body.balance-active {
  height: 100vh;
  height: -webkit-fill-available;
  overflow: hidden;
  overscroll-behavior: none;
}

button,
input,
textarea {
  font: inherit;
}

button {
  appearance: none;
  border: 0;
  cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled {
  cursor: default;
}

svg {
  display: block;
}

svg path,
svg circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.hidden,
.visually-hidden,
.hidden-summary {
  display: none !important;
}

.app-shell {
  position: relative;
  width: min(100%, 430px);
  height: var(--app-height);
  min-height: var(--app-height);
  margin: 0 auto;
  overflow: hidden;
  padding: var(--shell-top) 15px var(--safe-bottom);
  background: #000;
}

body.studio-active .app-shell {
  height: var(--app-height);
  min-height: var(--app-height);
  overflow: hidden;
  padding-bottom: var(--safe-bottom);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

body.result-active .result-view.active,
body.balance-active .balance-view.active {
  position: relative;
  display: flex;
  flex-direction: column;
  height: calc(var(--app-height) - var(--shell-top) - var(--nav-height) - 12px - var(--safe-bottom));
  overflow: hidden;
}

body.studio-active .studio-view.active {
  display: flex;
  flex-direction: column;
  height: calc(var(--app-height) - var(--shell-top) - var(--studio-bottom-space) - var(--safe-bottom));
  overflow: hidden;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 7px;
  color: var(--accent);
}

.logo-mark {
  display: block;
  width: 31px;
  height: 31px;
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover;
}

.brand {
  color: var(--accent);
  font-size: 26px;
  line-height: 1;
  font-weight: 700;
  white-space: nowrap;
}

.user-line {
  color: var(--muted);
  font-size: 12px;
}

.balance-wrap {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 11px;
}

.balance-label {
  color: var(--muted);
  font-size: 17px;
  white-space: nowrap;
}

.balance-pill {
  display: inline-flex;
  align-items: center;
  min-width: 118px;
  height: 38px;
  padding: 2px 2px 2px 18px;
  border: 1px solid var(--line);
  border-radius: var(--pill);
  background: #050505;
  color: var(--text);
}

.balance-pill span:first-child {
  min-width: 58px;
  color: var(--text);
  font-size: 17px;
  text-align: center;
  white-space: nowrap;
}

.plus-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-left: 8px;
  border-radius: 50%;
  background: #1b1b1b;
  color: var(--accent);
  font-size: 34px;
  font-weight: 400;
  line-height: .82;
}

.control-block {
  margin-bottom: 12px;
}

.generation-selector {
  position: relative;
  display: grid;
  grid-template-columns: 134px minmax(0, 1fr);
  gap: 7px;
  margin-bottom: 12px;
}

.generation-type-toggle,
.model-select-button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--pill);
  background: #020202;
}

.generation-type-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 2px;
}

.type-icon-button {
  display: grid;
  place-items: center;
  min-width: 0;
  border-radius: var(--pill);
  background: transparent;
  color: #fff;
}

.type-icon-button.active {
  background: var(--surface);
}

.type-icon-button svg {
  width: 24px;
  height: 24px;
}

.model-select-wrap {
  position: relative;
  min-width: 0;
}

.model-select-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: center;
  width: 100%;
  padding: 0 16px;
  color: var(--text);
  text-align: left;
}

.model-select-button span,
.model-dropdown-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-select-button small,
.model-dropdown-item small {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.model-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  z-index: 35;
  overflow: hidden;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 18px 38px rgba(0, 0, 0, .42);
}

.model-dropdown-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: center;
  width: 100%;
  min-height: 46px;
  padding: 0 16px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.model-dropdown-item.active {
  color: var(--accent);
}

.model-dropdown-item + .model-dropdown-item {
  border-top: 1px solid rgba(255, 255, 255, .03);
}

.model-tabs,
.mode-block {
  display: grid;
  min-height: 45px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--pill);
  background: #020202;
  overflow: hidden;
}

.model-tabs {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mode-block {
  grid-template-columns: repeat(var(--mode-tab-count, 2), minmax(0, 1fr));
  margin-bottom: 22px;
}

body.image-generation .mode-block {
  display: none;
}

.mode-block.has-motion {
  --mode-tab-count: 3;
}

.option-button,
.segment-button,
.mode-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 39px;
  padding: 7px 10px;
  border-radius: var(--pill);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  white-space: nowrap;
}

.option-button strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font: inherit;
}

.option-button small {
  display: none;
}

.option-button.active,
.segment-button.active,
.mode-tab.active {
  background: var(--surface);
  color: var(--text);
}

.mode-tab:disabled {
  color: #3e3e3e;
}

.media-panel {
  margin-bottom: 20px;
}

.reference-status-row {
  display: grid;
  grid-template-columns: auto auto auto 34px;
  align-items: center;
  gap: 15px;
  min-height: 28px;
  padding: 0 15px;
  margin-bottom: 20px;
}

.reference-status {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  min-width: 0;
  padding: 0;
  background: transparent;
  color: var(--muted-2);
  font-size: 13px;
  white-space: nowrap;
}

.reference-status svg {
  width: 23px;
  height: 23px;
  flex: 0 0 auto;
}

.reference-status.active {
  color: var(--accent);
}

.reference-status.disabled {
  color: #505050;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: transparent;
  color: #bdbdbd;
}

.icon-button svg {
  width: 24px;
  height: 24px;
}

.reference-rail {
  display: flex;
  gap: 13px;
  width: calc(100% + 15px);
  margin-right: -15px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.reference-rail::-webkit-scrollbar,
.chip-options::-webkit-scrollbar {
  display: none;
}

.reference-preview-grid {
  display: flex;
  flex: 0 0 auto;
  gap: 13px;
}

.reference-preview-card,
.reference-add-card,
.reference-empty-card,
.frame-card {
  position: relative;
  flex: 0 0 auto;
  width: 130px;
  height: 94px;
  overflow: hidden;
  border-radius: 18px;
  background: var(--surface);
}

.reference-preview-thumb,
.frame-thumb {
  display: block;
  width: 100%;
  height: 100%;
  background-position: center;
  background-size: cover;
}

.reference-preview-video {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
}

.reference-preview-video.is-ready {
  opacity: 1;
}

.video-preview-thumb {
  position: relative;
  display: grid;
  place-items: center;
  background: #111;
}

.video-preview-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.reference-preview-thumb.no-preview {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.media-remove-button {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #000;
  color: #fff;
  font-size: 24px;
  line-height: 1;
}

.reference-preview-card span:not(.frame-add) {
  display: none;
}

.reference-add-card {
  display: grid;
  place-items: center;
  color: var(--accent);
}

.reference-add-card span,
.frame-add {
  color: var(--accent);
  font-size: 36px;
  font-weight: 400;
  line-height: 1;
}

.reference-empty-card {
  background: #060606;
}

.keyframe-label-row {
  display: grid;
  grid-template-columns: 1fr 52px 1fr;
  align-items: center;
  gap: 12px;
  padding: 0 29px;
  margin-bottom: 27px;
  color: #444;
  font-size: 14px;
}

.keyframe-label-row span:last-child {
  text-align: right;
}

.keyframe-label-row .trash-button {
  justify-self: center;
  color: #303030;
  opacity: .55;
}

.keyframe-label-row .trash-button.has-media {
  color: var(--text);
  opacity: 1;
}

.keyframe-label-row .trash-button.has-media:active {
  color: var(--accent);
}

.keyframe-label-row .trash-button:disabled {
  color: #303030;
  opacity: .45;
}

.keyframe-grid {
  display: grid;
  grid-template-columns: minmax(0, 130px) 1fr minmax(0, 130px);
  align-items: center;
  gap: 18px;
}

.keyframe-grid .frame-card {
  width: 100%;
  max-width: 130px;
}

.keyframe-grid .frame-card:last-child {
  justify-self: end;
}

.frame-card {
  display: grid;
  place-items: center;
}

.frame-card.has-media .frame-add {
  display: none;
}

.frame-thumb {
  position: absolute;
  inset: 0;
}

.frame-start,
.frame-last {
  background-image: none;
}

.swap-button {
  display: grid;
  place-items: center;
  justify-self: center;
  width: 44px;
  height: 44px;
  background: transparent;
  color: #fff;
}

.swap-button svg {
  width: 25px;
  height: 25px;
}

.frame-meta {
  color: var(--muted-2);
  font-size: 12px;
}

.prompt-card {
  position: relative;
  min-height: 310px;
  margin-top: 5px;
}

body.studio-active .prompt-card {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  overflow: hidden;
}

.prompt-input {
  display: block;
  width: 100%;
  min-height: 310px;
  padding: 0 40px 0 17px;
  border: 0;
  outline: 0;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: #858585;
  caret-color: var(--accent);
  font-size: 17px;
  line-height: 1.12;
  letter-spacing: 0;
}

body.studio-active .prompt-input {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

body.studio-active .prompt-input::-webkit-scrollbar {
  display: none;
}

.prompt-input::placeholder {
  color: #858585;
  opacity: 1;
}

.expand-prompt-button {
  position: absolute;
  top: 4px;
  right: 13px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  background: transparent;
  color: #cfcfcf;
}

.expand-prompt-button svg {
  width: 20px;
  height: 20px;
}

.prompt-card.is-expanded .prompt-input {
  min-height: calc(100dvh - 245px);
}

body.studio-active .prompt-card.is-expanded .prompt-input {
  min-height: 0;
}

.studio-view.prompt-focus .app-header,
.studio-view.prompt-focus .model-block,
.studio-view.prompt-focus .mode-block,
.studio-view.prompt-focus .media-panel {
  display: none;
}

.studio-view.prompt-focus .prompt-card {
  margin-top: 0;
  padding-top: 8px;
}

.studio-view.prompt-focus .prompt-input {
  padding: 8px 40px 0 17px;
}

.studio-view.prompt-focus .expand-prompt-button {
  top: 8px;
  right: 13px;
  z-index: 50;
}

.generation-dock {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-height) + 17px + var(--safe-bottom));
  z-index: 30;
  width: min(calc(100vw - 30px), 400px);
  transform: translateX(-50%);
  padding-top: 76px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0), #000 42px, #000 100%);
  pointer-events: none;
}

.generation-dock > * {
  pointer-events: auto;
}

.settings-block {
  position: relative;
}

.settings-row {
  position: absolute;
  left: var(--settings-menu-left);
  bottom: 50px;
  display: none;
  width: 96px;
  align-items: end;
}

.settings-block.expanded .settings-row {
  display: block;
}

.settings-cell {
  display: none;
  overflow: hidden;
  border-radius: 18px;
  background: var(--surface);
}

.settings-cell.active {
  display: block;
}

.chip-options {
  display: grid;
  max-height: min(440px, calc(var(--app-height) - 285px));
  overflow-y: auto;
  padding: 6px 0;
  scrollbar-width: none;
}

.chip-options .option-button,
.chip-options .segment-button {
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 400;
}

.chip-options .option-button.active,
.chip-options .segment-button.active {
  color: var(--accent);
}

.settings-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) max-content 30px;
  align-items: center;
  gap: 4px;
}

body.image-generation .settings-summary {
  grid-template-columns: 76px 76px 1fr max-content 30px;
}

body.image-generation #selectedDurationChip,
body.image-generation #selectedSoundChip,
body.image-generation #durationSettingsCell,
body.image-generation #soundSettingsCell {
  display: none;
}

.setting-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 42px;
  padding-inline: 8px;
  border-radius: var(--pill);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prompt-counter {
  min-width: max-content;
  justify-self: end;
  color: var(--muted-2);
  font-size: 13px;
  text-align: right;
  white-space: nowrap;
}

.clear-prompt-button {
  display: grid;
  place-items: center;
  justify-self: end;
  width: 30px;
  height: 36px;
  background: transparent;
  color: #777;
}

.clear-prompt-button svg {
  width: 24px;
  height: 24px;
}

.primary-button,
.download-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  margin-top: 24px;
  border-radius: 25px;
  background: var(--accent);
  color: #050505;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
}

.primary-button:disabled,
.download-button.disabled {
  background: var(--surface);
  color: #565656;
  pointer-events: none;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: var(--safe-bottom);
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: min(calc(100vw - 30px), 400px);
  min-height: var(--nav-height);
  transform: translateX(-50%);
  background: #000;
}

body.studio-active .bottom-nav,
body.result-active .bottom-nav,
body.balance-active .bottom-nav {
  background: #000;
}

.nav-button {
  display: grid;
  grid-template-rows: 25px 18px;
  align-content: center;
  justify-items: center;
  gap: 2px;
  min-width: 0;
  padding: 7px 2px 5px;
  background: transparent;
  color: #e9e9e9;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
}

.nav-button svg {
  width: 24px;
  height: 24px;
}

.nav-button.active {
  color: var(--accent);
}

.result-header,
.balance-title-row,
.cost-row,
.payment-check,
.method-card {
  display: flex;
  align-items: center;
}

.result-header,
.balance-title-row {
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
  margin-bottom: 10px;
}

.result-header h2 {
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
}

.balance-title-row h2 {
  color: var(--text);
  font-size: 28px;
  font-weight: 700;
}

.round-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font-size: 30px;
  line-height: 1;
}

.result-header .round-button,
.result-info-button {
  width: 40px;
  height: 40px;
  border: 0;
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
}

.result-header .round-button {
  font-size: 24px;
}

.result-info-button {
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 700;
  line-height: 1;
}

.result-info-button.active {
  color: var(--accent);
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface);
}

.glass-card,
.result-details div,
.method-card,
.payment-check input,
.amount-input {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: var(--pill);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}

.status-badge.status-progress {
  color: var(--accent);
}

.status-badge.status-ready {
  color: #9cffb4;
}

.status-badge.status-error {
  color: var(--danger);
}

.video-frame {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  max-height: none;
  flex: 1 1 auto;
  overflow: hidden;
  border-radius: 8px;
  background: #050505;
}

.video-frame video,
.result-image,
.video-placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.video-frame video {
  object-fit: contain;
  background: #050505;
}

.result-image {
  object-fit: contain;
  background: #050505;
}

.video-placeholder {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 28px;
  background: #080808;
  color: var(--muted);
}

.result-view.no-result .video-placeholder {
  background: #000;
}

.play-button,
.empty-result-icon,
.generation-failed {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  font-size: 26px;
}

.video-time {
  position: absolute;
  z-index: 2;
  bottom: 12px;
  padding: 6px 10px;
  border-radius: var(--pill);
  background: rgba(0, 0, 0, .72);
  color: var(--text);
  font-size: 12px;
}

.video-time {
  left: 12px;
}

.video-fullscreen-button {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .72);
  color: var(--text);
}

.video-fullscreen-button svg {
  width: 20px;
  height: 20px;
}

.result-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  flex: 0 0 auto;
  margin: 10px 0;
}

.result-info-panel {
  position: absolute;
  top: 78px;
  left: 15px;
  right: 15px;
  z-index: 25;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  overflow: hidden;
  margin: 0;
  border-radius: 8px;
  background: rgba(18, 18, 18, .96);
  box-shadow: 0 22px 46px rgba(0, 0, 0, .54);
}

.result-info-panel.hidden {
  display: none;
}

.result-details div {
  min-height: 58px;
  padding: 10px 12px;
  border-radius: 16px;
}

.result-info-panel div {
  display: grid;
  grid-template-columns: minmax(90px, .45fr) minmax(0, 1fr);
  align-items: center;
  min-height: 46px;
  padding: 0 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.result-info-panel div + div {
  border-top: 1px solid rgba(255, 255, 255, .06);
}

.result-details span,
.cost-row span,
.method-card small,
.topup-card label,
#minTopupText,
.balance-hero span,
.balance-hero p {
  color: var(--muted);
}

.result-details strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 17px;
}

.result-info-panel strong {
  margin-top: 0;
  overflow: hidden;
  color: #777;
  font-size: 11px;
  font-weight: 400;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-info-panel span {
  font-size: 11px;
}

.wide-detail {
  grid-column: span 2;
}

.result-info-panel .wide-detail {
  grid-column: auto;
}

.download-button {
  flex: 0 0 auto;
  margin-top: 8px;
}

.result-action-bar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.result-action-chip,
.result-upscale-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--pill);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.result-action-chip {
  color: var(--muted);
}

.result-upscale-button {
  overflow: hidden;
  padding: 0 14px;
  text-overflow: ellipsis;
}

.result-upscale-button:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent);
  color: #050505;
}

.result-upscale-button:disabled,
.download-button.disabled {
  opacity: 0.48;
  pointer-events: none;
}

.upscale-notice {
  flex: 0 0 auto;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  text-align: center;
}

.balance-hero {
  flex: 0 0 auto;
  min-height: 82px;
  padding: 12px 15px;
  border-radius: 18px;
}

.balance-hero strong {
  display: block;
  margin: 5px 0 4px;
  color: var(--text);
  font-size: 31px;
  line-height: 1;
}

.cost-row {
  gap: 14px;
  flex: 0 0 auto;
  min-height: 62px;
  margin: 10px 0;
  padding: 10px 14px;
  border-radius: 20px;
}

body.balance-active .cost-row {
  display: none;
}

.bolt,
.method-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  color: #050505;
  font-size: 18px;
}

.cost-row strong {
  display: block;
  color: var(--text);
  font-size: 21px;
}

.topup-card {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  padding: 12px;
  border-radius: 18px;
}

.topup-card h3 {
  margin-bottom: 6px;
  font-size: 20px;
}

.topup-card label {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
}

.amount-input {
  width: 100%;
  min-height: 42px;
  padding: 8px 13px;
  border-radius: 14px;
  outline: 0;
  font-size: 20px;
}

#minTopupText {
  margin: 5px 0 8px;
  font-size: 12px;
}

.payment-methods {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 8px;
}

.payment-methods.single-method {
  grid-template-columns: 1fr;
}

.method-card {
  gap: 8px;
  width: 100%;
  min-height: 56px;
  padding: 8px;
  border-radius: 15px;
  text-align: left;
}

.method-card.active {
  border-color: var(--accent);
}

.method-card strong,
.method-card small {
  display: block;
}

.method-card strong {
  font-size: 13px;
  line-height: 1.15;
}

.method-card small {
  display: none;
}

.payment-warning {
  margin: 0 0 8px;
  padding: 7px 9px;
  border: 1px solid #3b3218;
  border-radius: 13px;
  background: #111006;
  color: #d8c47a;
  font-size: 11px;
  line-height: 1.22;
}

.payment-check {
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.topup-card .primary-button {
  margin-top: auto;
  min-height: 48px;
}

.payment-check input {
  min-width: 0;
  flex: 1 0 100%;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 14px;
  outline: 0;
}

.payment-check button {
  flex: 1 1 0;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--surface);
  color: var(--accent);
}

.generation-loader {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 10px);
  gap: 7px;
}

.generation-loader span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: generationDots 1.15s ease-in-out infinite;
}

.generation-loader span:nth-child(2) {
  animation-delay: .14s;
}

.generation-loader span:nth-child(3) {
  animation-delay: .28s;
}

.generation-copy,
.empty-result-copy {
  max-width: 300px;
  text-align: center;
}

.generation-copy strong,
.empty-result-copy strong {
  display: block;
  color: var(--text);
  font-size: 17px;
}

.generation-copy small,
.empty-result-copy small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.video-placeholder.is-generating {
  gap: 18px;
}

.video-placeholder.is-failed .generation-failed {
  color: var(--danger);
}

.result-view.no-result .video-time,
.video-frame.has-image .video-time {
  display: none;
}

.result-view.no-result .download-button {
  display: none;
}

.result-view.no-result .result-action-bar,
.result-view.no-result .upscale-notice,
.result-view.no-result .result-info-button {
  display: none;
}

.video-frame.has-video {
  position: relative !important;
  width: var(--video-frame-width, 100%) !important;
  height: var(--video-frame-height, auto) !important;
  min-height: auto !important;
  max-height: none !important;
  display: block !important;
  margin-left: auto !important;
  margin-right: auto !important;
  overflow: hidden !important;
  background: #050505 !important;
}

.video-frame.has-video video {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: contain !important;
}

.video-frame.has-video.is-portrait-video {
  border-radius: 8px !important;
}

.video-frame.has-video.is-landscape-video {
  border-radius: 8px !important;
}

.video-frame.has-video.is-square-video {
  border-radius: 8px !important;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(158px + env(safe-area-inset-bottom));
  z-index: 60;
  width: min(360px, calc(100vw - 32px));
  transform: translateX(-50%);
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(24, 24, 24, .96);
  color: var(--text);
}

@keyframes generationDots {
  0%, 80%, 100% {
    opacity: .35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-8px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .generation-loader span {
    animation: none;
  }
}

@media (max-width: 385px) {
  .app-shell {
    padding-inline: 14px;
  }

  .brand {
    font-size: 24px;
  }

  .balance-label {
    font-size: 15px;
  }

  .balance-pill {
    min-width: 108px;
    padding-left: 13px;
  }

  .reference-status-row {
    gap: 10px;
    padding-inline: 8px;
  }

  .reference-preview-card,
  .reference-add-card,
  .reference-empty-card,
  .frame-card {
    width: 128px;
  }

  .settings-summary {
    grid-template-columns: repeat(4, minmax(0, 1fr)) max-content 28px;
    gap: 3px;
  }

  body.image-generation .settings-summary {
    grid-template-columns: 72px 72px 1fr max-content 28px;
  }

  .setting-chip {
    height: 40px;
    padding-inline: 6px;
    font-size: 13px;
  }

  .prompt-counter {
    font-size: 12px;
  }

  .settings-row {
    width: 90px;
  }

  .nav-button {
    font-size: 12px;
  }
}

@media (max-width: 430px) and (max-height: 700px) {
  body.studio-active {
    --studio-bottom-space: 164px;
  }

  body.studio-active .app-header {
    margin-bottom: 12px;
  }

  body.studio-active .control-block {
    margin-bottom: 8px;
  }

  body.studio-active .mode-block {
    margin-bottom: 12px;
  }

  body.studio-active .media-panel {
    margin-bottom: 10px;
  }

  body.studio-active .reference-status-row {
    min-height: 26px;
    margin-bottom: 10px;
    padding-inline: 8px;
  }

  body.studio-active .reference-preview-card,
  body.studio-active .reference-add-card,
  body.studio-active .reference-empty-card,
  body.studio-active .frame-card {
    height: 78px;
    border-radius: 16px;
  }

  body.studio-active .prompt-card {
    margin-top: 0;
    min-height: 46px;
  }

  body.studio-active .generation-dock {
    bottom: calc(var(--nav-height) + 12px + var(--safe-bottom));
    padding-top: 60px;
  }

  body.studio-active .generation-dock .primary-button {
    min-height: 50px;
    margin-top: 18px;
  }
}

@media (max-height: 700px) {
  body.balance-active .balance-title-row {
    display: none;
  }

  body.balance-active .balance-hero {
    min-height: 64px;
    padding: 9px 12px;
  }

  body.balance-active .balance-hero strong {
    margin: 2px 0 0;
    font-size: 27px;
  }

  body.balance-active .balance-hero p {
    display: none;
  }

  body.balance-active .topup-card h3 {
    display: none;
  }

}
