/* Create page (Изображения) - styles from index.html */

* {
  box-sizing: border-box;
  font-family: 'Roboto', sans-serif;
}

html {
  overflow-x: auto;
  width: 100%;
  max-width: 100vw;
}

body {
  margin: 0;
  padding: 0;
  background: #0b1020;
  color: #f5f5f5;
  height: 100vh;
  width: 100%;
  min-width: 720px;
  max-width: 100vw;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow-x: auto;
  overflow-y: hidden;
}

.page-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-columns: minmax(227px, 467px) 320px 1fr;
  grid-template-rows: 1fr auto;
  grid-template-areas:
    "center images right"
    "center generate-block recent-section";
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 16px;
  gap: 16px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.column {
  background: rgba(15, 23, 42, 0.96);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 0 30px rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.25);
  overflow: hidden;
}

.center {
  grid-area: center;
  grid-row: span 2;
  min-width: 227px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.center-bottom-spacer {
  flex-shrink: 0;
  margin-bottom: 2px;
}

.prompt-block {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.prompt-block textarea {
  flex: 1;
  min-height: 80px;
  max-height: none;
  resize: none;
}

.images-column {
  grid-area: images;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.left {
  width: 12.5%;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.right {
  grid-area: right;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
  min-height: 0;
  overflow: hidden;
}

.generate-block {
  grid-area: generate-block;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
  flex-shrink: 0;
  padding: 12px 20px;
  background: rgba(15, 23, 42, 0.96);
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 0 30px rgba(15, 23, 42, 0.9);
}
.generate-block-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin-bottom: 0;
}
.balance-text {
  flex: 1;
  min-width: 0;
  margin: 8px 0;
  font-size: 17px;
  font-weight: 400;
  color: #f5f5f5;
  line-height: 1.4;
}
.balance-text strong {
  font-weight: 700;
}

h2 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.center h2:first-child,
.images-column h2,
.right h2 {
  text-align: center;
}

label {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
  color: #cbd5f5;
}

select, input[type="text"], input[type="password"], textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.9);
  color: #e5e7eb;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

select:focus, input[type="text"]:focus, input[type="password"]:focus, textarea:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.4);
  background: rgba(15, 23, 42, 1);
}

textarea {
  resize: vertical;
  min-height: 90px;
  max-height: 220px;
}

.row {
  display: flex;
  gap: 8px;
}

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

.settings-row-resolution-format {
  gap: 40px;
  flex-wrap: nowrap;
}
.settings-row-resolution-format > div {
  flex: 0 1 auto;
  min-width: 0;
}
.settings-row-resolution-format .btn-group .btn-option {
  padding: 6px 10px;
  font-size: 12px;
  min-height: 32px;
}
.settings-row-resolution-format .label-block {
  margin-bottom: 2px;
  font-size: 12px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
}

.switch input {
  display: none;
}

.switch-slider {
  width: 34px;
  height: 18px;
  border-radius: 999px;
  background: rgba(51, 65, 85, 0.9);
  position: relative;
  transition: background 0.15s ease;
}

.switch-slider::after {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #e5e7eb;
  position: absolute;
  top: 1px;
  left: 1px;
  transition: transform 0.15s ease, background 0.15s ease;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.7);
}

.switch input:checked + .switch-slider {
  background: #22c55e;
}

.switch input:checked + .switch-slider::after {
  transform: translateX(16px);
  background: #f9fafb;
}

.btn-primary {
  width: 100%;
  border-radius: 14px;
  border: none;
  padding: 14px 18px;
  min-height: 74px;
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  color: white;
  font-weight: 600;
  font-size: 17px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 12px 30px rgba(56, 189, 248, 0.25);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: default;
  box-shadow: none;
  filter: grayscale(0.2);
}

.btn-primary.generating .btn-icon {
  animation: generating-spin 1s linear infinite;
}
.btn-primary.generating:disabled {
  opacity: 0.9;
  filter: none;
}
@keyframes generating-spin {
  to { transform: rotate(360deg); }
}

.btn-primary:not(:disabled):hover {
  transform: translateY(-1px);
  background: linear-gradient(135deg, #22c55e, #16a34a);
  box-shadow: 0 16px 40px rgba(34, 197, 94, 0.4);
  filter: brightness(1.05);
}

.btn-secondary {
  margin-top: 8px;
  width: 100%;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: rgba(15, 23, 42, 0.9);
  color: #e5e7eb;
  padding: 9px 14px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-secondary:not(:disabled):hover {
  border-color: #38bdf8;
  background: rgba(15, 23, 42, 1);
  color: #f9fafb;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
}
.result-actions .btn-secondary {
  flex: 1;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.kie-download-notice {
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(251, 191, 36, 0.15);
  border: 1px solid rgba(251, 191, 36, 0.4);
  border-radius: 8px;
  font-size: 13px;
  color: #fbbf24;
}
.kie-download-notice a {
  color: #38bdf8;
  text-decoration: underline;
}
.kie-download-notice a:hover {
  color: #7dd3fc;
}

    #downloadBtn:not(:disabled) {
  border-color: rgba(34, 197, 94, 0.6);
  color: #86efac;
}
#downloadBtn:not(:disabled):hover {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.15);
  color: #bbf7d0;
}

#shareResultBtn:not(:disabled) {
  border-color: rgba(56, 189, 248, 0.6);
  color: #7dd3fc;
}
#shareResultBtn:not(:disabled):hover {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
  color: #bae6fd;
}

#editResultBtn:not(:disabled) {
  border-color: rgba(139, 92, 246, 0.6);
  color: #c4b5fd;
}
#editResultBtn:not(:disabled):hover {
  border-color: #8b5cf6;
  background: rgba(139, 92, 246, 0.15);
  color: #ddd6fe;
}

#clearResultBtn:not(:disabled),
.btn-secondary-clear:not(:disabled) {
  border-color: rgba(244, 63, 94, 0.6);
  color: #fda4af;
}
#clearResultBtn:not(:disabled):hover,
.btn-secondary-clear:not(:disabled):hover {
  border-color: #f43f5e;
  background: rgba(244, 63, 94, 0.15);
  color: #fecdd3;
}

.label-block {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
  color: #cbd5f5;
}

.btn-group {
  display: inline-flex;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.9);
}

.btn-group .btn-option {
  padding: 8px 12px;
  min-height: 36px;
  font-size: 13px;
  border: none;
  border-right: 1px solid rgba(148, 163, 184, 0.4);
  background: transparent;
  color: #e5e7eb;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  box-sizing: border-box;
}

.btn-group .btn-option:last-child {
  border-right: none;
}

.btn-group .btn-option:hover:not(:disabled) {
  background: rgba(56, 189, 248, 0.15);
  color: #f9fafb;
}

.btn-group .btn-option.active {
  background: rgba(56, 189, 248, 0.35);
  color: #fff;
}

.btn-group .btn-option:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-group-wrap {
  flex-wrap: wrap;
}
.btn-group-wrap .btn-option {
  padding: 5px 8px;
  font-size: 12px;
  min-height: 30px;
}
#aspectRatioGroup.btn-group .btn-option {
  padding: 6px 9px;
  font-size: 12px;
  min-height: 32px;
}

.google-search-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  display: inline-flex;
  margin-right: 6px;
  vertical-align: middle;
  flex-shrink: 0;
}

.btn-primary .btn-icon,
.btn-upload-preview .btn-icon {
  margin-right: 8px;
}

.token-info {
  font-size: 13px;
  color: #a5b4fc;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(30, 64, 175, 0.35);
  border: 1px solid rgba(96, 165, 250, 0.5);
  margin-top: 4px;
}

.note {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
}

.note-warning {
  color: #fcd34d;
  background: rgba(180, 83, 9, 0.2);
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(251, 191, 36, 0.4);
  margin-top: 6px;
}

.status {
  font-size: 12px;
  color: #e5e7eb;
  min-height: 18px;
}

.status.error {
  color: #fecaca;
}

.status.ok {
  color: #bbf7d0;
}

.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  overflow-y: auto;
  flex: 1;
  padding-right: 6px;
  min-height: 0;
  align-content: flex-start;
}

.prompt-block-actions {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}
.preview-upload-row {
  display: flex;
  flex-direction: column;
  margin-top: auto;
  margin-bottom: 8px;
  flex-shrink: 0;
}
.preview-upload-buttons {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.preview-upload-buttons .btn-upload-preview,
.preview-upload-buttons .btn-secondary {
  flex: 1;
  min-width: 0;
  margin-top: 0;
  min-height: 38px;
  align-items: center;
}
.preview-upload-buttons .btn-secondary {
  transform: translateY(9px);
}
.preview-upload-spacer {
  display: block;
  height: 9px;
  flex-shrink: 0;
}
.btn-upload-preview {
  width: 100%;
  transform: translateY(9px);
  border-radius: 999px;
  border: 1px solid rgba(34, 197, 94, 0.6);
  background: rgba(15, 23, 42, 0.9);
  color: #86efac;
  padding: 9px 14px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.btn-upload-preview:hover {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.15);
  color: #bbf7d0;
}
.note-preview {
  margin-bottom: 8px;
}
.thumb-item {
  position: relative;
  flex: 0 0 calc(50% - 5px);
  width: calc(50% - 5px);
  min-width: 0;
  overflow: hidden;
  border-radius: 10px;
  cursor: grab;
  display: flex;
  flex-direction: column;
}
.thumb-item.thumb-item-first {
  flex: 0 0 100%;
  width: 100%;
  aspect-ratio: 1 / 1;
}
.thumb-item:active {
  cursor: grabbing;
}
.thumb-item.thumb-drop-here {
  background: rgba(56, 189, 248, 0.2);
  border: 2px dashed rgba(56, 189, 248, 0.7);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.15);
}
.thumb-placeholder {
  flex: 0 0 calc(50% - 5px);
  width: calc(50% - 5px);
  aspect-ratio: 1 / 1;
  min-width: 0;
  border-radius: 10px;
  border: 2px dashed rgba(56, 189, 248, 0.5);
  background: rgba(56, 189, 248, 0.12);
}
.thumb-placeholder.thumb-placeholder-large {
  flex: 0 0 100%;
  width: 100%;
  aspect-ratio: 1 / 1;
}
.thumb-item img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: #020617;
  display: block;
}
.thumb-index {
  position: absolute;
  top: 6px;
  left: 6px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.thumb-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: rgba(0, 0, 0, 0.65);
  color: #fca5a5;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.thumb-remove:hover {
  background: rgba(220, 38, 38, 0.9);
  color: #fff;
}
.thumbs img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: #020617;
}
.thumbs:has(.thumbs-empty) {
  display: flex;
  align-items: center;
  justify-content: center;
  align-content: center;
  min-height: 120px;
}

.thumbs-empty {
  font-size: 12px;
  color: #6b7280;
  text-align: center;
  padding: 8px;
  width: 100%;
  box-sizing: border-box;
}

.recent-section {
  grid-area: recent-section;
  width: 100%;
  flex-shrink: 0;
  padding: 16px;
  background: rgba(15, 23, 42, 0.96);
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 0 30px rgba(15, 23, 42, 0.9);
}

.recent-section h2 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: #94a3b8;
  text-align: center;
}

.recent-thumbs-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 0;
}
.recent-thumb-arrow {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.9);
  color: #94a3b8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.recent-thumb-arrow:hover:not(:disabled) {
  border-color: #38bdf8;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
}
.recent-thumb-arrow:disabled {
  opacity: 0.4;
  cursor: default;
}
.recent-thumb-arrow svg {
  width: 20px;
  height: 20px;
}
.recent-thumbs-wrapper .recent-thumbs {
  flex: 1;
  min-width: 0;
}

.recent-thumbs {
  display: grid;
  grid-template-columns: repeat(5, minmax(90px, 1fr));
  grid-template-rows: 1fr;
  gap: 10px;
  width: 100%;
  aspect-ratio: 5 / 1;
  min-height: 0;
}

.recent-thumb {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 90px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid rgba(148, 163, 184, 0.4);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  background: #020617;
}

.recent-thumb:hover {
  border-color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.35);
}

.recent-thumb-img-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f172a;
  border-radius: 10px;
  overflow: hidden;
}
.recent-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.recent-thumb-size {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  transform: translateY(100%);
  transition: transform 0.2s ease;
  padding: 4px 6px;
  font-size: 11px;
  color: #e2e8f0;
  background: rgba(15, 23, 42, 0.95);
  border-top: 1px solid rgba(148, 163, 184, 0.4);
  text-align: center;
  pointer-events: none;
}
.recent-thumb:hover .recent-thumb-size {
  transform: translateY(0);
}

.recent-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1e293b;
  min-height: 80px;
}
.recent-thumb-placeholder .recent-thumb-spinner {
  width: 32px;
  height: 32px;
  color: #64748b;
  animation: generating-spin 1s linear infinite;
}
.recent-thumb-placeholder .recent-thumb-spinner svg {
  width: 100%;
  height: 100%;
}
.recent-thumb-placeholder.recent-thumb-error {
  color: #f87171;
  font-size: 12px;
  text-align: center;
  padding: 8px;
}
.recent-thumb-kie-only {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
  font-size: 12px;
  color: #94a3b8;
}
.recent-thumb-kie-only .recent-thumb-kie-link {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(56, 189, 248, 0.25);
  color: #38bdf8;
  text-decoration: none;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.recent-thumb-kie-only .recent-thumb-kie-link:hover {
  background: rgba(56, 189, 248, 0.45);
  color: #e0f2fe;
}

.recent-thumb-copy-prompt {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: none;
  background: rgba(0, 0, 0, 0.65);
  color: #86efac;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.recent-thumb-copy-prompt:hover {
  background: rgba(34, 197, 94, 0.8);
  color: #fff;
}
.recent-thumb-copy-prompt svg {
  width: 14px;
  height: 14px;
}
.recent-thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: none;
  background: rgba(0, 0, 0, 0.65);
  color: #fca5a5;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.recent-thumb-remove:hover {
  background: rgba(220, 38, 38, 0.9);
  color: #fff;
}
.recent-thumb-remove svg {
  width: 14px;
  height: 14px;
}

.recent-thumb[draggable="true"] {
  cursor: grab;
}
.recent-thumb[draggable="true"]:active {
  cursor: grabbing;
}

.thumbs.drop-target {
  outline: 2px dashed rgba(56, 189, 248, 0.8);
  outline-offset: 2px;
  background: rgba(56, 189, 248, 0.08);
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.is-open {
  display: flex;
}
.modal-overlay-fullscreen {
  padding: 16px;
  align-items: stretch;
  justify-content: stretch;
}
.modal-box-fullscreen {
  max-width: none;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  border-radius: 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
}
.modal-box-wide {
  max-width: min(95vw, 960px);
  width: 100%;
}
.before-after-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}
.before-after-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}
.before-after-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.before-after-close-btn:hover {
  color: #f1f5f9;
  background: rgba(148, 163, 184, 0.2);
}
.before-after-viewer {
  flex: 1;
  min-height: calc(100vh - 80px);
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 6px;
  width: 100%;
}
.ba-compare {
  flex: 1;
  min-height: calc(100vh - 110px);
  display: flex;
  flex-direction: column;
  width: 100%;
  border-radius: 4px;
  overflow: hidden;
  background: #0f172a;
}
.ba-box {
  position: relative;
  flex: 1;
  min-height: 85vh;
  height: 85vh;
  width: 100%;
  overflow: hidden;
}
.ba-box .ba-img {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  max-width: none !important;
  max-height: none !important;
  object-fit: contain;
  object-position: center center;
  display: block;
}
.ba-box .ba-before {
  width: 200%;
  height: 100%;
}
.ba-after {
  z-index: 0;
}
.ba-clip {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  overflow: hidden;
  z-index: 1;
  pointer-events: none;
  contain: layout style;
  backface-visibility: hidden;
}
.ba-before {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  pointer-events: none;
}
.ba-divider {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 12px;
  margin-left: -6px;
  cursor: ew-resize;
  pointer-events: auto;
  z-index: 2;
  touch-action: none;
  will-change: transform;
}
.ba-divider::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  margin-left: -0.5px;
  background: #fff;
  box-shadow: 0 0 4px rgba(0,0,0,0.3);
  pointer-events: none;
}
.ba-only-after {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.ba-only-after img {
  flex: 1;
  min-height: 0;
  min-width: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}
.before-after-note {
  font-size: 13px;
  color: #94a3b8;
  margin: 0;
}
.modal-box {
  background: rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 16px;
  padding: 24px;
  min-width: 360px;
  max-width: 440px;
  width: 100%;
  box-sizing: border-box;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
}
.modal-box.modal-box-fullscreen {
  min-width: 0;
  max-width: none;
  width: 100%;
  height: 100%;
  padding: 0;
  border-radius: 16px;
}
.modal-box h3 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
  color: #e5e7eb;
}
.modal-box p {
  margin: 0 0 16px;
  font-size: 14px;
  color: #94a3b8;
  line-height: 1.5;
}
.modal-dont-ask-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #94a3b8;
  cursor: pointer;
  user-select: none;
}
.modal-dont-ask-row input {
  width: 16px;
  height: 16px;
  accent-color: #38bdf8;
}
.modal-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 10px;
  justify-content: flex-start;
}
.modal-actions .btn-secondary {
  flex: 0 0 40%;
  min-width: 0;
  width: 40%;
  box-sizing: border-box;
}
.modal-btn-confirm {
  border-color: rgba(34, 197, 94, 0.7) !important;
  background: rgba(34, 197, 94, 0.2) !important;
  color: #86efac !important;
}
.modal-btn-confirm:hover {
  background: rgba(34, 197, 94, 0.4) !important;
  border-color: #22c55e !important;
  color: #dcfce7 !important;
}
.modal-btn-cancel {
  border-color: rgba(239, 68, 68, 0.6) !important;
  background: rgba(239, 68, 68, 0.15) !important;
  color: #fca5a5 !important;
}
.modal-btn-cancel:hover {
  background: rgba(239, 68, 68, 0.35) !important;
  border-color: #ef4444 !important;
  color: #fecaca !important;
}

.output-frame-wrapper {
  flex: 1;
  min-height: min(60vh, 560px);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.output-frame {
  width: 100%;
  max-height: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: radial-gradient(circle at top, #1f2937 0, #020617 55%, #020617 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.output-frame.has-image {
  background: transparent;
  border-color: transparent;
}
.output-frame.has-image img {
  cursor: pointer;
  pointer-events: auto;
}

.output-frame img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 12px;
  transition: none;
  pointer-events: none;
}

.output-placeholder {
  font-size: 13px;
  color: #6b7280;
  text-align: center;
  padding: 12px;
}
.output-error-block {
  font-size: 14px;
  color: #fca5a5;
  text-align: center;
  padding: 16px;
  max-width: 100%;
  word-break: break-word;
}

.small-label {
  font-size: 12px;
  color: #9ca3af;
}

.api-keys-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}
.api-key-cell {
  flex: 1;
  min-width: 0;
}
.api-key-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.api-key-row input[type="text"],
.api-key-row input[type="password"] {
  flex: 1;
  min-width: 0;
}

.icon-btn {
  width: 40px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: rgba(15, 23, 42, 0.9);
  cursor: pointer;
  color: #e5e7eb;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
  user-select: none;
}

.icon-btn:hover {
  border-color: #38bdf8;
  background: rgba(15, 23, 42, 1);
  color: #f9fafb;
}

.price-info {
  font-size: 13px;
  color: #bbf7d0;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(20, 83, 45, 0.35);
  border: 1px solid rgba(34, 197, 94, 0.5);
  margin-top: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.7);
  font-size: 11px;
  color: #e5e7eb;
}

.link {
  color: #38bdf8;
  text-decoration: none;
  font-size: 11px;
}

.link:hover {
  text-decoration: underline;
}

/* Страница 3D-моделей: настройки на всю высоту; результат = высота изображения+создать; 5 последних = высота блока скачать */
.app.app--create-3d {
  grid-template-columns: minmax(227px, 467px) 320px 1fr;
  grid-template-rows: 1fr auto auto;
  grid-template-areas:
    "center images right"
    "center generate-block right"
    "center tripo-export recent-section";
  max-width: none;
}
.app.app--create-3d .column.center {
  grid-row: 1 / -1;
}
.app.app--create-3d .column.right {
  grid-row: span 2;
}
.app.app--create-3d .tripo-export-panel--column {
  grid-area: tripo-export;
  margin-top: 0;
}
.app.app--create-3d .create-3d-generate-block {
  grid-area: generate-block;
  margin-top: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}
.app.app--create-3d .images-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}
.app.app--create-3d .recent-section {
  grid-area: recent-section;
}
.app.app--create-3d .tripo-thumbs-empty {
  font-size: 13px;
  color: #64748b;
  padding: 12px;
  text-align: center;
  background: rgba(15, 23, 42, 0.4);
  border-radius: 12px;
  border: 1px dashed rgba(148, 163, 184, 0.3);
}
.app.app--create-3d .tripo-image-preview-wrap {
  margin-bottom: 0;
}
.recent-section-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 10px 0;
  color: #e2e8f0;
}
.recent-thumbs--3d {
  display: grid;
  gap: 10px;
  min-height: 100px;
}
.recent-thumbs--3d .recent-thumb-3d {
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
}
.recent-thumbs--3d .recent-thumb-3d-inner {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.recent-thumbs--3d .recent-thumb-3d model-viewer {
  width: 100%;
  height: 100%;
  --poster-color: transparent;
}
.recent-thumbs--3d .recent-thumb-3d-inner .recent-thumb-3d-placeholder {
  font-size: 12px;
  color: #64748b;
  padding: 8px;
  text-align: center;
}
.recent-thumbs--3d > .recent-thumb-3d-placeholder {
  font-size: 13px;
  color: #64748b;
  padding: 12px;
  text-align: center;
}
.recent-thumbs--3d .recent-thumb-3d-btn {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(15, 23, 42, 0.9);
  color: #e2e8f0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  transition: background 0.15s, color 0.15s;
}
.recent-thumbs--3d .recent-thumb-3d-btn:hover {
  background: rgba(30, 41, 59, 0.95);
  color: #fff;
}
.recent-thumbs--3d .recent-thumb-3d-btn--delete {
  top: 6px;
  right: 6px;
}
.recent-thumbs--3d .recent-thumb-3d-btn--delete:hover {
  background: rgba(185, 28, 28, 0.9);
  color: #fff;
}
.recent-thumbs--3d .recent-thumb-3d-btn--download {
  bottom: 6px;
  right: 6px;
}
.recent-thumbs--3d .recent-thumb-3d-btn svg {
  width: 14px;
  height: 14px;
  display: block;
}
/* Правая колонка: результат на всю высоту, под ним — панель Экспорт */
.app.app--create-3d .column.right {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.app.app--create-3d .column.right .output-frame {
  flex: 1;
  min-height: 0;
  aspect-ratio: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.app.app--create-3d .output-placeholder,
.app.app--create-3d #tripoResult {
  font-size: 13px;
  color: #94a3b8;
  text-align: center;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 200px;
}
.app.app--create-3d #tripoResult a {
  color: #38bdf8;
  word-break: break-all;
}
.tripo-viewer-wrap {
  flex: 1;
  width: 100%;
  min-height: 200px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.app.app--create-3d .tripo-viewer-wrap {
  border: none;
  border-radius: 0;
  background: none;
}
.tripo-viewer-toolbar {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}
.tripo-viewer-toolbar-label {
  font-size: 13px;
  color: #94a3b8;
}
.tripo-viewer-toolbar .btn-group { margin: 0; }
.tripo-viewer-toolbar .btn-option { padding: 6px 12px; font-size: 13px; }
.tripo-model-viewer {
  width: 100%;
  height: 100%;
  flex: 1;
  min-height: 200px;
  --poster-color: transparent;
}
/* Панель «Экспорт» под результатом */
.tripo-export-panel {
  flex-shrink: 0;
  margin-top: 16px;
  padding: 16px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.2);
}
.app.app--create-3d .tripo-export-panel--column {
  background: rgba(15, 23, 42, 0.96);
  box-shadow: 0 0 30px rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.25);
}
.tripo-export-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 4px 0;
  color: #e2e8f0;
}
.tripo-export-desc {
  margin: 0 0 12px 0;
}
.tripo-export-row {
  margin-bottom: 12px;
}
.tripo-export-row .label-block {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}
.tripo-export-actions {
  margin-top: 12px;
}
.btn-primary--export .btn-icon {
  margin-right: 6px;
}
.tripo-export-extra {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.15);
  font-size: 12px;
  color: #94a3b8;
}
.tripo-image-preview-wrap {
  margin-bottom: 8px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.4);
  max-width: 280px;
  max-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.6);
}
.tripo-image-preview {
  max-width: 100%;
  max-height: 200px;
  object-fit: contain;
  display: block;
}
.app.app--create-3d .tripo-image-block {
  margin-bottom: 4px;
}
.tripo-select,
.tripo-input-num {
  width: 100%;
  max-width: 280px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.6);
  color: #e2e8f0;
  font-size: 14px;
}
.tripo-params-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}
.tripo-params-group .label-block { margin-bottom: 0; }
.tripo-check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
}
.tripo-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #e2e8f0;
  cursor: pointer;
}
.tripo-check input { accent-color: #38bdf8; }
.tripo-image-only-options { margin-top: 8px; }
@media (max-width: 900px) {
  .app.app--create-3d {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto auto auto;
    grid-template-areas:
      "center"
      "images"
      "generate-block"
      "tripo-export"
      "right"
      "recent-section";
  }
  .app.app--create-3d .tripo-export-panel--column {
    margin-top: 16px;
  }
}

@media (max-width: 1400px) {
  .page-wrap {
    overflow-y: auto;
    overflow-x: hidden;
  }

  .app {
    grid-template-columns: minmax(227px, 1.46fr) minmax(280px, 1fr);
    grid-template-rows: auto auto auto auto;
    grid-template-areas:
      "center images"
      "center generate-block"
      "right right"
      "recent-section recent-section";
    overflow: visible;
    flex: 0 0 auto;
    min-width: 0;
  }

  .right,
  .output-frame-wrapper,
  .output-frame {
    min-width: 0;
  }

  .center {
    grid-row: span 2;
    grid-column: auto;
  }

  .right {
    grid-row: auto;
  }

  .generate-block {
    grid-area: generate-block;
  }

  .recent-section {
    grid-area: recent-section;
  }

  .app.app--create-3d {
    grid-template-columns: minmax(227px, 1.46fr) minmax(280px, 1fr);
    grid-template-areas:
      "center images"
      "center generate-block"
      "center tripo-export"
      "right right"
      "recent-section recent-section";
  }
}

@media (max-width: 940px) {
  .page-wrap {
    overflow-y: auto;
    overflow-x: hidden;
    min-width: 0;
  }

  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto auto;
    grid-template-areas:
      "center"
      "images"
      "generate-block"
      "right"
      "recent-section";
    overflow: visible;
    flex: 0 0 auto;
    min-width: 0;
  }

  .center {
    grid-row: auto;
    grid-column: auto;
    min-width: 0;
  }

  .center .left {
    min-width: 0;
  }

  .images-column {
    max-width: 100%;
    min-width: 0;
  }

  .right {
    grid-row: auto;
    min-width: 0;
  }

  .center, .left, .right, .images-column {
    width: 100%;
    min-width: 0;
  }

  .generate-block {
    grid-area: generate-block;
    min-width: 0;
  }

  .recent-section {
    grid-area: recent-section;
    min-width: 0;
  }

  .recent-thumbs-wrapper {
    min-width: 0;
  }

  .recent-thumbs {
    min-width: 0;
    grid-template-columns: repeat(2, minmax(90px, 1fr));
  }

  .column {
    min-width: 0;
  }

  .output-frame-wrapper,
  .output-frame {
    min-width: 0;
    max-width: 100%;
  }

  .output-frame {
    aspect-ratio: auto;
    max-height: min(80vh, 720px);
  }

  .right {
    overflow: hidden;
  }
}

@media (max-width: 720px) {
  .output-frame {
    max-width: 480px;
    margin: 0 auto;
  }
}


.model-select-wrap {
  width: 100%;
  position: relative;
}
#modelSelect {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.model-select-trigger {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 36px 10px 12px;
  font-size: 0.95rem;
  color: #f9fafb;
  background: rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.model-select-trigger { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.model-select-trigger .model-trigger-name { flex-shrink: 0; text-align: left; }
.model-select-trigger .model-trigger-price { flex-shrink: 0; color: #fcd34d; display: flex; align-items: center; gap: 4px; }
.model-select-trigger:hover { border-color: rgba(148, 163, 184, 0.6); }
.model-select-trigger:focus { outline: none; border-color: #38bdf8; box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2); }
.model-select-trigger[aria-expanded="true"] { border-color: #38bdf8; border-radius: 8px 8px 0 0; }
.model-select-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 100;
  background: rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  max-height: 280px;
  overflow-y: auto;
  display: none;
}
.model-select-wrap.open .model-select-dropdown { display: block; }
.model-select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  font-size: 0.95rem;
  color: #f9fafb;
  cursor: pointer;
  text-align: left;
  border: none;
  width: 100%;
  box-sizing: border-box;
  background: transparent;
}
.model-select-option:hover { background: rgba(56, 189, 248, 0.15); }
.model-select-option .model-option-name { flex-shrink: 0; }
.model-select-option .model-option-price { flex-shrink: 0; color: #fcd34d; display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.coin-stack-icon { display: inline-flex; align-items: center; justify-content: center; width: 1em; height: 1em; vertical-align: middle; color: #fcd34d; }
.coin-stack-icon svg { width: 100%; height: 100%; display: block; flex-shrink: 0; }
.balance-text .coin-stack-icon,
.balance-text strong { color: #fcd34d; }
.balance-text .coin-stack-icon { vertical-align: -0.15em; }
#generateBtn .coin-stack-icon { color: #fcd34d; }
#generateBtn .btn-cost { color: #fcd34d; display: inline-flex; align-items: center; gap: 2px; margin-left: 5px; }
#generateText { display: inline-flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 2px; }
/* Баланс в навбаре — общие стили в common.css (.nav-balance) */
