
/* 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: max(110px, calc(110px + env(safe-area-inset-bottom, 0px)));
    --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;
}

.im-group-settings-fullscreen {
    width: 100%;
    height: 100%;
    max-height: 100%;
    padding: 0;
    border-radius: 0;
    background: #f2f2f7;
    overflow: hidden;
}

.im-group-settings-header {
    height: calc(44px + env(safe-area-inset-top, 20px));
    padding-top: env(safe-area-inset-top, 20px);
    box-sizing: border-box;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: #f2f2f7;
    z-index: 2;
}

.im-group-settings-back {
    position: absolute;
    left: 16px;
    display: flex;
    align-items: center;
    gap: 4px;
    color: #007aff;
    font-size: 16px;
    cursor: pointer;
}

.im-group-settings-title {
    color: #111;
    font-size: 17px;
    font-weight: 600;
}

.im-group-settings-content {
    display: block;
    min-height: 0;
    padding: 20px;
    padding-bottom: max(40px, env(safe-area-inset-bottom, 0px));
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.im-group-member-sheet,
.im-group-context-sheet,
.im-group-edit-sheet {
    width: 100%;
    max-height: 85%;
    padding-bottom: 0;
}

.im-group-member-sheet {
    max-height: 72%;
}

.im-group-more-sheet {
    width: 100%;
    max-height: 72%;
    padding-bottom: 0;
}

.im-group-member-content,
.im-group-more-content,
.im-group-context-content,
.im-group-edit-content {
    min-height: 0;
    padding: 8px 16px max(24px, env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.group-summary-more-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
}

.group-summary-more-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.group-summary-stat-card {
    padding: 10px;
    border-radius: 12px;
    border: 1px solid #ececf2;
    background: #fff;
    text-align: center;
}

.group-summary-stat-card span {
    display: block;
    margin-bottom: 4px;
    color: #8e8e93;
    font-size: 11px;
}

.group-summary-stat-card strong {
    display: block;
    color: #111;
    font-size: 16px;
}

.group-summary-more-title {
    padding: 0 2px;
    color: #8e8e93;
    font-size: 12px;
    font-weight: 700;
}

.group-summary-more-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
}

.group-poll-create-card {
    width: min(calc(100% - 32px), 430px);
    max-height: min(84%, 680px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f2f2f7;
}

.group-poll-create-header {
    position: relative;
    flex-shrink: 0;
}

.group-poll-create-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: #e5e5ea;
    color: #636366;
    cursor: pointer;
}

.group-poll-create-body {
    min-height: 0;
    padding: 14px 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.group-poll-create-label,
.group-poll-create-options-header {
    color: #636366;
    font-size: 12px;
    font-weight: 700;
}

.group-poll-question-input {
    width: 100%;
    margin: 8px 0 16px;
    padding: 12px 14px;
    border: 1px solid #e5e5ea;
    border-radius: 14px;
    background: #fff;
    color: #111;
    font: inherit;
    line-height: 1.45;
    resize: none;
    outline: none;
    box-sizing: border-box;
}

.group-poll-question-input:focus,
.group-poll-option-input:focus {
    border-color: #5856d6;
}

.group-poll-create-options-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.group-poll-options-list {
    overflow: hidden;
    border: 1px solid #e5e5ea;
    border-radius: 14px;
    background: #fff;
}

.group-poll-option-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 10px 0 14px;
    border-bottom: 1px solid #f2f2f7;
}

.group-poll-option-row:last-child {
    border-bottom: 0;
}

.group-poll-option-index {
    width: 18px;
    color: #8e8e93;
    font-size: 13px;
}

.group-poll-option-input {
    min-width: 0;
    flex: 1;
    border: 0;
    outline: 0;
    background: transparent;
    color: #111;
    font-size: 15px;
}

.group-poll-option-remove {
    width: 30px;
    height: 30px;
    border: 0;
    background: transparent;
    color: #ff3b30;
    cursor: pointer;
}

.group-poll-add-option-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 100%;
    margin-top: 10px;
    padding: 11px 14px;
    border: 0;
    border-radius: 12px;
    background: #fff;
    color: #5856d6;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.group-poll-add-option-btn:disabled {
    opacity: .45;
    cursor: default;
}

.group-poll-create-footer {
    flex-shrink: 0;
    padding: 12px 16px max(16px, env(safe-area-inset-bottom, 0px));
}

.group-poll-submit-btn {
    width: 100%;
    padding: 13px 16px;
    border: 0;
    border-radius: 14px;
    background: #5856d6;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

.group-poll-card {
    width: min(232px, 64vw);
    overflow: hidden;
    border: 1px solid #e5e5ea;
    border-radius: 14px;
    background: #fff;
    color: #111;
    box-sizing: border-box;
}

.group-poll-card-head {
    padding: 11px 12px 9px;
    border-bottom: 1px solid #f2f2f7;
}

.group-poll-card-kicker {
    margin-bottom: 4px;
    color: #8e8e93;
    font-size: 10px;
    font-weight: 700;
}

.group-poll-card-title {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
    word-break: break-word;
}

.group-poll-card-options {
    padding: 3px 10px;
}

.group-poll-card-option {
    width: 100%;
    padding: 8px 2px;
    border: 0;
    border-bottom: 1px solid #f2f2f7;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.group-poll-card-option:last-child {
    border-bottom: 0;
}

.group-poll-card-option-main {
    display: flex;
    align-items: center;
    gap: 7px;
}

.group-poll-radio {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    border: 1.5px solid #c7c7cc;
    border-radius: 50%;
}

.group-poll-card-option.is-user-selected .group-poll-radio {
    border: 4px solid #007aff;
}

.group-poll-option-text {
    min-width: 0;
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    word-break: break-word;
}

.group-poll-option-count {
    color: #8e8e93;
    font-size: 11px;
}

.group-poll-voters {
    display: flex;
    flex-wrap: wrap;
    gap: 3px 5px;
    margin: 5px 0 0 22px;
}

.group-poll-voter {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: #636366;
    font-size: 10px;
}

.group-poll-voter img {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    object-fit: cover;
}

.group-poll-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 34px;
    padding: 7px 12px;
    border-top: 1px solid #f2f2f7;
    color: #8e8e93;
    font-size: 10px;
}

.group-summary-empty {
    min-height: 96px;
    border-radius: 12px;
    border: 1px solid #ececf2;
    background: #fff;
    color: #8e8e93;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.group-summary-card {
    width: 100%;
    border: 1px solid #ececf2;
    border-radius: 12px;
    background: #fff;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    cursor: pointer;
}

.group-summary-card-main {
    flex: 1;
    min-width: 0;
}

.group-summary-card-title {
    color: #111;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
}

.group-summary-card-time {
    margin-top: 3px;
    color: #8e8e93;
    font-size: 11px;
}

.group-summary-card-event {
    margin-top: 6px;
    color: #4b5563;
    font-size: 13px;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.group-summary-card-delete {
    width: 30px;
    height: 30px;
    border-radius: 15px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ff3b30;
    background: #fff1f0;
}

.group-summary-detail-card {
    width: min(100%, 360px);
    max-height: min(82vh, 680px);
    background: #fff !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.group-summary-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid #f2f2f7;
    flex-shrink: 0;
}

.group-summary-detail-title {
    color: #111;
    font-size: 18px;
    font-weight: 750;
}

.group-summary-detail-subtitle {
    margin-top: 3px;
    color: #8e8e93;
    font-size: 12px;
}

.group-summary-detail-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 16px;
    background: #f2f2f7;
    color: #8e8e93;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.group-summary-detail-body {
    padding: 16px 18px 18px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.group-summary-detail-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 12px;
}

.group-summary-detail-field span {
    color: #8e8e93;
    font-size: 12px;
    font-weight: 700;
}

.group-summary-detail-field input,
.group-summary-detail-field textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #e5e5ea;
    border-radius: 12px;
    background: #f8f8fb;
    color: #111;
    font-size: 14px;
    line-height: 1.55;
    outline: none;
    padding: 10px 12px;
    resize: vertical;
}

.group-summary-detail-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.group-summary-detail-actions button {
    flex: 1;
    border: none;
    border-radius: 12px;
    padding: 12px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.group-summary-detail-delete {
    background: #ffe5e5;
    color: #ff3b30;
}

.group-summary-detail-save {
    background: #007aff;
    color: #fff;
}

.group-private-chat-detail-card {
    width: min(100%, 390px);
    max-height: min(78vh, 680px);
    background: #fff !important;
}

.group-private-chat-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid #f2f2f7;
    flex-shrink: 0;
}

.group-private-chat-detail-title {
    color: #111;
    font-size: 18px;
    font-weight: 750;
}

.group-private-chat-detail-subtitle {
    color: #8e8e93;
    font-size: 12px;
    margin-top: 3px;
}

.group-private-chat-detail-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: #f2f2f7;
    color: #636366;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.group-private-chat-detail-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 18px 18px;
    background: #fff;
    -webkit-overflow-scrolling: touch;
}

.group-private-chat-detail-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-bottom: 3px;
}

.group-private-chat-detail-row.is-group-start {
    margin-top: 9px;
}

.group-private-chat-detail-row:first-child {
    margin-top: 0;
}

.group-private-chat-detail-row.is-sender {
    align-items: flex-end;
}

.group-private-chat-detail-name {
    color: #8e8e93;
    font-size: 11px;
    margin: 0 8px 3px;
}

.group-private-chat-detail-bubble {
    display: inline-flex;
    flex-direction: column;
    align-self: flex-start;
    flex: 0 1 auto;
    width: max-content;
    inline-size: max-content;
    min-width: 0;
    max-width: 78%;
    max-inline-size: min(78%, 300px);
    padding: 7px 11px;
    border: none;
    border-radius: 17px;
    box-sizing: border-box;
    background: #e9e9eb;
    color: #111;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.42;
    text-align: left;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
}

button.group-private-chat-detail-bubble {
    display: inline-flex;
    flex-direction: column;
    align-self: flex-start;
    width: max-content;
    inline-size: max-content;
    max-width: 78%;
    max-inline-size: min(78%, 300px);
    min-width: 0;
    appearance: none;
    -webkit-appearance: none;
    padding: 7px 11px;
    border: none;
    background: #e9e9eb;
    color: #111;
    margin: 0;
    font: inherit;
    line-height: 1.42;
    text-align: left;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    outline: none;
    cursor: pointer;
}

.group-private-chat-detail-row.is-sender .group-private-chat-detail-bubble {
    align-self: flex-end;
    background: #111;
    color: #fff;
}

.group-private-chat-detail-original,
.group-private-chat-detail-translation {
    display: block;
    max-width: 100%;
    min-width: 0;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    hyphens: auto;
}

.group-private-chat-detail-translation {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    color: #6f6f75;
    font-size: 13px;
    line-height: 1.42;
}

.group-private-chat-detail-row.is-sender .group-private-chat-detail-translation {
    border-top-color: rgba(255, 255, 255, 0.22);
    color: rgba(255, 255, 255, 0.72);
}

.group-private-chat-detail-translation[hidden] {
    display: none;
}

.group-private-chat-detail-time-chip {
    align-self: center;
    margin: 7px 0 2px;
    color: #8e8e93;
    font-size: 11px;
}

.linked-account-chat-detail-card {
    width: min(100%, 360px);
    height: min(76vh, 560px);
    max-height: 560px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 24px;
}

.linked-account-chat-detail-messages {
    padding: 12px 18px 18px;
    overscroll-behavior: contain;
}

.group-private-chat-detail-time {
    display: none;
}

.group-private-chat-view-link,
.message-recalled-view-link {
    margin-left: 4px;
    color: #8e8e93;
    font: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
    vertical-align: baseline;
    cursor: pointer;
}

.recalled-message-detail-card {
    width: min(calc(100% - 32px), 390px);
    max-height: min(70vh, 560px);
    background: #fff !important;
}

.recalled-message-detail-content {
    overflow-y: auto;
    padding: 18px;
    color: #111;
    font-size: 15px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    user-select: text;
    -webkit-user-select: text;
}

.recalled-message-detail-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.recalled-message-detail-translate {
    border: 0;
    border-radius: 999px;
    padding: 6px 10px;
    background: #f2f2f7;
    color: #007aff;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
}

.recalled-message-detail-translation {
    margin: 0 18px 18px;
    padding: 12px 14px;
    border-radius: 12px;
    background: #f2f2f7;
    color: #3a3a3c;
    font-size: 14px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    user-select: text;
    -webkit-user-select: text;
}

.recalled-message-detail-translate[hidden],
.recalled-message-detail-translation[hidden] {
    display: none;
}

.message-recalled-notice {
    width: 100%;
    margin: 10px 0;
    color: #8e8e93;
    font-size: 13px;
    line-height: 1.4;
    text-align: center;
}

/* 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;
     /* 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: max(22px, calc(22px + env(safe-area-inset-bottom, 0px)));
    left: 50%;
    width: auto;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    z-index: 100;
    pointer-events: none;
}

.line-bottom-nav {
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    padding: 5px;
    border-radius: 32px;
    width: auto;
    max-width: calc(100vw - 32px);
    justify-content: center;
    align-items: center;
    gap: 0;
    height: 58px;
    position: relative;
    box-sizing: border-box;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.14);
}

/* Animated Indicator for iMessage */
.line-nav-indicator {
    position: absolute;
    left: 5px;
    top: auto;
    bottom: 5px;
    height: 48px;
    /* Width is handled by JS dynamically */
    background: rgba(0, 0, 0, 0.07);
    border-radius: 28px;
    z-index: 0;
    transition: left 0.28s cubic-bezier(0.25, 0.1, 0.25, 1), width 0.28s ease;
    pointer-events: none;
}

.line-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: #8e8e93;
    font-size: 10px;
    line-height: 1.1;
    font-weight: 500;
    cursor: pointer;
    z-index: 1;
    padding: 0;
    width: 78px;
    height: 48px;
    min-width: 0;
    flex: 0 0 78px;
    position: relative;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.line-nav-item i {
    font-size: 18px;
    line-height: 1;
}

.line-nav-item span {
    font-size: 10px;
    display: block;
}

.line-nav-item.active {
    color: #111111;
}

/* Animations */
@keyframes imFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.line-content, .chats-content, .calls-content {
    animation: imFadeIn 0.3s ease;
}

.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;
    gap: 12px;
    cursor: pointer;
}

.memory-sheet-title-row {
    padding: 0 16px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.memory-sheet-title-row .memory-sheet-title { padding: 0; }

.memory-sheet-add-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 16px;
    background: #007aff;
    color: #fff;
    cursor: pointer;
}

.memory-short-item:last-child {
    border-bottom: none;
}

.memory-short-summary-title {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.memory-short-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.memory-short-delete-btn {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 15px;
    background: #ffe5e5;
    color: #ff3b30;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.memory-short-delete-btn:hover {
    background: #ff3b30;
    color: #fff;
}

.memory-short-item .memory-short-delete-btn i {
    color: inherit;
    font-size: 12px;
}

.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,
.memory-entry-editor-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-entry-editor-close {
    position: absolute;
    right: 16px;
    top: 16px;
    border: none;
    background: transparent;
    color: #8e8e93;
    font-size: 18px;
    cursor: pointer;
}

.memory-entry-editor-body {
    overflow-y: auto;
    padding: 0 16px 18px;
}

.memory-entry-editor-field,
.memory-summary-stack-row {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 12px;
    color: #3a3a3c;
    font-size: 13px;
    font-weight: 600;
}

.memory-entry-editor-field input,
.memory-entry-editor-field textarea,
.memory-entry-editor-field select,
.memory-summary-stack-row select,
.memory-summary-stack-row textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #d1d1d6;
    border-radius: 11px;
    padding: 10px 11px;
    background: #fff;
    color: #111;
    font: inherit;
    font-weight: 400;
    line-height: 1.45;
    outline: none;
}

.memory-entry-editor-field textarea,
.memory-summary-stack-row textarea { resize: vertical; }

.memory-entry-editor-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 18px;
}

.memory-entry-editor-actions button,
.memory-summary-clear-prompt {
    border: none;
    border-radius: 12px;
    padding: 11px;
    background: #e5e5ea;
    color: #111;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

#memory-entry-editor-save { background: #007aff; color: #fff; }

.memory-summary-count-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.memory-summary-count {
    color: #111111;
    font-size: 18px;
    font-weight: 800;
    line-height: 1.1;
}

.memory-summary-setting-card {
    margin-top: 14px;
    padding: 4px 0 12px;
    border-radius: 16px;
    background: #f2f2f7;
}

.memory-summary-toggle-row {
    min-height: 58px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid #dedee3;
}

.memory-summary-toggle-row > div {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.memory-summary-toggle-row strong { font-size: 16px; color: #111; }
.memory-summary-toggle-row span { font-size: 12px; color: #8e8e93; }

.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-setting-card .memory-summary-form-row {
    margin: 6px 0 0;
    background: transparent;
}

.memory-summary-stack-row {
    margin: 8px 14px 0;
}

.memory-summary-stack-row textarea { min-height: 96px; }

.memory-summary-clear-prompt {
    margin: 0 14px 10px;
    padding: 8px 10px;
    color: #007aff;
    font-size: 13px;
}

.memory-summary-round-control {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #8e8e93;
    font-size: 13px;
}

.memory-summary-hint {
    padding: 0 14px;
    color: #8e8e93;
    font-size: 12px;
    line-height: 1.4;
}

.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;
}

.memory-summary-confirm-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

.chat-memory-autonomous-sheet {
    width: 100%;
    max-width: none;
    box-sizing: border-box;
    height: auto;
    max-height: 78%;
    display: flex;
    flex-direction: column;
    background: #f2f2f7;
}

.chat-memory-autonomous-content {
    padding: 12px 16px 6px;
    overflow-y: auto;
}

.chat-memory-autonomous-group {
    margin: 0 0 12px;
    background: #ffffff;
}

.chat-memory-autonomous-toggle-row {
    border-bottom: none;
}

.chat-memory-autonomous-card.is-enabled .chat-memory-autonomous-toggle-row {
    border-bottom: 1px solid var(--separator-color);
}

.chat-memory-autonomous-intervals {
    padding: 12px 14px 4px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.chat-memory-autonomous-card:not(.is-enabled) .chat-memory-autonomous-intervals,
.chat-memory-autonomous-card:not(.is-enabled) .chat-memory-autonomous-note {
    display: none;
}

.chat-memory-autonomous-intervals label {
    min-width: 0;
    color: #3a3a3c;
    font-size: 13px;
    line-height: 1.3;
}

.chat-memory-autonomous-intervals input {
    width: 68px;
    margin: 0 4px;
    padding: 6px 7px;
    border: 1px solid #d1d1d6;
    border-radius: 9px;
    background: #ffffff;
    color: #111111;
    font-size: 15px;
    text-align: center;
    outline: none;
}

.chat-memory-autonomous-note {
    margin: 4px 14px 12px;
    color: #8e8e93;
    font-size: 13px;
    line-height: 1.45;
}

.chat-memory-autonomous-save,
.chat-memory-autonomous-cancel {
    margin-left: 16px;
    margin-right: 16px;
    width: auto;
    min-height: 48px;
    padding: 14px 0;
    border-radius: 14px;
    font-size: 16px;
}

.chat-memory-autonomous-save {
    margin-top: 14px;
    background: #007aff;
    color: #ffffff;
}

.chat-memory-autonomous-cancel {
    margin-top: 8px;
    margin-bottom: calc(12px + env(safe-area-inset-bottom));
    background: #ffffff;
    color: #111111;
}

@media (max-width: 390px) {
    .chat-memory-autonomous-intervals {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 390px) {
    .line-bottom-nav {
        max-width: calc(100vw - 24px);
    }

    .line-nav-item {
        width: 72px;
        flex-basis: 72px;
    }

    .line-nav-item i {
        font-size: 17px;
    }

    .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;
     /* 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%;
    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);
    
    
    padding-bottom: 5px;
}

.chat-sticky-container.is-group {
    background: transparent;
    border-bottom: none;
    
    
    padding-bottom: 5px;
}

.chat-sticky-container :where(
    .chat-back-btn,
    .im-chat-back-btn,
    .chat-call-btn,
    .chat-menu-btn,
    .chat-cancel-batch-btn,
    .group-header-right-avatar,
    .group-header-right-avatar *,
    .im-chat-group-title-wrap,
    .im-chat-group-title-wrap *,
    .im-chat-header-main,
    .im-chat-header-main *,
    .ins-chat-avatar,
    .ins-chat-avatar *
) {
    pointer-events: auto;
}

.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;
    border: 0;
    background: transparent;
    color: #111111;
    font-size: 16px;
    font-weight: 500;
}

.chat-batch-header {
    width: 100%;
    box-sizing: border-box;
}

.batch-delete-btn:disabled {
    cursor: default !important;
}

.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;
}

.group-header-right-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(242, 242, 247, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: visible;
    flex-shrink: 0;
    pointer-events: auto;
    cursor: pointer;
}

.group-header-right-avatar-inner {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #e5e5ea;
}

.im-group-header-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
    background: #e5e5ea;
}

.im-group-header-avatar-fallback {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #ff9a9e, #fecfef);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    font-size: 20px;
}

.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;
    
    -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;
}

/* 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;
    white-space: pre-wrap;
    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-cot-row {
    width: 100%;
    margin: 6px 0;
    display: flex;
    justify-content: flex-start;
    box-sizing: border-box;
}

.chat-cot-row.chat-cot-row-inline {
    margin: 2px 0 6px;
}

.chat-cot-card {
    width: fit-content;
    max-width: min(78%, 330px);
    overflow: hidden;
    border: 0;
    border-radius: 999px;
    background: rgba(242, 242, 247, 0.94);
    color: #636366;
    box-sizing: border-box;
}

.chat-cot-card.is-expanded {
    width: min(78%, 330px);
    border-radius: 20px;
}

.chat-cot-toggle {
    width: 100%;
    min-height: 36px;
    padding: 7px 12px;
    border: 0;
    background: transparent;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font: inherit;
    cursor: pointer;
}

.chat-cot-title {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.chat-cot-chevron {
    color: #8e8e93;
}

.chat-cot-chevron {
    flex: 0 0 auto;
    font-size: 11px;
    transition: transform 0.2s ease;
}

.chat-cot-card.is-expanded .chat-cot-chevron {
    transform: rotate(180deg);
}

.chat-cot-content {
    padding: 0 12px 12px;
    color: #666;
    font-size: 13px;
    line-height: 1.58;
    white-space: pre-wrap;
    word-break: break-word;
    user-select: text;
    -webkit-user-select: text;
}

.chat-cot-content[hidden] {
    display: none;
}

.typing-row.im-cot-loading-row {
    margin-top: 10px;
}

.im-cot-loading-row .chat-cot-card {
    width: fit-content;
}

.im-cot-loading-row .chat-cot-toggle {
    cursor: default;
}

.im-cot-loading-dots {
    display: inline-flex;
    gap: 3px;
    margin-left: 3px;
}

.im-cot-loading-dots > span {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #8e8e93;
    animation: typingBounce 1.2s infinite ease-in-out;
}

.im-cot-loading-dots > span:nth-child(2) {
    animation-delay: 0.15s;
}

.im-cot-loading-dots > span:nth-child(3) {
    animation-delay: 0.3s;
}

.chat-row .chat-bubble.im-card-bubble {
    width: auto !important;
    min-width: 0 !important;
    max-width: min(70%, 260px) !important;
    flex: 0 1 auto !important;
    white-space: normal !important;
    box-sizing: border-box !important;
}

.chat-row .chat-bubble.im-card-bubble .im-card-content {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

#msg-context-bubble-clone .msg-context-card-clone,
#msg-context-bubble-clone .im-card-bubble {
    flex: 0 0 auto !important;
    min-width: 0 !important;
    max-width: min(72vw, 270px) !important;
    white-space: normal !important;
    box-sizing: border-box !important;
}

#msg-context-bubble-clone .chat-link-card,
#msg-context-bubble-clone .chat-fake-link-card {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

#msg-context-bubble-clone .msg-context-row-clone {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0 !important;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    box-sizing: border-box;
}

#msg-context-bubble-clone .msg-context-row-clone.user-row {
    justify-content: flex-end;
}

#msg-context-bubble-clone .msg-context-row-clone.ai-row {
    justify-content: flex-start;
}

#msg-context-bubble-clone .msg-context-row-clone .chat-bubble {
    flex: 0 1 auto;
}

.chat-row .chat-bubble.image-message-bubble {
    max-width: min(62vw, 204px) !important;
}

.chat-row .chat-bubble.image-message-bubble .chat-image-bubble-img {
    width: min(56vw, 200px) !important;
    height: min(56vw, 200px) !important;
    max-width: 200px !important;
    max-height: 200px !important;
}

.chat-row .voice-message-bubble {
    max-width: min(70%, 240px) !important;
}

.chat-row .pay-transfer-bubble {
    max-width: min(62%, 218px) !important;
}

.chat-row .group-red-packet-bubble {
    max-width: min(70%, 268px) !important;
}

.chat-row .html-bubble.im-card-bubble {
    max-width: min(72%, 260px) !important;
}

.chat-row .html-bubble.im-card-bubble > * {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.chat-row .html-bubble.im-card-bubble .loves-invite-bubble {
    width: min(62vw, 220px) !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.chat-row .moment-forward-bubble {
    width: min(62vw, 220px) !important;
    min-width: 0 !important;
    max-width: min(62vw, 220px) !important;
    box-sizing: border-box !important;
}

.chat-row .pay-receipt-card {
    width: min(76vw, 280px) !important;
    max-width: 280px !important;
    box-sizing: border-box !important;
}

.chat-row .voice-call-record-bubble {
    min-width: 176px !important;
}

.chat-row .voice-call-record-card {
    overflow: hidden;
}

.chat-row .voice-call-record-card > div:last-child {
    min-width: 0;
}

.chat-row .voice-call-record-card > div:last-child > div {
    overflow: hidden;
    text-overflow: ellipsis;
}

.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;
    opacity: 0.7;
    vertical-align: bottom;
}

.show-timestamps .bubble-meta {
    display: inline-flex;
    align-items: center;
}

.bubble-read-icon {
    margin-left: 3px;
    font-size: 10px;
    letter-spacing: 0;
}

/* User Bubble Base */
.user-bubble {
    background-color: #2c2c2e;
    color: #fff;
    border-radius: 20px;
    position: relative;
}

/* AI Bubble Base */
.ai-bubble {
    background-color: #f2f2f7;
    color: #000;
    border-radius: 20px;
    position: relative;
}

/* Timestamp Outside Logic */
.active-chat-interface.timestamp-outside .chat-bubble {
    overflow: visible; /* Allow timestamp to break out */
}

.active-chat-interface.timestamp-outside .user-row .bubble-meta {
    position: absolute;
    left: 0;
    bottom: 4px;
    transform: translateX(-100%);
    margin-left: -6px;
    margin-top: 0;
    color: #8e8e93;
}

.active-chat-interface.timestamp-outside .ai-row .bubble-meta {
    position: absolute;
    right: 0;
    bottom: 4px;
    transform: translateX(100%);
    margin-right: -6px;
    margin-top: 0;
    color: #8e8e93;
}

/* Offline Tavern Fullscreen View */
#offline-tavern-view {
    position: absolute;
    inset: 0;
    background: #ffffff; /* 改为白色背景 */
    color: #111;
    z-index: 1000;
    display: none;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding-top: 0 !important;
}

#offline-tavern-view.active {
    opacity: 1;
}

.offline-tavern-header {
    height: calc(54px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 16px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
    border-bottom: none;
    flex-shrink: 0;
    box-sizing: border-box;
}

.offline-tavern-back, .offline-tavern-settings {
    color: #000;
    font-size: 20px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f2f2f7;
    display: flex;
    align-items: center;
    justify-content: center;
}

.offline-tavern-title {
    font-size: 17px;
    font-weight: 600;
    color: #111;
}

.offline-tavern-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    font-size: 15px;
    line-height: 1.6;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* 居中气泡样式 */
.offline-tavern-bubble {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 10px;
    text-align: center;
}

.offline-tavern-bubble-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 8px;
}

.offline-tavern-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
    background-color: #f2f2f7;
    border: 3px solid #f2f2f7;
    margin-bottom: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.offline-tavern-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.offline-tavern-avatar i {
    font-size: 30px;
    color: #ccc;
}

.offline-tavern-name-container {
    display: flex;
    align-items: center;
    gap: 4px;
}

.offline-tavern-name {
    font-size: 16px;
    font-weight: 800;
    color: #111;
}

.offline-tavern-name-dropdown {
    font-size: 12px;
    color: #8e8e93;
}

.offline-tavern-sign {
    font-size: 12px;
    color: #8e8e93;
    background: #f7f7f5;
    padding: 2px 8px;
    border-radius: 12px;
    margin-top: 4px;
}

.offline-tavern-bubble-text {
    background: #f2f2f7;
    color: var(--offline-tavern-narrative-color, #111111);
    padding: 18px 20px;
    border-radius: 24px;
    font-size: 15px;
    width: 100%;
    max-width: 348px;
    text-align: left;
    box-sizing: border-box;
    line-height: 1.5;
    word-break: break-word;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.offline-tavern-bubble-body {
    width: 100%;
    max-width: 348px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.offline-tavern-thinking {
    width: fit-content;
    max-width: 100%;
    margin-bottom: 8px;
    overflow: hidden;
    border: 0;
    border-radius: 999px;
    background: #f2f2f7;
    text-align: left;
    box-sizing: border-box;
}

.offline-tavern-thinking.is-expanded {
    width: 100%;
    border-radius: 20px;
}

.offline-tavern-thinking-toggle {
    width: 100%;
    min-height: 36px;
    padding: 7px 12px;
    border: 0;
    background: transparent;
    color: #636366;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font: inherit;
    cursor: pointer;
}

.offline-tavern-thinking-label {
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.offline-tavern-thinking-icon {
    flex: 0 0 auto;
    color: #8e8e93;
    font-size: 11px;
    transition: transform 0.2s ease;
}

.offline-tavern-thinking.is-expanded .offline-tavern-thinking-icon {
    transform: rotate(180deg);
}

.offline-tavern-thinking-content {
    padding: 0 12px 12px;
    color: #666;
    font-size: 13px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

.offline-tavern-thinking-content[hidden] {
    display: none;
}

.offline-tavern-floor {
    display: inline;
    color: #8e8e93;
    font-size: 11px;
    font-weight: 800;
}

.offline-tavern-bubble-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 6px;
    min-height: 22px;
}

.offline-tavern-bubble-meta {
    padding: 0 4px;
    color: #8e8e93;
    font-size: 11px;
    line-height: 1.2;
    text-align: left;
    flex: 1;
    min-width: 0;
}

.offline-tavern-bubble-actions {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    opacity: 1;
    pointer-events: auto;
    flex-shrink: 0;
}

.offline-tavern-action-btn {
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 0;
    background: transparent;
    color: #8e8e93;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: none;
    font-size: 12px;
    padding: 0;
}

.offline-tavern-action-btn:hover,
.offline-tavern-action-btn:focus-visible {
    color: #636366;
}

.offline-tavern-action-btn.danger,
.offline-tavern-bubble.user .offline-tavern-action-btn {
    color: #8e8e93;
    background: transparent;
}

.offline-tavern-inline-editor {
    width: 100%;
    min-height: 100%;
    border: none;
    outline: none;
    resize: vertical;
    background: transparent;
    color: inherit;
    font: inherit;
    line-height: 1.5;
    padding: 0;
    box-sizing: border-box;
}

.offline-tavern-bubble-text[data-editing="true"] {
    display: block !important;
}

.offline-tavern-bubble-text[data-editing="true"] .offline-tavern-inline-editor {
    display: block;
    min-height: inherit;
}

.offline-tavern-reroll-placeholder {
    min-height: 64px;
    display: flex;
    align-items: center;
    color: #8e8e93;
    font-weight: 700;
}

.offline-tavern-history-card,
.offline-tavern-history-session,
.offline-tavern-history-back {
    border: none;
    border-radius: 14px;
    background: #f2f2f7;
    color: #111;
    padding: 12px 14px;
    text-align: left;
    cursor: pointer;
    font: inherit;
    width: 100%;
    max-width: 348px;
    box-sizing: border-box;
    align-self: center;
}

.offline-tavern-history-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 800;
}

.offline-tavern-history-session {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
    padding-right: 50px;
}

.offline-tavern-history-session:focus-visible {
    outline: 2px solid #007aff;
    outline-offset: 2px;
}

.offline-tavern-history-delete {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 15px;
    background: #ffe5e5;
    color: #ff3b30;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.offline-tavern-history-delete:hover {
    background: #ff3b30;
    color: #fff;
}

.offline-tavern-history-delete:disabled {
    opacity: 0.45;
    cursor: default;
}

.offline-tavern-history-title {
    font-size: 14px;
    font-weight: 800;
}

.offline-tavern-history-meta {
    font-size: 12px;
    color: #8e8e93;
}

.offline-tavern-history-summary {
    font-size: 13px;
    color: #3a3a3c;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.offline-tavern-history-detail-summary {
    width: 100%;
    max-width: 348px;
    align-self: center;
    box-sizing: border-box;
    border-radius: 14px;
    background: #fff;
    border: 1px solid #e5e5ea;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.offline-tavern-history-detail-summary-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.offline-tavern-history-detail-summary-title {
    font-size: 15px;
    font-weight: 800;
    color: #111;
}

.offline-tavern-history-detail-summary-meta {
    margin-top: 2px;
    font-size: 12px;
    color: #8e8e93;
}

.offline-tavern-history-summary-edit {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 15px;
    background: #f2f2f7;
    color: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.offline-tavern-history-detail-summary-text {
    font-size: 14px;
    line-height: 1.55;
    color: #2c2c2e;
    white-space: pre-wrap;
    word-break: break-word;
}

.offline-tavern-history-summary-textarea {
    display: none;
    width: 100%;
    min-height: 132px;
    box-sizing: border-box;
    border: 1px solid #007aff;
    border-radius: 12px;
    outline: none;
    resize: vertical;
    padding: 10px 12px;
    background: #f8f8fb;
    color: #111;
    font: inherit;
    font-size: 14px;
    line-height: 1.55;
}

.offline-tavern-history-summary-actions {
    display: none;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.offline-tavern-history-summary-actions button {
    border: none;
    border-radius: 12px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.offline-tavern-history-summary-cancel {
    background: #f2f2f7;
    color: #3a3a3c;
}

.offline-tavern-history-summary-save {
    background: #111;
    color: #fff;
}

.offline-tavern-history-detail-summary.is-editing .offline-tavern-history-detail-summary-text,
.offline-tavern-history-detail-summary.is-editing .offline-tavern-history-summary-edit {
    display: none;
}

.offline-tavern-history-detail-summary.is-editing .offline-tavern-history-summary-textarea {
    display: block;
}

.offline-tavern-history-detail-summary.is-editing .offline-tavern-history-summary-actions {
    display: flex;
}

.offline-tavern-paragraph {
    margin: 0 0 0.9em;
}

.offline-tavern-paragraph:last-child {
    margin-bottom: 0;
}

.offline-tavern-paragraph-wrap {
    margin: 0 0 0.9em;
}

.offline-tavern-paragraph-wrap:last-child {
    margin-bottom: 0;
}

.offline-tavern-paragraph-wrap .offline-tavern-paragraph {
    margin-bottom: 0;
}

.offline-tavern-speech {
    display: inline;
}

.offline-tavern-dialogue {
    color: var(--offline-tavern-dialogue-color, #8b8b8b);
}

.offline-tavern-barrage-btn {
    border: none;
    background: transparent;
    color: #8e8e93;
    padding: 0;
    margin: 0 0 0 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: pointer;
    font: inherit;
    line-height: 1;
    vertical-align: baseline;
}

.offline-tavern-speech.is-playable {
    border-radius: 4px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.14s ease, opacity 0.14s ease;
}

.offline-tavern-speech.is-playable:hover {
    background: rgba(0, 0, 0, 0.045);
}

.offline-tavern-speech.is-playable:active {
    background: rgba(0, 0, 0, 0.075);
    opacity: 0.82;
}

.offline-tavern-speech.is-playable:focus-visible {
    outline: 1px solid rgba(99, 99, 102, 0.55);
    outline-offset: 2px;
}

.offline-tavern-speech.is-playable.is-loading {
    background: rgba(0, 0, 0, 0.06);
    cursor: wait;
    opacity: 0.58;
}

.offline-tavern-barrage-btn {
    margin-top: 7px;
    font-size: 12px;
}

.offline-tavern-barrage-final-btn {
    margin: 4px 0 12px;
    padding: 7px 10px;
    border-radius: 999px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: #3a3a3c;
    font-size: 13px;
    font-weight: 700;
    align-self: flex-start;
}

.offline-tavern-barrage-btn:hover,
.offline-tavern-barrage-btn:focus-visible {
    color: #636366;
}

.offline-tavern-barrage-view {
    position: fixed;
    inset: 0;
    z-index: 1080;
    background: #fff;
    color: #111;
    display: none;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.18s ease;
}

.offline-tavern-barrage-view.active {
    opacity: 1;
}

.offline-tavern-barrage-header {
    height: calc(54px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 16px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #f2f2f7;
    box-sizing: border-box;
    flex-shrink: 0;
}

.offline-tavern-barrage-close,
.offline-tavern-barrage-spacer {
    width: 36px;
    height: 36px;
}

.offline-tavern-barrage-close {
    border: none;
    border-radius: 18px;
    background: #f2f2f7;
    color: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.offline-tavern-barrage-title {
    font-size: 17px;
    font-weight: 800;
}

.offline-tavern-barrage-list {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px max(24px, env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-sizing: border-box;
}

.offline-tavern-barrage-row {
    display: grid;
    grid-template-columns: minmax(54px, auto) 1fr auto;
    gap: 10px;
    align-items: baseline;
    padding: 10px 12px;
    border-radius: 12px;
    background: #f2f2f7;
    font-size: 14px;
    line-height: 1.35;
}

.offline-tavern-barrage-name {
    color: #636366;
    font-weight: 800;
    white-space: nowrap;
}

.offline-tavern-barrage-text {
    color: #111;
    word-break: break-word;
}

.offline-tavern-barrage-likes {
    color: #8e8e93;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    white-space: nowrap;
}

.offline-tavern-barrage-empty {
    color: #8e8e93;
    text-align: center;
    margin-top: 40px;
    font-size: 14px;
}

.offline-tavern-choice-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-top: 12px;
}

.offline-tavern-choice-btn {
    width: 100%;
    border: 1px solid #d1d1d6;
    background: rgba(255,255,255,0.72);
    color: #111;
    border-radius: 14px;
    padding: 9px 11px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
    cursor: pointer;
    font: inherit;
    line-height: 1.3;
}

.offline-tavern-choice-btn:active {
    background: rgba(229,229,234,0.9);
}

.offline-tavern-choice-index {
    width: 18px;
    height: 18px;
    border-radius: 9px;
    background: #111;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.offline-tavern-choice-text {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.offline-tavern-bubble.user .offline-tavern-bubble-text {
    background: #111;
    color: #fff;
}

/* 占位文本样式，后续可以根据实际内容替换 */
.offline-tavern-placeholder {
    color: #8e8e93;
    text-align: center;
    font-style: italic;
    margin-top: 40px;
}

.offline-tavern-input-area {
    padding: 6px 16px max(12px, env(safe-area-inset-bottom, 0px));
    background: #ffffff;
}

.offline-tavern-input-bar {
    display: flex;
    align-items: flex-end;
    background: #ffffff;
    border: 1px solid #e5e5ea;
    border-radius: 22px;
    padding: 6px 6px 6px 14px;
}

.offline-tavern-input {
    flex: 1;
    height: 34px;
    min-height: 34px;
    max-height: 120px;
    background: transparent;
    border: none;
    color: #111;
    padding: 6px 0;
    font-size: 15px;
    line-height: 22px;
    resize: none;
    outline: none;
    box-sizing: border-box;
}

.offline-tavern-input::placeholder {
    color: #8e8e93;
}

.offline-tavern-send {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #111;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 8px;
    margin-bottom: 1px;
    font-size: 14px;
}

.offline-tavern-send.is-generating {
    background: #ff9500;
}

.offline-tavern-send.is-stopping {
    background: #8e8e93;
}

.offline-tavern-attachment {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: #8e8e93;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
    margin-right: 4px;
    margin-bottom: 1px;
    font-size: 20px;
}

.offline-tavern-attachment:active {
    opacity: 0.7;
}

.offline-tavern-send:active {
    background: #666;
}


/* Adjust padding for group packets / pay transfer in outside mode */
.active-chat-interface.timestamp-outside .pay-transfer-bubble .bubble-meta,
.active-chat-interface.timestamp-outside .group-red-packet-bubble .bubble-meta {
    bottom: 12px;
}

/* Tails removed as requested */

/* Make connecting bubbles squarish */
.user-row.has-prev .user-bubble {
    border-top-right-radius: 4px;
}
.user-row.has-next .user-bubble {
    border-bottom-right-radius: 4px;
}

.ai-row.has-prev .ai-bubble {
    border-top-left-radius: 4px;
}
.ai-row.has-next .ai-bubble {
    border-bottom-left-radius: 4px;
}


.voice-message-bubble {
    min-width: 0;
    max-width: 70%;
    padding: 10px 14px;
    
    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;
    
    flex-shrink: 0;
}

.ai-bubble .voice-message-mic {
    background: transparent;
    
}

.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 {
    width: auto !important;
    max-width: min(44vw, 150px) !important;
    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 !important;
    max-width: min(40vw, 132px) !important;
    max-height: min(40vw, 132px) !important;
    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); }
}

/* Chat Message Headers */
.chat-message-header {
    display: flex;
    align-items: flex-start;
    width: 100%;
    margin-bottom: 8px;
    z-index: 10;
}

.chat-message-header.user-header {
    justify-content: flex-end;
    padding-right: 8px;
}

.chat-message-header.ai-header {
    justify-content: flex-start;
    padding-left: 8px;
}

.chat-header-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid #eee;
    z-index: 2;
    background: #fff;
    flex-shrink: 0;
}

.chat-header-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.user-header .chat-header-info {
    align-items: flex-end;
    padding-right: 20px;
    margin-right: -16px;
}

.ai-header .chat-header-info {
    align-items: flex-start;
    padding-left: 20px;
    margin-left: -16px;
}

.chat-header-name {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.chat-header-date {
    font-size: 12px;
    color: #888;
}

/* 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;
}

.im-together-listening-player {
    position: relative;
    width: 100%;
    height: 60px;
    margin: 0 0 9px;
    padding: 6px 8px 6px 6px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38px 38px;
    align-items: center;
    overflow: hidden;
    border: 0;
    border-radius: 20px;
    background: rgba(242,245,242,.94);
    box-shadow: 0 8px 24px rgba(41,53,45,.10);
    box-sizing: border-box;
}
.im-together-listening-player[hidden] { display: none !important; }
.im-together-listening-main,
.im-together-listening-control {
    margin: 0;
    padding: 0;
    border: 0 !important;
    outline: 0 !important;
    background: transparent;
    box-shadow: none !important;
    color: inherit;
    font: inherit;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
}
.im-together-listening-main { min-width: 0; display: grid; grid-template-columns: 46px minmax(0, 1fr); gap: 10px; align-items: center; text-align: left; }
.im-together-listening-art { width: 46px; height: 46px; display: grid; place-items: center; overflow: hidden; border-radius: 14px; background: #dce3de; color: #607067; }
.im-together-listening-art img { width: 100%; height: 100%; object-fit: cover; }
.im-together-listening-copy { min-width: 0; }
.im-together-listening-copy strong,
.im-together-listening-copy small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.im-together-listening-copy strong { color: #202723; font-size: 12px; }
.im-together-listening-copy small { margin-top: 4px; color: #7f8982; font-size: 9px; }
.im-together-listening-control { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; color: #344239; }
.im-together-listening-progress { position: absolute; left: 12px; right: 12px; bottom: 0; height: 2px; border-radius: 2px; background: linear-gradient(to right, #607168 var(--together-progress, 0%), rgba(96,113,104,.15) var(--together-progress, 0%)); }

.keyboard-open .ins-chat-input-container {
    padding: 8px 12px;
}

/* @ Mention List Box */
.at-mention-list {
    position: absolute;
    bottom: 100%;
    left: 16px;
    right: 16px;
    background: #ffffff;
    border: 1px solid #e5e5ea;
    border-radius: 12px;
    
    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);
    border: 1px solid rgba(255, 255, 255, 0.3);
    
    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 {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    margin: 0;
    flex: 0 0 32px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.16s ease, transform 0.16s ease, opacity 0.16s ease;
}

.send-btn-icon:active {
    transform: scale(0.94);
}

.send-btn {
    background: transparent;
    color: #8e8e93;
    font-size: 16px;
}

.send-btn:active {
    background: transparent;
    color: #636366;
}

.mic-btn {
    background: #111111;
    color: #ffffff;
}

.mic-btn:active {
    background: #2c2c2e;
}

/* 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;
    
}

.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 {
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
    gap: 15px;
    height: calc(54px + env(safe-area-inset-top, 0px));
    padding: calc(14px + env(safe-area-inset-top, 0px)) 20px 10px;
    color: #fff; /* White icons on cover */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    /* 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 */
    
    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-time-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.moment-translate-btn {
    color: #576b95;
    font-size: 12px;
    line-height: 1.4;
    cursor: pointer;
    user-select: none;
    vertical-align: baseline;
}

.moment-comment-delete {
    margin-left: 6px;
    color: #8e8e93;
    font-size: 12px;
    line-height: 1.4;
    cursor: pointer;
    user-select: none;
    vertical-align: baseline;
}

.moment-translation,
.moment-comment-translation,
.moment-thought-translation {
    display: none;
    color: #8e8e93;
    line-height: 1.5;
    white-space: pre-wrap;
}

.moment-translation {
    font-size: 14px;
    margin: -2px 0 8px;
}

.moment-comment-translation {
    font-size: 14px;
    margin: 3px 0 3px;
}

.moments-new-message-bubble {
    width: max-content;
    max-width: calc(100% - 32px);
    min-height: 42px;
    margin: 0 auto 4px;
    padding: 6px 14px 6px 7px;
    border: 0;
    border-radius: 8px;
    background: rgba(45, 45, 48, 0.92);
    color: #fff;
    align-items: center;
    gap: 9px;
    cursor: pointer;
}

.moments-new-message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 5px;
    overflow: hidden;
    background: #68686c;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.moments-new-message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.moments-new-message-text {
    font-size: 14px;
    line-height: 1.2;
    white-space: nowrap;
}

.moment-image-detail-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.72);
    opacity: 0;
    transition: opacity 0.18s ease;
}

.moment-image-detail-overlay.active {
    opacity: 1;
}

.moment-image-detail-card {
    width: min(100%, 420px);
    max-height: 88vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 22px;
}

.moment-image-detail-header {
    min-height: 48px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.moment-image-detail-author {
    min-width: 0;
    overflow: hidden;
    color: #111;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.moment-image-detail-close {
    color: #8e8e93;
    font-size: 18px;
    cursor: pointer;
}

.moment-image-detail-media {
    min-height: 260px;
    background: #111;
    display: flex;
    align-items: center;
    justify-content: center;
}

.moment-image-detail-media img {
    width: 100%;
    max-height: 62vh;
    object-fit: contain;
    display: block;
}

.moment-image-detail-copy {
    padding: 14px 16px 18px;
    overflow-y: auto;
}

.moment-image-detail-label {
    margin-bottom: 6px;
    color: #8e8e93;
    font-size: 12px;
}

.moment-image-detail-description {
    color: #222;
    font-size: 15px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

.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;
    
    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;
    
}

.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;
    
    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-floating-tabs {
    position: relative;
    z-index: 2;
    pointer-events: auto;
}

.chat-profile-panel-tab-btn {
    pointer-events: auto;
    touch-action: manipulation;
}

.chat-profile-panel-action-btn {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border: none;
    border-radius: 50%;
    background: #fff;
    color: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 0.18s ease, background 0.18s ease;
}

.chat-profile-panel-action-btn.is-page {
    font-size: 14px;
}

.chat-profile-panel-action-btn:disabled {
    opacity: 0.34;
    cursor: default;
    transform: none;
}

.chat-profile-panel-action-btn.is-danger {
    color: #ff3b30;
}

.chat-profile-panel-action-btn:active {
    transform: scale(0.94);
    background: #f2f2f7;
}

.chat-profile-panel-card {
    position: relative;
    width: min(100%, 320px);
    background: #ffffff;
    border-radius: 24px;
    
    overflow: hidden;
    transform: translateY(12px) scale(0.96);
    opacity: 0;
    touch-action: pan-y;
    will-change: transform, opacity;
    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;
    
}

.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;
    justify-content: center;
    text-align: center;
}

.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;
    
}

.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;
    
}

.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;
    
}

.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);
    
    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;
    
    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: rgba(0,0,0,0.4);
    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;
    
}

#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: #ffffff !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;
    
}

#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 */
    
    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,
.publish-moment-top-bar {
    height: calc(54px + env(safe-area-inset-top, 0px));
    min-height: calc(54px + env(safe-area-inset-top, 0px));
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: calc(env(safe-area-inset-top, 0px) + 10px) 20px 12px;
    background: #fff;
    border-bottom: 1px solid #f2f2f2;
    flex-shrink: 0;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 30;
}

.chat-profile-status-page {
    width: 100%;
}

.chat-profile-status-time {
    margin-bottom: 7px;
    color: #8e8e93;
    font-size: 11px;
    text-align: right;
}

.chat-profile-status-counter {
    margin-top: 10px;
    color: #8e8e93;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
}

.chat-profile-status-edit-overlay {
    position: absolute;
    inset: 0;
    z-index: 12;
    align-items: center;
    justify-content: center;
    padding: 14px;
    background: rgba(0, 0, 0, 0.32);
    opacity: 0;
    transition: opacity 0.18s ease;
}

.chat-profile-status-edit-overlay.active {
    opacity: 1;
}

.chat-profile-status-edit-card {
    width: 100%;
    max-height: 100%;
    overflow-y: auto;
    padding: 18px;
    border-radius: 20px;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transform: translateY(8px) scale(0.98);
    transition: transform 0.18s ease;
}

.chat-profile-status-edit-overlay.active .chat-profile-status-edit-card {
    transform: translateY(0) scale(1);
}

.chat-profile-status-edit-title {
    color: #111;
    font-size: 18px;
    font-weight: 750;
}

.chat-profile-status-edit-card label {
    color: #666;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.chat-profile-status-edit-card textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #e5e5ea;
    border-radius: 12px;
    background: #f8f8fb;
    color: #111;
    padding: 10px 11px;
    font: inherit;
    font-size: 14px;
    outline: none;
    resize: none;
}

.chat-profile-status-edit-card textarea:focus {
    border-color: #111;
}

.chat-profile-status-edit-readonly {
    color: #8e8e93;
    font-size: 12px;
}

.status-prompt-sheet-card {
    max-height: 82%;
    padding-left: 0;
    padding-right: 0;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
    background: #f2f2f7;
}

.status-prompt-sheet-content {
    padding: 6px 18px 0;
}

.status-prompt-toggle-group {
    margin: 14px 0 18px;
    overflow: hidden;
    border-radius: 18px;
    background: #fff;
}

.status-prompt-toggle-row {
    min-height: 72px;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 16px !important;
    cursor: default;
    border-bottom: none !important;
}

.status-prompt-toggle-copy {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-prompt-toggle-copy > span:last-child {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.status-prompt-toggle-icon {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    background: #111;
    color: #fff;
    font-size: 15px;
}

.status-prompt-input-label {
    display: block;
    margin: 0 4px 9px;
    color: #636366;
    font-size: 13px;
    font-weight: 600;
}

#status-prompt-input {
    min-height: 180px;
    width: 100%;
    padding: 16px 17px;
    border: 1px solid #e5e5ea;
    border-radius: 18px;
    background: #fff;
    line-height: 1.65;
    box-sizing: border-box;
    transition: opacity 0.2s ease, background 0.2s ease;
}

.status-builder-hint {
    margin-top: 3px;
    color: #8e8e93;
    font-size: 11px;
}

#status-prompt-input:disabled {
    opacity: 0.58;
    background: #fff;
}

.cot-settings-sheet-card {
    max-height: 86%;
    padding-left: 0;
    padding-right: 0;
    overflow: hidden;
    background: #f2f2f7;
}

.cot-settings-sheet-content {
    padding: 6px 18px 20px;
}

.cot-settings-toggle-group {
    margin: 14px 0 18px;
    overflow: hidden;
    border-radius: 18px;
    background: #fff;
}

.cot-settings-toggle-row {
    min-height: 72px;
    justify-content: space-between;
    gap: 14px;
    border-bottom: none !important;
}

.cot-settings-toggle-copy {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.cot-settings-toggle-copy > span:last-child {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.cot-settings-toggle-icon {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border-radius: 11px;
    background: #5856d6;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.cot-settings-menu-icon {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.cot-settings-input-label {
    display: block;
    margin: 0 4px 9px;
    color: #636366;
    font-size: 13px;
    font-weight: 600;
}

#chat-cot-prompt-input {
    min-height: 210px;
    width: 100%;
    padding: 16px 17px;
    border: none;
    border-radius: 18px;
    background: #fff;
    box-sizing: border-box;
    resize: vertical;
    font-size: 15px;
    line-height: 1.55;
}

.cot-settings-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.cot-settings-actions .sheet-action {
    flex: 1;
    margin: 0;
}

#save-status-prompt-btn {
    width: 100%;
    min-height: 48px;
    margin: 18px 0 0;
    border: none;
    border-radius: 15px;
    background: #111;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
}

.chat-profile-status-edit-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.chat-profile-status-edit-actions button {
    min-height: 40px;
    border: none;
    border-radius: 12px;
    background: #f2f2f7;
    color: #111;
    font-size: 14px;
    font-weight: 700;
}

.chat-profile-status-edit-actions button.is-primary {
    background: #111;
    color: #fff;
}

.publish-moment-content {
    padding-top: calc(69px + env(safe-area-inset-top, 0px)) !important;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)) !important;
    box-sizing: border-box;
    min-height: 0;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

#publish-moment-text { scroll-margin-top: calc(69px + env(safe-area-inset-top, 0px)); }

.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;
    
    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;
}

.moments-message-top-bar {
    height: calc(54px + env(safe-area-inset-top, 0px));
    min-height: calc(54px + env(safe-area-inset-top, 0px));
    display: flex;
    align-items: center;
    padding: calc(env(safe-area-inset-top, 0px) + 10px) 20px 12px;
    background-color: #fff;
    border-bottom: 1px solid #e5e5e5;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    flex-shrink: 0;
    z-index: 30;
}

#moments-message-list {
    padding-top: calc(54px + env(safe-area-inset-top, 0px));
}

/* 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: #ffffff; /* 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: #ffffff;
}

/* 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;
    
}

.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-link-entry,
.attachment-more-regenerate-entry,
.attachment-more-voice-entry,
.attachment-more-listen-entry,
.attachment-more-narration-entry,
.attachment-more-dynamic-action-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-link-entry:active,
.attachment-more-regenerate-entry:active,
.attachment-more-voice-entry:active,
.attachment-more-listen-entry:active,
.attachment-more-narration-entry:active,
.attachment-more-dynamic-action-entry:active,
.attachment-more-offline-entry:active {
    transform: scale(0.96);
    opacity: 0.85;
}

.attachment-more-pay-icon,
.attachment-more-link-icon,
.attachment-more-regenerate-icon,
.attachment-more-voice-icon,
.attachment-more-listen-icon,
.attachment-more-narration-icon,
.attachment-more-dynamic-action-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;
    
}

.attachment-more-regenerate-icon {
    background: #007aff;
}

.attachment-more-link-icon {
    background: #0a84ff;
}

.attachment-more-voice-icon {
    background: #34c759;
}

.attachment-more-listen-icon { background: #af52de; }
.attachment-more-listen-entry.active .attachment-more-listen-icon { background: #ff3b30; }

.attachment-more-narration-icon {
    background: #5856d6;
}

.attachment-more-dynamic-action-icon {
    background: #5ac8fa;
}

.attachment-more-offline-icon {
    background: #8e8e93;
}

.attachment-more-offline-entry.active .attachment-more-offline-icon {
    background: #ff9500;
}

.attachment-more-dynamic-action-entry.active .attachment-more-dynamic-action-icon {
    background: #111;
}

.attachment-more-pay-label,
.attachment-more-link-label,
.attachment-more-regenerate-label,
.attachment-more-voice-label,
.attachment-more-listen-label,
.attachment-more-narration-label,
.attachment-more-dynamic-action-label,
.attachment-more-offline-label {
    font-size: 12px;
    color: #111;
    font-weight: 600;
}

.im-link-composer-overlay {
    position: absolute;
    inset: 0;
    z-index: 70;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.im-link-composer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.38);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.im-link-composer-card {
    position: relative;
    width: min(100%, 360px);
    max-height: min(680px, 88%);
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.98);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(18px) scale(0.97);
    opacity: 0;
    transition: transform 0.22s ease, opacity 0.2s ease;
}

.im-link-composer-overlay.active .im-link-composer-backdrop { opacity: 1; }
.im-link-composer-overlay.active .im-link-composer-card { transform: none; opacity: 1; }

.im-link-composer-header {
    min-height: 58px;
    padding: 10px 16px;
    display: grid;
    grid-template-columns: 34px 1fr 34px;
    align-items: center;
    text-align: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    box-sizing: border-box;
}

.im-link-composer-header strong { font-size: 17px; color: #111; }

.im-link-composer-close {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: #f2f2f7;
    color: #111;
    cursor: pointer;
}

.im-link-composer-body {
    padding: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.im-link-composer-input {
    width: 100%;
    min-height: 104px;
    max-height: 170px;
    resize: vertical;
    border: 1px solid #e5e5ea;
    border-radius: 18px;
    background: #f7f7fa;
    padding: 12px 14px;
    box-sizing: border-box;
    color: #111;
    font: inherit;
    font-size: 15px;
    line-height: 1.45;
    outline: none;
}

.im-link-composer-input:focus { border-color: #0a84ff; background: #fff; }

.im-link-detection-row {
    min-height: 34px;
    margin: 10px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.im-link-platform-badge {
    --link-platform-color: #8e8e93;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 5px 9px;
    background: #f2f2f7;
    background: color-mix(in srgb, var(--link-platform-color) 12%, white);
    color: var(--link-platform-color);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.im-link-platform-badge:not(.is-valid) { background: #f2f2f7; color: #8e8e93; }

.im-link-resolve-status {
    min-width: 0;
    text-align: right;
    color: #8e8e93;
    font-size: 11px;
    line-height: 1.3;
}

.im-link-resolve-status[data-status="resolved"] { color: #248a3d; }
.im-link-resolve-status[data-status="partial"] { color: #b25000; }
.im-link-resolve-status[data-status="failed"],
.im-link-resolve-status[data-status="unconfigured"] { color: #c9342e; }

.im-link-preview {
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 18px;
    background: #fff;
    overflow: hidden;
}

.im-link-preview-cover {
    height: 112px;
    background: linear-gradient(135deg, #dbeafe, #f2f2f7);
    color: #0a84ff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    overflow: hidden;
}

.im-link-preview-cover img { width: 100%; height: 100%; object-fit: cover; display: none; }
.im-link-preview-cover.has-image img { display: block; }
.im-link-preview-cover.has-image > i { display: none; }
.im-link-preview-copy { padding: 11px 12px 12px; }
.im-link-preview-title { color: #111; font-size: 14px; font-weight: 800; line-height: 1.35; word-break: break-word; }
.im-link-preview-author { margin-top: 4px; color: #636366; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.im-link-preview-description { margin-top: 7px; color: #8e8e93; font-size: 12px; line-height: 1.4; word-break: break-word; }
.im-link-composer-hint { margin: 11px 2px 0; color: #8e8e93; font-size: 11px; line-height: 1.45; }

.im-link-composer-actions {
    padding: 12px 16px 16px;
    display: flex;
    gap: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.im-link-composer-actions button {
    flex: 1;
    height: 44px;
    border: 0;
    border-radius: 15px;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
}

.im-link-composer-cancel { background: #f2f2f7; color: #636366; }
.im-link-composer-send { background: #111; color: #fff; }
.im-link-composer-send:disabled { opacity: 0.38; cursor: default; }

.chat-link-card {
    width: min(64vw, 228px);
    border-radius: 15px;
    background: #fbfbfd;
    border: 1px solid rgba(0, 0, 0, 0.07);
    overflow: hidden;
    color: #111;
    cursor: pointer;
    text-align: left;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.045);
}

.chat-link-card-cover {
    height: 74px;
    background: linear-gradient(135deg, #1c1c1e, #6b6b70);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    overflow: hidden;
}

.chat-link-card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-link-card-body { padding: 9px 10px 10px; }
.chat-link-card-platform { color: var(--link-card-color, #3a3a3c); font-size: 9px; font-weight: 900; letter-spacing: 0.05em; text-transform: uppercase; }
.chat-link-card-title { margin-top: 3px; font-size: 13px; font-weight: 800; line-height: 1.32; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.chat-link-card-summary { margin-top: 5px; color: #636366; font-size: 10px; line-height: 1.38; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.chat-link-card-footer { margin-top: 8px; padding-top: 7px; border-top: 1px solid #f2f2f7; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #8e8e93; font-size: 9px; }
.chat-link-card-footer span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* iMessage Theme Fullscreen Editor */
.im-theme-config-view {
    z-index: 500;
    padding-top: 0 !important;
    background: #f2f2f7;
    overflow: hidden;
}

.im-theme-header {
    min-height: calc(58px + env(safe-area-inset-top, 0px));
    padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid #e5e5ea;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 58px;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.im-theme-back-btn,
.im-theme-apply-btn {
    border: 0;
    cursor: pointer;
    font: inherit;
}

.im-theme-back-btn {
    width: 38px;
    height: 38px;
    border-radius: 14px;
    background: #f2f2f7;
    color: #111;
    font-size: 17px;
}

.im-theme-title {
    min-width: 0;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.im-theme-title strong {
    color: #111;
    font-size: 18px;
    line-height: 1.2;
}

.im-theme-title span {
    color: #8e8e93;
    font-size: 11px;
    line-height: 1.2;
}

.im-theme-apply-btn {
    height: 36px;
    border-radius: 14px;
    background: #111;
    color: #fff;
    font-size: 14px;
    font-weight: 800;
}

.im-theme-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid #e5e5ea;
    flex-shrink: 0;
}

.im-theme-tabs .theme-tab {
    min-width: 0;
    height: 36px;
    border: 0;
    border-radius: 14px;
    background: #f2f2f7;
    color: #636366;
    font-size: 13px;
    font-weight: 900;
    cursor: pointer;
}

.im-theme-tabs .theme-tab.active {
    background: #111;
    color: #fff;
}

.im-theme-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 16px calc(24px + env(safe-area-inset-bottom, 0px));
    -webkit-overflow-scrolling: touch;
}

.im-theme-panel[hidden],
.theme-tab-content[hidden] {
    display: none !important;
}

.im-theme-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(220px, 0.75fr);
    gap: 14px;
    align-items: stretch;
}

.im-theme-editor-panel,
.im-theme-preset-panel {
    min-width: 0;
    border-radius: 22px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    padding: 14px;
}

.im-theme-editor-panel {
    display: flex;
    flex-direction: column;
}

.im-theme-preset-panel {
    min-height: 260px;
}

.im-theme-panel-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.im-theme-panel-heading strong {
    color: #111;
    font-size: 15px;
    line-height: 1.25;
}

.im-theme-panel-heading span {
    color: #8e8e93;
    font-size: 11px;
    line-height: 1.25;
    white-space: nowrap;
}

.im-theme-code-input {
    width: 100%;
    min-height: 330px;
    flex: 1;
    border: 1px solid #e5e5ea;
    border-radius: 16px;
    background: #f7f7fa;
    padding: 12px;
    color: #111;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.45;
    resize: vertical;
    outline: none;
}

.im-theme-code-input:focus {
    border-color: #0a84ff;
    background: #fff;
}

.im-theme-actions,
.im-theme-save-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.im-theme-actions .sheet-action,
.im-theme-save-row .sheet-action {
    margin: 0;
    border: 0;
    min-height: 42px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 800;
}

.im-theme-danger-action {
    background: #ffebee !important;
    color: #ff3b30 !important;
}

.im-theme-secondary-action {
    background: #f2f2f7 !important;
    color: #111 !important;
}

.im-theme-save-action {
    background: #e5e5ea !important;
    color: #111 !important;
}

.im-theme-save-row input {
    min-width: 0;
    border: 1px solid #e5e5ea;
    border-radius: 14px;
    background: #f7f7fa;
    padding: 0 12px;
    color: #111;
    font: inherit;
    font-size: 14px;
    outline: none;
}

.im-theme-save-row input:focus {
    border-color: #0a84ff;
    background: #fff;
}

.im-theme-preset-list {
    margin-top: 0 !important;
}

.im-theme-preset-list .account-card {
    border-radius: 16px;
}

@media (max-width: 430px) {
    .im-theme-header {
        grid-template-columns: 40px minmax(0, 1fr) 54px;
        padding-left: 12px;
        padding-right: 12px;
    }

    .im-theme-tabs {
        padding-left: 12px;
        padding-right: 12px;
        gap: 6px;
    }

    .im-theme-tabs .theme-tab {
        font-size: 12px;
    }

    .im-theme-content {
        padding: 12px 12px calc(24px + env(safe-area-inset-bottom, 0px));
    }

    .im-theme-layout {
        grid-template-columns: 1fr;
    }

    .im-theme-code-input {
        min-height: 300px;
    }
}

.im-fake-link-composer-overlay {
    position: absolute;
    inset: 0;
    z-index: 1230;
    display: none;
    align-items: center;
    justify-content: center;
    padding:
        max(18px, env(safe-area-inset-top, 0px))
        18px
        max(18px, env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
}

.im-fake-link-composer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.38);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.im-fake-link-composer-card {
    position: relative;
    width: min(100%, 410px);
    max-height: min(720px, calc(100% - 36px));
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.98);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(18px) scale(0.97);
    opacity: 0;
    transition: transform 0.22s ease, opacity 0.2s ease;
}

.im-fake-link-composer-overlay.active .im-fake-link-composer-backdrop { opacity: 1; }
.im-fake-link-composer-overlay.active .im-fake-link-composer-card { transform: none; opacity: 1; }

.im-fake-link-composer-header {
    min-height: 58px;
    padding: 10px 16px;
    display: grid;
    grid-template-columns: 34px 1fr 34px;
    align-items: center;
    text-align: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    box-sizing: border-box;
}

.im-fake-link-composer-header strong { font-size: 17px; color: #111; }

.im-fake-link-composer-close {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: #f2f2f7;
    color: #111;
    cursor: pointer;
}

.im-fake-link-composer-body {
    padding: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.im-fake-link-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 12px;
}

.im-fake-link-field span {
    color: #636366;
    font-size: 12px;
    font-weight: 800;
}

.im-fake-link-field input,
.im-fake-link-field textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #e5e5ea;
    border-radius: 16px;
    background: #f7f7fa;
    padding: 10px 12px;
    color: #111;
    font: inherit;
    font-size: 14px;
    line-height: 1.45;
    outline: none;
    resize: vertical;
    user-select: text;
}

.im-fake-link-field input:focus,
.im-fake-link-field textarea:focus {
    border-color: #0a84ff;
    background: #fff;
}

.im-fake-link-generation-row {
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 18px;
    background: #f7f7fa;
    border: 1px solid #e5e5ea;
}

.im-fake-link-generate-btn {
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 16px;
    background: #111;
    color: #fff;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
}

.im-fake-link-generate-btn:disabled {
    opacity: 0.55;
    cursor: default;
}

.im-fake-link-status {
    min-width: 0;
    color: #8e8e93;
    font-size: 12px;
    line-height: 1.35;
}

.im-fake-link-status[data-status="ready"] { color: #248a3d; }
.im-fake-link-status[data-status="loading"] { color: #0a84ff; }
.im-fake-link-status[data-status="error"] { color: #c9342e; }

.im-fake-link-composer-actions {
    padding: 12px 16px 16px;
    display: flex;
    gap: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.im-fake-link-composer-actions button {
    flex: 1;
    height: 44px;
    border: 0;
    border-radius: 15px;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
}

.im-fake-link-composer-cancel { background: #f2f2f7; color: #636366; }
.im-fake-link-composer-send { background: #111; color: #fff; }
.im-fake-link-composer-send:disabled { opacity: 0.45; cursor: default; }

.chat-fake-link-card {
    width: min(72vw, 270px);
    max-width: 100%;
    border-radius: 16px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    overflow: hidden;
    color: #111;
    cursor: pointer;
    text-align: left;
}

.chat-fake-link-card-cover {
    height: 126px;
    background: linear-gradient(135deg, #111, #4b5563);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
}

.chat-fake-link-card-body { padding: 11px 12px 12px; }
.chat-fake-link-card-platform { color: #0a84ff; font-size: 10px; font-weight: 900; letter-spacing: 0.04em; text-transform: uppercase; }
.chat-fake-link-card-title { margin-top: 4px; font-size: 14px; font-weight: 800; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.chat-fake-link-card-summary { margin-top: 6px; color: #636366; font-size: 11px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.chat-fake-link-card-footer { margin-top: 9px; padding-top: 8px; border-top: 1px solid #f2f2f7; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #8e8e93; font-size: 10px; }
.chat-fake-link-card-footer span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.im-fake-link-detail-overlay {
    z-index: 1220;
    justify-content: center;
    align-items: center;
    padding:
        max(16px, env(safe-area-inset-top, 0px))
        16px
        max(16px, env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
}

.im-fake-link-detail-sheet {
    width: min(100%, 430px);
    height: min(82vh, 720px);
    max-height: calc(100% - 32px);
    background: #fff;
    border-radius: 24px;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: none;
}

.im-fake-link-browser-bar {
    min-height: 56px;
    padding: 10px 14px;
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) 32px;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #f2f2f7;
}

.im-fake-link-browser-close {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: #f2f2f7;
    color: #111;
    cursor: pointer;
}

.im-fake-link-address {
    min-width: 0;
    border-radius: 14px;
    background: #f2f2f7;
    padding: 8px 11px;
    color: #636366;
    font-size: 12px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.im-fake-link-page {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0;
}

.im-fake-link-page-site {
    color: #0a84ff;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.im-fake-link-page-title {
    margin-top: 8px;
    color: #111;
    font-size: 25px;
    font-weight: 900;
    line-height: 1.18;
}

.im-fake-link-page-summary {
    margin-top: 12px;
    color: #636366;
    font-size: 15px;
    line-height: 1.55;
}

.im-fake-link-page-body {
    margin-top: 18px;
    color: #111;
    font-size: 16px;
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-word;
}

.im-fake-link-context-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 0 0 12px;
}

.im-fake-link-context-toggle {
    min-width: 0;
    border-radius: 14px;
    background: #f7f7fa;
    border: 1px solid #e5e5ea;
    padding: 9px 10px;
    display: flex;
    align-items: center;
    gap: 7px;
    color: #3a3a3c;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

.im-fake-link-context-toggle input {
    width: 16px;
    height: 16px;
    accent-color: #111;
    flex: 0 0 auto;
}

.im-fake-link-context-toggle span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.im-fake-link-context-row {
    grid-column: 1 / -1;
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.im-fake-link-context-row .im-fake-link-context-toggle {
    flex: 1;
}

.im-fake-link-context-limit {
    flex: 0 0 auto;
    min-width: 76px;
    border-radius: 14px;
    background: #f7f7fa;
    border: 1px solid #e5e5ea;
    padding: 7px 9px;
    display: flex;
    align-items: center;
    gap: 5px;
    color: #636366;
    font-size: 12px;
    font-weight: 800;
}

.im-fake-link-context-limit input {
    width: 38px;
    min-width: 0;
    border: 0;
    background: transparent;
    color: #111;
    font: inherit;
    font-weight: 900;
    text-align: center;
    outline: none;
}

.im-fake-link-web-mini-preview {
    margin-top: 12px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 18px;
    background: #fff;
    overflow: hidden;
}

.im-fake-link-web-mini-label {
    padding: 9px 12px;
    border-bottom: 1px solid #f2f2f7;
    color: #636366;
    font-size: 11px;
    font-weight: 900;
}

.im-fake-link-web-mini-frame {
    height: 290px;
    overflow: hidden;
    background: #fff;
}

.im-fake-link-preview-iframe,
.im-fake-link-detail-iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: #fff;
}

.im-fake-link-page-legacy {
    padding: 22px 18px 34px;
}

.im-fake-link-page.is-webpage {
    padding: 0;
    background: #fff;
}

.im-fake-link-page.is-webpage .im-fake-link-page-legacy {
    display: none;
}

.im-fake-link-web-host {
    height: 100%;
    min-height: 100%;
}

.im-fake-link-web-root {
    min-height: 100%;
    background: #fff;
    color: #111;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
    overflow-wrap: anywhere;
}

.im-fake-link-web-root button {
    font: inherit;
    cursor: pointer;
}

.im-fake-link-web-root img {
    max-width: 100%;
    height: auto;
}

.im-fake-link-web-root [hidden] {
    display: none !important;
}

.im-fake-link-web-root [data-fake-action] {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.pay-transfer-form-card {
    width: min(100%, 320px);
    background: rgba(255,255,255,0.96);
    border-radius: 24px;
    padding: 18px;
    
    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: #ffffff !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;
    
}

#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;
    
}

#moment-action-sheet .moment-action-sheet-title {
    background: #fff;
    padding: 15px;
    border-radius: 14px;
    margin-bottom: 8px;
    
}

/* 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;
}

#edit-char-persona-sheet .char-settings-sheet {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

#edit-char-persona-sheet .char-settings-content {
    min-height: 0;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
}

#edit-char-persona-sheet .form-group,
#edit-char-persona-sheet .form-item,
#edit-char-persona-sheet .global-textarea {
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
}

#edit-char-persona-sheet .form-item {
    gap: 12px;
}

#edit-char-persona-sheet .form-item label {
    flex: 0 0 auto;
    max-width: 48%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#edit-char-persona-sheet .form-item input,
#edit-char-persona-sheet .global-textarea {
    flex: 1 1 0;
    min-width: 0;
    max-width: 100%;
}

.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;
    
}

.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;
}

/* Single-chat history search */
#chat-settings-search-btn:focus-visible,
#chat-settings-favorites-btn:focus-visible,
.chat-history-search-back:focus-visible,
.chat-history-search-result:focus-visible,
.chat-favorites-back:focus-visible,
.chat-favorite-remove:focus-visible {
    outline: 2px solid #007aff;
    outline-offset: 2px;
}

#chat-history-search-view {
    background: #fff;
}

#chat-history-search-view .chat-history-search-sheet {
    width: 100%;
    height: 100%;
    max-height: 100%;
    padding: 0;
    border-radius: 0;
    background: #fff;
    overflow: hidden;
    box-sizing: border-box;
}

.chat-history-search-header {
    min-height: calc(48px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 14px 0;
    display: grid;
    grid-template-columns: minmax(64px, 1fr) minmax(0, 2fr) minmax(64px, 1fr);
    align-items: center;
    border-bottom: 1px solid rgba(60, 60, 67, 0.12);
    box-sizing: border-box;
    flex: 0 0 auto;
}

.chat-history-search-back {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 0;
    background: transparent;
    color: #007aff;
    padding: 8px 2px;
    font: inherit;
    font-size: 16px;
    cursor: pointer;
}

.chat-history-search-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    color: #111;
    font-size: 17px;
    font-weight: 700;
}

.chat-history-search-header-spacer {
    min-width: 64px;
}

.chat-history-search-input-wrap {
    margin: 12px 16px 8px;
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 13px;
    border-radius: 13px;
    background: #f2f2f7;
    color: #8e8e93;
    box-sizing: border-box;
    flex: 0 0 auto;
}

.chat-history-search-input-wrap input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    padding: 10px 0;
    background: transparent;
    color: #111;
    font: inherit;
    font-size: 16px;
}

.chat-history-search-input-wrap input::-webkit-search-cancel-button {
    cursor: pointer;
}

.chat-history-search-status {
    padding: 5px 18px 9px;
    color: #8e8e93;
    font-size: 13px;
    flex: 0 0 auto;
}

.chat-history-search-status.is-empty {
    padding-top: 26px;
    text-align: center;
}

.chat-history-search-results {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 16px max(18px, env(safe-area-inset-bottom, 18px));
    -webkit-overflow-scrolling: touch;
}

.chat-history-search-result {
    width: 100%;
    display: block;
    border: 0;
    border-bottom: 1px solid rgba(60, 60, 67, 0.12);
    background: #fff;
    padding: 14px 2px;
    color: #111;
    text-align: left;
    font: inherit;
    cursor: pointer;
}

.chat-history-search-result:active {
    background: #f7f7fa;
}

.chat-history-search-result-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.chat-history-search-result-heading strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 15px;
}

.chat-history-search-result-heading span {
    flex: 0 0 auto;
    color: #8e8e93;
    font-size: 12px;
}

.chat-history-search-result-text {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    color: #555;
    font-size: 14px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.chat-history-search-result-text mark {
    border-radius: 3px;
    background: #fff0a8;
    color: inherit;
    padding: 0 1px;
}

.chat-row.chat-search-target {
    animation: chat-search-target-pulse 2.2s ease-out;
}

@keyframes chat-search-target-pulse {
    0%, 24% { background: rgba(255, 214, 10, 0.3); }
    100% { background: transparent; }
}

/* Character-favorited user messages */
#chat-favorites-view {
    background: #fff;
}

#chat-favorites-view .chat-favorites-sheet {
    width: 100%;
    height: 100%;
    max-height: 100%;
    padding: 0;
    border-radius: 0;
    background: #fff;
    overflow: hidden;
    box-sizing: border-box;
}

.chat-favorites-header {
    min-height: calc(48px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 14px 0;
    display: grid;
    grid-template-columns: minmax(64px, 1fr) minmax(0, 2fr) minmax(64px, 1fr);
    align-items: center;
    border-bottom: 1px solid rgba(60, 60, 67, 0.12);
    box-sizing: border-box;
    flex: 0 0 auto;
}

.chat-favorites-back {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 0;
    background: transparent;
    color: #007aff;
    padding: 8px 2px;
    font: inherit;
    font-size: 16px;
    cursor: pointer;
}

.chat-favorites-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    color: #111;
    font-size: 17px;
    font-weight: 700;
}

.chat-favorites-header-spacer {
    min-width: 64px;
}

.chat-favorites-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 16px max(22px, env(safe-area-inset-bottom, 22px));
    background: #fff;
    -webkit-overflow-scrolling: touch;
}

.chat-favorites-empty {
    min-height: 58vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #8e8e93;
    font-size: 14px;
}

.chat-favorites-empty i {
    font-size: 30px;
    color: #c7c7cc;
}

.chat-favorite-card {
    position: relative;
    padding: 18px 38px 18px 0;
    margin: 0;
    border: 0;
    border-bottom: 1px solid rgba(60, 60, 67, 0.12);
    border-radius: 0;
    background: #fff;
    color: #111;
}

.chat-favorite-card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.chat-favorite-card-header strong {
    font-size: 12px;
    font-weight: 500;
    color: #8e8e93;
}

.chat-favorite-card-header span {
    flex: 0 0 auto;
    color: #8e8e93;
    font-size: 11px;
}

.chat-favorite-message {
    margin: 0;
    padding: 0;
    border: 0;
    color: #1c1c1e;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.chat-favorite-reason {
    margin-top: 10px;
    padding: 0;
    border: 0;
}

.chat-favorite-reason span {
    display: block;
    margin-bottom: 5px;
    color: #8e8e93;
    font-size: 11px;
    font-weight: 700;
}

.chat-favorite-reason p {
    margin: 0;
    color: #6d6d72;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.chat-favorite-remove {
    position: absolute;
    top: 14px;
    right: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0 0 2px;
    border: 0;
    border-radius: 50%;
    background: #f2f2f7;
    color: #8e8e93;
    font: inherit;
    font-size: 22px;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
}

.chat-favorite-remove:disabled {
    opacity: 0.45;
}

.favorite-saved-narration-pill {
    cursor: default;
}

@media (max-width: 360px) {
    .chat-history-search-header,
    .chat-favorites-header {
        grid-template-columns: 58px minmax(0, 1fr) 58px;
        padding-left: 10px;
        padding-right: 10px;
    }

    .chat-history-search-back span,
    .chat-favorites-back span {
        display: none;
    }
}


/* 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;
    
    cursor: pointer;
    transition: all 0.2s ease;
}

#chat-settings-sheet .char-memory-card.active {
    background: #1c1c1e;
    color: #fff;
    
}

#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;
    
}

#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;
    
}

.chat-memory-cherished-card {
    width: 100%;
    border: none;
    border-radius: 22px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfbfd 100%);
    border: 1px solid #ececf2;
    
    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;
    
}

.chat-memory-cherished-card:active {
    transform: scale(0.985);
    
    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(0, 0, 0, 0.4);
    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);
    
    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: 1100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(0, 0, 0, 0.4);
    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);
    
    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;
    
    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;
    
}

.chat-memory-modal-cherished-card:active {
    transform: scale(0.985);
    
    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;
}

.chat-memory-group-context-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 62px;
    padding: 10px 14px 10px 16px;
    border-bottom: 1px solid var(--separator-color);
}

.chat-memory-group-context-item:last-child {
    border-bottom: none;
}

.chat-memory-group-context-icon {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border-radius: 8px;
    background: #e8f8ee;
    color: #248a45;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.chat-memory-group-context-main {
    min-width: 0;
    flex: 1;
}

.chat-memory-group-context-name {
    overflow: hidden;
    color: #111;
    font-size: 14px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-memory-group-context-meta {
    margin-top: 3px;
    color: #8e8e93;
    font-size: 11px;
}

.chat-memory-group-context-limit-input {
    width: 44px;
    padding: 4px 2px;
    border: 1px solid #e5e5ea;
    border-radius: 6px;
    background: #fff;
    color: #111;
    font-size: 13px;
    text-align: center;
}

.chat-memory-group-context-remove,
.chat-memory-group-picker-check {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.chat-memory-group-context-remove {
    background: #fff0f0;
    color: #ff3b30;
    font-size: 12px;
}

.chat-memory-group-picker-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-memory-group-picker-select {
    width: 100%;
    min-height: 42px;
    padding: 0 10px;
    border: 1px solid #d1d1d6;
    border-radius: 8px;
    background: #fff;
    color: #111;
    font-size: 14px;
}

.chat-memory-group-picker-select:disabled {
    color: #8e8e93;
    background: #f2f2f7;
}

.chat-memory-group-picker-item {
    width: 100%;
    min-height: 58px;
    padding: 10px 12px;
    border: 1px solid #e5e5ea;
    border-radius: 8px;
    background: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #111;
    text-align: left;
    cursor: pointer;
}

.chat-memory-group-picker-item.is-selected {
    border-color: #007aff;
    background: #f4f9ff;
}

.chat-memory-group-picker-check {
    margin-left: auto;
    border: 1px solid #c7c7cc;
    background: #fff;
    color: #fff;
    font-size: 11px;
}

.chat-memory-group-picker-item.is-selected .chat-memory-group-picker-check {
    border-color: #007aff;
    background: #007aff;
}

.chat-memory-group-picker-save {
    width: 100%;
    min-height: 42px;
    border: none;
    border-radius: 8px;
    background: #007aff;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

@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;
    
    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;
    
}

#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;
}

/* 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;
    
}

.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 .relationship-sheet-card {
    height: min(88%, 780px);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    background: #f2f2f7;
}

#relationship-sheet .sheet-handle {
    margin-top: 10px;
}

.relationship-sheet-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 2px 20px 16px;
    flex-shrink: 0;
}

.relationship-sheet-heading .sheet-title {
    padding: 0;
    text-align: left;
}

.relationship-sheet-subtitle {
    margin-top: 4px;
    color: #8e8e93;
    font-size: 12px;
    line-height: 1.4;
}

.relationship-total-badge {
    min-width: 48px;
    padding: 6px 10px;
    border-radius: 999px;
    background: #e7f1ff;
    color: #0a84ff;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
}

.relationship-sheet-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 0 16px 18px;
    overscroll-behavior: contain;
}

.relationship-panel,
.relationship-list-section,
.relationship-picker-panel {
    flex-shrink: 0;
    border-radius: 20px;
    background: #ffffff;
}

.relationship-panel,
.relationship-picker-panel {
    padding: 14px;
}

.relationship-list-section {
    padding: 14px 0 4px;
}

.relationship-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 2px 12px;
}

.relationship-list-heading {
    justify-content: flex-start;
    padding: 0 14px 12px;
}

.relationship-section-heading > i {
    color: #b7b7bd;
    font-size: 17px;
}

.relationship-section-title {
    color: #1c1c1e;
    font-size: 14px;
    font-weight: 700;
}

.relationship-section-hint {
    margin-top: 3px;
    color: #8e8e93;
    font-size: 11px;
    line-height: 1.35;
}

.relationship-selected-count {
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: #f2f2f7;
    color: #636366;
    font-size: 11px;
    font-weight: 700;
    line-height: 22px;
    text-align: center;
}

#relationship-preview-area {
    position: relative;
    width: 100%;
    height: 248px;
    overflow: hidden;
    border: 1px solid #e5e5ea;
    border-radius: 16px;
    background:
        radial-gradient(circle at center, rgba(10, 132, 255, 0.075) 0, rgba(10, 132, 255, 0.025) 33%, transparent 64%),
        linear-gradient(#f7f7fa 1px, transparent 1px),
        linear-gradient(90deg, #f7f7fa 1px, transparent 1px),
        #fcfcfe;
    background-size: auto, 24px 24px, 24px 24px, auto;
    touch-action: none;
}

#relationship-canvas,
#relationship-nodes-container {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

#relationship-canvas {
    pointer-events: none;
}

#relationship-nodes-container {
    pointer-events: none;
}

#relationship-list,
#relationship-picker-list {
    display: flex;
    flex-direction: column;
}

#relationship-list {
    gap: 0;
    margin: 0 !important;
    padding: 0 14px 8px !important;
}

.relationship-item {
    min-height: 68px;
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) minmax(118px, 0.72fr) 32px;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border: 0;
    border-top: 1px solid #efeff4;
    border-radius: 0;
    background: transparent;
}

.relationship-item:first-child {
    border-top: 0;
}

.relationship-avatar {
    width: 46px;
    height: 46px;
    background: #f2f2f7;
}

.relationship-avatar i {
    color: #8e8e93;
    font-size: 18px;
}

.relationship-meta {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.relationship-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.relationship-name {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    color: #1c1c1e;
    font-size: 14px;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.relationship-type-badge {
    flex-shrink: 0;
    padding: 2px 6px;
    border-radius: 6px;
    background: #e7f1ff;
    color: #0a84ff;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .02em;
}

.relationship-type-badge.is-npc {
    background: #edf8f0;
    color: #248a3d;
}

.relationship-desc {
    margin-top: 4px;
    color: #8e8e93;
    font-size: 11px;
}

.relationship-input {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    border: 1px solid transparent;
    border-radius: 10px;
    outline: none;
    background: #f2f2f7;
    padding: 9px 10px;
    color: #1c1c1e;
    font-size: 12px;
    text-align: left;
    transition: border-color .18s ease, background-color .18s ease;
}

.relationship-input:focus {
    border-color: rgba(10, 132, 255, 0.42);
    background: #ffffff;
}

.relationship-delete-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: #f2f2f7;
    color: #8e8e93;
    cursor: pointer;
    padding: 0 !important;
    font-size: 12px;
}

.relationship-delete-btn:active {
    background: #ffe9e8;
    color: #ff3b30;
}

.relationship-empty-state {
    display: none;
    padding: 22px 24px 28px;
    color: #8e8e93;
    text-align: center;
}

.relationship-empty-icon {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
    border-radius: 14px;
    background: #f2f2f7;
    color: #8e8e93;
    font-size: 17px;
}

.relationship-empty-title {
    color: #3a3a3c;
    font-size: 13px;
    font-weight: 700;
}

.relationship-empty-copy {
    max-width: 260px;
    margin: 5px auto 0;
    font-size: 11px;
    line-height: 1.55;
}

#relationship-picker {
    display: none;
    margin: 0 !important;
}

.relationship-picker-filters {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin-bottom: 8px;
    padding: 3px;
    border-radius: 10px;
    background: #f2f2f7;
}

.relationship-filter-btn {
    min-height: 30px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #636366;
    font-size: 11px;
    font-weight: 650;
}

.relationship-filter-btn.active {
    background: #ffffff;
    color: #1c1c1e;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

#relationship-picker-list {
    gap: 0;
    max-height: 250px;
    overflow-y: auto;
}

.relationship-picker-item {
    grid-template-columns: 46px minmax(0, 1fr) 32px;
    cursor: pointer;
}

.relationship-picker-item:active {
    opacity: .65;
}

.relationship-picker-add {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #e7f1ff;
    color: #0a84ff;
    font-size: 11px;
}

.relationship-picker-empty {
    padding: 22px 12px 16px;
    color: #8e8e93;
    font-size: 12px;
    text-align: center;
}

.relationship-sheet-actions {
    display: grid;
    grid-template-columns: 1fr 1.25fr;
    gap: 10px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(60, 60, 67, 0.1);
    background: rgba(248, 248, 250, 0.96);
    flex-shrink: 0;
}

.relationship-add-person-btn,
.relationship-save-btn {
    min-height: 46px;
    margin: 0 !important;
    border: 0;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 700;
}

.relationship-add-person-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    background: #e7f1ff;
    color: #0a84ff;
}

.relationship-save-btn {
    background: #1c1c1e !important;
    color: #ffffff !important;
}

.relationship-node {
    pointer-events: auto;
}

.relationship-node img,
.relationship-node i {
    border: 2px solid #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.11);
}

.relationship-node.char-node img,
.relationship-node.char-node i {
    outline: 2px solid rgba(10, 132, 255, 0.24);
}

.relationship-node.npc-node img,
.relationship-node.npc-node i {
    outline: 2px solid rgba(52, 199, 89, 0.24);
}

.relationship-node.main-node img,
.relationship-node.main-node i {
    border-color: #ffffff;
    outline: 3px solid rgba(10, 132, 255, 0.72);
}

.node-label {
    max-width: 92px;
    overflow: hidden;
    padding: 3px 8px;
    border: 1px solid rgba(229, 229, 234, 0.92);
    background: rgba(255, 255, 255, 0.94);
    text-overflow: ellipsis;
}

@media (max-width: 420px) {
    #relationship-sheet .relationship-sheet-card {
        height: 90%;
    }

    .relationship-sheet-heading {
        padding-inline: 16px;
    }

    .relationship-sheet-content {
        padding-inline: 12px;
    }

    #relationship-preview-area {
        height: 220px;
    }

    .relationship-item {
        grid-template-columns: 44px minmax(0, 1fr) 30px;
        gap: 9px;
    }

    .relationship-avatar {
        width: 44px;
        height: 44px;
    }

    .relationship-input {
        grid-column: 2 / 4;
        grid-row: 2;
        width: 100%;
        margin: -3px 0 2px;
    }

    #relationship-list .relationship-delete-btn {
        grid-column: 3;
        grid-row: 1;
    }

    .relationship-picker-item {
        grid-template-columns: 44px minmax(0, 1fr) 30px;
    }

    .relationship-picker-item .relationship-input {
        display: none;
    }
}

/* Stickers View */
.app-view.stickers-view,
.stickers-view {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    background: #f7f7fa;
    overflow: hidden;
    padding-top: 0 !important;
}

.stickers-page-header {
    min-height: calc(58px + env(safe-area-inset-top, 0px));
    padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: 40px 1fr 40px;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid #e5e5ea;
    flex-shrink: 0;
}

.stickers-header-btn {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 14px;
    background: #f2f2f7;
    color: #111;
    font-size: 17px;
    cursor: pointer;
}

.stickers-header-add { background: #111; color: #fff; }

.stickers-page-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stickers-page-title strong { color: #111; font-size: 18px; }
.stickers-page-title span { color: #8e8e93; font-size: 11px; }

.stickers-page-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 16px calc(24px + env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
}

.stickers-group-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.sticker-group-card {
    min-width: 0;
    border: 1px solid #ececf1;
    border-radius: 20px;
    padding: 10px;
    background: #fff;
    color: #111;
    text-align: left;
    cursor: pointer;
}

.sticker-group-preview {
    aspect-ratio: 1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
    padding: 5px;
    border-radius: 15px;
    background: #f2f2f7;
    overflow: hidden;
}

.sticker-group-preview-cell {
    min-width: 0;
    min-height: 0;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
}

.sticker-group-preview-cell.empty { background: #e5e5ea; }
.sticker-group-preview-cell img { width: 100%; height: 100%; display: block; object-fit: cover; }

.sticker-group-copy {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 10px 3px 2px;
    min-width: 0;
}

.sticker-group-copy strong {
    overflow: hidden;
    color: #111;
    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sticker-group-copy span { color: #8e8e93; font-size: 11px; }

.stickers-empty-state {
    grid-column: 1 / -1;
    min-height: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #8e8e93;
    text-align: center;
}

.stickers-empty-state i { font-size: 42px; }
.stickers-empty-state strong { color: #111; font-size: 17px; }
.stickers-empty-state span { font-size: 13px; }

.sticker-category-detail-sheet {
    height: min(82%, 720px);
    max-height: 82%;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.sticker-detail-header {
    padding: 0 16px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid #f2f2f7;
}

.sticker-detail-header h2 { margin: 0; color: #111; font-size: 18px; }
.sticker-detail-header span { display: block; margin-top: 3px; color: #8e8e93; font-size: 11px; }

.sticker-detail-actions { display: flex; gap: 7px; }
.sticker-detail-actions button {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 13px;
    background: #f2f2f7;
    color: #111;
    cursor: pointer;
}
.sticker-detail-actions button.danger { color: #ff3b30; }

.sticker-detail-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 16px calc(20px + env(safe-area-inset-bottom, 0px));
}

.sticker-detail-batch-bar {
    padding: 9px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: #f7f7fa;
    border-bottom: 1px solid #e5e5ea;
    color: #636366;
    font-size: 13px;
}

.sticker-detail-batch-bar[hidden] { display: none; }
.sticker-detail-batch-bar button {
    border: 0;
    border-radius: 12px;
    padding: 8px 12px;
    background: #ff3b30;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.sticker-category-card {
    background: #fff;
    border: 1px solid #f2f2f7;
    border-radius: 14px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    
}

.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, minmax(0, 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-detail-item {
    position: relative;
    width: 100%;
    padding: 0;
    border: 0;
    cursor: pointer;
}

.sticker-detail-item.selected { outline: 3px solid #007aff; }
.sticker-detail-item .sticker-select-checkbox {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 22px;
    height: 22px;
    border: 2px solid #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    font-size: 11px;
}

.sticker-detail-item.selected .sticker-select-checkbox { background: #007aff; }

.sticker-manifest-upload-row {
    margin-bottom: 10px;
    padding: 11px 12px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f2f2f7;
}

.sticker-manifest-upload-row > div { min-width: 0; flex: 1; }
.sticker-manifest-upload-row strong { display: block; color: #111; font-size: 14px; }
.sticker-manifest-upload-row span { display: block; margin-top: 3px; color: #8e8e93; font-size: 10px; }
.sticker-manifest-upload-row button {
    border: 0;
    border-radius: 11px;
    padding: 8px 10px;
    background: #111;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
}

.sticker-local-preview {
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
    gap: 12px;
    padding: 12px 14px;
    border-top: 1px solid var(--separator-color);
    max-height: 208px;
    overflow-y: auto;
    overflow-x: hidden;
    align-items: start;
}

.sticker-local-preview.has-items {
    display: grid;
}

.sticker-preview-item {
    min-width: 0;
    width: 100%;
    display: grid;
    grid-template-rows: 64px 28px;
    gap: 7px;
    align-items: center;
    justify-items: center;
}

.sticker-preview-img {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    object-fit: cover;
    background: #e5e5ea;
    flex-shrink: 0;
    display: block;
}

.sticker-name-input {
    width: 100%;
    min-width: 0;
    height: 28px;
    border: 1px solid #e5e5ea;
    border-radius: 7px;
    padding: 3px 6px;
    background: #fff;
    color: #111;
    font-size: 11px;
    line-height: 1.2;
    text-align: center;
    outline: none;
}

.sticker-name-input:focus {
    border-color: #c7c7cc;
}


/* 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;
    
    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;
    
}
.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%;
}

.bind-account-detail-bottom-sheet {
    height: auto;
    max-height: 82%;
    display: flex;
    flex-direction: column;
    background: #f2f2f7;
}

.bind-account-detail-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 16px;
    box-sizing: border-box;
}

.bind-account-select-row {
    min-height: 48px;
    margin: 6px 0 14px;
    padding: 0 14px;
    border-radius: 14px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-sizing: border-box;
}

.bind-account-select-row span {
    color: #111111;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
}

.bind-account-select-row select {
    min-width: 0;
    max-width: 58%;
    border: none;
    outline: none;
    background: transparent;
    color: #007aff;
    font-size: 15px;
    text-align: right;
}

.bind-account-detail-empty {
    padding: 32px 18px;
    border-radius: 16px;
    background: #ffffff;
    color: #8e8e93;
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
}

.bind-account-detail-form {
    min-width: 0;
}

.bind-account-detail-avatar-section {
    display: flex;
    justify-content: center;
    margin: 10px 0 16px;
}

.bind-account-detail-avatar-btn {
    width: 92px;
    height: 92px;
    border: none;
    border-radius: 50%;
    background: #ffffff;
    color: #8e8e93;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: visible;
    cursor: pointer;
    padding: 0;
    font-size: 34px;
}

.bind-account-detail-avatar-btn img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.bind-account-detail-avatar-plus {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #111111;
    color: #ffffff;
    border: 2px solid #f2f2f7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.bind-account-detail-fields {
    margin: 0 0 14px;
    overflow: hidden;
}

.bind-account-detail-fields .form-item input {
    min-width: 0;
    text-align: right;
}

.bind-account-detail-persona {
    width: 100%;
    min-height: 132px;
    max-height: 220px;
    resize: vertical;
    box-sizing: border-box;
    margin: 12px 0 0;
}

.bind-account-detail-actions {
    flex-shrink: 0;
    padding: 0 16px max(20px, env(safe-area-inset-bottom));
    box-sizing: border-box;
}

.bind-account-detail-save {
    width: 100%;
    border: none;
    justify-content: center;
    background: #1c1c1e;
    color: #ffffff;
    margin: 0;
}

@media (max-width: 390px) {
    .bind-account-select-row {
        padding: 0 12px;
        gap: 8px;
    }

    .bind-account-select-row select {
        max-width: 52%;
        font-size: 14px;
    }

    .bind-account-detail-content {
        padding-left: 12px;
        padding-right: 12px;
    }
}
.offline-settings-tabs {
    position: sticky;
    top: 0;
    z-index: 4;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin: 8px 0 10px;
    padding: 4px;
    border-radius: 12px;
    background: #e9e9ed;
}

.offline-settings-tabs button {
    appearance: none;
    border: 0;
    border-radius: 9px;
    padding: 9px 12px;
    background: transparent;
    color: #666;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.offline-settings-tabs button.active {
    background: #fff;
    color: #007aff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.offline-settings-panel[hidden] {
    display: none !important;
}

.offline-settings-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 20px;
}

.offline-regex-intro,
.offline-regex-empty {
    padding: 12px 14px;
    border-radius: 12px;
    background: #eef6ff;
    color: #31506f;
    font-size: 12px;
    line-height: 1.55;
}

.offline-regex-empty {
    background: #f2f2f7;
    color: #8e8e93;
    text-align: center;
}

/* Offline studio fullscreen settings */
.app-view.offline-settings-view {
    display: none;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    padding-top: 0;
    background: #f2f2f2;
    color: #111;
}

.offline-settings-view.active {
    display: flex;
}

.offline-settings-header {
    min-height: 58px;
    padding: env(safe-area-inset-top, 0px) 16px 0;
    box-sizing: content-box;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    align-items: center;
    flex-shrink: 0;
    background: #fff;
    border-bottom: 1px solid #dedede;
}

.offline-settings-back {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #111;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 17px;
}

.offline-settings-heading {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.offline-settings-heading strong {
    font-size: 17px;
    line-height: 1.2;
    font-weight: 750;
    letter-spacing: 0;
}

.offline-settings-heading span,
.offline-settings-section-kicker span,
.offline-settings-worldbook-main small {
    font-size: 9px;
    line-height: 1.2;
    font-weight: 700;
    color: #8e8e93;
    letter-spacing: 0;
}

.offline-settings-tabs-wrap {
    flex-shrink: 0;
    padding: 12px 16px 10px;
    background: #fff;
    border-bottom: 1px solid #dedede;
}

.offline-settings-tabs {
    position: static;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: min(100%, 720px);
    margin: 0 auto;
    padding: 3px;
    gap: 3px;
    border: 1px solid #d6d6d6;
    border-radius: 8px;
    background: #ededed;
}

.offline-settings-tabs button {
    min-height: 42px;
    padding: 5px 12px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: #636366;
    font-size: 14px;
}

.offline-settings-tabs button small {
    font-size: 9px;
    font-weight: 700;
    color: #8e8e93;
    letter-spacing: 0;
}

.offline-settings-tabs button.active {
    background: #111;
    color: #fff;
    box-shadow: none;
}

.offline-settings-tabs button.active small {
    color: #b8b8b8;
}

.offline-settings-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 20px 16px calc(28px + env(safe-area-inset-bottom, 0px));
}

.offline-settings-content-inner {
    width: min(100%, 720px);
    margin: 0 auto;
}

.offline-settings-list {
    gap: 12px;
    padding-bottom: 0;
}

.offline-settings-worldbook,
.offline-settings-streaming,
.offline-settings-prompts,
.offline-settings-variable-hint,
.offline-regex-card,
.offline-regex-intro,
.offline-regex-empty {
    border: 1px solid #dcdcdc;
    border-radius: 8px;
    background: #fff;
    box-shadow: none;
}

.offline-settings-worldbook {
    min-height: 64px;
    padding: 12px 14px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    cursor: pointer;
}

.offline-settings-streaming {
    min-height: 64px;
    padding: 12px 14px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.offline-settings-number-input {
    width: 112px;
    min-width: 0;
    box-sizing: border-box;
    border: 1px solid #d1d1d6;
    border-radius: 8px;
    background: #f7f7f8;
    color: #111;
    padding: 8px 10px;
    font: inherit;
    font-size: 14px;
    text-align: right;
}

.offline-settings-number-input:focus {
    outline: 2px solid rgba(0, 122, 255, 0.22);
    border-color: #007aff;
}

.offline-settings-worldbook-main,
.offline-settings-worldbook-meta {
    display: flex;
    align-items: center;
}

.offline-settings-worldbook-main {
    min-width: 0;
    gap: 11px;
}

.offline-settings-worldbook-main > i {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #111;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.offline-settings-worldbook-main > span {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.offline-settings-worldbook-main strong {
    font-size: 15px;
    font-weight: 700;
}

.offline-settings-worldbook-meta {
    gap: 7px;
    color: #8e8e93;
    font-size: 13px;
    white-space: nowrap;
}

.offline-settings-variable-hint {
    padding: 13px 14px;
    color: #48484a;
    font-size: 12px;
    line-height: 1.65;
}

.offline-settings-section-kicker {
    margin-bottom: 5px;
    display: flex;
    align-items: baseline;
    gap: 7px;
}

.offline-settings-section-kicker strong {
    color: #111;
    font-size: 13px;
}

.offline-settings-variable-hint code {
    color: #111;
    background: #ededed;
    border-radius: 4px;
    padding: 1px 4px;
}

.offline-settings-prompts {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.offline-settings-prompt-item {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-bottom: 1px solid #e5e5e5;
}

.offline-settings-prompt-item:last-child {
    border-bottom: 0;
}

.offline-settings-prompt-row,
.offline-settings-move-actions,
.offline-settings-prompt-actions {
    display: flex;
    align-items: center;
}

.offline-settings-prompt-row {
    min-width: 0;
    gap: 8px;
    flex-wrap: nowrap;
    cursor: pointer;
}

.offline-settings-move-actions {
    gap: 3px;
    flex-shrink: 0;
}

.offline-settings-prompt-actions {
    gap: 6px;
    flex-shrink: 0;
}

.offline-settings-icon-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid #d8d8d8;
    border-radius: 7px;
    background: #f2f2f2;
    color: #111;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    font-size: 12px;
}

.offline-settings-icon-btn:disabled {
    color: #c7c7cc;
    background: #fafafa;
    cursor: default;
}

.offline-settings-icon-btn.danger {
    color: #b42318;
    background: #fff;
    border-color: #e2c5c2;
}

.offline-settings-prompt-name {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.offline-settings-name-input,
.offline-settings-name-label {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    border: 0;
    outline: 0;
    background: transparent;
    color: #111;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    padding: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.offline-settings-state-label {
    color: #8e8e93;
    font-size: 11px;
    font-weight: 650;
}

.offline-settings-expand-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border-color: transparent;
    background: #f2f2f7;
    color: #6f6f76;
}

.offline-settings-expand-btn i {
    font-size: 12px;
    transition: transform 0.2s ease;
}

.offline-settings-expand-btn[aria-expanded="true"] i {
    transform: rotate(180deg);
}

.offline-settings-prompt-content {
    display: none;
    margin-left: 66px;
}

.offline-settings-prompt-textarea,
.offline-settings-prompt-preview {
    width: 100%;
    min-height: 132px;
    box-sizing: border-box;
    border: 1px solid #d8d8d8;
    border-radius: 8px;
    outline: 0;
    background: #f7f7f7;
    padding: 11px 12px;
    color: #333;
    font: inherit;
    font-size: 13px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

.offline-settings-prompt-textarea {
    resize: vertical;
    user-select: text;
}

.offline-settings-add-btn,
.offline-regex-add {
    width: 100%;
    height: 44px;
    margin-top: 0;
    border: 0;
    border-radius: 8px;
    background: #111;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

/* Transient, user-only memory recall narration. It is not a persisted chat message. */
.memory-recall-narration {
    justify-content: center;
    padding: 8px 0 4px;
}

.memory-recall-narration-pill {
    border-radius: 999px;
    padding: 4px 9px;
    background: rgba(120, 120, 128, 0.12);
    color: #6d6d72;
    font-size: 11px;
    font-weight: normal;
    line-height: 1.2;
    cursor: pointer;
}

.memory-recall-narration-pill:active {
    transform: scale(0.97);
    background: rgba(120, 120, 128, 0.2);
}

.im-memory-recall-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.42);
}

.im-memory-recall-modal {
    width: min(100%, 390px);
    max-height: min(78vh, 620px);
    overflow: auto;
    box-sizing: border-box;
    border-radius: 22px;
    background: #fff;
    padding: 20px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.25);
}

.im-memory-recall-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.im-memory-recall-modal-title {
    font-size: 18px;
    font-weight: 700;
    color: #111;
}

.im-memory-recall-modal-close {
    border: 0;
    border-radius: 10px;
    padding: 7px 10px;
    background: #f2f2f7;
    color: #3a3a3c;
    font-size: 13px;
    cursor: pointer;
}

.im-memory-recall-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 9px;
    color: #303038;
    font-size: 13px;
}

.im-memory-recall-tag {
    border-radius: 999px;
    padding: 3px 8px;
    background: #e8f2ff;
    color: #007aff;
    font-size: 12px;
    font-weight: 600;
}

.offline-settings-view .offline-regex-card {
    border: 1px solid #dcdcdc;
    border-radius: 8px;
    background: #fff;
    box-shadow: none;
}

.offline-settings-view .offline-regex-order-actions button {
    border: 1px solid #d8d8d8;
    border-radius: 6px;
    background: #f2f2f2;
    color: #111;
}

.offline-settings-view .offline-regex-order-actions button.danger {
    color: #b42318;
    background: #fff;
    border-color: #e2c5c2;
}

.offline-settings-view .offline-regex-field input,
.offline-settings-view .offline-regex-field textarea {
    border-radius: 6px;
    border-color: #d8d8d8;
    background: #f7f7f7;
}

.offline-settings-view .offline-regex-field input:focus,
.offline-settings-view .offline-regex-field textarea:focus {
    border-color: #48484a;
    background: #fff;
}

.offline-settings-view .offline-regex-add {
    height: 44px;
    padding: 0 14px;
    border: 0;
    border-radius: 8px;
    background: #111;
    color: #fff;
}

.offline-settings-view .toggle-switch input:checked + .slider {
    background-color: #111;
}

.offline-theme-card {
    overflow: hidden;
    border: 1px solid #dcdcdc;
    border-radius: 8px;
    background: #fff;
}

.offline-theme-heading {
    padding: 16px;
    border-bottom: 1px solid #e5e5e5;
}

.offline-theme-heading > div {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.offline-theme-heading strong {
    color: #111;
    font-size: 15px;
    font-weight: 750;
}

.offline-theme-heading span {
    color: #8e8e93;
    font-size: 9px;
    font-weight: 700;
}

.offline-theme-heading p {
    margin: 5px 0 0;
    color: #636366;
    font-size: 12px;
    line-height: 1.45;
}

.offline-theme-color-row {
    min-height: 70px;
    padding: 12px 16px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid #e5e5e5;
}

.offline-theme-color-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.offline-theme-color-copy strong {
    color: #111;
    font-size: 15px;
    font-weight: 700;
}

.offline-theme-color-copy small {
    color: #8e8e93;
    font-size: 11px;
}

.offline-theme-color-controls {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
}

.offline-theme-color-swatch {
    width: 22px;
    height: 22px;
    border: 1px solid #cfcfcf;
    border-radius: 5px;
    box-sizing: border-box;
}

.offline-theme-color-picker {
    width: 32px;
    height: 32px;
    padding: 2px;
    border: 1px solid #d8d8d8;
    border-radius: 6px;
    background: #f7f7f7;
    cursor: pointer;
}

.offline-theme-color-picker::-webkit-color-swatch-wrapper {
    padding: 1px;
}

.offline-theme-color-picker::-webkit-color-swatch {
    border: 0;
    border-radius: 3px;
}

.offline-theme-color-value {
    width: 82px;
    height: 34px;
    padding: 0 9px;
    box-sizing: border-box;
    border: 1px solid #d8d8d8;
    border-radius: 6px;
    outline: none;
    background: #f7f7f7;
    color: #111;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    text-transform: uppercase;
}

.offline-theme-color-value:focus {
    border-color: #48484a;
    background: #fff;
}

.offline-theme-preset-controls {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.offline-theme-preset-select {
    min-width: 0;
    height: 42px;
    flex: 1;
    padding: 0 12px;
    border: 1px solid #d8d8d8;
    border-radius: 8px;
    outline: none;
    background: #f7f7f7;
    color: #111;
    font: inherit;
    font-size: 14px;
}

.offline-theme-preset-select:focus {
    border-color: #48484a;
    background: #fff;
}

.offline-theme-preset-delete {
    height: 42px;
    padding: 0 14px;
    border: 0;
    border-radius: 8px;
    background: #fff1f0;
    color: #ff3b30;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.offline-theme-preset-icon {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #f2f2f7;
    color: #111;
    font-size: 14px;
    cursor: pointer;
}

.offline-theme-preset-icon:active {
    transform: scale(0.96);
}

.offline-theme-preset-delete:disabled {
    background: #f7f7f7;
    color: #c7c7cc;
    cursor: default;
}

.offline-theme-css-input {
    width: calc(100% - 32px);
    min-height: 250px;
    margin: 16px;
    padding: 13px 14px;
    box-sizing: border-box;
    resize: vertical;
    border: 1px solid #d8d8d8;
    border-radius: 8px;
    outline: none;
    background: #f7f7f7;
    color: #1c1c1e;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.55;
    tab-size: 2;
}

.offline-theme-css-input:focus {
    border-color: #48484a;
    background: #fff;
}

.offline-theme-button-row {
    padding: 0 16px 14px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.offline-theme-button-row button,
.offline-theme-save-row button {
    min-height: 40px;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: #f2f2f7;
    color: #111;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.offline-theme-button-row button.danger {
    background: #fff1f0;
    color: #ff3b30;
}

.offline-theme-button-row button.primary,
.offline-theme-save-row button {
    background: #111;
    color: #fff;
}

.offline-theme-button-row button.primary {
    grid-column: 1 / -1;
}

.offline-theme-save-row {
    padding: 14px 16px 16px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    border-top: 1px solid #e5e5e5;
}

.offline-theme-save-row input {
    min-width: 0;
    height: 42px;
    padding: 0 12px;
    box-sizing: border-box;
    border: 1px solid #d8d8d8;
    border-radius: 8px;
    outline: none;
    background: #f7f7f7;
    color: #111;
    font: inherit;
    font-size: 13px;
}

.offline-theme-save-row input:focus {
    border-color: #48484a;
    background: #fff;
}

.offline-theme-reset-btn {
    width: 100%;
    height: 44px;
    padding: 0 16px;
    border: 0;
    background: #fff;
    color: #48484a;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid #dcdcdc;
    border-radius: 8px;
}

.offline-theme-reset-btn:hover,
.offline-theme-reset-btn:focus-visible {
    background: #f2f2f2;
    color: #111;
}

.offline-regex-intro {
    color: #48484a;
}

.offline-regex-summary-state,
.offline-regex-section-label {
    color: #636366;
}

.offline-regex-field input,
.offline-regex-field textarea {
    border-radius: 6px;
    border-color: #d8d8d8;
    background: #f7f7f7;
}

@media (max-width: 520px) {
    .offline-settings-content {
        padding-left: 12px;
        padding-right: 12px;
    }

    .offline-settings-tabs-wrap {
        padding-left: 12px;
        padding-right: 12px;
    }

    .offline-settings-prompt-item {
        padding: 12px;
    }

    .offline-settings-prompt-content {
        margin-left: 0;
    }

    .offline-settings-icon-btn {
        width: 27px;
        height: 28px;
    }

    .offline-settings-prompt-row {
        gap: 6px;
    }

    .offline-settings-prompt-actions {
        gap: 5px;
    }

    .offline-theme-color-row {
        padding-left: 12px;
        padding-right: 12px;
        gap: 8px;
    }

    .offline-theme-color-swatch {
        display: none;
    }

    .offline-theme-color-value {
        width: 76px;
    }

    .offline-theme-save-row {
        grid-template-columns: 1fr;
    }
}

.offline-regex-card {
    overflow: hidden;
    border: 1px solid #e5e5ea;
    border-radius: 14px;
    background: #fff;
}

.offline-regex-card.has-error {
    border-color: #ff9b93;
}

.offline-regex-card.is-disabled .offline-regex-summary-name,
.offline-regex-card.is-disabled .offline-regex-editor {
    opacity: 0.58;
}

.offline-regex-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    cursor: pointer;
    list-style: none;
}

.offline-regex-summary::-webkit-details-marker {
    display: none;
}

.offline-regex-summary::after {
    content: '\f078';
    margin-left: 2px;
    color: #8e8e93;
    font-family: 'Font Awesome 5 Free';
    font-size: 11px;
    font-weight: 900;
    transition: transform 0.18s ease;
}

.offline-regex-card[open] .offline-regex-summary::after {
    transform: rotate(180deg);
}

.offline-regex-summary-name {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    color: #111;
    font-size: 15px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.offline-regex-summary-state {
    color: #8e8e93;
    font-size: 12px;
}

.offline-regex-editor {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0 16px 16px;
    border-top: 1px solid #f1f1f3;
}

.offline-regex-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 12px;
}

.offline-regex-enabled,
.offline-regex-checks label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: #333;
    font-size: 13px;
    cursor: pointer;
}

.offline-regex-order-actions {
    display: flex;
    gap: 6px;
}

.offline-regex-order-actions button {
    width: 32px;
    height: 30px;
    border: 0;
    border-radius: 8px;
    background: #f2f2f7;
    color: #007aff;
    cursor: pointer;
}

.offline-regex-order-actions button.danger {
    color: #ff3b30;
}

.offline-regex-order-actions button:disabled {
    opacity: 0.35;
    cursor: default;
}

.offline-regex-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.offline-regex-field > span,
.offline-regex-section-label {
    color: #666;
    font-size: 12px;
    font-weight: 700;
}

.offline-regex-field input,
.offline-regex-field textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #d1d1d6;
    border-radius: 9px;
    padding: 9px 10px;
    outline: none;
    background: #fafafa;
    color: #111;
    font: inherit;
    font-size: 13px;
    resize: vertical;
}

.offline-regex-field input:focus,
.offline-regex-field textarea:focus {
    border-color: #007aff;
    background: #fff;
}

.offline-regex-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
}

.offline-regex-checks.vertical {
    flex-direction: column;
    gap: 9px;
}

.offline-regex-depths {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.offline-regex-error {
    display: none;
    padding: 8px 10px;
    border-radius: 8px;
    background: #fff0ef;
    color: #d70015;
    font-size: 12px;
    line-height: 1.4;
}

.offline-regex-add {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    border: 1px dashed #8bbcff;
    border-radius: 12px;
    padding: 12px;
    background: #eef6ff;
    color: #007aff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}
