/* ===== Общие стили чата ===== */
.chat-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 140px);
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
}

/* Хедер чата */
.chat-header-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}
.char-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    object-position: top;
    border: 2px solid var(--accent);
    flex-shrink: 0;
}
.char-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.char-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.char-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.char-messages-left {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(214, 51, 132, 0.08);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 600;
    white-space: nowrap;
}
.char-messages-left i { font-size: 1rem; }
.char-messages-left .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.desktop-only { display: flex; }
.mobile-only { display: none; }

/* Область сообщений */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.message {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.message p { margin: 0; word-break: break-word; white-space: pre-wrap; }
.message.user {
    align-self: flex-end;
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}
.message.partner {
    align-self: flex-start;
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-bottom-left-radius: 4px;
}
.msg-time {
    font-size: 0.65rem;
    color: inherit;
    opacity: 0.6;
    margin-top: 4px;
    text-align: right;
}

.typing-indicator {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--card-bg);
    border-radius: 18px;
    border: 1px solid var(--border-light);
}
.typing-indicator span {
    width: 6px; height: 6px;
    background: var(--accent);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

.story-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}
.action-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    padding: 8px 14px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.action-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }
.action-btn i { font-size: 0.9rem; }

.audio-progress-panel {
    margin-top: 10px;
    background: rgba(214, 51, 132, 0.05);
    border-radius: 12px;
    padding: 12px 16px;
    border: 1px solid rgba(214, 51, 132, 0.15);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.audio-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.audio-progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(214, 51, 132, 0.1);
    border-radius: 3px;
    overflow: hidden;
}
.audio-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s ease;
}
.inline-audio-player { display: flex; align-items: center; gap: 8px; }
.inline-audio-player audio { flex: 1; height: 32px; }

/* ===== Панель настроек ===== */
.settings-panel {
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 16px 20px;
    margin-bottom: 12px;
    box-shadow: 0 4px 12px rgba(214, 51, 132, 0.05);
    display: flex;
    flex-direction: column;
    gap: 0;
}
.setting-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 18px 0;
    border-bottom: 1px solid rgba(214, 51, 132, 0.08);
}
.setting-block:first-child { padding-top: 0; }
.setting-block:last-child { border-bottom: none; padding-bottom: 0; }
.setting-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}
.setting-label { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }
.setting-value { font-size: 1rem; font-weight: 700; color: var(--accent); }

.clean-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(214, 51, 132, 0.1);
    -webkit-appearance: none; appearance: none;
    outline: none; cursor: pointer;
}
.clean-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--accent);
    box-shadow: 0 2px 6px rgba(214, 51, 132, 0.2);
}

.mode-switch-row { display: flex; gap: 8px; }
.mode-option {
    flex: 1;
    padding: 8px 10px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    background: rgba(214, 51, 132, 0.05);
    border: 1px solid transparent;
    color: var(--text-secondary);
    transition: all 0.2s;
    text-align: center;
}
.mode-option.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(214, 51, 132, 0.2);
}

.mode-description {
    margin-top: 8px;
    background: rgba(214, 51, 132, 0.05);
    border: 1px solid rgba(214, 51, 132, 0.1);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.mode-description i { color: #FFD700; font-size: 1rem; margin-top: 2px; flex-shrink: 0; }
.mode-description span { flex: 1; }

/* ===== Кастомный селект (открывается вверх при нехватке места) ===== */
.custom-select-wrapper {
    width: 100%;
    position: relative;
}
.custom-select {
    position: relative;
    display: flex;
    flex-direction: column;
}
.custom-select__trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--card-bg);
    border: 1px solid rgba(214, 51, 132, 0.2);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-size: 0.9rem;
    color: var(--text-primary);
}
.custom-select__trigger:hover {
    border-color: var(--accent);
}
.custom-select.open .custom-select__trigger {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(214, 51, 132, 0.15);
}
.custom-select__trigger i {
    color: var(--accent);
    font-size: 0.8rem;
    transition: transform 0.2s;
}
.custom-select.open .custom-select__trigger i {
    transform: rotate(180deg);
}
.custom-options {
    position: absolute;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid rgba(214, 51, 132, 0.2);
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(214, 51, 132, 0.1);
    display: none;
    flex-direction: column;
    z-index: 20;
    max-height: 220px;
    overflow-y: auto;
}
.custom-select.open .custom-options {
    display: flex;
}
.custom-options.open-down {
    top: calc(100% + 4px);
    bottom: auto;
}
.custom-options.open-up {
    bottom: calc(100% + 4px);
    top: auto;
}
.custom-option {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary);
    transition: background 0.15s;
    white-space: nowrap;
}
.custom-option:hover {
    background: rgba(214, 51, 132, 0.08);
}
.custom-option.selected {
    background: rgba(214, 51, 132, 0.12);
    font-weight: 600;
    color: var(--accent);
}

/* Поле ввода */
.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 16px 0 0;
    border-top: 1px solid var(--border-light);
    flex-shrink: 0;
}
.settings-btn {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: rgba(214, 51, 132, 0.1);
    border: none;
    color: var(--accent);
    font-size: 1.2rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}
.settings-btn:hover { background: var(--accent); color: white; }
.chat-input {
    flex: 1;
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 0.95rem;
    color: var(--text-primary);
    font-family: "Inter", sans-serif;
    resize: none;
    max-height: 150px;
    outline: none;
    transition: border-color 0.2s;
    word-wrap: break-word;
}
.chat-input:focus { border-color: var(--accent); }
.send-btn {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}
.send-btn:hover { background: var(--accent-hover); }

/* ===== Адаптив ===== */
@media (max-width: 768px) {
    .desktop-only { display: none; }
    .mobile-only { display: flex; margin-top: 4px; align-self: flex-start; }
    .char-status { display: none; }
    .message { max-width: 85%; }
    .action-btn { padding: 6px 10px; font-size: 0.8rem; }
    .settings-panel { padding: 12px 16px; }
    .mode-option { font-size: 0.8rem; }
    .setting-label { font-size: 0.85rem; }
    .setting-block { padding: 14px 0; }
    .custom-select__trigger { font-size: 0.85rem; padding: 8px 12px; }
    .custom-option { font-size: 0.85rem; padding: 8px 12px; }
}
/* ===== Живая карточка генерации рассказа ===== */
.message.gen-card { max-width: 420px; padding: 16px 18px; }
.gen-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.gen-head b { display: block; font-size: 1rem; color: var(--text-primary); }
.gen-head small { color: var(--text-secondary); font-size: .8rem; font-variant-numeric: tabular-nums; }
.gen-pen { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: #fff;
    background: linear-gradient(135deg, #ff5fa2, #D63384 55%, #8a2be2); animation: genWrite 1.2s ease-in-out infinite; }
@keyframes genWrite { 0%, 100% { transform: rotate(-8deg) translateY(0); } 50% { transform: rotate(8deg) translateY(-2px); } }
.gen-bar { height: 6px; border-radius: 99px; background: rgba(214,51,132,.15); overflow: hidden; margin-bottom: 12px; }
.gen-bar i { display: block; height: 100%; transform-origin: left; transform: scaleX(.04); transition: transform .25s linear;
    background: linear-gradient(90deg, #ff5fa2, #D63384, #8a2be2); }
.gen-stages { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 6px; }
.gen-stages li { display: flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--text-secondary); opacity: .55; transition: opacity .3s; }
.gen-stages li.now { opacity: 1; color: var(--text-primary); font-weight: 600; }
.gen-stages li.done { opacity: .85; }
.gen-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(214,51,132,.5); flex: 0 0 16px; position: relative; }
.gen-stages li.now .gen-dot { border-color: #D63384; animation: genPulse 1s ease-in-out infinite; }
.gen-stages li.done .gen-dot { background: #D63384; border-color: #D63384; }
.gen-stages li.done .gen-dot::after { content: '✓'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: .6rem; color: #fff; font-weight: 900; }
@keyframes genPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.25); } }
.gen-tease { margin: 6px 0 0; font-size: .9rem; font-style: italic; color: var(--text-primary); }
.gen-fade { animation: genFade .5s ease; }
@keyframes genFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .gen-pen, .gen-stages li.now .gen-dot { animation: none; } }
#styleOptions { max-height: min(50vh, 360px); overflow-y: auto; -webkit-overflow-scrolling: touch; }


/* 30.09 тест «обрыв на самом интересном» */
.message .story-lock { position: relative; margin-top: -8px; }
.story-lock-fade { height: 56px; margin-top: -56px; position: relative; pointer-events: none;
    background: linear-gradient(to bottom, transparent, var(--bg-message-partner, var(--card-bg, #221f29))); }
.story-lock-body { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
    padding: 14px 12px 12px; border: 1px dashed rgba(214, 51, 132, .45); border-radius: 16px; margin-top: 6px; }
.story-lock-body b { font-size: 16px; }
.story-lock-body span { font-size: 13px; opacity: .75; }
.story-unlock-btn { white-space: nowrap; max-width: 100%; margin-top: 4px; min-height: 44px; padding: 0 18px; border: 0; border-radius: 40px; cursor: pointer;
    background: linear-gradient(135deg, #e0428f, #b02a74); color: #fff; font-weight: 700; font-size: 15px; }
.story-unlock-btn[disabled] { opacity: .6; }
.story-lock-sub { font-size: 13px; color: var(--accent, #D63384); text-decoration: none; }
.story-lock-msg { font-size: 12px; color: #ff7a9c; min-height: 14px; }
.custom-option .ero-svg, .custom-select__trigger-text .ero-svg { color: var(--accent); margin-right: 6px; }

/* 01.10: заголовок панели, «Готово» и строка текущих настроек над полем ввода */
.sp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sp-head b { font-size: 1rem; color: var(--text-primary); }
.sp-close { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border-light); background: transparent; color: var(--text-secondary); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.sp-close:hover { color: var(--accent); border-color: var(--accent); }
.sp-done { display: block; width: 100%; margin-top: 14px; padding: 12px; border: 0; border-radius: 14px; font-weight: 800; font-size: 1rem; color: #fff; cursor: pointer;
    background: linear-gradient(135deg, #D63384, #E91E63); box-shadow: 0 8px 18px rgba(214, 51, 132, .3); font-family: inherit; }
.settings-summary { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; width: fit-content; max-width: 100%; margin: 0 0 8px; padding: 7px 14px; border-radius: 999px;
    border: 1px solid var(--border-light); background: var(--card-bg); color: var(--text-secondary); font-size: .85rem; cursor: pointer; font-family: inherit; text-align: left; }
.settings-summary:hover { border-color: var(--accent); color: var(--text-primary); }
.settings-summary i, .settings-summary .ero-svg { color: var(--accent); }
.settings-summary .ss-edit { color: var(--accent); font-weight: 700; margin-left: 4px; }
.settings-summary { flex-wrap: nowrap; white-space: nowrap; overflow: hidden; }
@media (max-width: 600px) { .settings-summary { font-size: .78rem; padding: 6px 12px; gap: 5px; } .settings-summary .ss-edit { display: none; } }

/* 01.10: кнопка настроек — удобная для пальца высота */
.settings-summary { min-height: 34px; }

/* 06.10: пробный пакет в «обрыве» */
.story-trial-btn { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 18px; border-radius: 16px; text-decoration: none; font-weight: 800; font-size: 14px; color: #3d1d00 !important; background: linear-gradient(135deg, #fff1a8, #f2c14e 55%, #f59e0b); box-shadow: 0 10px 22px -12px rgba(242, 193, 78, .9); }
.story-trial-btn small { font-weight: 600; font-size: 11.5px; opacity: .8; }

/* 08.10: карточка новичка в генераторе — одно поле, одна кнопка, готовые идеи */
.gen-start { align-self: stretch; margin: 6px 0 4px; padding: 18px 16px 14px; border-radius: 20px;
    background: linear-gradient(160deg, rgba(214, 51, 132, .14), rgba(124, 58, 237, .08)); border: 1px solid rgba(214, 51, 132, .3);
    animation: gsIn .35s cubic-bezier(.2, 1.2, .4, 1) both; }
.gs-title { font-size: 20px; font-weight: 800; line-height: 1.25; margin: 0 0 12px; color: var(--text-primary, #fff); }
.gs-input { width: 100%; box-sizing: border-box; resize: none; min-height: 84px; padding: 13px 14px; border-radius: 14px;
    border: 1px solid var(--border-light, rgba(255, 255, 255, .14)); background: var(--input-bg, rgba(0, 0, 0, .25));
    color: var(--text-primary, #fff); font: inherit; font-size: 16px; line-height: 1.4; }
.gs-input:focus { outline: none; border-color: var(--accent, #d6337f); box-shadow: 0 0 0 3px rgba(214, 51, 132, .2); }
.gs-shake { animation: gsShake .35s; }
.gs-go { width: 100%; margin-top: 10px; min-height: 54px; border: 0; border-radius: 999px; cursor: pointer; color: #fff;
    font: inherit; font-size: 17px; font-weight: 800; background: linear-gradient(135deg, #ff4d9a, #d6337f 55%, #a855f7);
    box-shadow: 0 10px 28px rgba(214, 51, 132, .4); display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.gs-go:active { transform: scale(.98); }
.gs-or { margin: 14px 2px 8px; font-size: 14px; color: var(--text-secondary, #a59aa8); text-align: center; }
.gs-chips { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; }
.gs-chips .gen-idea { padding: 9px 13px; border-radius: 999px; cursor: pointer; border: 1px solid rgba(214, 51, 132, .4);
    background: rgba(214, 51, 132, .08); color: var(--text-primary, #fff); font: inherit; font-size: 14px; font-weight: 600; line-height: 1.2; }
.gs-chips .gen-idea:active { transform: scale(.96); }
.gs-note { margin-top: 12px; text-align: center; font-size: 13px; color: var(--text-secondary, #a59aa8); }
/* пока новичок не создал первый рассказ — одна форма: нижняя панель и «Режим» спрятаны */
body.gen-fresh .chat-input-area, body.gen-fresh .settings-summary { display: none !important; }
@keyframes gsIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes gsShake { 0%, 100% { transform: none; } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* 08.10: режим новичка — без длинного приветствия (его заменяет карточка); на узком экране идеи по две в ряд */
body.gen-fresh #chatMessages > .message.partner:first-child { display: none; }
@media (max-width: 380px) {
    .gen-start { padding: 16px 12px 12px; }
    .gs-title { font-size: 18px; }
    .gs-chips .gen-idea { font-size: 13px; padding: 8px 10px; }
}
/* 08.10: надпись кнопки в одну строку */
.gs-go { white-space: nowrap; padding: 0 14px; }
@media (max-width: 380px) { .gs-go { font-size: 15px; gap: 6px; } }
/* 08.10: подсказка нижнего поля целиком на узком экране */
@media (max-width: 380px) { .chat-input-area .chat-input::placeholder { font-size: 14px; } }

/* 08.10: после рассказа — «Продолжить» главная, «Послушать голосом» вторая заметная, остальные обычные */
.story-actions .continue-btn { flex: 1 1 100%; justify-content: center; min-height: 46px; font-size: 15px; border: 0; color: #fff;
    background: linear-gradient(135deg, #ff4d9a, #d6337f 60%, #a855f7); box-shadow: 0 8px 22px rgba(214, 51, 132, .35); }
.story-actions .continue-btn:hover { color: #fff; filter: brightness(1.06); }
.story-actions .audio-btn { flex: 1 1 100%; justify-content: center; min-height: 44px; font-size: 14.5px;
    border-color: rgba(214, 51, 132, .55); color: var(--accent, #d6337f); background: rgba(214, 51, 132, .08); }
.story-actions .rewrite-btn, .story-actions .download-btn { flex: 1 1 calc(50% - 4px); justify-content: center; }

/* 08.10: «Обычный | Продвинутый» на виду */
.gen-mode-bar { display: flex; gap: 8px; margin: 0 0 8px; }
.gm-chip { flex: 1 1 0; min-height: 42px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border-light, rgba(255, 255, 255, .12));
    background: var(--card-bg, #26262c); color: var(--text-secondary, #a59aa8); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 5px; white-space: nowrap; }
.gm-chip.gm-adv:not(.active) { border-color: rgba(214, 51, 132, .55); color: var(--accent, #d6337f); }
.gm-chip.active { background: var(--accent, #d6337f); border-color: var(--accent, #d6337f); color: #fff; }
.gen-start .gen-mode-bar { margin: 10px 0 4px; }
.gs-modehint { text-align: center; font-size: 13px; color: var(--text-secondary, #a59aa8); margin: 0 0 2px; }
body.gen-fresh > .gen-mode-bar { display: none; }
@media (max-width: 380px) { .gm-chip { font-size: 13px; padding: 0 8px; } }
/* 08.10: порядок кнопок под рассказом и без задвоения режима */
.story-actions .continue-btn { order: 1; }
.story-actions .audio-btn { order: 2; }
.story-actions .rewrite-btn, .story-actions .download-btn { order: 3; flex: 1 1 40%; min-width: 0; box-sizing: border-box; }
.story-actions .action-btn { box-sizing: border-box; }
.gen-mode-bar ~ .settings-summary { display: none !important; }

/* 08.10: аудио готово — заметно */
.audio-progress-panel.audio-ready { border: 1px solid rgba(214, 51, 132, .5); border-radius: 14px; padding: 10px; background: rgba(214, 51, 132, .08);
    animation: arIn .4s ease both; }
.audio-ready-t { font-weight: 700; margin: 0 0 8px; color: var(--text-primary, #fff); display: flex; align-items: center; gap: 8px; }
.audio-ready-t i { color: var(--accent, #d6337f); }
.audio-progress-fill { transition: width .25s linear; }
@keyframes arIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* 08.10: свой аудиоплеер в стиле сайта */
.ap { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 18px; background: var(--card-bg, #26262c);
    border: 1px solid var(--border-light, rgba(255, 255, 255, .1)); }
.ap audio { display: none; }
.ap-play { flex: 0 0 52px; width: 52px; height: 52px; border-radius: 50%; border: 0; cursor: pointer; color: #fff; font-size: 18px;
    background: linear-gradient(135deg, #ff4d9a, #d6337f 60%, #a855f7); box-shadow: 0 8px 22px rgba(214, 51, 132, .4);
    display: inline-flex; align-items: center; justify-content: center; }
.ap-play .fa-play { margin-left: 3px; }
.ap-on .ap-play { animation: apPulse 1.6s ease-in-out infinite; }
.ap-mid { flex: 1 1 auto; min-width: 0; }
.ap-seek { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 999px; cursor: pointer; outline: none;
    background: linear-gradient(90deg, var(--accent, #d6337f) var(--p, 0%), rgba(127, 127, 127, .3) var(--p, 0%)); }
.ap-seek::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px var(--accent, #d6337f); }
.ap-seek::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px var(--accent, #d6337f); }
.ap-time { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; color: var(--text-secondary, #a59aa8); font-variant-numeric: tabular-nums; }
.ap-speed, .ap-dl { flex: 0 0 auto; min-width: 40px; height: 36px; padding: 0 8px; border-radius: 12px; border: 1px solid var(--border-light, rgba(255, 255, 255, .12));
    background: transparent; color: var(--text-primary, #fff); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
@keyframes apPulse { 0%, 100% { box-shadow: 0 8px 22px rgba(214, 51, 132, .4); } 50% { box-shadow: 0 8px 30px rgba(214, 51, 132, .75); } }
@media (max-width: 360px) { .ap { gap: 8px; padding: 9px; } .ap-play { flex-basis: 46px; width: 46px; height: 46px; } .ap-speed { display: none; } }
/* 08.10: плеер без двойной рамки */
.audio-progress-panel .ap { background: transparent; border: 0; padding: 4px 2px; }

/* 08.10: длинный запрос — счётчик и цена под полем */
.lp-hint { margin: 6px 4px 0; font-size: 13px; line-height: 1.4; color: rgba(255, 255, 255, .62); }
.lp-hint.warn { color: #ffb4d0; }
.lp-hint .lp-on { margin-left: 6px; padding: 4px 12px; border: 0; border-radius: 999px; background: #e0337a; color: #fff;
  font: inherit; font-weight: 600; cursor: pointer; }

/* 11.10: подсказка про знаки и цену под полем промпта читается и в светлой теме */
html:not(.dark-theme) .lp-hint { color: #5b4352; }
html:not(.dark-theme) .lp-hint.warn { color: #b3135f; }

/* 11.10: подсказка под ползунком длины рассказа */
.length-hint { margin: 8px 0 0; font-size: 12.5px; line-height: 1.4; color: var(--text-muted, #a89cb0); transition: color .2s, transform .2s; }
.length-hint.paid { color: #f6c978; font-weight: 600; }


/* 02.11 (владелец: «на ПК плохо выглядит, выдели в красивый блок»): шапка генератора рассказов на компьютере.
   Крупная аватарка с кольцом, заголовок и пояснение целиком, всё в карточке с мягким свечением. hero-card-pc */
@media (min-width: 769px) {
    .chat-header-bar {
        position: relative;
        gap: 22px;
        padding: 22px 28px;
        margin: 6px 0 14px;
        border: 1px solid rgba(214, 51, 132, 0.28);
        border-radius: 24px;
        background:
            radial-gradient(120% 140% at 100% 0%, rgba(214, 51, 132, 0.20), transparent 60%),
            radial-gradient(90% 120% at 0% 100%, rgba(140, 80, 220, 0.14), transparent 60%),
            rgba(255, 255, 255, 0.03);
        box-shadow: 0 18px 40px -22px rgba(214, 51, 132, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.07);
        overflow: hidden;
    }
    .chat-header-bar .char-avatar {
        width: 92px;
        height: 92px;
        border: 3px solid transparent;
        background: linear-gradient(var(--bg-primary, #14101a), var(--bg-primary, #14101a)) padding-box, linear-gradient(135deg, #ff4d94, #b266ff 55%, #ffd36b) border-box;
        box-shadow: 0 0 0 5px rgba(214, 51, 132, 0.12), 0 10px 28px -8px rgba(214, 51, 132, 0.6);
    }
    .chat-header-bar .char-name {
        font-size: 1.75rem;
        line-height: 1.2;
        font-weight: 800;
        letter-spacing: -0.01em;
        margin-bottom: 8px;
    }
    .chat-header-bar .char-status {
        display: block;
        font-size: 1.05rem;
        line-height: 1.5;
        color: var(--text-secondary);
        max-width: 640px;
    }
    .chat-header-bar .char-messages-left.desktop-only {
        align-self: center;
        flex-direction: column;
        gap: 2px;
        padding: 14px 20px;
        border-radius: 18px;
        background: rgba(214, 51, 132, 0.12);
        border: 1px solid rgba(214, 51, 132, 0.3);
        font-size: 1.5rem;
        font-weight: 800;
        text-align: center;
    }
    .chat-header-bar .char-messages-left.desktop-only .label { font-size: 0.8rem; }
}

/* 03.11 (владелец: «формы смещаются на мобильных»): карточка новичка и скрытие приветствия действуют сразу по наличию #genIdeas, а не после скрипта (раньше форма прыгала вверх на 200px, CLS 0.2) */
#chatMessages:has(#genIdeas) > .message.partner:first-child { display: none; }
body:has(#genIdeas) .chat-input-area, body:has(#genIdeas) .settings-summary { display: none !important; }


/* 09.11 (владелец: «кнопку Готово не видно, прокрутка глючит, не понимаю, что делать»): на телефоне внизу закреплено нижнее меню и закрывало «Готово».
   Теперь «Готово» липнет к нижнему краю экрана над меню (видна всегда), а у панели есть отступ снизу, чтобы её можно было долистать. */
@media (max-width: 768px) {
    body.has-chat-page.keep-nav .settings-panel { margin-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); scroll-margin-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
    body.has-chat-page.keep-nav .sp-done {
        position: sticky; bottom: calc(66px + env(safe-area-inset-bottom, 0px)); z-index: 5; /* sp-done-sticky */
        box-shadow: 0 -10px 18px var(--card-bg, #26262c), 0 8px 18px rgba(214, 51, 132, .3);
    }
}
.sp-hint { margin: 0 0 10px; padding: 9px 12px; border-radius: 12px; font-size: .86rem; line-height: 1.4; color: var(--text-secondary); background: rgba(214, 51, 132, .08); border: 1px solid rgba(214, 51, 132, .18); }


/* 09.11 (владелец: «две прокрутки, внешняя ебёт мозг»), одна прокрутка на странице генератора.
   Страница не листается вообще (html и body заблокированы по высоте экрана), листается только область рассказа внутри. Языки и SEO-блок остаются в разметке под
   экраном для поисковиков, но пользователь их тут не прокручивает. Нижнее меню занимает свои 60 px, поле ввода и кнопка «Готово» над ним. */
@media (max-width: 1024px) {
    html:has(body.has-chat-page), body.has-chat-page { height: 100vh; height: var(--app-h, 100dvh); overscroll-behavior-y: auto; }
    body.has-chat-page > #ero-lang, body.has-chat-page > .seo-page { position: fixed; left: -9999px; top: 0; width: 1px; height: 1px; overflow: hidden; }
    body.has-chat-page > .app { height: 100vh; height: var(--app-h, 100dvh); min-height: 0; max-height: var(--app-h, 100dvh); }   /* story/index.css даёт .app min-height: 100vh: на телефоне с адресной строкой это выше видимой области, отсюда внешняя прокрутка */
    body.has-chat-page .main { height: 100vh; height: var(--app-h, 100dvh); display: flex; flex-direction: column; box-sizing: border-box; padding-bottom: 0 !important; }
    body.has-chat-page.keep-nav .main { padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important; }
    body.has-chat-page .chat-page { flex: 1 1 auto; min-height: 0; height: auto; }
    body.has-chat-page .chat-messages { overflow-y: auto; flex: 1 1 auto; min-height: 0; overscroll-behavior-y: auto; scroll-behavior: auto; }
}

/* 09.11 панель настроек рассказа на телефоне: открывается на всю область, листается сама, кнопка «Готово» всегда внизу на виду; кнопка «Назад» сверху. */
@media (max-width: 1024px) {
    body.has-chat-page .main, body.has-chat-page .chat-page { overflow: clip; }
    body.has-chat-page:has(#settingsPanel[style*="display: block"]) .chat-messages,
    body.has-chat-page:has(#settingsPanel[style*="display: block"]) .chat-header-bar,
    body.has-chat-page:has(#settingsPanel[style*="display: block"]) .gen-mode-bar,
    body.has-chat-page:has(#settingsPanel[style*="display: block"]) .chat-input-area,
    body.has-chat-page:has(#settingsPanel[style*="display: block"]) .settings-summary { display: none !important; }
    body.has-chat-page .settings-panel[style*="display: block"] { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior-y: auto; margin: 0 0 8px !important; -webkit-overflow-scrolling: touch; }
    body.has-chat-page.keep-nav .settings-panel .sp-done { position: sticky; bottom: 0 !important; z-index: 5; }
    .gen-back { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; margin: 0 0 6px; padding: 6px 12px 6px 8px; border-radius: 999px; font-size: .9rem; font-weight: 700; color: var(--text-primary); background: var(--card-bg); border: 1px solid var(--border-light); text-decoration: none; }
}
@media (min-width: 1025px) { .gen-back { display: none; } }

/* 09.11 экран «Какой рассказ написать?» на телефоне: шапка компактная (без аватара и подзаголовка), поле ниже, чтобы кнопка «Создать» целиком помещалась над нижним меню без липкой подложки. */
@media (max-width: 768px) {
    body.has-chat-page.gen-fresh .chat-header-bar { padding: 2px 0 6px; gap: 8px; }
    body.has-chat-page.gen-fresh .chat-header-bar .char-avatar,
    body.has-chat-page.gen-fresh .chat-header-bar .char-status { display: none; }
    body.has-chat-page.gen-fresh .chat-header-bar .char-name { font-size: .85rem; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    body.has-chat-page .gen-start { padding: 14px 14px 12px; }
    body.has-chat-page .gen-start .gs-input { min-height: 64px; }
}

/* 09.11 «Новый рассказ»: после прошлого рассказа на странице всегда есть явная кнопка начать заново (раньше был виден только старый текст и «Продолжить»). */
.gen-topline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 6px; }
.gen-topline .gen-back { margin: 0; }
.gen-new { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 0; border-radius: 999px; font: inherit; font-size: .9rem; font-weight: 800; color: #fff; cursor: pointer;
    background: linear-gradient(135deg, #ff4d9a, #d6337f 55%, #a855f7); }
.gen-new[hidden] { display: none; }
@media (min-width: 1025px) { .gen-topline:not(:has(.gen-new:not([hidden]))) { display: none; } }

/* 09.11 чтение рассказа на телефоне: шапка компактнее (без аватара и подзаголовка), чтобы под текст оставалось больше места. */
@media (max-width: 768px) {
    body.has-chat-page:not(.gen-fresh) .chat-header-bar { padding: 2px 0 6px; gap: 8px; }
    body.has-chat-page:not(.gen-fresh) .chat-header-bar .char-avatar,
    body.has-chat-page:not(.gen-fresh) .chat-header-bar .char-status { display: none; }
    body.has-chat-page:not(.gen-fresh) .chat-header-bar .char-name { font-size: .85rem; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* 09.11 «Удалить рассказ» под рассказом: тихая кнопка, красная после первого нажатия. */
.story-actions .delete-btn { order: 5; flex: 1 1 calc(50% - 4px); justify-content: center; min-height: 40px; font-size: 13.5px; background: transparent; color: var(--text-secondary, #a59aa8); border: 1px dashed var(--border-light, rgba(255, 255, 255, .18)); }
.story-actions .delete-btn.armed { color: #fff; background: #c62f4a; border: 1px solid #c62f4a; }

/* 09.11 низкие экраны (320x640): в карточке нового рассказа прячем счётчик и подсказку режима, чтобы «Создать» оставалась над нижним меню. */
@media (max-width: 768px) and (max-height: 700px) {
    body.has-chat-page.gen-fresh .chat-header-bar .char-messages-left,
    body.has-chat-page.gen-fresh .gs-modehint { display: none; }
    body.has-chat-page.gen-fresh .gs-title { font-size: 18px; margin-bottom: 8px; }
}

/* 09.11 чтение рассказа на телефоне: счётчик сообщений уходит из шапки (он есть в окне «Продолжить» и под полем), под текст остаётся больше места. */
@media (max-width: 768px) { body.has-chat-page:not(.gen-fresh) .chat-header-bar .char-messages-left { display: none; } }
/* 09.11 плашка «Подарок новичку» не ложится поверх открытого бокового меню */
body:has(.sidebar.open) .rw-sheet, body:has(.sidebar.open) .rw-backdrop { display: none !important; }

/* 09.11 экран 320 px: текст кнопки «Создать рассказ бесплатно» не упирается в край */
@media (max-width: 340px) { .gs-go { font-size: 14px; gap: 5px; padding: 0 10px; } }

/* 09.11 ПК (1025 px и шире): страница генератора тоже на один экран, листается только область рассказа (раньше ещё листалась страница из-за SEO-блока под генератором);
   шапка компактнее, чтобы на текст оставалось больше места. SEO-блок и языки остаются в разметке за краем экрана. */
@media (min-width: 1025px) {
    body.has-chat-page:has(#genModeBar) { height: 100vh; height: var(--app-h, 100dvh); overflow: hidden; }
    body.has-chat-page:has(#genModeBar) > .app { height: 100vh; height: var(--app-h, 100dvh); min-height: 0; max-height: var(--app-h, 100dvh); }
    body.has-chat-page:has(#genModeBar) > #ero-lang, body.has-chat-page:has(#genModeBar) > .seo-page { position: fixed; left: -9999px; top: 0; width: 1px; height: 1px; overflow: hidden; }
    body.has-chat-page:has(#genModeBar) .main { height: 100vh; height: var(--app-h, 100dvh); display: flex; flex-direction: column; box-sizing: border-box; padding-bottom: 12px; }
    body.has-chat-page:has(#genModeBar) .chat-page { flex: 1 1 auto; min-height: 0; height: auto; }
    body.has-chat-page:has(#genModeBar) .chat-messages { overflow-y: auto; flex: 1 1 auto; min-height: 0; }
    body.has-chat-page:has(#genModeBar) .chat-header-bar .char-avatar,
    body.has-chat-page:has(#genModeBar) .chat-header-bar .char-status { display: none; }
    body.has-chat-page:has(#genModeBar) .chat-header-bar { padding: 8px 24px; }
}

/* 10.11 бесплатный отрывок озвучки: заметная кнопка и блок с плеером под рассказом */
.story-actions .preview-btn { order: 2; flex: 1 1 100%; justify-content: center; min-height: 44px; font-size: 14.5px; font-weight: 700; color: #ff8fc0; background: rgba(214, 51, 132, .1); border: 1px solid rgba(214, 51, 132, .55); }
.story-actions .audio-btn { order: 2; }
.vp-sample { margin-top: 10px; padding: 12px 14px; border-radius: 14px; background: rgba(214, 51, 132, .08); border: 1px solid rgba(214, 51, 132, .25); }
.vp-sample .vp-t { font-weight: 700; font-size: .95rem; margin-bottom: 6px; }
.vp-sample audio { width: 100%; margin: 6px 0 8px; }
.vp-sample .vp-cta { font-size: .86rem; opacity: .88; margin-bottom: 8px; }
.vp-sample .vp-full { width: 100%; min-height: 42px; border: 0; border-radius: 999px; font: inherit; font-weight: 800; color: #fff; cursor: pointer; background: linear-gradient(135deg, #ff4d9a, #d6337f 55%, #a855f7); }

/* 10.11 (владелец: «эти темы зачем, они мешаются»): большие кнопки готовых тем скрыты (остаются в разметке для «Придумать идею»), карточка нового рассказа короткая */
.gen-start .gs-or, .gen-start .gs-chips { display: none; }
.gs-rand { display: inline-flex; align-items: center; gap: 6px; margin: 8px 0 0; padding: 6px 12px; border-radius: 999px; border: 1px dashed rgba(214, 51, 132, .5); background: transparent; color: var(--text-secondary, #a59aa8); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.gs-rand:hover, .gs-rand:active { color: #ff8fc0; border-color: rgba(214, 51, 132, .9); }


/* 11.11: совсем низкие экраны (320x568): после добавления «Придумать идею» кнопка «Создать» уходила под нижнее меню на 20 px, отступы карточки компактнее. */
@media (max-width: 768px) and (max-height: 600px) {
    body.has-chat-page.gen-fresh .gen-start .gs-input { min-height: 46px; }
    body.has-chat-page.gen-fresh .gs-rand { margin-top: 6px; padding: 4px 12px; }
    body.has-chat-page.gen-fresh .gen-start .gen-mode-bar { margin: 6px 0 2px; }
    body.has-chat-page.gen-fresh .gs-go { min-height: 46px; margin-top: 6px; }
    body.has-chat-page.gen-fresh .gs-note { margin-top: 8px; }
    body.has-chat-page.gen-fresh .gen-start { padding: 12px 14px 8px; }
}


/* 13.11: быстрые варианты «Изменить» под кнопками готового рассказа: компактный ряд, на телефоне переносится */
.tweak-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px; }
.tweak-chip { border: 1px solid var(--border-color, rgba(255, 255, 255, .18)); background: transparent; color: inherit; border-radius: 999px; padding: 7px 13px; font: inherit; font-size: .85rem; font-weight: 500; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tweak-chip:hover, .tweak-chip:active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tweak-title { flex-basis: 100%; font-size: .8rem; opacity: .7; }

/* 13.11 (владелец: «кнопку «Изменить» к кнопкам, где «Удалить»»): внизу один ряд: «Изменить» слева, «Удалить рассказ» справа */
.story-actions .edit-btn { order: 4; flex: 1 1 calc(50% - 4px); justify-content: center; min-height: 40px; font-size: 13.5px; }

/* 16.11: «Мои герои» */
.gs-cast { margin: 8px 0 0; }
.gs-cast-row { display: flex; flex-wrap: wrap; gap: 6px; }
.gs-cast-chip { display: inline-flex; align-items: center; border: 1px solid rgba(214, 51, 132, .4); border-radius: 999px; background: rgba(214, 51, 132, .1); }
.gs-cast-use { background: none; border: 0; color: inherit; font: inherit; font-size: 13px; padding: 7px 4px 7px 12px; cursor: pointer; min-height: 36px; }
.gs-cast-del { background: none; border: 0; color: inherit; opacity: .6; font-size: 18px; line-height: 1; padding: 0 12px 0 6px; cursor: pointer; min-height: 36px; }
.gs-cast-add { margin: 8px 0 0; background: none; border: 1px dashed rgba(214, 51, 132, .5); color: inherit; font: inherit; font-size: 13px; border-radius: 999px; padding: 8px 14px; cursor: pointer; min-height: 36px; }
.gs-cast-form { display: grid; gap: 8px; margin: 8px 0 0; }
.gs-cast-form input { width: 100%; box-sizing: border-box; font-size: 16px; padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .18); background: rgba(255, 255, 255, .06); color: inherit; }
.gs-cast-err { color: #ff8aa8; font-size: 13px; }
.gs-cast-btns { display: flex; gap: 8px; }
.gs-cast-save, .gs-cast-cancel { font: inherit; font-size: 14px; border-radius: 10px; padding: 10px 16px; cursor: pointer; border: 1px solid rgba(214, 51, 132, .5); color: inherit; background: none; min-height: 40px; }
.gs-cast-save { background: #D63384; border-color: #D63384; color: #fff; }
.gs-cast[hidden], .gs-cast-form[hidden], .gs-cast-err[hidden], .gs-cast-add[hidden] { display: none !important; }   /* 16.11: display у этих блоков перебивал атрибут hidden, форма была открыта всегда */
