:root {
  color-scheme: dark light;
  --panel: rgba(21, 24, 28, 0.86);
  --panel-border: rgba(255, 255, 255, 0.14);
  --text: #f5f2ea;
  --muted: #b8b2a6;
  --active: #f0c66a;
  --active-text: #17191c;
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.26);
}

* {
  box-sizing: border-box;
}

html,
body,
.app-shell,
#map {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  background: #171b1f;
  color: var(--text);
}

button {
  font: inherit;
  letter-spacing: 0;
}

input {
  font: inherit;
  letter-spacing: 0;
}

.app-shell {
  position: relative;
}

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

.topbar {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.brand,
.view-switch,
.mode-switch,
.status {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.brand {
  min-width: 0;
  height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: auto;
}

.brand-mark {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border-radius: 4px;
  background:
    linear-gradient(135deg, #75c6d8 0 45%, transparent 45%),
    linear-gradient(315deg, #f0c66a 0 48%, #4f9d73 48%);
}

.mode-switch {
  min-width: 0;
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(64px, 1fr);
  gap: 4px;
  height: 42px;
  padding: 4px;
  border-radius: 8px;
  pointer-events: auto;
}

.view-switch {
  min-width: 0;
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(54px, 1fr);
  gap: 4px;
  height: 42px;
  padding: 4px;
  border-radius: 8px;
  pointer-events: auto;
}

.view-button {
  min-width: 0;
  height: 32px;
  border: 0;
  border-radius: 6px;
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.view-button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

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

.mode-button {
  min-width: 0;
  height: 32px;
  border: 0;
  border-radius: 6px;
  padding: 0 11px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.mode-button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

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

.hidden {
  display: none;
}

.satellite-panel {
  position: absolute;
  top: 66px;
  right: 14px;
  z-index: 3;
  width: min(360px, calc(100vw - 28px));
  color: var(--text);
  pointer-events: none;
}

.satellite-panel-toggle,
.satellite-panel-body {
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  pointer-events: auto;
}

.satellite-panel-toggle {
  width: 100%;
  height: 40px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  border-radius: 8px;
  cursor: pointer;
}

.satellite-panel-body {
  margin-top: 8px;
  padding: 12px;
}

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

.tool-button {
  height: 34px;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.tool-button:hover {
  background: rgba(255, 255, 255, 0.14);
}

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

.tool-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.field {
  min-width: 0;
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field.wide {
  margin-top: 10px;
}

.field input {
  min-width: 0;
  width: 100%;
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 0 9px;
  background: rgba(8, 10, 12, 0.5);
  color: var(--text);
  font-size: 12px;
  outline: none;
}

.field input:focus {
  border-color: rgba(240, 198, 106, 0.76);
}

.check-field {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.check-field input {
  width: 16px;
  height: 16px;
  accent-color: var(--active);
}

.progress-wrap {
  height: 8px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #75c6d8, #f0c66a);
  transition: width 180ms ease;
}

.satellite-job-status {
  min-height: 18px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.satellite-job-status.error {
  color: #ffd2c6;
}

.satellite-log {
  width: 100%;
  max-height: 132px;
  margin: 8px 0 0;
  overflow: auto;
  white-space: pre-wrap;
  color: #d9d5ca;
  font: 11px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.selection-box {
  position: absolute;
  z-index: 4;
  border: 2px solid var(--active);
  background: rgba(240, 198, 106, 0.18);
  box-shadow: 0 0 0 1px rgba(23, 25, 28, 0.7);
  pointer-events: none;
}

.status {
  position: absolute;
  left: 14px;
  bottom: 26px;
  z-index: 2;
  max-width: min(420px, calc(100vw - 28px));
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 8px 11px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.status.visible {
  opacity: 1;
  transform: translateY(0);
}

.status.error {
  color: #ffd2c6;
  border-color: rgba(255, 145, 121, 0.42);
}

.maplibregl-ctrl-group {
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.maplibregl-ctrl-scale {
  border-color: rgba(255, 255, 255, 0.5);
  color: #f5f2ea;
  background: rgba(21, 24, 28, 0.72);
}

@media (max-width: 560px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .brand,
  .view-switch,
  .mode-switch {
    width: 100%;
  }

  .view-switch,
  .mode-switch {
    grid-auto-columns: 1fr;
  }

  .satellite-panel {
    top: 166px;
    left: 14px;
    right: 14px;
    width: auto;
  }
}
