.community-memory__overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(29, 45, 38, 0.46);
    opacity: 0;
    transition: opacity 180ms ease;
}

.community-memory__overlay[hidden] {
    display: none;
}

.community-memory__overlay.is-open {
    opacity: 1;
}

.community-memory__dialog {
    display: flex;
    flex-direction: column;
    width: min(100%, 520px);
    max-width: 520px;
    max-height: min(82vh, 760px);
    overflow: hidden;
    border-radius: 20px;
    background: #fffdf8;
    color: #26352d;
    box-shadow: 0 22px 60px rgba(31, 63, 45, 0.24);
    transition: transform 180ms ease;
}

.community-memory__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px 14px;
    border-bottom: 1px solid #e4eee7;
}

.community-memory__title {
    margin: 0;
    font-size: 20px;
    line-height: 1.35;
    color: #245a3b;
}

.community-memory__close,
.community-memory__publish-button,
.community-memory__retry,
.community-memory__more,
.community-memory__like,
.community-memory__delete {
    min-height: 44px;
    min-width: 44px;
    border: 1px solid transparent;
    border-radius: 12px;
    font: inherit;
    cursor: pointer;
    transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.community-memory__close {
    padding: 0 12px;
    background: #edf5ef;
    color: #356349;
}

.community-memory__error {
    margin: 12px 20px 0;
    padding: 10px 12px;
    border-radius: 12px;
    background: #fff0df;
    color: #8a4c16;
}

.community-memory__error[hidden] {
    display: none;
}

.community-memory__retry {
    margin-left: 10px;
    padding: 0 14px;
    border-color: #eba359;
    background: #fff8ee;
    color: #8a4c16;
}

.community-memory__list {
    flex: 1 1 auto;
    min-height: 120px;
    overflow-y: auto;
    padding: 8px 20px 16px;
}

.community-memory__item {
    display: flex;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid #edf1ee;
}

.community-memory__avatar {
    display: inline-flex;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #dcecdf;
    color: #28613e;
    font-weight: 700;
}

.community-memory__item-body {
    min-width: 0;
    flex: 1;
}

.community-memory__author {
    color: #2d5f40;
}

.community-memory__content {
    margin: 7px 0 10px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.6;
}

.community-memory__controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.community-memory__like,
.community-memory__delete {
    padding: 0 13px;
    background: #f3f7f4;
    color: #456150;
}

.community-memory__like.is-liked {
    border-color: #77a986;
    background: #e1f2e5;
    color: #225c38;
}

.community-memory__delete {
    background: #fff4e8;
    color: #98521b;
}

.community-memory__empty,
.community-memory__loading-more {
    margin: 24px 0;
    text-align: center;
    color: #6d7d73;
}

.community-memory__more {
    display: block;
    width: 100%;
    margin-top: 12px;
    background: #edf6ef;
    color: #2c6843;
}

.community-memory__publish {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 14px 20px 18px;
    border-top: 1px solid #e4eee7;
    background: #fff;
}

.community-memory__input {
    min-height: 88px;
    resize: vertical;
    padding: 11px 12px;
    border: 1px solid #b9ccbe;
    border-radius: 12px;
    font: inherit;
    line-height: 1.45;
    color: inherit;
}

.community-memory__input:focus {
    outline: 3px solid rgba(67, 139, 88, 0.18);
    border-color: #4c8c60;
}

.community-memory__publish-button {
    align-self: stretch;
    min-width: 72px;
    padding: 0 16px;
    background: #2f774a;
    color: #fff;
    font-weight: 700;
}

.community-memory button:disabled,
.community-memory button[aria-disabled="true"] {
    cursor: wait;
    opacity: 0.58;
}

@media (hover: hover) {
    .community-memory button:not(:disabled):not([aria-disabled="true"]):hover {
        transform: translateY(-1px);
        filter: brightness(0.98);
    }
}

@media (max-width: 640px) {
    .community-memory__overlay {
        align-items: flex-end;
        padding: 0;
    }

    .community-memory__dialog {
        width: 100%;
        max-width: none;
        max-height: min(88vh, 760px);
        border-radius: 20px 20px 0 0;
    }

    .community-memory__header,
    .community-memory__list {
        padding-right: 16px;
        padding-left: 16px;
    }

    .community-memory__publish {
        grid-template-columns: 1fr;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    }

    .community-memory__publish-button {
        min-height: 44px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .community-memory__overlay,
    .community-memory__dialog,
    .community-memory button {
        transition: none;
    }
}
