/* Дополнительные стили чат-бота, продолжают тему styles.css */

#chat-box {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: 1.25rem;
    margin-bottom: 1rem;
    max-height: 55vh;
    overflow-y: auto;
}

#chat-box::-webkit-scrollbar {
    width: 6px;
}
#chat-box::-webkit-scrollbar-thumb {
    background: rgba(135, 251, 234, 0.25);
    border-radius: 999px;
}

.msg {
    max-width: 85%;
    padding: 0.8rem 1.1rem;
    border-radius: 18px;
    font-size: 0.92rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.msg-user {
    align-self: flex-end;
    background: rgba(135, 251, 234, 0.14);
    color: #e6faff;
    border: 1px solid rgba(135, 251, 234, 0.25);
    border-bottom-right-radius: 4px;
}

.msg-bot {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.04);
    color: #d6f4ff;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom-left-radius: 4px;
}

.msg-error {
    align-self: center;
    color: #ffb4b4;
    background: rgba(255, 90, 90, 0.08);
    border: 1px solid rgba(255, 120, 120, 0.25);
    font-size: 0.85rem;
}

#chat-input-row {
    width: 100%;
    display: flex;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
}

#chat-input {
    flex: 1;
    padding: 0.85rem 1.1rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e6faff;
    font-family: inherit;
    font-size: 0.92rem;
    outline: none;
    resize: none;
    transition: border-color 0.3s ease;
}

#chat-input:focus {
    border-color: #87fbea;
}

#send-btn {
    flex-shrink: 0;
    padding: 0 1.4rem;
}

#send-btn:disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* --- Панель лимитов / профиль --- */
#usage-panel {
    width: 100%;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.usage-row {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.usage-row-head {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: rgba(192, 239, 255, 0.55);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.usage-bar-track {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

.usage-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #87fbea, #4fd1c5);
    transition: width 0.4s ease;
}

.usage-bar-fill.warn {
    background: linear-gradient(90deg, #ffd08a, #ff9d5c);
}

.usage-bar-fill.danger {
    background: linear-gradient(90deg, #ff9d9d, #ff5a5a);
}

/* --- Профиль / вход --- */
#profile-row {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
}

#profile-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
}

#profile-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
    background: rgba(135, 251, 234, 0.14);
}

#profile-name {
    font-size: 0.85rem;
    color: #e6faff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.yandex-login-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1.1rem;
    border-radius: 14px;
    background: #fc3f1d;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
    transition: 0.3s ease;
}

.yandex-login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(252, 63, 29, 0.4);
}

@media (max-width: 480px) {
    #chat-box { max-height: 60vh; }
    .msg { max-width: 92%; }
}

/* --- Экраны входа / согласия --- */
.auth-card {
    width: 100%;
    padding: 2.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.1rem;
    text-align: center;
}

.auth-text {
    margin: 0;
    color: rgba(192, 239, 255, 0.65);
    font-size: 0.92rem;
    line-height: 1.6;
}

.auth-btn-lg {
    font-size: 0.95rem;
    padding: 0.75rem 1.6rem;
}

.consent-avatar-wrap {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(135, 251, 234, 0.14);
    border: 1px solid rgba(135, 251, 234, 0.25);
}

.consent-avatar-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.consent-check-row {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    font-size: 0.85rem;
    color: rgba(214, 244, 255, 0.85);
    text-align: left;
    cursor: pointer;
    max-width: 340px;
}

.consent-check-row input[type="checkbox"] {
    margin-top: 0.2rem;
    width: 16px;
    height: 16px;
    accent-color: #87fbea;
    flex-shrink: 0;
    cursor: pointer;
}

.consent-check-row a {
    color: #87fbea;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* --- Область приложения после входа --- */
.app-area {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.btn-ghost-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    background: rgba(135, 251, 234, 0.12);
    color: #87fbea;
    border-radius: 12px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: 0.25s ease;
}
.btn-ghost-sm:hover {
    background: rgba(135, 251, 234, 0.2);
}

#profile-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

/* --- Промокоды --- */
.promo-panel {
    width: 100%;
    display: flex;
    gap: 0.6rem;
    padding: 0.85rem 1rem;
    margin-bottom: 0.6rem;
}

#promo-input {
    flex: 1;
    padding: 0.7rem 1rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e6faff;
    font-family: inherit;
    font-size: 0.88rem;
    outline: none;
    text-transform: uppercase;
}
#promo-input:focus {
    border-color: #87fbea;
}

.promo-msg {
    width: 100%;
    font-size: 0.82rem;
    padding: 0.6rem 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    text-align: center;
}
.promo-msg.success {
    color: #9dffc3;
    background: rgba(120, 255, 170, 0.08);
    border: 1px solid rgba(120, 255, 170, 0.25);
}
.promo-msg.error {
    color: #ffb4b4;
    background: rgba(255, 90, 90, 0.08);
    border: 1px solid rgba(255, 120, 120, 0.25);
}

/* --- Список чатов --- */
#chats-toolbar {
    width: 100%;
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    align-items: center;
}

#chats-select {
    flex: 1;
    padding: 0.6rem 0.9rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e6faff;
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
}

/* --- Профиль (страница) --- */
.profile-card {
    width: 100%;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    text-align: center;
    margin-bottom: 1.25rem;
}

.profile-card-avatar {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    object-fit: cover;
    background: rgba(135, 251, 234, 0.14);
    border: 2px solid rgba(135, 251, 234, 0.3);
    margin-bottom: 0.6rem;
}

.profile-card-name {
    margin: 0;
    font-size: 1.15rem;
    color: #e6faff;
}

.profile-card-number {
    margin: 0;
    font-size: 0.85rem;
    color: #87fbea;
    letter-spacing: 0.03em;
}

.profile-card-login {
    margin: 0;
    font-size: 0.78rem;
    color: rgba(192, 239, 255, 0.45);
}

.dot-row {
    display: flex;
    gap: 4px;
}
.dot-row span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #87fbea;
    opacity: 0.5;
    animation: dotPulse 1.2s infinite ease-in-out;
}
.dot-row span:nth-child(2) { animation-delay: 0.2s; }
.dot-row span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotPulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* ==================== Новый минималистичный layout ==================== */

.gate-screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.gate-screen .brand {
    text-align: center;
    margin-bottom: 1.75rem;
}

.gate-screen .auth-card {
    max-width: 26rem;
    width: 100%;
}

/* --- Общий шелл: сайдбар + основная область --- */
.app-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

#sidebar {
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 1rem 0.85rem;
    background: rgba(255, 255, 255, 0.02);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    height: 100vh;
    position: sticky;
    top: 0;
}

.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.4rem 1rem;
}

.sidebar-logo {
    font-family: 'font', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: #e6faff;
}

.btn-icon {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    border: none;
    background: rgba(135, 251, 234, 0.12);
    color: #87fbea;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    transition: 0.25s ease;
    flex-shrink: 0;
}
.btn-icon:hover {
    background: rgba(135, 251, 234, 0.22);
}

#chats-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding-right: 2px;
}

#chats-list::-webkit-scrollbar { width: 4px; }
#chats-list::-webkit-scrollbar-thumb {
    background: rgba(135, 251, 234, 0.2);
    border-radius: 999px;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 0.7rem;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.82rem;
    color: rgba(214, 244, 255, 0.65);
    transition: 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
}

.chat-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: #e6faff;
}

.chat-item.active {
    background: rgba(135, 251, 234, 0.1);
    color: #87fbea;
}

.chat-item-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-del {
    flex-shrink: 0;
    opacity: 0;
    background: none;
    border: none;
    color: rgba(255, 150, 150, 0.7);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0 2px;
    transition: opacity 0.2s ease;
}
.chat-item:hover .chat-item-del {
    opacity: 1;
}

.sidebar-bottom {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-link {
    display: block;
    text-align: left;
    padding: 0.55rem 0.7rem;
    border-radius: 10px;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 0.82rem;
    color: rgba(192, 239, 255, 0.55);
    text-decoration: none;
    cursor: pointer;
    transition: 0.2s ease;
}
.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.04);
    color: #e6faff;
}
.sidebar-link-danger:hover {
    color: #ffb4b4;
}

.donate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 0.9rem;
    border-radius: 12px;
    background: rgba(255, 105, 135, 0.1);
    border: 1px solid rgba(255, 105, 135, 0.25);
    color: #ff9db3;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: 0.25s ease;
}
.donate-btn:hover {
    background: rgba(255, 105, 135, 0.18);
    transform: translateY(-1px);
}

/* --- Основная область --- */
#main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 46rem;
    width: 100%;
    margin: 0 auto;
    padding: 1.25rem 1.25rem 1.5rem;
    min-height: 100vh;
}

#usage-bar-compact {
    display: flex;
    gap: 1.5rem;
    padding: 0.5rem 0.25rem 1rem;
    margin-bottom: 0.5rem;
}

.usage-compact-item {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.usage-compact-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(192, 239, 255, 0.4);
    flex-shrink: 0;
    width: 42px;
}

.usage-compact-item .usage-bar-track {
    flex: 1;
}

.usage-compact-value {
    font-size: 10px;
    color: rgba(192, 239, 255, 0.4);
    flex-shrink: 0;
    white-space: nowrap;
}

#main-area #chat-box {
    flex: 1;
    background: none;
    backdrop-filter: none;
    border: none;
    box-shadow: none;
    padding: 0.5rem 0.25rem;
    margin-bottom: 0.75rem;
    max-height: none;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

#main-area #chat-input-row {
    margin-bottom: 0.5rem;
}

#main-area #state-limit {
    background: rgba(255, 90, 90, 0.06);
    border: 1px solid rgba(255, 120, 120, 0.2);
    border-radius: 14px;
    padding: 0.75rem 1rem;
    width: 100%;
}

@media (max-width: 900px) {
    #sidebar {
        width: 220px;
    }
    #main-area {
        padding: 1rem;
    }
}

@media (max-width: 680px) {
    .app-shell {
        flex-direction: column;
    }
    #sidebar {
        width: 100%;
        height: auto;
        position: relative;
        flex-direction: row;
        align-items: center;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }
    .sidebar-top { display: none; }
    #chats-list {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: visible;
    }
    .sidebar-bottom {
        flex-direction: row;
        border-top: none;
        padding-top: 0;
        margin-left: 0.5rem;
    }
    .sidebar-link, .donate-btn {
        white-space: nowrap;
    }
}

/* --- Профиль: кнопка выйти в углу карточки --- */
.profile-card {
    position: relative;
}

.profile-card-logout {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 0.4rem 0.8rem;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #ffb4b4;
    background: rgba(255, 90, 90, 0.08);
    border: 1px solid rgba(255, 120, 120, 0.25);
    font-family: inherit;
    cursor: pointer;
    transition: 0.25s ease;
}
.profile-card-logout:hover {
    background: rgba(255, 90, 90, 0.18);
    border-color: rgba(255, 120, 120, 0.45);
}

/* --- Markdown внутри ответов бота --- */
.msg-bot .md-p {
    margin: 0 0 0.5rem;
}
.msg-bot .md-p:last-child {
    margin-bottom: 0;
}

.msg-bot .md-heading {
    margin: 0.7rem 0 0.4rem;
    color: #e6faff;
    font-family: 'font', sans-serif;
    line-height: 1.3;
}
.msg-bot .md-heading:first-child {
    margin-top: 0;
}
.msg-bot h3.md-heading { font-size: 1.05rem; }
.msg-bot h4.md-heading { font-size: 0.98rem; }
.msg-bot h5.md-heading, .msg-bot h6.md-heading { font-size: 0.92rem; }

.msg-bot .md-list {
    margin: 0 0 0.5rem;
    padding-left: 1.3rem;
}
.msg-bot .md-list li {
    margin-bottom: 0.25rem;
}

.msg-bot strong {
    color: #e6faff;
    font-weight: 700;
}
.msg-bot em {
    font-style: italic;
    color: #d6f4ff;
}

.msg-bot .md-code {
    background: rgba(135, 251, 234, 0.1);
    border: 1px solid rgba(135, 251, 234, 0.2);
    border-radius: 5px;
    padding: 0.1rem 0.4rem;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    color: #87fbea;
}

.msg-bot .md-pre {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 0.75rem 0.9rem;
    margin: 0.5rem 0;
    overflow-x: auto;
}
.msg-bot .md-pre code {
    font-family: 'Courier New', monospace;
    font-size: 0.82rem;
    color: #d6f4ff;
    white-space: pre;
}

.msg-bot a {
    color: #87fbea;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* --- Markdown: цитаты, линии, чекбоксы, таблицы, зачёркнутый, картинки --- */
.msg-bot del {
    color: rgba(192, 239, 255, 0.45);
    text-decoration: line-through;
}

.msg-bot .md-quote {
    margin: 0.5rem 0;
    padding: 0.4rem 0 0.4rem 0.9rem;
    border-left: 3px solid rgba(135, 251, 234, 0.4);
    background: rgba(255, 255, 255, 0.02);
    border-radius: 0 8px 8px 0;
    color: rgba(214, 244, 255, 0.75);
}
.msg-bot .md-quote .md-p {
    margin: 0;
}

.msg-bot .md-hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 0.75rem 0;
}

.msg-bot .md-checklist {
    list-style: none;
    padding-left: 0.2rem;
}
.msg-bot .md-check-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}
.msg-bot .md-checkbox {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin-top: 0.15rem;
    border-radius: 4px;
    border: 1px solid rgba(135, 251, 234, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #87fbea;
}
.msg-bot .md-check-item.checked .md-checkbox {
    background: rgba(135, 251, 234, 0.2);
}
.msg-bot .md-check-item.checked {
    color: rgba(192, 239, 255, 0.5);
    text-decoration: line-through;
}

.msg-bot .md-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.6rem 0;
    font-size: 0.85rem;
    overflow: hidden;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.msg-bot .md-table th,
.msg-bot .md-table td {
    padding: 0.5rem 0.7rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.msg-bot .md-table th {
    background: rgba(135, 251, 234, 0.08);
    color: #87fbea;
    font-weight: 700;
}
.msg-bot .md-table tr:last-child td {
    border-bottom: none;
}

.msg-bot .md-img {
    max-width: 100%;
    border-radius: 10px;
    margin: 0.4rem 0;
    display: block;
}