/* リセット・ベース */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  font-size: 14px;
  color: #333;
  background: #f5f5f5;
}

/* レイアウト */
.app-container {
  display: flex;
  height: 100vh;
  width: 100%;
  position: relative;
}

/* サイドパネル */
.sidebar {
  width: 320px;
  background: #fff;
  border-right: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
  z-index: 20;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid #eee;
  background: #2563eb;
  color: #fff;
}

.sidebar-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-header h1 {
  font-size: 16px;
  font-weight: 700;
}

.home-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.home-link:hover {
  text-decoration: underline;
  opacity: 0.9;
}

.sidebar-header p {
  font-size: 12px;
  margin-top: 4px;
  opacity: 0.85;
}

.btn-guide {
  background: #fff;
  border: none;
  color: #2563eb;
  font-weight: 700;
  font-size: 14px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.btn-guide:hover {
  background: #dbeafe;
  transform: scale(1.1);
}

.sidebar-section {
  padding: 16px;
  border-bottom: 1px solid #eee;
}

.sidebar-section h2 {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #555;
}

/* 住所検索 */
.search-section {
  padding: 12px 16px;
}

.search-box {
  display: flex;
  gap: 6px;
}

.search-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}

.search-input:focus {
  border-color: #2563eb;
}

.search-btn {
  width: 36px;
  height: 36px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.search-btn:hover {
  background: #eff6ff;
  border-color: #2563eb;
}

.search-results {
  list-style: none;
  margin-top: 6px;
}

.search-results li {
  padding: 8px 10px;
  font-size: 12px;
  color: #333;
  border-radius: 4px;
  transition: background 0.1s;
  line-height: 1.4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.search-results li:hover {
  background: #f5f5f5;
}

.search-place-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.search-action-btn {
  width: 30px;
  height: 28px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.search-action-btn:hover {
  background: #eff6ff;
  border-color: #2563eb;
}

.search-results .search-no-result {
  color: #999;
  cursor: default;
  text-align: center;
  padding: 12px;
}

.search-results .search-no-result:hover {
  background: none;
  color: #999;
}

/* 地図スタイルセレクタ */
.style-select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s;
}

.style-select:focus {
  border-color: #2563eb;
}

/* モード切替ボタン */
.mode-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mode-btn {
  flex: 1;
  padding: 8px 6px;
  border: 2px solid #ddd;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  transition: all 0.2s;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.mode-icon {
  font-size: 18px;
  line-height: 1;
}

.mode-label {
  font-size: 11px;
}

.mode-btn:hover {
  border-color: #2563eb;
  color: #2563eb;
}

.mode-btn.active {
  border-color: #2563eb;
  background: #eff6ff;
  color: #2563eb;
}

/* アコーディオン */
.accordion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.accordion-header h2 {
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.accordion-arrow {
  font-size: 10px;
  color: #999;
  transition: transform 0.2s;
}

.accordion-body {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
}

.accordion-body.open {
  max-height: 5000px;
}

.accordion .accordion-header {
  margin-bottom: 0;
}

.accordion .accordion-body.open {
  margin-top: 12px;
}

.accordion-header:hover .accordion-arrow {
  color: #2563eb;
}

.accordion-body:not(.open) + .accordion-arrow,
.accordion-header:has(+ .accordion-body:not(.open)) .accordion-arrow {
  transform: rotate(-90deg);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: #e5e7eb;
  color: #555;
  font-size: 11px;
  font-weight: 700;
}

.badge.has-items {
  background: #2563eb;
  color: #fff;
}

.badge.at-limit {
  background: #dc2626;
  color: #fff;
}

.limit-label {
  font-size: 10px;
  color: #aaa;
  font-weight: 400;
  margin-left: 2px;
}

/* 全クリアボタン */
.clear-all-btn {
  width: 100%;
  padding: 6px;
  margin-top: 8px;
  border: 1px solid #fecaca;
  border-radius: 4px;
  background: #fff;
  color: #dc2626;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.clear-all-btn:hover {
  background: #fee2e2;
  border-color: #dc2626;
}

/* アイテムリスト */
.item-list {
  list-style: none;
}

.item-list li {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.item-list li:hover {
  background: #f9f9f9;
}

.empty-message {
  font-size: 12px;
  color: #999;
  text-align: center;
  padding: 20px 0;
}

/* 地図エリア */
.map-container {
  flex: 1;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
}

/* ステータスバー */
.status-bar {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 12px;
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 円リストアイテム */
.circle-item-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}

.circle-item-info span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.circle-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.circle-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.btn-icon {
  width: 28px;
  height: 28px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.btn-icon:hover {
  background: #f0f0f0;
  border-color: #bbb;
}

.btn-delete:hover {
  background: #fee2e2;
  border-color: #dc2626;
  color: #dc2626;
}

.btn-delete.disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-lock.locked {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #b45309;
}

/* 円エディタ */
.circle-editor {
  padding: 16px;
  border-bottom: 1px solid #eee;
  background: #f9fafb;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-weight: 700;
  font-size: 13px;
  color: #2563eb;
}

.editor-row {
  margin-bottom: 10px;
}

.editor-row label {
  display: block;
  font-size: 12px;
  color: #555;
  margin-bottom: 4px;
}

.editor-row input[type="range"] {
  width: 100%;
  accent-color: #2563eb;
}

/* 半径入力（スライダー+数値） */
.radius-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.radius-row input[type="range"] {
  flex: 1;
}

.radius-number-input {
  width: 70px;
  padding: 4px 6px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 12px;
  text-align: right;
  outline: none;
}

.radius-number-input:focus {
  border-color: #2563eb;
}

.radius-unit {
  font-size: 12px;
  color: #777;
  white-space: nowrap;
}

.label-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.label-input:focus,
.desc-input:focus {
  border-color: #2563eb;
}

.profile-select {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  outline: none;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s;
}

.profile-select:focus {
  border-color: #2563eb;
}

.desc-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  resize: vertical;
  transition: border-color 0.15s;
}

.editor-row input[type="color"] {
  width: 40px;
  height: 30px;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  padding: 2px;
}

/* 到達圏オプション */
.editor-divider {
  border-top: 1px dashed #ddd;
  margin: 12px 0 8px;
}

.iso-toggle-row {
  margin-bottom: 8px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #7c3aed;
  cursor: pointer;
}

.toggle-label input[type="checkbox"] {
  accent-color: #7c3aed;
  width: 16px;
  height: 16px;
}

.iso-options {
  padding-left: 4px;
}

.iso-badge {
  display: inline-block;
  background: #ede9fe;
  color: #7c3aed;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
}

/* 保存・共有 */
.save-section {
  border-top: 2px solid #eee;
  position: sticky;
  bottom: 0;
  background: #fff;
  z-index: 5;
}

.save-buttons-row {
  display: flex;
  gap: 8px;
}

.save-btn {
  flex: 1;
  padding: 12px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.save-btn:hover {
  background: #1d4ed8;
}

.save-btn:disabled {
  background: #93c5fd;
  cursor: not-allowed;
}

.new-map-btn {
  padding: 12px 14px;
  background: #fff;
  color: #2563eb;
  border: 2px solid #2563eb;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.new-map-btn:hover {
  background: #eff6ff;
}

.share-box {
  margin-top: 12px;
}

.share-box label {
  font-size: 12px;
  color: #555;
  display: block;
  margin-bottom: 4px;
}

.share-url-row {
  display: flex;
  gap: 6px;
}

.share-url-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 12px;
  background: #f9f9f9;
  outline: none;
  min-width: 0;
}

.copy-btn {
  padding: 6px 12px;
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.copy-btn:hover {
  background: #15803d;
}

.share-note {
  font-size: 11px;
  color: #888;
  margin-top: 6px;
}

/* フッターリンク */
.footer-links {
  position: fixed;
  bottom: 4px;
  left: 324px;
  z-index: 10;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.85);
  padding: 2px 8px;
  border-radius: 4px;
}

.footer-links a {
  color: #666;
  text-decoration: none;
}

.footer-links a:hover {
  color: #2563eb;
  text-decoration: underline;
}

.footer-sep {
  color: #ccc;
  margin: 0 4px;
}

/* ピンポップアップ */
.pin-popup .mapboxgl-popup-content {
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  max-width: 220px;
  line-height: 1.5;
}

.pin-popup .mapboxgl-popup-content strong {
  color: #333;
}

/* 操作ガイドモーダル */
.guide-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.guide-overlay.active {
  display: flex;
}

.guide-modal {
  background: #fff;
  border-radius: 12px;
  max-width: 480px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.guide-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 16px;
  border-bottom: 1px solid #eee;
}

.guide-header h2 {
  font-size: 18px;
  color: #2563eb;
}

.guide-body {
  padding: 20px 24px;
}

.guide-item {
  display: flex;
  gap: 14px;
  margin-bottom: 20px;
}

.guide-item:last-child {
  margin-bottom: 0;
}

.guide-step {
  width: 32px;
  height: 32px;
  background: #2563eb;
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.guide-item strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}

.guide-item p {
  font-size: 13px;
  color: #666;
  line-height: 1.6;
}

.guide-close-btn {
  display: block;
  width: calc(100% - 48px);
  margin: 0 24px 20px;
  padding: 12px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.guide-close-btn:hover {
  background: #1d4ed8;
}

/* モバイルメニューボタン */
.mobile-menu-btn {
  display: none;
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 15;
  width: 44px;
  height: 44px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.mobile-menu-btn:hover {
  background: #f5f5f5;
}

/* レスポンシブ（モバイル） */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
    position: relative;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 300px;
    height: 100vh;
    max-height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: none;
    z-index: 30;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.15);
  }

  .mobile-menu-btn {
    display: flex;
  }

  .mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 25;
  }

  .map-container {
    width: 100%;
    height: 100vh;
  }

  .status-bar {
    bottom: 20px;
    font-size: 11px;
    padding: 6px 14px;
  }

  .mode-btn {
    padding: 8px 6px;
    font-size: 12px;
  }

  .guide-modal {
    width: 95%;
    max-height: 85vh;
  }

  .footer-links {
    left: 8px;
  }
}
