:root {
  --bg: #0b0f14;
  --panel: #141b24;
  --panel-2: #1a2430;
  --border: #2a3848;
  --text: #e8eef5;
  --muted: #8b9bb0;
  --accent: #3d9cf0;
  --danger: #e85d4c;
  --warn: #e6b84d;
  --ok: #3ecf8e;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --map-bottom-pad: 0px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

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

button {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
}

button.primary {
  background: var(--accent);
  border-color: transparent;
  color: #041018;
  font-weight: 600;
}

button.danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.9rem;
  background: linear-gradient(180deg, #121820, #0d1218);
  border-bottom: 1px solid var(--border);
  z-index: 5;
}

.app-header h1 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.app-header .sub {
  color: var(--muted);
  font-size: 0.75rem;
}

.header-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  min-height: 0;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }
  .panel {
    max-height: 48dvh;
    border-right: none;
    border-top: 1px solid var(--border);
  }
  .map-wrap {
    min-height: 52dvh;
    order: -1;
  }
}

.panel {
  overflow: auto;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 0.85rem;
}

.panel section {
  margin-bottom: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.panel h2 {
  margin: 0 0 0.55rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.55rem;
}

.field label {
  font-size: 0.8rem;
  color: var(--muted);
}

.field input,
.field select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
}

.field.row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.field.row input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.help {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.35;
}

.banner {
  background: rgba(230, 184, 77, 0.12);
  border: 1px solid rgba(230, 184, 77, 0.45);
  color: #f0d999;
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font-size: 0.78rem;
  line-height: 1.4;
  margin-bottom: 0.75rem;
}

.banner.danger {
  background: rgba(232, 93, 76, 0.12);
  border-color: rgba(232, 93, 76, 0.45);
  color: #f5b2aa;
}

.status {
  font-size: 0.8rem;
  color: var(--muted);
  min-height: 1.2em;
}

.status.ok {
  color: var(--ok);
}
.status.err {
  color: var(--danger);
}

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

.map-wrap.pick-mode #map {
  box-shadow: inset 0 0 0 3px rgba(61, 156, 240, 0.65);
}

#map {
  position: absolute;
  inset: 0;
}

.map-pick-banner {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 0.65rem;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  max-width: calc(100% - 1.2rem);
  background: rgba(12, 24, 40, 0.94);
  border: 1px solid var(--accent);
  color: var(--text);
  border-radius: 999px;
  padding: 0.45rem 0.55rem 0.45rem 0.9rem;
  font-size: 0.8rem;
  box-shadow: var(--shadow);
}

.map-pick-banner .banner-btn {
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: transparent;
  border-color: var(--border);
}

button.accent-outline {
  border-color: var(--accent);
  color: #9fd0ff;
}

button.accent-outline.active,
button#btn-pick-map.active {
  background: rgba(61, 156, 240, 0.2);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(61, 156, 240, 0.4);
}

.map-legend {
  position: absolute;
  z-index: 2;
  right: 0.6rem;
  bottom: 0.6rem;
  background: rgba(12, 16, 22, 0.88);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font-size: 0.72rem;
  line-height: 1.5;
  pointer-events: none;
}

.map-legend span {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 2px;
  margin-right: 0.35rem;
  vertical-align: middle;
}

.map-legend .fp-swatch {
  border-radius: 50%;
  background: #fff;
  border: 2px solid #e85d4c;
  box-sizing: border-box;
}

/* Draggable firing-point marker */
.fp-marker {
  width: 28px;
  height: 28px;
  position: relative;
  cursor: grab;
  touch-action: none;
}

.fp-marker:active {
  cursor: grabbing;
}

.fp-marker-dot {
  display: block;
  width: 18px;
  height: 18px;
  margin: 5px auto 0;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #e85d4c;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
}

.fp-marker-label {
  position: absolute;
  left: 50%;
  top: -14px;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: #e85d4c;
  padding: 0 4px;
  border-radius: 3px;
  line-height: 1.3;
  pointer-events: none;
  white-space: nowrap;
}

#coord-source {
  min-height: 1.1em;
  margin-bottom: 0.25rem;
  color: var(--accent);
}

.install-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.5rem 0.9rem;
  background: rgba(61, 156, 240, 0.12);
  border-bottom: 1px solid rgba(61, 156, 240, 0.35);
  font-size: 0.85rem;
}

.install-bar .primary {
  padding: 0.4rem 0.85rem;
}

.compass-panel {
  margin-top: 0.45rem;
  padding: 0.55rem 0.65rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

#compass-live {
  align-self: center;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.install-steps {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.install-steps li {
  margin-bottom: 0.4rem;
}

.install-steps strong {
  color: var(--text);
}

.warn-text {
  color: var(--warn);
  margin-top: 0.35rem;
  display: block;
  line-height: 1.35;
}

#ballistics-meta {
  margin-top: 0.45rem;
  line-height: 1.4;
}

#ballistic-load-info {
  margin: -0.25rem 0 0.55rem;
}

.subhead {
  margin: 0.75rem 0 0.4rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}

.risk-panel {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  line-height: 1.4;
}

.risk-list {
  margin: 0.35rem 0 0.5rem;
  padding-left: 1.1rem;
}

.risk-item {
  margin-bottom: 0.25rem;
}

.risk-item.danger-item {
  color: #f5a0a0;
}

.risk-kind {
  display: inline-block;
  font-size: 0.65rem;
  text-transform: uppercase;
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  margin-right: 0.25rem;
  background: var(--border);
}

.risk-kind.highway {
  background: rgba(255, 221, 0, 0.25);
  color: #ffe066;
}

.risk-kind.building {
  background: rgba(255, 102, 0, 0.25);
  color: #ffaa66;
}

.risk-kind.power {
  background: rgba(0, 229, 255, 0.2);
  color: #7aefff;
}

.ok-text {
  color: var(--ok);
}

/* Modal / onboarding */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-backdrop.hidden {
  display: none;
}

.modal {
  width: min(520px, 100%);
  max-height: 90dvh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.15rem 1.2rem;
}

.modal h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.modal p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.modal .actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.weather-chip {
  display: inline-flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--muted);
}

.weather-chip strong {
  color: var(--text);
  font-weight: 600;
}

.hidden {
  display: none !important;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.5rem;
}

/* MapLibre attribution contrast */
.maplibregl-ctrl-attrib {
  font-size: 10px !important;
}
