body:has(.gni-key-modal:not([hidden])),
body:has(.gni-api-modal:not([hidden])) {
  overflow: hidden;
}

.studio-account .balance-pill,
.studio-account .account-email-pill,
.studio-account .logout-pill,
.studio-account .invite-pill,
.studio-account .login-pill {
  display: none !important;
}

.gni-key-pill,
.gni-create-key-link {
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(38, 66, 56, 0.16);
  background: #ffffff;
  color: #24332d;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.gni-api-pill {
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(38, 66, 56, 0.16);
  background: #ffffff;
  color: #24332d;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.global-stats-pill[hidden] {
  display: none !important;
}

.global-stats-pill {
  display: none !important;
}

.gni-key-pill.is-bound {
  border-color: rgba(38, 117, 104, 0.26);
  background: rgba(38, 117, 104, 0.09);
  color: #23685d;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quota-pill {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio-account .quota-pill.gni-quota-pill {
  display: inline-flex !important;
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(38, 117, 104, 0.18);
  background: rgba(38, 117, 104, 0.08);
  color: #23685d;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 650;
}

.studio-account:not(.gni-account-ready) .quota-pill {
  visibility: hidden;
}

.model-chip {
  color: #23685d;
  background: rgba(38, 117, 104, 0.09);
}

.gni-create-key-link {
  display: none !important;
}

.gni-cost-hint {
  min-height: 34px;
  border: 1px solid rgba(38, 66, 56, 0.14);
  border-radius: 8px;
  background: #f7faf8;
  color: #3b4b44;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.prompt-action-row:has(.generate-fab[data-gni-enhanced="1"]) {
  flex-wrap: wrap;
}

.prompt-action-row:has(.generate-fab[data-gni-enhanced="1"]) .reference-row {
  flex: 0 0 48px;
}

.prompt-action-row:has(.generate-fab[data-gni-enhanced="1"]) .resolution-select {
  flex: 1 1 96px;
}

.prompt-action-row:has(.generate-fab[data-gni-enhanced="1"]) .gni-cost-hint {
  flex: 1 1 116px;
}

.generate-fab[data-gni-enhanced="1"] {
  width: 100%;
  min-width: 0;
  flex: 1 1 100%;
  padding: 0 14px;
  border-radius: 999px;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.gni-generate-label {
  display: inline-block;
}

.gni-history-empty {
  color: #a3a3a3;
  font-size: 12px;
  line-height: 18px;
}

.gni-key-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(11, 18, 16, 0.42);
  display: grid;
  place-items: center;
  padding: 20px;
}

.gni-key-modal[hidden] {
  display: none;
}

.gni-api-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(11, 18, 16, 0.42);
  display: grid;
  place-items: center;
  padding: 20px;
}

.gni-api-modal[hidden] {
  display: none;
}

.gni-api-dialog {
  width: min(520px, 100%);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 80px rgba(20, 30, 26, 0.24);
  color: #1f2d28;
  padding: 22px;
  position: relative;
}

.gni-api-dialog h2 {
  margin: 0 38px 8px 0;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: 0;
}

.gni-api-dialog p {
  margin: 0 0 14px;
  color: #5d6965;
  font-size: 13px;
  line-height: 1.6;
}

.gni-api-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: #f1f5f3;
  color: #51615b;
  cursor: pointer;
}

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

.gni-api-row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid rgba(38, 66, 56, 0.12);
  border-radius: 8px;
  background: #f7faf8;
}

.gni-api-row span {
  color: #5d6965;
  font-size: 12px;
  font-weight: 700;
}

.gni-api-row code {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: #24332d;
}

.gni-api-row button,
.gni-api-row-link a,
.gni-api-summary button {
  min-height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(38, 66, 56, 0.16);
  background: #ffffff;
  color: #263831;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}

.gni-api-row-link {
  grid-template-columns: 62px 1fr auto;
}

.gni-api-summary {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.gni-api-summary button {
  background: #267568;
  border-color: #267568;
  color: #ffffff;
}

.gni-api-tip {
  margin-top: 12px !important;
  color: #6d7b76 !important;
}

.gni-key-dialog {
  width: min(440px, 100%);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 80px rgba(20, 30, 26, 0.24);
  color: #1f2d28;
  padding: 22px;
  position: relative;
}

.gni-key-dialog h2 {
  margin: 0 38px 8px 0;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: 0;
}

.gni-key-dialog p {
  margin: 0 0 14px;
  color: #5d6965;
  font-size: 13px;
  line-height: 1.6;
}

.gni-key-dialog input {
  width: 100%;
  height: 42px;
  border: 1px solid rgba(38, 66, 56, 0.18);
  border-radius: 8px;
  padding: 0 12px;
  font: inherit;
  font-size: 14px;
  outline: none;
}

.gni-key-dialog input:focus {
  border-color: rgba(38, 117, 104, 0.55);
  box-shadow: 0 0 0 3px rgba(38, 117, 104, 0.12);
}

.gni-key-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: #f1f5f3;
  color: #51615b;
  cursor: pointer;
}

.gni-key-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.gni-key-actions a,
.gni-key-actions button {
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(38, 66, 56, 0.16);
  background: #ffffff;
  color: #263831;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}

.gni-key-save {
  background: #267568 !important;
  border-color: #267568 !important;
  color: #ffffff !important;
}

.gni-key-message {
  min-height: 20px;
  margin: 12px 0 0 !important;
  color: #356157 !important;
}

.gni-api-info {
  margin-top: 16px;
  border: 1px solid rgba(38, 66, 56, 0.12);
  border-radius: 8px;
  background: #f7faf8;
  padding: 12px;
}

.gni-api-info strong {
  display: block;
  margin-bottom: 8px;
  color: #24332d;
  font-size: 13px;
}

.gni-api-info dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.gni-api-info dl > div {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.gni-api-info dt,
.gni-api-info dd {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
}

.gni-api-info dt {
  color: #65736d;
}

.gni-api-info dd {
  color: #1f2d28;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  html,
  body,
  .studio-app {
    max-width: 100%;
    overflow-x: hidden;
  }

  .studio-topbar {
    min-width: 0;
    height: auto;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    padding: 10px 14px;
  }

  .studio-brand-group {
    min-width: 0;
    flex: 1 1 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    justify-content: stretch;
    width: 100%;
  }

  .studio-brand {
    min-width: 0;
  }

  .studio-brand span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .studio-nav {
    order: 2;
    flex: 1 1 100%;
    justify-content: center;
  }

  .studio-account {
    order: 3;
    flex: 1 1 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  .quota-pill,
  .invite-pill,
  .balance-pill,
  .account-email-pill,
  .logout-pill,
  .gni-key-pill,
  .gni-api-pill,
  .gni-create-key-link {
    min-width: 0;
    width: 100%;
    justify-content: center;
    padding-inline: 10px;
  }

  .generate-fab[data-gni-enhanced="1"] {
    flex: 1 1 140px;
    width: 100%;
  }

  .login-pill {
    flex: none;
    min-width: 0;
    width: 100%;
    justify-content: center;
  }

  .invite-pill,
  .gni-create-key-link {
    display: none !important;
  }

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

  .prompt-action-row {
    flex-wrap: wrap;
  }

  .gni-cost-hint {
    flex: 1 1 140px;
  }

  .gni-key-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .studio-grid {
    width: 100%;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr);
  }

  .prompt-panel,
  .canvas-area,
  .library-panel {
    width: 100%;
    min-width: 0;
  }

  .main-image-frame {
    max-width: calc(100vw - 40px);
  }

  .canvas-actions {
    max-width: 100%;
    overflow-x: hidden;
    padding-inline: 14px;
  }

  .canvas-actions .save-button,
.canvas-actions .share-card-button {
  min-width: 0;
}
}

.main-image-frame.gni-partial-frame {
  background: #111;
  border-style: solid;
}

.main-image-frame.gni-instant-frame {
  background: #111;
}

.main-image-frame.gni-instant-frame > img:not(.gni-instant-preview) {
  opacity: 0;
}

.main-image-frame.gni-partial-frame .gni-partial-preview {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(620px, 100dvh - 240px);
  object-fit: contain;
  filter: saturate(0.96);
}

.main-image-frame .gni-instant-preview {
  z-index: 1;
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(620px, 100dvh - 240px);
  object-fit: contain;
  filter: saturate(0.96);
}

.main-image-frame.gni-partial-frame .image-loading {
  background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.38) 100%);
  color: #fff;
}

.gni-partial-badge,
.gni-instant-badge {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 2;
  border-radius: 999px;
  background: rgba(23, 23, 23, 0.78);
  color: #fff;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.gni-download-progress {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1200;
  width: min(280px, calc(100vw - 36px));
  border: 1px solid rgba(38, 66, 56, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 16px 48px rgba(20, 30, 26, 0.18);
  color: #24332d;
  display: grid;
  gap: 8px;
  padding: 12px;
  font-size: 13px;
  font-weight: 700;
}

.gni-download-progress.is-error {
  border-color: rgba(176, 52, 52, 0.28);
  color: #9c2c2c;
}

.gni-download-track {
  height: 6px;
  border-radius: 999px;
  background: #eef3f0;
  overflow: hidden;
}

.gni-download-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #267568;
  transition: width 160ms ease;
}

.gni-download-progress.is-error .gni-download-fill {
  background: #b03434;
}

.canvas-actions button.gni-download-active {
  pointer-events: none;
  opacity: 0.72;
}
