:root {
  color-scheme: dark;
  --bg: #040406;
  --surface: #0b0d12;
  --surface-2: #11151f;
  --line: #1f2532;
  --text: #f3f5fc;
  --muted: #8f98b0;
  --accent: #19c7b5;
  --accent-2: #12b3a3;
  --accent-rgb: 25, 199, 181;
  --success: #7ce5a6;
  --warning: #ffd447;
  --danger: #ff8a96;
  --tg-safe-top: 0px;
  --tg-safe-bottom: 0px;
  --tg-controls-offset: 0px;
}

* {
  box-sizing: border-box;
}

.is-hidden {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  height: 100%;
  width: 100%;
  overflow-x: hidden;
  overflow-y: hidden;
  overscroll-behavior-y: none;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html.is-web-runtime.is-mobile-browser,
body.is-web-runtime.is-mobile-browser {
  height: auto;
  min-height: 100%;
  overflow-y: auto;
  overscroll-behavior-y: auto;
}

html.template-modal-open,
body.template-modal-open {
  overflow: hidden;
}

body.template-modal-open {
  position: fixed;
  top: var(--template-modal-lock-top, 0);
  width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  height: 100dvh;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

html.is-web-runtime.is-mobile-browser .app-shell,
body.is-web-runtime.is-mobile-browser .app-shell {
  min-height: 100svh;
  height: auto;
  display: block;
  overflow: visible;
}

.app-shell.is-hidden {
  display: none;
}

.boot-splash {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px 14px;
}

.boot-splash.is-hidden {
  display: none;
}

.boot-splash-card {
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(14, 18, 33, 0.96), rgba(9, 12, 22, 0.94));
  padding: 24px 20px;
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
}

.boot-splash-logo {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-strong);
  box-shadow: 0 0 28px rgba(var(--accent-rgb), 0.14);
}

.boot-splash-card strong {
  font-size: 30px;
  line-height: 1;
  letter-spacing: 0;
}

.boot-splash-card p {
  margin: 0;
  color: var(--text-soft);
}

.auth-gate {
  min-height: 100vh;
  display: grid;
  align-items: center;
  padding: 20px 14px;
}

.auth-gate.is-hidden {
  display: none;
}

.auth-gate-card {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  display: grid;
  gap: 12px;
}

.auth-brand-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.auth-brand-row strong {
  font-size: 18px;
  line-height: 1;
}

.auth-logo {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid #2f3a52;
  background: #111826;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.auth-gate-card h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.08;
}

.auth-gate-card > p {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.auth-primary {
  height: 50px;
  font-size: 18px;
}

.auth-dev {
  margin-top: 4px;
}

.auth-dev.is-hidden {
  display: none;
}

.app-header {
  min-height: calc(76px + max(var(--tg-safe-top, 0px), env(safe-area-inset-top)) + var(--tg-controls-offset, 0px));
  padding: calc(16px + max(var(--tg-safe-top, 0px), env(safe-area-inset-top)) + var(--tg-controls-offset, 0px)) 16px 14px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  background: rgba(4, 4, 6, 0.96);
  backdrop-filter: blur(8px);
  z-index: 12;
}

.avatar-chip {
  width: 44px;
  height: 44px;
  border: 1px solid #2a3241;
  border-radius: 999px;
  background: #121722;
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.brand-title {
  text-align: center;
  font-size: 20px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0;
}

.credits-chip {
  border: 1px solid rgba(var(--accent-rgb), 0.72);
  background: rgba(var(--accent-rgb), 0.2);
  color: #ecfffc;
  border-radius: 999px;
  min-width: 72px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  font-weight: 700;
  cursor: pointer;
}

.credits-chip svg,
.icon-btn svg,
.nav-btn svg,
.soft-btn svg,
.bot-link svg,
.dropzone-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.app-main {
  padding: 14px 14px calc(118px + max(env(safe-area-inset-bottom), var(--tg-safe-bottom, 0px)));
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

html.is-web-runtime.is-mobile-browser .app-main,
body.is-web-runtime.is-mobile-browser .app-main {
  padding-bottom: calc(190px + max(env(safe-area-inset-bottom), var(--tg-safe-bottom, 0px)));
  min-height: auto;
  overflow: visible;
  overscroll-behavior-y: auto;
  -webkit-overflow-scrolling: auto;
}

.screen {
  display: none;
  gap: 12px;
}

.screen-active {
  display: grid;
}

.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-row h2,
.section-row h3 {
  margin: 0;
  font-size: 34px;
  line-height: 1.12;
  letter-spacing: 0;
}

.section-row-tight h3 {
  font-size: 22px;
}

.section-row-tight span {
  font-size: 13px;
  color: var(--muted);
}

.template-search {
  min-height: 48px;
  border: 1px solid #263146;
  border-radius: 12px;
  background: rgba(16, 22, 33, 0.82);
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 10px;
  padding: 0 10px 0 14px;
  color: #8f99af;
  transition:
    border-color 0.18s ease,
    box-shadow 0.2s ease,
    background-color 0.18s ease;
}

.template-search:focus-within,
.template-search.is-active {
  border-color: rgba(var(--accent-rgb), 0.64);
  background: rgba(14, 25, 33, 0.9);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.08);
}

.template-search > svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.2px;
}

.template-search input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: #f3f7ff;
  font: inherit;
  font-size: 16px;
  line-height: 1.2;
}

.template-search input::placeholder {
  color: #768196;
}

.template-search input::-webkit-search-decoration,
.template-search input::-webkit-search-cancel-button {
  display: none;
}

.template-search-clear {
  width: 36px;
  height: 36px;
  border: 1px solid #2b354a;
  border-radius: 999px;
  background: rgba(14, 20, 31, 0.86);
  color: #d9e1f2;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition:
    border-color 0.16s ease,
    color 0.16s ease,
    transform 0.16s ease;
}

.template-search-clear.is-hidden {
  visibility: hidden;
  pointer-events: none;
}

.template-search-clear svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2px;
}

.template-search-clear:active {
  transform: scale(0.94);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid #2a3241;
  border-radius: 999px;
  background: #101621;
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: start;
}

.tools-grid-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.tools-grid > .tool-card {
  grid-column: 1 / -1;
}

.template-feed-stage,
.template-showcase,
.template-collection {
  min-width: 0;
}

.template-showcase {
  display: grid;
  gap: 22px;
}

.template-showcase-section {
  display: grid;
  gap: 10px;
  min-width: 0;
  content-visibility: auto;
  contain-intrinsic-size: auto 310px;
}

.template-section-header,
.template-collection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.template-section-title {
  min-width: 0;
  display: flex;
  align-items: center;
}

.template-section-title h3,
.template-collection-title h3 {
  margin: 0;
  min-width: 0;
  color: #f4f7ff;
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: 0;
}

.template-section-title small,
.template-collection-title small {
  color: #9fa8bc;
  font-size: 15px;
  font-weight: 700;
}

.template-section-open,
.template-back-btn {
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition:
    color 0.16s ease,
    background-color 0.16s ease,
    transform 0.16s ease;
}

.template-section-open {
  padding: 0 4px 0 10px;
  flex: 0 0 auto;
}

.template-section-open svg,
.template-back-btn svg {
  width: 17px;
  height: 17px;
  stroke-width: 2.5px;
}

.template-section-open:active,
.template-back-btn:active {
  transform: scale(0.97);
}

.template-section-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(180px, 24%);
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  align-items: start;
  overscroll-behavior-inline: contain;
  scroll-snap-type: x proximity;
  padding: 0 2px 8px 0;
  min-width: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(94, 233, 214, 0.28) rgba(14, 18, 28, 0.8);
}

.template-section-row::-webkit-scrollbar {
  height: 8px;
}

.template-section-row::-webkit-scrollbar-track {
  background: rgba(14, 18, 28, 0.72);
  border-radius: 999px;
}

.template-section-row::-webkit-scrollbar-thumb {
  background: rgba(94, 233, 214, 0.28);
  border-radius: 999px;
}

.template-rail-card {
  scroll-snap-align: start;
}

.template-rail-card .tool-overlay {
  padding: 22px 10px 9px;
  background: linear-gradient(to top, rgba(4, 4, 6, 0.88), rgba(4, 4, 6, 0.36) 62%, rgba(4, 4, 6, 0));
}

.template-rail-card .tool-overlay strong {
  display: block;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-rail-card .tool-overlay p,
.template-rail-card .template-card-stats {
  display: none;
}

.template-collection-header {
  grid-column: 1 / -1;
  padding: 2px 0 4px;
}

.template-collection-title {
  min-width: 0;
  display: grid;
  gap: 3px;
  text-align: right;
}

.template-collection-title > span {
  color: #8fe5d9;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.template-back-btn {
  padding: 0 12px 0 10px;
  border: 1px solid #2a3346;
  background: #111722;
  color: #dce6f8;
}

.template-empty-state {
  display: grid;
  gap: 6px;
  padding: 24px;
  border: 1px dashed #31405b;
  border-radius: 8px;
  background: rgba(15, 21, 32, 0.76);
  color: #dfe7f8;
}

.template-empty-state strong {
  font-size: 18px;
}

.template-empty-state p {
  margin: 0;
  color: #9fa8bc;
}

.template-search-results {
  align-items: start;
}

.template-collection.template-search-results {
  display: grid;
  gap: 10px;
}

.template-search-results-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 2px 0 4px;
}

.template-search-results-title {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.template-search-results-title > span {
  color: #8fe5d9;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.template-search-results-title h3 {
  margin: 0;
  color: #f4f7ff;
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: 0;
}

.template-search-results-title small {
  color: #9fa8bc;
  font-size: 15px;
  font-weight: 700;
}

.template-search-reset {
  min-height: 36px;
  border: 1px solid #2a3346;
  border-radius: 999px;
  background: #111722;
  color: #dce6f8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px 0 10px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.template-search-reset svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.4px;
}

@media (hover: hover) and (pointer: fine) {
  .template-section-open:hover,
  .template-back-btn:hover,
  .template-search-reset:hover {
    color: #6ef2de;
    background: rgba(var(--accent-rgb), 0.1);
  }

  .template-search-clear:hover {
    border-color: rgba(var(--accent-rgb), 0.5);
    color: #b8fff3;
  }
}

.tool-card {
  --template-ratio: 1;
  position: relative;
  isolation: isolate;
  width: 100%;
  display: block;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #253043;
  background: #11161f;
  cursor: pointer;
  transform: translate3d(0, 0, 0) scale(1);
  backface-visibility: hidden;
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.22s ease, box-shadow 0.28s ease;
}

.tool-card-top-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  display: flex;
  justify-content: flex-end;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
}

.tool-media {
  position: relative;
  z-index: 1;
  width: 100%;
  aspect-ratio: var(--template-ratio);
  background: #0f1521;
  overflow: hidden;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
}

.tool-card .tool-media-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: translate3d(0, 0, 0) scale(1.001);
  backface-visibility: hidden;
  transition: transform 0.44s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (hover: hover) {
  .tool-card:hover {
    transform: translate3d(0, -2px, 0) scale(1.006);
    border-color: #32425f;
    box-shadow: 0 14px 34px rgba(2, 5, 12, 0.42);
  }

  .tool-card:hover .tool-media-image {
    transform: translate3d(0, 0, 0) scale(1.03);
  }

  .reference-dropzone:hover {
    transform: translateY(-1px);
    border-color: #45567e;
    box-shadow: 0 12px 28px rgba(3, 7, 16, 0.24);
  }

  .reference-inline-btn:hover {
    color: #b3fff1;
  }
}

.tool-card:active {
  transform: scale(0.992);
}

.reference-dropzone:focus-visible,
.reference-inline-btn:focus-visible,
.reference-primary-btn:focus-visible {
  outline: 2px solid rgba(126, 229, 216, 0.72);
  outline-offset: 2px;
}

.tool-overlay {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 2;
  padding: 10px;
  background: linear-gradient(to top, rgba(4, 4, 6, 0.86), rgba(4, 4, 6, 0));
  display: grid;
  gap: 4px;
  pointer-events: none;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
}

.template-card-stats {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: 2px;
}

.template-like-btn,
.template-usage-stat {
  min-height: 30px;
  border-radius: 999px;
  border: 1px solid rgba(40, 49, 68, 0.86);
  background: rgba(8, 11, 18, 0.66);
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #e8edf8;
}

.template-like-btn {
  cursor: pointer;
}

.template-like-btn:hover:not(:disabled) {
  border-color: rgba(255, 111, 145, 0.38);
  background: rgba(255, 111, 145, 0.12);
}

.template-like-btn:disabled {
  opacity: 0.72;
  cursor: default;
}

.template-like-btn svg,
.template-usage-stat svg {
  width: 14px;
  height: 14px;
  stroke-width: 2px;
}

.template-like-btn svg {
  color: #ff6f91;
}

.template-like-btn.is-liked {
  border-color: rgba(255, 111, 145, 0.44);
  background: rgba(255, 111, 145, 0.14);
}

.template-like-btn.is-liked svg {
  fill: currentColor;
}

.template-usage-stat {
  color: #d7ddf2;
}

.template-usage-stat svg {
  color: #ffd447;
}

.tool-like-btn {
  padding: 0 9px;
}

.tool-overlay strong {
  font-size: 16px;
  line-height: 1.2;
}

.tool-overlay p {
  margin: 0;
  color: #d6dbee;
  font-size: 12px;
}

.tool-card-skeleton {
  pointer-events: none;
}

.tool-card-skeleton .tool-media {
  position: relative;
  background: #151c2a;
}

.tool-card-skeleton .tool-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(21, 28, 42, 0.3), rgba(77, 89, 118, 0.35), rgba(21, 28, 42, 0.3));
  animation: skeleton-shimmer 1.3s infinite linear;
}

.skeleton-line {
  display: block;
  border-radius: 6px;
  background: rgba(226, 233, 250, 0.18);
}

.skeleton-line-title {
  width: 66%;
  height: 18px;
}

.skeleton-line-subtitle {
  width: 42%;
  height: 12px;
}

@keyframes skeleton-shimmer {
  from {
    transform: translateX(-35%);
  }
  to {
    transform: translateX(35%);
  }
}

.segmented {
  border: 1px solid #242b3c;
  border-radius: 8px;
  background: #0b1019;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 4px;
  gap: 4px;
}

.segmented-btn {
  height: 36px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: #b0b7cc;
  font-weight: 600;
  cursor: pointer;
}

.segmented-btn.is-active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}

.studio-scene-block,
.studio-source-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at 12% 0%, rgba(47, 68, 112, 0.22), transparent 34%),
    var(--surface);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.studio-scene-head,
.studio-source-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.studio-scene-title,
.studio-source-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.studio-scene-title span {
  color: #8fe5d9;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.studio-scene-title strong,
.studio-source-copy strong {
  color: #f4f7ff;
  font-size: 18px;
  line-height: 1.18;
}

.studio-source-copy span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.studio-scene-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.studio-scene-block.has-template .studio-scene-actions,
.studio-scene-block.has-reference-open .studio-scene-actions {
  display: none;
}

.studio-scene-option {
  min-height: 82px;
  border: 1px solid #2c3650;
  border-radius: 8px;
  background: rgba(12, 18, 30, 0.82);
  color: #eef3ff;
  padding: 12px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  text-align: left;
  cursor: pointer;
  transition:
    border-color 0.18s ease,
    background-color 0.18s ease,
    transform 0.16s ease,
    box-shadow 0.18s ease;
}

.studio-scene-option:hover {
  border-color: #465576;
  background: rgba(17, 25, 41, 0.92);
}

.studio-scene-option:active {
  transform: scale(0.985);
}

.studio-scene-option.is-active {
  border-color: rgba(126, 229, 216, 0.58);
  box-shadow: 0 0 0 1px rgba(126, 229, 216, 0.08);
}

.studio-scene-option-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid #34405b;
  background: #131a29;
  display: grid;
  place-items: center;
  color: #cbd5ee;
}

.studio-scene-option-icon svg {
  width: 19px;
  height: 19px;
}

.studio-scene-option strong,
.studio-scene-option small {
  display: block;
  min-width: 0;
}

.studio-scene-option strong {
  font-size: 15px;
  line-height: 1.2;
}

.studio-scene-option small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.selected-template {
  border: 1px solid #2a3347;
  border-radius: 8px;
  background: #0f1521;
  padding: 10px;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.selected-template.is-hidden {
  display: none;
}

.selected-template-preview {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  border: 1px solid #2c3550;
  display: block;
  overflow: hidden;
  background: #0b1019;
}

.selected-template-preview-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.selected-template-preview video {
  pointer-events: none;
}

.template-modal-media-slot {
  width: 100%;
  background: #080d14;
}

.template-modal-media-slot.is-loading {
  opacity: 0.78;
}

.selected-template-body {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.selected-template-body strong {
  font-size: 16px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.selected-template-body span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

.template-clear-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid #2f3a52;
  background: #141b28;
  color: #d7deef;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.template-clear-btn:hover {
  border-color: #49536b;
}

.template-clear-btn svg {
  width: 16px;
  height: 16px;
}

.upload-dropzone {
  border: 1px dashed #333f58;
  border-radius: 8px;
  background: #0a0f18;
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  text-align: left;
  color: #cfd5ea;
  cursor: pointer;
  padding: 10px 12px;
  position: relative;
  overflow: hidden;
}

.reference-prompt-card {
  display: grid;
  gap: 14px;
  padding: 12px;
  border-radius: 8px;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, rgba(10, 16, 26, 0.98), rgba(9, 13, 22, 0.98)) padding-box,
    linear-gradient(120deg, rgba(126, 229, 216, 0.7), rgba(88, 122, 255, 0.56), rgba(178, 110, 255, 0.48), rgba(126, 229, 216, 0.7)) border-box;
  background-size: 100% 100%, 240% 240%;
  box-shadow: 0 14px 34px rgba(5, 10, 20, 0.24);
  transition:
    box-shadow 0.22s ease,
    background-position 0.22s ease,
    background-size 0.22s ease;
}

.reference-prompt-card.is-collapsed {
  display: none;
}

.reference-prompt-card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 220px;
  height: 160px;
  border-radius: 999px;
  background: radial-gradient(circle at 20% 20%, rgba(138, 155, 234, 0.1) 0%, rgba(138, 155, 234, 0) 72%);
  pointer-events: none;
  opacity: 0.55;
  transition: opacity 0.22s ease;
}

.reference-prompt-card::after {
  content: "";
  position: absolute;
  inset: auto 32px 16px auto;
  width: 180px;
  height: 120px;
  border-radius: 999px;
  background: radial-gradient(circle at 50% 50%, rgba(112, 128, 215, 0.08) 0%, rgba(112, 128, 215, 0) 76%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s ease;
}

.reference-prompt-card.is-busy {
  animation: none;
  background-size: 100% 100%, 100% 100%;
  box-shadow:
    0 18px 44px rgba(5, 10, 20, 0.28),
    0 0 0 1px rgba(118, 133, 195, 0.1);
}

.reference-prompt-card.is-busy::before {
  opacity: 0.2;
}

.reference-prompt-card.is-busy::after {
  opacity: 0.12;
  animation: none;
}

.reference-prompt-card.is-locked {
  gap: 10px;
  background:
    linear-gradient(180deg, rgba(10, 16, 26, 0.98), rgba(9, 13, 22, 0.98)) padding-box,
    linear-gradient(120deg, rgba(112, 139, 193, 0.48), rgba(70, 84, 120, 0.42), rgba(112, 139, 193, 0.48)) border-box;
}

.reference-prompt-busy-panel {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 20px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  border: 0 solid rgba(66, 77, 118, 0.76);
  border-radius: 18px;
  background:
    radial-gradient(circle at top center, rgba(31, 45, 79, 0.18), rgba(31, 45, 79, 0) 44%),
    linear-gradient(180deg, rgba(14, 19, 32, 0.98), rgba(11, 16, 28, 0.99));
  padding: 0 20px;
  transform: translateY(-8px) scale(0.985);
  transition:
    max-height 0.28s ease,
    opacity 0.22s ease,
    transform 0.22s ease,
    padding 0.22s ease,
    border-width 0.22s ease;
}

.reference-prompt-card.is-busy .reference-prompt-busy-panel {
  max-height: 300px;
  opacity: 1;
  pointer-events: none;
  padding: 20px;
  border-width: 1px;
  transform: translateY(0) scale(1);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.015),
    0 16px 28px rgba(5, 9, 18, 0.22);
}

.reference-prompt-busy-head {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  justify-self: start;
  color: #eef2ff;
}

.reference-prompt-busy-head strong {
  font-size: 22px;
  line-height: 1.08;
}

.reference-prompt-busy-icon {
  display: grid;
  place-items: center;
  color: #dbe2ff;
}

.reference-prompt-busy-icon svg {
  width: 18px;
  height: 18px;
}

.reference-prompt-busy-body {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.92fr);
  gap: 18px;
  align-items: stretch;
  min-height: 164px;
}

.reference-prompt-busy-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 14px;
  align-content: start;
}

.reference-prompt-busy-step {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(56, 67, 101, 0.76);
  background: rgba(15, 21, 35, 0.78);
  color: #7a86aa;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transition:
    background-color 420ms cubic-bezier(0.23, 1, 0.32, 1),
    color 420ms cubic-bezier(0.23, 1, 0.32, 1),
    box-shadow 420ms cubic-bezier(0.23, 1, 0.32, 1),
    transform 420ms cubic-bezier(0.23, 1, 0.32, 1),
    opacity 420ms cubic-bezier(0.23, 1, 0.32, 1);
}

.reference-prompt-busy-step::after {
  content: "";
  position: absolute;
  inset: -8px -10px;
  border-radius: inherit;
  background: radial-gradient(circle, rgba(132, 148, 235, 0.18), rgba(132, 148, 235, 0));
  opacity: 0;
  filter: blur(8px);
  transition: opacity 420ms cubic-bezier(0.23, 1, 0.32, 1);
  pointer-events: none;
}

.reference-prompt-busy-step.is-active {
  color: #eef3ff;
  border-color: rgba(67, 79, 115, 0.76);
  background: linear-gradient(180deg, rgba(27, 36, 59, 0.98), rgba(17, 24, 42, 0.98));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 8px 18px rgba(17, 25, 47, 0.32),
    0 0 22px rgba(79, 98, 182, 0.12);
  transform: translateY(-0.5px) scale(1.01);
}

.reference-prompt-busy-step.is-active::after {
  opacity: 0.88;
}

.reference-prompt-busy-caption {
  display: grid;
  gap: 6px;
  min-height: 164px;
  margin: 0;
  padding: 18px 20px;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(19, 26, 43, 0.96), rgba(14, 20, 35, 0.98)),
    radial-gradient(circle at top left, rgba(76, 94, 171, 0.08), rgba(76, 94, 171, 0) 52%);
  align-content: center;
  justify-self: stretch;
  text-align: left;
  color: #b7c1db;
  font-size: 15px;
  line-height: 1.55;
  transition:
    opacity 420ms cubic-bezier(0.23, 1, 0.32, 1),
    transform 420ms cubic-bezier(0.23, 1, 0.32, 1),
    color 420ms cubic-bezier(0.23, 1, 0.32, 1);
}

.reference-prompt-busy-caption.is-changing {
  opacity: 0.3;
  transform: translateY(6px);
}

.reference-prompt-busy-caption strong {
  color: #edf2ff;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.45;
}

.reference-prompt-busy-caption span {
  color: inherit;
}

.reference-prompt-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.reference-prompt-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.reference-prompt-copy {
  display: grid;
  gap: 4px;
  position: relative;
  z-index: 1;
}

.reference-prompt-copy strong {
  font-size: 16px;
  line-height: 1.2;
}

.reference-prompt-copy span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.reference-prompt-badge {
  flex: 0 0 auto;
  border: 1px solid rgba(84, 107, 152, 0.72);
  border-radius: 999px;
  background: rgba(14, 22, 35, 0.78);
  color: #dbe7ff;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 10px;
  position: relative;
  z-index: 1;
}

.reference-collapse-btn {
  width: 34px;
  height: 34px;
  min-height: 34px;
}

.reference-collapse-btn svg {
  width: 17px;
  height: 17px;
}

.reference-dropzone {
  position: relative;
  z-index: 1;
  min-height: 96px;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border: 1px solid #2d3750;
  border-radius: 10px;
  background: rgba(10, 15, 25, 0.9);
  padding: 12px;
  overflow: hidden;
  transition:
    border-color 0.18s ease,
    background-color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

.reference-dropzone-hitbox {
  position: absolute;
  inset: 0;
  z-index: 1;
  cursor: pointer;
}

.reference-dropzone.has-image {
  border-color: #3e4c70;
  background: rgba(12, 18, 29, 0.82);
}

.reference-dropzone.is-locked {
  border-style: dashed;
  border-color: rgba(72, 89, 126, 0.88);
  background: rgba(10, 15, 25, 0.64);
}

.reference-prompt-card.is-locked .reference-dropzone {
  min-height: 78px;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
}

.reference-prompt-card.is-locked .reference-preview-frame {
  width: 56px;
  height: 56px;
  border-radius: 12px;
}

.reference-prompt-card.is-locked .reference-preview-empty .dropzone-icon {
  width: 34px;
  height: 34px;
}

.reference-prompt-card.is-locked .reference-dropzone-copy {
  gap: 2px;
}

.reference-prompt-card.is-locked .reference-dropzone-copy strong {
  font-size: 14px;
}

.reference-prompt-card.is-locked .reference-dropzone-copy span {
  font-size: 12px;
}

.reference-prompt-card.is-locked .reference-dropzone-meta,
.reference-prompt-card.is-locked .reference-prompt-actions,
.reference-prompt-card.is-locked .reference-prompt-note {
  display: none;
}

.reference-prompt-card.is-busy .reference-dropzone {
  position: relative;
  z-index: 1;
  border-color: rgba(111, 128, 197, 0.56);
  background: rgba(9, 13, 23, 0.96);
  box-shadow:
    inset 0 0 0 1px rgba(132, 148, 235, 0.12),
    0 10px 24px rgba(12, 18, 34, 0.28);
}

.reference-prompt-card.is-busy .reference-prompt-actions {
  display: none;
}

.reference-prompt-actions,
.reference-prompt-note {
  position: relative;
  z-index: 1;
}

.reference-preview-frame,
.reference-dropzone-copy,
.reference-dropzone-meta,
.reference-dropzone-file-meta {
  position: relative;
  z-index: 2;
  pointer-events: none;
}

.reference-preview-frame {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  border: 1px solid #2d3750;
  background: linear-gradient(180deg, rgba(15, 22, 35, 0.96), rgba(10, 15, 24, 0.96));
  display: grid;
  place-items: center;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.reference-preview-empty {
  display: grid;
  place-items: center;
}

.reference-preview-empty .dropzone-icon {
  width: 42px;
  height: 42px;
}

.reference-preview-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.reference-dropzone-copy {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.reference-dropzone-copy strong {
  font-size: 15px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reference-dropzone-copy span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.reference-dropzone-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.reference-dropzone-file-meta {
  border: 1px solid rgba(58, 70, 100, 0.88);
  border-radius: 999px;
  background: rgba(15, 21, 34, 0.9);
  color: #dce5ff;
  padding: 4px 8px;
}

.dropzone-empty {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}

.dropzone-empty-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.upload-dropzone.has-image {
  width: fit-content;
  max-width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
  cursor: default;
}

.upload-dropzone.has-image .dropzone-empty {
  display: none;
}

.upload-dropzone.has-image .dropzone-clear-btn,
.upload-dropzone.has-image .dropzone-preview-badge {
  display: none;
}

.dropzone-icon {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid #2f3a50;
  display: grid;
  place-items: center;
  background: #141b28;
}

.dropzone-title {
  display: block;
  font-size: 15px;
  font-weight: 600;
}

.dropzone-subtitle {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.dropzone-preview-grid {
  width: 100%;
  max-width: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  margin-inline: 0;
  box-sizing: border-box;
}

.upload-dropzone.has-image .dropzone-preview-grid {
  width: fit-content;
  max-width: 100%;
  padding: 0;
}

.reference-preview-grid {
  max-width: 320px;
}

.reference-preview-grid .dropzone-preview-thumb {
  --thumb-size: min(280px, 100%);
  width: min(280px, 100%);
  flex: 0 1 min(280px, 100%);
}

.dropzone-preview-thumb {
  --thumb-size: 92px;
  width: var(--thumb-size);
  flex: 0 0 var(--thumb-size);
  margin: 0;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  border: 1px solid #28344a;
  background: #0b111b;
  overflow: hidden;
  position: relative;
}

.upload-dropzone.has-image .dropzone-preview-thumb {
  border-radius: 10px;
  border-color: #34415c;
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.2),
    inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.dropzone-preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.reference-preview-grid .dropzone-preview-thumb img {
  aspect-ratio: 4 / 5;
}

.dropzone-thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid rgba(55, 67, 93, 0.9);
  background: rgba(8, 11, 18, 0.88);
  color: #e7ecfa;
  display: grid;
  place-items: center;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.dropzone-preview-badge {
  position: absolute;
  right: 46px;
  bottom: 50%;
  transform: translateY(50%);
  border: 1px solid rgba(49, 56, 74, 0.9);
  border-radius: 999px;
  background: rgba(8, 11, 18, 0.82);
  color: #e8ecfb;
  font-size: 12px;
  padding: 4px 10px;
  pointer-events: none;
}

.studio-source-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.studio-source-add {
  height: 36px;
}

.dropzone-clear-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid #3b465f;
  background: rgba(12, 16, 25, 0.92);
  color: #eaf0ff;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 3;
}

.dropzone-clear-btn:hover {
  border-color: #58637a;
}

.dropzone-clear-btn svg {
  width: 16px;
  height: 16px;
}

.reference-prompt-actions {
  display: grid;
  gap: 8px;
  position: relative;
  z-index: 1;
}

.reference-primary-btn {
  width: 100%;
  justify-content: center;
}

.reference-inline-btn {
  justify-self: start;
  border: 0;
  background: none;
  color: #8fe5d9;
  font-size: 13px;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
  min-height: 20px;
}

.reference-inline-btn:hover {
  color: #b3fff1;
}

.reference-prompt-note {
  position: relative;
  z-index: 1;
  min-height: 18px;
}

.visually-hidden-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.panel-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.panel-card textarea {
  width: 100%;
  border: 1px solid #2b3345;
  border-radius: 8px;
  background: #090e17;
  color: var(--text);
  padding: 12px;
  font-size: 16px;
  line-height: 1.4;
  resize: vertical;
  min-height: 134px;
}

.prompt-card {
  background:
    radial-gradient(circle at 10% 0%, rgba(47, 68, 112, 0.2), transparent 34%),
    var(--surface);
}

.prompt-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.prompt-card-title {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.prompt-card-title strong {
  color: #f4f7ff;
  font-size: 18px;
  line-height: 1.18;
}

.prompt-source-status {
  min-height: 17px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
}

.prompt-source-status.is-template,
.prompt-source-status.is-reference,
.prompt-source-status.is-history {
  color: #8fe5d9;
}

.prompt-source-status.is-edited {
  color: #ffd88a;
}

.prompt-clear-btn {
  min-width: 44px;
  min-height: 36px;
  border: 1px solid #30394d;
  border-radius: 8px;
  background: rgba(16, 23, 36, 0.88);
  color: #dbe3f7;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition:
    border-color 0.16s ease,
    background-color 0.16s ease,
    color 0.16s ease,
    transform 0.16s ease;
}

.prompt-clear-btn:hover {
  border-color: #465576;
  background: rgba(20, 29, 45, 0.95);
  color: #f2f5ff;
}

.prompt-clear-btn:active {
  transform: scale(0.97);
}

.prompt-clear-btn svg {
  width: 16px;
  height: 16px;
}

.prompt-card textarea {
  min-height: 170px;
  max-height: min(44vh, 380px);
  padding: 14px;
  background: #080d16;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background-color 0.16s ease;
}

.prompt-card textarea:focus {
  outline: none;
  border-color: rgba(var(--accent-rgb), 0.62);
  background: #0a101a;
  box-shadow:
    0 0 0 1px rgba(var(--accent-rgb), 0.1),
    0 0 24px rgba(var(--accent-rgb), 0.08);
}

.prompt-card-footer {
  min-height: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.prompt-card-footer .storage-note {
  min-width: 0;
  margin-top: 1px;
}

.prompt-counter {
  flex: 0 0 auto;
  min-height: 20px;
  border: 1px solid #2c354b;
  border-radius: 999px;
  background: rgba(11, 17, 27, 0.78);
  color: #9ca6bd;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 750;
  line-height: 1.25;
  display: none;
  align-items: center;
}

.prompt-counter.is-visible {
  display: inline-flex;
}

.prompt-counter.is-warning {
  border-color: rgba(255, 212, 71, 0.38);
  color: #ffd88a;
}

.prompt-counter.is-danger {
  border-color: rgba(255, 138, 150, 0.48);
  color: #ff9da7;
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.help-icon-btn {
  width: 36px;
  height: 36px;
  min-height: 36px;
}

.tips-panel {
  margin-top: 4px;
  border: 1px solid #2a3347;
  border-radius: 8px;
  background: #0b121d;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.tips-panel strong {
  font-size: 14px;
}

.tips-panel ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  display: grid;
  gap: 4px;
}

.muted-inline {
  font-size: 13px;
  color: var(--muted);
}

.soft-btn {
  height: 42px;
  border-radius: 8px;
  border: 1px solid #2e3648;
  background: #111825;
  color: #ecf0ff;
  padding: 0 14px;
  font-weight: 600;
  cursor: pointer;
}

.soft-btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.file-trigger-label {
  text-decoration: none;
  user-select: none;
}

.settings-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at 12% 0%, rgba(47, 68, 112, 0.18), transparent 34%),
    var(--surface);
  overflow: hidden;
}

.settings-panel > summary {
  list-style: none;
  min-height: 72px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  font-weight: 600;
}

.settings-summary-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.settings-summary-copy > span {
  color: #f4f7ff;
  font-size: 18px;
  line-height: 1.18;
}

.settings-summary-copy > strong {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-panel > summary svg {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  color: #aab4cc;
  transition: transform 0.18s ease;
}

.settings-panel > summary::-webkit-details-marker {
  display: none;
}

.settings-panel[open] > summary svg {
  transform: rotate(180deg);
}

.settings-body {
  padding: 0 12px 12px;
  display: grid;
  gap: 12px;
}

.chip-field {
  display: grid;
  gap: 7px;
}

.chip-field-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choice-chip {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid #2b3449;
  background: rgba(15, 21, 34, 0.9);
  color: #a5afc6;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.choice-chip-label {
  white-space: nowrap;
}

.choice-chip:hover:not(:disabled) {
  border-color: #465576;
  color: #d6dcef;
}

.choice-chip[aria-checked="true"] {
  border-color: rgba(var(--accent-rgb), 0.68);
  background: rgba(var(--accent-rgb), 0.18);
  color: #eafffb;
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.08);
}

.choice-chip[aria-checked="true"]:hover:not(:disabled) {
  border-color: rgba(var(--accent-rgb), 0.78);
  background: rgba(var(--accent-rgb), 0.22);
  color: #eafffb;
}

.choice-chip:disabled {
  cursor: default;
  opacity: 0.52;
}

.choice-chip .chip-lock {
  margin-left: 2px;
  color: #8b95ad;
  font-size: 11px;
}

.choice-chip-ratio {
  padding: 0 12px;
}

.ratio-chip-preview {
  width: 28px;
  height: 18px;
  border-radius: 6px;
  border: 1px solid #35415c;
  background: #0d1220;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.ratio-chip-preview-frame {
  height: 10px;
  aspect-ratio: var(--ratio-width) / var(--ratio-height);
  border-radius: 3px;
  border: 1.5px solid #94a3c8;
  background: rgba(148, 163, 200, 0.12);
}

.choice-chip[aria-checked="true"] .ratio-chip-preview {
  border-color: rgba(23, 27, 36, 0.6);
  background: rgba(255, 255, 255, 0.34);
}

.choice-chip[aria-checked="true"] .ratio-chip-preview-frame {
  border-color: #1f2331;
  background: rgba(21, 24, 33, 0.16);
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
}

.field input,
.field select {
  width: 100%;
  height: 42px;
  border: 1px solid #2b3345;
  border-radius: 8px;
  background: #0a101b;
  color: var(--text);
  padding: 0 12px;
  font-size: 15px;
}

.field textarea {
  width: 100%;
  min-height: 104px;
  border: 1px solid #2b3345;
  border-radius: 8px;
  background: #0a101b;
  color: var(--text);
  padding: 12px;
  font-size: 15px;
  resize: vertical;
}

.primary-action {
  width: 100%;
  height: 54px;
  border: 1px solid #1cb9a8;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
}

.primary-action:disabled {
  cursor: wait;
  opacity: 0.82;
}

.primary-action.is-loading {
  background:
    linear-gradient(135deg, rgba(35, 202, 183, 0.92), rgba(20, 166, 150, 0.92)),
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.22), transparent);
  box-shadow: 0 0 28px rgba(var(--accent-rgb), 0.18);
}

#createButton {
  width: min(92%, 460px);
  justify-self: center;
}

.note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.history-retention-note {
  margin-top: -2px;
}

.storage-note {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.storage-note a {
  color: #7ee5d8;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.template-modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.78);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: calc(18px + max(var(--tg-safe-top, 0px), env(safe-area-inset-top)) + var(--tg-controls-offset, 0px)) 14px 14px;
  z-index: 50;
  overscroll-behavior: contain;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.26s cubic-bezier(0.22, 1, 0.36, 1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.template-modal.is-hidden {
  display: none;
}

.template-modal.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.template-modal-card {
  width: min(560px, 100%);
  max-height: min(92vh, 840px);
  border-radius: 8px;
  border: 1px solid #2c3650;
  background: #0c111b;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  position: relative;
  box-shadow: 0 28px 64px rgba(2, 7, 16, 0.52);
  transform: translateY(16px) scale(0.98);
  opacity: 0.92;
  transition:
    transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.24s ease;
}

.template-modal-media {
  position: relative;
  background: #080d14;
}

.template-modal.is-visible .template-modal-card {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.template-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  border: 1px solid rgba(57, 71, 102, 0.72);
  background: rgba(11, 20, 34, 0.62);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  color: #f2f5ff;
  font-size: 34px;
  font-weight: 300;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0 0 1px;
  z-index: 3;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease;
}

.template-modal-close:hover {
  background: rgba(17, 28, 46, 0.74);
  border-color: rgba(88, 105, 142, 0.78);
}

.template-modal-close:active {
  background: rgba(14, 24, 40, 0.85);
}

.template-modal-image {
  width: 100%;
  max-height: 52vh;
  object-fit: contain;
  display: block;
  background: #080d14;
  transition: opacity 0.2s ease;
}

.template-modal-image.is-loading {
  opacity: 0.78;
}

.template-modal-body {
  padding: 12px;
  display: grid;
  gap: 8px;
  grid-template-rows: auto auto auto auto;
  overflow: auto;
  overscroll-behavior: contain;
  min-height: 0;
}

.template-modal-prompt-section {
  display: grid;
  gap: 8px;
}

.template-modal-body strong {
  font-size: 18px;
  line-height: 1.2;
}

.template-modal-body span {
  color: var(--muted);
  font-size: 13px;
}

.template-modal-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.template-modal-stats-overlay {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  justify-content: flex-end;
}

.template-modal-like-btn,
.template-modal-usage-stat {
  min-height: 34px;
  font-size: 13px;
}

.template-modal-prompt-scroll {
  border: 1px solid #273149;
  border-radius: 8px;
  background: #090e16;
  min-height: 0;
  padding: 10px;
  overflow: hidden;
  position: relative;
  --template-prompt-collapsed-height: 168px;
  --template-prompt-expanded-height: min(30vh, 280px);
  max-height: var(--template-prompt-expanded-height);
  transition: max-height 0.26s cubic-bezier(0.23, 1, 0.32, 1);
}

.template-modal-prompt-scroll.is-collapsed {
  max-height: var(--template-prompt-collapsed-height);
}

.template-modal-prompt-scroll.is-expanded {
  overflow: auto;
  overscroll-behavior: contain;
}

.template-modal-prompt-scroll.is-loading {
  min-height: var(--template-prompt-collapsed-height);
}

.template-modal-prompt-scroll.is-collapsed::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 54px;
  background: linear-gradient(180deg, rgba(9, 14, 22, 0) 0%, rgba(9, 14, 22, 0.98) 88%);
  pointer-events: none;
}

.template-modal-prompt {
  margin: 0;
  color: #d8dff3;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.template-prompt-toggle {
  min-height: 34px;
  border: 1px solid #273149;
  border-radius: 999px;
  background: #101724;
  color: #dce3f6;
  justify-self: start;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease;
}

.template-prompt-toggle:hover {
  background: #131c2c;
  border-color: #32415f;
}

.template-prompt-toggle::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
  transform-origin: center;
  transition: transform 0.22s cubic-bezier(0.23, 1, 0.32, 1);
}

.template-prompt-toggle[aria-expanded="true"]::after {
  transform: rotate(-135deg) translateY(-1px);
}

.template-modal-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.template-use-btn {
  height: 46px;
  font-size: 16px;
}

.template-modal-note {
  min-height: 18px;
}

.result-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at 16% 0%, rgba(47, 68, 112, 0.18), transparent 34%),
    var(--surface);
  padding: 12px;
  display: grid;
  gap: 12px;
  scroll-margin-top: calc(84px + max(var(--tg-safe-top, 0px), env(safe-area-inset-top)) + var(--tg-controls-offset, 0px));
}

.active-result {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border: 1px solid #242c3d;
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 0%, rgba(33, 48, 82, 0.2), transparent 42%),
    #0a101a;
  min-height: 220px;
  display: grid;
  place-items: center;
  color: var(--muted);
  overflow: hidden;
}

.active-result-state {
  width: min(100%, 420px);
  padding: 24px 18px;
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
}

.active-result-icon {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  border: 1px solid #33405b;
  background: rgba(18, 25, 40, 0.9);
  color: #cfd8f2;
  display: grid;
  place-items: center;
}

.active-result-icon svg {
  width: 21px;
  height: 21px;
}

.active-result-state strong {
  color: #f2f6ff;
  font-size: 20px;
  line-height: 1.18;
}

.active-result-state span {
  color: #aab3ca;
  font-size: 14px;
  line-height: 1.45;
}

.active-result-state small {
  color: #7f8aa6;
  font-size: 12px;
  line-height: 1.35;
}

.active-result-action {
  margin-top: 4px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #edf3ff;
  transition:
    border-color 0.16s ease,
    background-color 0.16s ease,
    color 0.16s ease,
    transform 0.16s ease;
}

.active-result-action:hover {
  border-color: #465576;
  background: rgba(20, 29, 45, 0.95);
}

.active-result-action:active {
  transform: scale(0.97);
}

.active-result-action span {
  color: inherit;
  font-size: inherit;
  line-height: inherit;
}

.active-result-action svg {
  width: 16px;
  height: 16px;
}

.active-result-loading {
  border-color: rgba(78, 95, 142, 0.9);
  background:
    radial-gradient(circle at 50% 0%, rgba(44, 61, 106, 0.36), transparent 48%),
    #0a101a;
}

.active-result-loading .active-result-icon {
  color: #ddfff9;
  border-color: rgba(var(--accent-rgb), 0.42);
  box-shadow: 0 0 26px rgba(var(--accent-rgb), 0.14);
}

.active-result-error {
  border-color: rgba(149, 72, 84, 0.72);
  background:
    radial-gradient(circle at 50% 0%, rgba(126, 46, 63, 0.2), transparent 46%),
    #120d13;
}

.active-result-error .active-result-icon {
  color: #ffd8df;
  border-color: rgba(255, 143, 143, 0.44);
  background: rgba(42, 20, 28, 0.86);
}

.active-result-progress {
  width: min(100%, 320px);
  height: 4px;
  border-radius: 999px;
  background: rgba(63, 75, 112, 0.58);
  overflow: hidden;
  position: relative;
}

.active-result-progress span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 44%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.18), rgba(185, 239, 255, 0.96), rgba(var(--accent-rgb), 0.18));
  animation: active-result-progress 1.45s cubic-bezier(0.77, 0, 0.175, 1) infinite;
}

.active-result-has-image {
  grid-template-rows: minmax(0, 1fr) auto;
  place-items: stretch;
  background: #05070c;
}

.active-result-image-shell {
  min-width: 0;
  min-height: 220px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, rgba(36, 47, 76, 0.2), transparent 58%),
    #05070c;
}

.active-result img {
  width: 100%;
  max-height: min(62vh, 520px);
  object-fit: contain;
  display: block;
}

.empty-result {
  padding: 14px;
  text-align: center;
}

.first-photoset-result-offer {
  min-width: 0;
  margin: 0 10px 10px;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(var(--accent-rgb), 0.48);
  border-radius: 8px;
  background:
    radial-gradient(circle at 0% 0%, rgba(var(--accent-rgb), 0.18), transparent 48%),
    rgba(12, 21, 30, 0.96);
  box-shadow: 0 14px 34px rgba(var(--accent-rgb), 0.1);
  text-align: left;
}

.first-photoset-result-copy {
  min-width: 0;
}

.first-photoset-kicker {
  display: inline-flex;
  margin-bottom: 5px;
  color: #bff8f0;
  font-size: 11px;
  font-weight: 760;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.first-photoset-result-copy strong {
  display: block;
  color: #f4f8ff;
  font-size: 18px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.first-photoset-result-copy p {
  margin: 5px 0 0;
  color: #aeb8ce;
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.first-photoset-result-cta {
  width: auto;
  min-width: 168px;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  white-space: nowrap;
}

.image-actions {
  min-width: 0;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  border-top: 1px solid #242c3d;
  background: rgba(8, 12, 20, 0.96);
}

.image-actions-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.image-action-btn {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  font-size: 14px;
}

.image-action-btn svg {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
}

.image-action-btn span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes active-result-progress {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(260%);
  }
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  gap: 10px;
}

.history-pagination {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(13, 18, 29, 0.98), rgba(8, 12, 20, 0.98));
  padding: 7px;
  display: grid;
  gap: 9px;
  min-width: 0;
  overflow: hidden;
}

.history-empty {
  grid-column: 1 / -1;
  min-height: 120px;
  place-items: center;
  color: var(--muted);
}

.history-thumb {
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #273047;
  background:
    radial-gradient(circle at 50% 20%, rgba(var(--accent-rgb), 0.11), transparent 36%),
    #0f1522;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  text-align: center;
  position: relative;
  padding: 10px;
}

.history-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  grid-area: 1 / 1;
}

.history-thumb-open {
  position: absolute;
  inset: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  z-index: 2;
  padding: 0;
}

.history-thumb-ready {
  padding: 0;
  transition:
    border-color 0.2s ease,
    transform 0.16s cubic-bezier(0.23, 1, 0.32, 1);
}

.history-thumb-ready:active {
  transform: scale(0.985);
}

.history-open-indicator {
  position: absolute;
  right: 7px;
  bottom: 7px;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(65, 80, 116, 0.72);
  border-radius: 999px;
  background: rgba(7, 12, 21, 0.58);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #f1f5ff;
  display: grid;
  place-items: center;
  opacity: 0;
  transform: translateY(-2px) scale(0.96);
  transition:
    opacity 0.18s ease,
    transform 0.18s cubic-bezier(0.23, 1, 0.32, 1);
}

.history-open-indicator svg {
  width: 16px;
  height: 16px;
}

.history-thumb-open:hover .history-open-indicator,
.history-thumb-open:focus-visible .history-open-indicator {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.history-body {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.history-topline {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.chip {
  border: 1px solid #3a4358;
  border-radius: 999px;
  color: #d3daef;
  font-size: 11px;
  padding: 3px 8px;
}

.status-pill {
  border: 1px solid #3a4358;
  border-radius: 999px;
  color: #d3daef;
  font-size: 11px;
  padding: 3px 8px;
}

.status-done {
  border-color: rgba(84, 217, 146, 0.5);
  color: var(--success);
}

.status-failed,
.status-cancelled {
  border-color: rgba(255, 138, 150, 0.55);
  color: var(--danger);
}

.status-processing,
.status-queued {
  border-color: rgba(var(--accent-rgb), 0.58);
  color: #8eeade;
}

.history-status {
  position: absolute;
  left: 8px;
  top: 8px;
  background: rgba(9, 14, 24, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  max-width: calc(100% - 16px);
}

.history-prompt {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.plan-meta {
  color: #aab2c8;
  font-size: 11px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.history-repeat-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  min-height: 42px;
  font-size: 14px;
}

.history-repeat-btn svg {
  width: 15px;
  height: 15px;
}

.history-icon-action {
  width: 38px;
  height: 36px;
  border: 1px solid #2b3345;
  border-radius: 8px;
  background: #0d1422;
  color: #d9e0f4;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    transform 0.16s cubic-bezier(0.23, 1, 0.32, 1);
}

.history-icon-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.history-icon-action:not(:disabled):active {
  transform: scale(0.96);
}

.history-icon-action svg {
  width: 17px;
  height: 17px;
}

.history-download-overlay {
  position: absolute;
  right: 7px;
  top: 7px;
  z-index: 3;
  background: rgba(7, 12, 21, 0.62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.is-telegram-runtime [data-action="download-image"],
.is-telegram-runtime .active-result [data-action="download"] {
  display: none !important;
}

.btn-compact {
  width: 100%;
  height: 36px;
  font-size: 13px;
}

.app-shell.is-paywall-active {
  max-width: 1180px;
}

.paywall-screen {
  min-width: 0;
  margin: -14px -14px 0;
  overflow: hidden;
}

.paywall-screen.screen-active {
  display: block;
}

.paywall-gallery {
  position: relative;
  height: clamp(280px, 31vw, 390px);
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: #0b0d11;
}

.paywall-gallery::after {
  content: "";
  position: absolute;
  inset: 34% 0 0;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent, rgba(4, 4, 6, 0.18) 28%, var(--bg) 100%);
}

.paywall-gallery-track {
  position: absolute;
  top: -34px;
  left: 50%;
  display: grid;
  grid-template-columns: repeat(6, clamp(132px, 15vw, 205px));
  grid-template-rows: repeat(2, clamp(132px, 15vw, 205px));
  gap: 8px;
  width: max-content;
  transform: translateX(-50%) rotate(-2deg);
}

.paywall-gallery-image {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 5px;
  object-fit: cover;
  background: #10141b;
  opacity: 0;
  animation: paywall-image-in 480ms ease forwards;
}

.paywall-gallery-image:nth-child(2n) {
  transform: translateY(18px);
}

.paywall-gallery-image:nth-child(3n) {
  transform: translateY(-8px);
}

.paywall-gallery-image:nth-child(2) { animation-delay: 35ms; }
.paywall-gallery-image:nth-child(3) { animation-delay: 70ms; }
.paywall-gallery-image:nth-child(4) { animation-delay: 105ms; }
.paywall-gallery-image:nth-child(5) { animation-delay: 140ms; }
.paywall-gallery-image:nth-child(6) { animation-delay: 175ms; }
.paywall-gallery-image:nth-child(7) { animation-delay: 210ms; }
.paywall-gallery-image:nth-child(8) { animation-delay: 245ms; }
.paywall-gallery-image:nth-child(9) { animation-delay: 280ms; }
.paywall-gallery-image:nth-child(10) { animation-delay: 315ms; }
.paywall-gallery-image:nth-child(11) { animation-delay: 350ms; }
.paywall-gallery-image:nth-child(12) { animation-delay: 385ms; }

@keyframes paywall-image-in {
  from {
    opacity: 0;
    scale: 0.97;
  }

  to {
    opacity: 1;
    scale: 1;
  }
}

.paywall-content {
  position: relative;
  z-index: 2;
  width: min(calc(100% - 28px), 720px);
  margin: -34px auto 0;
}

.paywall-intro {
  text-align: center;
}

.paywall-eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-bottom: 12px;
  padding: 5px 10px;
  border: 1px solid rgba(var(--accent-rgb), 0.36);
  border-radius: 999px;
  background: rgba(4, 4, 6, 0.78);
  color: #bff8f0;
  font-size: 12px;
  font-weight: 700;
  backdrop-filter: blur(12px);
}

.paywall-intro h2 {
  max-width: 620px;
  margin: 0 auto;
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.03;
  font-weight: 800;
  letter-spacing: 0;
}

.paywall-intro p {
  max-width: 540px;
  margin: 12px auto 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.45;
}

.paywall-plans-heading {
  margin: 30px 0 12px;
  color: #cbd2df;
  font-size: 14px;
  font-weight: 700;
}

.plans-list {
  display: grid;
  gap: 10px;
}

.plan-card {
  position: relative;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 84px;
  padding: 15px 16px;
  border: 1px solid #283142;
  border-radius: 8px;
  background: #0d1117;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition:
    border-color 180ms ease,
    background-color 180ms ease,
    box-shadow 180ms ease;
}

.plan-card:hover {
  border-color: #3a465d;
  background: #111722;
}

.plan-card:focus-visible {
  outline: 2px solid rgba(var(--accent-rgb), 0.86);
  outline-offset: 2px;
}

.plan-card.is-selected {
  border-color: rgba(var(--accent-rgb), 0.88);
  background: rgba(var(--accent-rgb), 0.09);
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.18);
}

.plan-card.is-first-offer {
  border-color: rgba(var(--accent-rgb), 0.78);
  background:
    radial-gradient(circle at 20% 0%, rgba(var(--accent-rgb), 0.16), transparent 42%),
    #0b151c;
}

.plan-card.is-first-offer.is-selected {
  border-color: rgba(var(--accent-rgb), 0.96);
  background:
    radial-gradient(circle at 22% 0%, rgba(var(--accent-rgb), 0.24), transparent 46%),
    rgba(var(--accent-rgb), 0.1);
  box-shadow:
    0 0 0 1px rgba(var(--accent-rgb), 0.2),
    0 14px 42px rgba(var(--accent-rgb), 0.16);
}

.plan-card.is-secondary-start {
  background: #0a0f16;
}

.plan-card-unavailable {
  display: block;
  min-height: 0;
  color: var(--muted);
  cursor: default;
}

.plan-popular-badge {
  position: absolute;
  top: -10px;
  right: 12px;
  padding: 4px 9px;
  border: 1px solid rgba(var(--accent-rgb), 0.62);
  border-radius: 999px;
  background: #163d3a;
  color: #cafff8;
  font-size: 11px;
  font-weight: 750;
}

.plan-radio {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid #566178;
  border-radius: 50%;
}

.plan-radio::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  scale: 0.5;
  transition: opacity 180ms ease, scale 180ms ease;
}

.plan-card.is-selected .plan-radio {
  border-color: var(--accent);
}

.plan-card.is-selected .plan-radio::after {
  opacity: 1;
  scale: 1;
}

.plan-main {
  min-width: 0;
}

.plan-name-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.plan-name {
  font-size: 17px;
  font-weight: 760;
}

.plan-saving {
  color: var(--success);
  font-size: 12px;
  font-weight: 700;
}

.plan-bonus {
  color: #bff8f0;
}

.plan-result {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.plan-price {
  display: grid;
  justify-items: end;
  gap: 3px;
  white-space: nowrap;
}

.plan-price strong {
  font-size: 21px;
  line-height: 1;
  letter-spacing: 0;
}

.plan-price span {
  color: var(--muted);
  font-size: 12px;
}

.paywall-trust {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
  margin: 18px 0 4px;
  color: var(--muted);
  font-size: 12px;
}

.paywall-trust span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.paywall-trust span::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.paywall-checkout {
  position: fixed;
  z-index: 8;
  left: 50%;
  bottom: calc(78px + max(env(safe-area-inset-bottom), var(--tg-safe-bottom, 0px)));
  width: min(100%, 760px);
  margin-top: 18px;
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(4, 4, 6, 0.92);
  backdrop-filter: blur(18px);
  transform: translateX(-50%);
}

.paywall-checkout-inner {
  width: min(100%, 720px);
  margin: 0 auto;
}

.paywall-action {
  min-height: 54px;
  height: auto;
  padding: 10px 12px;
  border-color: #59dacc;
  background: #5fe0d0;
  color: #05211e;
  font-size: 17px;
  line-height: 1.2;
  white-space: normal;
}

.paywall-action:hover {
  background: #77eadc;
}

.paywall-action:disabled {
  border-color: #2d3848;
  background: #1a222d;
  color: #7f899c;
  cursor: default;
}

.paywall-note {
  min-height: 15px;
  margin-top: 7px;
  color: #7f899c;
  font-size: 11px;
  text-align: center;
}

.profile-card {
  grid-template-columns: 1fr;
}

.admin-access-card {
  gap: 12px;
}

.admin-marketing-panel {
  display: grid;
  gap: 12px;
}

.admin-marketing-tabs {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.admin-analytics-panel {
  display: grid;
  gap: 18px;
}

.admin-analytics-head,
.admin-analytics-section-head,
.admin-analytics-row,
.admin-analytics-attribution {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-analytics-head h3,
.admin-analytics-section h4 {
  margin: 0;
}

.admin-analytics-head .note {
  margin: 4px 0 0;
}

.admin-analytics-period {
  width: min(100%, 420px);
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.admin-analytics-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-block: 1px solid #283145;
}

.admin-analytics-kpi {
  min-width: 0;
  padding: 16px 14px;
  border-right: 1px solid #283145;
}

.admin-analytics-kpi:last-child {
  border-right: 0;
}

.admin-analytics-kpi span,
.admin-analytics-section-head span,
.admin-analytics-row span,
.admin-analytics-row small {
  color: var(--muted);
}

.admin-analytics-kpi span {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
}

.admin-analytics-kpi strong {
  display: block;
  overflow: hidden;
  font-size: 25px;
  line-height: 1.1;
  text-overflow: ellipsis;
}

.admin-analytics-kpi small {
  display: block;
  margin-top: 5px;
  color: #8f9ab0;
}

.admin-analytics-section {
  min-width: 0;
  padding-top: 16px;
  border-top: 1px solid #283145;
}

.admin-analytics-section-head {
  align-items: baseline;
  margin-bottom: 12px;
}

.admin-analytics-section-head h4 {
  font-size: 16px;
}

.admin-analytics-section-head span {
  font-size: 11px;
  text-align: right;
}

.admin-analytics-funnel {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.admin-analytics-stage {
  position: relative;
  min-width: 0;
  padding: 4px 14px 8px 0;
}

.admin-analytics-stage:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 25px;
  right: 8px;
  width: 1px;
  height: 26px;
  background: #283145;
}

.admin-analytics-stage span,
.admin-analytics-stage small {
  display: block;
  color: var(--muted);
}

.admin-analytics-stage span {
  min-height: 30px;
  font-size: 11px;
  line-height: 1.3;
}

.admin-analytics-stage strong {
  display: block;
  margin-top: 7px;
  font-size: 22px;
}

.admin-analytics-stage small {
  margin-top: 3px;
  font-size: 11px;
}

.admin-analytics-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.admin-analytics-table {
  display: grid;
}

.admin-analytics-row {
  min-height: 38px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(40, 49, 69, 0.72);
}

.admin-analytics-row:last-child {
  border-bottom: 0;
}

.admin-analytics-row-label {
  min-width: 0;
}

.admin-analytics-row-label strong,
.admin-analytics-row-label span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-analytics-row-label strong {
  font-size: 13px;
}

.admin-analytics-row-label span {
  margin-top: 2px;
  font-size: 11px;
}

.admin-analytics-row-value {
  flex: 0 0 auto;
  text-align: right;
}

.admin-analytics-row-value strong,
.admin-analytics-row-value small {
  display: block;
}

.admin-analytics-row-value strong {
  font-size: 14px;
}

.admin-analytics-row-value small {
  margin-top: 2px;
  font-size: 10px;
}

.admin-analytics-attribution {
  min-height: 44px;
  padding: 10px 12px;
  border-left: 2px solid rgba(var(--accent-rgb), 0.72);
  background: rgba(var(--accent-rgb), 0.06);
}

.admin-analytics-attribution span {
  color: var(--muted);
  font-size: 12px;
}

.admin-analytics-attribution strong {
  font-size: 15px;
}

.admin-form-card,
.admin-list-card {
  display: grid;
  gap: 14px;
}

.admin-form-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.admin-selected-summary {
  min-height: 18px;
  color: #aeb7c9;
}

.admin-selected-summary.is-warning {
  color: #ffd36b;
}

.admin-primary-action {
  font-size: 16px;
  height: 46px;
}

.admin-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.admin-checkboxes {
  display: grid;
  gap: 10px;
}

.admin-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid #283145;
  border-radius: 8px;
  background: #111827;
  color: var(--text);
}

.admin-checkbox input {
  margin: 0;
}

.admin-media-fields {
  display: grid;
  gap: 10px;
}

.admin-media-upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-media-preview {
  border: 1px solid #283145;
  border-radius: 8px;
  overflow: hidden;
  background: #0b1019;
}

.admin-media-preview img,
.admin-media-preview video {
  display: block;
  width: 100%;
  height: auto;
  max-height: 240px;
  object-fit: cover;
}

.admin-preview-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.admin-mini-stat {
  border: 1px solid #283145;
  border-radius: 8px;
  background: #0f1624;
  padding: 10px;
  display: grid;
  gap: 4px;
}

.admin-mini-stat span {
  color: var(--muted);
  font-size: 12px;
}

.admin-mini-stat strong {
  font-size: 20px;
}

.admin-list {
  display: grid;
  gap: 10px;
}

.admin-list-empty {
  border: 1px dashed #2a3347;
  border-radius: 8px;
  padding: 16px;
  color: var(--muted);
  background: rgba(17, 24, 39, 0.5);
}

@media (max-width: 700px) {
  .admin-marketing-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-analytics-panel {
    gap: 15px;
  }

  .admin-analytics-kpis,
  .admin-analytics-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-analytics-columns {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .admin-analytics-kpi:nth-child(2) {
    border-right: 0;
  }

  .admin-analytics-kpi:nth-child(-n + 2) {
    border-bottom: 1px solid #283145;
  }

  .admin-analytics-funnel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 14px;
  }

  .admin-analytics-stage {
    padding-right: 0;
  }

  .admin-analytics-stage:not(:last-child)::after {
    display: none;
  }

  .admin-analytics-stage span {
    min-height: 0;
  }

  .admin-analytics-attribution {
    align-items: flex-start;
    flex-direction: column;
  }
}

.admin-record-card {
  border: 1px solid #283145;
  border-radius: 8px;
  background: #111827;
  padding: 14px;
  display: grid;
  gap: 10px;
  cursor: pointer;
}

.admin-record-card.is-selected {
  border-color: rgba(var(--accent-rgb), 0.56);
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.18);
}

.admin-record-card-static {
  cursor: default;
}

.admin-record-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.admin-record-head strong {
  display: block;
  font-size: 16px;
}

.admin-record-head p,
.admin-record-text,
.admin-record-meta {
  margin: 0;
}

.admin-record-head p,
.admin-record-text,
.admin-record-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.admin-record-text {
  color: #e8edfe;
}

.admin-record-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.admin-template-card {
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
}

.admin-template-card-static {
  cursor: pointer;
}

.admin-template-thumb {
  width: 92px;
  aspect-ratio: 3 / 4;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #283145;
  background: #0b1019;
}

.admin-template-thumb img,
.admin-template-thumb video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.admin-template-body {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.admin-template-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-template-title-row strong {
  min-width: 0;
}

.admin-template-title-row .plan-badge,
.admin-template-title-row .plan-badge-muted {
  flex: 0 0 auto;
}

.stat {
  border: 1px solid #283145;
  border-radius: 8px;
  background: #111827;
  padding: 10px;
  display: grid;
  gap: 6px;
}

.stat span {
  font-size: 12px;
  color: var(--muted);
}

.stat strong {
  font-size: 22px;
}

.auth-actions {
  display: grid;
  gap: 10px;
}

.google-signin-wrap {
  display: flex;
  justify-content: center;
  width: 100%;
}

.google-signin-wrap.is-hidden {
  display: none;
}

.auth-btn {
  width: 100%;
}

.auth-btn.is-hidden {
  display: none;
}

#authCheckButton {
  border-color: rgba(var(--accent-rgb), 0.52);
}

.identity-grid {
  display: grid;
  gap: 8px;
}

.identity-item {
  border: 1px solid #283145;
  border-radius: 8px;
  background: #111827;
  padding: 10px;
  display: grid;
  gap: 6px;
}

.identity-item span {
  font-size: 12px;
  color: var(--muted);
}

.identity-item strong {
  font-size: 18px;
}

.identity-action {
  width: fit-content;
  min-width: 0;
}

.identity-note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.3;
}

.bot-link {
  height: 46px;
  border: 1px solid #2f3648;
  border-radius: 8px;
  background: #101724;
  color: #e8edfe;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
}

#logoutButton {
  width: 100%;
}

.bottom-nav {
  background: rgba(7, 9, 14, 0.96);
  backdrop-filter: blur(10px);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 6px 8px max(10px, env(safe-area-inset-bottom), var(--tg-safe-bottom, 0px));
  gap: 4px;
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(760px, 100%);
  z-index: 14;
  overflow: hidden;
  opacity: 1;
  transition:
    transform 0.28s ease,
    opacity 0.2s ease;
}

.bottom-nav::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 100vw;
  transform: translateX(-50%);
  border-top: 1px solid var(--line);
  pointer-events: none;
}

.nav-btn {
  min-height: 62px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #8f97ad;
  display: grid;
  place-items: center;
  gap: 5px;
  padding: 6px 4px;
  cursor: pointer;
}

.nav-btn span {
  font-size: 12px;
  line-height: 1;
}

.nav-btn.is-active {
  color: #fff;
  border-color: #2b3142;
  background: #121a29;
}

.nav-btn-center {
  min-height: 0;
  border-color: #31374b;
  border-radius: 999px;
  width: 64px;
  height: 64px;
  margin: 0 auto;
  padding: 0;
  gap: 0;
  background: #121a29;
  box-shadow: inset 0 1px 0 rgba(171, 188, 255, 0.16), 0 10px 24px rgba(3, 7, 18, 0.38);
}

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

.nav-btn-center.is-active {
  background: #1a2438;
  border-color: #4f5f83;
}

.nav-btn-center span {
  display: none;
}

html.is-web-runtime.is-mobile-browser.nav-hidden .bottom-nav,
body.is-web-runtime.is-mobile-browser.nav-hidden .bottom-nav {
  transform: translate(-50%, calc(100% + 20px));
  opacity: 0;
  pointer-events: none;
}

@media (min-width: 860px) {
  .plans-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .paywall-checkout {
    position: static;
    width: auto;
    margin-top: 18px;
    padding: 0 14px 40px;
    border-top: 0;
    background: none;
    backdrop-filter: none;
    transform: none;
  }
}

@media (max-width: 520px) {
  .paywall-gallery {
    height: 270px;
  }

  .paywall-gallery-track {
    top: -10px;
    grid-template-columns: repeat(6, 126px);
    grid-template-rows: repeat(2, 126px);
    gap: 6px;
  }

  .paywall-content {
    width: min(calc(100% - 24px), 720px);
    margin-top: -22px;
  }

  .paywall-intro h2 {
    max-width: 330px;
    font-size: 27px;
  }

  .paywall-intro p {
    max-width: 280px;
    font-size: 14px;
    overflow-wrap: anywhere;
  }

  .paywall-plans-heading {
    margin-top: 25px;
  }

  .plan-card {
    grid-template-columns: 22px minmax(0, 1fr) auto;
    gap: 10px;
    min-height: 78px;
    padding: 13px 12px;
  }

  .plan-name {
    font-size: 16px;
  }

  .plan-result {
    font-size: 12px;
  }

  .plan-price strong {
    font-size: 19px;
  }

  .paywall-action {
    font-size: 15px;
  }

  .first-photoset-result-offer {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .first-photoset-result-cta {
    width: 100%;
    min-width: 0;
  }

  .paywall-trust {
    flex-direction: column;
    align-items: center;
  }

  .studio-scene-block,
  .studio-source-panel {
    padding: 10px;
  }

  .studio-scene-head,
  .studio-source-head {
    align-items: stretch;
    gap: 10px;
  }

  .studio-source-head {
    flex-direction: column;
  }

  .studio-scene-title strong,
  .studio-source-copy strong {
    font-size: 17px;
  }

  .studio-scene-actions {
    grid-template-columns: 1fr;
  }

  .studio-scene-option {
    min-height: 72px;
    padding: 10px;
  }

  .studio-source-actions {
    justify-content: space-between;
  }

  .studio-source-add {
    flex: 1 1 auto;
    justify-content: center;
  }

  .upload-dropzone {
    min-height: 78px;
  }

  .upload-dropzone.has-image {
    min-height: 0;
  }

  .dropzone-preview-grid {
    gap: 7px;
  }

  .dropzone-preview-thumb {
    --thumb-size: 86px;
  }

  .dropzone-preview-badge {
    display: none;
  }

  .reference-dropzone {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
  }

  .reference-preview-frame {
    width: 64px;
    height: 64px;
  }

  .reference-dropzone-copy strong {
    font-size: 14px;
  }

  .reference-dropzone-copy span,
  .reference-dropzone-meta {
    font-size: 12px;
  }

  .reference-prompt-card.is-locked .reference-dropzone {
    grid-template-columns: 52px minmax(0, 1fr);
    padding: 10px;
  }

  .reference-prompt-card.is-locked .reference-preview-frame {
    width: 52px;
    height: 52px;
  }

  .reference-prompt-busy-panel {
    gap: 16px;
  }

  .reference-prompt-card.is-busy .reference-prompt-busy-panel {
    max-height: 380px;
    padding: 18px 16px;
  }

  .reference-prompt-busy-head strong {
    font-size: 20px;
  }

  .reference-prompt-busy-body {
    grid-template-columns: 1fr;
    gap: 14px;
    min-height: 0;
  }

  .reference-prompt-busy-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .reference-prompt-busy-step {
    min-height: 34px;
    padding: 0 12px;
    font-size: 12px;
  }

  .reference-prompt-busy-caption {
    min-height: 112px;
    padding: 16px 14px;
    text-align: center;
    font-size: 14px;
  }

  .reference-prompt-busy-caption strong {
    font-size: 14px;
  }

  .prompt-card {
    padding: 10px;
  }

  .prompt-card-head {
    align-items: center;
  }

  .prompt-clear-btn {
    min-height: 34px;
    padding: 0 10px;
  }

  .prompt-card textarea {
    min-height: 158px;
    max-height: 46vh;
  }

  .prompt-card-footer {
    align-items: flex-start;
    gap: 8px;
  }

  .active-result {
    min-height: 190px;
  }

  .active-result-state {
    padding: 20px 14px;
  }

  .active-result-state strong {
    font-size: 18px;
  }

  .active-result-image-shell {
    min-height: 180px;
  }

  .active-result img {
    max-height: 54vh;
  }

  .image-actions,
  .image-actions-two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .template-search {
    min-height: 46px;
    grid-template-columns: 20px minmax(0, 1fr) 34px;
    gap: 8px;
    padding: 0 8px 0 12px;
    border-radius: 10px;
  }

  .template-search input {
    font-size: 15px;
  }

  .template-search-clear {
    width: 34px;
    height: 34px;
  }

  .template-showcase {
    gap: 20px;
  }

  .template-section-header,
  .template-collection-header {
    gap: 10px;
  }

  .template-section-title {
    min-width: 0;
  }

  .template-section-title h3,
  .template-collection-title h3,
  .template-search-results-title h3 {
    font-size: 22px;
  }

  .template-section-title small,
  .template-collection-title small,
  .template-search-results-title small {
    font-size: 13px;
  }

  .template-search-results-header {
    gap: 10px;
  }

  .template-search-reset {
    min-height: 34px;
    padding: 0 10px;
    font-size: 13px;
  }

  .template-section-row {
    grid-auto-columns: minmax(150px, 46%);
    gap: 8px;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .template-section-row::-webkit-scrollbar {
    display: none;
  }

  .template-section-open {
    min-height: 34px;
    font-size: 14px;
  }

  .template-rail-card .tool-overlay {
    padding: 20px 9px 8px;
  }

  .template-rail-card .tool-overlay strong {
    font-size: 14px;
  }

  .template-modal {
    place-items: start center;
    padding-top: calc(12px + max(var(--tg-safe-top, 0px), env(safe-area-inset-top)) + var(--tg-controls-offset, 0px));
  }

  .template-modal-card {
    width: 100%;
    max-height: none;
    margin-bottom: calc(16px + max(env(safe-area-inset-bottom), var(--tg-safe-bottom, 0px)));
  }

  .template-modal-body {
    overflow: visible;
    overscroll-behavior: auto;
  }

  .template-modal-image {
    max-height: 36vh;
  }

  .template-modal-close {
    top: 10px;
    right: 10px;
    width: 48px;
    height: 48px;
    font-size: 30px;
  }

  html.is-web-runtime.is-mobile-browser .template-modal-close,
  body.is-web-runtime.is-mobile-browser .template-modal-close {
    right: 10px;
  }

  .template-modal-stats-overlay {
    right: 10px;
    bottom: 10px;
  }

  .template-modal-prompt-scroll {
    --template-prompt-collapsed-height: 124px;
    --template-prompt-expanded-height: min(24vh, 220px);
  }

  .dropzone-preview-thumb {
    --thumb-size: clamp(80px, 24vw, 120px);
  }

  .nav-btn-center {
    width: 60px;
    height: 60px;
  }

  .admin-form-actions,
  .admin-grid-2,
  .admin-preview-grid {
    grid-template-columns: 1fr;
  }

  .admin-template-card {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .admin-template-thumb {
    width: 72px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reference-prompt-card,
  .reference-prompt-card::before,
  .reference-prompt-card::after,
  .reference-dropzone,
  .reference-primary-btn,
  .reference-inline-btn,
  .tool-card,
  .tool-card .tool-media-image,
  .template-modal,
  .template-modal-card,
  .choice-chip,
  .template-section-open,
  .template-back-btn {
    transition: none !important;
  }

  .prompt-clear-btn,
  .prompt-card textarea,
  .active-result-action {
    transition: none !important;
  }

  .active-result-action:active {
    transform: none;
  }

  .reference-prompt-card {
    animation: none !important;
  }

  .reference-prompt-card::before,
  .reference-prompt-card::after,
  .reference-prompt-busy-step,
  .reference-prompt-busy-caption,
  .active-result-progress span,
  .paywall-gallery-image {
    animation: none !important;
    transition: none !important;
  }

  .paywall-gallery-image {
    opacity: 1;
  }
}

@media (max-width: 390px) {
  .tools-grid {
    grid-template-columns: 1fr;
  }

  .history-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-btn span {
    font-size: 11px;
  }

  .dropzone-preview-thumb {
    --thumb-size: 78px;
  }
}
