/* --- Moment capture UI --- */

.moment-select-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 62px;
    padding: 14px 18px 10px;
    padding-top: max(14px, env(safe-area-inset-top));
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    z-index: 30;
    flex-shrink: 0;
}

.moment-select-bar.visible {
    display: flex;
}

.moment-select-bar button,
.moment-panel-actions button,
#moment-favorites-refresh-btn,
.moment-favorites-header .action-btn {
    min-height: 36px;
    border: 0;
    border-radius: 10px;
    padding: 8px 14px;
    background: #f4f5f7;
    color: #2a3032;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.moment-select-bar button:disabled,
.moment-panel-actions button:disabled {
    opacity: 0.45;
    cursor: default;
}

.moment-select-bar button:active:not(:disabled),
.moment-panel-actions button:active:not(:disabled),
#moment-favorites-refresh-btn:active,
.moment-favorites-header .action-btn:active {
    background: #e9ecef;
}

#moment-next-btn,
#moment-editor-save-btn {
    background: #2a3032;
    color: #fff;
}

#moment-next-btn:active:not(:disabled),
#moment-editor-save-btn:active:not(:disabled) {
    background: #1a1e1f;
}

.moment-select-title {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: #2a3032;
}

.moment-select-title strong {
    font-size: 15px;
    line-height: 1.2;
}

.moment-select-title span {
    font-size: 12px;
    color: #718096;
}

#chat-room-screen.moment-select-active .message-wrapper[data-id] {
    cursor: pointer;
}

.message-wrapper.multi-select-selected,
.message-wrapper.moment-selected {
    background: rgba(255, 248, 235, 0.72);
    border-radius: 12px;
    box-shadow:
        inset 0 0 0 1.5px rgba(200, 175, 130, 0.45),
        0 4px 16px rgba(180, 155, 110, 0.08);
    backdrop-filter: blur(6px) saturate(1.05);
    -webkit-backdrop-filter: blur(6px) saturate(1.05);
    transition: background 0.18s ease, box-shadow 0.18s ease;
}

.message-wrapper.moment-unselectable {
    opacity: 0.45;
}

.message-wrapper.moment-selected.moment-unselectable {
    opacity: 1;
}

.moment-panel-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10020;
    display: none;
    align-items: flex-end;
    justify-content: center;
    background: rgba(15, 20, 25, 0.35); /* 更柔和的遮罩 */
    padding: 14px;
    box-sizing: border-box;
}

.moment-panel-backdrop.visible {
    display: flex;
}

.moment-editor-panel {
    width: min(100%, 430px);
    max-height: min(82vh, 720px);
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1), 0 2px 10px rgba(0, 0, 0, 0.05);
    padding: 18px;
    color: #2a3032;
    animation: momentPanelUp 0.2s ease-out;
}

@keyframes momentPanelUp {
    from {
        transform: translateY(16px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.moment-panel-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 12px;
}

.moment-editor-preview {
    max-height: 100px;
    overflow-y: auto;
    margin-bottom: 14px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #f7f9fa;
    border: 1px solid #edf2f7;
    color: #4a5568;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.moment-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.moment-field span,
.moment-advanced summary {
    font-size: 13px;
    font-weight: 700;
    color: #4a5568;
}

.moment-field input,
.moment-field textarea,
.moment-field select {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fbfcfd;
    color: #2a3032;
    font-size: 15px;
    line-height: 1.4;
    padding: 10px 12px;
    outline: none;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.moment-field textarea {
    resize: vertical;
    min-height: 96px;
}

.moment-field input:focus,
.moment-field textarea:focus,
.moment-field select:focus {
    background: #ffffff;
    border-color: #a0aec0;
    box-shadow: 0 0 0 3px rgba(206, 228, 241, 0.4);
}

.moment-advanced {
    margin: 4px 0 12px;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f7f9fa;
}

.moment-advanced summary {
    cursor: pointer;
    min-height: 30px;
    display: flex;
    align-items: center;
}

.moment-editor-error {
    min-height: 18px;
    color: #d9534f;
    font-size: 13px;
    margin-bottom: 8px;
}

.moment-panel-actions {
    display: flex;
    gap: 10px;
}

.moment-panel-actions button {
    flex: 1;
    min-height: 42px;
}

.moment-favorites-screen {
    background: #ffffff;
}

.moment-favorites-header .header-left {
    gap: 10px;
}

#moment-favorites-screen .moment-favorites-header {
    min-height: 56px;
    padding-top: max(16px, env(safe-area-inset-top, 16px));
    padding-bottom: 12px;
    padding-left: 16px;
    padding-right: 16px;
    gap: 12px;
}

#moment-favorites-screen .moment-favorites-header .title {
    font-size: 20px !important;
    line-height: 1.2 !important;
    letter-spacing: -0.2px;
    font-weight: 700;
}

.moment-favorites-header .back-btn {
    position: static;
    width: 34px;
    height: 34px;
    border: 0;
    background: #f4f5f7;
    border-radius: 10px;
    font-size: 24px;
    line-height: 1;
    color: #2a3032;
    transition: background-color 0.2s;
}
.moment-favorites-header .back-btn:active {
    background: #e9ecef;
}

.moment-favorites-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

#moment-favorites-screen .moment-favorites-actions {
    gap: 8px;
}

.moment-favorites-mode-btn {
    min-height: 34px;
    border: 0;
    border-radius: 999px;
    padding: 7px 12px;
    background: #edf2f7;
    color: #4a5568;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
}

.moment-favorites-mode-btn:active {
    background: #e2e8f0;
}

#moment-favorites-screen #moment-favorites-refresh-btn {
    width: 40px !important;
    min-width: 40px;
    height: 34px !important;
    min-height: 34px;
    padding: 0 !important;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #edf2f7;
    color: #4a5568;
    font-size: 15px;
}

.moment-favorites-content {
    padding: 12px 16px 90px;
    overflow-y: auto;
    background: #fdfcfa;
}

.moment-favorites-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.moment-favorite-card {
    width: 100%;
    text-align: left;
    border: 1px solid rgba(200, 180, 150, 0.12);
    border-radius: 14px;
    background: #fffdf9;
    padding: 16px;
    color: #2a3032;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(120, 100, 70, 0.04), 0 4px 12px rgba(120, 100, 70, 0.03);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.moment-favorite-card:active {
    transform: scale(0.98);
    background: #fefbf5;
}

.moment-favorite-card.is-deleted {
    background: #f8fafc;
    border-color: #e2e8f0;
    box-shadow: none;
    opacity: 0.92;
}

.moment-favorite-card strong {
    display: block;
    font-size: 16px;
    margin-bottom: 8px;
    color: #2a3032;
}

.moment-favorite-card p {
    margin: 0;
    color: #64748b;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.moment-favorite-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
    color: #94a3b8;
    font-size: 12px;
}

.moment-anchor-chip {
    display: inline-flex;
    max-width: 100%;
    margin-top: 12px;
    padding: 5px 10px;
    border-radius: 999px;
    background: #edf2f7;
    color: #4a5568;
    font-size: 12px;
    font-weight: 500;
    overflow-wrap: anywhere;
}

.moment-favorites-empty {
    padding: 40px 16px;
    text-align: center;
    color: #94a3b8;
    font-size: 14px;
}

.moment-detail-panel {
    display: flex;
    flex-direction: column;
    max-height: min(84vh, 720px);
    padding: 0;
    overflow: hidden;
    background: #fdfcfa;
}

.moment-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    background: rgba(253, 252, 250, 0.98);
    flex-shrink: 0;
}

.moment-detail-heading {
    min-width: 0;
}

.moment-detail-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.moment-detail-heading h2 {
    margin: 0;
    color: #2a3032;
    font-size: 18px;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.moment-detail-submeta {
    margin-top: 6px;
    color: #94a3b8;
    font-size: 12px;
}

.moment-detail-edit-btn {
    min-height: 34px;
    border: 0;
    border-radius: 999px;
    padding: 7px 12px;
    background: #edf2f7;
    color: #4a5568;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
}

.moment-detail-edit-btn:active {
    background: #e2e8f0;
}

.moment-detail-close-btn {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: #f4f5f7;
    color: #2a3032;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.2s;
}
.moment-detail-close-btn:active {
    background: #e9ecef;
}

.moment-detail-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 18px;
}

.moment-detail-footer {
    display: flex;
    gap: 12px;
    padding: 14px 18px 18px;
    border-top: 1px solid rgba(0, 0, 0, 0.04);
    background: rgba(253, 252, 250, 0.98);
    flex-shrink: 0;
}

.moment-detail-footer button {
    min-height: 44px;
    border: 0;
    border-radius: 12px;
    padding: 9px 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s;
}

.moment-detail-footer button:disabled {
    opacity: 0.55;
    cursor: default;
}

.moment-detail-delete-btn {
    flex: 1.1;
    background: #fff5f5;
    color: #d9534f;
}
.moment-detail-delete-btn:active:not(:disabled) {
    background: #ffe3e3;
}

.moment-detail-restore-btn {
    flex: 1;
    background: #2a3032;
    color: #ffffff;
}

.moment-detail-restore-btn:active:not(:disabled) {
    background: #1f2426;
}

.moment-detail-hard-delete-btn {
    flex: 1.1;
    background: #fff5f5;
    color: #c53030;
}

.moment-detail-hard-delete-btn:active:not(:disabled) {
    background: #ffe3e3;
}

.moment-detail-close-secondary-btn {
    flex: 0.9;
    background: #f4f5f7;
    color: #2a3032;
}
.moment-detail-close-secondary-btn:active:not(:disabled) {
    background: #e9ecef;
}

.moment-edit-backdrop {
    z-index: 10030;
}

.moment-edit-hint {
    margin: 0 0 14px;
    padding: 10px 12px;
    border-radius: 12px;
    background: #fdfcfa;
    border: 1px solid rgba(200, 180, 150, 0.12);
    color: #718096;
    font-size: 13px;
    line-height: 1.45;
}

.moment-detail-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 18px;
}

.moment-detail-chip {
    display: inline-flex;
    max-width: 100%;
    padding: 6px 12px;
    border-radius: 999px;
    background: #edf2f7;
    color: #4a5568;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.moment-detail-excerpt h3 {
    margin: 20px 0 12px;
    color: #2a3032;
    font-size: 15px;
}

.moment-detail-excerpt h3:first-child {
    margin-top: 0;
}

.moment-detail-group {
    padding: 14px 0;
    border-top: 1px dashed rgba(0, 0, 0, 0.06);
}

.moment-detail-group:first-of-type {
    border-top: 0;
    padding-top: 4px;
}

.moment-detail-group-sender {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.moment-detail-group-sender strong {
    color: #2a3032;
    font-size: 14px;
}

.moment-detail-group-sender span {
    color: #a0aec0;
    font-size: 11px;
    white-space: nowrap;
}

.moment-detail-group-content {
    color: #4a5568;
    font-size: 14px;
    line-height: 1.65;
    overflow-wrap: anywhere;
}

.moment-part {
    margin: 0 0 10px;
}

.moment-part:last-child {
    margin-bottom: 0;
}

.moment-part-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.moment-part-html {
    overflow: hidden;
    border: 1px solid rgba(200, 180, 150, 0.16);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: 0 1px 4px rgba(120, 100, 70, 0.04);
}

.moment-html-preview {
    max-width: 100%;
    overflow: auto;
    padding: 10px;
    color: #2a3032;
}

.moment-html-preview > :first-child {
    margin-top: 0;
}

.moment-html-preview > :last-child {
    margin-bottom: 0;
}

.moment-html-code-fallback {
    max-height: 220px;
    margin: 0;
    overflow: auto;
    padding: 10px;
    color: #4a5568;
    font-size: 12px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.moment-detail-content h2,
.moment-detail-content h3 {
    margin: 0 0 14px;
    color: #2a3032;
}

.moment-detail-content h2 {
    font-size: 18px;
}

.moment-detail-content h3 {
    margin-top: 18px;
    font-size: 15px;
}

.moment-detail-row {
    margin-bottom: 14px;
}

.moment-detail-row span {
    display: block;
    margin-bottom: 6px;
    color: #718096;
    font-size: 12px;
    font-weight: 700;
}

.moment-detail-row p,
.moment-detail-message p {
    margin: 0;
    color: #2a3032;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.moment-detail-message-body {
    color: #2a3032;
    font-size: 14px;
    line-height: 1.6;
}

/* 预留：折叠的原始消息快照区域 */
.moment-detail-original-messages {
    margin-top: 24px;
    padding: 14px;
    background: #f7f9fa;
    border-radius: 12px;
    border: 1px solid #edf2f7;
}

.moment-detail-original-messages summary {
    font-size: 13px;
    font-weight: 600;
    color: #718096;
    cursor: pointer;
    list-style: none; /* Hide default arrow in some browsers */
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.moment-detail-original-messages summary::-webkit-details-marker {
    display: none;
}

.moment-detail-original-messages summary::after {
    content: '▼';
    font-size: 10px;
    color: #a0aec0;
    transition: transform 0.2s;
}

.moment-detail-original-messages[open] summary::after {
    transform: rotate(180deg);
}

.moment-detail-original-messages-content {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.moment-detail-message {
    padding: 0;
    border-top: none;
}

.moment-detail-message strong {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    color: #4a5568;
    font-size: 13px;
}
.moment-detail-message strong span {
    font-weight: normal;
    font-size: 11px;
    color: #a0aec0;
}

.moment-detail-message strong .sender {
    color: #4a5568;
    font-size: 13px;
    font-weight: 700;
}

.moment-detail-message strong .time {
    color: #a0aec0;
    font-size: 11px;
    font-weight: 500;
}

@media (max-width: 420px) {
    .moment-panel-backdrop {
        padding: 8px;
    }

    .moment-editor-panel {
        border-radius: 18px;
        padding: 16px;
    }

    .moment-detail-panel {
        padding: 0;
    }

    .moment-select-bar {
        padding-left: 12px;
        padding-right: 12px;
    }
}
