:root {
  color-scheme: light;
  font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", sans-serif;
  background: #f6f7fb;
  color: #1f2937;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

.app-header {
  background: #111827;
  color: #f9fafb;
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.header-watermark {
  font-size: 11px;
  color: rgba(248, 250, 252, 0.7);
}

.license-note {
  font-size: 11px;
  color: rgba(248, 250, 252, 0.7);
}

.app-header h1 {
  margin: 0 0 6px;
  font-size: 22px;
}

.app-header p {
  margin: 0;
  font-size: 14px;
  opacity: 0.8;
}

.status {
  background: #1f2937;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
}

.app-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  padding: 16px;
}

.main-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel h2,
.panel h3 {
  margin: 0 0 8px;
}

.group {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.action-row button {
  flex: 1 1 calc(50% - 8px);
}

.inline-check {
  display: inline-flex;
  flex-wrap: nowrap;
}

.inline-check span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
label {
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

input[type="number"],
input[type="text"],
select,
input[type="file"] {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  font-size: 13px;
}

button {
  padding: 6px 10px;
  border-radius: 6px;
  border: none;
  background: #2563eb;
  color: #fff;
  cursor: pointer;
  font-size: 13px;
}

.icon-button {
  padding: 4px 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #2563eb;
}

.icon-button img {
  width: 18px;
  height: 18px;
  display: block;
}

.icon-button.active {
  background: #1d4ed8;
}

button.secondary {
  background: #6b7280;
}

button:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.distance-label {
  font-size: 12px;
  font-weight: 600;
  color: #1d4ed8;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(29, 78, 216, 0.4);
  border-radius: 8px;
  padding: 2px 6px;
}

.map-panel {
  min-height: 820px;
}

#map {
  flex: 1;
  min-height: 740px;
  border-radius: 12px;
  position: relative;
  overflow: hidden;
}

#profileChart {
  max-height: 240px;
}

.map-search {
  position: absolute;
  left: 60px;
  top: 12px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px;
  align-items: center;
  background: rgba(255, 255, 255, 0.9);
  padding: 6px;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
  z-index: 500;
}

.marker-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.35);
}

.marker-a {
  background: #2563eb;
}

.marker-b {
  background: #dc2626;
}

.marker-label {
  font-size: 12px;
  font-weight: 600;
  color: #111827;
}

.map-search input[type="text"] {
  min-width: 220px;
  font-size: 12px;
}

.map-search button {
  font-size: 12px;
  padding: 6px 10px;
}

.map-search-status {
  grid-column: 1 / -1;
  font-size: 11px;
  color: #4b5563;
}

.map-legend {
  display: flex;
  gap: 10px;
  font-size: 12px;
  color: #4b5563;
  flex-wrap: wrap;
}

.legend-note {
  font-size: 11px;
  color: #6b7280;
}

.legend-item::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-right: 6px;
  background: currentColor;
}

.legend-item:nth-child(1)::before {
  color: #2563eb;
}

.legend-item:nth-child(2)::before {
  color: #dc2626;
}

.legend-item:nth-child(3)::before {
  color: #b91c1c;
}

.map-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  background: #f9fafb;
  color: #6b7280;
  font-size: 13px;
  z-index: 0;
}

.map-ready .map-error {
  display: none;
}

.hint {
  font-size: 12px;
  color: #6b7280;
  margin: 0;
}

@media (max-width: 1200px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .map-panel {
    min-height: 400px;
  }
}

@media (max-width: 900px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-right {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
  }

  .row {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .map-search {
    left: 12px;
    right: 12px;
    grid-template-columns: 1fr auto auto;
  }

  button,
  input,
  select {
    min-height: 40px;
  }
}

@media (max-width: 640px) {
  .app-layout {
    padding: 12px;
  }

  .panel {
    padding: 12px;
  }

  .field-row {
    grid-template-columns: 96px 1fr auto;
  }

  .map-panel {
    min-height: 320px;
  }

  #map {
    min-height: 300px;
  }

  #profileChart {
    max-height: 220px;
  }

  .map-search {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    left: 8px;
    right: 8px;
    padding: 8px;
  }

  #mapSearchInput {
    grid-column: 1 / -1;
    min-width: 0;
    height: 36px;
    font-size: 14px;
  }

  #mapSearchButton,
  #locateMe {
    width: 100%;
    height: 34px;
    font-size: 11px;
    padding: 0 6px;
    white-space: nowrap;
  }
}
