/* ============================================================================
   YAZME AI PORTAL 2026 | Шторка ИИ
   ----------------------------------------------------------------------------
   Дизайн-язык: редакционный (editorial). Серифная типографика с кириллицей,
   терракотовый акцент, пульсирующая точка вместо аватара ИИ, обтекание текста
   вокруг аватаров, три темы через токены yazme-theme.css (amber/cloud/midnight).
   Заменяет critter_house.css в шторке.
   ========================================================================== */

:root {
    --ap-serif: 'Source Serif 4', 'Lora', Georgia, 'Times New Roman', serif;
    --ap-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --ap-maxw: 780px;
    --ap-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --ap-spring: cubic-bezier(0.34, 1.45, 0.5, 1);
}

/* ============================================================
   ОВЕРЛЕЙ (шторка)
   ============================================================ */
.ai-overlay-modal {
    position: fixed;
    top: 100%;
    left: 0;
    width: 100vw;
    height: 100dvh;
    z-index: 2147483640 !important;
    /* Сплошной непрозрачный фон (страхуемся от любых сторонних «стёкол») */
    background: var(--yz-bg, #262624) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-top-left-radius: 26px;
    border-top-right-radius: 26px;
    box-shadow: 0 -14px 50px rgba(0, 0, 0, 0.45);
    transition: top 0.55s cubic-bezier(0.32, 0.72, 0, 1), border-radius 0.55s ease;
    font-family: var(--ap-sans);
    color: var(--yz-text, #faf9f5);
}
.ai-overlay-modal.active { top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }

/* Полная заморозка, пока шторка закрыта */
#ai-overlay-modal:not(.active) *,
#ai-overlay-modal:not(.active)::before,
#ai-overlay-modal:not(.active)::after { animation-play-state: paused !important; }

/* Коралловое выделение текста — как у Claude */
.ai-overlay-modal ::selection { background: var(--yz-accent, #d97757); color: #fff; }
.ai-overlay-modal ::-moz-selection { background: var(--yz-accent, #d97757); color: #fff; }

/* ============================================================
   ПУЛЬСИРУЮЩАЯ ТОЧКА / АВАТАР ИИ
   ============================================================ */
@keyframes apPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 var(--yz-accent-soft, rgba(217,119,87,0.35)); }
    50% { transform: scale(1.22); box-shadow: 0 0 0 9px rgba(217, 119, 87, 0); }
}
@keyframes apPulseSoft {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.14); opacity: 0.82; }
}
.ap-dot {
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--yz-grad, linear-gradient(135deg, #e2885f, #b3552e));
    flex: 0 0 auto;
    animation: apPulse 2.2s var(--ap-ease) infinite;
}

/* Аватар ИИ в сообщении: рождается точкой, вырастает в аватар */
.ap-ai-avatar {
    float: left;
    width: 34px; height: 34px;
    margin: 3px 12px 4px 0;
    shape-outside: circle(50% at 50% 50%);
    border-radius: 50%;
    background: var(--yz-grad, linear-gradient(135deg, #e2885f, #b3552e));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px var(--yz-accent-soft, rgba(217,119,87,0.3));
    transition: transform 0.5s var(--ap-spring), border-radius 0.4s ease;
    position: relative;
}
.ap-ai-avatar svg { width: 17px; height: 17px; display: block; }
.ap-ai-avatar .ap-ai-emoji {
    position: absolute;
    right: -5px; bottom: -5px;
    width: 17px; height: 17px;
    border-radius: 50%;
    background: var(--yz-surface, #30302e);
    border: 1px solid var(--yz-border-strong, rgba(255,255,255,0.17));
    font-size: 10px;
    line-height: 15px;
    text-align: center;
    cursor: pointer;
}
/* Состояние «думает/печатает» — сжат в пульсирующую точку */
.ap-msg.ai.is-thinking .ap-ai-avatar {
    transform: scale(0.38);
    transform-origin: left center;
    animation: apPulseSoft 1.5s ease-in-out infinite;
}
.ap-msg.ai.is-thinking .ap-ai-avatar svg,
.ap-msg.ai.is-thinking .ap-ai-avatar .ap-ai-emoji { opacity: 0; }
.ap-ai-avatar svg, .ap-ai-avatar .ap-ai-emoji { transition: opacity 0.3s ease 0.15s; }

/* ============================================================
   ВЕРХНЯЯ ПАНЕЛЬ
   ============================================================ */
.ap-topbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: calc(var(--safe-top, 0px) + 10px) 14px 10px 16px;
    /* Сплошной фон — как обычная страница, без «стекла» */
    background: var(--yz-bg, #262624);
    border-bottom: 1px solid var(--yz-border, rgba(255,255,255,0.08));
    z-index: 60;
}
.ap-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
    cursor: default;
}
.ap-brand-name {
    font-family: var(--ap-serif);
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.01em;
    color: var(--yz-text);
    white-space: nowrap;
}
.ap-session-title {
    font-family: var(--ap-serif);
    font-style: italic;
    font-size: 13.5px;
    color: var(--yz-muted, #8d8878);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    padding-left: 10px;
    border-left: 1px solid var(--yz-border-strong, rgba(255,255,255,0.17));
    transition: opacity 0.4s ease;
}
.ap-session-title:empty { display: none; }

.ap-topbar-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.ap-icon-btn {
    width: 38px; height: 38px;
    border-radius: 13px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--yz-dim, #b9b4a7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.22s var(--ap-spring);
    position: relative;
    flex: 0 0 auto;
}
.ap-icon-btn:hover { background: var(--yz-surface, #30302e); border-color: var(--yz-border, rgba(255,255,255,0.08)); color: var(--yz-text); }
.ap-icon-btn:active { transform: scale(0.88); }
.ap-icon-btn.accent { color: var(--yz-accent-hi, #e88a68); }
.ap-icon-btn .ap-btn-emoji { font-size: 16px; line-height: 1; }
.ap-close-btn:hover { color: var(--yz-danger, #e5484d); }

/* Подсказка-точка на кнопке (тизер) */
.ap-teaser-dot {
    position: absolute;
    top: 4px; right: 4px;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--yz-accent, #d97757);
    animation: apPulse 1.8s infinite;
}

/* ============================================================
   ЗОНА ЧАТА
   ============================================================ */
.ap-chat-zone {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scroll-behavior: auto;
    position: relative;
}
.ap-chat-zone::-webkit-scrollbar { width: 5px; }
.ap-chat-zone::-webkit-scrollbar-thumb { background: var(--yz-border-strong); border-radius: 10px; }

.ap-thread {
    max-width: var(--ap-maxw);
    margin: 0 auto;
    padding: 26px 20px 30px;
    display: flex;
    flex-direction: column;
    gap: 26px;
}

/* ============================================================
   ПРИВЕТСТВЕННЫЙ ЭКРАН
   ============================================================ */
.ap-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: calc(100dvh - 300px);
    padding: 30px 18px 10px;
    animation: apFadeUp 0.7s var(--ap-ease) both;
}
@keyframes apFadeUp {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: none; }
}
.ap-welcome-dot {
    width: 46px; height: 46px;
    border-radius: 50%;
    background: var(--yz-grad);
    box-shadow: 0 12px 40px var(--yz-accent-soft, rgba(217,119,87,0.35));
    animation: apPulse 2.6s var(--ap-ease) infinite;
    margin-bottom: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ap-welcome-dot svg { width: 22px; height: 22px; }
.ap-welcome h1 {
    font-family: var(--ap-serif);
    font-weight: 700;
    font-size: clamp(27px, 6.4vw, 38px);
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin: 0 0 12px;
    color: var(--yz-text);
}
.ap-welcome h1 em {
    font-style: italic;
    color: var(--yz-accent-hi, #e88a68);
}
.ap-welcome-sub {
    font-family: var(--ap-serif);
    font-size: 16px;
    color: var(--yz-dim, #b9b4a7);
    margin: 0 0 30px;
    max-width: 420px;
    line-height: 1.55;
}
.ap-quick-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 22px;
}
.ap-quick-chip {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    height: 44px;
    padding: 0 19px;
    border-radius: 999px;
    border: 1px solid var(--yz-border, rgba(255,255,255,0.08));
    background: var(--yz-surface, #30302e);
    color: var(--yz-text);
    font-family: var(--ap-sans);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s var(--ap-spring);
    box-shadow: var(--yz-shadow-sm);
}
.ap-quick-chip i { color: var(--yz-accent-hi, #e88a68); font-size: 14px; }
.ap-quick-chip:hover {
    transform: translateY(-2px);
    border-color: var(--yz-accent-line, rgba(217,119,87,0.42));
    box-shadow: var(--yz-accent-glow, 0 8px 26px rgba(217,119,87,0.35));
}
.ap-quick-chip:active { transform: scale(0.95); }

.ap-invite-hint {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--yz-muted, #8d8878);
    background: transparent;
    border: 1px dashed var(--yz-border-strong, rgba(255,255,255,0.17));
    border-radius: 999px;
    padding: 9px 16px;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: var(--ap-sans);
}
.ap-invite-hint i { color: var(--yz-accent-hi); }
.ap-invite-hint:hover { color: var(--yz-text); border-color: var(--yz-accent-line); background: var(--yz-accent-soft); }

/* ============================================================
   СООБЩЕНИЯ
   ============================================================ */
.ap-msg { animation: apFadeUp 0.4s var(--ap-ease) both; position: relative; }
.ap-msg::after { content: ''; display: block; clear: both; }

/* --- Сообщение пользователя: карточка, аватар с обтеканием --- */
.ap-msg.user .ap-msg-card {
    background: var(--yz-accent-soft, rgba(217,119,87,0.14));
    border: 1px solid var(--yz-border, rgba(255,255,255,0.08));
    border-radius: 20px;
    padding: 14px 18px 14px 15px;
    overflow: hidden;
}
.ap-user-avatar {
    float: left;
    width: 32px; height: 32px;
    margin: 2px 11px 3px 0;
    shape-outside: circle(50% at 50% 50%);
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid var(--yz-border-strong, rgba(255,255,255,0.17));
    background: var(--yz-surface-2);
}
.ap-msg .ap-msg-text {
    font-family: var(--ap-serif);
    font-size: 16.5px;
    line-height: 1.68;
    color: var(--yz-text);
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-height: 24px;
}
.ap-msg.user .ap-msg-text { font-size: 16px; line-height: 1.6; white-space: pre-wrap; }

/* --- Сообщение ИИ: без пузыря, редакционная типографика --- */
.ap-msg.ai { padding: 0 2px; }
.ap-msg.ai .ap-msg-body { overflow: visible; }

/* Милая строка статуса при раздумьях */
.ap-thinking-line {
    font-family: var(--ap-serif);
    font-style: italic;
    font-size: 15px;
    color: var(--yz-muted, #8d8878);
    padding-top: 6px;
    min-height: 24px;
    transition: opacity 0.35s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}
.ap-think-text { transition: opacity 0.3s ease; }
.ap-thinking-line .ap-tdots { display: inline-flex; gap: 4px; }
.ap-thinking-line .ap-tdots span {
    width: 4px; height: 4px;
    border-radius: 50%;
    background: var(--yz-accent, #d97757);
    animation: apDots 1.2s infinite;
}
.ap-thinking-line .ap-tdots span:nth-child(2) { animation-delay: 0.15s; }
.ap-thinking-line .ap-tdots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes apDots { 0%, 100% { opacity: 0.25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }

/* Имя специалиста (бота) */
.ap-bot-label {
    font-family: var(--ap-sans);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--yz-accent-hi, #e88a68);
    margin-bottom: 5px;
}

/* ============================================================
   ТИПОГРАФИКА ОТВЕТОВ (markdown) — «газетный» стиль
   ============================================================ */
.ap-msg-text p { margin: 0 0 0.85em; }
.ap-msg-text p:last-child { margin-bottom: 0; }

.ap-msg-text h1, .ap-msg-text h2, .ap-msg-text h3, .ap-msg-text h4 {
    font-family: var(--ap-serif);
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.25;
    color: var(--yz-text);
    margin: 1.25em 0 0.5em;
}
.ap-msg-text h1:first-child, .ap-msg-text h2:first-child, .ap-msg-text h3:first-child { margin-top: 0.2em; }
.ap-msg-text h1 { font-size: 24px; }
.ap-msg-text h2 { font-size: 20.5px; }
.ap-msg-text h3 { font-size: 18px; }
.ap-msg-text h4 { font-size: 16px; text-transform: uppercase; letter-spacing: 0.05em; font-family: var(--ap-sans); font-weight: 800; color: var(--yz-dim); }

.ap-msg-text strong { font-weight: 700; color: var(--yz-text); }
.ap-msg-text em { color: var(--yz-dim); }
.ap-msg-text a { color: var(--yz-accent-hi, #e88a68); text-decoration: underline; text-decoration-color: var(--yz-accent-line); text-underline-offset: 3px; transition: 0.2s; }
.ap-msg-text a:hover { text-decoration-color: var(--yz-accent-hi); }

/* Списки: удобные и красивые */
.ap-msg-text ul, .ap-msg-text ol { margin: 0.6em 0 1em; padding-left: 6px; list-style: none; counter-reset: apList; }
.ap-msg-text li { position: relative; padding-left: 26px; margin-bottom: 0.55em; line-height: 1.62; }
.ap-msg-text li:last-child { margin-bottom: 0; }
.ap-msg-text ul > li::before {
    content: '';
    position: absolute;
    left: 6px; top: 0.62em;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--yz-accent, #d97757);
    opacity: 0.85;
}
.ap-msg-text ol > li { counter-increment: apList; }
.ap-msg-text ol > li::before {
    content: counter(apList);
    position: absolute;
    left: 0; top: 0.1em;
    font-family: var(--ap-serif);
    font-weight: 700;
    font-size: 0.92em;
    color: var(--yz-accent-hi, #e88a68);
    min-width: 20px;
}
.ap-msg-text ul ul > li::before { background: transparent; border: 1.5px solid var(--yz-accent); width: 6px; height: 6px; }
.ap-msg-text li p { margin: 0; display: inline; }

/* Цитаты */
.ap-msg-text blockquote {
    margin: 0.9em 0;
    padding: 10px 18px;
    border-left: 3px solid var(--yz-accent, #d97757);
    background: var(--yz-accent-soft, rgba(217,119,87,0.14));
    border-radius: 0 14px 14px 0;
    font-style: italic;
    color: var(--yz-dim);
}
.ap-msg-text blockquote p { margin: 0; }

/* Код */
.ap-msg-text code {
    font-family: 'SF Mono', 'JetBrains Mono', Consolas, monospace;
    font-size: 0.85em;
    background: var(--yz-accent-soft);
    color: var(--yz-accent-hi);
    padding: 2px 7px;
    border-radius: 7px;
}
.ap-msg-text pre {
    position: relative;
    margin: 0.9em 0;
    background: #1d1c1a;
    border: 1px solid var(--yz-border, rgba(255,255,255,0.08));
    border-radius: 16px;
    overflow: hidden;
}
.ap-msg-text pre code {
    display: block;
    background: transparent;
    color: #e8e6e0;
    padding: 16px 18px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.6;
    border-radius: 0;
}
.ap-code-copy {
    position: absolute;
    top: 8px; right: 8px;
    width: 30px; height: 30px;
    border-radius: 9px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.06);
    color: #b9b4a7;
    font-size: 12px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: 0.2s;
    opacity: 0;
}
.ap-msg-text pre:hover .ap-code-copy { opacity: 1; }
.ap-code-copy:hover { color: #fff; background: rgba(255,255,255,0.14); }

/* Таблицы */
.ap-msg-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.9em 0;
    font-size: 14.5px;
    font-family: var(--ap-sans);
}
.ap-msg-text th, .ap-msg-text td { padding: 9px 12px; border-bottom: 1px solid var(--yz-border); text-align: left; }
.ap-msg-text th { font-family: var(--ap-serif); font-weight: 700; color: var(--yz-text); border-bottom: 2px solid var(--yz-border-strong); }
.ap-msg-text hr { border: none; border-top: 1px solid var(--yz-border-strong); margin: 1.3em 0; }

/* Картинки/арт в сообщениях */
.ap-msg-text img, .ap-art-container img {
    max-width: min(320px, 100%);
    border-radius: 16px;
    display: block;
}
.ap-art-container {
    margin-top: 10px;
    position: relative;
    max-width: 320px;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--yz-border);
    box-shadow: var(--yz-shadow-md);
}
.ap-art-container img { cursor: zoom-in; width: 100%; }
.ap-art-actions {
    position: absolute;
    right: 8px; bottom: 8px;
    display: flex; gap: 6px;
    opacity: 0;
    transition: 0.25s;
}
.ap-art-container:hover .ap-art-actions { opacity: 1; }
.ap-art-actions a, .ap-art-actions button {
    width: 34px; height: 34px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.25);
    background: rgba(0,0,0,0.5);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 13px;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    text-decoration: none;
}

/* Вложение-файл */
.ap-file-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding: 9px 14px;
    border-radius: 14px;
    background: var(--yz-surface, #30302e);
    border: 1px solid var(--yz-border);
    font-family: var(--ap-sans);
}
.ap-file-chip i { color: var(--yz-accent-hi); font-size: 17px; }
.ap-file-chip .ap-file-name { font-size: 13px; font-weight: 600; color: var(--yz-text); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-file-chip a { font-size: 11px; color: var(--yz-accent-hi); text-decoration: none; }

/* ============================================================
   ПАНЕЛЬ ДЕЙСТВИЙ ПОД СООБЩЕНИЕМ
   ============================================================ */
.ap-action-bar {
    display: flex;
    gap: 4px;
    clear: both;
    margin-top: 9px;
    opacity: 0;
    transform: translateY(3px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.ap-msg:hover .ap-action-bar, .ap-msg:focus-within .ap-action-bar { opacity: 1; transform: none; }
.ap-msg.user .ap-action-bar { padding-left: 4px; }
.ap-ab-btn {
    height: 30px;
    min-width: 30px;
    padding: 0 8px;
    border-radius: 9px;
    border: none;
    background: transparent;
    color: var(--yz-muted, #8d8878);
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.18s ease;
    font-family: var(--ap-sans);
}
.ap-ab-btn:hover { background: var(--yz-surface, #30302e); color: var(--yz-text); }
.ap-ab-btn:active { transform: scale(0.88); }
.ap-ab-btn.brain-active { color: var(--yz-accent-hi, #e88a68); }
.ap-ab-btn.brain-active i { filter: drop-shadow(0 0 6px var(--yz-accent-soft)); }
@media (max-width: 800px) {
    .ap-action-bar { opacity: 1; transform: none; }
}

/* ============================================================
   ЗОНА ВВОДА (компактная, как была)
   ============================================================ */
.ap-input-zone {
    flex: 0 0 auto;
    padding: 10px 14px calc(var(--safe-bottom, 0px) + 14px);
    /* Сплошной фон без градиента-прозрачности */
    background: var(--yz-bg, #262624);
    position: relative;
    z-index: 55;
}
.ap-input-inner { max-width: var(--ap-maxw); margin: 0 auto; }

.ap-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    background: var(--yz-surface, #30302e);
    border: 1px solid var(--yz-border-strong, rgba(255,255,255,0.17));
    border-radius: 26px;
    padding: 6px;
    box-shadow: var(--yz-shadow-md);
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.ap-input-wrapper:focus-within {
    border-color: var(--yz-accent-line, rgba(217,119,87,0.42));
    box-shadow: 0 0 0 3px var(--yz-accent-soft, rgba(217,119,87,0.14)), var(--yz-shadow-md);
}
.ap-input-wrapper textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    color: var(--yz-text);
    font-family: var(--ap-serif);
    font-size: 16px;
    line-height: 1.45;
    padding: 10px 8px;
    max-height: 132px;
    min-height: 24px;
    caret-color: var(--yz-accent, #d97757);
}
.ap-input-wrapper textarea::placeholder { color: var(--yz-muted, #8d8878); font-style: italic; }

.ap-input-wrapper button {
    width: 42px; height: 42px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s var(--ap-spring);
    flex: 0 0 auto;
    font-size: 16px;
    outline: none;
}
#ch-attach-btn { background: transparent; color: var(--yz-muted); }
#ch-attach-btn:hover { background: var(--yz-accent-soft); color: var(--yz-accent-hi); }
#ch-mic-btn { background: transparent; color: var(--yz-muted); }
#ch-mic-btn:hover { background: var(--yz-accent-soft); color: var(--yz-accent-hi); transform: scale(1.05); }
#ch-send-btn {
    background: var(--yz-grad, linear-gradient(135deg, #e2885f, #b3552e));
    color: #fff;
    box-shadow: var(--yz-accent-glow, 0 8px 26px rgba(217,119,87,0.35));
}
#ch-send-btn:hover { transform: translateY(-2px); filter: brightness(1.07); }
#ch-send-btn:active { transform: scale(0.9); }
#ch-stop-btn {
    background: var(--yz-accent-soft);
    color: var(--yz-accent-hi);
    border: 1px solid var(--yz-accent-line) !important;
    animation: apPulseSoft 1.5s infinite;
}

/* Волна записи голоса */
.ch-recording-wave { display: flex; flex: 1; align-items: center; padding: 0 10px; gap: 12px; }
.ch-wave-bars { display: flex; align-items: center; gap: 4px; height: 24px; }
.ch-bar { width: 4px; background: var(--yz-accent, #d97757); border-radius: 2px; animation: apWave 1s ease-in-out infinite; }
.ch-bar:nth-child(1) { height: 40%; animation-delay: 0s; }
.ch-bar:nth-child(2) { height: 80%; animation-delay: 0.1s; }
.ch-bar:nth-child(3) { height: 100%; animation-delay: 0.2s; }
.ch-bar:nth-child(4) { height: 80%; animation-delay: 0.3s; }
.ch-bar:nth-child(5) { height: 40%; animation-delay: 0.4s; }
@keyframes apWave { 0%, 100% { transform: scaleY(0.4); } 50% { transform: scaleY(1); } }
.ch-record-timer { color: var(--yz-accent-hi); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; font-family: var(--ap-sans); }
.ch-record-status { color: var(--yz-muted); font-size: 13px; font-weight: 500; animation: apPulseSoft 1.5s infinite; font-family: var(--ap-sans); }

/* Превью прикрепленного файла */
.ap-file-preview { max-width: var(--ap-maxw); margin: 0 auto 8px; }
.ap-file-preview-card {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--yz-surface);
    border: 1px solid var(--yz-accent-line);
    border-radius: 16px;
    padding: 8px 10px 8px 14px;
    box-shadow: var(--yz-shadow-sm);
    animation: apFadeUp 0.3s ease;
    font-family: var(--ap-sans);
}
.ap-file-preview-card i.ap-fp-icon { color: var(--yz-accent-hi); font-size: 18px; }
.ap-fp-info { display: flex; flex-direction: column; line-height: 1.3; }
.ap-fp-name { font-size: 13px; font-weight: 600; color: var(--yz-text); max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-fp-size { font-size: 11px; color: var(--yz-muted); }
.ap-fp-remove {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: none;
    background: var(--yz-surface-2);
    color: var(--yz-muted);
    cursor: pointer;
    font-size: 12px;
    display: flex; align-items: center; justify-content: center;
    transition: 0.2s;
}
.ap-fp-remove:hover { color: var(--yz-danger); background: rgba(229, 72, 77, 0.12); }

/* Дисклеймер под вводом */
.ap-input-note {
    text-align: center;
    font-size: 11px;
    color: var(--yz-muted);
    margin-top: 8px;
    font-family: var(--ap-sans);
    opacity: 0.75;
}

/* ============================================================
   ПАНЕЛЬ ИСТОРИИ (боковая шторка)
   ============================================================ */
.ap-history-backdrop {
    position: absolute;
    inset: 0;
    background: var(--yz-overlay, rgba(22,21,19,0.72));
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
    z-index: 70;
}
.ap-history-backdrop.active { opacity: 1; pointer-events: auto; }
.ap-history-panel {
    position: absolute;
    top: 0; right: 0;
    height: 100%;
    width: min(380px, 94vw);
    background: var(--yz-bg, #262624);
    border-left: 1px solid var(--yz-border-strong);
    z-index: 71;
    transform: translateX(105%);
    transition: transform 0.45s var(--ap-ease);
    display: flex;
    flex-direction: column;
    box-shadow: var(--yz-shadow-lg);
}
.ap-history-panel.active { transform: translateX(0); }
.ap-history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(var(--safe-top, 0px) + 20px) 20px 16px;
}
.ap-history-head h3 {
    margin: 0;
    font-family: var(--ap-serif);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.015em;
    display: flex;
    align-items: center;
    gap: 10px;
}
.ap-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 14px calc(var(--safe-bottom, 0px) + 20px);
    display: flex;
    flex-direction: column;
    gap: 7px;
}

/* Премиальная кнопка нового диалога */
.ap-new-chat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 2px 2px 14px;
    height: 50px;
    border-radius: 16px;
    border: none;
    background: var(--yz-grad, linear-gradient(135deg, #e2885f, #b3552e));
    color: #fff;
    font-family: var(--ap-sans);
    font-size: 14.5px;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    box-shadow: var(--yz-accent-glow, 0 8px 26px rgba(217,119,87,0.35));
    transition: all 0.25s var(--ap-spring);
    flex: 0 0 auto;
}
.ap-new-chat-btn i {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    display: grid;
    place-items: center;
    font-size: 11px;
}
.ap-new-chat-btn:hover { filter: brightness(1.08); transform: translateY(-2px); box-shadow: 0 12px 32px rgba(217,119,87,0.45); }
.ap-new-chat-btn:active { transform: scale(0.97); }

/* Карточки диалогов */
.ap-history-item {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 13px 42px 13px 16px;
    border-radius: 15px;
    cursor: pointer;
    background: var(--yz-surface, #30302e);
    border: 1px solid var(--yz-border, rgba(255,255,255,0.08));
    box-shadow: var(--yz-shadow-sm);
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.ap-history-item:hover { border-color: var(--yz-accent-line); transform: translateY(-1px); }
.ap-history-item.active-session { border-color: var(--yz-accent, #d97757); background: var(--yz-accent-soft, rgba(217,119,87,0.14)); }
.ap-history-item.pinned::before {
    content: '';
    position: absolute;
    left: 0; top: 12px; bottom: 12px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--yz-grad);
}
.ap-hi-title {
    font-family: var(--ap-serif);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--yz-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ap-hi-date { font-size: 11px; color: var(--yz-muted); font-family: var(--ap-sans); }
.ap-hi-pin {
    position: absolute;
    right: 6px; top: 50%;
    transform: translateY(-50%);
    width: 32px; height: 32px;
    border: none;
    background: transparent;
    color: var(--yz-muted);
    opacity: 0.45;
    cursor: pointer;
    font-size: 13px;
    border-radius: 9px;
    transition: 0.2s;
}
.ap-history-item:hover .ap-hi-pin { opacity: 1; }
.ap-hi-pin:hover { color: var(--yz-accent-hi); background: var(--yz-accent-soft); }
.ap-hi-pin.pinned-on { color: var(--yz-accent); opacity: 1; transform: translateY(-50%) rotate(45deg); }
.ap-history-empty { text-align: center; color: var(--yz-muted); font-size: 13px; padding: 30px 10px; font-family: var(--ap-sans); }
.ap-load-more {
    margin: 8px 6px 0;
    height: 42px;
    border-radius: 13px;
    border: 1px dashed var(--yz-border-strong);
    background: transparent;
    color: var(--yz-dim);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    font-family: var(--ap-sans);
}
.ap-load-more:hover { border-color: var(--yz-accent-line); color: var(--yz-accent-hi); }

@media (max-width: 640px) {
    .ap-history-panel {
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 78dvh;
        border-left: none;
        border-top: 1px solid var(--yz-border-strong);
        border-radius: 24px 24px 0 0;
        transform: translateY(105%);
    }
    .ap-history-panel.active { transform: translateY(0); }
    .ap-history-head { padding-top: 14px; }
    .ap-history-head::before {
        content: '';
        position: absolute;
        top: 7px; left: 50%;
        transform: translateX(-50%);
        width: 42px; height: 4px;
        border-radius: 4px;
        background: var(--yz-border-strong);
    }
}

/* ============================================================
   МОДАЛКИ ПОРТАЛА (скриншот, приглашение, память, закреп)
   ============================================================ */
.ap-modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--yz-overlay, rgba(22,21,19,0.72));
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    z-index: 2147483646;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.ap-modal-overlay.active { opacity: 1; pointer-events: auto; }
.ap-modal-card {
    width: 100%;
    max-width: 420px;
    max-height: 86dvh;
    overflow-y: auto;
    background: var(--yz-surface, #30302e);
    border: 1px solid var(--yz-border-strong);
    border-radius: 24px;
    padding: 24px;
    box-shadow: var(--yz-shadow-lg);
    transform: translateY(24px) scale(0.96);
    transition: transform 0.4s var(--ap-spring);
    font-family: var(--ap-sans);
}
.ap-modal-overlay.active .ap-modal-card { transform: none; }
.ap-modal-card h3 {
    margin: 0 0 8px;
    font-family: var(--ap-serif);
    font-size: 21px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--yz-text);
    display: flex;
    align-items: center;
    gap: 10px;
}
.ap-modal-card h3 i { color: var(--yz-accent-hi); font-size: 18px; }
.ap-modal-sub { color: var(--yz-dim); font-size: 13.5px; line-height: 1.55; margin: 0 0 18px; }
.ap-modal-btn-row { display: flex; gap: 10px; margin-top: 18px; }
.ap-btn {
    flex: 1;
    height: 48px;
    border-radius: 15px;
    border: none;
    font-family: var(--ap-sans);
    font-size: 14.5px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.22s var(--ap-spring);
    text-decoration: none;
}
.ap-btn.primary { background: var(--yz-grad); color: #fff; box-shadow: var(--yz-accent-glow); }
.ap-btn.primary:hover { filter: brightness(1.07); transform: translateY(-1px); }
.ap-btn.ghost { background: var(--yz-surface-2, #3a3936); color: var(--yz-text); border: 1px solid var(--yz-border); }
.ap-btn.ghost:hover { border-color: var(--yz-border-strong); }
.ap-btn:active { transform: scale(0.96); }

.ap-modal-input {
    width: 100%;
    background: var(--yz-bg, #262624);
    border: 1px solid var(--yz-border-strong);
    color: var(--yz-text);
    padding: 13px 16px;
    border-radius: 14px;
    font-size: 15px;
    font-family: var(--ap-serif);
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.ap-modal-input:focus { border-color: var(--yz-accent-line); box-shadow: 0 0 0 3px var(--yz-accent-soft); }

/* Скриншот: превью и сетка шеринга */
.ap-shot-preview {
    width: 100%;
    max-height: 38dvh;
    object-fit: contain;
    border-radius: 16px;
    border: 1px solid var(--yz-border-strong);
    background: var(--yz-bg-deep);
    margin-bottom: 16px;
    box-shadow: var(--yz-shadow-md);
}
.ap-share-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 9px;
}
.ap-share-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 13px 6px;
    border-radius: 15px;
    border: 1px solid var(--yz-border);
    background: var(--yz-surface-2, #3a3936);
    color: var(--yz-text);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.22s var(--ap-spring);
    text-decoration: none;
}
.ap-share-tile i { font-size: 19px; color: var(--yz-accent-hi); }
.ap-share-tile:hover { transform: translateY(-2px); border-color: var(--yz-accent-line); box-shadow: var(--yz-shadow-sm); }
.ap-share-tile.tg i { color: #2aabee; }
.ap-share-tile.wa i { color: #25d366; }
.ap-share-tile.vk i { color: #0077ff; }

/* Память (ядро) */
.ap-memory-item {
    background: var(--yz-bg, #262624);
    border: 1px solid var(--yz-border);
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 10px;
}
.ap-memory-role { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--yz-accent-hi); margin-bottom: 5px; display: flex; align-items: center; gap: 6px; }
.ap-memory-text { font-family: var(--ap-serif); font-size: 13.5px; color: var(--yz-dim); line-height: 1.5; max-height: 72px; overflow: hidden; }
.ap-memory-remove {
    margin-top: 8px;
    background: transparent;
    border: none;
    color: var(--yz-danger);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* Тост */
.ap-toast {
    position: fixed;
    bottom: calc(var(--safe-bottom, 0px) + 96px);
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    background: var(--yz-surface, #30302e);
    border: 1px solid var(--yz-accent-line);
    color: var(--yz-text);
    padding: 11px 20px;
    border-radius: 999px;
    font-size: 13.5px;
    font-weight: 600;
    font-family: var(--ap-sans);
    z-index: 2147483647;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.35s var(--ap-spring);
    display: flex;
    align-items: center;
    gap: 9px;
    box-shadow: var(--yz-shadow-lg);
    max-width: 88vw;
}
.ap-toast i { color: var(--yz-accent-hi); }
.ap-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Лайтбокс */
#ch-lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 9, 8, 0.96);
    z-index: 2147483647;
    justify-content: center;
    align-items: center;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}
#ch-lightbox-img { max-width: 95vw; max-height: 92dvh; object-fit: contain; border-radius: 14px; }
.ch-lightbox-close {
    position: absolute;
    top: calc(var(--safe-top, 0px) + 16px);
    right: 16px;
    width: 42px; height: 42px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    font-size: 17px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    z-index: 2;
}

/* ============================================================
   АДАПТИВ
   ============================================================ */
@media (max-width: 800px) {
    .ap-thread { padding: 20px 16px 24px; gap: 22px; }
    .ap-topbar { padding-left: 12px; padding-right: 10px; gap: 6px; }
    .ap-icon-btn { width: 36px; height: 36px; font-size: 14px; }
    .ap-brand-name { font-size: 16px; }
    .ap-session-title { display: none; }
    .ap-msg .ap-msg-text { font-size: 16px; line-height: 1.65; }
    .ap-msg-text h1 { font-size: 21px; }
    .ap-msg-text h2 { font-size: 18.5px; }
    .ap-msg-text h3 { font-size: 16.5px; }
    .ap-welcome { min-height: calc(100dvh - 340px); }
    .ap-input-wrapper button { width: 40px; height: 40px; }
    .ap-share-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Игровой режим: прячем интерфейс поверх игры */
body.game-fullscreen-active .ap-topbar,
body.game-fullscreen-active .ap-input-zone { pointer-events: none; }

/* ============================================================
   ТОНКАЯ ПОДГОНКА СВЕТЛОЙ ТЕМЫ (Cloud)
   ============================================================ */
html[data-yz-theme="cloud"] .ai-overlay-modal { box-shadow: 0 -14px 50px rgba(60, 50, 35, 0.18); }
html[data-yz-theme="cloud"] .ap-msg-text code { color: var(--yz-accent-deep, #a54c2b); }
html[data-yz-theme="cloud"] .ap-input-wrapper { background: #ffffff; }
html[data-yz-theme="cloud"] .ap-history-item { box-shadow: none; }
html[data-yz-theme="cloud"] .ap-history-item.active-session { background: var(--yz-accent-soft); }
html[data-yz-theme="cloud"] .ap-quick-chip { background: #ffffff; }
html[data-yz-theme="cloud"] .ap-icon-btn:hover { background: #ffffff; }
html[data-yz-theme="cloud"] .ap-ab-btn:hover { background: rgba(35, 32, 25, 0.06); }
html[data-yz-theme="cloud"] .ap-modal-card,
html[data-yz-theme="cloud"] .ap-toast { background: #ffffff; }
html[data-yz-theme="cloud"] .ap-msg.user .ap-msg-card { border-color: rgba(201, 101, 67, 0.22); }

/* Спокойный режим */
@media (prefers-reduced-motion: reduce) {
    .ai-overlay-modal *, .ap-dot, .ap-welcome-dot { animation: none !important; transition-duration: 0.01ms !important; }
}

/* ============================================================================
   YAZME AI PORTAL — РЕДИЗАЙН 2026 (оверрайды)
   Прозрачная шапка · факт-карточка «ты знал?» · шторка диалогов слева ·
   мессенджер-раскладка · плавающий стеклянный композер · минимум теней
   ========================================================================== */

/* Лента занимает весь экран; шапка и композер парят над ней (текст уезжает под них) */
.ai-overlay-modal .ap-chat-zone{ position:absolute; inset:0; z-index:1; }
.ai-overlay-modal .ap-thread{ padding:88px 20px 134px; }

/* Прозрачная шапка со стеклянными «вырезанными» кнопками */
.ai-overlay-modal .ap-topbar{
    position:absolute; top:0; left:0; right:0; z-index:60;
    background:transparent; border-bottom:none;
    padding:calc(var(--safe-top,0px) + 12px) 14px 10px; gap:8px;
    pointer-events:none;
}
.ai-overlay-modal .ap-topbar > *{ pointer-events:auto; }
.ap-topbar-spacer{ flex:1; }
.ai-overlay-modal .ap-topbar .ap-icon-btn{
    width:42px; height:42px; border-radius:14px; color:var(--yz-text);
    background:rgba(30,29,28,.5); border:1px solid var(--yz-border-strong);
    -webkit-backdrop-filter:blur(14px) saturate(1.4); backdrop-filter:blur(14px) saturate(1.4);
}
.ai-overlay-modal .ap-topbar .ap-icon-btn:hover{ background:rgba(48,48,46,.72); }
.ai-overlay-modal .ap-topbar .ap-menu-btn{ font-size:17px; }
.ai-overlay-modal .ap-topbar .ap-close-btn:hover{ color:var(--yz-danger,#e5695f); }

/* Плавающий стеклянный композер */
.ai-overlay-modal .ap-input-zone{
    position:absolute; left:0; right:0; bottom:0; z-index:55;
    background:transparent; padding:10px 14px calc(var(--safe-bottom,0px) + 12px);
}
.ai-overlay-modal .ap-input-zone::before{
    content:''; position:absolute; left:0; right:0; bottom:100%; height:46px;
    background:linear-gradient(180deg, transparent, var(--yz-bg,#262624)); pointer-events:none;
}
.ai-overlay-modal .ap-input-wrapper{
    background:rgba(48,48,46,.60); border:1px solid var(--yz-border-strong);
    box-shadow:0 6px 20px rgba(0,0,0,.16);
    -webkit-backdrop-filter:blur(22px) saturate(1.6); backdrop-filter:blur(22px) saturate(1.6);
}
.ai-overlay-modal .ap-input-wrapper:focus-within{
    border-color:var(--yz-accent-line);
    box-shadow:0 0 0 3px var(--yz-accent-soft), 0 6px 20px rgba(0,0,0,.16);
}
.ai-overlay-modal .ap-input-note{ opacity:.8; }

/* Раздел «ты знал?» — минимализм, без тяжёлых теней */
.ai-overlay-modal .ap-welcome{ min-height:calc(100dvh - 260px); justify-content:center; padding:12px 2px; }
@keyframes apFactIn{ from{opacity:0; transform:translateY(18px);} to{opacity:1; transform:none;} }
.ap-fact-card{
    position:relative; overflow:hidden; cursor:pointer; width:100%;
    border-radius:26px; padding:26px 24px 22px;
    background:linear-gradient(162deg, rgba(217,119,87,.10), rgba(56,52,49,.30));
    border:1px solid var(--yz-border-strong);
    animation:apFactIn .6s var(--ap-ease) both;
    transition:transform .3s var(--ap-spring), border-color .3s;
}
.ap-fact-card:hover{ border-color:var(--yz-accent-line); }
.ap-fact-card:active{ transform:scale(.985); }
.ap-fact-label{ display:inline-flex; align-items:center; gap:8px; font-family:var(--ap-serif); font-style:italic; font-size:15px; color:var(--yz-accent-hi); margin-bottom:14px; }
.ap-fact-spark{ font-style:normal; }
.ap-fact-text{ font-family:var(--ap-serif); font-weight:600; font-size:23px; line-height:1.34; letter-spacing:-.01em; color:var(--yz-text); margin-bottom:22px; }
.ap-fact-actions{ display:flex; align-items:center; gap:10px; }
.ap-fact-cta{
    display:inline-flex; align-items:center; gap:9px; height:44px; padding:0 20px; border-radius:999px; border:none;
    background:var(--yz-grad); color:#fff; font-family:var(--ap-sans); font-size:14px; font-weight:700; cursor:pointer;
    transition:transform .2s var(--ap-spring);
}
.ap-fact-cta:active{ transform:scale(.94); }
.ap-fact-arw{ transition:transform .3s var(--ap-spring); }
.ap-fact-card:hover .ap-fact-arw{ transform:translateX(4px); }
.ap-fact-refresh{
    width:44px; height:44px; border-radius:50%; border:1px solid var(--yz-border-strong);
    background:transparent; color:var(--yz-dim); cursor:pointer;
    display:flex; align-items:center; justify-content:center; margin-left:auto;
    transition:.25s var(--ap-spring); font-size:14px;
}
.ap-fact-refresh:hover{ color:var(--yz-accent-hi); border-color:var(--yz-accent-line); transform:rotate(90deg); }

/* Сообщения пользователя — как в мессенджере: справа, аватар справа */
.ai-overlay-modal .ap-msg.user .ap-msg-card{
    display:flex; justify-content:flex-end; align-items:flex-end; gap:9px;
    background:transparent; border:none; padding:0; border-radius:0; overflow:visible;
}
.ai-overlay-modal .ap-msg.user .ap-msg-text{
    background:var(--yz-accent-soft); border:1px solid var(--yz-accent-line);
    border-radius:22px 22px 6px 22px; padding:12px 16px; max-width:78%;
}
.ai-overlay-modal .ap-msg.user .ap-user-avatar{
    float:none; margin:0; width:32px; height:32px; shape-outside:none;
}
.ai-overlay-modal .ap-msg.user .ap-action-bar{ justify-content:flex-end; padding-left:0; padding-right:2px; }

/* Шторка диалогов: выезжает СЛЕВА; чипы Стиль/Друг сверху */
.ai-overlay-modal .ap-history-panel{
    left:0 !important; right:auto !important; top:0 !important; bottom:auto !important;
    height:100% !important; width:min(340px,86vw) !important; max-width:340px;
    border-right:1px solid var(--yz-border-strong); border-left:none;
    border-radius:0 !important; transform:translateX(-105%) !important;
}
.ai-overlay-modal .ap-history-panel.active{ transform:translateX(0) !important; }
.ai-overlay-modal .ap-history-head::before{ display:none !important; }
.ap-history-title{ font-family:var(--ap-serif); font-size:20px; font-weight:700; color:var(--yz-text); }
.ap-hist-actions{ display:flex; gap:8px; margin:0 2px 12px; }
.ap-hist-chip{
    flex:1; display:flex; align-items:center; justify-content:center; gap:7px; height:44px;
    border-radius:14px; border:1px solid var(--yz-border); background:rgba(255,255,255,.04);
    color:var(--yz-text); font-family:var(--ap-sans); font-size:13px; font-weight:600; cursor:pointer; transition:.2s;
}
.ap-hist-chip:hover{ background:var(--yz-accent-soft); border-color:var(--yz-accent-line); }
.ap-hist-chip i{ color:var(--yz-accent-hi); }
.ap-hist-emoji{ font-size:15px; line-height:1; }
