:root {
  color-scheme: dark;
  --panel: rgba(9, 14, 13, 0.9);
  --panel-border: rgba(255, 255, 255, 0.14);
  --text: #f4f8f5;
  --muted: rgba(244, 248, 245, 0.64);
  --line: rgba(244, 248, 245, 0.16);
  --green: #35f29a;
  --red: #ff3f4c;
  --button: #f4f8f5;
  --button-text: #06100d;
}

* {
  box-sizing: border-box;
}

html,
body,
#app,
#map {
  width: 100%;
  height: 100%;
}

html {
  background: #050807;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #050807;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.leaflet-container {
  background: #050807;
  font-family: inherit;
}

.leaflet-control-zoom {
  display: none;
}

.leaflet-control-attribution {
  display: none !important;
}

.secret-hotspot {
  position: fixed;
  top: max(0px, env(safe-area-inset-top));
  right: max(0px, env(safe-area-inset-right));
  z-index: 20;
  width: 76px;
  height: 76px;
  border: 0;
  border-radius: 0;
  background: transparent;
  opacity: 0;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
}

.center-crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 15;
  width: 52px;
  height: 52px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.center-crosshair::before,
.center-crosshair::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.72);
}

.center-crosshair::before {
  top: 50%;
  left: -12px;
  width: 76px;
  height: 1px;
  transform: translateY(-50%);
}

.center-crosshair::after {
  top: -12px;
  left: 50%;
  width: 1px;
  height: 76px;
  transform: translateX(-50%);
}

#app.is-picking .center-crosshair {
  opacity: 1;
}

.settings-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(1px);
}

.settings-panel {
  position: fixed;
  right: 12px;
  bottom: 12px;
  left: 12px;
  z-index: 40;
  transform: translateY(calc(100% + 24px));
  display: grid;
  gap: 16px;
  max-height: min(82vh, 680px);
  overflow: auto;
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(18px) saturate(140%);
  transition: transform 220ms ease;
  -webkit-overflow-scrolling: touch;
}

.settings-panel.is-open {
  transform: translateY(0);
}

.panel-grip {
  justify-self: center;
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.3);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(22px, 5vw, 30px);
  line-height: 1.05;
  letter-spacing: 0;
}

.icon-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  font-size: 30px;
  line-height: 1;
}

.status-line {
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  font-size: 14px;
  line-height: 1.35;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.switch-row strong,
.switch-row small {
  display: block;
}

.switch-row strong {
  margin-bottom: 4px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.2;
}

.switch-row small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
}

.control-block {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.control-block > span {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.segmented-control button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
}

.segmented-control button.is-selected {
  color: var(--button-text);
  background: var(--button);
}

input[type="checkbox"] {
  position: relative;
  flex: 0 0 auto;
  width: 54px;
  height: 32px;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  appearance: none;
  background: rgba(255, 255, 255, 0.12);
  outline: none;
  transition:
    background 160ms ease,
    border-color 160ms ease;
}

input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.28);
  transition: transform 160ms ease;
}

input[type="checkbox"]:checked {
  border-color: rgba(53, 242, 154, 0.6);
  background: rgba(53, 242, 154, 0.56);
}

input[type="checkbox"]:checked::before {
  transform: translateX(22px);
}

.field-grid {
  display: grid;
  gap: 12px;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

input[type="datetime-local"],
input[type="number"] {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

input:focus-visible,
button:focus-visible {
  outline: 2px solid rgba(53, 242, 154, 0.9);
  outline-offset: 2px;
}

input:disabled {
  color: rgba(244, 248, 245, 0.48);
  background: rgba(255, 255, 255, 0.04);
}

input.is-invalid {
  border-color: rgba(255, 63, 76, 0.9);
}

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

.primary-button,
.ghost-button {
  min-height: 46px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  white-space: nowrap;
}

.primary-button {
  color: var(--button-text);
  background: var(--button);
}

.ghost-button {
  color: var(--text);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.07);
}

.button-row .primary-button {
  grid-column: 1 / -1;
}

.bracelet-marker {
  width: 190px !important;
  height: 54px !important;
  margin-left: -17px !important;
  margin-top: -27px !important;
  pointer-events: none;
}

.bracelet-dot {
  position: absolute;
  top: 18px;
  left: 8px;
  display: block;
  width: 18px;
  height: 18px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: var(--red);
  box-shadow:
    0 0 0 7px rgba(255, 63, 76, 0.18),
    0 0 24px rgba(255, 63, 76, 0.64);
}

.point-label {
  position: absolute;
  top: 50%;
  left: 38px;
  display: grid;
  gap: 1px;
  min-width: 92px;
  max-width: 142px;
  padding: 7px 10px;
  transform: translateY(-50%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: var(--text);
  background: rgba(7, 16, 13, 0.82);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(12px) saturate(125%);
}

.point-label strong,
.point-label small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.point-label strong {
  font-size: 14px;
  line-height: 1.1;
}

.point-label small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.15;
}

.bracelet-marker.is-live .point-label {
  border-color: rgba(53, 242, 154, 0.42);
}

.bracelet-marker.is-live .point-label small {
  color: rgba(53, 242, 154, 0.9);
}

.bracelet-marker.is-live .bracelet-dot {
  background: var(--green);
  box-shadow:
    0 0 0 8px rgba(53, 242, 154, 0.2),
    0 0 26px rgba(53, 242, 154, 0.74);
  animation: live-pulse 1200ms ease-out infinite;
}

@keyframes live-pulse {
  0% {
    box-shadow:
      0 0 0 0 rgba(53, 242, 154, 0.66),
      0 0 26px rgba(53, 242, 154, 0.74);
  }

  72% {
    box-shadow:
      0 0 0 20px rgba(53, 242, 154, 0),
      0 0 26px rgba(53, 242, 154, 0.58);
  }

  100% {
    box-shadow:
      0 0 0 0 rgba(53, 242, 154, 0),
      0 0 26px rgba(53, 242, 154, 0.74);
  }
}

@media (min-width: 720px) {
  .settings-panel {
    top: calc(18px + env(safe-area-inset-top));
    right: calc(18px + env(safe-area-inset-right));
    bottom: auto;
    left: auto;
    width: min(420px, calc(100vw - 36px));
    max-height: calc(100vh - 36px - env(safe-area-inset-top));
    transform: translateX(calc(100% + 36px));
    padding: 16px;
  }

  .settings-panel.is-open {
    transform: translateX(0);
  }

  .panel-grip {
    display: none;
  }

  .field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field-grid label:first-child {
    grid-column: 1 / -1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .settings-panel,
  .center-crosshair,
  input[type="checkbox"],
  input[type="checkbox"]::before {
    transition: none;
  }

  .bracelet-marker.is-live .bracelet-dot {
    animation: none;
  }
}
