/* ===== Общие стили чата ===== */
.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%;
    background: linear-gradient(135deg, #D63384, #E91E63);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.4rem;
    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; }
}