/* =========================================
     1. ОСНОВНОЙ КАРКАС МОДАЛЬНОГО ОКНА
  ========================================= */
  .vis-modal-overlay {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh; /* мобильные браузеры: без «прыжка» адресной строки */
    background-color: rgba(0, 0, 0, 0.7);
    align-items: center;
    justify-content: center;
    font-family: 'Roboto Slab', Arial, sans-serif;
    backdrop-filter: blur(3px);
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0); /* без серой «вспышки» при тапе на Android/iOS */
  }

  .vis-modal-content {
    background-color: #fff;
    border-radius: 12px;
    width: 95%;
    max-width: 1400px;
    height: 90vh;
    height: 90dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  }

  .vis-modal-header {
    padding: 20px 30px;
    background-color: #fff;
    border-bottom: 1px solid #eaeaea;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
  }

  .vis-modal-header h2 {
    margin: 0;
    font-size: 24px;
    color: #000;
    font-weight: 700;
  }

  .vis-limit-badge {
    background: #f4f6ff;
    border: 1px solid rgba(35, 0, 176, 0.15);
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 13px;
    color: #555;
    font-family: Arial, sans-serif;
    white-space: nowrap;
  }
  .vis-limit-badge #visLimitCount,
  .vis-limit-badge #visLimitTotal {
    color: #2300b0;
    font-weight: 700;
  }
  .vis-limit-label-short { display: none; }

  /* --- Таймер до следующей генерации --- */
  .vis-reset-timer {
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 12px;
    background: linear-gradient(135deg, #f4f6ff 0%, #eceaff 100%);
    border: 1px solid rgba(35, 0, 176, 0.15);
    color: #2300b0;
    font-family: 'Roboto', Arial, sans-serif;
    animation: vis-fade-in 0.35s ease-out;
    box-sizing: border-box;
  }
  .vis-reset-timer-icon { flex-shrink: 0; }
  .vis-reset-timer-body { display: flex; flex-direction: column; line-height: 1.25; }
  .vis-reset-timer-label { font-size: 12px; color: #6b6b7b; font-family: Arial, sans-serif; }
  .vis-reset-timer-time {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 1px;
    font-variant-numeric: tabular-nums;
    color: #2300b0;
  }
  .vis-theme-dark .vis-reset-timer {
    background: #262233;
    border-color: rgba(162, 145, 229, 0.25);
    color: #a291e5;
  }
  .vis-theme-dark .vis-reset-timer-label { color: #8a8699; }
  .vis-theme-dark .vis-reset-timer-time { color: #a291e5; }

  .vis-modal-close {
    background: none;
    border: none;
    font-size: 36px;
    cursor: pointer;
    color: #999;
    line-height: 1;
    padding: 0;
    width: 44px;              /* удобная зона нажатия на тач-экранах */
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin: -4px -10px -4px 0;
    border-radius: 8px;
    transition: color 0.3s;
  }

  .vis-modal-close:hover {
    color: #2300b0;
  }

  .vis-modal-body {
    display: flex;
    flex-direction: row;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }

  /* =========================================
     2. КОЛОНКИ (МЕНЮ И РЕЗУЛЬТАТ)
  ========================================= */
  .vis-modal-upload-col {
    flex: 0 0 380px;
    padding: 30px;
    overflow-y: auto;
    border-right: 1px solid #eaeaea;
    background: #fff;
    box-sizing: border-box;
  }

  .vis-modal-upload-col p {
    text-align: center;
    color: #555;
    margin-top: 0;
    margin-bottom: 30px;
    font-size: 15px;
    font-family: Arial, sans-serif;
    line-height: 1.5;
  }

  .vis-modal-result-col {
    flex: 1;
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f4f6ff;
    position: relative;
    overflow-y: auto;
    box-sizing: border-box;
  }

  .vis-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-top: auto;      /* центрируется даже при justify-content: flex-start на мобильных */
    margin-bottom: auto;
    color: #999;
    font-family: Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
  }

  #resultText {
    margin-top: 14px;
    font-weight: 700;
    color: #777;
    font-size: 16px;
  }

  /* мини-инструкция в пустом состоянии */
  .vis-steps {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
    max-width: 300px;
  }

  .vis-step {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: #888;
    line-height: 1.4;
  }

  .vis-step-num {
    width: 24px;
    height: 24px;
    flex: none;
    border-radius: 50%;
    border: 1.5px solid #c9c2ee;
    background: #fff;
    color: #2300b0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
  }

  /* =========================================
     3. ЭЛЕМЕНТЫ УПРАВЛЕНИЯ И ЗАГРУЗКИ
  ========================================= */
  .vis-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed #2300b0;
    border-radius: 8px;
    padding: 50px 20px;
    text-align: center;
    cursor: pointer;
    background: #fff;
    transition: all 0.3s ease;
  }

  .vis-dropzone:hover {
    background: #f4f6ff;
  }

  .vis-dropzone-subtitle {
    color: #888;
    font-size: 14px;
    margin-top: 8px;
    font-family: Arial, sans-serif;
  }

  #imageInput {
    display: none;
  }

  .vis-generate-btn {
    margin-top: 30px;
    background: #2300b0;
    color: #fff;
    padding: 16px 25px;
    border: none;
    cursor: pointer;
    border-radius: 5px;
    font-size: 18px;
    font-weight: 700;
    font-family: inherit;
    transition: background 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    width: 100%;
  }

  .vis-generate-btn:hover {
    background: #1a0080;
  }

  .vis-generate-btn.vis-disabled {
    background: #a291e5 !important;
    cursor: not-allowed;
    pointer-events: none;
  }

  .vis-reupload-btn {
    padding: 12px;
    background: transparent;
    color: #2300b0;
    border: 2px solid #2300b0;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    width: 100%;
  }

  .vis-reupload-btn:hover {
    background: #2300b0;
    color: #ffffff;
  }

  /* --- Выбор способа загрузки: файл или камера ---
     Кнопки в столбик на всю ширину: узкая колонка (≤380px) не вмещает
     «Сфотографировать» рядом с «Загрузить фото» — слово не переносится и распирало блок. */
  .vis-upload-choice {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    margin-top: 4px;
  }

  .vis-upload-choice-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 16px;
    border: 2px solid #2300b0;
    border-radius: 8px;
    background: #fff;
    color: #2300b0;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-sizing: border-box;
  }

  .vis-upload-choice-btn svg { flex-shrink: 0; }

  .vis-upload-choice-btn:hover {
    background: #2300b0;
    color: #fff;
  }

  .vis-dropzone-hint { margin-top: 12px; }

  /* Подсветка зоны при перетаскивании файла */
  .vis-dropzone.vis-dragover {
    background: #f4f6ff;
    border-style: solid;
    box-shadow: 0 0 0 4px rgba(35, 0, 176, 0.15);
  }

  /* --- Оверлей веб-камеры (десктоп) --- */
  .vis-camera-overlay {
    position: fixed;
    inset: 0;
    z-index: 10100;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
  }

  .vis-camera-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    max-width: 720px;
    width: 100%;
  }

  .vis-camera-box video {
    width: 100%;
    max-height: 70vh;
    max-height: 70dvh;
    border-radius: 12px;
    background: #000;
    transform: scaleX(-1);   /* зеркальное превью — как в зеркале барбершопа */
    object-fit: cover;
  }

  .vis-camera-controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
  }

  .vis-camera-snap {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    background: #2300b0;
    color: #fff;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(35, 0, 176, 0.5);
    transition: filter 0.15s ease, transform 0.15s ease;
  }
  .vis-camera-snap:hover { filter: brightness(1.15); transform: translateY(-1px); }

  .vis-camera-cancel {
    padding: 15px 24px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 10px;
    background: transparent;
    color: #fff;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
  }
  .vis-camera-cancel:hover { border-color: #fff; background: rgba(255, 255, 255, 0.1); }

  /* =========================================
     4. ШТОРКА И ФОТО (СЛАЙДЕР ДО/ПОСЛЕ)
  ========================================= */
  .vis-comparison-container {
    position: relative;
    display: grid;
    place-items: center;
    margin: 0 auto;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);

    background: transparent;
    width: 100%;

    max-height: 65vh;
    max-height: 65dvh;
    min-height: 0 !important;

    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
    /* touch-action намеренно НЕ блокируем на всём контейнере:
       иначе на телефоне нельзя проскроллить окно, коснувшись фото.
       Блокировка стоит только на ручке слайдера ниже. */
  }

  .vis-img-before, .vis-img-after {
    grid-area: 1 / 1;

    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;

    object-fit: contain !important;
    object-position: center;
    pointer-events: none;

    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
  }

  .vis-img-after {
    z-index: 2;
    clip-path: inset(0 100% 0 0);
    display: block;
  }

  .vis-slider-handle {
    position: absolute;
    top: 0;
    left: 50%;
    bottom: 0;
    width: 44px;
    transform: translateX(-50%);
    cursor: ew-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    touch-action: none; /* свайп по ручке двигает шторку, а не страницу */

    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
  }

  /* линия-разделитель, чтобы шторка читалась */
  .vis-slider-handle::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    margin-left: -1px;
    background: #fff;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.45);
  }

  .vis-slider-icon {
    position: relative;
    z-index: 1;
    width: 34px;
    height: 34px;
    background: white;
    border-radius: 50%;
    color: #2300b0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  }

  .vis-compare-label {
    position: absolute;
    top: 12px;
    z-index: 5;
    padding: 5px 12px;
    border-radius: 999px;
    font-family: Arial, sans-serif;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #fff;
    background: rgba(0, 0, 0, 0.55);
    pointer-events: none;
  }
  .vis-compare-label-after  { left: 12px; }   /* слева показывается результат */
  .vis-compare-label-before { right: 12px; }

  /* Плавное «проявление» результата после генерации */
  .vis-revealing .vis-img-after { transition: clip-path 0.9s cubic-bezier(0.22, 1, 0.36, 1); }
  .vis-revealing .vis-slider-handle { transition: left 0.9s cubic-bezier(0.22, 1, 0.36, 1); }
  .vis-compare-label { transition: opacity 0.5s ease 0.45s; }

  /* =========================================
     5. КОНСТРУКТОР СТИЛЕЙ
  ========================================= */
  .vis-constructor {
    margin-top: 20px;
    text-align: left;
    animation: vis-fade-in 0.4s ease-out;
  }

  @keyframes vis-fade-in {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  .vis-constructor-group {
    margin-bottom: 15px;
  }

  .vis-constructor-group label {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: #333;
    margin-bottom: 5px;
    font-family: Arial, sans-serif;
  }

  .vis-style-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 10px;
  }

  .vis-style-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 2px solid #eaeaea;
    border-radius: 8px;
    padding: 6px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fff;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }

  .vis-style-card img {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 4px;
    display: block;
    margin-bottom: 6px;
    flex-shrink: 0;
    background: #f4f5f7;
  }

  .vis-style-label {
    font-family: 'Roboto', Arial, sans-serif;
    font-size: 11px;
    font-weight: 600;
    color: #333333;
    line-height: 1.3;
    text-align: center;
    padding: 6px 4px;
    width: 100%;
    box-sizing: border-box;
    border-radius: 4px;
    word-wrap: break-word;
    white-space: normal;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    min-height: 34px;
  }

  .vis-style-card:hover {
    border-color: #a291e5;
  }

  .vis-style-card.active {
    border-color: #2300b0;
    background-color: #f4f6ff;
    box-shadow: 0 4px 10px rgba(35, 0, 176, 0.15);
    transform: translateY(-2px);
  }

  /* ФИКС: раньше подпись получала синюю плашку, похожую на «обрезанное» выделение текста.
     Теперь выбор показывают рамка и фон карточки, а текст просто перекрашивается. */
  .vis-style-card.active .vis-style-label {
    color: #2300b0;
  }

  /* =========================================
     5-bis. ТРИГГЕР ВЫБОРА СТИЛЯ + ГАЛЕРЕЯ-ПИКЕР
  ========================================= */
  .vis-style-trigger {
    display: flex; align-items: center; gap: 12px; width: 100%;
    margin-top: 8px; padding: 10px 12px;
    background: #fff; border: 2px solid #eaeaea; border-radius: 10px;
    cursor: pointer; text-align: left; font-family: inherit; box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  }
  .vis-style-trigger:hover { border-color: #a291e5; background: #faf9ff; }
  .vis-style-trigger.vis-trigger-selected { border-color: #2300b0; background: #f4f6ff; }
  .vis-trigger-thumb {
    flex: 0 0 auto; width: 46px; height: 46px; border-radius: 8px;
    background: #f0f0f4; color: #a291e5; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
  }
  .vis-trigger-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .vis-trigger-thumb svg { width: 22px; height: 22px; }
  .vis-trigger-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
  .vis-trigger-name {
    font-family: 'Roboto', Arial, sans-serif; font-size: 14px; font-weight: 700; color: #333;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .vis-trigger-selected .vis-trigger-name { color: #2300b0; }
  .vis-trigger-sub {
    font-family: Arial, sans-serif; font-size: 11.5px; color: #999;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .vis-trigger-caret { flex: 0 0 auto; color: #b7b7c4; }

  .vis-picker-overlay {
    position: fixed; inset: 0; z-index: 10100; background: rgba(0,0,0,0.6);
    display: none; align-items: center; justify-content: center; padding: 24px;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
  }
  .vis-picker-panel {
    background: #fff; border-radius: 14px; width: 100%; max-width: 900px;
    max-height: 88vh; max-height: 88dvh; display: flex; flex-direction: column;
    overflow: hidden; box-shadow: 0 25px 60px -12px rgba(0,0,0,0.55);
    animation: vis-fade-in 0.25s ease-out;
  }
  .vis-picker-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 18px 22px; border-bottom: 1px solid #eee; flex-shrink: 0;
  }
  .vis-picker-title { font-size: 20px; font-weight: 700; color: #000; font-family: 'Roboto Slab', Arial, sans-serif; }
  .vis-picker-close {
    background: none; border: none; font-size: 32px; line-height: 1; color: #999; cursor: pointer;
    width: 40px; height: 40px; border-radius: 8px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; transition: color 0.2s;
  }
  .vis-picker-close:hover { color: #2300b0; }
  .vis-picker-tools {
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
    padding: 14px 22px; border-bottom: 1px solid #f0f0f0; flex-shrink: 0;
  }
  .vis-picker-search-wrap { position: relative; flex: 1 1 220px; min-width: 0; }
  .vis-picker-search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #b0b0bc; pointer-events: none; }
  .vis-picker-search {
    width: 100%; box-sizing: border-box; padding: 11px 14px 11px 38px;
    border: 1px solid #d8d8e0; border-radius: 9px; outline: none;
    font-size: 15px; font-family: 'Roboto', Arial, sans-serif; color: #222; transition: border-color 0.2s;
  }
  .vis-picker-search:focus { border-color: #2300b0; }
  .vis-picker-ai {
    display: flex; align-items: center; gap: 7px; flex-shrink: 0; padding: 11px 15px;
    border: 1.5px solid #2300b0; border-radius: 9px; background: #fff; color: #2300b0;
    font-family: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer;
    transition: background 0.2s, color 0.2s;
  }
  .vis-picker-ai:hover { background: #2300b0; color: #fff; }
  .vis-picker-keep {
    display: flex; align-items: center; gap: 7px; flex-shrink: 0; padding: 11px 15px;
    border: 1.5px solid #d0d0d8; border-radius: 9px; background: #fff; color: #666;
    font-family: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
  }
  .vis-picker-keep:hover { border-color: #999; color: #333; background: #f6f6f8; }
  .vis-picker-body { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; padding: 18px 22px; -webkit-overflow-scrolling: touch; }
  .vis-picker-body .vis-style-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; margin-top: 0; }
  .vis-picker-empty { text-align: center; color: #999; font-family: Arial, sans-serif; font-size: 15px; padding: 40px 0; }
  .vis-picker-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 22px; border-top: 1px solid #eee; flex-shrink: 0;
  }
  .vis-picker-hint { font-family: Arial, sans-serif; font-size: 13px; color: #999; }
  .vis-picker-done {
    padding: 11px 26px; border: none; border-radius: 9px; background: #2300b0; color: #fff;
    font-family: inherit; font-size: 15px; font-weight: 700; cursor: pointer; transition: background 0.2s;
  }
  .vis-picker-done:hover { background: #1a0080; }

  @media (max-width: 639px) {
    .vis-picker-overlay { padding: 0; }
    .vis-picker-panel { max-width: 100%; width: 100%; height: 100vh; height: 100dvh; max-height: none; border-radius: 0; }
    .vis-picker-head { padding: 14px 16px; padding-top: calc(14px + env(safe-area-inset-top)); }
    .vis-picker-tools { padding: 12px 16px; }
    .vis-picker-body { padding: 14px 16px; }
    .vis-picker-body .vis-style-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 9px; }
    .vis-picker-foot { padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  }

  .vis-theme-dark .vis-style-trigger { background: #221e2e; border-color: #332e40; }
  .vis-theme-dark .vis-style-trigger:hover { border-color: #6f5bd6; background: #262036; }
  .vis-theme-dark .vis-style-trigger.vis-trigger-selected { border-color: #a291e5; background: #2a2440; }
  .vis-theme-dark .vis-trigger-thumb { background: #2c2838; color: #a291e5; }
  .vis-theme-dark .vis-trigger-name { color: #ececf2; }
  .vis-theme-dark .vis-trigger-selected .vis-trigger-name { color: #cfc4ff; }
  .vis-theme-dark .vis-trigger-sub { color: #8a8699; }
  .vis-theme-dark .vis-picker-panel { background: #1c1926; }
  .vis-theme-dark .vis-picker-head { border-bottom-color: #302a3d; }
  .vis-theme-dark .vis-picker-title { color: #fff; }
  .vis-theme-dark .vis-picker-tools { border-bottom-color: #2a2536; }
  .vis-theme-dark .vis-picker-search { background: #262032; border-color: #3a3448; color: #ececf2; }
  .vis-theme-dark .vis-picker-search:focus { border-color: #a291e5; }
  .vis-theme-dark .vis-picker-ai { background: transparent; border-color: #a291e5; color: #cfc4ff; }
  .vis-theme-dark .vis-picker-ai:hover { background: #a291e5; color: #1c1926; }
  .vis-theme-dark .vis-picker-keep { background: transparent; border-color: #3a3548; color: #9b96ad; }
  .vis-theme-dark .vis-picker-keep:hover { border-color: #6f6a80; color: #cfc9dc; background: #262233; }
  .vis-theme-dark .vis-picker-foot { border-top-color: #302a3d; }
  .vis-theme-dark .vis-picker-hint { color: #8a8699; }


  .vis-textarea {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color 0.3s;
  }

  .vis-textarea:focus {
    outline: none;
    border-color: #2300b0;
  }

  .vis-checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    color: #2300b0;
  }

  .vis-checkbox-label input {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #2300b0;
  }

  .vis-ai-hint {
    font-size: 12px;
    color: #555;
    margin: 5px 0 0 28px;
    font-family: Arial, sans-serif;
  }

  /* =========================================
     6. ЭКРАН ЗАГРУЗКИ (ЛОАДЕР)
  ========================================= */
  .vis-loader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10050;
    backdrop-filter: blur(2px);
  }

  .vis-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top-color: #2300b0;
    border-radius: 50%;
    animation: vis-spin 1s linear infinite;
  }

  @keyframes vis-spin {
    100% { transform: rotate(360deg); }
  }

  .vis-loader-overlay p {
    margin: 18px 14px 0;
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    text-align: center;
    font-family: Arial, sans-serif;
  }

  /* =========================================
     7. КНОПКИ РЕЗУЛЬТАТА И КОММЕНТАРИЙ ИИ
  ========================================= */
  .vis-book-btn {
    background: linear-gradient(135deg, #00b957 0%, #00954a 100%);
    color: #fff !important;
    padding: 16px 20px;
    border-radius: 10px;
    font-size: 17px;
    font-weight: 700;
    text-align: center;
    text-decoration: none !important;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;   /* паддинги внутри 100% — кнопка не вылезает за край формы */
    box-shadow: 0 6px 18px rgba(0, 149, 74, 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
  }
  .vis-book-btn:hover {
    color: #fff !important;
    filter: brightness(1.06);
    transform: translateY(-2px);
    box-shadow: 0 9px 24px rgba(0, 149, 74, 0.45);
  }
  .vis-book-btn:active { transform: translateY(0); }

  /* --- Панель заявки: раскрывается на месте фото и кнопок --- */
  .vis-lead-panel {
    width: 100%;
    max-width: 500px;
    flex-direction: column;
    gap: 12px;
    animation: vis-fade-in 0.3s ease-out;
  }

  .vis-lead-back {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: #2300b0;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    padding: 6px 6px 6px 2px;
    border-radius: 6px;
    transition: color 0.15s ease;
  }
  .vis-lead-back svg { flex-shrink: 0; }
  .vis-lead-back:hover { color: #1a0080; }

  /* --- Форма заявки (имя + телефон, скидка 20%) --- */
  .vis-lead-box {
    background: linear-gradient(135deg, #f0fff7 0%, #ffffff 100%);
    border: 1px solid #b7ecce;
    border-radius: 12px;
    padding: 20px 18px;
    box-sizing: border-box;
    box-shadow: 0 8px 24px rgba(0, 149, 74, 0.14);
    animation: vis-fade-in 0.3s ease-out;   /* плавно появляется при клике по кнопке */
  }

  .vis-lead-title {
    font-size: 18px;
    font-weight: 700;
    color: #007a3d;
    margin-bottom: 6px;
  }

  .vis-lead-text {
    margin: 0 0 16px;
    font-size: 13px;
    line-height: 1.5;
    color: #4a5c50;
    font-family: Arial, sans-serif;
  }

  #leadForm {
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;   /* якорь для honeypot-поля */
  }

  .vis-lead-input {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 16px;      /* 16px — iOS не приближает страницу при фокусе */
    font-family: Arial, sans-serif;
    box-sizing: border-box;
    transition: border-color 0.2s;
    background: #fff;
    color: #222;
  }
  .vis-lead-input:focus { outline: none; border-color: #00b957; }
  .vis-lead-input.vis-input-error { border-color: #d63031; }

  .vis-lead-submit { width: 100%; border: none; font-family: inherit; cursor: pointer; }
  .vis-lead-submit:disabled { filter: grayscale(0.4) brightness(0.9); cursor: wait; transform: none; }

  .vis-lead-error {
    font-size: 13px;
    color: #d63031;
    font-family: Arial, sans-serif;
    line-height: 1.4;
  }

  .vis-lead-success {
    font-size: 14px;
    line-height: 1.55;
    color: #007a3d;
    font-family: Arial, sans-serif;
  }
  .vis-lead-success strong { font-weight: 700; }

  .vis-download-btn {
    background: #2300b0;
    color: #fff !important;
    border: none;
    padding: 15px 25px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    box-shadow: 0 6px 18px rgba(35, 0, 176, 0.3);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
  }
  .vis-download-btn:hover {
    filter: brightness(1.08);
    transform: translateY(-2px);
    box-shadow: 0 9px 24px rgba(35, 0, 176, 0.4);
  }
  .vis-download-btn:active { transform: translateY(0); }

  .vis-correct-btn {
    background: transparent;
    color: #2300b0;
    border: 2px solid #2300b0;
    padding: 14px 25px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s;
  }
  .vis-correct-btn:hover { background: #f4f6ff; }

  /* =========================================
     8. ИНФОРМАЦИОННЫЕ ПЛАШКИ (ПРЕДУПРЕЖДЕНИЯ ИИ)
  ========================================= */
  .vis-info-box {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 10px;
    font-family: 'Roboto', Arial, sans-serif;
    font-size: 12px;
    line-height: 1.45;
    margin-top: 15px;
    box-sizing: border-box;
  }

  .vis-info-general {
    background-color: #f4f6ff;
    color: #2300b0;
    border: 1px solid rgba(35, 0, 176, 0.15);
  }

  .vis-info-warning {
    background-color: #fffaf0;
    color: #b36b00;
    border: 1px solid rgba(255, 152, 0, 0.3);
  }

  .vis-info-warning strong {
    font-weight: 700;
    color: #995c00;
  }

  /* =========================================
     9. КАРТОЧКА AI-СТИЛИСТА
  ========================================= */
  .vis-premium-toggle {
    background: linear-gradient(135deg, #f4f6ff 0%, #ffffff 100%);
    border: 2px solid #2300b0;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(35, 0, 176, 0.1);
    transition: all 0.3s ease;
  }

  .vis-premium-toggle:hover {
    box-shadow: 0 6px 20px rgba(35, 0, 176, 0.15);
  }

  .vis-ai-title {
    font-size: 16px;
    font-weight: 700;
    color: #2300b0;
    user-select: none;
  }

  /* =========================================
     10. АДАПТИВНОСТЬ — БРЕЙКПОИНТЫ КАК В TILDA
         базовые стили = 1200+
  ========================================= */

  /* --- 960–1200: чуть компактнее две колонки --- */
  @media (max-width: 1199px) {
    .vis-modal-content { width: 96%; }
    .vis-modal-upload-col { flex-basis: 340px; padding: 24px; }
    .vis-modal-result-col { padding: 24px; }
    .vis-modal-header { padding: 18px 24px; }
  }

  /* --- 640–960: одна колонка, общий скролл --- */
  @media (max-width: 959px) {
    .vis-modal-content { width: 96%; height: 92vh; height: 92dvh; }
    .vis-modal-body { flex-direction: column; overflow-y: auto; }
    .vis-modal-upload-col {
      flex: none;
      width: 100%;
      border-right: none;
      border-bottom: 1px solid #eaeaea;
      padding: 24px;
      overflow-y: visible;
    }
    .vis-modal-result-col {
      flex: none;
      width: 100%;
      padding: 24px;
      min-height: 340px;
      justify-content: flex-start;   /* контент сверху вниз, чтобы не обрезался при скролле */
      overflow-y: visible;
    }
    /* главная кнопка всегда под рукой */
    .vis-generate-btn {
      position: sticky;
      bottom: 10px;
      z-index: 20;
      box-shadow: 0 0 0 6px #ffffff, 0 10px 25px rgba(35, 0, 176, 0.35);
    }
    .vis-comparison-container { max-height: 60vh; max-height: 60dvh; }
  }

  /* --- 480–640: окно на весь экран --- */
  @media (max-width: 639px) {
    .vis-modal-content { width: 100%; height: 100vh; height: 100dvh; border-radius: 0; }
    .vis-modal-header {
      padding: 12px 16px;
      padding-top: calc(12px + env(safe-area-inset-top));
      flex-wrap: wrap;
      gap: 8px 12px;
    }
    .vis-modal-header h2 { font-size: 20px; }
    .vis-limit-badge { order: 3; width: 100%; text-align: center; font-size: 12px; padding: 5px 10px; box-sizing: border-box; }
    .vis-modal-close { font-size: 30px; margin-right: -8px; }
    .vis-modal-upload-col, .vis-modal-result-col { padding: 18px 16px; }
    .vis-modal-result-col { min-height: 300px; padding-bottom: max(18px, env(safe-area-inset-bottom)); }
    .vis-modal-upload-col p { margin-bottom: 20px; }
    .vis-style-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .vis-dropzone { padding: 24px 16px; }
    .vis-dropzone-hint { display: none; }            /* drag&drop на телефоне не актуален */
    .vis-generate-btn, .vis-book-btn, .vis-download-btn, .vis-correct-btn { font-size: 16px; padding: 14px 20px; }
    .vis-comparison-container { max-height: 52vh; max-height: 52dvh; }
    .vis-textarea { font-size: 16px; }   /* iOS не приближает страницу при фокусе */
  }

  /* --- 320–480: компактные отступы и сетка 2 колонки --- */
  @media (max-width: 479px) {
    .vis-modal-header { padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top)); }
    .vis-modal-header h2 { font-size: 18px; }
    .vis-limit-label-full { display: none; }
    .vis-limit-label-short { display: inline; }
    .vis-modal-upload-col, .vis-modal-result-col { padding: 16px 13px; }
    .vis-modal-upload-col p { font-size: 14px; }
    .vis-style-grid { grid-template-columns: repeat(2, 1fr); }
    .vis-style-label { font-size: 11px; min-height: 30px; }
    .vis-generate-btn, .vis-book-btn, .vis-download-btn, .vis-correct-btn { font-size: 15px; padding: 13px 16px; }
    .vis-premium-toggle { padding: 13px; }
    .vis-ai-title { font-size: 15px; }
    .vis-compare-label { font-size: 11px; padding: 4px 10px; top: 8px; }
    .vis-compare-label-after  { left: 8px; }
    .vis-compare-label-before { right: 8px; }
  }

  /* --- запас на самые узкие (320–360) --- */
  @media (max-width: 359px) {
    .vis-modal-header h2 { font-size: 16px; }
    .vis-style-grid { gap: 6px; }
    .vis-generate-btn, .vis-book-btn, .vis-download-btn { font-size: 14px; }
    .vis-upload-choice-btn { font-size: 13px; }
  }

  /* =========================================
     11. ТЁМНАЯ ТЕМА (window.VISUALIZER_THEME = 'dark')
  ========================================= */
  .vis-theme-dark .vis-modal-content { background-color: #1d1a26; }
  .vis-theme-dark .vis-modal-header { background-color: #1d1a26; border-bottom-color: #332e40; }
  .vis-theme-dark .vis-modal-header h2 { color: #ffffff; }
  .vis-theme-dark .vis-limit-badge { background: #262233; border-color: rgba(162, 145, 229, 0.25); color: #b5b1c4; }
  .vis-theme-dark .vis-limit-badge #visLimitCount,
  .vis-theme-dark .vis-limit-badge #visLimitTotal { color: #a291e5; }
  .vis-theme-dark .vis-modal-close { color: #8a8699; }
  .vis-theme-dark .vis-modal-close:hover { color: #a291e5; }

  .vis-theme-dark .vis-modal-upload-col { background: #1d1a26; border-right-color: #332e40; }
  .vis-theme-dark .vis-modal-upload-col p { color: #b5b1c4; }
  .vis-theme-dark .vis-modal-result-col { background: #171420; }
  .vis-theme-dark .vis-empty-state { color: #8a8699; }
  .vis-theme-dark #resultText { color: #9b96ad; }
  .vis-theme-dark #placeholderIcon { stroke: #3a3548; }
  .vis-theme-dark .vis-step { color: #8a8699; }
  .vis-theme-dark .vis-step-num { border-color: #4a4166; background: #221e2e; color: #b9a8ff; }

  .vis-theme-dark .vis-dropzone { background: #221e2e; border-color: #6f5bd6; }
  .vis-theme-dark .vis-dropzone:hover { background: #2a2539; }
  .vis-theme-dark .vis-dropzone.vis-dragover { background: #2a2539; box-shadow: 0 0 0 4px rgba(162, 145, 229, 0.25); }
  .vis-theme-dark .vis-dropzone-subtitle { color: #8a8699; }
  .vis-theme-dark .vis-upload-choice-btn { background: #221e2e; border-color: #6f5bd6; color: #b9a8ff; }
  .vis-theme-dark .vis-upload-choice-btn:hover { background: #2300b0; border-color: #2300b0; color: #ffffff; }
  .vis-theme-dark .vis-reupload-btn { color: #b9a8ff; border-color: #6f5bd6; }
  .vis-theme-dark .vis-reupload-btn:hover { background: #2300b0; border-color: #2300b0; color: #ffffff; }

  .vis-theme-dark .vis-lead-back { color: #b9a8ff; }
  .vis-theme-dark .vis-lead-back:hover { color: #cfc4ff; }
  .vis-theme-dark .vis-lead-box { background: linear-gradient(135deg, #1c2c22 0%, #221e2e 100%); border-color: #00954a; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3); }
  .vis-theme-dark .vis-lead-title { color: #3ddc84; }
  .vis-theme-dark .vis-lead-text { color: #b5b1c4; }
  .vis-theme-dark .vis-lead-input { background: #221e2e; border-color: #3a3548; color: #ffffff; }
  .vis-theme-dark .vis-lead-input::placeholder { color: #6f6a80; }
  .vis-theme-dark .vis-lead-input:focus { border-color: #00b957; }
  .vis-theme-dark .vis-lead-success { color: #3ddc84; }

  .vis-theme-dark .vis-constructor-group label { color: #d9d6e4; }
  .vis-theme-dark .vis-style-card { background: #221e2e; border-color: #332e40; }
  .vis-theme-dark .vis-style-card img { background: #2c2838; }
  .vis-theme-dark .vis-style-label { color: #c9c5d8; }
  .vis-theme-dark .vis-style-card:hover { border-color: #6f5bd6; }
  .vis-theme-dark .vis-style-card.active { border-color: #a291e5; background-color: #2a2440; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35); }
  .vis-theme-dark .vis-style-card.active .vis-style-label { color: #cfc4ff; }

  .vis-theme-dark .vis-textarea { background: #221e2e; border-color: #3a3548; color: #ffffff; }
  .vis-theme-dark .vis-textarea::placeholder { color: #6f6a80; }
  .vis-theme-dark .vis-textarea:focus { border-color: #a291e5; }

  .vis-theme-dark .vis-premium-toggle { background: linear-gradient(135deg, #272046 0%, #221e2e 100%); border-color: #6f5bd6; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3); }
  .vis-theme-dark .vis-ai-title { color: #b9a8ff; }
  .vis-theme-dark .vis-checkbox-label { color: #b9a8ff; }
  .vis-theme-dark .vis-checkbox-label input { accent-color: #7c66e8; }
  .vis-theme-dark .vis-ai-hint { color: #9b96ad; }

  .vis-theme-dark .vis-info-general { background-color: #221e3a; color: #b9a8ff; border-color: rgba(162, 145, 229, 0.3); }
  .vis-theme-dark .vis-info-warning { background-color: #2e2517; color: #e0a84f; border-color: rgba(255, 152, 0, 0.35); }
  .vis-theme-dark .vis-info-warning strong { color: #f0b963; }

  .vis-theme-dark .vis-generate-btn:hover { background: #2e07d6; }
  .vis-theme-dark .vis-correct-btn { color: #b9a8ff; border-color: #6f5bd6; }
  .vis-theme-dark .vis-correct-btn:hover { background: #272046; }
  .vis-theme-dark .vis-spinner { border-color: #332e40; border-top-color: #a291e5; }

  @media (max-width: 959px) {
    .vis-theme-dark .vis-modal-upload-col { border-bottom-color: #332e40; }
    .vis-theme-dark .vis-generate-btn { box-shadow: 0 0 0 6px #1d1a26, 0 10px 25px rgba(0, 0, 0, 0.5); }
  }

/* =========================================
   ОКНО ОШИБКИ (вместо браузерного alert)
========================================= */
.vis-error-overlay {
  position: fixed;
  inset: 0;
  z-index: 10300;
  background: rgba(10, 8, 16, 0.62);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.vis-error-box {
  background: #fff;
  border-radius: 14px;
  max-width: 380px;
  width: 100%;
  padding: 26px 24px;
  text-align: center;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
  animation: vis-fade-in 0.25s ease-out;
  box-sizing: border-box;
}

.vis-error-icon { font-size: 40px; line-height: 1; }

.vis-error-title {
  margin-top: 10px;
  font-size: 17px;
  font-weight: 700;
  color: #1d1a26;
}

.vis-error-text {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.5;
  color: #555;
  font-family: Arial, sans-serif;
  word-break: break-word;
}

.vis-error-btn {
  margin-top: 18px;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 9px;
  background: #2300b0;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease;
}
.vis-error-btn:hover { background: #1a0080; }

.vis-theme-dark .vis-error-box { background: #221e2e; }
.vis-theme-dark .vis-error-title { color: #ffffff; }
.vis-theme-dark .vis-error-text { color: #b5b1c4; }
