.web-post-upload-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    width: 100%;
    min-width: 0;
}

.web-post-upload-grid > * {
    min-width: 0;
    max-width: 100%;
}

.web-post-upload-component {
    min-width: 0;
    max-width: 100%;
}

.web-post-upload-dropzone {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-height: 9.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    padding: 1rem;
    border: 1px dashed color-mix(in srgb, var(--web-color-primary) 44%, var(--web-border-color));
    border-radius: var(--web-radius);
    box-sizing: border-box;
    background:
        linear-gradient(
            180deg,
            color-mix(in srgb, var(--web-color-primary) 8%, var(--web-bg-surface)),
            var(--web-bg-muted)
        );
    color: var(--web-text-primary);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.web-post-upload-dropzone:hover,
.web-post-upload-dropzone:focus-within {
    border-color: var(--web-color-primary);
    background:
        linear-gradient(
            180deg,
            color-mix(in srgb, var(--web-color-primary) 12%, var(--web-bg-surface)),
            var(--web-bg-muted)
        );
    transform: translateY(-0.06rem);
}

.web-post-upload-icon {
    width: 2.4rem;
    height: 2.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: color-mix(in srgb, var(--web-color-primary) 14%, var(--web-bg-surface));
    color: var(--web-color-primary);
    font-size: 1.3rem;
}

.web-post-upload-action,
.web-post-video-dropzone [data-video-uploader-label] {
    max-width: 100%;
    min-height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.48rem 0.9rem;
    border: none;
    border-radius: 999px;
    background: var(--web-color-primary);
    color: var(--web-text-inverse);
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: normal;
    box-shadow: 0 0.35rem 0.9rem color-mix(in srgb, var(--web-color-primary) 26%, transparent);
}

.web-post-upload-action.required::after {
    content: ' *';
}

.web-post-video-dropzone [data-video-uploader-label] {
    margin-bottom: 0;
}

.web-post-video-dropzone [data-video-uploader-label]:hover {
    background: var(--web-color-primary-hover);
    color: var(--web-text-inverse);
}

.web-post-upload-help {
    min-width: 0;
    max-width: 18rem;
    color: var(--web-text-secondary);
    font-size: 0.8125rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.web-post-video-dropzone {
    cursor: default;
    overflow: hidden;
}

.web-post-video-upload-component {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.55rem;
}

.web-post-video-upload-component .web-post-upload-status,
.web-post-video-upload-component .web-post-video-grid,
.web-post-video-upload-component .web-video-cover-panel {
    align-self: stretch;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.web-post-media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.web-post-image-upload-component[data-post-image-sortable="1"] .web-post-media-grid {
    grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
}

.web-post-media-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: calc(var(--web-radius) - 0.125rem);
    overflow: hidden;
    border: 1px solid var(--web-border-color);
    background: var(--web-bg-muted);
}

.web-post-media-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.web-post-video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(12rem, 100%), 1fr));
    gap: 0.5rem;
    align-items: start;
    min-width: 0;
    max-width: 100%;
    margin-top: 0.75rem;
}

.web-post-video-item {
    position: relative;
    min-width: 0;
}

.web-post-media-sort-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 0.4rem;
}

.web-post-media-item > .web-post-media-sort-controls {
    position: absolute;
    right: 0.25rem;
    bottom: 0.25rem;
    left: 0.25rem;
    margin-top: 0;
    padding: 0.2rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--web-text-primary) 68%, transparent);
}

.web-post-media-sort-controls button {
    width: 2.5rem;
    height: 2.5rem;
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    border: 1px solid color-mix(in srgb, var(--web-border-color) 72%, transparent);
    border-radius: 999px;
    background: var(--web-bg-surface);
    color: var(--web-text-primary);
    cursor: pointer;
}

.web-post-media-sort-controls button:hover,
.web-post-media-sort-controls button:focus-visible {
    border-color: var(--web-color-primary);
    color: var(--web-color-primary);
}

.web-post-media-sort-controls button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.web-post-media-sort-handle {
    cursor: grab !important;
    touch-action: none;
    user-select: none;
}

.web-post-media-sort-handle:active {
    cursor: grabbing !important;
}

[data-media-sort-index].is-media-dragging,
[data-post-image-item].is-media-dragging,
[data-video-sort-item].is-media-dragging {
    opacity: 0.55;
}

[data-post-image-item].is-media-drag-over,
[data-video-sort-item].is-media-drag-over {
    outline: 2px solid var(--web-color-primary);
    outline-offset: 0.15rem;
}

.web-post-video-player {
    position: relative;
    aspect-ratio: 16 / 9;
    border-radius: calc(var(--web-radius) - 0.125rem);
    overflow: hidden;
    border: 1px solid var(--web-border-color);
    background: var(--web-bg-muted);
}

.web-post-video-item video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: color-mix(in srgb, var(--web-text-primary) 92%, transparent);
}

.web-post-media-remove {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    width: 1.35rem;
    height: 1.35rem;
    border: none;
    border-radius: 50%;
    background: color-mix(in srgb, var(--web-text-primary) 62%, transparent);
    color: var(--web-text-inverse);
    font-size: 0.75rem;
    cursor: pointer;
}

.web-post-upload-status {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    min-width: 0;
    max-width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--web-border-color);
    border-radius: calc(var(--web-radius) - 0.125rem);
    box-sizing: border-box;
    background: var(--web-bg-muted);
}

.web-post-upload-status[hidden] {
    display: none;
}

.web-post-upload-spinner {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    margin-top: 0.1rem;
    border: 2px solid color-mix(in srgb, var(--web-color-primary) 20%, transparent);
    border-top-color: var(--web-color-primary);
    border-radius: 50%;
    animation: web-post-upload-spin 0.75s linear infinite;
}

.web-post-upload-status-body {
    flex: 1;
    min-width: 0;
}

.web-post-upload-text {
    display: block;
    font-size: 0.875rem;
    color: var(--web-text-secondary);
    margin-bottom: 0.5rem;
}

.web-post-progress {
    min-width: 0;
    height: 0.35rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--web-text-primary) 8%, var(--web-bg-muted));
    overflow: hidden;
}

.web-post-progress-bar {
    max-width: 100%;
    height: 100%;
    background: var(--web-color-primary);
    transition: width 0.2s;
}

.web-video-uploader {
    min-width: 0;
    max-width: 100%;
}

.web-video-cover-panel {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0.75rem;
    border: 1px solid var(--web-border-color);
    border-radius: calc(var(--web-radius) - 0.125rem);
    background: var(--web-bg-muted);
}

.web-post-video-item .web-video-cover-panel {
    margin-top: 0.5rem !important;
}

.web-video-cover-title {
    margin-bottom: 0.25rem;
    color: var(--web-text-primary);
    font-size: 0.875rem;
    font-weight: 700;
}

.web-video-cover-sub {
    margin-bottom: 0.65rem;
    color: var(--web-text-secondary);
    font-size: 0.8125rem;
}

.web-video-cover-frames {
    display: flex;
    gap: 0.5rem;
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 0.25rem;
}

.web-video-cover-frame {
    flex: 0 0 auto;
    width: 7.5rem;
    height: 4.25rem;
    padding: 0;
    overflow: hidden;
    border: 2px solid transparent;
    border-radius: calc(var(--web-radius) - 0.125rem);
    background: var(--web-bg-surface);
    cursor: pointer;
}

.web-video-cover-frame img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.web-video-cover-frame.active {
    border-color: var(--web-color-primary);
}

.web-video-cover-empty {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    min-width: 0;
    max-width: 100%;
}

.web-video-cover-empty .btn {
    max-width: 100%;
    white-space: normal;
}

@keyframes web-post-upload-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (min-width: 768px) {
    .web-post-upload-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
