:root {
  --bg: #eef2f7;
  --panel: #ffffff;
  --panel-soft: #f3f6fb;
  --text: #14213d;
  --muted: #74829a;
  --line: #dce4f0;
  --line-soft: #edf2f8;
  --navy: #111d33;
  --navy-deep: #0b1628;
  --accent: #dd84ad;
  --accent-dark: #b75b8a;
  --accent-soft: #fff0f7;
  --mint: #c4f3d1;
  --lavender: #e2dcff;
  --peach: #ffe2c6;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --shadow: 0 12px 30px rgba(17, 29, 51, 0.08);
  --shadow-soft: 0 8px 22px rgba(17, 29, 51, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  line-height: 1.45;
}

body.no-scroll {
  overflow: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
}

h1,
h2 {
  margin: 0 0 10px;
  line-height: 1.15;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
  font-weight: 850;
}

h2 {
  font-size: 22px;
  font-weight: 850;
}

.mobile-app-header,
.sidebar-overlay {
  display: none;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: 258px;
  padding: 30px 12px 14px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  border-right: 1px solid var(--line);
  box-shadow: 8px 0 24px rgba(17, 29, 51, 0.04);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-brand {
  padding: 0 12px 20px;
  display: flex;
  align-items: center;
}

.sidebar-brand img {
  width: 148px;
  height: auto;
  display: block;
}

.sidebar-section {
  padding: 0 12px;
  color: #8a97aa;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.side-nav .sidebar-section {
  margin-top: 10px;
}

.side-nav .sidebar-section:first-child {
  margin-top: 0;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.side-nav a {
  display: flex;
  align-items: center;
  min-height: 39px;
  padding: 9px 12px;
  border-radius: 9px;
  color: #26375f;
  font-weight: 800;
  font-size: 14px;
}

.side-nav a:hover {
  background: #f3f6fb;
  color: var(--text);
}

.side-nav a.is-active {
  background: var(--accent-soft);
  color: var(--accent-dark);
  box-shadow: inset 0 0 0 1px rgba(221, 132, 173, 0.2);
}

.sidebar-spacer {
  flex: 1 1 auto;
}

.sidebar-balance,
.sidebar-user {
  margin: 0 2px;
  padding: 12px;
  border-radius: 14px;
  background: #f8fbff;
  border: 1px solid var(--line);
}

.sidebar-balance {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-balance span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.sidebar-balance strong {
  font-size: 20px;
}

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

.sidebar-user span {
  font-size: 13px;
  font-weight: 800;
}

.app-main {
  min-height: 100vh;
  margin-left: 258px;
}

.content-topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  min-height: 82px;
  padding: 16px 22px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.content-topbar h1 {
  margin: 0 0 3px;
  color: #1d2735;
  font-size: 29px;
}

.content-topbar p {
  margin: 0;
  color: #6e7b91;
  font-size: 14px;
}

.auth-topbar {
  width: min(1220px, calc(100% - 32px));
  min-height: 72px;
  margin: 16px auto 0;
  padding: 0 18px 0 22px;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-weight: 950;
  color: var(--text);
  letter-spacing: 0;
}

.brand-logo {
  display: flex;
  align-items: center;
}

.brand-logo img {
  width: 154px;
  height: auto;
  display: block;
}

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

.nav a,
.link-button,
.nav-balance {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #26375f;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  padding: 9px 11px;
}

.nav a.nav-cta {
  background: var(--accent);
  color: #fff;
  padding: 10px 15px;
  font-weight: 850;
}

.sidebar .link-button {
  padding: 6px 10px;
  background: #edf2f8;
  color: var(--text);
}

.nav-balance {
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
  padding: 9px 14px;
}

.nav a:hover,
.link-button:hover {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.nav a.nav-cta:hover {
  background: var(--accent-dark);
  color: #fff;
}

.sidebar .link-button:hover {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.inline-form {
  display: flex;
}

.page {
  width: auto;
  margin: 0;
  padding: 18px 22px 46px;
}

.auth-page {
  width: min(1220px, calc(100% - 32px));
  margin: 34px auto 64px;
  padding: 0;
}

.auth-shell {
  min-height: calc(100vh - 160px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.public-shell {
  min-height: calc(100vh - 150px);
  display: flex;
  align-items: center;
  gap: 24px;
}

.public-product,
.public-panel {
  flex: 1 1 0;
}

.self-tryon-shell {
  min-height: 0;
  justify-content: flex-start;
  align-items: flex-start;
}

.self-tryon-panel {
  width: min(1180px, 100%);
  max-width: none;
  padding: 28px;
}

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

.tryon-column {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  background: #fbfdff;
}

.upload-preview.large {
  width: 116px;
  height: 116px;
}

.saved-photo-section {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

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

.saved-photo-card {
  position: relative;
  min-width: 0;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
}

.saved-photo-card input {
  position: absolute;
  top: 10px;
  left: 10px;
  width: auto;
  min-height: auto;
  z-index: 2;
}

.saved-photo-card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 10px;
  display: block;
}

.saved-photo-card:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(221, 132, 173, 0.18);
}

.self-tryon-actions {
  margin-top: 16px;
}

.public-product img {
  width: 100%;
  max-height: 680px;
  object-fit: contain;
  border-radius: 28px;
  background: #fff;
  box-shadow: var(--shadow);
}

.public-panel {
  max-width: 520px;
}

.public-panel.self-tryon-panel {
  width: min(1180px, 100%);
  max-width: none;
  flex: 0 1 1180px;
}

.self-tryon-panel .upload-card {
  min-width: 0;
}

.self-tryon-panel .upload-meta {
  flex: 1 1 auto;
}

.self-tryon-panel .upload-title,
.self-tryon-panel .upload-file-name {
  overflow-wrap: normal;
  word-break: normal;
}

.auth-panel {
  width: min(440px, 100%);
}

.google-auth-button {
  min-height: 46px;
  width: 100%;
  margin: 18px 0 16px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: #26375f;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 850;
}

.google-auth-button:hover {
  border-color: #c7d3e3;
  background: #fbfdff;
  color: var(--text);
}

.google-auth-mark {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid #d8e1ed;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #4285f4;
  font-weight: 950;
  font-size: 15px;
  line-height: 1;
  flex: 0 0 auto;
}

.auth-divider {
  margin: 0 0 16px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 750;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  background: var(--line);
  flex: 1 1 auto;
}

.welcome-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  padding: 20px;
  background: rgba(11, 22, 40, 0.48);
  display: flex;
  align-items: center;
  justify-content: center;
}

.welcome-modal-panel {
  position: relative;
  width: min(430px, 100%);
  padding: 26px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 18px 48px rgba(17, 29, 51, 0.18);
  text-align: center;
}

.welcome-modal-panel h2 {
  margin-bottom: 10px;
}

.welcome-modal-panel p {
  margin: 0 0 20px;
  color: #52627a;
  font-size: 16px;
}

.welcome-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #f3f6fb;
  color: #52627a;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.welcome-modal-close:hover {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.panel,
.pricing-card,
.generation-card,
.balance-box,
.stat {
  background: var(--panel);
  border: 1px solid #d9e1ed;
  border-radius: 12px;
  box-shadow: none;
}

.panel {
  padding: 16px;
}

.muted,
.hint {
  color: var(--muted);
}

.hint {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.hidden {
  display: none !important;
}

.alert {
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid #ffcdc7;
  border-radius: 16px;
  padding: 12px 14px;
  margin: 14px 0;
  overflow-wrap: anywhere;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row > label,
.form-row > .field-group {
  flex: 1 1 0;
  min-width: 0;
}

label,
.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: #26375f;
  font-size: 14px;
  font-weight: 650;
}

.field-label {
  color: #26375f;
}

input,
textarea,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 12px;
  color: var(--text);
  background: #fbfdff;
  font: inherit;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(221, 132, 173, 0.18);
}

textarea {
  resize: vertical;
}

.checkbox {
  flex-direction: row;
  align-items: center;
}

.checkbox input {
  width: auto;
  min-height: auto;
}

.upload-card {
  min-height: 116px;
  border: 1px dashed #cbd7e6;
  border-radius: 12px;
  padding: 12px;
  background: #fbfdff;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.upload-card:hover {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(221, 132, 173, 0.12);
}

.upload-input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

.upload-preview {
  width: 92px;
  height: 92px;
  border-radius: 10px;
  background: #eef3fa;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: 0 0 auto;
}

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

.upload-placeholder {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  line-height: 1;
}

.upload-meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.upload-title {
  color: var(--text);
  font-size: 15px;
}

.upload-file-name {
  overflow-wrap: anywhere;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: none;
}

.button.primary:hover {
  background: var(--accent-dark);
}

.button.is-loading {
  gap: 8px;
  pointer-events: none;
}

.button.is-loading .spinner.compact {
  width: 18px;
  height: 18px;
  border-width: 2px;
}

button:disabled,
.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.dashboard-header,
.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.content-grid.single-column {
  display: flex;
  flex-direction: column;
}

.api-page-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(520px, 1.4fr);
  align-items: start;
  gap: 18px;
}

.api-key-form {
  max-width: 560px;
}

.api-key-box {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}

.api-key-box code {
  flex: 1;
  overflow-wrap: anywhere;
  color: var(--text);
}

.api-mini-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8fafd;
}

.api-mini-card small {
  color: var(--muted);
  line-height: 1.45;
}

.api-docs {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.api-docs pre {
  overflow: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8fafd;
  white-space: pre;
  max-width: 100%;
  font-size: 13px;
  line-height: 1.55;
}

.api-doc-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.api-doc-section h3 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
}

.api-doc-section p {
  margin: 0;
}

.api-limit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px;
}

.api-limit-grid span {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8fafd;
}

.api-limit-grid small {
  color: var(--muted);
}

@media (max-width: 1100px) {
  .api-page-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .api-limit-grid {
    grid-template-columns: 1fr;
  }
}

.dashboard-header {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  margin-bottom: 14px;
}

.dashboard-header h1 {
  font-size: 24px;
  margin-bottom: 4px;
}

.dashboard-header p {
  margin: 0;
}

.dashboard-header .muted,
.dashboard-header .eyebrow {
  color: var(--muted);
}

.dashboard-header h1 {
  color: var(--text);
}

.dashboard-header .balance-box {
  display: none;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  box-shadow: none;
}

.dashboard-header .button:not(.primary) {
  background: #fff;
}

.header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.page-toolbar .muted {
  margin: 0;
}

.balance-box {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 170px;
}

.balance-box.compact {
  min-width: 104px;
  padding: 11px 14px;
}

.balance-box span,
.stat span,
.copy-block span,
.eyebrow {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.balance-box strong,
.stat strong {
  font-size: 26px;
}

.balance-box.compact strong {
  font-size: 22px;
}

.content-grid {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.content-grid > .panel {
  flex: 1 1 0;
}

.stats-row,
.pricing-grid,
.cards-grid,
.preset-picker,
.mode-picker,
.result-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.pricing-grid {
  margin-bottom: 20px;
}

.stat {
  flex: 1 1 170px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.stat:nth-child(1),
.pricing-card:nth-child(1) {
  background: #fff;
}

.stat:nth-child(2),
.pricing-card:nth-child(2) {
  background: #fff;
}

.stat:nth-child(3),
.pricing-card:nth-child(3) {
  background: #fff;
}

.pricing-card {
  flex: 1 1 260px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
}

.package-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
}

.price {
  font-size: 30px;
  font-weight: 950;
}

.generation-list,
.table-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.generation-row,
.table-list a,
.list-item,
.public-link-row,
.transaction-row {
  border: 1px solid #d9e2ef;
  border-radius: 12px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  background: #fbfdff;
}

.transaction-row {
  justify-content: space-between;
  align-items: center;
}

.transaction-meta {
  text-align: right;
  flex: 0 0 auto;
}

.positive {
  color: #10843f;
}

.negative {
  color: #b42318;
}

.public-link-row {
  align-items: center;
}

.public-links-panel {
  align-self: stretch;
}

.compact-links-list {
  max-height: 510px;
  overflow: auto;
  padding-right: 2px;
}

.public-link-row.compact {
  align-items: center;
  gap: 9px;
}

.public-link-row.compact img {
  width: 58px;
  height: 58px;
}

.public-link-row.compact .copy-row {
  gap: 7px;
}

.public-link-row.compact .copy-input {
  min-height: 36px;
  padding: 8px 10px;
}

.public-link-row img {
  width: 68px;
  height: 68px;
  object-fit: cover;
  border-radius: 12px;
}

.public-link-row > div {
  flex: 1 1 auto;
  min-width: 0;
}

.copy-input {
  margin-top: 8px;
  font-size: 13px;
}

.table {
  border-collapse: separate;
  border-spacing: 0 8px;
}

.table th {
  border-bottom: 0;
}

.table td {
  background: #fbfdff;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

.table td:first-child {
  border-left: 1px solid var(--line-soft);
  border-radius: 12px 0 0 12px;
}

.table td:last-child {
  border-right: 1px solid var(--line-soft);
  border-radius: 0 12px 12px 0;
}

.table-list a,
.list-item {
  justify-content: space-between;
  align-items: flex-start;
}

.generation-row img {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 12px;
}

.generation-row span,
.generation-card div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

small {
  color: var(--muted);
  display: block;
}

.generation-card {
  width: calc(33.333% - 11px);
  min-width: 250px;
  overflow: hidden;
  color: var(--text);
  display: flex;
  flex-direction: column;
}

.generation-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.image-placeholder {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eef4fb;
  color: var(--muted);
  font-weight: 900;
}

.generation-card div {
  padding: 14px;
}

.admin-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.admin-result-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
}

.admin-result-card > .gallery-item img {
  border: 0;
  border-radius: 0;
}

.admin-result-info {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
}

.admin-result-source {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 12px;
}

.admin-result-source span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  flex: 1 1 auto;
}

.admin-result-source .gallery-item {
  width: 54px;
  flex: 0 0 54px;
}

.admin-result-source .gallery-item img {
  aspect-ratio: 1;
  border-radius: 10px;
}

.admin-result-delete-form {
  padding: 0 12px 12px;
}

.admin-result-delete-form .mini-button {
  width: 100%;
}

.gallery-frame {
  width: calc(33.333% - 11px);
  min-width: 150px;
  position: relative;
  overflow: hidden;
  border-radius: 12px;
}

.gallery-item {
  width: 100%;
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: zoom-in;
}

.icon-action {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.76);
  background: rgba(25, 41, 87, 0.78);
  color: #fff;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}

.hide-result-button {
  left: 10px;
  right: auto;
}

.icon-action:hover {
  background: var(--accent);
}

.icon-action:disabled {
  opacity: 0.72;
  cursor: wait;
}

.image-loader {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: rgba(17, 24, 39, 0.54);
  color: #fff;
  border-radius: 12px;
  text-align: center;
}

.gallery-frame.is-regenerating .gallery-item img {
  filter: blur(1.5px);
  transform: scale(1.01);
}

.gallery-frame.is-hidden-result .gallery-item img {
  filter: grayscale(0.65) opacity(0.48);
}

.gallery-frame.is-hidden-result::after {
  content: "Приховано з ZIP";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  padding: 7px 9px;
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.72);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.spinner.compact {
  width: 28px;
  height: 28px;
  border-color: rgba(255, 255, 255, 0.36);
  border-top-color: #fff;
}

.result-grid > .gallery-item {
  width: calc(33.333% - 11px);
  min-width: 150px;
}

.gallery-item img,
.result-grid > img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  display: block;
}

.gallery-item:hover img {
  border-color: var(--accent);
  box-shadow: 0 18px 42px rgba(25, 41, 87, 0.18);
}

.result-grid.single img {
  width: min(280px, 100%);
}

.public-result-panel {
  overflow: hidden;
}

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

.public-result-grid h2 {
  font-size: 22px;
}

.public-result-slot {
  min-width: 0;
}

.public-result-grid > div {
  min-width: 0;
}

.public-result-item {
  width: 100%;
  display: block;
}

.public-result-item img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  display: block;
}

.compact-result-processing {
  min-height: auto;
  aspect-ratio: 3 / 4;
  width: 100%;
  min-width: 0;
  padding: 12px;
  margin-bottom: 0;
  overflow: hidden;
}

.public-result-actions {
  display: flex;
  justify-content: center;
  margin-top: 14px;
}

.public-result-actions .button {
  width: min(360px, 100%);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 15, 25, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 76px;
}

.lightbox-figure {
  margin: 0;
  max-width: min(940px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.lightbox-figure img {
  max-width: 100%;
  max-height: calc(100vh - 110px);
  object-fit: contain;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
}

.lightbox-figure figcaption {
  color: #fff;
  font-weight: 800;
}

.lightbox-close,
.lightbox-nav {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.lightbox-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 30px;
  line-height: 1;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  width: 52px;
  height: 72px;
  border-radius: 14px;
  font-size: 48px;
  transform: translateY(-50%);
}

.lightbox-prev {
  left: 18px;
}

.lightbox-next {
  right: 18px;
}

.copy-block {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px;
  margin-bottom: 10px;
  background: #fbfdff;
}

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

.copy-row {
  margin-top: 8px;
}

.copy-row .copy-input {
  margin-top: 0;
}

.mini-button {
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.mini-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.danger-button {
  border-color: #ffcdc7;
  color: var(--danger);
}

.danger-button:hover {
  border-color: var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
}

.danger-panel {
  border-color: #ffcdc7;
  background: #fffafa;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.pagination .is-active-page {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.pagination-gap {
  color: var(--muted);
  font-weight: 800;
  padding: 0 2px;
}

.copy-block p {
  white-space: pre-line;
  margin-bottom: 0;
}

.preset-option {
  width: 150px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  background: #fff;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.preset-option:hover {
  transform: translateY(-1px);
}

.preset-option input {
  position: absolute;
  top: 11px;
  left: 11px;
  width: auto;
  min-height: auto;
}

.preset-option img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 8px;
}

.preset-option span {
  font-weight: 800;
  color: var(--text);
}

.preset-option:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(221, 132, 173, 0.18);
}

.mode-option {
  flex: 1 1 180px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fbfdff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.mode-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-option strong {
  color: var(--text);
}

.mode-option {
  position: relative;
}

.mode-option::after {
  content: "";
  position: absolute;
  top: 14px;
  right: 14px;
  width: 12px;
  height: 12px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: #fff;
}

.mode-option:has(input:checked) {
  border-color: var(--accent);
  background: linear-gradient(90deg, rgba(221, 132, 173, 0.14), rgba(221, 132, 173, 0.04));
  box-shadow: 0 0 0 3px rgba(221, 132, 173, 0.16);
}

.mode-option:has(input:checked)::after {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 3px #fff;
}

.model-source-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.model-source-option {
  position: relative;
  min-height: 38px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbfdff;
  color: var(--text);
  cursor: pointer;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.model-source-option input {
  width: auto;
  min-height: auto;
}

.model-source-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.custom-model-field {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rules-box {
  border: 1px solid #f0cf9d;
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff9ef;
  color: #5f3b09;
  font-size: 13px;
}

.rules-box strong {
  display: block;
  margin-bottom: 6px;
}

.rules-box ul {
  margin: 0;
  padding-left: 18px;
}

.rules-box li + li {
  margin-top: 4px;
}

.processing-state {
  min-height: 220px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #f8fafd;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  margin-bottom: 16px;
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

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

.search-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.table {
  width: 100%;
}

.table th,
.table td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
}

.table th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.debug {
  overflow: auto;
  background: #111827;
  color: #fff;
  padding: 14px;
  border-radius: 10px;
}

@media (max-width: 860px) {
  h1 {
    font-size: 28px;
  }

  body.mobile-menu-open {
    overflow: hidden;
  }

  .mobile-app-header {
    position: sticky;
    top: 0;
    z-index: 35;
    min-height: 64px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 8px 20px rgba(17, 29, 51, 0.05);
  }

  .mobile-brand {
    color: var(--text);
    display: flex;
    align-items: center;
    white-space: nowrap;
  }

  .mobile-brand img {
    width: 136px;
    height: auto;
    display: block;
  }

  .mobile-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }

  .mobile-credit-pill {
    min-height: 38px;
    padding: 9px 11px;
    border-radius: 999px;
    background: var(--accent-soft);
    border: 1px solid rgba(221, 132, 173, 0.24);
    color: var(--accent-dark);
    font-size: 13px;
    font-weight: 850;
    white-space: nowrap;
  }

  .mobile-menu-button {
    width: 42px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f8fbff;
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    cursor: pointer;
  }

  .mobile-menu-button span {
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: var(--text);
    display: block;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 36;
    background: rgba(8, 14, 25, 0.48);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
    display: block;
  }

  body.mobile-menu-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: min(304px, calc(100vw - 42px));
    min-height: 100vh;
    padding: 24px 12px 14px;
    border-radius: 0;
    gap: 14px;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 18px 0 38px rgba(8, 14, 25, 0.26);
    background: #fff;
  }

  body.mobile-menu-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-brand {
    padding: 0 10px 18px;
  }

  .sidebar-brand img {
    width: 142px;
  }

  .sidebar-section {
    display: block;
  }

  .side-nav {
    flex-direction: column;
    overflow: visible;
    padding-bottom: 0;
  }

  .side-nav a {
    flex: 0 0 auto;
    min-height: 30px;
    padding: 2px 12px;
  }

  .sidebar-balance,
  .sidebar-user {
    margin: 0;
  }

  .sidebar-spacer {
    display: block;
  }

  .app-main {
    margin-left: 0;
  }

  .content-topbar {
    position: static;
    min-height: auto;
    padding: 14px 16px;
  }

  .content-topbar h1 {
    font-size: 24px;
  }

  .auth-topbar {
    position: static;
    padding: 12px 14px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: min(100% - 22px, 1220px);
    border-radius: 16px;
    gap: 8px;
  }

  .nav {
    gap: 4px;
    flex: 0 0 auto;
  }

  .brand-logo img {
    width: 128px;
  }

  .nav a.nav-cta {
    padding: 9px 12px;
    font-size: 14px;
    white-space: nowrap;
  }

  .page {
    width: auto;
    margin: 0;
    padding: 14px 12px 34px;
  }

  .auth-page {
    width: min(100% - 22px, 1220px);
    margin: 18px auto 48px;
    padding: 0;
  }

  .dashboard-header,
  .page-toolbar,
  .content-grid,
  .public-shell {
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard-header {
    padding: 14px;
    background: var(--panel);
  }

  .public-panel {
    max-width: none;
  }

  .self-tryon-panel {
    padding: 0;
  }

  .public-link-row {
    flex-direction: column;
    align-items: stretch;
  }

  .tryon-upload-grid {
    grid-template-columns: 1fr;
  }

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

  .search-form {
    flex-direction: column;
    align-items: stretch;
  }

  .generation-card,
  .gallery-frame,
  .gallery-item,
  .result-grid > img,
  .preset-option {
    width: 100%;
  }

  .public-result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .public-result-panel {
    padding: 12px;
  }

  .public-result-grid h2 {
    font-size: 18px;
    margin-bottom: 8px;
  }

  .public-result-grid .gallery-item {
    width: 100%;
  }

  .compact-result-processing {
    padding: 8px;
    gap: 6px;
  }

  .compact-result-processing strong {
    font-size: 13px;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }

  .compact-result-processing .muted {
    font-size: 12px;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }

  .compact-result-processing .spinner {
    width: 34px;
    height: 34px;
  }

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

  .form-row {
    flex-direction: column;
  }

  .mode-picker {
    flex-direction: column;
  }

  .mode-option {
    flex: 1 1 auto;
  }

  .table {
    display: block;
    overflow-x: auto;
  }
}

@media (max-width: 520px) {
  .panel,
  .pricing-card {
    padding: 14px;
  }

  .preset-picker {
    grid-template-columns: 1fr;
  }

  .header-actions,
  .button {
    width: 100%;
  }

  .upload-card {
    align-items: stretch;
    flex-direction: column;
  }

  .upload-preview {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
  }

  .upload-preview.large {
    width: 100%;
  }

  .lightbox {
    padding: 64px 12px 24px;
  }

  .lightbox-nav {
    top: auto;
    bottom: 18px;
    width: 48px;
    height: 48px;
    font-size: 36px;
    transform: none;
  }

  .lightbox-prev {
    left: calc(50% - 58px);
  }

  .lightbox-next {
    right: calc(50% - 58px);
  }

  .lightbox-figure img {
    max-height: calc(100vh - 170px);
  }
}
