body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    overflow: hidden;
    /* スクロールはコンテナ内で行う */
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

#global-mobile-menu,
.global-mobile-menu {
    display: none !important;
}

.discover-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    z-index: 100;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0) 100%);
    pointer-events: none;
    /* コンテンツのタップを邪魔しないように */
}

.discover-header a,
.discover-header button,
.discover-header span {
    pointer-events: auto;
    /* ボタンはタップ可能に */
    color: #fff;
    text-decoration: none;
    font-weight: bold;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
}

.back-button {
    font-size: 1.1rem;
    min-width: 0;
}

.saved-items-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 42px;
    flex: 0 0 auto;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 8px;
    background-color: rgba(0, 0, 0, 0.35);
    padding: 8px 34px 8px 12px;
    font-size: 0.9rem;
    line-height: 1;
    backdrop-filter: blur(6px);
    cursor: pointer;
}

.saved-items-button:hover,
.saved-items-button:focus-visible {
    background-color: rgba(255, 255, 255, 0.18);
}

.saved-count-badge {
    position: absolute;
    top: -7px;
    right: -7px;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 8px;
    background-color: #20c997;
    color: #07130f;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    line-height: 1;
    font-weight: 800;
    text-shadow: none;
    border: 1px solid rgba(255, 255, 255, 0.9);
}

.discover-container {
    width: 100%;
    height: 100dvh;
    /* 動的ビューポート高さを使用 */
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

.discover-container::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari and Opera */
}

/* 各スワイプアイテム */
.discover-item {
    position: relative;
    width: 100%;
    height: 100dvh;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #111;
}

.media-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding-bottom: 70px;
    /* オーバーレイと丸被りしないように余白 */
}

/* 画像を少し小さく */
.media-container img {
    width: 100%;
    flex: 0.7;
    min-height: 0;
    /* flex-itemのオーバーフロー防止 */
    object-fit: contain;
    /* アスペクト比を維持しつつ全体を表示 */
    border: none;
}

/* 動画領域を少し大きく（開始位置を上に） */
.media-container video,
.media-container iframe {
    width: 100%;
    flex: 1.3;
    min-height: 0;
    /* flex-itemのオーバーフロー防止 */
    object-fit: contain;
    /* アスペクト比を維持しつつ全体を表示 */
    border: none;
}

/* 動画がタップされた時に視覚的なフィードバック */
.media-container video {
    cursor: pointer;
}

.item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 80px 20px 30px 20px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.6) 40%, rgba(0, 0, 0, 0) 100%);
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
}

.item-info {
    flex: 1;
    padding-right: 15px;
    pointer-events: auto;
}

.item-title {
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 8px;
    line-height: 1.4;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.item-meta .badge {
    font-size: 0.85rem;
    margin-right: 5px;
    margin-bottom: 5px;
    pointer-events: auto;
}

.item-meta a.badge {
    text-decoration: none;
    color: inherit;
}

.item-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    pointer-events: auto;
}

.detail-link,
.action-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: white;
}

.action-button {
    border: 0;
    background: transparent;
    padding: 0;
    font: inherit;
    cursor: pointer;
}

.action-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    margin-bottom: 5px;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    transition: background-color 0.2s;
}

.action-btn:hover {
    background-color: rgba(233, 30, 99, 0.6);
}

.save-button .action-btn {
    background-color: rgba(255, 255, 255, 0.18);
}

.save-button:hover .action-btn,
.save-button:focus-visible .action-btn {
    background-color: rgba(32, 201, 151, 0.45);
}

.save-button.is-saved .action-btn {
    background-color: rgba(32, 201, 151, 0.78);
    border-color: rgba(255, 255, 255, 0.85);
    color: #061510;
}

.save-button.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.action-label {
    font-size: 0.8rem;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.loading-indicator {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
}

.saved-items-overlay {
    position: fixed;
    inset: 0;
    z-index: 600;
    pointer-events: none;
}

.saved-items-overlay.is-open {
    pointer-events: auto;
}

.saved-items-backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background-color: rgba(0, 0, 0, 0.58);
    opacity: 0;
    transition: opacity 0.2s ease;
    cursor: pointer;
}

.saved-items-overlay.is-open .saved-items-backdrop {
    opacity: 1;
}

.saved-items-sheet {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 82dvh;
    display: flex;
    flex-direction: column;
    padding: 16px 16px max(18px, env(safe-area-inset-bottom));
    border-radius: 8px 8px 0 0;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-bottom: 0;
    background-color: rgba(13, 13, 13, 0.98);
    box-shadow: 0 -14px 40px rgba(0, 0, 0, 0.45);
    transform: translateY(100%);
    transition: transform 0.2s ease;
}

.saved-items-overlay.is-open .saved-items-sheet {
    transform: translateY(0);
}

.saved-items-sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 12px;
}

.saved-items-eyebrow {
    margin: 0 0 3px;
    color: #9ee6d1;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0;
}

.saved-items-sheet h2 {
    margin: 0;
    font-size: 1.1rem;
    line-height: 1.35;
    font-weight: 800;
}

.saved-items-close {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    border: 1px solid rgba(255, 255, 255, 0.26);
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
}

.saved-items-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}

.saved-items-clear {
    min-height: 40px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 0 14px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
}

.saved-items-clear:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.saved-items-list {
    min-height: 0;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 2px;
}

.saved-items-empty {
    margin: 18px 0 22px;
    padding: 18px 14px;
    border: 1px dashed rgba(255, 255, 255, 0.28);
    border-radius: 8px;
    color: #e7e7e7;
    background-color: rgba(255, 255, 255, 0.06);
    line-height: 1.7;
}

.saved-item-card {
    display: flex;
    gap: 12px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.08);
}

.saved-item-thumb {
    width: 72px;
    height: 96px;
    flex: 0 0 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    overflow: hidden;
    background-color: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.6);
}

.saved-item-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.saved-item-body {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
}

.saved-item-body h3 {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.saved-item-meta {
    margin: 0;
    color: #cfcfcf;
    font-size: 0.8rem;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.saved-item-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.saved-detail-link,
.saved-remove-button {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    padding: 0 14px;
    font-size: 0.86rem;
    font-weight: 800;
    text-decoration: none;
}

.saved-detail-link {
    border: 1px solid rgba(32, 201, 151, 0.65);
    background-color: rgba(32, 201, 151, 0.22);
    color: #eafff7;
}

.saved-detail-link.is-disabled {
    opacity: 0.45;
    pointer-events: none;
}

.saved-remove-button {
    border: 1px solid rgba(255, 255, 255, 0.24);
    background-color: rgba(255, 255, 255, 0.08);
    color: #fff;
    cursor: pointer;
}

.save-toast {
    position: fixed;
    left: 50%;
    bottom: 112px;
    z-index: 700;
    max-width: min(320px, calc(100% - 32px));
    padding: 10px 14px;
    border-radius: 8px;
    background-color: rgba(20, 20, 20, 0.92);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
    transform: translate(-50%, 10px);
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.save-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* チュートリアルオーバーレイ */
.swipe-tutorial {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    cursor: pointer;
    transition: opacity 0.5s;
}

.tutorial-content {
    text-align: center;
    animation: swipeUpAnim 2.5s infinite ease-out;
}

.swipe-icon {
    font-size: 3.5rem;
    margin-bottom: 20px;
}

.tutorial-content p {
    font-size: 1.3rem;
    font-weight: bold;
    margin: 0;
    text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.8);
}

.tutorial-sub {
    font-size: 0.9rem !important;
    color: #e0e0e0;
    font-weight: normal !important;
    margin-top: 12px !important;
}

@keyframes swipeUpAnim {
    0% {
        transform: translateY(30px);
        opacity: 0;
    }

    20% {
        opacity: 1;
    }

    70% {
        transform: translateY(-40px);
        opacity: 1;
    }

    100% {
        transform: translateY(-40px);
        opacity: 0;
    }
}
