/*
 * Новый интерфейс (ui_v2): индивидуальная программа с тренером и экран AI Тренера.
 * Правила действуют только внутри .v2 и берут цвета из токенов ui-v2.css.
 */

.v2 .v2-tp-card .v2-chip { align-self: flex-start; }
.v2 .v2-tp-card,
.v2 .v2-tp-ai { display: flex; flex-direction: column; gap: 12px; }
.v2 .v2-tp-ai { flex-direction: row; align-items: center; gap: 14px; }
.v2 .v2-tp-ai-icon {
    flex-shrink: 0; width: 48px; height: 48px; border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    background: #171717; color: var(--c-accent);
}

.v2 .v2-tp-sub { font-size: 13px; line-height: 1.4; color: var(--c-text-dim); }
.v2 .v2-tp-label { font-size: 13px; font-weight: 700; color: var(--c-text-dim); }
.v2 .v2-tp-h2 { margin: 0; font-size: 17px; font-weight: 800; }
.v2 .v2-tp-error { min-height: 0; font-size: 13px; font-weight: 700; color: var(--c-tag-text); }
.v2 .v2-tp-error:empty { display: none; }

/* Аватар и строка тренера */
.v2 .v2-tp-avatar {
    flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: #171717; color: var(--c-accent); font-weight: 800;
}
.v2 .v2-tp-avatar.is-muted { background: var(--c-track); color: var(--c-text); }
.v2 .v2-tp-trainer { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.v2 .v2-tp-trainer-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.v2 .v2-tp-trainer-name { font-size: 15px; font-weight: 800; overflow-wrap: break-word; }
.v2 .v2-tp-mini { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px; background: var(--c-surface-2); }
.v2 .v2-tp-dot { flex-shrink: 0; width: 10px; height: 10px; border-radius: 50%; background: var(--c-flame); }

/* Кнопки */
.v2 .v2-tp-actions { display: flex; gap: 10px; }
.v2 .v2-tp-cta { width: 100%; min-height: 52px; font-size: 16px; font-weight: 800; border-radius: 18px; }
.v2 .v2-tp-cta.is-grow { flex: 1; width: auto; }
.v2 .v2-tp-secondary { width: 100%; min-height: 52px; font-weight: 800; border-radius: 18px; }
.v2 .v2-tp-round {
    flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    background: var(--c-accent); color: var(--c-accent-ink);
}
.v2 .v2-tp-actions .v2-tp-round { width: 52px; height: 52px; border-radius: 18px; background: var(--c-surface-2); color: var(--c-text); border: 1px solid var(--c-line-strong); }
.v2 .v2-tp-write {
    flex-shrink: 0; min-height: 44px; padding: 0 12px; border: 0; border-radius: 22px; cursor: pointer;
    display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
    background: var(--c-accent); color: var(--c-accent-ink); font: inherit; font-size: 13px; font-weight: 800;
}
.v2 .v2-tp-soon { flex-shrink: 0; padding: 1px 6px; border-radius: 8px; background: rgba(0, 0, 0, 0.12); font-size: 10px; font-weight: 800; }
.v2 .v2-tp-adjust { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 12px; font-size: 15px; white-space: nowrap; }
.v2 .v2-tp-link { min-height: 44px; border: 0; background: none; cursor: pointer; font: inherit; font-size: 14px; font-weight: 700; color: var(--c-text); }
.v2 .v2-tp-link-inline { min-height: 0; padding: 0; text-decoration: underline; }
.v2 .v2-tp-version { padding: 5px 12px; border-radius: 12px; background: var(--c-accent); color: var(--c-accent-ink); font-size: 13px; font-weight: 800; }
.v2 .v2-tp-meta { margin-top: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.v2 .v2-tp-history { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.v2 .v2-tp-history-row { display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px; border-radius: 12px; background: var(--c-surface-2); }

/* Hero «нет заявки» */
.v2 .v2-tp-hero { background: #171717; color: #fff; border-color: transparent; display: flex; flex-direction: column; gap: 8px; padding: 20px; }
.v2 .v2-tp-hero-chip { align-self: flex-start; padding: 6px 12px; border-radius: 14px; background: var(--c-accent); color: var(--c-accent-ink); font-size: 13px; font-weight: 800; }
.v2 .v2-tp-hero-title { margin: 4px 0 0; font-size: 25px; line-height: 1.15; font-weight: 800; letter-spacing: -0.01em; color: #fff; }
.v2 .v2-tp-hero-text { font-size: 14px; line-height: 1.5; color: #d4d6d0; }
.v2 .v2-tp-hero-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 6px; }
.v2 .v2-tp-hero-step { display: flex; flex-direction: column; gap: 2px; padding: 10px; border-radius: 14px; background: #2a2a2a; font-size: 12px; line-height: 1.35; }
.v2 .v2-tp-hero-step b { color: var(--c-accent); }

/* Выбор тренера и поля */
.v2 .v2-tp-block { display: flex; flex-direction: column; gap: 10px; }
.v2 .v2-tp-radios { display: flex; flex-direction: column; gap: 8px; }
.v2 .v2-tp-radio {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 8px 14px;
    border: 1px solid var(--c-line-strong); border-radius: 18px; background: var(--c-surface);
    text-align: left; cursor: pointer; color: var(--c-text); font: inherit;
}
.v2 .v2-tp-radio.is-on { border: 2px solid var(--c-text); background: var(--c-surface-2); }
.v2 .v2-tp-radio .v2-tp-check { margin-left: auto; opacity: 0; display: flex; }
.v2 .v2-tp-radio.is-on .v2-tp-check { opacity: 1; }
.v2 .v2-tp-input { box-sizing: border-box; width: 100%; min-height: 48px; padding: 12px 14px; border-radius: 14px; font-size: 15px; resize: none; }

/* Лента статусов */
.v2 .v2-tp-timeline { list-style: none; margin: 0; padding: 20px; display: flex; flex-direction: column; }
.v2 .v2-tp-step { position: relative; display: flex; gap: 14px; padding-bottom: 18px; }
.v2 .v2-tp-step:last-child { padding-bottom: 0; }
.v2 .v2-tp-step::before { content: ""; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--c-line-strong); }
.v2 .v2-tp-step:last-child::before { display: none; }
.v2 .v2-tp-step.is-done::before { background: #171717; }
.v2 .v2-tp-dot-step {
    flex-shrink: 0; width: 28px; height: 28px; box-sizing: border-box; border-radius: 50%;
    border: 2px solid var(--c-line-strong); display: flex; align-items: center; justify-content: center;
}
.v2 .v2-tp-step.is-done .v2-tp-dot-step { background: #171717; border-color: #171717; color: var(--c-accent); }
.v2 .v2-tp-step.is-now .v2-tp-dot-step { background: var(--c-accent); border: 3px solid #171717; }
.v2 .v2-tp-step-body { display: flex; flex-direction: column; gap: 2px; }
.v2 .v2-tp-step-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 800; }
.v2 .v2-tp-step.is-todo .v2-tp-step-title { font-weight: 700; color: var(--c-text-dim); }
.v2 .v2-tp-now { padding: 3px 10px; border-radius: 10px; background: var(--c-accent); color: var(--c-accent-ink); font-size: 12px; font-weight: 800; }
.v2 .v2-tp-goal { display: flex; flex-direction: column; gap: 4px; }
.v2 .v2-tp-goal-text { font-size: 15px; font-weight: 700; overflow-wrap: anywhere; }

/* Отказ */
.v2 .v2-tp-reason { padding: 18px; border-radius: 24px; background: #fbe9dc; border: 1px solid #e7b999; color: #171717; }
.v2 .v2-tp-reason-label { font-size: 12px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: #8a3f12; }
.v2 .v2-tp-reason-text { margin-top: 6px; font-size: 16px; line-height: 1.45; font-weight: 600; overflow-wrap: anywhere; }

/* Программа готова */
.v2 .v2-tp-weekprogress { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; }
.v2 .v2-tp-bar { height: 8px; border-radius: 4px; background: var(--c-track); }
.v2 .v2-tp-bar span { display: block; height: 8px; border-radius: 4px; background: var(--c-flame); }
.v2 .v2-tp-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.v2 .v2-tp-tab { min-height: 44px; border: 0; border-radius: 14px; background: var(--c-surface); color: var(--c-text); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.v2 .v2-tp-tab.is-on { background: #171717; color: var(--c-accent); font-weight: 800; }
.v2 .v2-tp-sessions { display: flex; flex-direction: column; gap: 8px; }
.v2 .v2-tp-session { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 20px; }
.v2 .v2-tp-session.is-today { border: 2px solid #171717; }
.v2 .v2-tp-session-mark { flex-shrink: 0; width: 40px; height: 40px; box-sizing: border-box; border-radius: 12px; border: 2px solid var(--c-line-strong); display: flex; align-items: center; justify-content: center; }
.v2 .v2-tp-session.is-past .v2-tp-session-mark { background: var(--c-accent); border-color: transparent; color: var(--c-accent-ink); }
.v2 .v2-tp-session-body { flex: 1; min-width: 0; }
.v2 .v2-tp-session-title { font-size: 15px; font-weight: 800; overflow-wrap: anywhere; }

/* AI Тренер по макету: шапка, три чипа, ссылка на программу, чат, быстрые вопросы, ввод-«таблетка» */
.v2-sr { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.v2.v2-ai { display: block; box-sizing: border-box; width: 100%; min-width: 0; max-width: none; margin: 0; padding: 0 16px; border-radius: 0; background: var(--c-bg); }
.v2-aichat > *, .v2-aichat-body > * { min-width: 0; }
.v2-aichat { display: flex; flex-direction: column; min-height: 0; gap: 8px; overflow: hidden; }
.v2-aichat-head { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: 4px 0 0; }
.v2-aichat-back { flex-shrink: 0; width: 44px; height: 44px; border: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--c-surface); color: var(--c-text); cursor: pointer; }
.v2-aichat-title { flex: 1; min-width: 0; }
.v2 .v2-aichat-title h1 { margin: 0; font-size: 22px; font-weight: 800; line-height: 1.2; color: var(--c-text); }
.v2-aichat-sub { font-size: 13px; color: var(--c-text-dim); }
.v2-aichat-profile { flex-shrink: 0; min-height: 44px; padding: 0 14px; border: 0; border-radius: 22px; background: var(--c-surface); color: var(--c-text); font: inherit; font-size: 14px; font-weight: 800; cursor: pointer; }
.v2-aichat-top { flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px; }
.v2-ai-chips { display: flex; flex-wrap: nowrap; gap: 6px; align-items: center; overflow-x: auto; scrollbar-width: none; }
.v2-ai-chips::-webkit-scrollbar { display: none; }
.v2-ai-chips:empty { display: none; }
.v2-ai-chip { flex: 0 0 auto; max-width: 70%; padding: 6px 12px; border-radius: 14px; background: var(--c-surface); color: var(--c-text); font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v2-ai-handoff {
    display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; box-sizing: border-box;
    padding: 6px 8px 6px 14px; border: 0; border-radius: 18px; background: var(--c-accent); color: var(--c-accent-ink);
    font: inherit; text-align: left; cursor: pointer;
}
.v2-ai-handoff-text { flex: 1; font-size: 14px; font-weight: 800; line-height: 1.3; }
.v2-ai-handoff-arrow { flex-shrink: 0; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; }
.v2-aichat-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.v2 .v2-aichat-messages {
    flex: 1 1 auto; min-height: 0; max-height: none; margin: 0; padding: 8px 0; gap: 12px;
    display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden;
    border: 0; border-radius: 0; background: transparent; box-shadow: none;
}
.v2 .v2-aichat-messages .message { max-width: 100%; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; display: flex; }
.v2 .v2-aichat-messages .user-message { align-self: flex-end; justify-content: flex-end; max-width: 290px; }
.v2 .v2-aichat-messages .ai-message { align-self: flex-start; max-width: 320px; }
.v2 .v2-aichat-messages .message { min-width: 0; }
.v2 .v2-aichat-messages .chat-bubble { min-width: 0; max-width: 100%; box-sizing: border-box; padding: 12px 16px; font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; box-shadow: none; }
.v2 .v2-aichat-messages .user-message .chat-bubble { border-radius: 20px 20px 4px 20px; background: #171717; color: #fff; }
.v2 .v2-aichat-messages .ai-message .chat-bubble { border-radius: 4px 20px 20px 20px; background: var(--c-surface); color: var(--c-text); line-height: 1.5; padding: 14px 16px; }
.v2 .v2-aichat-messages .ai-message-content { color: inherit; }
.v2 .v2-aichat-messages .error-message { align-self: flex-start; padding: 12px 16px; border-radius: 4px 20px 20px 20px; background: var(--c-tag-bg); color: var(--c-tag-text); }
.v2 .v2-aichat-messages .ai-toolbar { display: flex; justify-content: flex-end; margin-bottom: 4px; }
.v2 .v2-aichat-messages .ai-tool-btn { min-height: 28px; padding: 0 10px; border: 0; border-radius: 10px; background: var(--c-surface-2); color: var(--c-text-dim); font-size: 12px; }
.v2-aichat-suggest { flex: 0 0 auto; display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.v2-aichat-suggest::-webkit-scrollbar { display: none; }
.v2-aichat-sug { flex: 0 0 auto; white-space: nowrap; min-height: 44px; padding: 0 16px; border: 1px solid var(--c-line-strong); border-radius: 22px; background: var(--c-surface); color: var(--c-text); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.v2-aichat-foot { flex: 0 0 auto; padding-bottom: 8px; }
.v2-aichat-composer { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 18px; border-radius: 26px; background: var(--c-surface); box-shadow: var(--shadow-card); }
.v2-aichat-composer textarea { flex: 1; min-width: 0; min-height: 0; height: 24px; max-height: 96px; box-sizing: content-box; padding: 12px 0; border: 0; outline: 0; background: transparent; color: var(--c-text); font: inherit; font-size: 16px; line-height: 24px; resize: none; }
.v2-aichat-send { flex-shrink: 0; width: 48px; height: 48px; border: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--c-accent); color: var(--c-accent-ink); cursor: pointer; }
.v2-aichat-note { margin: 6px 0 0; padding: 0; background: transparent; text-align: center; font-size: 12px; line-height: 1.4; color: var(--c-text-dim); }
.v2-aichat-note > span { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0 4px; }
.v2-aichat-composer textarea:focus, .v2-aichat-composer textarea:focus-visible { outline: none; box-shadow: none; }
.v2-aichat-composer:focus-within { outline: 2px solid var(--c-text); outline-offset: 2px; }
.v2-aichat-more { padding: 0; border: 0; background: none; font: inherit; font-weight: 700; color: var(--c-text); cursor: pointer; text-decoration: underline; }
.v2-aichat-full { margin-top: 6px; padding: 10px 12px; border-radius: 12px; background: var(--c-surface-2); text-align: left; }

/* Начатый диалог: быстрые вопросы больше не нужны; при вводе (клавиатура) верх и нижняя панель уступают место чату */
.v2-aichat-body:has(.user-message) .v2-aichat-suggest { display: none; }
.v2-aichat:focus-within .v2-aichat-top,
.v2-aichat:focus-within .v2-aichat-suggest,
.v2-aichat:focus-within .v2-aichat-sub { display: none; }
body:has(.v2-aichat-composer textarea:focus) .v2-tabbar { display: none; }
@media (max-height: 700px) {
    .v2-aichat-sub { display: none; }
    .v2-ai-handoff { min-height: 44px; }
    .v2-ai-handoff-text { font-size: 13px; }
}
@media (max-height: 600px) {
    .v2-aichat-top .v2-ai-chips { display: none; }
}
.v2 .v2-aichat-messages .ai-message-content,
.v2 .v2-aichat-messages .ai-p { overflow-wrap: anywhere; }
.v2 .v2-aichat-messages .ai-code { max-width: 100%; box-sizing: border-box; }

/* Экран AI: высоту задаёт fitAiScreen, область контента старой вёрстки не режет и не отступает */
html[data-ui='v2'] #dashboard.dashboard--ai-fill .mobile-content-area {
    bottom: 0;
    padding: 0 16px;
    overflow: visible;
}
.v2 .v2-aichat-note.ai-disclaimer { background: transparent; color: var(--c-text-dim); font-size: 12px; }
.v2-aichat-composer textarea::placeholder { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 380px) {
    .v2 .v2-tp-hero-title { font-size: 22px; }
    .v2 .v2-tp-hero-steps { gap: 6px; }
}
