.memory-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    max-height: 400px;
    overflow-y: auto;
    padding-inline-end: 0.25rem;
}

.memory-list::-webkit-scrollbar {
    width: 8px;
}

.memory-list::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 8px;
}

.memory-card {
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-soft);
    padding: 1rem 1.1rem;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    transition: background-color 0.15s ease;
    animation: fade-in 0.2s ease;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: pan-y;
}

.memory-card.editing,
.memory-card.confirming-delete {
    -webkit-user-select: text;
    user-select: text;
    touch-action: auto;
}

html.suppress-select,
html.suppress-select * {
    -webkit-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
}

html.suppress-select input,
html.suppress-select textarea {
    -webkit-user-select: text !important;
    user-select: text !important;
}

.memory-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    flex-shrink: 0;
}

.memory-timestamp {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.memory-card.card-removing,
.schedule-card.card-removing {
    overflow: hidden;
    pointer-events: none;
    transition:
        height 0.32s ease,
        padding-top 0.32s ease,
        padding-bottom 0.32s ease,
        border-width 0.32s ease,
        border-inline-start-width 0.32s ease,
        opacity 0.32s ease,
        transform 0.32s ease;
}

.card-flash {
    animation: flash-highlight 1.4s ease;
}

.memory-card:hover {
    background-color: var(--card-bg-hover);
}

.memory-card.archived {
    opacity: 0.5;
}

.memory-card.archived .memory-text {
    text-decoration: line-through;
    text-decoration-color: var(--text-muted);
}

.memory-card.trashed {
    opacity: 0.75;
}

.memory-body {
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
}

.memory-text {
    font-size: 0.92rem;
    font-weight: 500;
    unicode-bidi: plaintext;
    -webkit-user-select: none;
    user-select: none;
}

.memory-card.editing .memory-text,
.memory-card.editing .edit-input {
    -webkit-user-select: text;
    user-select: text;
}

.memory-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
}

.entity-mention {
    display: inline-flex;
    align-items: center;
}

.entity-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-inline-end: 5px;
    flex-shrink: 0;
}

.entity-dot--date { background-color: var(--entity-date); }
.entity-dot--day { background-color: var(--entity-day); }
.entity-dot--place { background-color: var(--entity-place); }
.entity-dot--person { background-color: var(--entity-person); }
.entity-dot--org { background-color: var(--entity-org); }
.entity-dot--time { background-color: var(--entity-time); }
.entity-dot--recurrence { background-color: var(--entity-time); }

.memory-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.btn-delete {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: color 0.15s ease, background-color 0.15s ease;
}

.btn-delete:hover {
    color: var(--danger);
    background-color: var(--danger-soft);
}

.btn-notify {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: color 0.15s ease, background-color 0.15s ease;
}

.btn-notify:hover {
    color: var(--warning);
    background-color: var(--warning-soft);
}

.btn-notify.is-active {
    color: var(--warning);
}

.btn-edit {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: color 0.15s ease, background-color 0.15s ease;
}

.btn-edit:hover {
    color: var(--accent);
    background-color: var(--accent-soft);
}

.btn-restore {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background-color: var(--accent-soft);
    border: 1px solid var(--accent);
    color: var(--accent);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1;
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-md);
    flex-shrink: 0;
    transition: color 0.15s ease, background-color 0.15s ease, transform 0.05s ease;
}

.btn-restore span:first-child {
    font-size: 1rem;
}

.btn-restore:hover {
    color: #04121c;
    background-color: var(--accent);
}

.btn-restore:active {
    transform: translateY(1px);
}

.memory-card.confirming-delete,
.memory-card.editing {
    flex-direction: column;
    align-items: stretch;
    gap: 0.7rem;
}

.delete-confirm-text {
    font-size: 0.9rem;
    color: var(--text-main);
    font-weight: 500;
}

.delete-confirm-preview {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
    overflow-wrap: break-word;
}

.delete-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
}

.delete-confirm-text,
.delete-confirm-preview,
.delete-confirm-actions,
.edit-input {
    animation: fade-in 0.3s ease;
}

.edit-input {
    flex: none;
    line-height: 1.85;
    padding: 0.85rem 0.9rem;
}

.memory-card.editing {
    --edit-lines: 1;
}

.memory-card.editing .delete-confirm-actions {
    gap: clamp(0.45rem, calc(0.39rem + var(--edit-lines) * 0.06rem), 0.75rem);
}

.memory-card.editing .delete-confirm-actions .btn {
    font-size: clamp(0.78rem, calc(0.745rem + var(--edit-lines) * 0.035rem), 0.95rem);
    padding: clamp(0.44rem, calc(0.39rem + var(--edit-lines) * 0.05rem), 0.78rem)
             clamp(0.78rem, calc(0.68rem + var(--edit-lines) * 0.1rem), 1.25rem);
}

.btn-danger {
    background-color: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    opacity: 0.9;
}

.memory-thumb {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    padding: 0;
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-elevated);
    cursor: pointer;
}

.memory-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.photo-lightbox {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.85rem;
    background: rgba(4, 8, 18, 0.88);
    padding: 1.5rem;
}

.photo-lightbox[hidden] {
    display: none;
}

.photo-lightbox img {
    max-width: min(100%, 720px);
    max-height: min(78vh, 720px);
    object-fit: contain;
    border-radius: 12px;
}

.photo-lightbox-close {
    position: absolute;
    top: max(0.8rem, env(safe-area-inset-top));
    inset-inline-end: 0.9rem;
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

.photo-lightbox-actions,
.photo-lightbox-confirm-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    justify-content: center;
}

.photo-lightbox-actions[hidden],
.photo-lightbox-confirm[hidden] {
    display: none;
}

.photo-lightbox-confirm {
    text-align: center;
}

.photo-lightbox-confirm p {
    margin: 0 0 0.7rem;
    color: #fff;
    font-weight: 600;
}

.photo-lightbox-replace,
.photo-lightbox-remove {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.28);
}

.photo-lightbox-remove {
    color: #fecaca;
}

.photo-lightbox--readonly .photo-lightbox-actions,
.photo-lightbox--readonly .photo-lightbox-confirm {
    display: none;
}
