/* ===== Общие стили чата ===== */
.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; }
