/* Ideogram Character Edit — редактор маски + страница */

/*
 * gen-ui задаёт .td-editor-zone { transform: translateY(0) } — из-за любого transform
 * position:fixed у #icoEditorPanel привязывается к зоне редактора, а не к viewport:
 * маска обрезается, соседние блоки (параметры, кнопка) визуально «наезжают».
 */
.page-ideogram-character #genUiEditor.td-editor-zone {
  transform: none !important;
}

.page-ideogram-character .gpt-image-layout {
  padding-bottom: 2rem;
}

.page-ideogram-character .gpt-image-layout,
.page-ideogram-character .gpt-image-container {
  max-width: 100%;
  box-sizing: border-box;
}

.ico-intro {
  font-size: 14px;
  color: #555;
  line-height: 1.5;
  margin: 0 0 1rem;
  max-width: 640px;
}

/* Промпт — та же карточка, что на Nano Banana (.td-prompt-card в gen-ui.css) */
.page-ideogram-character .td-prompt-card {
  min-width: 0;
  max-width: 100%;
}

.ico-upload-card .ico-drop-hint {
  margin: 0 0 10px;
  color: #888;
  font-weight: 400;
}

@media (max-width: 768px) {
  .ico-upload-card .ico-drop-hint {
    display: none;
  }
}

.ico-uploads-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 1rem;
}

@media (max-width: 700px) {
  .ico-uploads-row {
    grid-template-columns: 1fr;
  }
}

.ico-upload-card {
  border: 1px dashed #ccc;
  border-radius: 12px;
  padding: 14px;
  background: #fafafa;
  text-align: center;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.ico-upload-card.ico-upload-card--drag {
  border-color: #0066ff;
  background: #e8f0ff;
}

.ico-upload-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
}

.ico-upload-card p {
  margin: 0 0 10px;
  font-size: 12px;
  color: #666;
}

.ico-upload-card .ico-file-input {
  display: none;
}

.ico-upload-btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  background: #0066ff;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}

.ico-upload-btn:hover {
  background: #0052cc;
}

.ico-url-ok {
  font-size: 12px;
  color: #0a0;
  margin-top: 8px;
  word-break: break-all;
}

.ico-editor-panel {
  display: none;
  margin: 1rem 0;
  padding: 16px;
  background: #f4f6f9;
  border-radius: 16px;
  border: 1px solid #e2e6ec;
}

.ico-editor-panel.ico-editor-panel--visible {
  display: block;
}

.ico-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.ico-toolbar label {
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ico-toolbar input[type="range"] {
  width: 100px;
}

.ico-tool-btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid #ccc;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
}

.ico-tool-btn.ico-tool-btn--active {
  border-color: #0066ff;
  background: #e8f0ff;
  color: #0066ff;
}

.ico-editor-mobile-back {
  display: none;
}

.ico-reopen-mask-wrap {
  display: none;
  margin: 0 0 1rem;
  text-align: center;
}

.page-ideogram-character.ico-mobile .ico-reopen-mask-wrap:not([hidden]) {
  display: block;
}

.ico-reopen-mask-btn {
  display: inline-block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid #0066ff;
  background: rgba(0, 102, 255, 0.08);
  color: #0066ff;
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.ico-reopen-mask-btn:active {
  background: rgba(0, 102, 255, 0.14);
}

.ico-stage-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
  margin: 0 auto;
  vertical-align: top;
  /* Не отдавать жест вертикальному скроллу панели — иначе при рисовании маска визуально «плывёт» */
  touch-action: none;
}

.ico-stage-inner {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
}

.ico-stage-inner img {
  display: block;
  max-width: 100%;
  height: auto;
  user-select: none;
  pointer-events: none;
}

.ico-mask-canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
  opacity: 0.45;
}

.ico-hint {
  font-size: 12px;
  color: #666;
  margin-top: 10px;
  max-width: 560px;
}

.ico-hint strong {
  color: #333;
}

.ico-settings-bar {
  margin-top: 1rem;
}

.ico-expand-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ico-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid #8d95a5;
  color: #5b6475;
  font-size: 11px;
  font-weight: 700;
  cursor: help;
  user-select: none;
}

.ico-tip::after {
  content: "Если галочка включена, сервис сам дополняет и обогощает ваш короткий промпт перед генерацией: добавляет детали, формулировки, иногда стиль - чтобы запрос к модели был «богаче». Если выключить - в генерацию уходит почти дословно то, что вы написали.";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(100% + 10px);
  width: min(320px, 82vw);
  padding: 10px 12px;
  border-radius: 10px;
  background: #1d2330;
  color: #fff;
  font-size: 12px;
  line-height: 1.45;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
  pointer-events: none;
  z-index: 20;
}

.ico-tip:hover::after,
.ico-tip:focus-visible::after {
  opacity: 1;
  visibility: visible;
}

.ico-fullscreen-btn {
  display: none;
}

.page-ideogram-character.ico-mobile .ico-toolbar {
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

.page-ideogram-character.ico-mobile .ico-editor-mobile-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 100%;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  font-weight: 600;
  border-color: var(--border, #ccc);
  background: var(--border-light, #f0f1f3);
  color: var(--text, #1a1a1a);
  margin-bottom: 2px;
}

.page-ideogram-character.ico-mobile .ico-stage-wrap {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
}

.page-ideogram-character.ico-mobile .ico-stage-inner {
  width: 100%;
  max-width: 100%;
}

.page-ideogram-character.ico-mobile .ico-stage-inner img {
  width: 100%;
  height: auto;
}

/* Мобилка: редактор маски — слой поверх страницы; параметры и «Сгенерировать» закреплены снизу */
@media (max-width: 768px) {
  .page-ideogram-character .td-main {
    overflow-x: hidden;
  }

  .page-ideogram-character .ico-toolbar {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .page-ideogram-character .ico-toolbar label {
    flex: 1 1 100%;
    min-width: 0;
    max-width: 100%;
  }

  .page-ideogram-character .ico-toolbar input[type="range"] {
    flex: 1;
    min-width: 0;
    max-width: 160px;
  }

  .page-ideogram-character.ico-mobile #icoEditorPanel.ico-editor-panel--visible {
    position: fixed;
    z-index: 10006;
    left: 0;
    right: 0;
    top: var(--td-header-bottom, 57px);
    bottom: calc(200px + env(safe-area-inset-bottom, 0px));
    margin: 0;
    border-radius: 0;
    border: none;
    padding: 10px 12px;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    background: var(--bg, #fff);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  }

  /* Фон не скроллится под оверлеем — убирает «лишний» вертикальный скролл и сдвиги */
  .page-ideogram-character.ico-mobile:has(#icoEditorPanel.ico-editor-panel--visible),
  html:has(.page-ideogram-character.ico-mobile #icoEditorPanel.ico-editor-panel--visible) {
    overflow: hidden;
  }

  .page-ideogram-character.ico-mobile:has(#icoEditorPanel.ico-editor-panel--visible) .td-pills-wrap.td-gen-params {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(68px + max(8px, env(safe-area-inset-bottom)));
    z-index: 10007;
    margin: 0;
    padding: 8px 12px 10px;
    background: var(--bg, #fff);
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.08);
    box-sizing: border-box;
  }

  .page-ideogram-character.ico-mobile:has(#icoEditorPanel.ico-editor-panel--visible) .td-generate-wrap {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10008;
    margin: 0;
    padding: 6px 12px max(10px, env(safe-area-inset-bottom));
    background: var(--bg, #fff);
    box-sizing: border-box;
  }

  /* Резерв снизу не нужен: body overflow:hidden, контент под оверлеем не прокручивается */
  .page-ideogram-character.ico-mobile:has(#icoEditorPanel.ico-editor-panel--visible) .td-shell {
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom, 0px));
  }
}

.page-ideogram-character.ico-mobile.ico-fs-open .ico-editor-panel {
  position: fixed;
  inset: 0;
  /* Выше шапки (10005), полос параметров и кнопки — иначе «На весь экран» остаётся под ними */
  z-index: 10050;
  background: var(--bg, #fff);
  border-radius: 0;
  border: none;
  margin: 0;
  padding: 10px;
  padding-top: max(10px, env(safe-area-inset-top, 0px));
  display: flex;
  flex-direction: column;
  bottom: 0 !important;
  top: 0 !important;
  max-height: none !important;
}

.page-ideogram-character.ico-mobile.ico-fs-open:has(#icoEditorPanel.ico-editor-panel--visible),
html:has(.page-ideogram-character.ico-mobile.ico-fs-open #icoEditorPanel.ico-editor-panel--visible) {
  overflow: hidden;
}

.page-ideogram-character.ico-mobile.ico-fs-open .ico-stage-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-ideogram-character #icoPhoto.gpt-photo {
  cursor: zoom-in;
}

.page-ideogram-character .ico-btn-generate--busy {
  pointer-events: none;
  opacity: 0.72;
}
