
/* Global Variables */
:root {
    --ios-bg: #f2f2f7;
    --ios-header: #f9f9f9;
    --ios-border: #c6c6c8;
    --ios-blue: #007aff;
    --ios-green: #34c759;
    --ios-gray: #8e8e93;
    --ios-bubble-receive: #e9e9eb;
    --ios-bubble-send: #95ec69; /* WeChat Green */
}

/* Reset & Base */
* {
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* App Container */
#imessage-view {
    --im-bottom-nav-space: 72px;
    --im-chat-input-space: 14px;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #fff;
    display: flex;
    /* display: none; Removed to allow transition from .app-view */
    flex-direction: column;
    z-index: 200;    
    padding-top: 0 !important; /* Override .app-view padding */
}


/* iMessage (LINE Style) Styles */

/* Group Create & Details Styles */
#create-group-members-list .line-list-item {
    cursor: pointer;
    border-radius: 12px;
    padding: 10px;
    transition: background-color 0.2s;
}
#create-group-members-list .line-list-item:active {
    background-color: #f2f2f7;
}

#group-details-view {
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.group-action-btn:active {
    background-color: #f2f2f7 !important;
}

/* 1. Header */
.line-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px 10px;
    position: absolute;
    top: max(10px, env(safe-area-inset-top, 0px));
    left: 0;
    width: 100%;
    background-color: transparent;
    z-index: 10;
}

.line-header-left {
    font-size: 22px;
    font-weight: 700;
    color: #000;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    background: transparent;
}

.line-header-right {
    display: flex;
    gap: 20px;
    font-size: 20px;
    color: #000;
}

.line-content {
    padding: calc(60px + env(safe-area-inset-top, 0px)) 20px var(--im-bottom-nav-space); /* Top padding for floating header, Bottom padding for nav */
    overflow-y: auto;
    flex: 1;
}

/* 2. Profile Section */
.line-profile {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.line-profile-info {
    display: flex;
    flex-direction: column;
}

.line-profile-name {
    font-size: 24px;
    font-weight: 700;
    color: #000;
    margin-bottom: 4px;
}

.line-profile-sign {
    font-size: 13px;
    color: #8e8e93;
}

.line-profile-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #e5e5ea;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    color: #aeaeb2;
    overflow: hidden;
}

.line-profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 3. Search Bar */
.line-search-container {
    margin-bottom: 20px;
}

.line-search-bar {
    background-color: #e5e5ea;
    border-radius: 20px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #8e8e93;
    font-size: 15px;
}

/* 4. Services Grid */
.line-section {
    margin-bottom: 30px;
}

.line-section-title {
    font-size: 13px;
    color: #8e8e93;
    margin-bottom: 10px;
    font-weight: 600;
}

.line-services-grid {
    display: flex;
    justify-content: space-between;
}

.line-service-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 60px;
    text-align: center;
}

.line-service-icon {
    width: 48px;
    height: 48px;
    background-color: transparent; /* Flat style */
    border-radius: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 32px;
    color: #333;
    box-shadow: none; /* Removed shadow for flat style */
}

.line-service-item span {
    font-size: 11px;
    color: #000;
    white-space: nowrap;
}

/* 5. Lists (Groups, Friends) */
.collapsible-section {
    margin-bottom: 20px;
}

.line-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    margin-bottom: 10px;
}

.toggle-icon {
    font-size: 12px;
    color: #c7c7cc;
    transition: transform 0.2s;
}

.collapsible-section.collapsed .toggle-icon {
    transform: rotate(180deg);
}

.line-section-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.collapsible-section.collapsed .line-section-content {
    display: none;
}

.line-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.line-item-icon {
    width: 44px;
    height: 44px;
    border-radius: 16px;
    background-color: #e5e5ea;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #000;
}

.line-item-icon.bg-light {
    background-color: #fff;
    border: 1px solid #e5e5ea;
}

.line-item-text {
    font-size: 16px;
    color: #000;
    font-weight: 500;
}

.line-item-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: #e5e5ea;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #aeaeb2;
    overflow: hidden;
}

.line-item-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 6. Bottom Navigation */
.line-bottom-nav-container {
    position: absolute;
    bottom: 12px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    z-index: 100;
    pointer-events: none;
}

.line-bottom-nav {
    pointer-events: auto;
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    padding: 3px;
    border-radius: 40px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    width: auto;
    min-width: min(316px, calc(100vw - 32px));
    justify-content: space-between;
    align-items: stretch;
    height: 49px;
    position: relative;
}

/* Animated Indicator for iMessage */
.line-nav-indicator {
    position: absolute;
    top: 3px; 
    bottom: 3px; 
    /* Width is handled by JS dynamically */
    background-color: rgba(0, 0, 0, 0.06);
    border-radius: 36px; 
    z-index: 0;
    transition: left 0.3s cubic-bezier(0.25, 1, 0.5, 1), width 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    left: 4px; /* Initial position */
}

.line-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    color: #8e8e93;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    z-index: 1;
    padding: 0 11px;
    min-width: 68px;
    height: 100%;
    transition: color 0.3s;
}

.line-nav-item i {
    font-size: 19px;
    margin-bottom: 0;
}

.line-nav-item span {
    font-size: 10px;
    display: block;
}

.line-nav-item.active {
    color: #000;
}

/* Animations */
@keyframes imFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.line-content, .chats-content, .calls-content {
    animation: imFadeIn 0.3s ease;
}

.memory-content {
    display: none;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    position: relative;
    overflow: hidden;
    background: #f2f2f7;
    animation: imFadeIn 0.3s ease;
}

.memory-top-friends-scroll {
    display: flex;
    overflow-x: auto;
    padding: calc(62px + env(safe-area-inset-top, 0px)) 16px 18px;
    gap: 16px;
    scrollbar-width: none;
    background: #f2f2f7;
    align-items: flex-start;
    flex-shrink: 0;
    touch-action: pan-x;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
}

.memory-top-friends-scroll::-webkit-scrollbar {
    display: none;
}

.memory-friend-story-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    flex-shrink: 0;
    width: 72px;
    transition: opacity 0.2s ease;
}

.memory-friend-story-item:active {
    opacity: 0.7;
}

.memory-friend-story-avatar-wrapper {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    padding: 3px;
    background: linear-gradient(45deg, #007aff 0%, #34c759 100%);
    display: flex;
    justify-content: center;
    align-items: center;
}

.memory-friend-story-item.active .memory-friend-story-avatar-wrapper {
    background: linear-gradient(45deg, #c6c6c8 0%, #c6c6c8 100%);
}

.memory-friend-story-avatar-img,
.memory-friend-story-avatar-icon {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background: #ffffff;
    border: 3px solid #ffffff;
}

.memory-friend-story-avatar-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    color: #8e8e93;
    font-size: 24px;
}

.memory-friend-story-name {
    width: 100%;
    color: #333333;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.memory-library-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 8px 18px var(--im-bottom-nav-space);
    background: #f2f2f7;
}

.memory-selected-name {
    display: none;
}

.memory-files-title {
    display: none;
}

.memory-search-bar {
    width: 100%;
    height: 36px;
    margin-bottom: 18px;
    padding: 0 10px;
    border-radius: 10px;
    background: #e5e5ea;
    color: #8e8e93;
    font-size: 16px;
    display: flex;
    align-items: center;
    box-sizing: border-box;
}

.memory-search-bar i {
    margin-right: 8px;
}

.memory-section-title {
    margin: 0 0 10px;
    color: #111111;
    font-size: 18px;
    font-weight: 700;
}

.memory-files-group {
    margin-bottom: 20px;
    overflow: hidden;
    border-radius: 12px;
    background: #ffffff;
}

.memory-file-row {
    display: flex;
    align-items: center;
    min-height: 50px;
    padding: 0 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    box-sizing: border-box;
}

.memory-file-row:last-child {
    border-bottom: none;
}

.memory-file-row span {
    flex: 1;
    color: #111111;
    font-size: 17px;
    font-weight: 500;
}

.memory-file-icon {
    width: 26px;
    margin-right: 15px;
    color: #007aff;
    font-size: 22px;
    text-align: center;
}

.memory-download-icon {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #e5e5ea;
    font-size: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 2px;
}

.memory-file-chevron {
    color: #c7c7cc;
    font-size: 14px;
}

.memory-empty-state {
    width: 100%;
    padding: 24px 20px;
    color: #8e8e93;
    font-size: 14px;
    text-align: center;
}

.memory-location-bottom-sheet {
    height: auto;
    min-height: 220px;
    max-height: 70%;
    background: #f2f2f7;
    display: flex;
    flex-direction: column;
}

.memory-location-sheet-empty {
    flex: 1;
    overflow-y: auto;
    padding: 8px 16px 24px;
}

.memory-sheet-title {
    padding: 0 16px 12px;
    color: #111111;
    font-size: 20px;
    font-weight: 700;
}

.memory-short-list {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 14px;
    background: #ffffff;
}

.memory-short-item {
    min-height: 50px;
    padding: 0 14px;
    border: none;
    border-bottom: 1px solid #f0f0f0;
    background: #ffffff;
    color: #111111;
    font-size: 16px;
    font-weight: 500;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.memory-short-item:last-child {
    border-bottom: none;
}

.memory-short-item i {
    color: #c7c7cc;
    font-size: 13px;
}

.memory-short-empty {
    padding: 34px 12px;
    color: #8e8e93;
    font-size: 14px;
    text-align: center;
}

.memory-entry-detail-card,
.memory-summary-card {
    width: min(340px, calc(100vw - 36px));
    max-height: 78%;
    display: flex;
    flex-direction: column;
    background: #ffffff;
}

.memory-entry-detail-body,
.memory-summary-body {
    overflow-y: auto;
    padding: 0 16px 18px;
}

.memory-entry-field {
    margin-bottom: 12px;
    padding: 12px;
    border-radius: 12px;
    background: #f2f2f7;
}

.memory-entry-field-label,
.memory-summary-label {
    margin-bottom: 6px;
    color: #8e8e93;
    font-size: 12px;
    font-weight: 700;
}

.memory-entry-field-value {
    color: #111111;
    font-size: 15px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.memory-summary-count-card {
    padding: 14px;
    border-radius: 14px;
    background: #f2f2f7;
    text-align: center;
}

.memory-summary-count {
    color: #111111;
    font-size: 34px;
    font-weight: 800;
    line-height: 1.1;
}

.memory-summary-form-row {
    min-height: 48px;
    margin-top: 14px;
    padding: 0 14px;
    border-radius: 14px;
    background: #f2f2f7;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #111111;
    font-size: 16px;
    font-weight: 500;
}

.memory-summary-form-row input {
    width: 74px;
    border: 1px solid #d1d1d6;
    border-radius: 10px;
    padding: 6px 8px;
    background: #ffffff;
    color: #111111;
    font-size: 16px;
    text-align: center;
    outline: none;
}

.memory-summary-confirm-btn {
    width: 100%;
    margin-top: 16px;
    padding: 13px 0;
    border: none;
    border-radius: 14px;
    background: #007aff;
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

@media (max-width: 390px) {
    .line-bottom-nav {
        min-width: min(292px, calc(100vw - 28px));
        height: 47px;
    }

    .line-nav-item {
        min-width: 63px;
        padding: 0 8px;
    }

    .line-nav-item i {
        font-size: 18px;
    }

    .line-nav-item span {
        font-size: 9px;
    }
}

/* Chats List View */
.chats-content {
    display: none; /* Hidden by default */
    flex-direction: column;
    height: 100%;
    min-height: 0;
    position: relative;
    overflow: hidden;
    /* padding-top removed to bring content right under header */
}

.chats-header {
    padding: 10px 20px 10px;
}

.chats-title {
    font-size: 30px;
    font-weight: 700;
    color: #000;
}

.chats-list-container {
    flex: 1;
    overflow-y: auto;
    padding-top: 50px;
    padding-bottom: var(--im-bottom-nav-space);
}

/* Chat Item Styles (Rounded Bubble) */
.chat-unread-badge {
    background-color: #ff3b30;
    color: white;
    font-size: 11px;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 4px;
    position: absolute;
    bottom: -2px;
    right: -2px;
    border: 2px solid #fff;
}
.chat-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    margin: 0 16px 12px;
    gap: 12px;
    cursor: pointer;
    background-color: #fff;
    border-radius: 40px; /* Large pill shape */
    border: 1px solid #f2f2f7;
    box-shadow: none; /* Removed shadow */
}

.chat-item:active {
    transform: scale(0.98);
    background-color: #f9f9f9;
    transition: transform 0.1s;
}


.chat-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #e5e5ea;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    color: #aeaeb2;
    overflow: hidden;
    flex-shrink: 0;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
}

.chat-row-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-name {
    font-size: 16px;
    font-weight: 600;
    color: #000;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-time {
    font-size: 12px;
    color: #8e8e93;
}

.chat-message {
    font-size: 14px;
    color: #8e8e93;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Empty State */
.chats-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 40px;
    margin-top: -60px; /* Offset for nav */
}

.empty-icon-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: #f2f2f7;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 32px;
    color: #8e8e93;
    margin-bottom: 20px;
}

.chats-empty-state h2 {
    font-size: 20px;
    margin-bottom: 10px;
}

.chats-empty-state p {
    font-size: 15px;
    color: #8e8e93;
    line-height: 1.4;
}

/* Calls View */
.calls-content {
    display: none;
    flex-direction: column;
    height: 100%;
    padding-top: 90px;
}

.calls-header {
    padding: 0 20px 10px;
}

.calls-title {
    font-size: 30px;
    font-weight: 700;
    color: #000;
}

.calls-search-wrapper {
    padding: 0 20px 10px;
}

.calls-search {
    background-color: #e5e5ea;
    border-radius: 10px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #8e8e93;
    font-size: 15px;
}

.contact-section {
    padding: 0 20px;
    margin-bottom: 20px;
}

.contact-section-letter {
    font-size: 13px;
    color: #8e8e93;
    font-weight: 600;
    margin-bottom: 8px;
    background-color: #f2f2f7;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 0.5px solid #e5e5ea;
}

.contact-name {
    font-size: 17px;
    font-weight: 500;
}

/* iMessage Views Background Forced to White */
.imessage-view {
    background-color: var(--screen-bg, #ffffff) !important;
}

.line-content {
    background-color: #ffffff;
}

.chats-content {
    background-color: #ffffff;
}

.calls-content {
    background-color: #ffffff;
}

/* Active Chat Interface (Instagram Style) */
.active-chat-interface {
    --im-chat-bg-color: #ffffff;
    --im-chat-bg-image: none;
    --im-chat-bg-size: cover;
    --im-chat-bg-position: center;
    --im-chat-bg-repeat: no-repeat;
    --im-chat-avatar-size: 44px;
    --im-chat-name-size: 16px;
    --im-chat-sign-size: 13px;
    --im-chat-header-bg: #ffffff;
    --im-chat-header-backdrop: none;
    --im-chat-header-padding: 0 16px;
    --im-chat-header-gap: 8px;
    --im-chat-header-left-offset: 8px;
    --im-chat-status-color: #34c759;
    --im-chat-input-container-bg: #ffffff;
    --im-chat-input-bg: #ffffff;
    --im-chat-input-radius: 22px;
    --im-chat-message-padding-x: 16px;
    --im-chat-message-top-space: 96px;
    display: flex;
    flex-direction: column;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    background-color: var(--im-chat-page-bg, var(--im-chat-bg-color));
    background-image: var(--im-chat-bg-image);
    background-size: var(--im-chat-bg-size);
    background-position: var(--im-chat-bg-position);
    background-repeat: var(--im-chat-bg-repeat);
    z-index: 150; /* Above lists and bottom nav, but below overlays/modals */    
    min-height: 0;
    overflow: hidden;
}

.active-chat-interface.has-chat-bg {
    --im-chat-header-bg: #ffffff;
    --im-chat-header-border: 1px solid #f2f2f7;
    --im-chat-header-backdrop: none;
    --im-chat-input-container-bg: transparent;
}

.chat-sticky-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 20;
    padding-top: max(10px, env(safe-area-inset-top, 0px));
    padding-bottom: 10px;
    pointer-events: none; /* Allow scroll through empty space */
}

.chat-sticky-container.is-friend {
    background: #ffffff;
    border-bottom: var(--im-chat-header-border, 1px solid #f2f2f7);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding-bottom: 5px;
}

.chat-sticky-container.is-group {
    background: transparent;
    border-bottom: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding-bottom: 5px;
}

.chat-sticky-container * {
    pointer-events: auto; /* Re-enable clicks on buttons */
}

.chat-sticky-container::before {
    display: none;
}

.chat-top-bar {
    position: relative; /* Relative to its sticky container */
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: var(--im-chat-header-padding);
    align-items: center; /* Center horizontally with avatar and name */
    color: #000;
    font-size: 20px;
    z-index: 10;
    pointer-events: none;
}

.im-chat-top-bar {
    padding-left: var(--im-chat-header-left-offset) !important;
}

.im-chat-header-left,
.im-chat-actions,
.im-chat-input-actions {
    display: flex;
    align-items: center;
}

.im-chat-header-left {
    gap: var(--im-chat-header-gap);
    flex: 1;
    min-width: 0;
}

.im-chat-actions {
    gap: 12px;
    flex-shrink: 0;
}

.im-chat-header-main {
    justify-content: flex-start;
    cursor: pointer;
    pointer-events: auto;
}

.im-chat-back-btn,
.im-chat-icon-btn,
.im-chat-cancel-batch-btn {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.im-chat-back-btn {
    width: 24px;
    padding: 5px 0;
    flex-shrink: 0;
}

.im-chat-icon-btn {
    padding: 5px;
    font-size: 18px;
}

.im-chat-cancel-batch-btn {
    padding: 5px;
    color: #007aff;
    font-size: 16px;
    font-weight: 500;
}

.ins-chat-header {
    display: flex;
    flex-direction: row; /* Horizontal layout: Avatar -> Name */
    align-items: center;
    padding: 0;
    margin-top: 0;
    margin-left: 5px; /* Tighter spacing */
    flex: 1; 
}

.im-chat-avatar-wrap {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
}

.im-chat-title-wrap {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    margin-left: 8px;
    gap: 1px;
    min-width: 0;
}

.ins-chat-avatar {
    width: var(--im-chat-avatar-size);
    height: var(--im-chat-avatar-size);
    border-radius: 50%;
    background-color: #f2f2f7;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    color: #8e8e93;
    overflow: hidden;
    margin-bottom: 0;
    margin: 0;
    flex-shrink: 0;
}

.ins-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ins-chat-name {
    font-size: var(--im-chat-name-size);
    font-weight: 600;
    color: #000;
    line-height: 1.05;
}

.ins-chat-sign {
    font-size: var(--im-chat-sign-size);
    color: #8e8e93;
    margin-top: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    gap: 4px;
}

.im-chat-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--im-chat-status-color);
    flex-shrink: 0;
}

.ins-chat-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    box-sizing: border-box;
    padding: calc(var(--im-chat-message-top-space) + env(safe-area-inset-top, 0px)) var(--im-chat-message-padding-x) var(--im-chat-input-space);
    display: flex;
    flex-direction: column;
    gap: 2px; /* Ultra tight spacing for consecutive messages */
    min-height: 0;
}

.chat-history-loader {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 2px 0 10px;
    flex-shrink: 0;
}

.chat-history-load-more-btn {
    border: 0;
    border-radius: 16px;
    background: rgba(242, 242, 247, 0.92);
    color: #3a3a3c;
    min-height: 34px;
    padding: 6px 14px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font: inherit;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    -webkit-tap-highlight-color: transparent;
}

.chat-history-load-more-btn:active {
    transform: scale(0.98);
    background: rgba(229, 229, 234, 0.95);
}

.chat-history-load-more-title {
    font-size: 13px;
    line-height: 1.2;
    font-weight: 600;
}

.chat-history-load-more-meta {
    font-size: 11px;
    line-height: 1.2;
    color: #8e8e93;
}

/* Chat Timestamps (Center Bubble) */
.chat-timestamp {
    display: flex;
    justify-content: center;
    margin: 16px 0 6px 0;
}

.chat-timestamp span {
    background-color: rgba(0, 0, 0, 0.2);
    color: #fff;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* Chat Bubbles */
.chat-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    width: 100%;
}

.chat-row:not(.has-prev) {
    margin-top: 10px; /* Spacing between different groups */
}

/* Base style update for P2 bubble matching */
.chat-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 20px;
    font-size: 15px;
    line-height: 1.4;
    word-wrap: break-word;
    transition: border-radius 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.chat-row:first-child {
    margin-top: 0;
}

.chat-row.user-row {
    justify-content: flex-end;
}

.chat-row.ai-row {
    justify-content: flex-start;
}

.chat-avatar-small {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: #e5e5ea;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    color: #8e8e93;
}

.chat-avatar-small img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bubble-meta {
    display: none; /* Hidden by default */
    margin-left: 6px;
    font-size: 10px;
    vertical-align: bottom;
    opacity: 0.7;
}

.show-timestamps .bubble-meta {
    display: inline-block;
}

.bubble-read-icon {
    margin-left: 4px;
    font-size: 10px;
}

.user-bubble {
    background-color: #2c2c2e; /* Restore Dark Gray */
    color: #fff;
    border-bottom-right-radius: 4px; 
}
.user-row.has-next .user-bubble {
    border-bottom-right-radius: 8px !important; 
}
.user-row.has-prev .user-bubble {
    border-top-right-radius: 8px !important; 
}

.ai-bubble {
    background-color: #f2f2f7;
    color: #000;
    border-bottom-left-radius: 4px; 
}
.ai-row.has-next .ai-bubble {
    border-bottom-left-radius: 8px !important; 
}
.ai-row.has-prev .ai-bubble {
    border-top-left-radius: 8px !important; 
}

.chat-offline-scene-row {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 2px 40px;
    box-sizing: border-box;
    text-align: center;
}

.chat-offline-scene-row span {
    max-width: 100%;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--im-chat-bg-color, #ffffff);
    color: #8e8e93;
    font-size: 12px;
    font-style: italic;
    line-height: 1.35;
    text-align: center;
    box-shadow: none;
    word-break: break-word;
}

.chat-offline-action {
    display: inline;
    color: #8e8e93;
    font-size: inherit;
    line-height: inherit;
}

.voice-message-bubble {
    min-width: 0;
    max-width: 70%;
    padding: 10px 14px;
    box-shadow: none;
    overflow: visible;
}

.voice-message-bubble-inner {
    width: auto;
    min-height: 0;
    border: 0;
    padding: 0;
    border-radius: 0;
    background: transparent;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font: inherit;
    text-align: left;
}

.ai-bubble .voice-message-bubble-inner {
    background: transparent;
}

.voice-message-mic {
    width: auto;
    height: auto;
    border-radius: 0;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: none;
    flex-shrink: 0;
}

.ai-bubble .voice-message-mic {
    background: transparent;
    box-shadow: none;
}

.voice-message-wave {
    display: flex;
    align-items: center;
    gap: 3px;
    min-width: 0;
}

.voice-message-wave span {
    display: block;
    width: 3px;
    border-radius: 999px;
    background: currentColor;
    opacity: 0.82;
}

.voice-message-wave span:nth-child(1) { height: 7px; opacity: 0.4; }
.voice-message-wave span:nth-child(2) { height: 14px; opacity: 0.62; }
.voice-message-wave span:nth-child(3) { height: 22px; opacity: 0.92; }
.voice-message-wave span:nth-child(4) { height: 11px; opacity: 0.58; }
.voice-message-wave span:nth-child(5) { height: 18px; opacity: 0.76; }

.voice-message-duration {
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
    opacity: 0.76;
    font-weight: 700;
    letter-spacing: 0;
}

.voice-message-transcript {
    margin-top: 7px;
    padding-top: 7px;
    border-radius: 0;
    border-top: 1px solid rgba(255,255,255,0.22);
    background: transparent;
    font-size: 13px;
    line-height: 1.45;
    white-space: normal;
    word-break: break-word;
    user-select: text;
    -webkit-user-select: text;
}

.ai-bubble .voice-message-transcript {
    background: transparent;
    color: #2c2c2e;
    border-top-color: rgba(0,0,0,0.12);
}

.sticker-message-wrap {
    max-width: 150px;
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    background: transparent;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.ai-row .sticker-message-wrap {
    align-items: flex-start;
}

.sticker-message-img {
    width: auto;
    max-width: 132px;
    max-height: 132px;
    object-fit: contain;
    display: block;
    border-radius: 0;
    background: transparent;
}

.sticker-message-meta {
    margin-top: 3px;
    color: #8e8e93;
    text-shadow: none;
}

.sticker-group-wrap {
    max-width: min(78%, 190px);
}

/* Hide AI avatar for messages that connect downwards */
.ai-row.has-next .chat-avatar-small {
    visibility: hidden;
}

/* Group chat assistant bubbles */
.group-ai-bubble-wrap {
    width: 100%;
    max-width: min(78%, 280px);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.group-ai-speaker-name {
    font-size: 11px;
    color: #8e8e93;
    margin-bottom: 4px;
    margin-left: 36px;
    line-height: 1.2;
}

.group-ai-bubble-row {
    width: 100%;
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.group-ai-avatar-slot {
    width: 28px;
    min-width: 28px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    flex-shrink: 0;
}

.group-ai-avatar-slot img,
.group-ai-avatar-slot .chat-avatar-small {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e5e5ea;
    color: #8e8e93;
    font-size: 12px;
    font-weight: 600;
    overflow: hidden;
}

.group-ai-avatar-placeholder {
    width: 28px;
    height: 28px;
    visibility: hidden;
    flex-shrink: 0;
}

.group-ai-row .ai-bubble {
    max-width: 100%;
}

.group-ai-row.group-ai-row-continuous .ai-bubble {
    border-top-left-radius: 8px !important;
}

/* Typing Indicator */
.typing-indicator {
    background-color: #e5e5ea;
    padding: 12px 14px;
    border-radius: 20px;
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 4px;
    align-items: center;
    height: 38px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background-color: #8e8e93;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Input Area */
.ins-chat-input-container {
    width: 100%;
    padding: 10px 16px 8px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    background-color: var(--im-chat-input-container-bg, #ffffff);
    border-top: none;
    z-index: 30;
    flex-shrink: 0;
    transition: background-color 0.25s;
}

/* @ Mention List Box */
.at-mention-list {
    position: absolute;
    bottom: 100%;
    left: 16px;
    right: 16px;
    background: #ffffff;
    border: 1px solid #e5e5ea;
    border-radius: 12px;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.08);
    max-height: 200px;
    overflow-y: auto;
    z-index: 40;
    display: none;
    flex-direction: column;
    padding: 8px 0;
    margin-bottom: 8px;
}

.at-mention-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    gap: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.at-mention-item:active {
    background-color: #f2f2f7;
}

.at-mention-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #e5e5ea;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    color: #8e8e93;
    overflow: hidden;
    flex-shrink: 0;
}

.at-mention-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.at-mention-name {
    font-size: 15px;
    color: #000;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


.ins-chat-input-wrapper {
    display: flex;
    align-items: center;
    background-color: var(--im-chat-input-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border-radius: var(--im-chat-input-radius);
    padding: 6px 12px;
    gap: 10px;
}

.im-chat-input-actions {
    gap: 8px;
}

.ins-input-icon {
    width: 32px;
    height: 32px;
    background-color: #2c2c2e; /* Dark Gray */
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
    margin: -4px 0 -4px -4px;
    padding: 4px;
    box-sizing: content-box;
    background-clip: content-box;
}

.ins-message-input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 15px;
    padding: 8px 0;
    min-width: 0;
}

.send-btn-icon {
    font-size: 20px;
    color: #2c2c2e; /* Dark Gray */
    cursor: pointer;
    padding: 10px;
    margin: -10px;
    flex-shrink: 0;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

/* Chat Tool Button in Settings */
.chat-tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.chat-tool-btn .tool-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-size: 20px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.chat-tool-btn span {
    font-size: 11px;
    color: #000;
    font-weight: 500;
}


/* Context Menu */
.msg-menu-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    font-size: 16px;
    font-weight: 500;
    color: #000;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    cursor: pointer;
    transition: background-color 0.1s;
}

.msg-menu-item:active {
    background-color: rgba(0,0,0,0.05);
}

.msg-menu-item.destructive {
    color: #ff3b30;
}

.msg-menu-item.destructive i {
    color: #ff3b30 !important;
}

.msg-reaction {
    user-select: none;
    -webkit-user-select: none;
}

.msg-reaction:active {
    transform: scale(1.3);
    background: rgba(0,0,0,0.05);
}

/* Chat Row modifications during active state */
.chat-row {
    transition: transform 0.2s, opacity 0.2s;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.chat-row.message-active {
    opacity: 0; /* Hide the original row while context menu is open, since we clone the bubble */
}

/* Styles for Add Friend Inputs (Commented to prevent global conflict) */
/*
.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-size: 14px;
    color: #8e8e93;
    margin-left: 5px;
}

.form-input {
    padding: 12px;
    border: 1px solid #c6c6c8;
    border-radius: 8px;
    font-size: 16px;
    outline: none;
}
*/

/* Toggle Switch (Commented to use ios_emulator.css version) */
/*
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 30px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--ios-green);
}

input:checked + .slider:before {
    transform: translateX(20px);
}
*/

/* Moments (朋友圈) Styling */
#moments-content {
    flex: 1;
    background-color: #fff;
    display: none;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.moments-top-bar {
    height: calc(114px + env(safe-area-inset-top, 0px));
    padding-top: calc(54px + env(safe-area-inset-top, 0px));
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-left: 15px;
    padding-right: 15px;
    color: #fff; /* White icons on cover */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 20;
    /* background: linear-gradient(to bottom, rgba(0,0,0,0.5), transparent); */
}

.moments-scroll-container {
    flex: 1;
    overflow-y: auto;
    background-color: #fff;
    padding-bottom: 80px;
}

.moments-cover-wrapper {
    width: 100%;
    height: 180px; /* 缩短高度，仿微信 */
    position: relative;
    background-color: #333;
    cursor: pointer;
}

.moments-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.moments-user-info {
    position: absolute;
    bottom: -20px;
    right: 15px;
    display: flex;
    align-items: flex-end;
    gap: 15px;
    z-index: 10;
}

.moments-user-name {
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 30px; /* Push up from bottom edge of avatar */
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.moments-user-avatar-wrapper {
    width: 70px;
    height: 70px;
    border-radius: 8px;
    background: #fff;
    padding: 2px; /* Border effect */
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    overflow: hidden;
    cursor: pointer;
}

.moments-user-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 6px;
    object-fit: cover;
}

.moments-user-avatar-icon {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #e5e5ea;
    color: #8e8e93;
    font-size: 30px;
    border-radius: 6px;
}

.main-moments-signature {
    position: absolute;
    right: 15px;
    bottom: -42px;
    width: calc(100% - 110px);
    text-align: right;
    font-size: 12px;
    color: #8e8e93;
    line-height: 1.4;
    word-break: break-word;
    display: none;
    z-index: 11;
}

.moments-list {
    padding-top: 52px; /* Space for avatar + signature hanging */
}

.moment-item {
    display: flex;
    padding: 15px;
    border-bottom: 1px solid #f2f2f2;
    gap: 10px;
}

.moment-avatar {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    background: #ddd;
    flex-shrink: 0;
    overflow: hidden;
}

.moment-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.moment-main {
    flex: 1;
}

.moment-name {
    color: #576b95; /* WeChat Name Color */
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 5px;
}

.moment-text {
    font-size: 15px;
    color: #000;
    margin-bottom: 8px;
    line-height: 1.4;
}

.moment-images {
    margin-bottom: 8px;
}

.moment-images.single {
    display: block;
}

.moment-images.single .moment-img-wrapper {
    width: auto;
    height: auto;
    max-width: 70%;
    max-height: 200px;
    background: #f2f2f7;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.moment-images.single .moment-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.moment-images.double, .moment-images.grid {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.moment-img-wrapper {
    background: #f2f2f7; /* Prevent pure transparent showing weird colors behind */
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.moment-images.double .moment-img-wrapper,
.moment-images.grid .moment-img-wrapper {
    width: 80px;
    height: 80px;
}

.moment-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center; /* Ensure image covers fully centered */
    display: block;
}

.moment-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    margin-top: 5px;
}

.moment-time {
    font-size: 12px;
    color: #8e8e93;
}

.moment-action-btn {
    width: 32px;
    height: 20px;
    background: #f7f7f7;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #576b95;
    cursor: pointer;
}

/* Group Member Profile Card (Floating) */
.group-member-profile-card {
    position: absolute;
    width: 250px;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    z-index: 1100;
    /* Remove display: none so JS can toggle flex safely */
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: scale(0.85);
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.25s;
    pointer-events: auto;
    /* Origin will be set dynamically via JS based on click position */
}

.group-member-profile-card.active {
    transform: scale(1);
    opacity: 1;
}

.gmp-header {
    height: 70px;
    background: linear-gradient(180deg, #f2f2f7 0%, #ffffff 100%);
    position: relative;
}

.gmp-avatar-wrapper {
    position: absolute;
    bottom: -30px;
    left: 16px;
    display: flex;
    align-items: flex-end;
}

.gmp-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid #ffffff;
    background-color: #e5e5ea;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    color: #8e8e93;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.gmp-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gmp-status-bubble {
    background: #ffffff;
    border: 1px solid #e5e5ea;
    border-radius: 14px;
    padding: 4px 10px;
    font-size: 12px;
    color: #333;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    margin-left: -8px;
    margin-bottom: 6px;
    position: relative;
    cursor: pointer;
}

.gmp-status-bubble::before {
    content: '';
    position: absolute;
    left: -5px;
    bottom: 8px;
    border-width: 5px 5px 5px 0;
    border-style: solid;
    border-color: transparent #ffffff transparent transparent;
    filter: drop-shadow(-1px 0px 0px #e5e5ea);
}

.gmp-body {
    padding: 40px 16px 16px;
    display: flex;
    flex-direction: column;
}

.gmp-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}

.gmp-name {
    font-size: 18px;
    font-weight: 700;
    color: #000;
}

.gmp-title {
    background: #f2f2f7;
    color: #8e8e93;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 500;
}

.gmp-signature {
    font-size: 13px;
    color: #8e8e93;
    margin-bottom: 12px;
    line-height: 1.4;
}

.gmp-inner-voice {
    font-size: 13px;
    color: #333;
    line-height: 1.4;
    background: #f2f2f7;
    padding: 10px 12px;
    border-radius: 16px;
    margin-bottom: 16px;
    min-height: 40px;
    position: relative;
}

.gmp-inner-voice::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 12px;
    border-width: 0 6px 6px 6px;
    border-style: solid;
    border-color: transparent transparent #f2f2f7 transparent;
}

.gmp-action-btn {
    background: #000;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    padding: 10px;
    border-radius: 20px;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.gmp-action-btn:active {
    background: #333;
}

/* Single Chat Profile Panel */
.chat-profile-panel-overlay {
    position: absolute;
    inset: 0;
    z-index: 1100;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: calc(88px + env(safe-area-inset-top, 0px)) 16px 24px;
    background: rgba(0, 0, 0, 0.22);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}

.chat-profile-panel-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.chat-profile-panel-card {
    width: min(100%, 320px);
    background: #ffffff;
    border-radius: 24px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    transform: translateY(12px) scale(0.96);
    opacity: 0;
    transition: transform 0.22s ease, opacity 0.22s ease;
}

.chat-profile-panel-overlay.active .chat-profile-panel-card {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.chat-profile-panel-header {
    height: 88px;
}

.chat-profile-panel-header .gmp-avatar-wrapper {
    bottom: -34px;
    left: 18px;
}

.chat-profile-panel-header .gmp-avatar {
    width: 66px;
    height: 66px;
}

.chat-profile-panel-header-status {
    max-width: 170px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-profile-panel-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.chat-profile-panel-close:active {
    transform: scale(0.96);
}

.chat-profile-panel-body {
    padding-top: 46px;
    gap: 0;
    max-height: min(62vh, 520px);
}

.chat-profile-panel-content {
    margin-top: 4px;
    min-height: 132px;
    max-height: min(40vh, 320px);
    overflow-y: auto;
    padding-right: 2px;
}

.chat-profile-panel-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-profile-panel-section-label {
    font-size: 12px;
    color: #8e8e93;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.chat-profile-panel-thought {
    margin-bottom: 0;
    margin-top: 0;
    min-height: 108px;
    white-space: pre-wrap;
    word-break: break-word;
    color: #222;
    display: flex;
    align-items: flex-start;
}

.chat-profile-panel-thought.is-empty {
    color: #8e8e93;
    font-style: italic;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.chat-profile-panel-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chat-profile-panel-meta-bubble {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 7px 12px;
    border-radius: 999px;
    background: #f8f8fb;
    border: 1px solid #ececf2;
}

.chat-profile-panel-meta-key {
    font-size: 11px;
    color: #8e8e93;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.chat-profile-panel-meta-value {
    font-size: 12px;
    color: #222;
    font-weight: 600;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


.chat-profile-panel-events {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: min(36vh, 280px);
    overflow-y: auto;
    padding-right: 2px;
}

.chat-profile-event-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 12px 12px 4px;
    border-radius: 18px;
    background: #f8f8fb;
}

.chat-profile-event-dot {
    width: 10px;
    height: 10px;
    margin-top: 6px;
    border-radius: 50%;
    background: #111;
    flex-shrink: 0;
}

.chat-profile-event-main {
    flex: 1;
    min-width: 0;
}

.chat-profile-event-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 4px;
}

.chat-profile-event-title {
    font-size: 14px;
    font-weight: 700;
    color: #111;
    line-height: 1.35;
}

.chat-profile-event-time {
    font-size: 11px;
    color: #8e8e93;
    white-space: nowrap;
    flex-shrink: 0;
}

.chat-profile-event-desc {
    font-size: 12px;
    color: #666;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-profile-panel-empty {
    min-height: 132px;
    border-radius: 18px;
    background: #f8f8fb;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 16px;
}

.chat-profile-panel-empty-title {
    font-size: 15px;
    font-weight: 700;
    color: #111;
    margin-bottom: 6px;
}

.chat-profile-panel-empty-desc {
    font-size: 12px;
    color: #8e8e93;
    line-height: 1.5;
}

.chat-profile-panel-tabs {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.chat-profile-panel-tab {
    border: none;
    background: #f2f2f7;
    color: #6b7280;
    border-radius: 16px;
    min-height: 40px;
    padding: 10px 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
}

.chat-profile-panel-tab.active {
    background: #111;
    color: #fff;
    box-shadow: 0 8px 18px rgba(17, 17, 17, 0.16);
}

.chat-profile-panel-tab:active {
    transform: scale(0.97);
}

.chat-profile-memory-request-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border-radius: 20px;
    background: linear-gradient(180deg, #ffffff 0%, #f8f8fb 100%);
    border: 1px solid #ececf2;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
}

.chat-profile-memory-request-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.chat-profile-memory-request-title {
    font-size: 14px;
    font-weight: 700;
    color: #111827;
    line-height: 1.4;
}

.chat-profile-memory-request-badge {
    flex-shrink: 0;
    padding: 4px 10px;
    border-radius: 999px;
    background: #eef2ff;
    color: #4f46e5;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.chat-profile-memory-request-badge.is-confirmed {
    background: #e8fff1;
    color: #149954;
}

.chat-profile-memory-request-badge.is-cancelled {
    background: #fff1f2;
    color: #e11d48;
}

.chat-profile-memory-request-content {
    font-size: 13px;
    color: #374151;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-profile-memory-request-detail {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.55;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid #ececf2;
}

.chat-profile-memory-request-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.chat-profile-memory-request-time {
    font-size: 11px;
    color: #9ca3af;
}

.chat-profile-memory-request-detail-trigger {
    border: none;
    background: transparent;
    color: #111827;
    font-size: 12px;
    font-weight: 700;
    padding: 0;
    cursor: pointer;
}

.chat-profile-memory-request-detail-trigger:active {
    opacity: 0.65;
}

.chat-profile-memory-request-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.chat-profile-memory-request-btn {
    min-height: 40px;
    border: none;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease;
}

.chat-profile-memory-request-btn.is-confirm {
    background: #111827;
    color: #ffffff;
    box-shadow: 0 10px 20px rgba(17, 24, 39, 0.14);
}

.chat-profile-memory-request-btn.is-cancel {
    background: #f3f4f6;
    color: #6b7280;
}

.chat-profile-memory-request-btn:active {
    transform: scale(0.97);
}

.chat-profile-event-detail-overlay {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(15, 23, 42, 0.24);
    opacity: 0;
    transition: opacity 0.22s ease;
}

.chat-profile-event-detail-overlay.active {
    opacity: 1;
}

.chat-profile-event-detail-card {
    position: relative;
    width: min(100%, 284px);
    max-height: min(68vh, 420px);
    overflow-y: auto;
    padding: 18px 16px 16px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 22px 48px rgba(15, 23, 42, 0.2);
    transform: translateY(10px) scale(0.96);
    opacity: 0;
    transition: transform 0.22s ease, opacity 0.22s ease;
}

.chat-profile-event-detail-overlay.active .chat-profile-event-detail-card {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.chat-profile-event-detail-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: #f3f4f6;
    color: #111827;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.chat-profile-event-detail-close:active {
    transform: scale(0.96);
}

.chat-profile-event-detail-label {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 10px;
    border-radius: 999px;
    background: #f3f4f6;
    color: #6b7280;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 12px;
}

.chat-profile-event-detail-title {
    font-size: 18px;
    font-weight: 800;
    color: #111827;
    line-height: 1.35;
    margin-bottom: 8px;
    padding-right: 36px;
}

.chat-profile-event-detail-time {
    font-size: 12px;
    color: #9ca3af;
    margin-bottom: 14px;
}

.chat-profile-event-detail-desc {
    font-size: 14px;
    color: #374151;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 12px;
}

.chat-profile-event-detail-detail {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
    padding: 12px 13px;
    border-radius: 16px;
    background: #f8f8fb;
    border: 1px solid #ececf2;
}

/* Action Menu Popup */
.moment-action-menu {
    position: absolute;
    right: 40px;
    top: -5px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    padding: 0;
    overflow: hidden;
    width: 0;
    transition: width 0.2s ease-out;
}

.moment-action-menu.active {
    width: 250px; /* Expanded width */
}

.moment-action-item {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
    font-size: 13px;
    padding: 10px 0;
    white-space: nowrap;
    cursor: pointer;
    gap: 5px;
}

.moment-action-item:active {
    background: rgba(0,0,0,0.05);
}

.moment-interaction-area {
    background: #f7f7f7;
    border-radius: 4px;
    padding: 5px 8px;
    margin-top: 8px;
    font-size: 13px;
    position: relative;
}

.moment-interaction-area::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 10px;
    border-width: 0 5px 5px 5px;
    border-style: solid;
    border-color: transparent transparent #f7f7f7 transparent;
}

.moment-likes {
    color: #576b95;
    margin-bottom: 2px;
    word-break: break-all;
}

.moment-comment {
    color: #000;
    margin-top: 2px;
}

.moment-comment-name {
    color: #576b95;
    font-weight: 500;
}

/* Custom Modal */
.custom-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.4);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
}

.custom-modal {
    width: 80%;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: popIn 0.2s ease-out;
}

@keyframes popIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.custom-modal-content {
    padding: 20px;
    text-align: center;
}

.custom-modal-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 10px;
}

.custom-modal-message {
    font-size: 14px;
    color: #000;
    margin-bottom: 15px;
}

.custom-modal-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
}

.custom-modal-actions {
    display: flex;
    border-top: 1px solid #dcdcdc;
}

.custom-modal-btn {
    flex: 1;
    padding: 12px;
    text-align: center;
    font-size: 16px;
    color: #007aff;
    cursor: pointer;
    border-right: 1px solid #dcdcdc;
    background: #fff;
}

.custom-modal-btn:last-child {
    border-right: none;
}

.custom-modal-btn:active {
    background: #f2f2f2;
}

.custom-modal-btn.destructive {
    color: #ff3b30;
}

/* Moment Detail Overlay - 全白背景、内容居中 */
#moment-detail-overlay .bottom-sheet {
    background: #fff !important;
    display: flex;
    flex-direction: column;
    align-items: stretch; /* 修改为 stretch 以便内部元素控制宽度 */
    padding: 0; /* 移除外层 padding */
}

#moment-detail-overlay .bottom-sheet > * {
    max-width: 100%;
}

.moment-detail-container {
    padding: 20px 24px; /* 增加内边距 */
}

/* 放大详情文字 */
.moment-detail-text {
    font-size: 18px !important; /* 字体放大 */
    line-height: 1.6 !important;
    color: #333;
    margin-top: 15px;
    margin-bottom: 20px;
}

.moment-detail-header {
    margin-bottom: 20px !important;
}

/* 微信朋友圈详情排版对齐 */
.moment-detail-content {
    margin-left: 0 !important; /* 取消左边距，让文字顶格对齐头像左侧（微信样式） */
}

.moment-detail-name {
    font-size: 18px !important; /* 名字放大 */
}

.moment-detail-avatar {
    width: 48px !important;
    height: 48px !important;
}

/* Char Moments Settings Sheet - 圆角气泡按钮 */
#char-moments-settings-sheet .moment-action-sheet-item {
    background: #fff;
    padding: 12px 16px;
    text-align: center;
    font-size: 15px;
    font-weight: 500;
    color: #8e8e93;
    cursor: pointer;
    border-bottom: none;
    margin-bottom: 8px;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

#char-moments-settings-sheet .moment-action-sheet-item:last-child {
    margin-bottom: 0;
}

#char-moments-settings-sheet .moment-action-sheet-item:active {
    background: #f2f2f7;
}

/* 详情页更多按钮界面圆角包裹 */
#moment-detail-action-sheet .bottom-sheet {
    background: transparent !important;
    padding: 0 10px 10px 10px;
}

#moment-detail-action-sheet .moment-action-sheet-item {
    background: #fff;
    padding: 12px 16px;
    text-align: center;
    font-size: 15px;
    font-weight: 500;
    color: #8e8e93;
    cursor: pointer;
    border-bottom: none;
    margin-bottom: 8px;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

#moment-detail-action-sheet .moment-action-sheet-item:last-child {
    margin-bottom: 0;
}

#moment-detail-action-sheet .moment-action-sheet-item:active {
    background: #f2f2f7;
}

#moment-detail-action-sheet .bottom-sheet-cancel {
    margin-top: 8px;
}

.moment-action-btn-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px; /* Very tight gap */
    flex: 1;
    font-size: 10px; /* Smallest legible font */
    color: #8e8e93; /* Gray color */
}

.moment-action-icon-box {
    width: 40px; /* Even smaller box */
    height: 40px;
    background: #fff;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 16px; /* Even smaller icon */
    color: #8e8e93; /* Gray icon */
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    cursor: pointer;
}

.moment-action-icon-box:active {
    background: #f2f2f7;
}

/* User Moments Page (Detailed) */
#user-moments-view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    z-index: 300;
    display: none;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.35s ease;
    opacity: 0;
}

#user-moments-view.active {
    transform: translateX(0);
    opacity: 1;
}

#user-moments-view.closing {
    transform: translateX(100%);
    opacity: 0;
}

.user-moments-top-bar {
    height: calc(98px + env(safe-area-inset-top, 0px));
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 20;
    padding-top: calc(54px + env(safe-area-inset-top, 0px));
}

.user-moments-scroll-container {
    flex: 1;
    overflow-y: auto;
    background: #fff;
}

/* User Moments Layout (Time Line) */
.user-moments-list {
    padding-top: 0px; /* Shift up */
}

.user-moment-group {
    display: flex;
    padding: 8px 15px; /* Tighter padding */
}

.user-moment-date-col {
    width: 60px; /* Narrower date column */
    padding-right: 8px;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 2px; /* Tighter gap between day and month */
}

.user-moment-day {
    font-size: 22px; /* Slightly smaller */
    font-weight: 600;
    color: #000;
    line-height: 1;
    background: transparent !important;
    padding: 0 !important;
    border: none !important;
}

.user-moment-month {
    font-size: 11px; /* Smaller */
    color: #000;
    font-weight: 600;
    margin-top: 8px; /* Align with day text baseline somewhat */
}

.user-moment-content-col {
    flex: 1;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
}

.pinned-group .user-moment-content-col {
    display: flex;
    flex-direction: row; /* Horizontal layout for pinned */
    overflow-x: auto; /* Allow scrolling if many */
    gap: 5px;
    padding-bottom: 5px; /* Space for scrollbar if any */
}

/* Hide scrollbar for clean look */
.pinned-group .user-moment-content-col::-webkit-scrollbar {
    display: none;
}

.user-moment-item {
    display: flex;
    gap: 8px;
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    cursor: pointer;
}

.user-moment-media {
    width: 100%;
    height: 100%;
    background: #f2f2f2;
    overflow: hidden;
    flex-shrink: 0;
    aspect-ratio: 1 / 1;
}

.user-moment-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.user-moment-text-preview {
    background: #f2f2f7;
    padding: 8px;
    font-size: 13px;
    color: #333;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    width: 100%;
}

/* Text Only Square for Pinned/Grid */
.text-only-moment-square {
    width: 100%;
    height: 100%;
    background-color: #e5e5ea;
    color: #000;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 5px;
    overflow: hidden;
    line-height: 1.2;
    flex-shrink: 0;
}

/* Pinned Bubble Style - CHANGED to text only */
.pinned-bubble {
    font-size: 24px;
    font-weight: 600;
    color: #000;
    line-height: 1;
    background: transparent;
    padding: 0;
    cursor: pointer;
}

/* Publish Moment View */
#publish-moment-view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    z-index: 400;
    display: none;
    flex-direction: column;
}

.publish-top-bar {
    height: calc(98px + env(safe-area-inset-top, 0px));
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    padding-top: calc(54px + env(safe-area-inset-top, 0px));
    background: #fff;
    border-bottom: 1px solid #f2f2f2;
}

.publish-content {
    padding: 20px;
    flex: 1;
}

.publish-textarea {
    width: 100%;
    height: 100px;
    border: none;
    resize: none;
    font-size: 16px;
    outline: none;
    margin-bottom: 20px;
}

.publish-images-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.publish-add-btn {
    width: 100%;
    aspect-ratio: 1;
    background: #f2f2f2;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 30px;
    color: #ccc;
    cursor: pointer;
}

.publish-submit-btn {
    padding: 6px 12px;
    border-radius: 4px;
    background: #f2f2f2;
    color: #b2b2b2;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.publish-submit-btn.active {
    background: #07c160; /* WeChat Green */
    color: #fff;
}

/* Settings Sheet Overrides for Chat (Commented to prevent global conflict) */
/*
.settings-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid #f2f2f2;
    cursor: pointer; 
}

.settings-avatar {
    width: 60px;
    height: 60px;
    border-radius: 6px;
    background: #eee;
    overflow: hidden;
}

.settings-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.settings-name {
    font-size: 18px;
    font-weight: 600;
}

.settings-group {
    background: #fff;
    margin-top: 10px;
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #f2f2f2;
    font-size: 16px;
    color: #000;
    cursor: pointer;
}

.settings-item i {
    color: #c7c7cc;
}

.settings-item.destructive {
    color: #ff3b30;
    justify-content: center;
}
*/

/* Preset CSS List */
#css-preset-list {
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.account-card {
    background: #fff;
    border-radius: 12px;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
}

.delete-icon {
    color: #ff3b30;
    padding: 10px;
    cursor: pointer;
}

/* Moment Message List */
#moments-message-view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    z-index: 350;
    display: none;
    flex-direction: column;
}

/* Moment Forward Sheet Tweaks */
#moment-forward-sheet .bottom-sheet-content {
    /* Horizontal scroll for friends */
}

#moment-forward-list {
    display: flex;
    overflow-x: auto;
    gap: 15px;
    padding: 10px 0;
}

.bottom-sheet-cancel {
    margin-top: 10px;
    padding: 12px;
    background: #fff !important; /* Explicitly no dark background */
    border-radius: 16px !important; /* Rounded corners */
    text-align: center;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    color: #000 !important;
}

.bottom-sheet-cancel:active {
    background: #f2f2f2 !important;
}

/* Moment Forward Bubble Style */
.moment-forward-bubble {
    padding: 10px !important;
    background: #fff !important;
    border: 1px solid #e5e5ea !important;
    min-width: 200px;
}

.user-row .moment-forward-bubble {
    background: #fff !important; /* Keep white even for user */
}

/* Pay Transfer Bubble */
.pay-transfer-bubble {
    padding: 4px 6px !important;
    min-width: 156px;
    max-width: min(56vw, 210px);
}

.pay-transfer-bubble .bubble-meta {
    margin-top: 4px;
}

.pay-transfer-card {
    background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(248,248,250,0.98) 100%);
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: 20px;
    padding: 11px 12px;
    color: #111;
    box-shadow: 0 6px 16px rgba(0,0,0,0.04);
}

.pay-transfer-card.is-received {
    background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(246,249,246,0.98) 100%);
}

.pay-transfer-card.is-income {
    background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(245,247,255,0.98) 100%);
}

.pay-transfer-card.is-pending {
    background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(249,249,251,0.98) 100%);
    cursor: pointer;
}

.user-bubble.pay-transfer-bubble {
    background: transparent !important;
    color: #111 !important;
    border-bottom-right-radius: 22px !important;
}

.ai-bubble.pay-transfer-bubble {
    background: transparent !important;
    color: #111 !important;
    border-bottom-left-radius: 22px !important;
}

.pay-transfer-card-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.pay-transfer-card-icon {
    width: 28px;
    height: 28px;
    border-radius: 10px;
    background: #111;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}

.pay-transfer-card-meta {
    min-width: 0;
    flex: 1;
}

.pay-transfer-card-title {
    font-size: 12px;
    font-weight: 700;
    color: #111;
    line-height: 1.1;
}

.pay-transfer-card-subtitle {
    font-size: 10px;
    color: #8e8e93;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pay-transfer-card-amount {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: #111;
    margin-bottom: 4px;
    line-height: 1.05;
}

.pay-transfer-card-desc {
    font-size: 11px;
    color: #636366;
    line-height: 1.35;
    word-break: break-word;
    margin-bottom: 0;
}

.attachment-more-icon-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    width: 100%;
}

.attachment-more-pay-entry,
.attachment-more-regenerate-entry,
.attachment-more-voice-entry,
.attachment-more-offline-entry {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.16s ease, opacity 0.16s ease;
}

.attachment-more-pay-entry:active,
.attachment-more-regenerate-entry:active,
.attachment-more-voice-entry:active,
.attachment-more-offline-entry:active {
    transform: scale(0.96);
    opacity: 0.85;
}

.attachment-more-pay-icon,
.attachment-more-regenerate-icon,
.attachment-more-voice-icon,
.attachment-more-offline-icon {
    width: 56px;
    height: 56px;
    border-radius: 19px;
    background: #111;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.08);
}

.attachment-more-regenerate-icon {
    background: #007aff;
}

.attachment-more-voice-icon {
    background: #34c759;
}

.attachment-more-offline-icon {
    background: #8e8e93;
}

.attachment-more-offline-entry.active .attachment-more-offline-icon {
    background: #ff9500;
}

.attachment-more-pay-label,
.attachment-more-regenerate-label,
.attachment-more-voice-label,
.attachment-more-offline-label {
    font-size: 12px;
    color: #111;
    font-weight: 600;
}

.pay-transfer-form-card {
    width: min(100%, 320px);
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-radius: 24px;
    padding: 18px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.12);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pay-transfer-form-title {
    font-size: 17px;
    font-weight: 700;
    color: #111;
    text-align: center;
    margin-bottom: 2px;
}

.pay-transfer-amount-input,
.pay-transfer-desc-input {
    width: 100%;
    border: 1px solid #e5e5ea;
    background: #f8f8fa;
    border-radius: 16px;
    padding: 13px 14px;
    font-size: 15px;
    color: #111;
    outline: none;
}

.pay-transfer-amount-input:focus,
.pay-transfer-desc-input:focus {
    border-color: #c7c7cc;
    background: #fff;
}

.pay-transfer-form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 4px;
}

.pay-transfer-cancel-btn,
.pay-transfer-submit-btn {
    height: 44px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.pay-transfer-cancel-btn {
    background: #f2f2f7;
    color: #111;
}

.pay-transfer-submit-btn {
    background: #111;
    color: #fff;
}

.pay-transfer-cancel-btn:active,
.pay-transfer-submit-btn:active {
    transform: scale(0.98);
}

/* Pinned Chat Override */
.pinned-chat {
    background-color: #f7f7f7 !important; /* Slightly distinct bg for pinned chat interface */
}

/* Moment Details Modal Styles */
.moment-detail-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff; /* Full screen white */
    z-index: 500;
    display: none;
    flex-direction: column;
    overflow-y: auto;
}

.moment-detail-container {
    padding: 24px 20px;
    padding-top: calc(env(safe-area-inset-top) + 20px);
}

.moment-detail-header {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
    align-items: flex-start;
}

.moment-detail-avatar {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    background: #eee;
    overflow: hidden;
}

.moment-detail-name-area {
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-top: 2px;
}

.moment-detail-name {
    font-size: 18px;
    font-weight: 600;
    color: #576b95;
}

.moment-detail-pinned-tag {
    font-size: 10px;
    background: #f2f2f7;
    color: #8e8e93;
    padding: 2px 4px;
    border-radius: 2px;
    align-self: flex-start;
    display: none;
}

.moment-detail-content {
    margin-left: 0; /* align with name */
    margin-top: 15px;
}

.moment-detail-text {
    font-size: 18px;
    color: #000;
    line-height: 1.5;
    margin-bottom: 15px;
}

.moment-detail-images {
    margin-bottom: 15px;
}

.moment-detail-img-wrapper {
    background: transparent;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.moment-detail-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.moment-detail-images.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
}
.moment-detail-images.grid .moment-detail-img-wrapper {
    aspect-ratio: 1/1;
}

.moment-detail-images.single .moment-detail-img-wrapper img {
    max-width: 80%;
    max-height: 300px;
    width: auto;
    height: auto;
}

.moment-detail-images.double {
    display: flex;
    gap: 5px;
}
.moment-detail-images.double .moment-detail-img-wrapper {
    width: 120px;
    height: 120px;
}

.moment-detail-time-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.moment-detail-time {
    font-size: 12px;
    color: #8e8e93;
}

.moment-detail-more {
    color: #576b95;
    font-size: 20px;
    cursor: pointer;
}

.moment-detail-interaction {
    background: #f7f7f7;
    border-radius: 4px;
    padding: 8px 10px;
    margin-top: 15px;
    font-size: 14px;
}

.moment-detail-likes {
    color: #576b95;
    margin-bottom: 5px;
    display: flex;
    gap: 5px;
    align-items: center;
}

.moment-detail-comment {
    margin-top: 4px;
}

.moment-detail-comment-name {
    color: #576b95;
    font-weight: 500;
}

/* Moment Action Sheet Items */
#moment-action-sheet .bottom-sheet {
    background: transparent !important;
    padding: 0 10px 10px 10px;
}

#moment-action-sheet .moment-action-sheet-item {
    background: #fff;
    padding: 12px 16px;
    text-align: center;
    font-size: 15px;
    font-weight: 500;
    color: #8e8e93;
    cursor: pointer;
    border-bottom: none;
    margin-bottom: 8px;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

#moment-action-sheet .moment-action-sheet-item:last-child {
    margin-bottom: 0;
}

#moment-action-sheet .moment-action-sheet-item:active {
    background: #f2f2f7;
}

#moment-action-sheet #moment-action-cancel {
    margin-top: 8px;
    background: #fff;
    padding: 16px 20px;
    text-align: center;
    font-size: 17px;
    font-weight: 600;
    color: #007aff;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

#moment-action-sheet .moment-action-sheet-title {
    background: #fff;
    padding: 15px;
    border-radius: 14px;
    margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Action Sheet Share Friends List */
#moment-share-friends-list {
    display: flex;
    overflow-x: auto;
    gap: 15px;
    padding: 0;
    border-bottom: none;
    margin-bottom: 0;
}

.moment-share-friend-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    min-width: 60px;
    cursor: pointer;
}

.moment-share-friend-avatar {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    background: #eee;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    color: #8e8e93;
}
.moment-share-friend-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.moment-share-friend-name {
    font-size: 11px;
    text-align: center;
    width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Popup for Pinned Moments List */
#pinned-moments-popup {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 600;
    display: none;
    justify-content: center;
    align-items: center;
}

.pinned-popup-content {
    width: 80%;
    max-height: 70%;
    background: #fff;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pinned-popup-header {
    padding: 15px;
    text-align: center;
    font-weight: 600;
    border-bottom: 1px solid #f2f2f2;
    position: relative;
}

.pinned-popup-close {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #8e8e93;
}

.pinned-popup-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.pinned-popup-item {
    display: flex;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f2f2f2;
}
.pinned-popup-item:last-child {
    border-bottom: none;
}

.pinned-popup-media {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    background: #f2f2f2;
}

.pinned-popup-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Moments Signature Row */
.moments-signature-row {
    display: flex;
    justify-content: flex-end;
    padding: 0 16px 0 0;
    margin-top: 8px;
    margin-bottom: 20px;
}

.user-moments-signature {
    width: calc(100% - 110px);
    max-width: calc(100% - 110px);
    margin-left: auto;
    text-align: right;
    color: #8e8e93;
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
    display: none;
}

/* Char Settings Segment */
.char-settings-sheet {
    max-height: 90%;
}

.char-settings-content {
    padding-bottom: 20px;
}

.char-settings-segment-wrap {
    padding: 0 16px 16px;
}

.char-settings-segment {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: #e9e9eb;
    border-radius: 999px;
}

.char-settings-tab {
    flex: 1;
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 14px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.char-settings-tab.active {
    background: #fff;
    color: #111827;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.char-settings-panel {
    display: none;
}

.char-settings-panel.active {
    display: block;
}

#chat-settings-sheet .bottom-sheet {
    overflow: hidden;
}

#chat-settings-sheet .detail-sheet-content {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    padding-bottom: 0;
}

#chat-settings-sheet .detail-sheet-content > div:first-child,
#chat-settings-sheet #chat-settings-segment {
    flex: 0 0 auto;
}

#chat-settings-sheet .char-settings-panel {
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
}

#chat-settings-sheet .char-settings-panel.active {
    flex: 1 1 auto;
}


/* Memory Panels - scoped to chat settings only */
#chat-settings-sheet .char-memory-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 0 16px 16px;
}

#chat-settings-sheet .char-memory-card {
    border: none;
    background: #fff;
    border-radius: 18px;
    padding: 14px 12px;
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    cursor: pointer;
    transition: all 0.2s ease;
}

#chat-settings-sheet .char-memory-card.active {
    background: #1c1c1e;
    color: #fff;
    box-shadow: 0 6px 14px rgba(28, 28, 30, 0.2);
}

#chat-settings-sheet .char-memory-panels {
    padding: 0 16px 4px;
}

#chat-settings-sheet .char-memory-section {
    display: none;
}

#chat-settings-sheet .char-memory-section.active {
    display: block;
    animation: imFadeIn 0.2s ease;
}

#chat-settings-sheet .char-memory-collapsible {
    margin: 0 16px 16px;
    border-radius: 20px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

#chat-settings-sheet .char-memory-collapse-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    cursor: pointer;
}

#chat-settings-sheet .char-memory-collapse-header i {
    font-size: 13px;
    color: #8e8e93;
    transition: transform 0.2s ease;
}

#chat-settings-sheet .char-memory-collapse-header.expanded i {
    transform: rotate(180deg);
}

#chat-settings-sheet .char-memory-collapse-body {
    display: none;
    padding: 0 16px 16px;
    border-top: none;
}

/* Remove all gray backgrounds and separators in chat settings for a pure white look */
#chat-settings-sheet .settings-group {
    background-color: #ffffff !important;
}

#chat-settings-sheet .settings-item {
    background-color: #ffffff !important;
}

#chat-settings-sheet .settings-item::after {
    display: none !important;
}

#chat-settings-sheet .char-memory-collapse-body.expanded {
    display: block;
    animation: imFadeIn 0.2s ease;
}

/* Cherished Memory Cards */
.chat-memory-cherished-cards-section {
    margin-bottom: 14px;
}

.chat-memory-cherished-section-title {
    font-size: 13px;
    font-weight: 700;
    color: #8e8e93;
    margin-bottom: 10px;
    padding-left: 2px;
    letter-spacing: 0.02em;
}

.chat-memory-cherished-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.chat-memory-cherished-empty {
    padding: 16px 14px;
    border-radius: 20px;
    background: linear-gradient(180deg, #ffffff 0%, #fafafd 100%);
    border: 1px solid #ececf2;
    color: #8e8e93;
    font-size: 13px;
    line-height: 1.65;
    text-align: left;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}

.chat-memory-cherished-card {
    width: 100%;
    border: none;
    border-radius: 22px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfbfd 100%);
    border: 1px solid #ececf2;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
    padding: 14px 15px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    text-align: left;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
    position: relative;
    overflow: hidden;
}

.chat-memory-cherished-card::before {
    content: '';
    position: absolute;
    top: 12px;
    left: 14px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff2d55;
    box-shadow: 0 0 0 4px rgba(255, 45, 85, 0.1);
}

.chat-memory-cherished-card:active {
    transform: scale(0.985);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
    background: linear-gradient(180deg, #ffffff 0%, #f7f7fa 100%);
}

.chat-memory-cherished-card-title {
    padding-left: 20px;
    font-size: 15px;
    font-weight: 700;
    color: #111827;
    line-height: 1.35;
    width: 100%;
}

.chat-memory-cherished-card-content {
    font-size: 13px;
    color: #374151;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
    width: 100%;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.chat-memory-cherished-card-time {
    margin-top: 2px;
    font-size: 11px;
    color: #9ca3af;
    font-weight: 600;
}

.chat-memory-cherished-detail-overlay {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(15, 23, 42, 0.26);
    opacity: 0;
    transition: opacity 0.22s ease;
}

.chat-memory-cherished-detail-overlay.active {
    opacity: 1;
}

.chat-memory-cherished-detail-card {
    position: relative;
    width: min(100%, 292px);
    max-height: min(68vh, 440px);
    overflow-y: auto;
    padding: 18px 16px 16px;
    border-radius: 26px;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 22px 48px rgba(15, 23, 42, 0.2);
    transform: translateY(10px) scale(0.96);
    opacity: 0;
    transition: transform 0.22s ease, opacity 0.22s ease;
}

.chat-memory-cherished-detail-overlay.active .chat-memory-cherished-detail-card {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.chat-memory-cherished-detail-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: #f3f4f6;
    color: #111827;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.chat-memory-cherished-detail-close:active {
    transform: scale(0.96);
}

.chat-memory-cherished-detail-label {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 10px;
    border-radius: 999px;
    background: #fff1f5;
    color: #e11d48;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 12px;
}

.chat-memory-cherished-detail-title {
    font-size: 18px;
    font-weight: 800;
    color: #111827;
    line-height: 1.35;
    margin-bottom: 8px;
    padding-right: 36px;
}

.chat-memory-cherished-detail-time {
    font-size: 12px;
    color: #9ca3af;
    margin-bottom: 14px;
}

.chat-memory-cherished-detail-content {
    font-size: 14px;
    color: #374151;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 12px;
}

.chat-memory-cherished-detail-reason,
.chat-memory-cherished-detail-thought {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
    padding: 12px 13px;
    border-radius: 16px;
    background: #f8f8fb;
    border: 1px solid #ececf2;
}

.chat-memory-cherished-detail-reason {
    margin-bottom: 10px;
}

/* Generic Memory Modal */
.chat-memory-modal-overlay {
    position: absolute;
    inset: 0;
    z-index: 7;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(15, 23, 42, 0.24);
    opacity: 0;
    transition: opacity 0.22s ease;
}

.chat-memory-modal-overlay.active {
    opacity: 1;
}

.chat-memory-modal-card {
    position: relative;
    width: min(100%, 304px);
    max-height: min(72vh, 500px);
    overflow-y: auto;
    padding: 18px 16px 16px;
    border-radius: 26px;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 22px 48px rgba(15, 23, 42, 0.2);
    transform: translateY(10px) scale(0.96);
    opacity: 0;
    transition: transform 0.22s ease, opacity 0.22s ease;
}

.chat-memory-modal-overlay.active .chat-memory-modal-card {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.chat-memory-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: #f3f4f6;
    color: #111827;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.chat-memory-modal-close:active {
    transform: scale(0.96);
}

.chat-memory-modal-label {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 10px;
    border-radius: 999px;
    background: #f3f4f6;
    color: #6b7280;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 12px;
}

.chat-memory-modal-title {
    font-size: 18px;
    font-weight: 800;
    color: #111827;
    line-height: 1.35;
    margin-bottom: 8px;
    padding-right: 36px;
}

.chat-memory-modal-subtitle {
    font-size: 12px;
    color: #9ca3af;
    margin-bottom: 14px;
    line-height: 1.5;
}

.chat-memory-modal-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-memory-modal-empty {
    min-height: 120px;
    border-radius: 18px;
    background: #f8f8fb;
    border: 1px solid #ececf2;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 18px 16px;
    font-size: 13px;
    color: #8e8e93;
    line-height: 1.65;
}

.chat-memory-modal-text-block {
    font-size: 14px;
    color: #374151;
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-word;
    padding: 14px 14px;
    border-radius: 18px;
    background: #f8f8fb;
    border: 1px solid #ececf2;
}

.chat-memory-modal-plain-note {
    font-size: 12px;
    color: #8e8e93;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding-left: 2px;
}

.chat-memory-modal-cherished-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-memory-modal-cherished-card {
    width: 100%;
    border: none;
    border-radius: 22px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfbfd 100%);
    border: 1px solid #ececf2;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
    padding: 14px 15px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    text-align: left;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
    position: relative;
    overflow: hidden;
}

.chat-memory-modal-cherished-card::before {
    content: '';
    position: absolute;
    top: 12px;
    left: 14px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff2d55;
    box-shadow: 0 0 0 4px rgba(255, 45, 85, 0.1);
}

.chat-memory-modal-cherished-card:active {
    transform: scale(0.985);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
    background: linear-gradient(180deg, #ffffff 0%, #f7f7fa 100%);
}

.chat-memory-modal-cherished-card-title {
    padding-left: 20px;
    font-size: 15px;
    font-weight: 700;
    color: #111827;
    line-height: 1.35;
    width: 100%;
}

.chat-memory-modal-cherished-card-content {
    font-size: 13px;
    color: #374151;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
    width: 100%;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.chat-memory-modal-cherished-card-time {
    margin-top: 2px;
    font-size: 11px;
    color: #9ca3af;
    font-weight: 600;
}

@media (max-width: 420px) {
    .chat-memory-cherished-card {
        border-radius: 20px;
    }

    .chat-memory-cherished-detail-card {
        width: min(100%, 100%);
        border-radius: 22px;
    }

    .chat-memory-modal-card {
        width: min(100%, 100%);
        border-radius: 22px;
    }

    .chat-memory-modal-cherished-card {
        border-radius: 20px;
    }
}

/* Relationship Preview Nodes */
.relationship-node {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    z-index: 10;
}

.relationship-node img,
.relationship-node i {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background-color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border: 2px solid #fff;
}

.relationship-node i {
    display: flex;
    justify-content: center;
    align-items: center;
    color: #8e8e93;
    font-size: 20px;
}

.relationship-node.main-node img,
.relationship-node.main-node i {
    width: 50px;
    height: 50px;
    border: 2px solid var(--ios-blue);
}

.node-label {
    font-size: 12px;
    font-weight: 600;
    color: #333;
    background: rgba(255, 255, 255, 0.8);
    padding: 2px 6px;
    border-radius: 8px;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

/* Relationship Sheet */
.relationship-item {
    background: #fff;
    border-radius: 18px;
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

#relationship-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0 16px 16px;
}

#relationship-empty-state {
    padding: 12px 16px 20px;
    color: #8e8e93;
    font-size: 13px;
    text-align: center;
}

.relationship-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    background: #e5e5ea;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8e8e93;
    flex-shrink: 0;
}

.relationship-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.relationship-meta {
    flex: 1;
    min-width: 0;
}

.relationship-name {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 4px;
}

.relationship-desc {
    font-size: 12px;
    color: #8e8e93;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.relationship-input {
    width: 120px;
    border: none;
    outline: none;
    background: #f2f2f7;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 13px;
    text-align: right;
    color: #111827;
}

.relationship-input::placeholder {
    color: #b0b0b0;
}

#relationship-picker {
    display: none;
    padding: 0 16px 16px;
}

#relationship-picker-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#relationship-picker .relationship-item {
    min-height: 72px;
}

#relationship-list .relationship-item {
    justify-content: space-between;
}

@media (max-width: 420px) {
    #relationship-list .relationship-item {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .relationship-input {
        width: 100%;
        margin-left: 56px;
        text-align: left;
    }
}

/* NPC Chat: basic text chat with AI reply only */
.im-chat-npc .ins-chat-sign,
.im-chat-npc .im-chat-status-dot,
.im-chat-npc .chat-call-btn,
.im-chat-npc .plus-btn {
    display: none !important;
}

.im-chat-npc .im-chat-title-wrap {
    justify-content: center;
    min-height: 44px;
}

.im-chat-npc .im-chat-header-main {
    gap: 10px;
}

.im-chat-npc .ins-chat-input-wrapper {
    padding-left: 14px;
}

.im-chat-npc .mic-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 50%;
    background: #111111;
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 34px;
    font-size: 15px;
}

/* NPC Settings */
.npc-settings-sheet {
    overflow: hidden;
}

#npc-chat-settings-sheet .npc-settings-content {
    overflow-y: auto;
    padding: 0 0 max(20px, env(safe-area-inset-bottom, 0px));
}

.npc-settings-profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 16px 12px;
}

.npc-settings-avatar {
    width: 86px;
    height: 86px;
    border-radius: 50%;
    background: #f2f2f7;
    color: #8e8e93;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 34px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.npc-settings-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.npc-settings-name {
    max-width: 260px;
    margin-top: 12px;
    color: #111111;
    font-size: 22px;
    font-weight: 800;
    line-height: 1.25;
    text-align: center;
    overflow-wrap: anywhere;
}

.npc-settings-group {
    margin: 10px 16px;
}

.npc-settings-icon-actions {
    display: flex;
    align-items: center;
    gap: 24px;
    padding-right: 8px;
    color: #111111;
    font-size: 19px;
}

.npc-settings-icon-actions i {
    cursor: pointer;
}

.npc-settings-danger-group {
    margin-top: 24px;
}

/* Cleaner Relationship Network */
#relationship-sheet .bottom-sheet {
    background: #f7f7fb;
}

#relationship-preview-area {
    background: radial-gradient(circle at center, #ffffff 0%, #fbfbfe 68%, #f3f4f8 100%) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 8px 22px rgba(15, 23, 42, 0.06);
}

#relationship-list,
#relationship-picker-list {
    gap: 10px;
}

#relationship-list {
    margin: 0 16px 14px !important;
    padding: 0 !important;
}

#relationship-picker {
    margin: 0 16px 16px !important;
    padding: 12px !important;
    border: 1px solid #ececf2;
    border-radius: 18px;
    background: #ffffff;
}

.relationship-item {
    min-height: 66px;
    border: 1px solid #ececf2;
    border-radius: 16px;
    padding: 11px 12px;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.04);
}

.relationship-meta {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.relationship-input {
    width: 104px;
    min-width: 104px;
    text-align: left;
}

.relationship-delete-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #fff1f1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0 !important;
}

.relationship-node {
    pointer-events: auto;
}

.relationship-node img,
.relationship-node i {
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.16);
}

.relationship-node.main-node img,
.relationship-node.main-node i {
    box-shadow: 0 8px 20px rgba(0, 122, 255, 0.18);
}

.node-label {
    max-width: 88px;
    padding: 3px 8px;
    border: 1px solid rgba(236, 236, 242, 0.95);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 420px) {
    .relationship-item {
        display: grid;
        grid-template-columns: 44px minmax(0, 1fr) 34px;
        align-items: center;
        gap: 10px;
    }

    .relationship-input {
        grid-column: 2 / 4;
        width: 100%;
        min-width: 0;
        margin-left: 0;
    }
}

/* Stickers View */
.stickers-view .header-btn {
    z-index: 100;
    position: relative;
}

.sticker-category-card {
    background: #fff;
    border: 1px solid #f2f2f7;
    border-radius: 14px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: none;
}

.sticker-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    position: relative;
}

.sticker-category-title {
    font-size: 16px;
    font-weight: 600;
    color: #000;
    display: flex;
    align-items: center;
    gap: 10px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.sticker-category-cover {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: #f2f2f7;
    object-fit: cover;
}

.sticker-category-delete {
    color: #ff3b30;
    cursor: pointer;
    font-size: 13px;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sticker-category-delete:hover {
    background: #ffebee;
}

.sticker-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.sticker-item {
    aspect-ratio: 1;
    background: #f2f2f7;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.sticker-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sticker-preview-img {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
    background: #e5e5ea;
    flex-shrink: 0;
}


/* Keyboard stability: avoid focus-triggered smooth scrolling on mobile */
#chat-message-input:focus {
    scroll-behavior: auto;
}

.custom-minimal-tabs {
    display: flex;
    justify-content: space-around;
    padding: 0 40px;
    margin-top: 15px;
    margin-bottom: 15px;
}
.custom-minimal-tabs button.char-settings-tab {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 10px 20px;
    font-size: 16px;
    font-weight: 600;
    color: #ccc;
    cursor: pointer;
    position: relative;
    outline: none;
    transition: color 0.2s;
    flex: none !important;
}
.custom-minimal-tabs button.char-settings-tab.active {
    color: #000;
    background: none !important;
    box-shadow: none !important;
}
.custom-minimal-tabs button.char-settings-tab::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 3px;
    background-color: #000;
    border-radius: 3px;
    transition: width 0.2s ease;
}
.custom-minimal-tabs button.char-settings-tab.active::after {
    width: 80%;
}
