* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f8f8f8;
  color: #333;
  padding-bottom: env(safe-area-inset-bottom);
}

.pamphlet-header {
  background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
  color: white;
  padding: 16px 16px 16px;
  padding-top: calc(16px + env(safe-area-inset-top));
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.pamphlet-header h1 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
}

.header-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.search-box {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 8px 12px;
  flex: 1;
}

.search-box input {
  background: none;
  border: none;
  color: white;
  font-size: 16px;
  flex: 1;
  outline: none;
}

.search-box input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.search-icon {
  margin-right: 8px;
  opacity: 0.7;
}

.pdf-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  font-weight: 500;
}

.pdf-btn:active {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0.95);
}

.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0;
  padding-bottom: 8px;
  scroll-behavior: smooth;
}

.filter-btn {
  padding: 6px 14px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  background: transparent;
  color: white;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.filter-btn.active {
  background: white;
  color: #4a90e2;
  border-color: white;
}

.filter-btn:active {
  transform: scale(0.95);
}

.pamphlet-container {
  padding: 16px;
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
  max-width: 1000px;
  margin: 0 auto;
}

.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.15);
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  display: flex;
}

.bottom-bar-link {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 0;
  color: #fff;
  text-decoration: none;
  font-size: 15px;
  font-weight: 700;
  transition: opacity 0.2s;
}

.bottom-bar-link:active {
  opacity: 0.6;
}

.bottom-bar-divider {
  width: 1px;
  height: 24px;
  align-self: center;
  background: rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}

.bottom-bar-placeholder {
  flex: 1 1 0;
  min-width: 0;
}

.pamphlet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.pamphlet-card {
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: all 0.2s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.pamphlet-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.pamphlet-image {
  width: 100%;
  aspect-ratio: 1;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  font-size: 12px;
  color: #999;
  padding-top: 8px;
}

@media (min-width: 500px) {
  /* PC/タブレットでは横幅の制限を外して画面全幅で表示する。 */
  .pamphlet-container {
    max-width: none;
  }
  .pamphlet-image {
    width: 100%;
    height: 150px;
    flex-shrink: 0;
  }
}

.pamphlet-image img {
  /* width: 100%; */
  height: 100%;
  /* object-fit: cover; */
}

.pamphlet-info {
  padding: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.pamphlet-name {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
  line-height: 1.3;
  height: calc(1.3em * 2);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.pamphlet-meta {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
  flex-wrap: wrap;
  align-items: center;
}

.pamphlet-category {
  background: #f0f7ff;
  color: #4a90e2;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.pamphlet-code {
  font-size: 11px;
  color: #999;
}

.empty {
  text-align: center;
  padding: 60px 20px;
  color: #999;
  grid-column: 1 / -1;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.loading {
  text-align: center;
  padding: 40px 20px;
  color: #999;
}

.spinner {
  border: 3px solid #f0f0f0;
  border-top: 3px solid #4a90e2;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.info-bar {
  background: #fff3cd;
  color: #856404;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  margin-bottom: 12px;
  text-align: center;
}

.info-bar.offline {
  background: #d1ecf1;
  color: #0c5460;
}

.back-link {
  display: flex;
  width: fit-content;
  margin-left: auto;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  padding: 8px 16px;
  background: #fff;
  color: #4a90e2;
  border: 1.5px solid #4a90e2;
  border-radius: 20px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s, color 0.2s;
}

.back-link:hover {
  background: #4a90e2;
  color: #fff;
}

.back-link:active {
  opacity: 0.7;
}

.pamphlet-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.pamphlet-modal.active {
  display: flex;
  align-items: flex-end;
}

.pamphlet-modal-content {
  width: 100%;
  background: white;
  border-radius: 16px 16px 0 0;
  padding: 0;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15);
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

.pamphlet-modal-close {
  position: sticky;
  top: 12px;
  width: 44px;
  height: 44px;
  background: white;
  border: none;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-left: auto;
  margin-right: 16px;
}

.pamphlet-pdf-bar {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  text-align: center;
}

.pamphlet-pdf-open-btn {
  background: #4a90e2;
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.pamphlet-pdf-open-btn:hover {
  background: #357abd;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.pamphlet-pdf-open-btn:active {
  background: #2a5a99;
  transform: translateY(0);
}

.pamphlet-slider {
  position: relative;
  background: #f0f0f0;
  aspect-ratio: 8.5 / 11;
  overflow: visible;
}

.pamphlet-slider-container {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
  z-index: 0;
}

.pamphlet-slides {
  display: flex;
  height: 100%;
  transition: transform 0.3s ease-out;
}

.pamphlet-slide {
  min-width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f0f0;
}

.pamphlet-slide img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: white;
  cursor: pointer;
  transition: opacity 0.2s;
}

.pamphlet-slide img:hover {
  opacity: 0.8;
}

.pamphlet-slider-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 24px;
  cursor: pointer;
  z-index: 5;
  transition: background 0.2s;
}

.pamphlet-slider-btn:active {
  background: rgba(0, 0, 0, 0.7);
}

.pamphlet-slider-btn.prev {
  left: 8px;
}

.pamphlet-slider-btn.next {
  right: 8px;
}

.pamphlet-slide-counter {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.pamphlet-modal-info {
  padding: 20px;
}

.pamphlet-modal-info h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 12px;
  line-height: 1.4;
}


.pamphlet-modal-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.pamphlet-modal-badge {
  display: inline-block;
  background: #f0f7ff;
  color: #4a90e2;
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
}

.pamphlet-modal-code {
  font-size: 13px;
  color: #999;
}

.pamphlet-modal-specs {
  margin-bottom: 16px;
  padding: 12px;
  background: #f9f9f9;
  border-radius: 6px;
}

.pamphlet-modal-spec-item {
  font-size: 14px;
  color: #555;
  padding: 8px 0;
  border-bottom: 1px solid #eee;
}

.pamphlet-modal-spec-item:last-child {
  border-bottom: none;
}

.pamphlet-modal-spec-item:empty {
  display: none;
}

.pamphlet-modal-spec-label {
  font-weight: 600;
  color: #333;
  margin-right: 8px;
}

.pamphlet-modal-desc {
  font-size: 14px;
  color: #555;
  line-height: 1.6;
}

@media (max-width: 480px) {
  .pamphlet-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .pamphlet-info {
    padding: 10px;
  }

  .pamphlet-name {
    font-size: 13px;
  }

  .pamphlet-category {
    font-size: 11px;
    padding: 3px 7px;
  }

  .pamphlet-code {
    font-size: 11px;
  }

  .back-link {
    font-size: 13px;
    padding: 9px 16px;
  }

  .pamphlet-pdf-open-btn {
    font-size: 15px;
    padding: 12px 20px;
  }

  .pamphlet-modal-info {
    padding: 16px;
  }

  .pamphlet-modal-info h2 {
    font-size: 18px;
  }
}

/* PC/タブレット：画面幅に応じて自動で列数を増やす（カードは小さいまま多列に）。
   旧: 3列/4列固定。全幅表示のため撤去し auto-fill に統一（スマホ≤480は2列のまま）。 */
@media (min-width: 500px) {
  .pamphlet-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
  }
}

.pamphlet-fullscreen-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.pamphlet-fullscreen-modal.active {
  display: flex;
}

.pamphlet-fullscreen-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  width: auto;
  height: auto;
}

.pamphlet-fullscreen-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  background: #f0f0f0;
  border: none;
  border-radius: 50%;
  font-size: 24px;
  color: #999;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.pamphlet-fullscreen-close:active {
  background: rgba(255, 255, 255, 0.3);
}

@media print {
  .pamphlet-header {
    position: static;
  }

  .pamphlet-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }

  .pamphlet-card {
    page-break-inside: avoid;
  }
}

/* ===== 説明会モード（?present）=====
   大画面モニターに映しても、タブレット縦くらいの比率の「枠」に収めて表示する。
   通常の顧客・営業表示には一切影響しない（body.present-mode のときだけ有効）。
   sticky なヘッダー・fixed な下部バー・モーダル・全画面画像も同じフレーム幅に揃える。 */
body.present-mode {
  --frame-w: 800px;
  background: #f8f8f8;
  /* 枠外はごく薄いグレーのレターボックス */
}

/* ヘッダー・本文をフレーム幅に収めて中央寄せ */
body.present-mode .pamphlet-header,
body.present-mode .pamphlet-container {
  max-width: var(--frame-w);
  margin-left: auto;
  margin-right: auto;
}

/* 本文（一覧）はフレーム内を白背景にして端末画面のように見せる */
body.present-mode .pamphlet-container {
  background: #fff;
}

/* ヘッダー：端末上部のように影を付けてフレームを際立たせる */
body.present-mode .pamphlet-header {
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.2);
}

/* 下部バー：画面中央のフレーム幅に合わせる（全幅に伸ばさない） */
body.present-mode .bottom-bar {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--frame-w);
}

/* 一覧グリッド：モニター幅に関係なく3列で固定（大画面での4列化を防ぐ） */
body.present-mode .pamphlet-grid {
  grid-template-columns: repeat(3, 1fr);
}

/* 詳細モーダル：背景オーバーレイは全画面のまま、中身だけフレーム幅に収めて中央寄せ */
body.present-mode .pamphlet-modal.active {
  justify-content: center;
}

body.present-mode .pamphlet-modal-content {
  width: 100%;
  max-width: var(--frame-w);
}

/* 全画面画像：クリック拡大時も画面いっぱいに広げず、フレーム幅までに収める */
body.present-mode .pamphlet-fullscreen-image {
  max-width: var(--frame-w);
}

/* ===== 大画面(PC)の自動表示：一覧は画面全幅・モーダル/拡大画像だけ枠内 =====
   present-mode（?present の説明会モード）と違い、一覧（ヘッダー/本文/グリッド）は
   全幅のまま多列表示にする。モーダルと全画面画像だけ、画面いっぱいに広がらないよう枠幅に収める。 */
body.contain-modal {
  --frame-w: 800px;
}
body.contain-modal .pamphlet-modal.active {
  justify-content: center;
}
body.contain-modal .pamphlet-modal-content {
  width: 100%;
  max-width: var(--frame-w);
}
body.contain-modal .pamphlet-fullscreen-image {
  max-width: var(--frame-w);
}
