* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; font-family: -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif; }

#app { display: flex; flex-direction: column; height: 100%; }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: #1e293b;
  color: #fff;
  flex-wrap: wrap;
  gap: 8px;
}
header h1 { font-size: 16px; margin: 0; letter-spacing: -0.01em; }

.brand { display: flex; align-items: baseline; gap: 9px; }
.brand-by {
  font-size: 11.5px;
  font-style: italic;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: #7dd3fc;
  text-decoration: none;
  opacity: 0.85;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.brand-by:hover { opacity: 1; color: #bae6fd; text-decoration: underline; }

.mode-toggle { display: flex; align-items: center; gap: 14px; }

.switch-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #cbd5e1;
  cursor: pointer;
  user-select: none;
}
.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track {
  position: absolute;
  inset: 0;
  background: #475569;
  border-radius: 999px;
  transition: background 0.15s;
}
.switch-track::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s;
}
.switch input:checked + .switch-track { background: #2563eb; }
.switch input:checked + .switch-track::before { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid #93c5fd; outline-offset: 2px; }
.mode-btn {
  padding: 6px 12px;
  border: 1px solid #475569;
  background: #334155;
  color: #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.mode-btn.active { background: #2563eb; border-color: #2563eb; color: #fff; }

#main { flex: 1; display: flex; min-height: 0; }
#map { flex: 1; min-width: 0; }

.rect-select-btn {
  width: 29px;
  height: 29px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: none;
  cursor: pointer;
  color: #333333;
  padding: 0;
}
.rect-select-btn:hover { background: #f0f0f0; }
.rect-select-btn.active { background: #2563eb; color: #fff; }

/* 左パネル: 画像書き出し関連（メイン機能） */
#export-panel {
  width: 300px;
  flex-shrink: 0;
  padding: 16px;
  background: #f8fafc;
  border-right: 1px solid #e2e8f0;
  overflow-y: auto;
}

.section-label { font-size: 13px; font-weight: 600; color: #334155; margin: 0 0 8px; }
.section-desc { font-size: 12px; color: #64748b; line-height: 1.6; margin: -2px 0 12px; }

/* 「グリッドZIP用」「単体ダウンロード」を別々の機能として視覚的に区切るためのカード */
.panel-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 18px;
}

.grid-preview-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: linear-gradient(180deg, #eef2f8, #e2e8f0);
  overflow: hidden;
  cursor: ns-resize; /* ホイールで解像度を調整できることを示す */
  user-select: none;
}
.grid-preview-wrap.dragging { cursor: grabbing; }

.grid-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  will-change: transform;
}
/* srcが未設定の間はネイティブの壊れた画像アイコンを隠し、プレースホルダーだけ見せる */
.grid-preview:not([src]), .grid-preview[src=""] { display: none; }

.grid-preview-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: #94a3b8;
}
/* 画像にsrcがセットされたら、直後のプレースホルダーは隠す */
.grid-preview[src]:not([src=""]) + .grid-preview-placeholder { display: none; }

#grid-zoom {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  margin: 16px 0 14px;
  background: #cbd5e1;
  border-radius: 999px;
  cursor: pointer;
}
#grid-zoom::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #2563eb;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
  cursor: pointer;
}
#grid-zoom::-moz-range-track {
  background: #cbd5e1;
  height: 4px;
  border-radius: 999px;
}
#grid-zoom::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #2563eb;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
  cursor: pointer;
}
.grid-zoom-scale {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: #94a3b8;
}

.grid-plan { font-size: 12.5px; color: #64748b; margin: 8px 0 0; }
.grid-plan.warn { color: #dc2626; }
.grid-download .secondary-btn { margin-top: 8px; }

/* ダウンロードボタンを押すと「標準／高解像度」を選ぶミニメニューが下に出る */
.download-menu-wrap { position: relative; }
.download-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.18);
  overflow: hidden;
}
.download-menu-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-bottom: 1px solid #f1f5f9;
  background: #fff;
  color: #1e293b;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.download-menu-item:last-child { border-bottom: none; }
.download-menu-item:hover { background: #eff6ff; }

.bbox-nav {
  display: grid;
  grid-template-columns: repeat(3, 34px);
  grid-template-rows: repeat(3, 34px);
  gap: 4px;
  width: fit-content;
  margin: 0 auto;
}
.nav-btn {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.nav-btn:hover:not(:disabled) { background: #eff6ff; border-color: #93c5fd; }
.nav-btn:disabled { background: #f1f5f9; color: #cbd5e1; border-color: #e2e8f0; cursor: not-allowed; }
.nav-center {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 14px;
}

#generate-btn, .secondary-btn {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  color: #fff;
}
#generate-btn { background: linear-gradient(90deg, #fdba74 0%, #ea580c 100%); }
#generate-btn:disabled { background: #94a3b8; cursor: not-allowed; }

.secondary-btn { background: linear-gradient(90deg, #7dd3fc 0%, #2563eb 100%); margin-bottom: 16px; }
.secondary-btn:disabled { background: #94a3b8; cursor: not-allowed; }

/* PowerPoint関連の書き出しボタン（グリッドPPTX / PPTX生成）はパワポカラー（オレンジ系）で揃える */
#grid-pptx-download-btn { background: linear-gradient(90deg, #fdba74 0%, #ea580c 100%); }
#grid-pptx-download-btn:disabled { background: #94a3b8; cursor: not-allowed; }

/* 右パネル: 開閉式ドロワー（店舗カテゴリ・Google Maps・PowerPoint生成） */
#side-drawer {
  flex-shrink: 0;
  display: flex;
  background: #f8fafc;
  border-left: 1px solid #e2e8f0;
}
.drawer-toggle {
  width: 28px;
  flex-shrink: 0;
  border: none;
  border-right: 1px solid #e2e8f0;
  background: #eef2f7;
  color: #64748b;
  cursor: pointer;
  font-size: 12px;
}
.drawer-toggle:hover { background: #e2e8f0; }
.drawer-body {
  width: 0;
  overflow: hidden;
  transition: width 0.2s ease;
}
#side-drawer.open .drawer-body { width: 340px; }
/* 余白は子要素個別ではなくこのラッパーが一括で持つ（子ごとのCSS詳細度差で余白が欠けるのを防ぐ） */
.drawer-body-inner {
  width: 340px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

#gmaps h2, #category-panel h2 { font-size: 14px; margin: 0 0 8px; color: #334155; }
#category-panel { border-top: 1px solid #e2e8f0; }
.cat-group { margin-bottom: 4px; }
.cat-group summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  padding: 4px 0;
}
.cat-items-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 4px;
  padding-left: 10px;
}
.cat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  font-size: 13px;
  color: #334155;
  min-width: 0;
}
.cat-item input { cursor: pointer; flex-shrink: 0; }
.cat-item label { cursor: pointer; display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-item .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.legend-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; color: #1e293b; }
.legend-row .dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid #fff; box-shadow: 0 0 0 1px #94a3b8; flex-shrink: 0; }
#gmaps-list { font-size: 13px; color: #64748b; }
#gmaps-list a { color: #2563eb; text-decoration: none; }
#gmaps-list a:hover { text-decoration: underline; }

#status { min-height: 1.4em; font-size: 12.5px; color: #334155; white-space: pre-wrap; }
#status.error { color: #dc2626; }

.disclaimer { font-size: 11.5px; color: #94a3b8; line-height: 1.6; margin: 0; }
