/* Black full-bleed Studio chrome ported from the Zerkalo mock. */
html,
body,
.app,
.viewport,
.topbar,
.startup,
.entry,
.entry--status {
  background: #000 !important;
  color: #fff;
  --paper: #000;
  --paper-raised: #111;
  --paper-soft: #111;
}

.app[data-active-view="studio"] .viewport,
.app[data-active-view="entry"] .viewport,
.app[data-active-view="gallery"] .viewport {
  position: relative;
  padding: 0;
  overflow: hidden;
}

.app[data-active-view="studio"] .native-action,
.app[data-active-view="entry"] .native-action,
.app[data-active-view="studio"] .wordmark,
.app[data-active-view="entry"] .wordmark,
.app[data-active-view="studio"] .balance-button,
.app[data-active-view="entry"] .balance-button,
.app[data-active-view="studio"] .topbar__gallery,
.app[data-active-view="entry"] .topbar__gallery {
  display: none !important;
}

.app[data-active-view="studio"] .tabbar,
.app[data-active-view="entry"] .tabbar,
.editor-tools {
  display: none !important;
}

.topbar {
  display: none !important;
}

.app[data-active-view="gallery"] .topbar {
  display: none !important;
}

.app[data-active-view="profile"] .topbar {
  display: none !important;
}

.app[data-active-view="profile"] .viewport {
  padding: 0;
  overflow: auto;
}

.subview--profile {
  min-height: var(--layout-height);
  padding: calc(var(--safe-top) + 12px) 16px calc(var(--safe-bottom) + 24px);
}

.startup {
  background: #000;
  color: #f4f1e8;
}

.startup__signal,
.startup__status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.startup .empty-hero {
  padding-bottom: calc(80px + var(--safe-bottom));
}

.studio {
  position: absolute;
  inset: 0;
  background: #000;
}

.studio .canvas {
  position: absolute;
  inset: 0;
  background: #111;
  touch-action: none;
  user-select: none;
}

.studio .canvas.is-pan {
  touch-action: none;
  overflow: hidden;
}

.studio .canvas.is-pan .canvas__image {
  max-width: none;
  will-change: transform;
  transform-origin: center center;
  pointer-events: none;
  transition: none;
}

.studio .canvas::after {
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.28), transparent 18%);
}

.studio .canvas__image {
  object-fit: contain;
  transition: filter 360ms ease, opacity 260ms ease;
}

.studio .canvas.is-generating .canvas__image {
  filter: brightness(0.55) saturate(0.8);
}

.studio .canvas.is-generating .empty-hero {
  display: none;
}

.empty-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #000;
}

.empty-hero {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 16px 80px;
  border: 0;
  background: transparent;
  color: #f4f1e8;
  text-align: center;
}

.empty-hero__add {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 104px;
  height: 104px;
  padding: 0;
  border: 0;
  border-radius: 52px;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
}

.empty-hero p {
  margin: 0;
  font-size: 17px;
  line-height: 1;
}

.sr-create {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.empty-hero svg {
  display: block;
  width: 44px;
  height: 44px;
  fill: currentColor;
  stroke: none;
}

.empty-hero svg path {
  fill: currentColor;
  stroke: none;
}

.entry--status {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: var(--layout-height);
  padding: 28px 22px calc(40px + var(--safe-bottom));
  background: #000;
  color: #fff;
}

.entry--status .entry__copy,
.entry--status .entry__eyebrow,
.entry--status .entry__intro,
.entry--status h1 {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.gear {
  position: absolute;
  top: calc(var(--safe-top) + 6px);
  right: 16px;
  left: auto;
  z-index: 8;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: transparent;
  color: #fff;
  mix-blend-mode: normal;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

.gear[data-ink="dark"] {
  color: #111;
  filter: drop-shadow(0 1px 2px rgba(255, 255, 255, 0.45));
}

.gear svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  stroke: none;
}

.app[data-active-sheet="review"] .version-path,
.app[data-generation-status="queued"] .version-path,
.app[data-generation-status="running"] .version-path,
.app[data-generation-status="slow"] .version-path,
.app[data-generation-status="queued"] .chain,
.app[data-generation-status="running"] .chain,
.app[data-generation-status="slow"] .chain {
  visibility: hidden;
}

html[data-keyboard="true"] .gear,
.app[data-active-sheet="review"] .gear,
.app[data-active-sheet="model"] .gear,
.app[data-active-sheet="parameters"] .gear,
.app[data-active-sheet="topup"] .gear,
.app[data-editor-mode="result"] .gear,
.app[data-generation-status="queued"] .gear,
.app[data-generation-status="running"] .gear,
.app[data-generation-status="slow"] .gear {
  visibility: hidden;
  pointer-events: none;
}

.studio .version-path {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.chain {
  position: absolute;
  top: calc(var(--safe-top) + 6px);
  right: 64px;
  left: 16px;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 4px 2px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  pointer-events: auto;
  scrollbar-width: none;
}

.chain::-webkit-scrollbar {
  display: none;
}

.chain:empty {
  display: none;
}

.chain__item {
  position: relative;
  box-sizing: border-box;
  flex: none;
  width: 36px;
  height: 48px;
  padding: 0;
  overflow: visible;
  border: 2px solid transparent;
  border-radius: 12px;
  background: #1a1a1a;
}

/* The visible thumbnail stays narrow; its hit area includes half the gap. */
.chain__item::before {
  content: "";
  position: absolute;
  inset: 0 -6px;
}

.chain__item[aria-busy="true"]::after {
  content: "";
  position: absolute;
  inset: 12px 6px;
  border: 2px solid #fff;
  border-right-color: transparent;
  border-radius: 50%;
  animation: chain-loading 700ms linear infinite;
}

@keyframes chain-loading {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .chain__item[aria-busy="true"]::after { animation: none; }
}

.chain__item.on {
  border-color: #fff;
  box-shadow: none;
}

.chain__item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
}

.studio .references {
  top: calc(var(--safe-top) + 56px);
}

.studio-panel {
  position: absolute;
  right: 16px;
  bottom: calc(var(--safe-bottom) + var(--kb, 0px));
  left: 16px;
  z-index: 8;
  display: grid;
  grid-template-rows: auto;
  gap: 8px;
  width: auto;
  max-width: none;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-top: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.prompt-caption {
  margin: 0 8px 2px;
  overflow: hidden;
  color: rgba(244, 241, 232, 0.7);
  font-size: 13px;
  line-height: 1.3;
  max-height: 2.6em;
}

html[data-keyboard="true"] .prompt-caption,
.app[data-active-sheet="review"] .prompt-caption,
.app[data-generation-status="queued"] .prompt-caption,
.app[data-generation-status="running"] .prompt-caption,
.app[data-generation-status="slow"] .prompt-caption {
  display: none;
}

html[data-keyboard="true"] .app,
html[data-keyboard="true"] .viewport,
html[data-keyboard="true"] .studio {
  min-height: var(--frame-stable-height, var(--layout-height));
  height: var(--frame-stable-height, 100%);
}

html[data-keyboard="true"] .studio,
.app[data-keyboard="true"] .studio {
  display: block;
  position: absolute;
  inset: 0;
  overflow: hidden;
}

html[data-keyboard="true"] .canvas,
html[data-keyboard="true"] .studio .canvas,
.app[data-keyboard="true"] .studio .canvas {
  position: absolute;
  inset: 0;
  height: auto;
  min-height: 0;
}

html[data-keyboard="true"] .studio-panel,
.app[data-keyboard="true"] .studio-panel {
  max-height: none;
  overflow: visible;
  padding-bottom: 0;
}

.app[data-editor-mode="result"] .composer,
.app[data-generation-status="queued"] .composer,
.app[data-generation-status="running"] .composer,
.app[data-generation-status="slow"] .composer,
.app[data-active-sheet="review"] .composer,
.app[data-active-sheet="topup"] .composer {
  visibility: hidden;
  pointer-events: none;
}

.result-dock {
  display: none;
  grid-template-columns: 44px 1fr;
  gap: 8px;
}

.app[data-editor-mode="result"] .result-dock {
  display: grid;
}

.app[data-generation-status="queued"] .result-dock,
.app[data-generation-status="running"] .result-dock,
.app[data-generation-status="slow"] .result-dock {
  display: none;
}

.result-dock button {
  height: 44px;
  border: 0;
  border-radius: 22px;
}

.result-dock__share {
  display: grid;
  place-items: center;
  padding: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.result-dock__share svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.result-dock__edit {
  background: #fff;
  color: #000;
  font-size: 16px;
}

.canvas-status {
  background: transparent;
  place-content: end stretch;
  justify-items: stretch;
  padding: 0 28px calc(14px + var(--safe-bottom));
  gap: 10px;
}

.canvas-status__art {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.wait-eta {
  font-size: 64px;
  font-weight: 650;
  letter-spacing: -0.06em;
  line-height: 1;
  color: #f4f1e8;
}

.wait-bar {
  width: 100%;
  height: 3px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.16);
}

.wait-bar i {
  display: block;
  width: calc(var(--generation-progress, 0.02) * 100%);
  height: 100%;
  background: #f2ff42;
}

.canvas-status strong,
.canvas-status small {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.studio .state-note {
  bottom: calc(12px + var(--safe-bottom) + 60px);
  background: rgba(10, 10, 10, 0.86);
  border-color: transparent;
  color: #fff;
}

.app[data-active-view="studio"] .sheet-layer {
  background: rgba(0, 0, 0, 0.35);
}

.app[data-active-view="studio"] .sheet {
  color: #fff;
  background: rgba(16, 16, 16, 0.94);
  box-shadow: 0 -24px 60px rgba(0, 0, 0, 0.48);
}

.app[data-active-sheet="review"] .sheet-layer,
.app[data-active-sheet="parameters"] .sheet-layer,
.app[data-active-sheet="model"] .sheet-layer {
  background: transparent;
  backdrop-filter: none;
}

.app[data-active-sheet="review"] .sheet {
  margin: 0 12px calc(8px + var(--safe-bottom));
  padding: 12px;
  max-height: none;
  border-radius: 18px;
  background: rgba(10, 10, 10, 0.86);
  backdrop-filter: blur(18px);
}

.app[data-active-sheet="review"] .review-summary,
.app[data-active-sheet="review"] .review-balance,
.app[data-active-sheet="review"] .review-media-block {
  display: none;
}

.app[data-active-sheet="review"] .review-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 8px;
  min-height: 44px;
}

.app[data-active-sheet="review"] .review-head h2 {
  margin: 0;
  color: #f4f1e8;
  font-size: 15px;
  font-weight: 600;
}

.app[data-active-sheet="review"] .review-gear {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: transparent;
  color: #fff;
}

.app[data-active-sheet="review"] .review-gear svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.app[data-active-sheet="review"] .review-prompt {
  margin: 0 0 8px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  font-size: 18px;
  line-height: 1.35;
  color: #fff;
  -webkit-line-clamp: unset;
}

.app[data-active-sheet="review"] .task-meta {
  margin: 0 0 12px;
  color: #f4f1e8;
  font-size: 15px;
}

.app[data-active-sheet="review"] .go-row {
  display: flex;
  gap: 8px;
}

.app[data-active-sheet="review"] .go-row .review-cta {
  flex: 1;
}

.app[data-active-sheet="review"] .sheet__handle,
.app[data-active-sheet="review"] .sheet__close {
  display: none;
}

.app[data-active-sheet="review"] .sheet__header h2 {
  font-size: 15px;
  font-weight: 600;
}

.app[data-active-view="studio"] .choice-row,
.app[data-active-view="studio"] .review-summary__button,
.app[data-active-view="studio"] .segmented {
  background: rgba(255, 255, 255, 0.08);
  border-color: transparent;
  color: #fff;
}

.app[data-active-sheet="review"] .review-prompt {
  background: none;
  box-shadow: none;
}

.app[data-active-view="studio"] .choice-row.is-selected,
.app[data-active-view="studio"] .segmented button.is-selected {
  background: #fff;
  color: #000;
}

.app[data-active-sheet="review"] .review-cta {
  height: 44px;
  min-height: 44px;
  border-radius: 22px;
  background: #fff;
  color: #000;
}

.subview {
  background: #000;
  color: #fff;
}

.subview .profile-row,
.subview .boost-reward {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.subview .boost-reward p,
.subview .boost-reward__link {
  color: #f4f1e8;
}

.gallery-card {
  background: #161616;
}

html[data-telegram-native="true"] body,
html[data-telegram-native="true"] .app {
  background: #000;
}

.app .topbar,
.app .tabbar,
.app .native-action,
.app .toast-region,
.app .sheet-layer {
  position: absolute;
  left: 0;
  right: 0;
  width: auto;
  transform: none;
  backdrop-filter: none;
}

.app[data-active-sheet="parameters"] .sheet-layer,
.app[data-active-sheet="model"] .sheet-layer {
  align-items: end;
  background: transparent;
}

.app[data-active-sheet="parameters"] .sheet,
.app[data-active-sheet="model"] .sheet {
  margin: 0 12px calc(12px + var(--safe-bottom) + 52px);
  padding: 12px 12px 10px;
  max-height: none;
  border-radius: 16px;
  background: rgba(12, 12, 12, 0.86);
  backdrop-filter: blur(16px);
}

.app[data-active-sheet="parameters"] .sheet__handle,
.app[data-active-sheet="parameters"] .sheet__header,
.app[data-active-sheet="model"] .sheet__handle,
.app[data-active-sheet="model"] .sheet__header,
.app[data-active-sheet="parameters"] .settings-done {
  display: none;
}

.app[data-active-sheet="parameters"] h4,
.app[data-active-sheet="model"] h4 {
  margin: 0 0 8px;
  color: #f4f1e8;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: lowercase;
}

.app[data-active-sheet="parameters"] h4:not(:first-of-type),
.app[data-active-sheet="model"] h4:not(:first-of-type) {
  margin-top: 12px;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font: 16px/1 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.04em;
}

.pill.on {
  background: #fff;
  color: #000;
  font-weight: 700;
}

.subview--gallery {
  position: absolute;
  inset: 0;
  overflow: hidden;
  padding: 0;
}

.subview--gallery .gallery-scroll {
  position: absolute;
  inset: 0;
  padding: calc(var(--safe-top) + 8px) 2px calc(68px + var(--safe-bottom));
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.subview--gallery .gallery-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 258px;
  gap: 1px;
  background: #000;
}

.subview--gallery .gallery-card {
  height: 100%;
  aspect-ratio: auto;
  background: #161616;
}

.subview--gallery .gallery-card--new {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #161616;
  color: #f4f1e8;
}

.subview--gallery .gallery-card--new svg {
  width: 36px;
  height: 36px;
  fill: currentColor;
  stroke: none;
}

.subview--gallery .composer {
  position: absolute;
  right: 16px;
  bottom: calc(var(--safe-bottom) + var(--kb, 0px));
  left: 16px;
  z-index: 8;
  width: auto;
}

.gallery-loading {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.78);
  color: #f4f1e8;
  pointer-events: none;
}

.gallery-loading p {
  margin: 0;
  font-size: 16px;
}

.gallery-loading__pulse {
  width: 36px;
  height: 36px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: #fff;
  border-radius: 50%;
  animation: gallery-spin 0.8s linear infinite;
}

@keyframes gallery-spin {
  to { transform: rotate(360deg); }
}

.pill[disabled] {
  opacity: 0.35;
}

@media (min-width: 520px) {
  html:not([data-telegram-native="true"]),
  html:not([data-telegram-native="true"]) body {
    background: #d8d3c6 !important;
  }
}
