:root {
  --color-primary: #10b981;
  --color-primary-hover: #059669;
  --color-primary-light: #ecfdf5;
  --color-text-main: #111827;
  --color-text-muted: #6b7280;
  --color-bg-page: #f9fafb;
  --color-bg-card: #ffffff;
  --color-border: #e5e7eb;
  --color-border-dark: #d1d5db;
  --color-danger: #ef4444;
  --color-danger-light: #fef2f2;
  --color-warning: #f59e0b;
  --color-dark: #1f2937;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-family);
  background-color: var(--color-bg-page);
  color: var(--color-text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  width: 100%;
}

.desktop-only {
  display: flex;
}
.mobile-only {
  display: none;
}

/* ヘッダー＆告知バー */
.top-notice-bar {
  background-color: var(--color-dark);
  color: #fff;
  font-size: 0.72rem;
  padding: 6px 10px;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  line-height: 1.3;
  flex-wrap: wrap;
}
.top-notice-bar .highlight {
  color: #34d399;
  font-weight: 700;
  white-space: nowrap;
}

/* メインヘッダー */
.site-header {
  background-color: #fff;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand-logo {
  display: flex;
  align-items: baseline;
  gap: 6px;
  text-decoration: none;
  color: var(--color-text-main);
  flex-shrink: 0;
}
.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  white-space: nowrap;
}
.brand-subtitle {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}
.btn-nav-action {
  background: none;
  border: 1px solid var(--color-border);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  color: var(--color-text-main);
  white-space: nowrap;
}
.btn-nav-action:hover {
  background-color: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary-hover);
}

/* スマホ用ヘッダーアイコン */
.mobile-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.icon-nav-btn {
  background: #f9fafb;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  position: relative;
  cursor: pointer;
}
.badge-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  border-radius: 10px;
  padding: 1px 5px;
}

/* コンテナ */
.main-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* フィルター・検索バー */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
  background-color: #fff;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}
.filter-select, .search-input {
  padding: 8px 12px;
  border: 1px solid var(--color-border-dark);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: #fff;
}
.filter-chip {
  padding: 6px 12px;
  border-radius: 20px;
  background: #f3f4f6;
  border: 1px solid var(--color-border);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}
.filter-chip.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

/* マイ好み登録用チップスタイル */
.pref-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}
.pref-checkbox-label:hover {
  background: #f3f4f6;
}
.pref-checkbox-label input[type="checkbox"] {
  accent-color: var(--color-primary);
  cursor: pointer;
}

/* 商品グリッド */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

/* 商品カード */
.item-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  display: flex;
  flex-direction: column;
}
.item-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.item-thumb-wrapper {
  position: relative;
  width: 100%;
  padding-top: 120%; /* アスペクト比 */
  background: #f3f4f6;
  overflow: hidden;
}
.item-thumb {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}
.item-card:hover .item-thumb {
  transform: scale(1.03);
}

/* バッジ類 */
.item-badge-hold {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(31, 41, 55, 0.9);
  color: #fff;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.item-badge-drop {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--color-danger);
  color: #fff;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
}
.btn-fav {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background 0.2s, color 0.2s;
  box-shadow: var(--shadow-sm);
}
.btn-fav.active {
  color: var(--color-danger);
}

.item-info {
  padding: 14px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}
.item-brand {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--color-text-muted);
  font-weight: 600;
  margin-bottom: 2px;
}
.item-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text-main);
  margin-bottom: 8px;
  line-height: 1.3;
}
.item-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: auto;
  margin-bottom: 8px;
}
.item-price {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--color-text-main);
}
.item-old-price {
  font-size: 0.85rem;
  text-decoration: line-through;
  color: var(--color-text-muted);
}
.item-size-diff {
  display: inline-block;
  background: var(--color-primary-light);
  color: var(--color-primary-hover);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
}

/* モーダル表示中の背景スクロールを完全に固定 */
body:has(.modal-overlay.active) {
  overflow: hidden !important;
}

/* モーダル */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  justify-content: center;
  align-items: flex-start; /* 上詰めでキーボード出現時も操作しやすく */
  z-index: 1100;
  padding: 24px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain; /* 端までスクロールしても背景へ伝播させない */
}
.modal-overlay.active {
  display: flex;
}
.modal-card {
  background: #fff;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  position: relative;
  display: flex;
  flex-direction: column;
  overscroll-behavior: contain; /* カード内スクロールが端に達しても連鎖させない */
}
.modal-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--color-border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 20;
}

/* 詳細モーダル内レイアウト */
.modal-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  padding: 24px;
}
@media (max-width: 768px) {
  .modal-detail-grid {
    grid-template-columns: 1fr;
  }
}

/* 画像ギャラリー & ズーム */
.gallery-main {
  position: relative;
  width: 100%;
  padding-top: 100%;
  background: #f8f9fa;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 12px;
}
.gallery-main img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: zoom-in;
  transition: transform 0.2s;
}
.gallery-thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}
.gallery-thumb-item {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  object-fit: cover;
}
.gallery-thumb-item.active {
  border-color: var(--color-primary);
}

/* リアルタイム閲覧者数表示 */
.live-viewers-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 12px;
}
.live-pulse {
  width: 8px;
  height: 8px;
  background-color: #f59e0b;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

/* 実寸サイズ比較表 */
.measurements-box {
  background: #f9fafb;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin: 16px 0;
}
.measurements-title {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
}
.size-diff-highlight {
  color: var(--color-primary-hover);
  font-weight: 700;
}

/* アクションボタン */
.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}
.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  text-align: center;
}
.btn-primary:hover {
  background: var(--color-primary-hover);
}
.btn-secondary {
  background: #fff;
  color: var(--color-text-main);
  border: 1px solid var(--color-border-dark);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.btn-secondary:hover {
  background: #f3f4f6;
}
.btn-hold {
  background: var(--color-dark);
  color: #fff;
  border: none;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-hold:hover {
  background: #374151;
}
.btn-disabled {
  opacity: 0.5;
  cursor: not-allowed !important;
}

/* スマホ専用 下部固定ボトムナビゲーションバー */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background-color: #ffffff;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 900;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  text-decoration: none;
  color: #6b7280;
  padding: 6px 0;
  cursor: pointer;
  position: relative;
  font-family: inherit;
}
.bottom-nav-item.active {
  color: var(--color-primary-hover);
}
.nav-icon {
  font-size: 1.25rem;
  margin-bottom: 2px;
}
.nav-label {
  font-size: 0.68rem;
  font-weight: 700;
}
.bottom-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 18px);
  background: var(--color-danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  border-radius: 10px;
  padding: 1px 5px;
}

/* モバイル最適化メディアクエリ (max-width: 768px) */
@media (max-width: 768px) {
  body {
    padding-bottom: 75px; /* ボトムナビ用の余白 */
  }

  /* スマホヘッダーの最適化 */
  .header-inner {
    padding: 8px 10px;
  }
  .brand-title {
    font-size: 1.1rem;
  }
  .brand-subtitle {
    display: none; /* スマホでは省略してアイコン領域を確保 */
  }
  .mobile-header-actions {
    gap: 6px;
  }
  .icon-nav-btn {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
  }

  .desktop-only {
    display: none !important;
  }
  .mobile-only {
    display: flex !important;
  }

  /* メインコンテナ */
  .main-container {
    padding: 10px 10px 80px;
    overflow-x: hidden;
  }

  /* フィルターバー */
  .filter-bar {
    padding: 10px;
    gap: 8px;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .search-input {
    min-width: 140px;
    flex: 1;
    font-size: 0.85rem;
  }
  .filter-select {
    min-width: 110px;
    font-size: 0.85rem;
  }
  .filter-chip {
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* 商品グリッド：スマホで2列表示 */
  .items-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .item-info {
    padding: 10px;
  }
  .item-title {
    font-size: 0.85rem;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .item-price {
    font-size: 1.05rem;
  }
  .btn-fav {
    width: 28px;
    height: 28px;
    font-size: 0.9rem;
    top: 6px;
    right: 6px;
  }
  .item-badge-hold, .item-badge-drop {
    font-size: 0.65rem;
    padding: 3px 6px;
    top: 6px;
    left: 6px;
  }

  /* モーダル：キーボードが開いても入力しやすいよう上詰めに配置 */
  .modal-overlay {
    padding: 16px 12px 90px 12px;
    align-items: flex-start; /* 上詰め */
  }
  .modal-card {
    max-height: 85vh;
    border-radius: var(--radius-lg);
    width: 100%;
    margin-top: 8px;
  }
  .modal-detail-grid {
    padding: 16px;
    gap: 16px;
  }
  .modal-actions {
    margin-top: 14px;
  }
  .btn-primary, .btn-secondary, .btn-hold {
    padding: 12px 16px;
    font-size: 0.9rem;
  }
}

/* アプリ内トースト通知（PC・スマホ両対応） */
#shopToastContainer {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
  width: calc(100% - 32px);
  pointer-events: none;
}

@media (max-width: 768px) {
  #shopToastContainer {
    top: 14px;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%);
    width: calc(100% - 24px);
    max-width: 420px;
  }
}

@keyframes toastSlideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

