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

html,
body {
  height: 100%;
}

body {
  font-family:
    system-ui,
    -apple-system,
    sans-serif;
}

.main {
  position: relative;
  height: 100%;
}

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

.map-title {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 1000;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #374151;
  text-shadow:
    0 1px 2px rgba(255, 255, 255, 0.9),
    0 -1px 2px rgba(255, 255, 255, 0.9),
    1px 0 2px rgba(255, 255, 255, 0.9),
    -1px 0 2px rgba(255, 255, 255, 0.9);
  pointer-events: none;
  margin: 0;
}

.status {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 1000;
  margin: 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.map-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-btn {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: #fff;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-btn--primary {
  background: #2563eb;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.modal-content {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  border-radius: 12px;
  background: #fff;
}

.modal-content h2 {
  margin-bottom: 16px;
  font-size: 18px;
}

.form-field {
  display: block;
  margin-bottom: 16px;
}

fieldset.form-field {
  border: none;
  padding: 0;
  margin: 0 0 16px;
  min-width: 0;
}

.form-field > span,
.form-field > legend {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
}

.form-field input[type="text"],
.form-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font: inherit;
}

.form-field input:disabled {
  background: #f3f4f6;
  color: #6b7280;
  cursor: not-allowed;
}

.icon-picker-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-selected {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #eff6ff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.icon-details {
  position: relative;
}

.icon-details summary {
  list-style: none;
  cursor: pointer;
}

.icon-details summary::-webkit-details-marker {
  display: none;
}

.icon-add-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #d1d5db;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: #6b7280;
}

.icon-details[open] .icon-add-btn {
  border-color: #2563eb;
  background: #2563eb;
  color: #fff;
}

.icon-hint {
  font-size: 12px;
  color: #9ca3af;
}

.icon-details .icon-picker-panel {
  position: absolute;
  top: 40px;
  left: 0;
  z-index: 10;
  width: 280px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.icon-details.is-locked .icon-add-btn {
  opacity: 0.4;
  pointer-events: none;
}

.icon-tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  padding: 8px 8px 0;
  border-bottom: 1px solid #f3f4f6;
}

.icon-tab {
  flex-shrink: 0;
  border: none;
  background: #f3f4f6;
  color: #6b7280;
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  margin-bottom: 8px;
}

.icon-tab.is-active {
  background: #2563eb;
  color: #fff;
}

.icon-grids {
  max-height: 220px;
  overflow-y: auto;
  padding: 10px;
}

.icon-emoji-grid {
  display: none;
  flex-wrap: wrap;
  gap: 4px;
}

.icon-emoji-grid.is-active {
  display: flex;
}

.icon-emoji-btn {
  width: 34px;
  height: 34px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #f9fafb;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-emoji-btn.is-selected {
  border-color: #2563eb;
  background: #eff6ff;
}

.timing-picker {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: #f3f4f6;
}

.timing-option {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  border-radius: 8px;
  font-size: 13px;
  color: #6b7280;
  cursor: pointer;
}

.timing-option input {
  display: none;
}

.timing-option.is-selected {
  background: #fff;
  color: #1f2937;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.form-error {
  margin-bottom: 12px;
  color: #dc2626;
  font-size: 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}

.btn--secondary {
  background: #e5e7eb;
}

.btn--primary {
  background: #2563eb;
  color: #fff;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ★変更：元投稿を独立したカードにする */
.original-card {
  background: #eff6ff;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 6px;
}

/* ★追加：アバター＋名前＋日時のヘッダー部分（元投稿・返信で共通） */
.post-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}

.post-card-avatar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.post-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.post-avatar--sm {
  width: 26px;
  height: 26px;
  font-size: 13px;
  background: #fff;
}

.post-card-name {
  font-size: 13px;
  font-weight: 600;
  color: #1f2937;
}

.post-card-time {
  font-size: 11px;
  color: #6b7280;
  margin-top: 1px;
}

/* ★変更：本文と日時の間の余白を広げる */
.post-card-body {
  font-size: 13px;
  line-height: 1.7;
  color: #374151;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ★追加：返信件数の見出し */
.replies-heading {
  font-size: 12px;
  color: #9ca3af;
  margin: 16px 0 8px 4px;
}

.detail-replies {
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-replies:empty {
  margin-bottom: 0;
}

/* ★変更：返信を独立したカードにする（インデント＋グレー背景） */
.reply-item {
  margin-left: 18px;
  background: #f9fafb;
  border-radius: 10px;
  padding: 10px 12px;
}

.reply-item .post-card-name {
  font-size: 12px;
}

.reply-item .post-card-time {
  font-size: 10px;
}

.reply-item .post-card-body {
  font-size: 12px;
}

.detail-replies-empty {
  color: #9ca3af;
  font-size: 13px;
  padding: 4px 4px 8px;
}

/* ★追加：返信フォームの区切り */
.reply-form-section {
  border-top: 1px solid #e5e7eb;
  padding-top: 14px;
  margin-top: 4px;
}

.reply-form-heading {
  font-size: 12px;
  color: #9ca3af;
  margin: 0 0 12px 2px;
}

.at-reply-btn {
  flex-shrink: 0;
  border: none;
  background: none;
  color: #2563eb;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
}

.leaflet-popup-content {
  white-space: pre-wrap;
  word-break: break-word;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.marker-cluster-small {
  background-color: rgba(37, 99, 235, 0.2);
}
.marker-cluster-small div {
  background-color: rgba(37, 99, 235, 0.55);
}

.marker-cluster-medium {
  background-color: rgba(37, 99, 235, 0.3);
}
.marker-cluster-medium div {
  background-color: rgba(37, 99, 235, 0.65);
}

.marker-cluster-large {
  background-color: rgba(37, 99, 235, 0.4);
}
.marker-cluster-large div {
  background-color: rgba(37, 99, 235, 0.75);
}

.marker-cluster div {
  color: #fff;
  font-weight: 600;
}

.legal-open-btn {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 900;
  border: none;
  background: rgba(255, 255, 255, 0.75);
  color: #6b7280;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.legal-sheet {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.legal-sheet[hidden] {
  display: none;
}

.legal-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.legal-sheet-panel {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  background: #fff;
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.legal-sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: #d1d5db;
  margin: 10px auto 4px;
  cursor: grab;
  touch-action: none;
}

.legal-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px 0;
  border-bottom: 1px solid #e5e7eb;
}

.legal-tab {
  flex: 1;
  border: none;
  background: none;
  padding: 10px 4px;
  font-size: 12px;
  color: #9ca3af;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.legal-tab.is-active {
  color: #2563eb;
  font-weight: 600;
  border-bottom-color: #2563eb;
}

.legal-body {
  padding: 16px 20px 24px;
  overflow-y: auto;
}

.legal-panel {
  display: none;
  font-size: 13px;
  line-height: 1.8;
  color: #374151;
}

.legal-panel.is-active {
  display: block;
}

.legal-panel h2 {
  font-size: 15px;
  margin-bottom: 10px;
  color: #1f2937;
}

.legal-panel h3 {
  font-size: 13px;
  margin: 16px 0 6px;
  color: #1f2937;
}

.legal-panel p {
  margin-bottom: 8px;
}

.legal-panel ul,
.legal-panel ol {
  margin: 0 0 8px 18px;
}

.legal-panel li {
  margin-bottom: 4px;
}

.operator-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.operator-table th,
.operator-table td {
  text-align: left;
  padding: 8px 4px;
  border-bottom: 1px solid #e5e7eb;
}

.operator-table th {
  width: 90px;
  color: #6b7280;
  font-weight: 500;
}

.post-preview-tooltip {
  background: #fff;
  border: none;
  border-radius: 12px;
  padding: 4px 12px;
  font-size: 12px;
  color: #374151;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  width: 120px;
  white-space: nowrap;
  overflow: visible;
  text-overflow: ellipsis;
  text-align: center;
}

.post-preview-tooltip::before {
  border-top-color: #fff;
  left: 45px;
}
