.container {
    display: flex;
    /* padding: 20px; */
    /* gap: 20px; */
}

.image-list {
    flex: 1;
    margin-left: 20px;
    margin-top: 5px;
}

.image-display {
    flex: 2;
    max-width: 100%;
}

#imageSelect {
    width: 100%;
    padding: 8px;
    margin-bottom: 15px;
}

#selectedImage {
    max-width: 100%;
    height: auto;
}

/* Base Layout */
.layout {
    display: flex;
    min-height: 100vh;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    touch-action: manipulation;
    /* 追加: タップのみを許可 */
}

/* Sidebar */
.sidebar {
    width: 300px;
    background-color: #f5f5f5;
    /* padding: 20px; */
    border-right: 1px solid #ddd;
    overflow-y: auto;
    height: 100vh;
}

/* Main Content */
.main-content {
    width: 640px;
    height: 720px;
    overflow: hidden;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: 0px;
    position: relative;
}

.watermark {
    position: absolute;
    bottom: 5%;
    right: 5%;
    color: rgba(0, 0, 0, 0.7);
    font-size: 12px;
    z-index: 10;
    text-shadow:
        -1px -1px 0 #fff,
        1px -1px 0 #fff,
        -1px 1px 0 #fff,
        1px 1px 0 #fff;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.sidebar h2 {
    margin-bottom: 15px;
    font-size: 1.2em;
}

#imageFileList {
    list-style: none;
    padding: 0;
}

#imageFileList li {
    padding: 8px;
    cursor: pointer;
    border-bottom: 1px solid #ddd;
}

#imageFileList li:hover {
    background-color: #e9e9e9;
}

.add-button {
    background-color: #4CAF50;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 15px;
    width: 100%;
}

.add-button:hover {
    background-color: #45a049;
}

.image-file-list {
    list-style: none;
    padding: 0;
}

.image-file-list li {
    padding: 10px;
    margin-bottom: 5px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.image-file-list li:hover {
    background-color: #f0f0f0;
    color: #333;
}

.save-button {
    background-color: #2196F3;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin: 15px 0;
    width: 100%;
}

.save-button:hover {
    background-color: #1976D2;
}

.folder {
    margin-bottom: 10px;
}

.folder-name {
    display: flex;
    padding: 8px;
    background: none;
    border-radius: 4px;
    cursor: pointer;
    /* font-weight: bold; */
    position: relative;
    align-items: center;
    gap: 10px;
}

.folder-name::before {
    display: none;
}

.folder-name span {
    color: #333;
    text-shadow: none;
    flex-grow: 1;
}

.folder-thumbnail {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    transform: scale(1.2);
    transform-origin: center;
    object-position: center 15%;
}

.image-item {
    padding: 6px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.image-item:hover {
    background-color: #f0f0f0;
}

.image-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.image-container img {
    width: 100%;
    height: auto;
    object-fit: cover;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: transform 0.2s;
    user-select: none;
    aspect-ratio: 4 / 3;
    /* 縦横比を指定 (例: 4:3) */
}

/* Grid Layouts */
.image-grid,
.event-image-grid {
    display: grid;
    width: calc(100% - 40px);
    margin: 0;
    justify-content: center;
}

.image-grid {
    aspect-ratio: 10 / 7;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(3, 1fr);
    padding: 0;
}

.image-grid img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: transform 0.2s;
    user-select: none;
}

.event-image-grid {
    height: 100px;
    grid-template-columns: 7fr 7fr 7fr 9fr;
    padding: 0;
    margin: 0 0 20px;
}

.event-image-grid .image-container {
    width: 140px;
    height: 100px;
}

.event-image-grid .image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-grid img.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.image-grid img.drag-over {
    border: 1px solid #ddd;
}

.image-grid img.insert-before {
    border-left: 3px solid #4CAF50;
}

.image-grid img.insert-after {
    border-right: 3px solid #4CAF50;
}

.delete-button {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 20px;
    height: 20px;
    background-color: rgba(255, 0, 0, 0.7);
    color: white;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    z-index: 10;
}

.image-container:hover .delete-button {
    display: flex;
}

.delete-button:hover {
    background-color: rgba(255, 0, 0, 0.9);
}

.event-image-section {
    margin-bottom: 20px;
    border-bottom: 1px solid #ddd;
    padding-bottom: 15px;
}

.event-image-section h3 {
    font-size: 1.1em;
    margin-bottom: 10px;
}

.event-image-list {
    list-style: none;
    padding: 0;
}

.event-image-list li {
    padding: 8px;
    cursor: pointer;
    background-color: #fff;
    border-bottom: 1px solid #eee;
    position: relative;
    height: 40px;
    display: flex;
    align-items: center;
    background-size: cover;
    background-position: center;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.event-image-list li::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.3);
    z-index: 1;
}

.event-image-list li span {
    position: relative;
    z-index: 2;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.event-image-list li:hover {
    background-color: #f0f0f0;
}

.tab-container {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.tab-buttons {
    display: flex;
    border-bottom: 1px solid #ddd;
    margin-bottom: 15px;
}

.tab-button {
    padding: 12px 8px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    color: #666;
    flex: 1;
    transition: all 0.3s;
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.tab-button i {
    font-size: 1.2rem;
}

.tab-button.active {
    color: #2196F3;
    border-bottom-color: #2196F3;
    font-weight: bold;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ...existing code... */

.idol-backgrounds {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: -1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    overflow: hidden;
}

.idol-background {
    width: 100%;
    height: 100%;
    background-size: 200%;
    background-position: left 65% top 30%;
    background-repeat: no-repeat;
    opacity: 0.8;
    position: relative;
    overflow: hidden;
}

.playlist-section {
    padding: 10px 0;
}

.playlist-section h3 {
    font-size: 0.9rem;
    color: #666;
    margin: 15px 0 8px;
    padding-bottom: 5px;
    border-bottom: 1px solid #eee;
}

.playlist-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.playlist-list li {
    padding: 8px;
    margin-bottom: 4px;
    background-color: #f8f8f8;
    border-radius: 4px;
    font-size: 0.9rem;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: space-between;
    touch-action: none;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.playlist-list li.dragging {
    opacity: 0.8;
    background-color: #e0e0e0;
    border: 1px dashed #2196F3;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transform: scale(1.02);
    cursor: grabbing;
}

.playlist-list li .drag-handle {
    cursor: grab;
    padding: 0 8px;
    color: #999;
    display: flex;
    align-items: center;
    transition: color 0.2s ease;
}

.playlist-list li .drag-handle:hover {
    color: #2196F3;
}

.playlist-list li.dragging .drag-handle {
    color: #2196F3;
}

.playlist-list li .item-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
}

.playlist-list li button {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 2px 6px;
    font-size: 0.8rem;
}

.playlist-list li button:hover {
    color: #ff4444;
}

/* Mobile Responsive */
@media screen and (max-width: 890px) {
    .layout {
        flex-direction: column;
        height: auto;
        overflow-y: visible;
    }

    .main-content {
        width: 100vw;
        height: 100vw;
        align-items: flex-start;
        order: 1;
    }

    .sidebar {
        width: 100%;
        height: auto;
        min-height: 50vh;
        position: relative;
        order: 2;
        border-top: 1px solid #ddd;
        background-color: rgba(245, 245, 245, 0.95);
        backdrop-filter: blur(5px);
        /* padding: 10px; */
        display: flex;
        flex-direction: column;
    }

    .image-grid {
        transform-origin: center top;
        margin: 0;
        width: calc(100vw - 20px);
        height: calc(70vw - 20px);
        grid-template-columns: repeat(6, 1fr);
        grid-template-rows: repeat(3, 1fr);
        justify-content: center;
    }

    .event-image-grid {
        transform-origin: center top;
        width: calc(100vw - 20px);
        height: calc((100vw - 20px)/6);
        grid-template-columns: 7fr 7fr 7fr 9fr;
        justify-content: center;
    }

    .image-container,
    .image-container img {
        width: 100%;
        height: 100%;
    }

    .event-image-grid .image-container,
    .event-image-grid .image-container img {
        width: 100%;
        height: 100%;
    }

    .save-button {
        margin: 10px 0;
        position: sticky;
        bottom: 10px;
        flex-shrink: 0;
    }

    #imageFileList {
        max-height: calc(50vh - 100px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tab-button {
        padding: 8px 4px;
        font-size: 0.75rem;
    }

    .tab-button i {
        font-size: 1.1rem;
    }

    .tab-container {
        display: flex;
        flex-direction: column;
        flex-grow: 1;
        height: 0;
        min-height: 0;
        margin-top: 10px;
    }

    .tab-buttons {
        flex-shrink: 0;
    }

    .tab-content {
        flex-grow: 1;
        height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
        /* 垂直スクロールを許可 */
    }

    .image-file-list,
    .event-image-list,
    .playlist-list {
        flex-grow: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
        /* 垂直スクロールを許可 */
    }

    .playlist-list li {
        touch-action: pan-y;
        /* 垂直スクロールを許可 */
    }

    .image-item {
        touch-action: pan-y;
        /* 垂直スクロールを許可 */
    }

    .tab-content.active {
        display: flex;
        flex-direction: column;
    }

    .image-file-list,
    .event-image-list {
        flex-grow: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .watermark {
        font-size: min(2.5vw, 12px);
        bottom: 5%;
        right: 5%;
    }

    .playlist-section h3 {
        font-size: 0.85rem;
        margin: 12px 0 6px;
    }

    .playlist-list li {
        padding: 6px;
        font-size: 0.85rem;
    }

    .event-image-list {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        padding: 0;
    }

    .event-image-list li {
        height: calc((100vw - 36px) / 3);
        margin: 0;
        border: none;
        border-radius: 4px;
        background-size: cover;
        background-position: center;
    }

    .event-image-list li span {
        font-size: 0.8rem;
        position: absolute;
        bottom: 5px;
        left: 5px;
        right: 5px;
        text-align: center;
    }
}

body {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    touch-action: manipulation;
    /* 追加: タップのみを許可 */
}

/* ...existing code... */

.song-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.back-button {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #666;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.back-button:hover {
    background-color: rgba(0, 0, 0, 0.1);
    color: #333;
}

.nav-title {
    font-size: 1.1em;
    margin: 0;
    color: #333;
}

/* ...existing code... */

/* ...existing code... */

.image-item {
    /* padding: 8px; */
    cursor: pointer;
    border-bottom: 1px solid #eee;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.image-item .song-thumbnail {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
    transform: scale(1.2);
    /* サムネイルのズーム率を1.5倍に */
    transform-origin: center;
    /* 中心からズーム */
    object-position: center 15%;
    /* 画像を上部30%の位置にズーム */
}

.image-item .song-name {
    flex-grow: 1;
}

/* ...existing code... */

/* ...existing code... */

.folder-favorite {
    position: absolute;
    right: 10px;
    z-index: 3;
    color: rgba(128, 128, 128, 0.7);
    /* グレーの半透明に変更 */
    cursor: pointer;
    padding: 5px;
    transition: all 0.2s ease;
    text-shadow: 0 0 3px rgba(255, 255, 255, 0.8);
    /* 白いシャドウを追加 */
}

.folder-favorite.active {
    color: #ffeb3b;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

.folder-favorite:hover {
    transform: scale(1.2);
}

/* ...existing code... */