:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --bg-2: #fbf9f4;
  --panel: #ffffff;
  --panel-alpha: rgba(255, 255, 255, 0.92);
  --text: #1f2a1f;
  --muted: #62705f;
  --accent: #1b8f7a;
  --accent-2: #e8894a;
  --border: #d8d1c5;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1412;
  --bg-2: #19201b;
  --panel: #1f2621;
  --panel-alpha: rgba(31, 38, 33, 0.92);
  --text: #eef2ea;
  --muted: #b7c1b2;
  --accent: #5bc4b5;
  --accent-2: #f2a05a;
  --border: #2b342e;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Zen Kaku Gothic New", "Hiragino Sans", sans-serif;
  background: radial-gradient(circle at top, var(--bg-2), var(--bg));
  color: var(--text);
  overflow-x: hidden;
}

.app {
  min-height: 100vh;
}

.map-screen {
  position: relative;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

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

#map.leaflet-container {
  background: #dfe7df;
}

[data-theme="dark"] #map {
  filter: brightness(0.75) contrast(1.1) saturate(1.1);
}

#center-pin {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  transform: translate(-50%, -100%);
  border-radius: 50% 50% 50% 0;
  background: var(--accent-2);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  z-index: 600;
  pointer-events: none;
  display: none;
}

#center-pin::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  background: #fff;
  border-radius: 50%;
  top: 6px;
  left: 6px;
}

.origin-badge {
  position: absolute;
  top: 56px;
  right: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 12px;
  z-index: 600;
}

.settings-button {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 700;
}

.overlay-controls {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 720px;
  margin: 0 auto;
  z-index: 500;
}

.panel-main {
  display: grid;
  gap: 12px;
}

.panel {
  background: var(--panel-alpha);
  border-radius: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.panel-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.standalone-controls {
  display: flex;
}

.standalone-controls > button {
  flex: 1;
}

.standalone-controls-inline {
  gap: 10px;
}

.standalone-controls #manual-button {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.gps-icon-button .icon {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 1.6;
  fill: none;
}

.gps-icon-button .gps-icon-wrap {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 44px;
  margin-left: auto;
}

.gps-icon-button .gps-label {
  display: inline-block;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  font-size: 12px;
  transition: max-width 0.2s ease, opacity 0.2s ease;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a.ghost {
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.standalone-controls button.gps-icon-button {
  padding: 0;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  flex: 0 0 44px;
  margin-left: auto;
  flex-direction: row;
  justify-content: flex-start;
  box-sizing: border-box;
  background: var(--panel);
  border-color: var(--border);
  border-radius: 10px;
  gap: 0;
  overflow: hidden;
  transition: width 0.2s ease, padding 0.2s ease;
}

.gps-icon-button.is-expanded {
  width: 200px;
  padding: 0 14px;
  gap: 8px;
  flex: 0 0 200px;
}

.gps-icon-button.is-expanded .gps-label {
  max-width: 160px;
  opacity: 1;
}

.icon-button {
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-alpha);
  color: var(--text);
  padding: 8px 12px;
  font-weight: 600;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

button.primary {
  background: var(--accent);
  box-shadow: none;
  color: #fff;
}

button.secondary {
  background: var(--panel);
  border-color: var(--border);
  color: var(--text);
}

button.ghost,
a.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

button:disabled,
.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.manual-controls p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.hidden {
  display: none;
}

.range-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.range-estimate {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.label {
  font-size: 12px;
  color: var(--muted);
}

.value {
  font-weight: 600;
  margin-left: 6px;
}

.range-slider {
  position: relative;
  height: 34px;
}

.range-slider input[type="range"] {
  position: absolute;
  left: 0;
  top: 8px;
  width: 100%;
  background: transparent;
  appearance: none;
  height: 0;
}

.range-slider input[type="range"]::-webkit-slider-runnable-track {
  background: transparent;
  height: 0;
}

.range-slider input[type="range"]::-moz-range-track {
  background: transparent;
  height: 0;
}

.range-slider input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  pointer-events: auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.range-slider input[type="range"]::-moz-range-thumb {
  pointer-events: auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.range-track {
  position: absolute;
  top: 16px;
  left: 0;
  right: 0;
  height: 6px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 999px;
}

.range-fill {
  position: absolute;
  top: 16px;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.form-row {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.form-row input[type="number"] {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.seg-button {
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
}

.seg-button.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

@media (max-width: 420px) {
  .segmented {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .seg-button {
    padding: 8px 10px;
    font-size: 14px;
  }

  .settings-window {
    width: calc(100vw - 24px);
    margin: 24px 12px;
  }

  .modal-header {
    padding: 12px;
  }

  .modal-body {
    padding: 12px;
  }

  .panel {
    padding: 12px;
  }

  .form-row input[type="number"] {
    width: 100%;
  }
}
.hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.note {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.status {
  min-height: 0;
  font-size: 12px;
  color: var(--muted);
  margin-top: 0;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.status:not(:empty) {
  min-height: 18px;
  margin-top: 6px;
}

.toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.toast.show {
  opacity: 1;
}

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

.modal.hidden {
  display: none;
}

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

.modal-window {
  position: relative;
  width: calc(100vw - 16px);
  margin: 16px 8px 24px;
  background: var(--panel);
  border-radius: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  max-height: 82vh;
  overflow: hidden;
  overflow-x: hidden;
  z-index: 1;
}

.settings-window {
  width: min(92vw, 720px);
  max-width: 720px;
  margin: 48px auto 24px;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}

.alert-window {
  width: min(88vw, 420px);
  margin-top: 120px;
}

.modal-text {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--text);
}

.modal-header {
  position: sticky;
  top: 0;
  background: var(--panel);
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 2;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  padding: 16px;
  display: grid;
  gap: 14px;
  max-height: calc(82vh - 64px);
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
}
