/* static/css/style.css */
body { 
    font-family: 'Montserrat', sans-serif; 
    background-color: #fbfaf9;
    background-image: 
        radial-gradient(circle at 15% 10%, rgba(244, 121, 32, 0.06) 0%, transparent 40%),
        radial-gradient(circle at 85% 30%, rgba(244, 121, 32, 0.08) 0%, transparent 45%),
        radial-gradient(circle at 50% 80%, rgba(244, 121, 32, 0.05) 0%, transparent 50%),
        url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23f47920' fill-opacity='0.03' fill-rule='evenodd'%3E%3Ccircle cx='20' cy='20' r='15' opacity='0.5'/%3E%3Ccircle cx='80' cy='60' r='25' opacity='0.3'/%3E%3Cpath d='M40 80c10-5 20 15 30 0s-10-25-30-10-10 15 0 10z' opacity='0.4'/%3E%3C/g%3E%3C/svg%3E");
    background-attachment: fixed;
}

h1, h2, h3, .heading-font {
    font-family: 'Onest', 'Montserrat', sans-serif;
}

/* Custom Input Styles */
select, input[type="number"], textarea {
    background-color: #fcf6f2;
    border-color: #f0dfd1;
    color: #333333;
    transition: all 0.3s ease;
}

select:focus, input[type="number"]:focus, textarea:focus {
    outline: none;
    border-color: #F47920;
    box-shadow: 0 0 0 3px rgba(244, 121, 32, 0.2);
    background-color: #fff;
}

/* Organic shape for the custom checkbox */
.organic-checkbox {
    appearance: none;
    width: 24px;
    height: 24px;
    background-color: #fcf6f2;
    border: 2px solid #f0dfd1;
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.organic-checkbox:checked {
    background-color: transparent;
    border-color: transparent;
}

.organic-checkbox:checked::after {
    content: '';
    position: absolute;
    width: 32px;
    height: 32px;
    background-color: #F47920;
    border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
    z-index: 0;
    animation: morph 3s ease-in-out infinite alternate;
}

.organic-checkbox:checked::before {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: white;
    font-size: 14px;
    z-index: 1;
}

@keyframes morph {
    0% { border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%; }
    34% { border-radius: 70% 30% 50% 50% / 30% 30% 70% 70%; }
    67% { border-radius: 100% 60% 60% 100% / 100% 100% 60% 60%; }
    100% { border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%; }
}

/* Organic Button */
.btn-organic {
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.btn-organic::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, #F47920, #e0681b);
    z-index: -1;
    transition: opacity 0.3s ease;
}

.btn-organic:hover::before {
    opacity: 0.9;
}

/* Tooltips using Tailwind classes (hover handles visibility) */
/* Emptying these as we rely on Tailwind classes like group-hover:opacity-100 now */
.splatter-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background-color: #F47920;
    color: white;
    border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
    font-size: 12px;
}

.splatter-icon-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 2px dashed #F47920;
    color: #F47920;
    border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
    font-size: 12px;
}

textarea::-webkit-scrollbar { width: 8px; }
textarea::-webkit-scrollbar-track { background: transparent; }
textarea::-webkit-scrollbar-thumb { background: #f0dfd1; border-radius: 4px; }
textarea::-webkit-scrollbar-thumb:hover { background: #F47920; }

/* General Markdown Styles */
.markdown-body h1, .markdown-body h2, .markdown-body h3 { 
    color: #333333; 
    font-weight: 800; 
    font-family: 'Onest', sans-serif;
    margin-top: 1.75em; 
    margin-bottom: 0.75em; 
    line-height: 1.3;
}
.markdown-body h1 { font-size: 1.5em; }
.markdown-body h2 { font-size: 1.25em; }
.markdown-body h3 { font-size: 1.1em; }
.markdown-body p { margin-bottom: 1em; }
.markdown-body ul { list-style-type: none; margin-left: 0; margin-bottom: 1em; padding-left: 0; }
.markdown-body ul li { 
    position: relative; 
    padding-left: 1.5em; 
    margin-bottom: 0.5em; 
}
.markdown-body ul li::before {
    content: '•';
    color: #F47920;
    font-weight: bold;
    position: absolute;
    left: 0;
    font-size: 1.2em;
    line-height: 1;
}
.markdown-body ol { list-style-type: decimal; margin-left: 1.5em; margin-bottom: 1em; }
.markdown-body li { margin-bottom: 0.35em; }
.markdown-body strong { font-weight: 700; color: #333333; }
.markdown-body em { font-style: italic; }
.markdown-body blockquote { 
    border: 2px solid #f0dfd1;
    background-color: #fcf6f2;
    padding: 1.25em 1.5em; 
    color: #555555; 
    border-radius: 12px;
    margin-top: 1.5em;
    margin-bottom: 1.5em; 
    font-style: normal;
    position: relative;
    box-shadow: 0 4px 12px rgba(0,0,0,0.02);
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.markdown-body blockquote p {
    margin-bottom: 0;
    line-height: 1.6;
}
.markdown-body blockquote p:not(:last-child) {
    margin-bottom: 0.75em;
}
.markdown-body blockquote::before {
    content: '';
    position: absolute;
    left: -2px;
    top: 20px;
    bottom: 20px;
    width: 4px;
    background-color: #F47920;
    border-radius: 0 4px 4px 0;
}

.markdown-body pre {
    border: 2px solid #f0dfd1;
    background-color: #fcf6f2;
    padding: 1.25em 1.5em; 
    color: #555555; 
    border-radius: 12px;
    margin-top: 1.75em;
    margin-bottom: 1.75em; 
    position: relative;
    box-shadow: 0 4px 12px rgba(0,0,0,0.02);
    white-space: pre-wrap; 
    word-wrap: break-word;
    overflow-wrap: break-word;
    font-family: inherit; 
    line-height: 1.6;
}
.markdown-body pre::before {
    content: '';
    position: absolute;
    left: -2px;
    top: 20px;
    bottom: 20px;
    width: 4px;
    background-color: #F47920;
    border-radius: 0 4px 4px 0;
}
.markdown-body pre code {
    font-family: inherit; 
    background: transparent;
    padding: 0;
    white-space: pre-wrap;
    color: inherit;
}
.markdown-body p code {
    background-color: #fcf6f2;
    color: #d46b08;
    padding: 0.2em 0.4em;
    border-radius: 0.25rem;
    font-family: inherit;
    font-weight: 600;
}

.markdown-body a { color: #F47920; text-decoration: underline; text-underline-offset: 2px; font-weight: 500; }
.markdown-body a:hover { color: #d96a1a; }

.step1-body p { margin-bottom: 1.25rem; }
.step1-body strong { color: #333333; font-weight: 700; }

.select-arrow {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23F47920' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M5 8l5 5 5-5'/%3e%3c/svg%3e");
    background-position: right 1rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.decorative-blob {
    position: absolute;
    width: 60px;
    height: 60px;
    background-color: #F47920;
    border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
    z-index: -1;
    opacity: 0.1;
}

/* ---------------------------------------------------------------------------
   Выбор аватара HeyGen: только обычный CSS + createElement.
   Tailwind CDN не генерирует классы из строк innerHTML — поэтому здесь
   никаких utility-классов для динамически созданных узлов.
   --------------------------------------------------------------------------- */
/* ── Avatar Modal ──────────────────────────────────────────
   Все стили карточек, вкладок, фильтра задаются INLINE через JS.
   Здесь остаются только стили для кнопок выбора аватара в формах.
   ─────────────────────────────────────────────────────────── */
#heygen-avatar-btn,
#upgrade-avatar-btn,
[id^="video-avatar-btn-"] {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ═══════════════════════════════════════════════════════════
   GENERATION TREE  —  Minimal Content Pipeline
   ═══════════════════════════════════════════════════════════ */

#result-tree { display: flex; flex-direction: column; gap: 12px; }

/* ── Анимация появления нового узла ─────────────────────── */
@keyframes tnSlideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════════════════════
   КАРТОЧКА УЗЛА
   ══════════════════════════════════════════════════════════ */
.tn {
    --tn-color: #94a3b8;
    --tn-bg:    #f8fafc;
    position: relative;
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
    transition: box-shadow 0.2s, transform 0.15s;
    overflow: visible;
}
.tn:hover          { box-shadow: 0 2px 8px rgba(0,0,0,0.08), 0 8px 24px rgba(0,0,0,0.06); }
.tn--new           { animation: tnSlideIn 0.35s ease-out; }

/* Карточка статьи — чуть крупнее */
.tn--article {
    box-shadow: 0 2px 8px rgba(59,130,246,0.1), 0 8px 32px rgba(59,130,246,0.06);
}

/* ══════════════════════════════════════════════════════════
   ЗАГОЛОВОК КАРТОЧКИ
   ══════════════════════════════════════════════════════════ */
.tn__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    cursor: pointer;
    user-select: none;
    border-radius: 20px;
    transition: background 0.15s;
    position: relative;
    min-height: 56px;
}
.tn__header:hover { background: rgba(0,0,0,0.018); }
.tn__body--hidden ~ * { display: none; }

/* Иконка в цветном круге */
.tn__icon-wrap {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: 1.5px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
    transition: transform 0.2s;
}
.tn__header:hover .tn__icon-wrap { transform: scale(1.08); }

/* Центральная группа */
.tn__center {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.tn__title-row {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}

.tn__title {
    font-weight: 700;
    font-size: 14px;
    color: #1e293b;
    line-height: 1.2;
    font-family: 'Onest', sans-serif;
}
.tn--article .tn__title { font-size: 15px; }

.tn__rename-input {
    font-size: 14px;
    font-weight: 700;
    border: 1.5px solid #e2e8f0;
    border-radius: 6px;
    padding: 2px 8px;
    outline: none;
    min-width: 120px;
    font-family: 'Onest', sans-serif;
}

/* Счётчик дочерних */
.tn__counter {
    font-size: 10px;
    font-weight: 700;
    color: var(--tn-color);
    background: var(--tn-bg);
    border: 1px solid var(--tn-color);
    border-radius: 20px;
    padding: 1px 7px;
    flex-shrink: 0;
    opacity: 0.85;
}

/* Статус */
.tn__spin-icon { color: #f59e0b; font-size: 12px; }
.tn__fail-dot  {
    width: 8px; height: 8px;
    border-radius: 50%; background: #ef4444; flex-shrink: 0;
}

/* Строка тегов */
.tn__tags {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}
.tn__tag {
    display: inline-block;
    background: var(--tn-bg);
    color: var(--tn-color);
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    white-space: nowrap;
    border: 1px solid var(--tn-color);
    opacity: 0.8;
}

/* Правая группа */
.tn__right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.tn__date-tag {
    font-size: 10px;
    color: #94a3b8;
    white-space: nowrap;
    font-weight: 500;
}
.tn__cost-tag {
    font-size: 10px;
    color: #94a3b8;
    font-weight: 600;
    white-space: nowrap;
}

/* Кнопка удаления — внизу тела карточки, всегда видима */
.tn__del-row {
    display: flex;
    justify-content: flex-end;
    padding-top: 6px;
    margin-bottom: 2px;
}
.tn__del-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    color: #cbd5e1;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 8px;
    transition: all 0.2s;
    letter-spacing: 0.2px;
}
.tn__del-btn:hover { color: #ef4444; background: #fef2f2; }

/* Стрелка раскрытия */
.tn__arrow {
    font-size: 11px;
    color: #cbd5e1;
    transition: transform 0.25s, color 0.15s;
    flex-shrink: 0;
    line-height: 1;
}
.tn__arrow--open { transform: rotate(90deg); color: var(--tn-color); }
.tn__header:hover .tn__arrow { color: var(--tn-color); }

/* ══════════════════════════════════════════════════════════
   ТЕЛО КАРТОЧКИ
   ══════════════════════════════════════════════════════════ */
.tn__body {
    padding: 0 18px 16px;
    animation: tnBodyIn 0.2s ease-out;
}
@keyframes tnBodyIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.tn__body--hidden { display: none; }

/* ── Контент узлов ──────────────────────────────────────────── */
.tn__content { margin-bottom: 4px; }

/* Текст экспертной статьи */
.tn__article-text {
    font-size: 14px;
    line-height: 1.7;
    color: #374151;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 6px;
}

.tn__expand-text-btn {
    background: none;
    border: none;
    color: #3b82f6;
    font-size: 11px;
    cursor: pointer;
    padding: 6px 0 2px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: opacity 0.15s;
}
.tn__expand-text-btn:hover { opacity: 0.75; }

/* Кнопки экспорта статьи (HTML / DOCX / PDF) */
.tn__export-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 10px 0 4px;
}
.tn__export-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
    border: 1.5px solid #e0e7ff;
    background: #f5f7ff;
    color: #4f46e5;
    cursor: pointer;
}
.tn__export-btn:hover {
    background: #e0e7ff;
    border-color: #818cf8;
    color: #3730a3;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(79,70,229,0.15);
}
.tn__export-btn i {
    font-size: 13px;
    opacity: 0.85;
}

/* Текст сценария */
.tn__script-text {
    font-size: 13px;
    line-height: 1.65;
    color: #374151;
    white-space: pre-wrap;
    background: #faf5ff;
    border-radius: 12px;
    padding: 14px 16px;
    max-height: 240px;
    overflow-y: auto;
    border: 1px solid #e9d5ff;
}

/* Аудиоплеер */
.tn__audio-player {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff7ed;
    border-radius: 12px;
    padding: 10px 14px;
    margin-bottom: 8px;
    border: 1px solid #fed7aa;
}
.tn__audio-el { flex: 1; min-width: 0; height: 34px; }
.tn__dl-btn {
    flex-shrink: 0;
    color: #f59e0b;
    font-size: 16px;
    text-decoration: none;
    transition: transform 0.15s, color 0.15s;
    opacity: 0.7;
}
.tn__dl-btn:hover { opacity: 1; transform: translateY(-1px); }

/* Иконки таймкодов (JSON / VTT) */
.tn__tc-icon {
    flex-shrink: 0;
    color: #22d3ee;
    font-size: 14px;
    text-decoration: none;
    transition: transform 0.15s, color 0.15s;
    opacity: 0.75;
}
.tn__tc-icon:hover { opacity: 1; transform: translateY(-1px); color: #06b6d4; }

/* Кнопка +таймкоды */
.tn__tc-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 6px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    color: #06b6d4;
    background: transparent;
    border: 1px solid #a5f3fc;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.tn__tc-btn:hover { background: #ecfeff; border-color: #06b6d4; }
.tn__tc-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Спиннер авто-генерации таймкодов */
.tn__tc-spin {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #6366f1;
    background: #eef2ff;
    border: 1px dashed #a5b4fc;
    padding: 4px 10px;
    border-radius: 8px;
    margin-top: 6px;
    user-select: none;
}

/* Видео */
.tn__video-wrap {
    width: 100%;
    max-width: 600px;
    margin-bottom: 10px;
    border-radius: 14px;
    overflow: hidden;
    background: #0f172a;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.tn__video-wrap--vertical  { max-width: 240px; }
.tn__video-wrap--square    { max-width: 340px; }
.tn__video-el { width: 100%; display: block; }
.tn__video-pending {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    color: #8b5cf6;
    font-size: 13px;
    font-weight: 600;
    background: #f5f3ff;
    border-radius: 12px;
    margin-bottom: 8px;
    border: 1px solid #e9d5ff;
}

.tn__video-error {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 16px;
    color: #b91c1c;
    font-size: 12px;
    background: #fef2f2;
    border-radius: 10px;
    margin-bottom: 8px;
    border: 1px solid #fecaca;
    line-height: 1.5;
    word-break: break-word;
}
.tn__video-error i { flex-shrink: 0; margin-top: 2px; }

/* Строка параметров */
.tn__param-row {
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 8px;
    font-weight: 500;
}

/* Оценка */
.tn__eval-badge {
    display: inline-flex;
    align-items: center;
    background: #fef9c3;
    border: 1px solid #fde047;
    color: #854d0e;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 8px;
    gap: 4px;
}
.tn__eval-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: 1.5px solid #e2e8f0;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 20px;
    cursor: pointer;
    margin-bottom: 8px;
    transition: all 0.2s;
}
.tn__eval-btn:hover { border-color: #f59e0b; color: #f59e0b; background: #fffbeb; }

/* Строка статистики */
.tn__stats-row {
    font-size: 10px;
    color: #94a3b8;
    padding: 6px 10px;
    background: #f8fafc;
    border-radius: 8px;
    margin-top: 8px;
    font-weight: 500;
}

/* ══════════════════════════════════════════════════════════
   СЕКЦИЯ ДОЧЕРНИХ УЗЛОВ
   ══════════════════════════════════════════════════════════ */
.tn__section { margin-top: 8px; }

/* ── Строка-разделитель с кнопкой «+» ─────────────────── */
.tn__section-label {
    --tn-next-color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0 10px;
}

/* Левая часть: иконка + текст + счётчик */
.tn__section-left {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    flex-shrink: 0;
}
.tn__section-icon {
    font-size: 9px;
    color: var(--tn-next-color);
    opacity: 0.6;
}
.tn__section-text {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--tn-next-color);
    opacity: 0.6;
}
.tn__section-count {
    font-size: 9px;
    font-weight: 700;
    color: #fff;
    background: var(--tn-next-color);
    border-radius: 20px;
    padding: 0 6px;
    min-width: 16px;
    text-align: center;
    opacity: 0.7;
    line-height: 16px;
}

/* Тонкая горизонтальная линия */
.tn__section-line {
    flex: 1;
    height: 1px;
    background: #f1f5f9;
    border-radius: 1px;
    min-width: 12px;
}

/* Контейнер дочерних карточек */
.tn__children {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-left: 14px;
    border-left: 2px solid #f1f5f9;
    margin-left: 6px;
}

/* ══════════════════════════════════════════════════════════
   КНОПКА «+» В СТРОКЕ СЕКЦИИ
   ══════════════════════════════════════════════════════════ */
.tn__section-add {
    --add-color: #94a3b8;
    --add-bg:    #f8fafc;
    position: relative;        /* для тултипа */
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px 5px 8px;
    border-radius: 20px;
    border: 1.5px solid var(--add-color);
    background: var(--add-bg);
    color: var(--add-color);
    font-size: 11px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
    opacity: 0.65;
    line-height: 1;
}
.tn__section-add:hover {
    opacity: 1;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

/* Иконка типа внутри кнопки */
.tn__section-add .fas:first-child {
    font-size: 10px;
    opacity: 0.8;
}

/* «+» рядом с иконкой */
.tn__section-add-plus {
    font-size: 9px;
    font-weight: 900;
    transition: transform 0.2s;
}
.tn__section-add:hover .tn__section-add-plus {
    transform: rotate(90deg);
}

/* ── Тултип ── */
.tn__section-add-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    padding: 6px 12px;
    border-radius: 8px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s, transform 0.15s;
    transform: translateX(-50%) translateY(4px);
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
/* Стрелка тултипа */
.tn__section-add-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1e293b;
}
.tn__section-add:hover .tn__section-add-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ═══════════════════════════════════════════════════════════
   МОДАЛЬНОЕ ОКНО ГЕНЕРАЦИИ
   ═══════════════════════════════════════════════════════════ */
#generate-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
#generate-modal-content {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    animation: gmIn 0.2s ease-out;
}
@keyframes gmIn {
    from { opacity: 0; transform: scale(0.95) translateY(-10px); }
    to   { opacity: 1; transform: scale(1)    translateY(0); }
}
.gm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 14px;
    border-bottom: 1px solid #f1f5f9;
}
#gm-title {
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
    font-family: 'Onest', sans-serif;
}
.gm-close {
    background: none;
    border: none;
    font-size: 18px;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}
.gm-close:hover { color: #374151; }

#gm-body { padding: 18px 20px; }

.gm-form { display: flex; flex-direction: column; gap: 14px; }
.gm-row { display: flex; flex-direction: column; gap: 5px; }
.gm-row--2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gm-row--3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.gm-row--inline { flex-direction: row; align-items: center; gap: 10px; }

.gm-label {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.gm-input, .gm-select {
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    color: #1e293b;
    background: #f8f9fb;
    transition: border-color 0.15s;
    width: 100%;
}
.gm-input:focus, .gm-select:focus {
    outline: none;
    border-color: #6366f1;
    background: #fff;
}
.gm-range { width: 100%; accent-color: #6366f1; }
.gm-range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #94a3b8;
}
.gm-hint {
    font-size: 10px;
    color: #6366f1;
    margin: 2px 0 0;
}
.gm-hint.hidden { display: none; }
.gm-avatar-btn {
    width: 100%;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 12px;
    background: #f8f9fb;
    font-size: 13px;
    color: #374151;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: border-color 0.15s;
}
.gm-avatar-btn:hover { border-color: #6366f1; }

/* Hint icon "?" for Submagic params */
.gm-hint-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #64748b;
    font-size: 9px;
    font-weight: 800;
    cursor: help;
    margin-left: 4px;
    vertical-align: middle;
    line-height: 1;
    position: relative;
}
.gm-hint-icon:hover { background: #cbd5e1; color: #334155; }

/* Кастомный тултип через data-tooltip (заменяет нативный title) */
.gm-hint-icon[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #f1f5f9;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.45;
    padding: 7px 10px;
    border-radius: 8px;
    width: max-content;
    max-width: 220px;
    white-space: normal;
    word-break: break-word;
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.15s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.gm-hint-icon[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1e293b;
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.gm-hint-icon[data-tooltip]:hover::after,
.gm-hint-icon[data-tooltip]:hover::before {
    opacity: 1;
}

/* Montage modal: mode tabs (Auto / Smart) */
.gm-row--mode { margin-bottom: 6px; }
.gm-mode-tabs {
    display: inline-flex;
    background: #f1f5f9;
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
    margin-top: 4px;
}
.gm-mode-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}
.gm-mode-tab input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.gm-mode-tab:hover { color: #334155; }
.gm-mode-tab.is-active {
    background: #fff;
    color: #e11d48;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.gm-mode-tab.is-active i { color: #e11d48; }

/* Smart mode: Russia-only tag — accent green */
.tn__tag--russia { background: #dcfce7; color: #166534; }

/* Montage preview link */
.tn__montage-preview-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #e11d48;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 8px;
    background: #fff1f2;
    border: 1px solid #fecdd3;
    margin-bottom: 8px;
    transition: background 0.15s, color 0.15s;
}
.tn__montage-preview-link:hover { background: #ffe4e6; color: #be123c; }

/* WPM-слайдер в модальном окне */
.gm-wpm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.gm-wpm-badge {
    font-size: 15px;
    font-weight: 800;
    color: #6366f1;
    background: #eef2ff;
    border: 1.5px solid #c7d2fe;
    border-radius: 8px;
    padding: 1px 10px;
    min-width: 44px;
    text-align: center;
    font-family: 'Onest', monospace;
}
.gm-wpm-track {
    position: relative;
    padding-bottom: 28px; /* место под маркеры */
}
.gm-wpm-range { width: 100%; accent-color: #6366f1; cursor: pointer; }
.gm-wpm-marks {
    position: absolute;
    top: 22px;
    left: 0;
    right: 0;
    height: 28px;
    font-size: 9px;
    color: #94a3b8;
    pointer-events: none;
}
.gm-wpm-mark-left  { position: absolute; left: 0; }
.gm-wpm-mark-right { position: absolute; right: 0; text-align: right; }
.gm-wpm-mark-norm  {
    position: absolute;
    transform: translateX(-50%);
    text-align: center;
    line-height: 1.2;
    color: #6366f1;
    font-weight: 700;
}
.gm-wpm-mark-norm span { font-size: 8px; font-weight: 500; opacity: 0.7; }

.gm-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px 18px;
    border-top: 1px solid #f1f5f9;
}
.gm-cancel-btn {
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 18px;
    background: #fff;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
}
.gm-cancel-btn:hover { background: #f8f9fb; }
#gm-submit-btn {
    border: none;
    border-radius: 8px;
    padding: 8px 20px;
    background: #6366f1;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    transition: background 0.15s;
}
#gm-submit-btn:hover   { background: #4f46e5; }
#gm-submit-btn:disabled { background: #a5b4fc; cursor: not-allowed; }

/* ═══════════════════════════════════════════════════════════
   РЕДАКТОР ПРОМПТОВ
   ═══════════════════════════════════════════════════════════ */

/* Чипы-плейсхолдеры */
.pe-chip {
    display: inline-block;
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 11px;
    font-weight: 600;
    background: #fef3e2;
    color: #c2670a;
    border: 1.5px solid #f8d5a5;
    border-radius: 6px;
    padding: 2px 8px;
    cursor: default;
    user-select: all;
    letter-spacing: 0.01em;
}

/* Стиль-селект */
.pe-style-select {
    background-color: #fcf6f2;
    border-color: #f0dfd1;
    color: #2d1b0e;
    font-weight: 600;
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 10px;
    border-width: 2px;
    margin-bottom: 10px;
}
.pe-style-select:focus { outline: none; border-color: #f47920; }

/* Кнопки вкладок промптов */
.prompt-tab {
    transition: all 0.15s;
    cursor: pointer;
    white-space: nowrap;
}
.prompt-tab:focus { outline: none; }

/* Textarea редактора — моноширинный шрифт */
#prompt-editor-text {
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 12.5px;
    line-height: 1.65;
    background-color: #fdfdfc;
    border-color: #e8ddd4;
    color: #2d1b0e;
    min-height: 260px;
    transition: border-color 0.2s;
}
#prompt-editor-text:focus {
    border-color: #f47920;
    outline: none;
    box-shadow: 0 0 0 3px rgba(244, 121, 32, 0.12);
}

/* Кнопка-тоггл (под card 1) */
#prompt-editor-toggle {
    font-size: 11px;
    letter-spacing: 0.03em;
    opacity: 0.65;
    transition: opacity 0.15s;
}
#prompt-editor-toggle:hover { opacity: 1; }

/* Модалка пароля */
#pe-password-modal {
    animation: peModalIn 0.15s ease-out;
}
@keyframes peModalIn {
    from { opacity: 0; transform: scale(0.97); }
    to   { opacity: 1; transform: scale(1); }
}
#pe-pwd-input, #pe-pwd-name-input {
    background: #fcf6f2;
    border-color: #e8ddd4;
    transition: border-color 0.2s;
}
#pe-pwd-input:focus, #pe-pwd-name-input:focus {
    border-color: #f47920;
    outline: none;
    box-shadow: 0 0 0 3px rgba(244, 121, 32, 0.12);
}

/* Кнопка удалить — disabled состояние */
#prompt-delete-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}


/* ─── Карточка «Результаты поиска — Шаг 1» ──────────────────────────────── */
.tn-step1-card {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.05);
    border: 1px solid #e0e7ff;
    overflow: hidden;
    margin-bottom: 16px;
}

.tn-step1-card__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: #f5f7ff;
    border-bottom: 1px solid #e0e7ff;
    cursor: default;
    user-select: none;
}

.tn-step1-card__icon-wrap {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: #e0e7ff;
    color: #4f46e5;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}

.tn-step1-card__hdr-text {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.tn-step1-card__title {
    font-weight: 700;
    font-size: 13px;
    color: #3730a3;
}

.tn-step1-card__category {
    font-size: 11px;
    color: #6366f1;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 6px;
    padding: 2px 8px;
    font-weight: 600;
}

.tn-step1-card__threshold {
    font-size: 11px;
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: 6px;
    padding: 2px 8px;
    font-weight: 600;
    cursor: help;
}

.tn-step1-card__hdr-right { margin-left: auto; }

.tn-step1-card__toggle {
    background: none; border: none; cursor: pointer;
    color: #6366f1; font-size: 12px; padding: 4px 6px;
    border-radius: 6px;
    transition: background 0.15s;
}
.tn-step1-card__toggle:hover { background: #e0e7ff; }

.tn-step1-card__dl-btn {
    background: none; border: none; cursor: pointer;
    color: #6366f1; font-size: 13px; padding: 4px 7px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}
.tn-step1-card__dl-btn:hover { background: #e0e7ff; color: #4338ca; }

.tn-step1-card__body {
    padding: 14px 18px 16px;
}

/* ── Таблица статей ── */
.tn-step1-card__grid {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 12px;
}

.tn-step1-card__row {
    display: grid;
    grid-template-columns: 28px 1fr 110px 68px;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 8px;
    background: #f8fafc;
    font-size: 11.5px;
    color: #64748b;
    transition: background 0.1s;
}
.tn-step1-card__row:hover { background: #f1f5f9; }

.tn-step1-card__row--used {
    background: #f0fdf4;
    color: #166534;
}
.tn-step1-card__row--used:hover { background: #dcfce7; }

.tn-step1-card__num {
    font-weight: 700;
    color: #6366f1;
    font-size: 11px;
    text-align: right;
}
.tn-step1-card__row--used .tn-step1-card__num { color: #16a34a; }

.tn-step1-card__file {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11.5px;
}

.tn-step1-card__pct-wrap {
    display: flex;
    align-items: center;
    gap: 5px;
    position: relative;
    height: 14px;
    background: #e2e8f0;
    border-radius: 99px;
    overflow: hidden;
    width: 100%;
}
.tn-step1-card__pct-bar {
    position: absolute; left: 0; top: 0; bottom: 0;
    background: #a5b4fc;
    border-radius: 99px;
    transition: width 0.3s ease;
}
.tn-step1-card__row--used .tn-step1-card__pct-bar { background: #86efac; }
.tn-step1-card__pct-label {
    position: relative; z-index: 1;
    font-size: 10px; font-weight: 700;
    color: #334155;
    padding-left: 5px;
}

.tn-step1-card__used-badge {
    font-size: 10px; font-weight: 700;
    color: #15803d;
    background: #dcfce7;
    border: 1px solid #86efac;
    border-radius: 5px;
    padding: 1px 6px;
    white-space: nowrap;
    text-align: center;
}
.tn-step1-card__skip-badge {
    font-size: 10px; font-weight: 600;
    color: #94a3b8;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    padding: 1px 6px;
    white-space: nowrap;
    text-align: center;
}

/* ── Строка статистики ── */
.tn-step1-card__stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid #e0e7ff;
}

/* ─── Суммарная стоимость запроса (нижняя панель) ───────────────────────── */
.tn-load-error {
    padding: 12px 16px;
    margin: 8px 0;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    color: #dc2626;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tn-total-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #1e1b4b;
    border-radius: 16px;
    padding: 14px 20px;
    margin-top: 16px;
    box-shadow: 0 2px 8px rgba(30,27,75,0.18);
}

.tn-total-bar__left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 0;
}

.tn-total-bar__icon {
    color: #a5b4fc;
    font-size: 14px;
    flex-shrink: 0;
}

.tn-total-bar__label {
    font-size: 12px;
    font-weight: 700;
    color: #c7d2fe;
    white-space: nowrap;
    flex-shrink: 0;
}

.tn-total-bar__breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tn-total-bar__item {
    font-size: 11px;
    color: #818cf8;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(165,180,252,0.2);
    border-radius: 6px;
    padding: 2px 8px;
    white-space: nowrap;
}

.tn-total-bar__item strong {
    color: #e0e7ff;
    font-weight: 700;
}

.tn-total-bar__total {
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    white-space: nowrap;
    letter-spacing: -0.5px;
    flex-shrink: 0;
}

/* ─── Разделители секций формы (Текст / Аудио / Видео) ──────────────────── */
.form-section-divider {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    margin-top: 4px;
    padding: 2px 0;
    user-select: none;
}

/* Первый разделитель в форме без верхнего отступа */
.form-section-divider:first-child {
    margin-top: 0;
}

.form-section-divider__label {
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    white-space: nowrap;
    flex-shrink: 0;
}

.form-section-divider__line {
    flex: 1 1 auto;
    height: 1px;
    background: linear-gradient(to right, #e5e7eb 0%, #e5e7eb 70%, transparent 100%);
    border-radius: 1px;
}

/* ── History filters ──────────────────────────────────────────────────────── */

.history-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    border: 1.5px solid #e5e7eb;
    background: #fff;
    color: #6b7280;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
    white-space: nowrap;
    line-height: 1.4;
}

.history-filter-btn:hover {
    border-color: #F47920;
    color: #F47920;
    background: #fdf9f6;
}

.history-filter-btn.active {
    background: #F47920;
    color: #fff;
    border-color: #F47920;
    box-shadow: 0 2px 8px rgba(244, 121, 32, 0.25);
}

/* ── Node type badges on history cards ───────────────────────────────────── */

.node-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: #fdf9f6;
    color: #F47920;
    border: 1px solid #f0dfd1;
    white-space: nowrap;
}
