/* ================= BASE ================= */

.chat-page {
    --header-offset: 0px;
    background: radial-gradient(circle at top, #1a131f 0%, #050307 55%);
    height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    color: #fff;
}

/* ================= HEADER ================= */

.chat-header {
    display: flex;
    align-items: center;
    background: #141016;
    border-bottom: 1px solid #0b090d;
    padding: 10px 14px;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.65);
    border-radius: 0 0 18px 18px;

    will-change: transform;
    transform: translateY(var(--header-offset));
    transition: transform 0.16s ease-out, box-shadow 0.16s ease-out;
}

.chat-page.scrolled .chat-header {
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

.chat-back {
    background: transparent;
    border: none;
    color: #f3c7ff;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.chat-back:hover {
    background: #211827;
    transform: translateX(-1px);
}

.chat-header-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 18px rgba(0, 0, 0, 0.6);
}

.chat-header-info {
    flex: 1;
    display: flex;
    align-items: center;
    min-width: 0;
}

.chat-header-name-row {
    flex: 1;
    display: flex;
    justify-content: center;
}

.chat-header-user-btn {
    all: unset;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    margin-left: auto;
}

.chat-header-name {
    font: 700 1.15rem 'Montserrat', Arial, sans-serif;
    color: #fff;
    letter-spacing: -0.03em;
}

.chat-status-info {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
}

.chat-header-status-online {
    width: 9px;
    height: 9px;
    background: #43ff88;
    border-radius: 50%;
    box-shadow: 0 0 4px rgba(67, 255, 136, 0.9);
}

.chat-header-status-text {
    color: #d8cfff;
    font-size: 0.88rem;
}

.name-and-status {
    display: flex;
    align-items: center;
    flex-direction: column;
}
/* --- upload indicator --- */

.chat-upload-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    font-size: 0.83rem;
    color: #d5c9f6;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.chat-upload-indicator.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.chat-upload-progress {
    flex: 0 0 78px;
    height: 3px;
    border-radius: 999px;
    background: #312535;
    overflow: hidden;
}

.chat-upload-progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #ff4eb6, #ffbdf1);
    transition: width 0.15s linear;
}

.chat-upload-progress-fill.error {
    background: #ff5b74;
}

.chat-send-btn.is-uploading svg {
    opacity: 0.3;
}

.chat-send-btn.is-uploading {
    position: relative;
}

.chat-send-btn.is-uploading::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    animation: chat-upload-spin 0.8s linear infinite;
}

@keyframes chat-upload-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ================= MESSAGES ================= */

.chat-messages {
    width: 100%;
    flex: 1 1 auto;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 10px 96px;
    box-sizing: border-box;
    min-height: 0;
    scroll-behavior: smooth;
}


.chat-msg {
    display: flex;
    opacity: 0;
    transform: translateY(6px);
    animation: chatMsgIn 0.18s ease-out forwards;
}

@keyframes chatMsgIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-msg.ai {
    justify-content: flex-start;
    padding-right: 40px;
}

.chat-msg.user {
    justify-content: flex-end;
    padding-left: 40px;
}

.btn-teh {
    background: linear-gradient(135deg, #ff4eb6, #bb5cff);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 8px;
    width: 100%
}

.button-wrapper {
    text-align: center;
}

/* bubble */

.chat-msg-bubble {
    position: relative;
    display: inline-block;
    max-width: 80vw;
    padding: 11px 72px 15px 16px;
    border-radius: 22px;
    font-size: 0.96rem;
    word-break: break-word;
    font-family: 'Montserrat', Arial, sans-serif;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}


.chat-msg-bubble.ai {
    background: #18131f;
    color: #f8f4ff;
    border-radius: 20px 20px 20px 6px;
}


.chat-msg-bubble.user {
    background: linear-gradient(135deg, #ff4eb6, #bb5cff);
    color: #fff;
    border-radius: 20px 20px 6px 20px;
}


.chat-msg.ai + .chat-msg.ai .chat-msg-bubble {
    border-top-left-radius: 6px;
    margin-top: 3px;
}

.chat-msg.user + .chat-msg.user .chat-msg-bubble {
    border-top-right-radius: 6px;
    margin-top: 3px;
}

.chat-msg.ai + .chat-msg.user,
.chat-msg.user + .chat-msg.ai {
    margin-top: 12px;
}


.bubble-text {
    display: block;
    min-width: 0;
    overflow-wrap: anywhere;
}

.bubble-meta {
    position: absolute;
    right: 10px;
    bottom: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    opacity: 0.85;
}

.chat-msg-time {
    font-size: 0.68rem;
    line-height: 1;
    white-space: nowrap;
}

.chat-msg-bubble.ai .chat-msg-time {
    color: #9b8fa9;
}

.chat-msg-bubble.user .chat-msg-time {
    color: #f7e6ff;
}

.chat-msg-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.chat-msg-ticks-wrapper {
    display: inline-block;
    position: relative;
}

.chat-msg-status {
    width: 14px;
    height: 14px;
    opacity: 0.9;
}

.second-tick {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}


.chat-msg-img {
    max-width: 240px;
    max-height: 340px;
    border-radius: 14px;
    overflow: hidden;
}

.chat-msg-img img,
.chat-msg-img video {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    border-radius: 14px;
    display: block;
}


/* typing bubble */

.chat-msg.typing .chat-msg-bubble {
    background: #18131f;
    color: #f8f4ff;
    min-width: 56px;
    max-width: 96px;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 20px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #bb8efd;
    opacity: 0.7;
    animation: typingBlink 1.2s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.22s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.44s;
}

@keyframes typingBlink {
    0%,
    100% {
        opacity: 0.6;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-4px);
    }
    60% {
        opacity: 0.6;
        transform: translateY(0);
    }
}

/* ================= INPUT BAR ================= */

.chat-input-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: #120e13;
    border-top: 1px solid #281822;
    z-index: 99;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.8);
}

.chat-plus-btn {
    height: 34px;
    width: 34px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #ff4eb6, #ff9af0);
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    display: block;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 18px rgba(255, 78, 182, 0.8);
}

.chat-plus-btn:disabled {
    background: rgba(255, 78, 182, 0.2);
    box-shadow: none;
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-input-wrap {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #221822;
    border-radius: 20px;
    padding: 7px 12px;
}

.chat-input {
    flex: 1 1 auto;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    color: #fff;
    font-size: 16px;
    font-family: 'Montserrat', Arial, sans-serif;
    resize: none;
}

.chat-input::placeholder {
    color: #817282;
}

.token-balance-wrap.hidden {
    display: none;
}

.token-balance-wrap {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #2f2533;
    font-size: 0.85rem;
    color: #fff;
}

.token-balance {
    font-weight: 500;
}

.chat-send-btn {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: #ff4eb6;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 0 18px rgba(255, 78, 182, 0.8);
}

.chat-send-btn:disabled {
    background: rgba(255, 78, 182, 0.2);
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.6;
}

.chat-send-btn svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

.chat-send-btn:disabled svg {
    opacity: 0.6;
}

.chat-plus-menu {
    position: absolute;
    bottom: 70px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #1e141f;
    padding: 10px 12px;
    border-radius: 16px;
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.7);
    z-index: 100;
    transform: translateY(12px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.22s ease;
}

.chat-plus-menu.show {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.plus-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    color: #fff;
    background: #2a1d2c;
    border: none;
    padding: 9px 14px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.18s, transform 0.12s;
}

.plus-item:hover {
    background: #3a2640;
    transform: translateX(3px);
}

/* ================= MODAL ================= */

.modal {
    position: fixed;
    z-index: 999;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-photo,
.modal-video {
    max-width: 95vw;
    max-height: 90vh;
    border-radius: 18px;
    box-shadow: 0 6px 64px rgba(0, 0, 0, 0.25);
}

.modal-video {
    display: none;
    background: #000;
}

.close-modal {
    position: absolute;
    top: 30px;
    right: 40px;
    color: #fff;
    font-size: 2.2rem;
    cursor: pointer;
    z-index: 2;
    text-shadow: 0 2px 12px #222;
}

.asterisks {
    color: #c64789;
    font-style: italic;
}

.quotes {
    font-style: italic;
    color: white; /* Optional: keep white color for italic */
}

.round-brackets {
    color: pink;
}

i {
    font-style: italic;
}

.chat-msg-date-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
    font-size: 12px;
    color: rgba(255, 192, 203, 0.62);
    position: relative;
}

.chat-msg-date-separator::before,
.chat-msg-date-separator::after {
    content: "";
    flex-grow: 1;
    border-top: 0.5px solid rgba(255, 192, 203, 0.62);;
    margin: 0 10px;
}

.date-text {
    padding: 0 10px;
    position: relative;
    z-index: 1;
    font-size: 14px;
}

.media-placeholder {
    background: #000;
    color: #aaa;
    text-align: center;
    font-size: 18px;
    display: flex;
    justify-content: center;
    flex-direction: column;

    align-items: center;
    border-radius: 22px;
}

.media-placeholder-label {
    font-size: 12px;
    color: #c64789;
    text-align: center;
}

.chat-history-loader {
    width: 100%;
    text-align: center;
    padding: 8px 0 10px;
    display: none;
    color: #c64789;

}

.chat-history-loader .loading-icon {
    width: 26px;
    height: 26px;
    animation: spin 1s linear infinite;
}

.scroll-anchor {
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* ================= PROFILE ================= */

.character-profile {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at top, #1a131f 0%, #050307 55%);
    color: #fff;
    z-index: 200;
    overflow-y: auto;
}

/* HEADER */
.profile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px;
    background: #141016;
    border-bottom: 1px solid #0b090d;
    box-shadow: 0 10px 26px rgba(0,0,0,0.6);
}

.profile-back-btn {
    all: unset;
    color: #f3c7ff;
    font-size: 22px;
    cursor: pointer;
}

.profile-username {
    font-weight: 700;
    letter-spacing: -0.03em;
}

/* HERO */
.profile-hero {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 18px;
}

.profile-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 28px rgba(0,0,0,0.7);
}


.profile-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px 12px;
}

.profile-info-item {
    border-radius: 12px;
    padding: 2px 18px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/*.profile-info-item:last-child {*/
/*    grid-column: span 2; !* occupation на всю ширину *!*/
/*}*/

.info-label,
.info-label-header {
    font-size: 9px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.55);
}

.info-value,
.info-value-header {
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    line-break: auto;
}

.profile-stats {
    display: flex;
    flex: 1;
    justify-content: space-around;
    text-align: center;
}

.profile-stats b {
    display: block;
    font-size: 14px;
}

.profile-stats span {
    font-size: 11px;
    color: #cdbcf7;
}

/* BIO */
.profile-bio {
    padding: 0 18px;
    font-size: 14px;
    color: #f1eaff;
    margin-bottom: 20px;
}

.profile-bio p {
    margin: 0;
    letter-spacing: 0.5px;
    font-size: 12px;
}

/* ACTIONS */
.profile-actions {
    display: flex;
    gap: 10px;
    padding: 16px 18px;
}

.profile-btn {
    flex: 1;
    padding: 9px;
    border-radius: 999px;
    border: 1px solid #3a2640;
    background: #221822;
    color: #fff;
}

.profile-btn.primary {
    background: linear-gradient(135deg, #ff4eb6, #bb5cff);
    border: none;
}

/* GRID */
.profile-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
}

.grid-item {
    aspect-ratio: 1 / 1;
    cursor: pointer;
    position: relative;
    background-color: #18131f;

    background-size: cover;   /* 👈 КЛЮЧЕВОЕ */
    background-position: center;
    background-repeat: no-repeat;
}
.profile-feed.hidden {
    display: none;
}

/* FEED ITEM */
.profile-feed-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 520px;
    margin: 0 auto;
}

.profile-feed-item img {
    display: block;
}

/* мягкая анимация */
.profile-feed {
    flex: 1 1 auto;          /* 👈 растягиваем */
    overflow-y: auto;        /* 👈 ВКЛЮЧАЕМ SCROLL */
    -webkit-overflow-scrolling: touch;

    display: flex;
    flex-direction: column;
    gap: 22px;

    padding: 12px 0 40px;
}

@keyframes feedIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-clone {
    position: fixed;
    z-index: 9999;
    border-radius: 12px;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    transition: all 0.45s cubic-bezier(.22,.61,.36,1);
    will-change: transform;
}

/* HEADER */
.feed-post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 14px;
}

.feed-post-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.feed-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.feed-username {
    font-weight: 600;
    color: #fff;
}

.feed-more {
    all: unset;
    font-size: 20px;
    color: #aaa;
    cursor: pointer;
}

/* MEDIA */
.feed-media {
    width: 100%;
    max-width: 100%;
    height: auto;

    display: block;
    object-fit: cover;

}

/* ACTIONS */
.feed-actions {
    display: flex;
    justify-content: space-between;
    padding: 10px 14px 6px;
}

.feed-actions-left {
    display: flex;
    gap: 12px;
}

.feed-btn {
    all: unset;
    font-size: 20px;
    cursor: pointer;
}

.feed-btn {
    all: unset;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feed-btn img {
    width: 22px;
    height: 22px;
    display: block;
}

/* liked state */
.feed-btn.like.active img {
    filter: drop-shadow(0 0 6px rgba(255, 78, 182, 0.8));
}

.feed-btn.like.active {
    color: #ff4eb6;
}

/* LIKES */
.feed-likes {
    padding: 0 14px;
    font-size: 0.9rem;
    font-weight: 600;
}

/* DESCRIPTION */
.feed-description {
    padding: 4px 14px 0;
    font-size: 0.95rem;
    color: #eae6f5;
}

.feed-description b {
    margin-right: 4px;
}

.character-feed {
    position: fixed;
    inset: 0;
    z-index: 9999;

    display: flex;
    flex-direction: column;

    background: radial-gradient(circle at top, #1a131f, #050307);

    overflow: hidden; /* 👈 scroll будет внутри */
}

.feed-header {
    position: sticky;
    top: 0;
    z-index: 20;

    display: grid;
    grid-template-columns: 44px 1fr 44px;
    align-items: center;

    height: 52px;
    padding: 0 8px;

    background: rgba(14, 11, 18, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);

    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.feed-back-btn {
    all: unset;

    width: 22px;
    height: 36px;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 20px;
    font-weight: 600;

    color: #f3c7ff;
    cursor: pointer;

    border-radius: 50%;
    transition: background 0.15s ease, transform 0.1s ease;
}

.feed-header-title {
    display: flex;
    align-items: center;
    flex-direction: column;
}

.feed-title,
.feed-subtitle{
    justify-self: center;

    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;

    color: #ffffff;
    pointer-events: none;
}

.feed-subtitle {
    font-size: 0.75rem;
    font-weight: 400;
}

.chat-translate-bar {
    position: sticky;
    top: 56px;
    z-index: 20;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;

    padding: 8px 14px;

    font-size: 12.5px;
    line-height: 1;

    background: rgba(14, 11, 18, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);

    border-bottom: 1px solid rgba(255,255,255,0.05)
}

.translate-toggle-btn {
    all: unset;
    cursor: pointer;

    display: flex;
    align-items: center;
    gap: 6px;

    font-size: 12.5px;
    color: #9a9a9a;
}

.translate-toggle-btn::before {
    content: "🌐";
    opacity: 0.6;
}

.translate-toggle-btn.active {
    color: #ffffff;
}

.translate-toggle-btn.active::before {
    content: "🟢";
    opacity: 1;
}

.translate-lang-btn {
    all: unset;
    cursor: pointer;

    font-size: 12.5px;
    font-weight: 500;

    color: #ff4eb6;
}

.translate-lang-btn:hover {
    text-decoration: underline;
}

.translate-lang-popup {
    position: fixed;
    top: calc(56px + 48px);
    left: 14px;
    right: 14px;

    max-height: 60vh;
    overflow-y: auto;

    background: #141016;
    border-radius: 16px;
    padding: 6px;

    box-shadow: 0 18px 60px rgba(0,0,0,0.7);
    z-index: 999;
}

.translate-lang-item {
    width: 100%;
    padding: 14px 14px;

    background: transparent;
    border: none;
    color: #fff;

    font-size: 14px;
    border-radius: 12px;
    text-align: left;

    cursor: pointer;
}

.translate-lang-item:hover {
    background: rgba(255,255,255,0.05);
}

.translate-lang-item.active {
    background: rgba(255,255,255,0.1);
}

.translate-lang-btn.hidden {
    display: none;
}

.chat-header-info {
    position: relative;
}

.chat-header-settings-btn {
    background: none;
    border: none;
    padding: 6px;
    margin-left: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: opacity 0.2s ease, transform 0.15s ease;
}

.chat-header-settings-btn:hover {
    opacity: 1;
    transform: scale(1.05);
}

.chat-header-dots-icon {
    width: 18px;
    height: 18px;
    display: block;
}

.chat-settings-menu {
    position: absolute;
    top: 55px;
    right: 0;
    min-width: 160px;

    background: #121216;
    border-radius: 14px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.6);

    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;

    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: all 0.18s ease;
    z-index: 100;
}

.chat-settings-menu.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.chat-settings-item {
    background: none;
    border: none;
    color: var(--white);
    padding: 10px 12px;
    text-align: left;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s ease;
}

.chat-settings-item:hover {
    background: rgba(255,255,255,0.06);
}

.chat-settings-item.danger {
    color: #ff4d6d;
}

