:root {
  --bg: #06131a;
  --bg-soft: #0d1d25;
  --card: rgba(10, 24, 32, 0.78);
  --card-strong: rgba(15, 31, 40, 0.94);
  --line: rgba(161, 210, 205, 0.18);
  --line-strong: rgba(161, 210, 205, 0.34);
  --text: #edf7f6;
  --muted: #9eb4b8;
  --accent: #8be9d6;
  --accent-strong: #4fd1ba;
  --danger: #ff7b7b;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Manrope", sans-serif;
  background:
    radial-gradient(circle at 20% 10%, rgba(79, 209, 186, 0.18), transparent 28%),
    radial-gradient(circle at 80% 0%, rgba(74, 222, 128, 0.14), transparent 24%),
    linear-gradient(180deg, #071017 0%, #08151d 48%, #051017 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: radial-gradient(circle at center, black 34%, transparent 100%);
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 36px 0 64px;
}

.hero-card,
.site-header,
.composer-card,
.examples-card,
.gallery-card,
.loading-card,
.result-card,
.message-card {
  background: var(--card);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.hero-card {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
  padding: 32px;
  border-radius: 28px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-radius: 20px;
}

.site-brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.site-brand h1 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(24px, 3vw, 30px);
  line-height: 1;
  letter-spacing: -0.04em;
}

.site-mark {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.site-header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.02);
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.nav-link:hover,
.nav-link.is-active {
  color: var(--text);
  border-color: var(--line-strong);
  background: rgba(139, 233, 214, 0.08);
}

.hero-copy h1,
.section-head h2 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: -0.04em;
}

.hero-copy h1 {
  font-size: clamp(42px, 6vw, 74px);
  line-height: 0.95;
  max-width: 10ch;
}

.lead {
  max-width: 58ch;
  margin: 20px 0 0;
  font-size: 18px;
  line-height: 1.75;
  color: var(--muted);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.hero-pills span,
.model-chip {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(139, 233, 214, 0.06);
  color: var(--text);
  font-size: 14px;
}

.hero-panel,
.auth-card,
.success-card {
  height: 100%;
}

.auth-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding: 28px;
  border-radius: 24px;
  background: var(--card-strong);
  border: 1px solid var(--line);
}

.auth-label {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.auth-card p,
.hint,
.message-card,
.loading-card p {
  color: var(--muted);
}

.workspace {
  display: grid;
  gap: 22px;
  margin-top: 22px;
}

.workspace-top {
  display: grid;
  grid-template-columns: minmax(0, 0.98fr) minmax(340px, 1.02fr);
  gap: 22px;
  align-items: start;
}

.workspace-side {
  display: grid;
  gap: 18px;
  align-content: start;
}

.composer-card,
.examples-card,
.gallery-card,
.result-card {
  padding: 26px;
  border-radius: 24px;
}

.section-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section-head.compact {
  margin-bottom: 18px;
}

.section-head h2 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1;
}

.workspace-top .section-head h2 {
  font-size: clamp(24px, 3vw, 34px);
}

.generator-form {
  display: grid;
  gap: 18px;
}

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

.upload-field {
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
}

.upload-field.is-dragover {
  border-color: var(--accent);
  background: rgba(139, 233, 214, 0.08);
}

.upload-field strong {
  font-size: 16px;
  color: var(--text);
}

.upload-field em {
  font-style: normal;
  font-size: 14px;
  color: var(--muted);
}

.upload-field input[type="file"] {
  padding: 0;
  border: 0;
  background: transparent;
}

.reference-order {
  display: grid;
  gap: 10px;
}

.reference-item {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.reference-preview {
  width: 84px;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

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

.reference-details {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.reference-index {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.reference-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

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

.reference-remove {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  cursor: pointer;
}

.reference-remove:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
}

.field span {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

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

input,
textarea,
select {
  width: 100%;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
  transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  padding-right: 52px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent) 50%),
    linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position:
    calc(100% - 24px) calc(50% - 2px),
    calc(100% - 18px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

select option {
  color: #071017;
  background: #f3fbfa;
}

textarea {
  min-height: 168px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.primary-btn,
.ghost-btn,
.prompt-pill,
.link-btn {
  border: 0;
  cursor: pointer;
  text-decoration: none;
}

.primary-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 0 22px;
  border-radius: 16px;
  font-weight: 800;
  transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
}

.primary-btn {
  color: #04201d;
  background: linear-gradient(135deg, var(--accent) 0%, #dcfff7 100%);
  box-shadow: 0 18px 40px rgba(79, 209, 186, 0.25);
}

.ghost-btn {
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.primary-btn:hover,
.ghost-btn:hover,
.prompt-pill:hover {
  transform: translateY(-1px);
}

.primary-btn[disabled] {
  opacity: 0.6;
  cursor: wait;
}

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

.prompt-pill {
  padding: 18px;
  text-align: left;
  border-radius: 20px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  line-height: 1.65;
}

.loading-card {
  display: grid;
  gap: 14px;
  padding: 22px 26px;
  border-radius: 22px;
}

.loading-title {
  font-size: 22px;
  font-weight: 800;
}

.loading-status {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.loading-progress {
  margin-top: 12px;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
}

.loading-progress-bar {
  display: block;
  height: 100%;
  width: 6%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-strong) 0%, #c8fff4 100%);
  box-shadow: 0 10px 24px rgba(79, 209, 186, 0.35);
  transition: width 0.35s ease;
}

.loading-progress-bar.is-processing {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.26) 0%, rgba(255, 255, 255, 0.04) 24%, rgba(255, 255, 255, 0.26) 48%, rgba(255, 255, 255, 0.04) 72%, rgba(255, 255, 255, 0.26) 100%),
    linear-gradient(90deg, var(--accent-strong) 0%, #c8fff4 100%);
  background-size: 180px 100%, 100% 100%;
  animation: progress-flow 1.25s linear infinite;
}

.result-layout {
  display: block;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.balance-hero,
.balance-card,
.balance-section {
  background: var(--card);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.balance-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 20px;
  padding: 28px;
  border-radius: 28px;
}

.balance-lead {
  max-width: 60ch;
}

.balance-hero-side {
  display: flex;
  align-items: stretch;
}

.balance-credit-big {
  width: 100%;
  padding: 24px;
  border-radius: 24px;
  border: 1px solid var(--line-strong);
  background:
    radial-gradient(circle at top right, rgba(139, 233, 214, 0.18), transparent 35%),
    rgba(255, 255, 255, 0.03);
}

.balance-credit-big span {
  display: block;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.balance-credit-big strong {
  display: block;
  margin-top: 12px;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(38px, 5vw, 64px);
  line-height: 0.95;
}

.balance-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.balance-card {
  padding: 22px;
  border-radius: 22px;
}

.balance-card.spotlight {
  background:
    radial-gradient(circle at top left, rgba(139, 233, 214, 0.16), transparent 32%),
    rgba(10, 24, 32, 0.86);
}

.balance-card-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.balance-card-value {
  margin-top: 10px;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1;
}

.balance-card-note {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

.balance-section {
  padding: 26px;
  border-radius: 24px;
}

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

.benefit-card {
  padding: 20px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.benefit-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.benefit-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(139, 233, 214, 0.12);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.benefit-card h3 {
  margin: 14px 0 0;
  font-size: 24px;
  font-family: "Space Grotesk", sans-serif;
  line-height: 1.1;
}

.benefit-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.benefit-meta div,
.meta-row {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.benefit-meta span,
.meta-row span {
  display: block;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.benefit-meta strong,
.meta-row strong {
  display: block;
  margin-top: 8px;
  color: var(--text);
  line-height: 1.5;
  word-break: break-word;
}

.empty-balance-state {
  padding: 22px;
  border-radius: 18px;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}

.account-meta-grid {
  display: grid;
  gap: 14px;
}

.gallery-item {
  display: grid;
  gap: 12px;
  padding: 12px;
  text-align: left;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.gallery-item:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
}

.gallery-thumb {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

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

.gallery-meta {
  display: grid;
  gap: 8px;
}

.gallery-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.gallery-prompt {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.image-frame {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 24px;
  background:
    radial-gradient(circle at top, rgba(79, 209, 186, 0.14), transparent 34%),
    rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}

.image-frame[data-ratio="16:9"] {
  aspect-ratio: 16 / 9;
}

.image-frame[data-ratio="9:16"] {
  aspect-ratio: 9 / 16;
}

.image-frame[data-ratio="4:3"] {
  aspect-ratio: 4 / 3;
}

.image-frame[data-ratio="3:4"] {
  aspect-ratio: 3 / 4;
}

.image-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  position: relative;
  z-index: 1;
}

.image-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.result-details {
  margin-top: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.result-details summary {
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.result-details summary::-webkit-details-marker {
  display: none;
}

.stats-panel.compact {
  gap: 0;
  padding: 0 16px 14px;
}

.stat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.stat-row:first-child {
  border-top: 0;
}

.stats-panel {
  display: grid;
  gap: 14px;
}

.stat-block {
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.stat-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  margin-top: 8px;
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
}

.stat-value.small {
  font-size: 16px;
  line-height: 1.6;
  word-break: break-word;
}

.message-card {
  padding: 18px 22px;
  border-radius: 18px;
}

.message-card.error {
  border-color: rgba(255, 123, 123, 0.35);
  background: rgba(255, 123, 123, 0.08);
  color: #ffd2d2;
}

.message-card.info {
  border-color: rgba(139, 233, 214, 0.25);
  background: rgba(139, 233, 214, 0.06);
  color: var(--text);
}

.form-error {
  color: #ffd0d0;
  font-size: 14px;
}

.hidden {
  display: none !important;
}

@keyframes pulse {
  0%,
  80%,
  100% {
    transform: scale(0.7);
    opacity: 0.45;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes progress-flow {
  from {
    background-position: 0 0, 0 0;
  }

  to {
    background-position: 180px 0, 0 0;
  }
}

@media (max-width: 920px) {
  .hero-card,
  .workspace-top,
  .balance-hero,
  .result-layout,
  .prompt-grid,
  .control-grid,
  .gallery-grid,
  .balance-grid,
  .benefits-grid {
    grid-template-columns: 1fr;
  }

  .reference-item {
    grid-template-columns: 1fr;
  }

  .reference-preview {
    width: 100%;
    max-width: 160px;
  }

  .hero-copy h1 {
    max-width: none;
  }

  .workspace-side {
    gap: 22px;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100vw - 18px, 1180px);
    padding-top: 18px;
    padding-bottom: 36px;
  }

  .hero-card,
  .site-header,
  .composer-card,
  .examples-card,
  .gallery-card,
  .result-card {
    padding: 20px;
    border-radius: 22px;
  }

  .primary-btn,
  .ghost-btn {
    width: 100%;
  }

  .site-header {
    align-items: stretch;
    flex-direction: column;
  }

  .site-header-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .form-actions {
    align-items: stretch;
  }
}
