:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #121419;
  --muted: #5f6672;
  --line: #d7dbe3;
  --accent: #101217;
  --accent-soft: #eceff4;
  --sgm: #2f8746;
  --fuj: #2d6cdf;
  --yok: #c32323;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "LINE Seed JP", "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  font-weight: 400;
}

code,
pre {
  font-family: "LINE Seed JP", "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
}

.layout {
  display: grid;
  grid-template-columns: 336px minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
  transition: grid-template-columns 0.2s ease;
}

.layout.panel-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.panel {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 18px;
  overflow: auto;
  min-width: 0;
  transition: opacity 0.2s ease, padding 0.2s ease, border-width 0.2s ease;
}

.layout.panel-collapsed .panel {
  opacity: 0;
  pointer-events: none;
  padding: 0;
  border-right-width: 0;
}

h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.08;
  letter-spacing: 0.01em;
  font-weight: 700;
}

.brand-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

h2 {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.3;
  letter-spacing: 0.01em;
  font-weight: 600;
}

.lead {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  font-weight: 500;
}

.lead-link {
  display: inline-block;
  text-decoration: none;
}

.lead-link:hover {
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

.repo-link {
  margin-top: 3px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  color: #6f7785;
  text-decoration: none;
  transition: color 0.15s ease, opacity 0.15s ease;
  opacity: 0.94;
}

.repo-link:hover {
  color: #4d5563;
  opacity: 1;
}

.repo-link-icon {
  fill: currentcolor;
  width: 12px;
  height: 12px;
}

.repo-link-label {
  font-size: 9px;
  line-height: 1;
  letter-spacing: 0.03em;
  font-weight: 500;
}

.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-top: 12px;
  background: #ffffff;
}

.ui-icon {
  fill: currentcolor;
  flex: 0 0 auto;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.section-header h2 {
  margin: 0;
}

.info-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  color: #7d8694;
  background: #f2f4f8;
  border: 1px solid #dbe1ea;
  cursor: default;
}

.tip-bubble {
  position: absolute;
  right: 0;
  top: calc(100% + 7px);
  z-index: 60;
  min-width: 210px;
  max-width: min(260px, 72vw);
  border-radius: 9px;
  background: #171b21;
  color: #f6f8fb;
  border: 1px solid #2c323f;
  box-shadow: 0 8px 24px rgba(14, 18, 26, 0.32);
  font-size: 11px;
  line-height: 1.45;
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 7px 8px;
  opacity: 0;
  transform: translateY(-3px);
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.info-tip:hover .tip-bubble {
  opacity: 1;
  transform: translateY(0);
}

.radio-group {
  margin: 0;
  border: 0;
  padding: 0;
  display: grid;
  gap: 7px;
}

.radio-group label {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: #1f2430;
}

.radio-group input[type="radio"] {
  margin: 0;
}

.checkbox-group {
  margin: 0;
  border: 0;
  padding: 0;
  display: grid;
  gap: 7px;
}

.checkbox-group label {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: #1f2430;
}

.checkbox-group input[type="checkbox"] {
  margin: 0;
}

.settings-grid {
  display: grid;
  gap: 10px;
}

.settings-row {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.settings-label {
  font-size: 12px;
  line-height: 1.35;
  color: #4d5665;
  font-weight: 600;
}

.settings-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.settings-value {
  font-size: 11px;
  color: #596273;
  font-weight: 600;
  min-width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.settings-select {
  width: 100%;
  min-height: 32px;
  border-radius: 8px;
  border: 1px solid #d3d9e4;
  background: #ffffff;
  color: #1f2530;
  padding: 5px 8px;
  font-size: 13px;
  line-height: 1.3;
  font-weight: 500;
}

.settings-accordion {
  border: 1px solid #dbe1ea;
  border-radius: 10px;
  padding: 6px 9px 9px;
  background: #fbfcfe;
}

.settings-accordion > summary {
  list-style: none;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.4;
  font-weight: 600;
  color: #1f2937;
}

.boundary-summary {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.boundary-summary-label {
  text-decoration: none;
}

.boundary-summary-tip {
  position: absolute;
  right: 0;
  top: calc(100% + 7px);
  z-index: 65;
  border-radius: 8px;
  background: #171b21;
  color: #f6f8fb;
  border: 1px solid #2c323f;
  box-shadow: 0 8px 24px rgba(14, 18, 26, 0.32);
  font-size: 11px;
  line-height: 1.35;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  padding: 6px 8px;
  opacity: 0;
  transform: translateY(-3px);
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.boundary-summary:hover .boundary-summary-label {
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

.boundary-summary:hover .boundary-summary-tip {
  opacity: 1;
  transform: translateY(0);
}

.settings-accordion > summary::-webkit-details-marker {
  display: none;
}

.settings-accordion[open] > summary {
  margin-bottom: 7px;
}

.settings-accordion .settings-row + .settings-row {
  margin-top: 6px;
}

.settings-accordion input[type="color"] {
  width: 44px;
  height: 28px;
  border: 1px solid #d3d9e4;
  border-radius: 7px;
  padding: 0;
  background: #ffffff;
}

input,
select,
button {
  font: inherit;
}

button {
  border: none;
  border-radius: 9px;
  padding: 8px 10px;
  cursor: pointer;
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
  transition: transform 0.1s ease, opacity 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

button.ghost {
  background: var(--accent-soft);
  color: #1e2530;
}

button.ghost.danger {
  color: #8e1f1f;
  border: 1px solid #e4c5c5;
  background: #fbf4f4;
}

#selected-count {
  margin: 0 0 8px;
  font-size: 13px;
  color: #232a35;
  font-weight: 600;
}

.section-tag {
  margin: 0 0 8px;
  font-size: 12px;
  color: #6b7380;
  font-weight: 600;
}

.depot-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.depot-sgm {
  background: #ebf5ef;
  color: #256337;
  border: 1px solid #c7dfcf;
}

.depot-fuj {
  background: #edf3ff;
  color: #224fa8;
  border: 1px solid #c9d8f4;
}

.depot-yok {
  background: #fef0f0;
  color: #9a3131;
  border: 1px solid #f1caca;
}

.depot-btn:hover {
  opacity: 0.96;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.history-row {
  margin-top: 10px;
}

#reset-all {
  width: 100%;
  margin-top: 8px;
}

.chips {
  display: grid;
  gap: 8px;
  min-height: 32px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
}

.chip {
  width: 100%;
  background: #f7f8fa;
  border: 1px solid #cdd3dc;
  color: #1f2929;
  padding: 8px 10px;
  border-radius: 12px;
  text-align: left;
  display: grid;
  gap: 2px;
  line-height: 1.35;
}

.chip-title {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
}

.chip-sub {
  font-size: 12px;
  font-weight: 500;
  color: #2d3748;
}

.chip-meta {
  font-size: 11px;
  font-weight: 500;
  color: #5b6472;
}

.map-wrap {
  position: relative;
  min-width: 0;
}

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

.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 1240;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.loading-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.loading-overlay.is-closing {
  opacity: 0;
}

.loading-card {
  min-width: min(480px, calc(100vw - 40px));
  max-width: min(560px, calc(100vw - 40px));
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid #d2d8e3;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 14px 36px rgba(9, 15, 26, 0.18);
  backdrop-filter: blur(4px);
}

.loading-title {
  margin: 0 0 8px;
  font-size: 13px;
  line-height: 1.4;
  font-weight: 700;
  color: #111827;
}

.loading-step {
  margin: 0;
  padding-left: 16px;
  position: relative;
  font-size: 12px;
  line-height: 1.55;
  font-weight: 500;
  color: #495566;
}

.loading-step + .loading-step {
  margin-top: 3px;
}

.loading-step::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.58em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8f99a7;
}

.loading-step.is-done {
  color: #1f4f38;
}

.loading-step.is-done::before {
  background: #2f8746;
}

.panel-toggle {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 1200;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: #0e1117;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.2);
}

.panel-toggle-icon {
  width: 16px;
  height: 16px;
  fill: currentcolor;
  color: #ffffff;
}

.panel-toggle-icon-collapsed {
  display: none;
}

.layout.panel-collapsed .panel-toggle-icon-expanded {
  display: none;
}

.layout.panel-collapsed .panel-toggle-icon-collapsed {
  display: inline-block;
}

.panel-backdrop {
  display: none;
  border: 0;
  margin: 0;
  padding: 0;
  background: rgba(8, 11, 18, 0.28);
  opacity: 0;
  pointer-events: none;
}

.panel-backdrop:hover,
.panel-backdrop:active {
  transform: none;
}

.legend {
  position: absolute;
  right: 12px;
  bottom: 12px;
  background: #fffffff4;
  border: 1px solid #d4d8e0;
  border-radius: 10px;
  padding: 10px 12px;
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.leaflet-container {
  font-family: "LINE Seed JP", "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  font-size: 13px;
}

.leaflet-popup-content {
  margin: 9px 10px;
  line-height: 1.5;
}

.popup-grid {
  display: grid;
  gap: 4px;
  font-size: 12px;
}

.popup-grid dt {
  color: #5a616c;
  font-weight: 500;
}

.popup-grid dd {
  margin: 0 0 4px;
  color: #0f1f2a;
  font-weight: 700;
}

.depot-pin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  height: 28px;
  padding: 0 10px;
  border-radius: 16px;
  border: 2px solid #ffffff;
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 0 0 2px #101827, 0 6px 14px rgba(0, 0, 0, 0.35);
}

.depot-pin.depot-sgm {
  background: var(--sgm);
}

.depot-pin.depot-fuj {
  background: var(--fuj);
}

.depot-pin.depot-yok {
  background: var(--yok);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  margin-right: 6px;
}

.dot.sgm {
  background: var(--sgm);
}

.dot.fuj {
  background: var(--fuj);
}

.dot.yok {
  background: var(--yok);
}

.dot.none {
  background: #aeb8c3;
}

.leaflet-interactive:focus,
.leaflet-container:focus,
.leaflet-container a:focus,
.leaflet-pane svg path:focus,
.leaflet-marker-icon:focus {
  outline: none !important;
}

.leaflet-zoom-box {
  display: none !important;
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr;
    min-height: 100dvh;
  }

  .layout.panel-collapsed {
    grid-template-columns: 1fr;
  }

  .panel {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(360px, 88vw);
    z-index: 1400;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    max-height: none;
    padding: calc(14px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom));
    box-shadow: 14px 0 28px rgba(8, 12, 20, 0.22);
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
    transition: transform 0.22s ease, opacity 0.2s ease;
    -webkit-overflow-scrolling: touch;
  }

  .layout.panel-collapsed .panel {
    transform: translateX(calc(-100% - 12px));
    opacity: 0;
    pointer-events: none;
    padding: calc(14px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom));
    border-right-width: 1px;
  }

  .map-wrap {
    min-height: 100dvh;
  }

  #map {
    height: 100dvh;
  }

  .panel-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1300;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.2s ease;
  }

  .layout.panel-collapsed .panel-backdrop {
    opacity: 0;
    pointer-events: none;
  }

  .panel-toggle {
    left: max(10px, calc(8px + env(safe-area-inset-left)));
    top: max(10px, calc(8px + env(safe-area-inset-top)));
    z-index: 1500;
    width: 42px;
    height: 42px;
    min-height: 42px;
    padding: 0;
  }

  .legend {
    right: max(8px, calc(8px + env(safe-area-inset-right)));
    bottom: max(8px, calc(8px + env(safe-area-inset-bottom)));
    max-width: min(72vw, 330px);
    font-size: 12px;
    gap: 5px;
  }

  button {
    min-height: 42px;
  }
}

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

  .layout.panel-collapsed {
    grid-template-columns: 1fr;
  }

  .panel {
    width: min(360px, 92vw);
    padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
  }

  .depot-actions {
    grid-template-columns: 1fr;
  }

  .row {
    grid-template-columns: 1fr;
  }

  .chip-title {
    font-size: 12px;
  }

  .chip-sub,
  .chip-meta {
    font-size: 11px;
  }

  .settings-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

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

  .settings-value {
    min-width: 32px;
  }
}
