
/* Front authentication */
body.auth-locked .site-layer {
  opacity: 0;
  filter: none;
  pointer-events: none;
  user-select: none;
}

.auth-gate {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: none;
  padding: 24px;
  align-items: flex-start;
  justify-content: center;
  overflow-x: hidden;
  overflow-y: auto;
  background:
    radial-gradient(circle at 20% 14%, rgba(106, 88, 255, .08), transparent 32%),
    radial-gradient(circle at 82% 76%, rgba(42, 190, 216, .055), transparent 30%);
  backdrop-filter: none;
}

.auth-gate.show {
  display: flex;
}

.auth-card {
  position: relative;
  width: min(430px, 100%);
  margin: auto;
  padding: 30px 34px 28px;
  border: 1px solid rgba(190, 183, 255, .24);
  border-radius: 26px;
  background: transparent;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.auth-heading {
  display: flex;
  margin-bottom: 22px;
  gap: 13px;
  align-items: center;
  justify-content: space-between;
}

.auth-identity {
  display: flex;
  gap: 13px;
  align-items: center;
}

.auth-heading b {
  color: #fff;
  font-size: 17px;
  letter-spacing: .08em;
}

.auth-mark {
  display: grid;
  width: 46px;
  height: 46px;
  margin-bottom: 0;
  border: 1px solid rgba(151, 139, 255, .38);
  border-radius: 16px;
  color: #b0a7ff;
  background: rgba(142, 130, 255, .045);
  place-items: center;
}

.auth-mark svg {
  width: 22px;
  height: 22px;
}

.auth-theme-control {
  flex: 0 0 auto;
}

.auth-tabs {
  display: grid;
  margin-bottom: 24px;
  padding: 4px;
  grid-template-columns: 1fr 1fr;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 13px;
  background: transparent;
}

.auth-tabs button {
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  color: rgba(226, 230, 250, .48);
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 750;
}

.auth-tabs button.active {
  color: #fff;
  background: linear-gradient(110deg, rgba(126, 104, 241, .18), rgba(50, 174, 207, .07));
  box-shadow: inset 0 0 0 1px rgba(158, 147, 255, .15);
}

.auth-tabs button[hidden] {
  display: none;
}

.auth-tabs:has(button[hidden]) {
  grid-template-columns: 1fr;
}

.auth-card h2 {
  margin: 0 0 22px;
  font-size: 27px;
}

.auth-card form,
.auth-card label {
  display: flex;
  flex-direction: column;
}

.auth-card label[hidden] {
  display: none;
}

.auth-card form {
  gap: 15px;
}

.auth-card label {
  gap: 8px;
  color: rgba(236, 238, 255, .78);
  font-size: 14px;
  font-weight: 700;
}

.auth-card label > span:first-child {
  color: rgba(236, 238, 255, .78);
}

.auth-card input {
  width: 100%;
  height: 48px;
  padding: 0 15px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 13px;
  outline: 0;
  color: #fff;
  background: rgba(4, 8, 27, .045);
  font: inherit;
  font-size: 15px;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.auth-password-wrap {
  position: relative;
  display: block;
}

.auth-password-wrap input {
  padding-right: 64px;
}

.auth-password-toggle {
  position: absolute;
  top: 50%;
  right: 12px;
  min-width: 38px;
  padding: 4px;
  border: 0;
  color: rgba(225, 229, 249, .48);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  transform: translateY(-50%);
}

.auth-password-toggle:hover {
  color: #fff;
}

.auth-card input:focus {
  border-color: rgba(142, 130, 255, .65);
  box-shadow: 0 0 0 3px rgba(142, 130, 255, .1);
}

.auth-submit {
  width: 100%;
  min-height: 48px;
  justify-content: center;
  font-size: 15px;
}

.auth-policy {
  display: grid;
  gap: 4px;
  margin-top: 17px;
  padding: 11px 13px;
  border: 1px solid rgba(255, 205, 112, .14);
  border-radius: 12px;
  color: rgba(235, 229, 209, .58);
  background: rgba(93, 65, 16, .045);
  font-size: 12px;
  line-height: 1.6;
  text-align: left;
}

.auth-policy strong {
  color: rgba(255, 226, 162, .92);
  font-size: 13px;
}

.auth-policy[hidden] {
  display: none;
}

.site-announcement {
  width: 100%;
  padding: 9px 24px;
  border-bottom: 1px solid rgba(255, 218, 132, .14);
  color: rgba(255, 233, 182, .88);
  background: rgba(114, 77, 15, .18);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.site-announcement.maintenance {
  color: #ffd3dc;
  border-bottom-color: rgba(255, 116, 145, .18);
  background: rgba(126, 27, 54, .2);
}

.auth-error {
  min-height: 20px;
  color: #ff91aa;
  font-size: 13px;
}

.auth-field-error {
  margin-top: -2px;
  color: #ff91aa;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
}

.auth-field-error:empty {
  display: none;
}

.auth-card input[aria-invalid="true"] {
  border-color: rgba(255, 108, 141, .72);
  box-shadow: 0 0 0 3px rgba(255, 108, 141, .1);
}

.auth-card .dialog-action:disabled {
  opacity: .55;
  cursor: wait;
}

html[data-theme="light"] body.auth-locked .site-layer {
  opacity: 0;
}

html[data-theme="light"] .auth-gate {
  background:
    radial-gradient(circle at 18% 12%, rgba(118, 99, 241, .09), transparent 31%),
    radial-gradient(circle at 84% 78%, rgba(44, 184, 207, .08), transparent 29%);
}

html[data-theme="light"] .auth-card {
  border-color: rgba(55, 63, 98, .16);
  color: #171c31;
  background: transparent;
  box-shadow: none;
}

html[data-theme="light"] .auth-heading b,
html[data-theme="light"] .auth-card h2,
html[data-theme="light"] .auth-card label,
html[data-theme="light"] .auth-card label > span:first-child {
  color: #171c31;
}

html[data-theme="light"] .auth-tabs {
  border-color: rgba(45, 55, 90, .12);
  background: transparent;
}

html[data-theme="light"] .auth-tabs button {
  color: rgba(35, 43, 70, .68);
}

html[data-theme="light"] .auth-tabs button.active {
  color: #312866;
  background: linear-gradient(110deg, rgba(126, 104, 241, .14), rgba(50, 174, 207, .07));
}

html[data-theme="light"] .auth-card input {
  border-color: rgba(45, 55, 90, .14);
  color: #171c31;
  background: rgba(255, 255, 255, .16);
}

html[data-theme="light"] .auth-card input::placeholder {
  color: rgba(39, 47, 75, .58);
}

html[data-theme="light"] .auth-password-toggle {
  color: rgba(35, 43, 70, .7);
}

html[data-theme="light"] .auth-password-toggle:hover {
  color: #171c31;
}

html[data-theme="light"] .auth-policy {
  border-color: rgba(164, 111, 26, .16);
  color: rgba(86, 62, 27, .66);
  background: rgba(255, 229, 176, .18);
}

html[data-theme="light"] .auth-policy strong {
  color: #7d531a;
}

@media (max-width: 520px) {
  .auth-heading {
    align-items: flex-start;
  }

  .auth-theme-control {
    padding-left: 8px;
  }

  .auth-theme-control > span {
    display: none;
  }
}

#logoutButton {
  gap: 6px;
}

.credits-disabled .credit-control,
.credits-disabled .generation-credit-hint {
  display: none !important;
}

.recharge-button {
  display: inline-flex;
  min-height: 38px;
  padding: 0 13px;
  gap: 7px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(103, 222, 188, .28);
  border-radius: 12px;
  color: #d9fff3;
  background: linear-gradient(115deg, rgba(37, 151, 132, .18), rgba(84, 105, 223, .14));
  box-shadow: inset 0 1px rgba(255, 255, 255, .06);
  font-size: 13px;
  font-weight: 760;
  text-decoration: none;
  backdrop-filter: blur(14px);
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s, box-shadow .2s, transform .2s;
}

.recharge-button svg {
  width: 15px;
  height: 15px;
  color: #8af0d1;
}

.recharge-button:hover {
  border-color: rgba(115, 235, 201, .5);
  color: #fff;
  background: linear-gradient(115deg, rgba(44, 174, 150, .28), rgba(91, 113, 237, .22));
  box-shadow: 0 8px 24px rgba(39, 165, 141, .12), inset 0 1px rgba(255, 255, 255, .09);
  transform: translateY(-1px);
}

.recharge-button:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px rgba(107, 234, 197, .15);
}

.recharge-button[aria-disabled="true"],
.recharge-dialog-action[aria-disabled="true"] {
  opacity: .58;
  cursor: not-allowed;
}

.redeem-code-button {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  min-height: 38px;
  padding: 0 14px 0 10px;
  overflow: hidden;
  gap: 8px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 207, 118, .32);
  border-radius: 12px;
  outline: 0;
  color: #fff3cf;
  background:
    linear-gradient(115deg, rgba(127, 88, 255, .23), rgba(212, 126, 75, .2)),
    rgba(255, 255, 255, .035);
  box-shadow:
    inset 0 1px rgba(255, 255, 255, .08),
    0 0 24px rgba(184, 118, 255, .1);
  font: inherit;
  font-size: 13px;
  font-weight: 760;
  letter-spacing: .02em;
  backdrop-filter: blur(14px);
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s, box-shadow .2s, transform .2s;
}

.redeem-code-button::after {
  position: absolute;
  z-index: -1;
  top: -85%;
  left: -45%;
  width: 26%;
  height: 270%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .32), transparent);
  content: "";
  transform: translateX(-160%) rotate(18deg);
  animation: redeemShine 4.2s ease-in-out infinite;
  pointer-events: none;
}

.redeem-code-button:hover {
  border-color: rgba(255, 218, 144, .58);
  color: #fff;
  background:
    linear-gradient(115deg, rgba(138, 98, 255, .34), rgba(223, 140, 77, .3)),
    rgba(255, 255, 255, .05);
  box-shadow:
    inset 0 1px rgba(255, 255, 255, .12),
    0 8px 26px rgba(159, 98, 231, .17);
  transform: translateY(-1px);
}

.redeem-code-button:focus-visible {
  box-shadow:
    0 0 0 3px rgba(255, 205, 119, .16),
    0 8px 26px rgba(159, 98, 231, .17);
}

.redeem-code-icon {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border: 1px solid rgba(255, 224, 159, .25);
  border-radius: 8px;
  color: #ffe5a9;
  background: rgba(255, 217, 139, .08);
  box-shadow: 0 0 15px rgba(255, 197, 105, .1);
  place-items: center;
}

.redeem-code-icon svg {
  width: 14px;
  height: 14px;
}

@keyframes redeemShine {
  0%,
  56% {
    transform: translateX(-160%) rotate(18deg);
  }

  82%,
  100% {
    transform: translateX(720%) rotate(18deg);
  }
}

.credit-badge {
  display: inline-flex;
  min-height: 34px;
  padding: 0 12px;
  gap: 5px;
  align-items: center;
  border: 1px solid rgba(255, 214, 126, .2);
  border-radius: 999px;
  color: rgba(255, 239, 198, .86);
  background: rgba(98, 70, 16, .2);
  font-size: 12px;
  font-weight: 750;
  backdrop-filter: blur(12px);
  cursor: pointer;
  transition: border-color .18s, transform .18s, background .18s;
}

.credit-badge:hover {
  border-color: rgba(255, 214, 126, .42);
  background: rgba(116, 82, 18, .3);
  transform: translateY(-1px);
}

.credit-badge b {
  color: #fff2b8;
  font-size: 13px;
}

.recharge-dialog-action {
  margin-top: 20px;
  text-decoration: none;
}

.recharge-dialog-action svg {
  width: 15px;
  height: 15px;
}

.redeem-separator {
  display: flex;
  margin: 20px 0 -4px;
  gap: 12px;
  align-items: center;
  color: rgba(222, 226, 247, .38);
  font-size: 10px;
}

.redeem-separator::before,
.redeem-separator::after {
  height: 1px;
  flex: 1;
  background: rgba(255, 255, 255, .08);
  content: "";
}

#logoutButton span:first-child {
  max-width: 92px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-right {
  grid-template-columns: minmax(170px, 1fr) minmax(104px, .48fr) minmax(210px, .92fr) auto;
}

@container (max-width: 960px) {
  .composer-right {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .composer .generate-button {
    width: 100%;
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .header-actions {
    gap: 6px;
  }

  .header-actions > .recharge-button,
  .header-actions > .redeem-code-button {
    display: none;
  }

  #logoutButton span:last-child,
  #currentUsername {
    display: none;
  }

  .credit-badge {
    min-height: 32px;
    padding: 0 10px;
  }

  .auth-card {
    padding: 28px 22px;
  }

  .auth-gate {
    padding: 14px;
  }

  .composer-right {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .redeem-code-button::after {
    animation: none;
  }
}

.batch-picker {
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 3px;
  gap: 2px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 10px;
  background: rgba(255, 255, 255, .045);
  box-shadow: inset 0 1px rgba(255, 255, 255, .05), 0 10px 30px rgba(0, 0, 0, .12);
  -webkit-backdrop-filter: blur(18px) saturate(120%);
  backdrop-filter: blur(18px) saturate(120%);
}

.batch-picker:hover {
  border-color: rgba(154, 144, 255, .34);
  background: rgba(126, 108, 255, .075);
}

.batch-picker > span {
  padding: 0 8px;
  color: rgba(232, 235, 255, .66);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.batch-picker > select {
  width: 100%;
  min-width: 0;
  height: 31px;
  padding: 0 24px 0 9px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 9px;
  color: rgba(255, 255, 255, .92);
  background:
    linear-gradient(45deg, transparent 50%, rgba(245, 246, 255, .78) 50%) right 10px center / 6px 6px no-repeat,
    linear-gradient(135deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, .02));
  font-size: 13px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.batch-picker > select option {
  color: #f7f7ff;
  background: #11152d;
}

.composer-right {
  grid-template-columns:
    minmax(160px, 1fr)
    minmax(100px, .45fr)
    minmax(112px, .5fr)
    minmax(190px, .88fr)
    minmax(98px, .42fr)
    auto;
}

.batch-controls {
  display: flex;
  width: 100%;
  padding: 2px 0 0;
  gap: 8px;
  grid-column: 1 / -1;
  justify-content: flex-end;
}

.batch-controls[hidden] {
  display: none !important;
}

.batch-control-button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(151, 139, 255, .24);
  border-radius: 10px;
  color: rgba(240, 242, 255, .82);
  background: rgba(126, 108, 255, .09);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  transition: border-color .18s, background .18s, transform .18s;
}

.batch-control-button:hover {
  border-color: rgba(151, 139, 255, .48);
  background: rgba(126, 108, 255, .16);
  transform: translateY(-1px);
}

.batch-control-button.danger {
  border-color: rgba(255, 128, 155, .2);
  color: rgba(255, 190, 204, .82);
  background: rgba(255, 91, 128, .055);
}

.batch-control-button:disabled {
  opacity: .48;
  cursor: wait;
  transform: none;
}

.output-panel {
  min-height: 0;
  overflow: hidden;
}

.output-body {
  overflow: hidden;
}

.result-stage.show.batch-results {
  display: grid;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  align-content: start;
  align-items: start;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px;
  scrollbar-gutter: stable;
}

.batch-results .result-card {
  width: 100%;
}

.batch-results .result-image-button img {
  width: 100%;
  max-height: 280px;
}

.batch-results .result-actions {
  min-height: 88px;
  padding: 10px;
  align-items: stretch;
  flex-direction: column;
}

.batch-results .result-actions > div {
  align-self: flex-end;
}

@container (max-width: 960px) {
  .composer-right {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .composer .generate-button,
  .batch-controls {
    width: 100%;
    grid-column: 1 / -1;
  }
}

@media (max-width: 1320px) {
  .result-stage.show.batch-results {
    height: auto;
    max-height: min(72vh, 820px);
  }
}

@media (max-width: 760px) {
  .composer-right {
    grid-template-columns: 1fr;
  }

  .batch-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .batch-control-button {
    width: 100%;
  }

  .result-stage.show.batch-results {
    grid-template-columns: 1fr;
  }

  .batch-results .result-image-button img {
    max-height: 430px;
  }
}

/* Keep the composer controls on two compact rows. */
.composer-footer {
  display: block;
}

.composer-right {
  grid-template-columns:
    minmax(0, 1fr)
    minmax(0, 1fr)
    minmax(150px, .78fr);
}

@container (max-width: 960px) {
  .composer-right {
    grid-template-columns:
      minmax(0, 1fr)
      minmax(0, 1fr)
      minmax(150px, .78fr);
  }
}

.reference-picker {
  display: flex;
  min-width: 0;
  min-height: 38px;
  padding: 3px;
  gap: 2px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 10px;
  background: rgba(255, 255, 255, .045);
  box-shadow: inset 0 1px rgba(255, 255, 255, .05), 0 10px 30px rgba(0, 0, 0, .12);
  -webkit-backdrop-filter: blur(18px) saturate(120%);
  backdrop-filter: blur(18px) saturate(120%);
}

.reference-picker:hover {
  border-color: rgba(154, 144, 255, .34);
  background: rgba(126, 108, 255, .075);
}

.reference-picker .upload-button {
  min-width: 0;
  padding: 0 7px;
  border: 0;
  background: transparent;
  box-shadow: none;
  white-space: nowrap;
}

.reference-picker .prompt-count {
  margin-left: auto;
  padding-right: 7px;
  white-space: nowrap;
}

.composer-right > .size-picker {
  min-width: 0;
  grid-column: auto;
}

.composer-right > .batch-picker {
  grid-column: auto;
}

.composer-right > .generate-button,
.composer-right > .batch-controls {
  width: 100%;
  min-width: 0;
  grid-column: auto;
}

.composer-right > .generate-button {
  min-height: 38px;
}

.composer-right > .generate-button[hidden] {
  display: none !important;
}

.composer-right > .batch-controls {
  display: grid;
  padding: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.composer-right > .batch-controls .batch-control-button {
  min-width: 0;
  padding: 0 7px;
  font-size: 11px;
}

@container (max-width: 700px) {
  .composer-right {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .composer-right > .size-picker {
    grid-column: auto;
  }

  .composer-right > .batch-picker {
    grid-column: auto;
  }

  .composer-right > .generate-button,
  .composer-right > .batch-controls {
    grid-column: 1 / -1;
  }
}

html[data-theme="light"] .reference-picker,
html[data-theme="light"] .batch-picker,
html[data-theme="light"] .batch-control-button {
  border-color: rgba(35, 45, 78, .13);
  color: rgba(25, 31, 54, .76);
  background: rgba(255, 255, 255, .34);
  box-shadow: none;
}

html[data-theme="light"] .reference-picker:hover,
html[data-theme="light"] .batch-picker:hover,
html[data-theme="light"] .batch-control-button:hover {
  border-color: rgba(115, 96, 225, .3);
  color: #171c31;
  background: rgba(124, 107, 244, .07);
}

html[data-theme="light"] .batch-picker > span,
html[data-theme="light"] .reference-picker .prompt-count {
  color: rgba(35, 43, 70, .58);
}

html[data-theme="light"] .batch-picker > select {
  border-color: rgba(35, 45, 78, .1);
  color: rgba(25, 31, 54, .88);
  background:
    linear-gradient(45deg, transparent 50%, rgba(35, 43, 70, .7) 50%) right 10px center / 6px 6px no-repeat,
    rgba(255, 255, 255, .44);
}

html[data-theme="light"] .batch-picker > select option {
  color: #171c31;
  background: #fff;
}

html[data-theme="light"] .credit-badge b,
html[data-theme="light"] .redeem-code-label {
  color: #272d4a;
}
