:root {
  --bg: #f3f4f6;
  --bg-1: #f3f4f6;
  --bg-2: #f3f4f6;
  --panel: rgba(255, 255, 255, 0.96);
  --panel-strong: rgba(255, 255, 255, 0.98);
  --ink: #111827;
  --muted: #6b7280;
  --accent: #0f766e;
  --accent-2: #14b8a6;
  --line: rgba(17, 24, 39, 0.08);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111827;
    --bg-1: #111827;
    --bg-2: #111827;
    --panel: rgba(31, 41, 55, 0.96);
    --panel-strong: rgba(31, 41, 55, 0.98);
    --ink: #f3f4f6;
    --muted: #9ca3af;
    --accent: #2dd4bf;
    --accent-2: #14b8a6;
    --line: rgba(255, 255, 255, 0.08);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.12);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  color: var(--ink);
  font-size: 16px;
  background: var(--bg);
}

body::before,
body::after {
  display: none;
}

header {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 14px 18px 12px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid rgba(17, 24, 39, 0.06);
  background: rgba(243, 244, 246, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: riseIn 0.45s ease both;
}

/* マップ上のローディングオーバーレイ（.layout直下） */
.map-loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(243, 244, 246, 0.85);
  z-index: 1100;
  pointer-events: auto;
  transition: opacity 0.3s ease;
}

.map-loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.map-loading-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  background: var(--panel-strong);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(16, 36, 61, 0.15);
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* マップ空状態メッセージ（.layout直下） */
.map-empty-state {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--panel-strong);
  padding: 18px 28px;
  border-radius: 14px;
  text-align: center;
  font-weight: 700;
  color: var(--muted);
  z-index: 1050;
  box-shadow: var(--shadow);
  pointer-events: none;
}

.map-empty-state p { margin: 0; }
.map-empty-hint { font-size: 13px; font-weight: 400; margin-top: 6px !important; }

/* overscroll防止（PWAでpull-to-refresh干渉回避） */
body, .side, main {
  overscroll-behavior: contain;
}

/* タップ応答改善: 300ms遅延除去 */
button, .card, .mobile-tab, .controls-toggle, .region-header, a {
  touch-action: manipulation;
}

/* Leaflet ポップアップ閉じるボタン拡大 */
.leaflet-popup-close-button {
  width: 32px !important;
  height: 32px !important;
  font-size: 22px !important;
  line-height: 32px !important;
  padding: 0 !important;
  right: 4px !important;
  top: 4px !important;
}

h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.01em;
  font-weight: 700;
}

.sub {
  margin-top: 5px;
  font-size: 14px;
  color: var(--muted);
}

#dateText {
  display: none;
}

.description {
  margin: 6px 0 0;
  font-size: 16px;
  color: var(--muted);
  line-height: 1.5;
}

.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 350px 1fr;
  height: calc(var(--vh, 1vh) * 100 - 74px);
  gap: 12px;
  padding: 12px;
}

.side {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: auto;
  animation: riseIn 0.5s ease both;
}

.controls,
.list {
  padding: 14px;
}

.list {
  content-visibility: auto;
  contain: layout style;
}

label,
input,
button {
  display: block;
  width: 100%;
}

label {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}

#nearbyBtn {
  margin-top: 8px;
  margin-bottom: 6px;
}

.reset-btn {
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  border: 1px solid var(--line);
  box-shadow: none;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 12px;
  margin-bottom: 10px;
}

.reset-btn:hover {
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  box-shadow: none;
  transform: none;
}

#nearbyBtn.active {
  background: #d97706;
  box-shadow: none;
}

.search-wrap {
  position: relative;
  margin-bottom: 12px;
}

#searchInput {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  margin-bottom: 0;
  font-size: 16px;
  background: var(--panel-strong);
  color: var(--ink);
}

#searchInput::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.autocomplete {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 0 0 12px 12px;
  box-shadow: 0 8px 20px rgba(16, 36, 61, 0.15);
  max-height: 200px;
  overflow-y: auto;
}

.autocomplete.hidden {
  display: none;
}

.ac-item {
  padding: 10px 12px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ac-item:hover {
  background: rgba(0, 93, 115, 0.08);
}

.ac-item:last-child {
  border-bottom: none;
}


/* Favorite button */


/* Map preset buttons overlay */
.map-presets {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;
  display: flex;
  gap: 4px;
}

.map-presets button {
  display: inline-block;
  width: auto;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: #374151;
  border: 1px solid #d1d5db;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  min-height: 0;
  transition: all 140ms ease;
}

.map-presets button:hover {
  background: white;
  border-color: #9ca3af;
  transform: none;
}

.map-presets button.active {
  background: rgba(15, 118, 110, 0.10);
  color: var(--accent);
  border-color: rgba(15, 118, 110, 0.28);
}

/* Skeleton loading cards */
.skeleton-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  background: var(--panel-strong);
}

.sk-line {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--line) 25%, rgba(255,255,255,0.5) 50%, var(--line) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  margin-bottom: 8px;
}

.sk-title {
  width: 75%;
  height: 18px;
}

.sk-meta {
  width: 60%;
}

.sk-meta.short {
  width: 40%;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.date-range {
  display: flex;
  align-items: end;
  gap: 6px;
  margin-top: 4px;
  margin-bottom: 8px;
}

.date-field {
  flex: 1;
  min-width: 0;
}

.date-field label {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 2px;
}

.date-separator {
  font-size: 16px;
  color: var(--muted);
  padding-bottom: 10px;
}

input[type="date"] {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 8px;
  font-size: 14px;
  background: var(--panel-strong);
  color: var(--ink);
  font-family: inherit;
}

.date-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.date-presets button {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
  background: #fff;
  color: #374151;
  border: 1px solid #d1d5db;
  box-shadow: none;
  width: auto;
  transition: all 140ms ease;
}

.date-presets button:hover {
  border-color: #9ca3af;
  background: #f9fafb;
  color: #374151;
  box-shadow: none;
}

.date-presets button.active {
  background: rgba(15, 118, 110, 0.10);
  color: var(--accent);
  border-color: rgba(15, 118, 110, 0.28);
}

input[type="text"],
input[type="number"] {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  margin-top: 6px;
  margin-bottom: 12px;
  font-size: 16px;
  background: var(--panel-strong);
  color: var(--ink);
}

input[type="checkbox"] {
  width: auto;
  display: inline;
  margin-right: 7px;
  accent-color: var(--accent-2);
}

button {
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--accent);
  color: white;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  cursor: pointer;
  box-shadow: none;
  transition: background-color 140ms ease, border-color 140ms ease, transform 120ms ease;
}

button:hover {
  background: var(--accent-2);
  transform: none;
  box-shadow: none;
}

button:active {
  transform: scale(0.98);
  box-shadow: none;
}

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.2);
}

button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.2);
}

input:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.2);
  border-color: var(--accent-2);
}

.card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
  background: var(--panel-strong);
  box-shadow: none;
  opacity: 1;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
  cursor: pointer;
}

.card:hover {
  border-color: #d1d5db;
  background: #fcfcfd;
  transform: translateY(-1px);
}

.card:nth-child(-n+8) {
  animation: cardIn 0.25s ease both;
  animation-delay: calc(var(--i, 0) * 20ms);
}

.card.highlight {
  background: rgba(15, 118, 110, 0.04);
  border-color: rgba(15, 118, 110, 0.28);
}

.card h3 {
  margin: 0 0 6px 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card a {
  color: var(--accent);
  font-weight: 700;
}

.day-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
  margin-right: 6px;
  vertical-align: middle;
  letter-spacing: 0.04em;
}

.day-badge.today {
  background: #e63946;
  color: white;
}

.day-badge.tomorrow {
  background: #f4a261;
  color: white;
}

.category-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 5px;
  margin-left: 4px;
  vertical-align: middle;
}

.category-tag.cat-story { background: rgba(233, 150, 122, 0.25); color: #a0522d; }
.category-tag.cat-craft { background: rgba(100, 149, 237, 0.25); color: #2e5090; }
.category-tag.cat-music { background: rgba(186, 85, 211, 0.25); color: #7b2d8e; }
.category-tag.cat-sports { background: rgba(50, 205, 50, 0.25); color: #2d7f2d; }
.category-tag.cat-baby { background: rgba(255, 182, 193, 0.35); color: #c44569; }
.category-tag.cat-food { background: rgba(255, 165, 0, 0.25); color: #b8860b; }
.category-tag.cat-nature { background: rgba(34, 139, 34, 0.25); color: #1a6b1a; }
.category-tag.cat-consultation { background: rgba(70, 130, 180, 0.25); color: #2e6d99; }

.no-map-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(63, 85, 109, 0.12);
  color: var(--muted);
  margin-left: 4px;
  vertical-align: middle;
}

.meta {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
  display: grid;
  gap: 2px;
}

.meta span,
.meta div {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta strong {
  color: var(--ink);
  font-weight: 600;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 12px;
}

.card-actions a {
  color: var(--accent);
  font-weight: 700;
}

.cal-btn, .route-btn {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  background: #fff;
  color: #374151;
  border: 1px solid #e5e7eb;
  text-decoration: none;
  transition: all 140ms ease;
}

.cal-btn:hover, .route-btn:hover {
  border-color: #9ca3af;
  background: #f9fafb;
}

.share-btn {
  width: auto;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  background: #fff;
  color: #374151;
  border: 1px solid #e5e7eb;
  box-shadow: none;
  min-height: 0;
  transition: all 140ms ease;
}

.share-btn:hover {
  border-color: #9ca3af;
  background: #f9fafb;
  color: #374151;
  transform: none;
  box-shadow: none;
}

#map {
  height: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: riseIn 0.56s ease both;
  contain: layout style;
}

.leaflet-popup-content-wrapper {
  border-radius: 10px !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
  padding: 0 !important;
}

.leaflet-popup-content {
  margin: 0 !important;
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", sans-serif;
}

.popup-content {
  padding: 14px 16px;
}

.popup-title {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.4;
  color: var(--ink);
  margin-bottom: 6px;
}

.popup-meta {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.popup-actions {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.popup-actions__row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.popup-action {
  min-height: 42px;
  border-radius: 8px;
  text-decoration: none !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  border: 1px solid transparent;
}

.popup-action svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.popup-action--primary {
  width: 100%;
  padding: 10px 12px;
  background: var(--accent) !important;
  color: #fff !important;
}

.popup-action--primary:hover,
.popup-action--primary:focus-visible {
  filter: brightness(0.92);
}

.popup-action--secondary {
  padding: 10px 8px;
  background: color-mix(in srgb, var(--accent) 10%, var(--bg)) !important;
  color: var(--ink) !important;
  border-color: color-mix(in srgb, var(--accent) 24%, var(--bg));
}

.popup-action--secondary:hover,
.popup-action--secondary:focus-visible {
  background: color-mix(in srgb, var(--accent) 18%, var(--bg)) !important;
}

.event-pin-wrap {
  background: transparent;
  border: 0;
}

.event-pin {
  width: 28px;
  height: 40px;
  display: block;
}

/* Region / prefecture filters */
.region-section {
  margin-top: 4px;
  margin-bottom: 4px;
}

.region-filter-title {
  font-size: 14px;
  font-weight: 700;
  color: #17324b;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.region-filter-title::-webkit-details-marker {
  display: none;
}

.region-filter-title::before {
  content: "\25B6";
  font-size: 10px;
  transition: transform 0.2s ease;
}

.region-section[open] > .region-filter-title::before {
  transform: rotate(90deg);
}

.region-bulk {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 9px;
  margin-top: 8px;
}

.region-bulk button {
  margin: 0;
  padding: 8px 10px;
  font-size: 14px;
}

.region-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 8px;
  overflow: hidden;
}

.region-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  cursor: pointer;
  list-style: none;
}

.region-header::-webkit-details-marker {
  display: none;
}

.region-header::after {
  content: "\25B6";
  font-size: 9px;
  margin-left: auto;
  transition: transform 0.2s ease;
  color: var(--muted);
}

.region-group[open] > .region-header::after {
  transform: rotate(90deg);
}

.region-header input[type="checkbox"] {
  margin: 0;
}

.region-header .region-count {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 2px;
}

.pref-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
  padding: 6px 8px 8px;
}

.pref-option {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 500;
  padding: 5px 6px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid transparent;
}

.pref-option input[type="checkbox"] {
  margin: 0;
}

.pref-option .pref-count {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  margin-left: auto;
  white-space: nowrap;
}

.pref-list-flat {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pref-list-flat .pref-option {
  flex: 0 0 auto;
}

.loading {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 10px;
}

.group-header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 8px 12px;
  margin: 0 -14px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.group-header:not(:first-child) {
  margin-top: 6px;
}

.controls > * {
  animation: fadeUp 0.36s ease both;
}

.controls > *:nth-child(1) {
  animation-delay: 0.05s;
}
.controls > *:nth-child(2) {
  animation-delay: 0.1s;
}
.controls > *:nth-child(3) {
  animation-delay: 0.15s;
}
.controls > *:nth-child(4) {
  animation-delay: 0.2s;
}
.controls > *:nth-child(5) {
  animation-delay: 0.25s;
}
.controls > *:nth-child(6) {
  animation-delay: 0.3s;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-color-scheme: dark) {
  body {
    background: var(--bg);
  }
  header { background: rgba(17, 24, 39, 0.88); }
  .side { background: var(--panel); }
  .card { background: var(--panel); border-color: var(--line); }
  .card:hover { background: rgba(31, 41, 55, 0.8); border-color: rgba(255, 255, 255, 0.12); }
  .card.highlight { background: rgba(45, 212, 191, 0.08); }
  .cal-btn, .route-btn, .share-btn { background: rgba(31, 41, 55, 0.8); color: var(--ink); border-color: var(--line); }
  .cal-btn:hover, .route-btn:hover, .share-btn:hover { background: rgba(55, 65, 81, 0.9); color: var(--ink); }
  .group-header { background: var(--bg); }
  input[type="date"], input[type="text"], input[type="number"], #searchInput {
    background: rgba(31, 41, 55, 0.9);
    color: var(--ink);
    border-color: var(--line);
  }
  .date-presets button, .reset-btn, .map-presets button {
    background: rgba(31, 41, 55, 0.8);
    color: var(--ink);
    border-color: var(--line);
  }
  .date-presets button.active, .map-presets button.active {
    background: rgba(45, 212, 191, 0.12);
    color: var(--accent);
    border-color: rgba(45, 212, 191, 0.3);
  }
  .popup-action--secondary {
    background: rgba(31, 41, 55, 0.8) !important;
    color: var(--ink) !important;
    border-color: var(--line) !important;
  }
  .popup-action--secondary:hover {
    background: rgba(55, 65, 81, 0.9) !important;
  }
  .autocomplete { background: var(--panel-strong); }
  .skeleton-card { background: var(--panel); }
  .sk-line { background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; }
  .region-header { background: rgba(45, 212, 191, 0.06); }
  .region-filter-title { color: var(--ink); }
  .pref-option { background: rgba(31, 41, 55, 0.65); border-color: var(--line); }
  .leaflet-popup-content-wrapper { background: var(--panel-strong) !important; }
  .popup-title { color: var(--ink); }
  .map-loading { background: rgba(17, 24, 39, 0.85); }
  .map-empty-state { background: var(--panel); }
  /* マップタイルをダークモードに合わせて減光 */
  .leaflet-tile-pane { filter: brightness(0.8) contrast(1.1) saturate(0.8); }
  .leaflet-control-zoom a { background: rgba(31, 41, 55, 0.9) !important; color: var(--ink) !important; border-color: var(--line) !important; }
  .locate-control a { background: rgba(31, 41, 55, 0.9) !important; color: var(--ink) !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* モバイルタブバー（デスクトップでは非表示） */
.mobile-tabs {
  display: none;
}

/* フィルター折りたたみ（デスクトップではトグル非表示） */
.controls-section {
  border: none;
}

.controls-toggle {
  display: none;
}

@media (max-width: 900px) {
  .mobile-tabs {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--panel-strong);
    border-top: 1px solid var(--line);
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -4px 16px rgba(16, 36, 61, 0.12);
  }

  .mobile-tab {
    flex: 1;
    border: none;
    border-radius: 0;
    padding: 14px 0;
    font-size: 15px;
    font-weight: 700;
    background: transparent;
    color: var(--muted);
    box-shadow: none;
    transition: color 0.15s ease, background 0.15s ease;
  }

  .mobile-tab:hover {
    transform: none;
    box-shadow: none;
  }

  .mobile-tab:active {
    transform: none;
    box-shadow: none;
  }

  .mobile-tab.active {
    color: var(--accent);
    background: transparent;
    border-bottom: 2px solid var(--accent);
  }

  header {
    padding: 10px 14px 8px;
  }

  h1 {
    font-size: 20px;
  }

  .description {
    display: none;
  }

  .layout {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0;
    /* Use flex-like fill instead of fragile fixed-px calc */
    height: calc(var(--vh, 1vh) * 100 - var(--header-h, 46px) - 48px - env(safe-area-inset-bottom, 0px));
  }

  .side {
    display: none;
    border-radius: 0;
    border-left: none;
    border-right: none;
    box-shadow: none;
  }

  .side.show {
    display: block;
    height: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  main {
    display: none;
  }

  main.show {
    display: block;
    height: 100%;
  }

  main.show #map {
    height: 100%;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }

  .controls-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
    cursor: pointer;
    list-style: none;
    border-bottom: 1px solid var(--line);
  }

  .controls-toggle::-webkit-details-marker {
    display: none;
  }

  .controls-toggle::before {
    content: "\25B6";
    font-size: 10px;
    transition: transform 0.2s ease;
  }

  .controls-section[open] > .controls-toggle::before {
    transform: rotate(90deg);
  }

  .controls-section[open] > .controls-toggle {
    border-bottom: 1px solid var(--line);
  }

  .controls-section:not([open]) > .controls-toggle {
    border-bottom: none;
  }

  .mobile-tab .tab-badge {
    font-size: 12px;
    font-weight: 400;
    opacity: 0.85;
  }

  /* タッチ最適化: 44px minimum tap target */
  button,
  input[type="date"] {
    min-height: 44px;
  }

  .date-presets button {
    padding: 10px 4px;
    font-size: 13px;
  }


  .map-presets {
    top: auto;
    bottom: 10px;
    right: 50%;
    transform: translateX(50%);
  }

  .map-presets button {
    padding: 8px 12px;
    min-height: 36px;
    font-size: 13px;
  }

  .pref-option {
    padding: 8px 6px;
    min-height: 44px;
  }

  .card {
    padding: 14px;
  }

  /* カード内リンク: タップ領域確保 */
  .card-actions a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 4px 0;
  }

  /* 日付inputが小画面で溢れない */
  .date-range {
    flex-wrap: wrap;
  }

  .date-field {
    min-width: 120px;
  }

  /* Leafletコントロールがタブバーと重ならない */
  .leaflet-bottom {
    bottom: 56px !important;
  }

  /* タブバー分の余白を確保（safe-area含む） */
  .list {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  }

  /* 現在地ボタン: 44px最小タップ領域 */
  .locate-control a {
    width: 44px !important;
    height: 44px !important;
    font-size: 22px !important;
  }
}

/* フッター免責事項 */
.site-footer {
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
  text-align: center;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}
.site-footer a {
  color: var(--accent);
  text-decoration: underline;
}

/* 横画面: ヘッダーを最小化して地図エリアを確保 */
@media (max-width: 900px) and (orientation: landscape) {
  header {
    padding-top: calc(4px + env(safe-area-inset-top, 0px));
    padding-bottom: 4px;
  }
  h1 { font-size: 16px; }
  .mobile-tab { padding: 8px 0; }
}

/* Footer area links for SEO */
.footer-area-links {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.footer-area-links h2 {
  font-size: 0.85em;
  color: var(--muted);
  margin: 0 0 10px;
  font-weight: 600;
}
.area-link-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}
.area-link-group {
  font-size: 0.78em;
  line-height: 1.8;
}
.area-link-group > a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.area-link-group > a:hover {
  text-decoration: underline;
}
.area-sub-links {
  margin-left: 2px;
}
.area-sub-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92em;
}
.area-sub-links a:hover {
  color: var(--accent);
  text-decoration: underline;
}
.area-sub-links a::before {
  content: "・";
  color: var(--line);
}
