/* Shared story composer: compact, uncropped preview on every profile/community page. */
.story-modal-content {
    width: min(760px, calc(100vw - 32px));
    max-width: 760px;
    max-height: min(900px, calc(100dvh - 32px));
}

.story-modal-body {
    min-height: 0;
    padding: 1.25rem;
    gap: 0;
}

.story-modal-body:has(.story-preview-container[style*="block"]) {
    display: grid;
    grid-template-columns: minmax(250px, 340px) minmax(220px, 1fr);
    grid-template-rows: auto auto 1fr;
    align-items: start;
    gap: 0.75rem 1.25rem;
}

.story-modal-body:has(.story-preview-container[style*="block"]) .story-preview-container {
    grid-column: 1;
    grid-row: 1 / span 3;
}

.story-modal-body:has(.story-preview-container[style*="block"]) .story-text-input,
.story-modal-body:has(.story-preview-container[style*="block"]) .story-char-counter {
    grid-column: 2;
}

#storyPreview,
.story-preview-container {
    width: 100%;
    max-width: 340px;
    margin: 0 auto;
    background: transparent;
    border-radius: 0;
    overflow: visible;
}

.story-preview-wrapper {
    width: 100%;
    height: min(60dvh, 600px);
    max-height: 600px;
    padding-bottom: 0;
    aspect-ratio: 9 / 16;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    background: #050505;
    overflow: hidden;
}

.story-preview.story-preview-image,
.story-preview.story-preview-video,
.story-preview.story-preview-video.contain-mode {
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 17px;
}

.story-preview.story-preview-image {
    object-fit: cover;
}

.story-preview.story-preview-video,
.story-preview.story-preview-video.contain-mode {
    object-fit: contain;
    background: #000;
}

.story-preview-details {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.65rem;
}

.story-preview-file {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    gap: 0.15rem;
}

.story-preview-file strong {
    overflow: hidden;
    color: var(--text-primary);
    font-size: 0.8125rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.story-preview-file span {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.story-replace-media {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 0.5rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    cursor: pointer;
    font: inherit;
    font-size: 0.8125rem;
}

.story-replace-media:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.story-duration-notice {
    margin-top: 0.65rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid rgba(245, 158, 11, 0.35);
    border-radius: 10px;
    background: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
    font-size: 0.75rem;
    line-height: 1.4;
}

.story-duration-notice[hidden] {
    display: none;
}

.story-text-input {
    width: 100%;
    max-width: none;
    min-height: 112px;
    max-height: 240px;
    margin-top: 0;
    resize: vertical;
}

.story-char-counter {
    position: static;
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    background: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-align: right;
    backdrop-filter: none;
    animation: none;
}

@media (max-width: 720px) {
    .story-modal {
        padding: 0;
        align-items: flex-end;
    }

    .story-modal-content {
        width: 100%;
        max-width: none;
        max-height: 100dvh;
        border-radius: 22px 22px 0 0;
    }

    .story-modal-header {
        padding: 0.85rem 1rem;
    }

    .story-modal-body,
    .story-modal-body:has(.story-preview-container[style*="block"]) {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.65rem;
        padding: 0.75rem 1rem;
    }

    #storyPreview,
    .story-preview-container {
        width: min(100%, 270px);
        max-width: 270px;
    }

    .story-preview-wrapper {
        height: min(48dvh, 430px);
        min-height: 280px;
        padding-bottom: 0;
    }

    .story-text-input {
        min-height: 72px;
        max-height: 112px;
        padding: 0.75rem 0.9rem;
        resize: none;
    }

    .story-modal-footer {
        gap: 0.65rem;
        padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
    }
}

@media (max-width: 380px), (max-height: 680px) {
    .story-preview-wrapper {
        height: min(40dvh, 330px);
        min-height: 230px;
    }

    .story-preview-details {
        margin-top: 0.45rem;
    }

    .story-text-input {
        min-height: 60px;
    }
}
