*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: #000;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

/* --- ヘッダー --- */
.ml-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.ml-header__title {
  font-size: 18px;
  font-weight: bold;
}

.ml-header__toggle {
  display: flex;
  gap: 4px;
  background: #222;
  border-radius: 8px;
  padding: 2px;
}

.ml-header__btn {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  background: transparent;
  color: #999;
  transition: all 0.2s;
}

.ml-header__btn.is-active {
  background: #fff;
  color: #000;
}

/* ============================
   スクロールビュー（TikTok風）
   ============================ */
:root {
  --header-h: 44px;
}

.ml-scroll {
  display: block;
}

.ml-scroll__container {
  height: calc(100vh - var(--header-h));
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;          /* Firefox */
  -ms-overflow-style: none;       /* IE/Edge */
}

.ml-scroll__container::-webkit-scrollbar {
  display: none;                  /* Chrome/Safari/Edge */
}

.ml-scroll__item {
  scroll-snap-align: start;
  height: calc(100vh - var(--header-h));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0 16px;
  position: relative;
}

.ml-scroll__frame {
  position: relative;
  height: calc(100% - 28px); /* 日付表示分を確保 */
  max-height: calc(100vh - var(--header-h) - 28px);
  aspect-ratio: 9 / 16;
  max-width: 100%;
  background: #111;
  border-radius: 12px;
  overflow: hidden;
  flex-shrink: 0;
}

.ml-scroll__frame iframe,
.ml-scroll__frame .yt-player-div {
  position: absolute;
  top: -60px;
  left: 0;
  width: 100%;
  height: calc(100% + 120px);
  border: none;
  pointer-events: auto;
}

/* Instagram — videoタグ */
.ml-scroll__frame--ig video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
}

/* ソースバッジ（スクロールビュー） */
.ml-scroll__badge {
  position: absolute;
  top: 12px;
  left: 16px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: bold;
}

.ml-scroll__badge--ig {
  background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  color: #fff;
}

.ml-scroll__placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555;
  font-size: 14px;
}

.ml-scroll__info {
  margin-top: 12px;
  text-align: center;
  max-width: 400px;
  width: 100%;
}

.ml-scroll__date {
  font-size: 12px;
  color: #888;
  margin-bottom: 8px;
}

/* スクロールビュー内のリンクは非表示（固定ボタンに置き換え） */
.ml-scroll__link {
  display: none;
}

/* --- 商品を見る 固定ボタン（スクロールビュー用） --- */
.ml-scroll__fixed-link {
  position: fixed;
  bottom: 24px;
  left: 16px;
  z-index: 200;
  display: inline-block;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: bold;
  color: #fff;
  background: rgba(51, 51, 51, 0.9);
  border-radius: 20px;
  text-decoration: none;
  text-align: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 0.2s;
}

.ml-scroll__fixed-link:hover {
  background: rgba(85, 85, 85, 0.9);
}

.ml-scroll__fixed-link.is-hidden {
  display: none;
}

.ml-scroll__counter {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 12px;
  color: #666;
}

/* --- 音量コントロール --- */
.ml-volume {
  position: fixed;
  bottom: 24px;
  right: 16px;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(30, 30, 30, 0.9);
  border-radius: 20px;
  padding: 8px 14px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.ml-volume__btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  width: 24px;
  text-align: center;
}

.ml-volume__slider {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 4px;
  background: #555;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.ml-volume__slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}

.ml-volume__slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: none;
  cursor: pointer;
}

/* ============================
   グリッドビュー（一覧）
   ============================ */
.ml-grid {
  display: none;
  padding: 68px 16px 16px;
  max-width: 1200px;
  margin: 0 auto;
}

.ml-grid__track {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

@media (max-width: 768px) {
  .ml-grid__track {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
}

.ml-grid__item {
  position: relative;
}

.ml-grid__frame {
  position: relative;
  width: 100%;
  padding-top: 177.78%;
  background: #111;
  border-radius: 12px;
  overflow: hidden;
}

.ml-grid__frame iframe {
  position: absolute;
  top: -60px;
  left: 0;
  width: 100%;
  height: calc(100% + 120px);
  border: none;
}

/* Instagram: グリッド内video */
.ml-grid__frame--ig video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
}

/* ソースバッジ（グリッド） */
.ml-grid__badge {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: bold;
  z-index: 1;
}

.ml-grid__badge--ig {
  background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  color: #fff;
}

.ml-grid__placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555;
  font-size: 13px;
}

.ml-grid__date {
  margin-top: 6px;
  font-size: 11px;
  color: #888;
  text-align: center;
}

.ml-grid__link {
  display: block;
  margin-top: 6px;
  padding: 6px 0;
  text-align: center;
  font-size: 12px;
  font-weight: bold;
  color: #fff;
  background: #333;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.2s;
}

.ml-grid__link:hover {
  background: #555;
}

/* ローディング */
.ml-loading {
  text-align: center;
  padding: 24px;
  color: #666;
  font-size: 14px;
}

.ml-loading.is-hidden {
  display: none;
}

/* 表示切り替え */
.ml-scroll.is-hidden,
.ml-grid.is-hidden {
  display: none !important;
}

.ml-grid.is-visible {
  display: block;
}
